Ejemplo n.º 1
0
    def test_ideal2pixels(self):
        # Setup
        self.data_path = join(test.TEST_DATA_PATH, "calib_data")
        images_dir = join(self.data_path, "gimbal_camera")
        intrinsics_file = join(self.data_path, "static_camera.yaml")
        intrinsics = CameraIntrinsics(intrinsics_file)
        chessboard = Chessboard(nb_rows=6, nb_cols=7, square_size=0.29)
        self.data = PreprocessData("IMAGES",
                                   images_dir=images_dir,
                                   chessboard=chessboard,
                                   intrinsics=intrinsics)
        # Load test image
        image_path = join(self.data_path, "static_camera", "img_0.jpg")
        image = cv2.imread(image_path)

        # cv2.imshow("Image", image)
        # cv2.waitKey()

        # Detect chessboard corners
        chessboard = Chessboard(nb_rows=6, nb_cols=7, square_size=0.29)
        corners = chessboard.find_corners(image)

        # Convert points from ideal to pixel coordinates
        corners_ud = self.data.intrinsics.undistort_points(corners)
        self.data.intrinsics.undistort_image(image)
        K_new = self.data.intrinsics.K_new
        self.data.ideal2pixel(corners_ud, K_new)
    def test_undistort_points(self):
        # Load corners
        img_path = join(self.data_path, "gimbal_camera", "img_0.jpg")
        img = cv2.imread(img_path)
        chessboard = Chessboard(nb_rows=6, nb_cols=7, square_size=0.29)
        corners = chessboard.find_corners(img)

        # Undistort points using equidistant distortion model
        points = self.intrinsics.undistort_points(corners)
        self.assertEqual(len(points), len(corners))
        self.assertEqual(points.shape[0], len(corners))
        self.assertEqual(points.shape[1], 1)
        self.assertEqual(points.shape[2], 2)
Ejemplo n.º 3
0
    def __init__(self, **kwargs):
        self.data_path = kwargs.get("data_path")
        self.preprocessed = kwargs.get("preprocessed", False)
        self.inspect_data = kwargs.get("inspect_data", False)
        self.joint_file = kwargs["joint_file"]

        if self.preprocessed is False:
            self.image_dirs = kwargs["image_dirs"]
            self.intrinsic_files = kwargs["intrinsic_files"]
            self.chessboard = Chessboard(**kwargs)
        else:
            self.data_dirs = kwargs["data_dirs"]
            self.intrinsic_files = kwargs["intrinsic_files"]
Ejemplo n.º 4
0
    def test_load(self):
        # Setup
        self.data_path = join(test.TEST_DATA_PATH, "calib_data")
        images_dir = join(self.data_path, "gimbal_camera")
        intrinsics_file = join(self.data_path, "static_camera.yaml")
        intrinsics = CameraIntrinsics(intrinsics_file)
        chessboard = Chessboard(nb_rows=6, nb_cols=7, square_size=0.29)
        self.data = PreprocessData("IMAGES",
                                   images_dir=images_dir,
                                   chessboard=chessboard,
                                   intrinsics=intrinsics)

        # load data
        self.data.preprocess()
        self.assertTrue(len(self.data.images) > 0)
        self.assertTrue(len(self.data.images_ud) > 0)
Ejemplo n.º 5
0
    def __init__(self, intrinsics_file):
        self.intrinsics = CameraIntrinsics(intrinsics_file)

        # Chessboard
        self.chessboard = Chessboard(t_G=np.array([0.3, 0.1, 0.1]),
                                     nb_rows=11,
                                     nb_cols=11,
                                     square_size=0.02)
        self.plot_chessboard = PlotChessboard(chessboard=self.chessboard)

        # Gimbal
        self.gimbal = GimbalModel()
        self.gimbal.set_attitude([0.0, 0.0, 0.0])
        self.plot_gimbal = PlotGimbal(gimbal=self.gimbal)

        # Cameras
        self.static_camera = self.setup_static_camera()
        self.gimbal_camera = self.setup_gimbal_camera()
Ejemplo n.º 6
0
 def __init__(self, **kwargs):
     self.chessboard = kwargs.get("chessboard", Chessboard())