예제 #1
0
    def _button_raw_orient_fired(self):
        """
        update the external calibration with results of raw orientation, i.e.
        the iterative process that adjust the initial guess' external
        parameters (position and angle of cameras) without internal or
        distortions.

        See: https://github.com/openptv/openptv/liboptv/src/orientation.c#L591
        """
        if self.need_reset:
            self.reset_show_images()
            self.need_reset = 0

        # backup the ORI/ADDPAR files first
        self.backup_ori_files()

        # get manual points from cal_points and use ids from man_ori.par

        for i_cam in range(self.n_cams):
            selected_points = np.zeros((4, 3))
            for i, cp_id in enumerate(self.cal_points['id']):
                for j in range(4):
                    if cp_id == self.camera[i_cam].man_ori[j]:
                        selected_points[j, :] = self.cal_points['pos'][i, :]
                        continue

            # in pixels:
            manual_detection_points = np.array(
                (self.camera[i_cam]._x, self.camera[i_cam]._y)).T

            success = external_calibration(self.cals[i_cam], selected_points, \
                                           manual_detection_points, self.cpar)

            if success is False:
                print("Initial guess has not been successful\n")
            else:
                self.camera[i_cam]._plot.overlays = []
                self._project_cal_points(i_cam, color="red")
                self._write_ori(i_cam)

        self.status_text = "Orientation finished"
        self.pass_raw_orient = True
예제 #2
0
    def test_external_calibration(self):
        """External calibration using clicked points."""
        ref_pts = np.array([[-40., -25., 8.], [40., -15., 0.], [40., 15., 0.],
                            [40., 0., 8.]])

        # Fake the image points by back-projection
        targets = convert_arr_metric_to_pixel(
            image_coordinates(ref_pts, self.cal,
                              self.control.get_multimedia_params()),
            self.control)

        # Jigg the fake detections to give raw_orient some challenge.
        targets[:, 1] -= 0.1

        self.assertTrue(
            external_calibration(self.cal, ref_pts, targets, self.control))
        np.testing.assert_array_almost_equal(self.cal.get_angles(),
                                             self.orig_cal.get_angles(),
                                             decimal=4)
        np.testing.assert_array_almost_equal(self.cal.get_pos(),
                                             self.orig_cal.get_pos(),
                                             decimal=3)
예제 #3
0
 def test_external_calibration(self):
     """External calibration using clicked points."""
     ref_pts = np.array([
         [-40., -25., 8.],
         [ 40., -15., 0.],
         [ 40.,  15., 0.],
         [ 40.,   0., 8.]])
 
     # Fake the image points by back-projection
     targets = convert_arr_metric_to_pixel(image_coordinates(
         ref_pts, self.cal, self.control.get_multimedia_params()),
         self.control)
     
     # Jigg the fake detections to give raw_orient some challenge.
     targets[:,1] -= 0.1
     
     self.assertTrue(external_calibration(
         self.cal, ref_pts, targets, self.control))
     np.testing.assert_array_almost_equal(
         self.cal.get_angles(), self.orig_cal.get_angles(),
         decimal=4)
     np.testing.assert_array_almost_equal(
         self.cal.get_pos(), self.orig_cal.get_pos(),
         decimal=3)