Пример #1
0
    def __init__(self, image_task_q, event_q, config, settings,
                 imageprocessor):
        super(FSImageWorkerProcess, self).__init__(group=None)
        self.image_task_q = image_task_q
        self.settings = settings
        self.config = config
        self.exit = False
        self.event_q = event_q
        self.image = FSImage()

        self.log = logging.getLogger('IMAGE_PROCESSOR THREAD')
        self.log.setLevel(logging.DEBUG)
        self.image_processor = imageprocessor
        self._logger = logging.getLogger(__name__)
        self._logger.setLevel(logging.DEBUG)
Пример #2
0
    def _capture_scanner_calibration(self, position):

        image = self._capture_pattern()

        if (position > 577 and position < 1022):
            flags = cv2.CALIB_CB_FAST_CHECK | cv2.CALIB_CB_ADAPTIVE_THRESH | cv2.CALIB_CB_NORMALIZE_IMAGE
        else:
            flags = cv2.CALIB_CB_FAST_CHECK

        pose = self._imageprocessor.detect_pose(image, flags)
        plane = self._imageprocessor.detect_pattern_plane(pose)

        #self._logger.debug("Position: " + str(position))

        if plane is not None:

            distance, normal, corners = plane
            self._logger.debug("Pose detected...  ")
            # Laser triangulation ( Between 60 and 115 degree )
            # angel/(360/3200)
            try:
                #Laser Calibration
                if (position > 577 and position < 1022):
                    #self.settings.camera.contrast = 40
                    self.settings.camera.brightness = 70
                    self._hardwarecontroller.led.off()
                    for i in xrange(self.config.laser.numbers):
                        image = self._capture_laser(i)
                        image = self._imageprocessor.pattern_mask(image, corners)
                        self.image = image
                        fs_image = FSImage()
                        fs_image.save_image(image, position, "laser", dir_name="calibration")
                        points_2d, _ = self._imageprocessor.compute_2d_points(image, roi_mask=False, refinement_method='RANSAC')
                        point_3d = self._imageprocessor.compute_camera_point_cloud(
                            points_2d, distance, normal)
                        if self._point_cloud[i] is None:
                            self._point_cloud[i] = point_3d.T
                        else:
                            self._point_cloud[i] = np.concatenate(
                                (self._point_cloud[i], point_3d.T))
                    self.settings.camera.contrast = 40
                    self.settings.camera.brightness = 50

                # Platform extrinsics
                origin = corners[self.config.calibration.pattern.columns * (self.config.calibration.pattern.rows - 1)][0]
                origin = np.array([[origin[0]], [origin[1]]])
                t = self._imageprocessor.compute_camera_point_cloud(
                    origin, distance, normal)

            except StandardError, e:
                self._logger.error("Laser Capture Error: "+str(e))
                message = {
                    "message": "LASER_CALIBRATION_ERROR",
                    "level": "error"
                }
                self._eventmanager.broadcast_client_message(FSEvents.ON_INFO_MESSAGE, message)
                t = None

            if t is not None:
                self.x += [t[0][0]]
                self.y += [t[1][0]]
                self.z += [t[2][0]]

            else:
                self.image = image