def getProfileSettings(self): self.distanceLeftValue = profile.getProfileSettingFloat( 'distance_left') self.normalLeftValues = profile.getProfileSettingNumpy('normal_left') self.distanceRightValue = profile.getProfileSettingFloat( 'distance_right') self.normalRightValues = profile.getProfileSettingNumpy('normal_right')
def updateCalibrationProfile(self): self.driver.camera.setIntrinsics( profile.getProfileSettingNumpy('camera_matrix'), profile.getProfileSettingNumpy('distortion_vector')) self.cameraIntrinsics.setIntrinsics( profile.getProfileSettingNumpy('camera_matrix'), profile.getProfileSettingNumpy('distortion_vector')) self.cameraIntrinsics.setPatternParameters( profile.getProfileSettingInteger('pattern_rows'), profile.getProfileSettingInteger('pattern_columns'), profile.getProfileSettingInteger('square_width'), profile.getProfileSettingFloat('pattern_distance')) self.cameraIntrinsics.setUseDistortion( profile.getProfileSettingInteger('use_distortion_calibration')) self.simpleLaserTriangulation.setIntrinsics( profile.getProfileSettingNumpy('camera_matrix'), profile.getProfileSettingNumpy('distortion_vector')) self.simpleLaserTriangulation.setPatternParameters( profile.getProfileSettingInteger('pattern_rows'), profile.getProfileSettingInteger('pattern_columns'), profile.getProfileSettingInteger('square_width'), profile.getProfileSettingFloat('pattern_distance')) self.simpleLaserTriangulation.setUseDistortion( profile.getProfileSettingInteger('use_distortion_calibration')) self.laserTriangulation.setIntrinsics( profile.getProfileSettingNumpy('camera_matrix'), profile.getProfileSettingNumpy('distortion_vector')) self.laserTriangulation.setPatternParameters( profile.getProfileSettingInteger('pattern_rows'), profile.getProfileSettingInteger('pattern_columns'), profile.getProfileSettingInteger('square_width'), profile.getProfileSettingFloat('pattern_distance')) self.laserTriangulation.setUseDistortion( profile.getProfileSettingInteger('use_distortion_calibration')) self.platformExtrinsics.setExtrinsicsStep( profile.getProfileSettingFloat('extrinsics_step')) self.platformExtrinsics.setIntrinsics( profile.getProfileSettingNumpy('camera_matrix'), profile.getProfileSettingNumpy('distortion_vector')) self.platformExtrinsics.setPatternParameters( profile.getProfileSettingInteger('pattern_rows'), profile.getProfileSettingInteger('pattern_columns'), profile.getProfileSettingInteger('square_width'), profile.getProfileSettingFloat('pattern_distance')) self.platformExtrinsics.setUseDistortion( profile.getProfileSettingInteger('use_distortion_calibration'))
def updatePCGProfile(self): self.pcg.resetTheta() self.pcg.setViewROI(profile.getMachineSettingBool('view_roi')) self.pcg.setROIDiameter(profile.getMachineSettingInteger('roi_diameter')) self.pcg.setROIWidth(profile.getMachineSettingInteger('roi_width')) self.pcg.setROIHeight(profile.getMachineSettingInteger('roi_height')) self.pcg.setROIDepth(profile.getMachineSettingInteger('roi_depth')) self.pcg.setDegrees(profile.getProfileSettingFloat('step_degrees_scanning')) resolution = profile.getProfileSetting('resolution_scanning') self.pcg.setResolution(int(resolution.split('x')[1]), int(resolution.split('x')[0])) useLaser = profile.getProfileSetting('use_laser') self.pcg.setUseLaser(useLaser == 'Left' or useLaser == 'Both', useLaser == 'Right' or useLaser == 'Both') self.pcg.setCameraIntrinsics(profile.getProfileSettingNumpy('camera_matrix'), profile.getProfileSettingNumpy('distortion_vector')) self.pcg.setLaserTriangulation(profile.getProfileSettingNumpy('distance_left'), profile.getProfileSettingNumpy('normal_left'), profile.getProfileSettingNumpy('distance_right'), profile.getProfileSettingNumpy('normal_right')) self.pcg.setPlatformExtrinsics(profile.getProfileSettingNumpy('rotation_matrix'), profile.getProfileSettingNumpy('translation_vector')) scanType = profile.getProfileSetting('scan_type') if scanType == 'Simple Scan': self.scanningWorkbench.currentScan = self.simpleScan self.driver.camera.setExposure(profile.getProfileSettingInteger('laser_exposure_scanning')) elif scanType == 'Texture Scan': self.scanningWorkbench.currentScan = self.textureScan self.driver.camera.setExposure(profile.getProfileSettingInteger('color_exposure_scanning')) self.simpleScan.setFastScan(profile.getProfileSettingBool('fast_scan')) self.simpleScan.setSpeedMotor(profile.getProfileSettingInteger('feed_rate_scanning')) self.simpleScan.setAccelerationMotor(profile.getProfileSettingInteger('acceleration_scanning')) self.simpleScan.setImageType(profile.getProfileSetting('img_type')) self.simpleScan.setUseThreshold(profile.getProfileSettingBool('use_cr_threshold')) self.simpleScan.setThresholdValue(profile.getProfileSettingInteger('cr_threshold_value')) self.simpleScan.setColor(struct.unpack('BBB',profile.getProfileSetting('point_cloud_color').decode('hex'))) self.textureScan.setFastScan(profile.getProfileSettingBool('fast_scan')) self.textureScan.setSpeedMotor(profile.getProfileSettingInteger('feed_rate_scanning')) self.textureScan.setAccelerationMotor(profile.getProfileSettingInteger('acceleration_scanning')) self.textureScan.setImageType(profile.getProfileSetting('img_type')) self.textureScan.setUseOpen(profile.getProfileSettingBool('use_open')) self.textureScan.setOpenValue(profile.getProfileSettingInteger('open_value')) self.textureScan.setUseThreshold(profile.getProfileSettingBool('use_threshold')) self.textureScan.setThresholdValue(profile.getProfileSettingInteger('threshold_value'))
def updateCalibrationProfile(self): self.driver.camera.setIntrinsics(profile.getProfileSettingNumpy('camera_matrix'), profile.getProfileSettingNumpy('distortion_vector')) self.cameraIntrinsics.setIntrinsics(profile.getProfileSettingNumpy('camera_matrix'), profile.getProfileSettingNumpy('distortion_vector')) self.cameraIntrinsics.setPatternParameters(profile.getProfileSettingInteger('pattern_rows'), profile.getProfileSettingInteger('pattern_columns'), profile.getProfileSettingInteger('square_width'), profile.getProfileSettingFloat('pattern_distance')) self.cameraIntrinsics.setUseDistortion(profile.getProfileSettingInteger('use_distortion_calibration')) self.simpleLaserTriangulation.setIntrinsics(profile.getProfileSettingNumpy('camera_matrix'), profile.getProfileSettingNumpy('distortion_vector')) self.simpleLaserTriangulation.setPatternParameters(profile.getProfileSettingInteger('pattern_rows'), profile.getProfileSettingInteger('pattern_columns'), profile.getProfileSettingInteger('square_width'), profile.getProfileSettingFloat('pattern_distance')) self.simpleLaserTriangulation.setUseDistortion(profile.getProfileSettingInteger('use_distortion_calibration')) self.laserTriangulation.setIntrinsics(profile.getProfileSettingNumpy('camera_matrix'), profile.getProfileSettingNumpy('distortion_vector')) self.laserTriangulation.setPatternParameters(profile.getProfileSettingInteger('pattern_rows'), profile.getProfileSettingInteger('pattern_columns'), profile.getProfileSettingInteger('square_width'), profile.getProfileSettingFloat('pattern_distance')) self.laserTriangulation.setUseDistortion(profile.getProfileSettingInteger('use_distortion_calibration')) self.platformExtrinsics.setExtrinsicsStep(profile.getProfileSettingFloat('extrinsics_step')) self.platformExtrinsics.setIntrinsics(profile.getProfileSettingNumpy('camera_matrix'), profile.getProfileSettingNumpy('distortion_vector')) self.platformExtrinsics.setPatternParameters(profile.getProfileSettingInteger('pattern_rows'), profile.getProfileSettingInteger('pattern_columns'), profile.getProfileSettingInteger('square_width'), profile.getProfileSettingFloat('pattern_distance')) self.platformExtrinsics.setUseDistortion(profile.getProfileSettingInteger('use_distortion_calibration'))
def updatePCGProfile(self): self.pcg.resetTheta() self.pcg.setViewROI(profile.getProfileSettingBool('view_roi')) self.pcg.setROIDiameter(profile.getProfileSettingInteger('roi_diameter')) self.pcg.setROIHeight(profile.getProfileSettingInteger('roi_height')) self.pcg.setDegrees(profile.getProfileSettingFloat('step_degrees_scanning')) resolution = profile.getProfileSetting('resolution_scanning') self.pcg.setResolution(int(resolution.split('x')[1]), int(resolution.split('x')[0])) useLaser = profile.getProfileSetting('use_laser') self.pcg.setUseLaser(useLaser == 'Left' or useLaser == 'Both', useLaser == 'Right' or useLaser == 'Both') self.pcg.setCameraIntrinsics(profile.getProfileSettingNumpy('camera_matrix'), profile.getProfileSettingNumpy('distortion_vector')) self.pcg.setLaserTriangulation(profile.getProfileSettingNumpy('distance_left'), profile.getProfileSettingNumpy('normal_left'), profile.getProfileSettingNumpy('distance_right'), profile.getProfileSettingNumpy('normal_right')) self.pcg.setPlatformExtrinsics(profile.getProfileSettingNumpy('rotation_matrix'), profile.getProfileSettingNumpy('translation_vector')) scanType = profile.getProfileSetting('scan_type') if scanType == 'Simple Scan': self.scanningWorkbench.currentScan = self.simpleScan self.driver.camera.setExposure(profile.getProfileSettingInteger('laser_exposure_scanning')) elif scanType == 'Texture Scan': self.scanningWorkbench.currentScan = self.textureScan self.driver.camera.setExposure(profile.getProfileSettingInteger('color_exposure_scanning')) self.simpleScan.setFastScan(profile.getProfileSettingBool('fast_scan')) self.simpleScan.setSpeedMotor(profile.getProfileSettingInteger('feed_rate_scanning')) self.simpleScan.setAccelerationMotor(profile.getProfileSettingInteger('acceleration_scanning')) self.simpleScan.setImageType(profile.getProfileSetting('img_type')) self.simpleScan.setUseThreshold(profile.getProfileSettingBool('use_cr_threshold')) self.simpleScan.setThresholdValue(profile.getProfileSettingInteger('cr_threshold_value')) self.simpleScan.setColor(struct.unpack('BBB',profile.getProfileSetting('point_cloud_color').decode('hex'))) self.textureScan.setFastScan(profile.getProfileSettingBool('fast_scan')) self.textureScan.setSpeedMotor(profile.getProfileSettingInteger('feed_rate_scanning')) self.textureScan.setAccelerationMotor(profile.getProfileSettingInteger('acceleration_scanning')) self.textureScan.setImageType(profile.getProfileSetting('img_type')) self.textureScan.setUseOpen(profile.getProfileSettingBool('use_open')) self.textureScan.setOpenValue(profile.getProfileSettingInteger('open_value')) self.textureScan.setUseThreshold(profile.getProfileSettingBool('use_threshold')) self.textureScan.setThresholdValue(profile.getProfileSettingInteger('threshold_value'))
def _start(self, progressCallback, afterCallback): XL = None XR = None if os.name == 'nt': flush = 2 else: flush = 1 if self.driver.isConnected: board = self.driver.board camera = self.driver.camera ##-- Switch off lasers board.setLeftLaserOff() board.setRightLaserOff() ##-- Setup motor step = 5 angle = 0 board.setSpeedMotor(1) board.enableMotor() board.setSpeedMotor(150) board.setAccelerationMotor(150) time.sleep(0.2) if progressCallback is not None: progressCallback(0) while self.isCalibrating and abs(angle) < 180: if progressCallback is not None: progressCallback(1.11 * abs(angle / 2.)) angle += step camera.setExposure( profile.getProfileSettingNumpy('exposure_calibration')) #-- Image acquisition imageRaw = camera.captureImage(flush=True, flushValue=flush) #-- Pattern detection ret = self.getPatternPlane(imageRaw) if ret is not None: step = 4 #2 d, n, corners = ret camera.setExposure( profile.getProfileSettingNumpy('exposure_calibration') / 2.) #-- Image laser acquisition imageRawLeft = camera.captureImage(flush=True, flushValue=flush) board.setLeftLaserOn() imageLeft = camera.captureImage(flush=True, flushValue=flush) board.setLeftLaserOff() self.image = imageLeft if imageLeft is None: break imageRawRight = camera.captureImage(flush=True, flushValue=flush) board.setRightLaserOn() imageRight = camera.captureImage(flush=True, flushValue=flush) board.setRightLaserOff() self.image = imageRight if imageRight is None: break #-- Pattern ROI mask imageRaw = self.cornersMask(imageRaw, corners) imageLeft = self.cornersMask(imageLeft, corners) imageRawLeft = self.cornersMask(imageRawLeft, corners) imageRight = self.cornersMask(imageRight, corners) imageRawRight = self.cornersMask(imageRawRight, corners) #-- Line segmentation uL, vL = self.getLaserLine(imageLeft, imageRawLeft) uR, vR = self.getLaserLine(imageRight, imageRawRight) #-- Point Cloud generation xL = self.getPointCloudLaser(uL, vL, d, n) if xL is not None: if XL is None: XL = xL else: XL = np.concatenate((XL, xL)) xR = self.getPointCloudLaser(uR, vR, d, n) if xR is not None: if XR is None: XR = xR else: XR = np.concatenate((XR, xR)) else: step = 5 self.image = imageRaw board.setRelativePosition(step) board.moveMotor() time.sleep(0.1) # self.saveScene('XL.ply', XL) # self.saveScene('XR.ply', XR) #-- Compute planes dL, nL, stdL = self.computePlane(XL, 'l') dR, nR, stdR = self.computePlane(XR, 'r') ##-- Switch off lasers board.setLeftLaserOff() board.setRightLaserOff() #-- Disable motor board.disableMotor() #-- Restore camera exposure camera.setExposure( profile.getProfileSettingNumpy('exposure_calibration')) if self.isCalibrating and nL is not None and nR is not None: response = (True, ((dL, nL, stdL), (dR, nR, stdR))) if progressCallback is not None: progressCallback(100) else: if self.isCalibrating: response = (False, Error.CalibrationError) else: response = (False, Error.CalibrationCanceled) self.image = None if afterCallback is not None: afterCallback(response)
def _start(self, progressCallback, afterCallback): XL = None XR = None if os.name=='nt': flush = 2 else: flush = 1 if self.driver.isConnected: board = self.driver.board camera = self.driver.camera ##-- Switch off lasers board.setLeftLaserOff() board.setRightLaserOff() ##-- Setup motor step = 5 angle = 0 board.setSpeedMotor(1) board.enableMotor() board.setSpeedMotor(150) board.setAccelerationMotor(150) time.sleep(0.2) if progressCallback is not None: progressCallback(0) while self.isCalibrating and abs(angle) < 180: if progressCallback is not None: progressCallback(1.11*abs(angle/2.)) angle += step camera.setExposure(profile.getProfileSettingNumpy('exposure_calibration')) #-- Image acquisition imageRaw = camera.captureImage(flush=True, flushValue=flush) #-- Pattern detection ret = self.getPatternPlane(imageRaw) if ret is not None: step = 4 #2 d, n, corners = ret camera.setExposure(profile.getProfileSettingNumpy('exposure_calibration')/2.) #-- Image laser acquisition imageRawLeft = camera.captureImage(flush=True, flushValue=flush) board.setLeftLaserOn() imageLeft = camera.captureImage(flush=True, flushValue=flush) board.setLeftLaserOff() self.image = imageLeft if imageLeft is None: break imageRawRight = camera.captureImage(flush=True, flushValue=flush) board.setRightLaserOn() imageRight = camera.captureImage(flush=True, flushValue=flush) board.setRightLaserOff() self.image = imageRight if imageRight is None: break #-- Pattern ROI mask imageRaw = self.cornersMask(imageRaw, corners) imageLeft = self.cornersMask(imageLeft, corners) imageRawLeft = self.cornersMask(imageRawLeft, corners) imageRight = self.cornersMask(imageRight, corners) imageRawRight = self.cornersMask(imageRawRight, corners) #-- Line segmentation uL, vL = self.getLaserLine(imageLeft, imageRawLeft) uR, vR = self.getLaserLine(imageRight, imageRawRight) #-- Point Cloud generation xL = self.getPointCloudLaser(uL, vL, d, n) if xL is not None: if XL is None: XL = xL else: XL = np.concatenate((XL,xL)) xR = self.getPointCloudLaser(uR, vR, d, n) if xR is not None: if XR is None: XR = xR else: XR = np.concatenate((XR,xR)) else: step = 5 self.image = imageRaw board.setRelativePosition(step) board.moveMotor() time.sleep(0.1) # self.saveScene('XL.ply', XL) # self.saveScene('XR.ply', XR) #-- Compute planes dL, nL, stdL = self.computePlane(XL, 'l') dR, nR, stdR = self.computePlane(XR, 'r') ##-- Switch off lasers board.setLeftLaserOff() board.setRightLaserOff() #-- Disable motor board.disableMotor() #-- Restore camera exposure camera.setExposure(profile.getProfileSettingNumpy('exposure_calibration')) if self.isCalibrating and nL is not None and nR is not None: response = (True, ((dL, nL, stdL), (dR, nR, stdR))) if progressCallback is not None: progressCallback(100) else: if self.isCalibrating: response = (False, Error.CalibrationError) else: response = (False, Error.CalibrationCanceled) self.image = None if afterCallback is not None: afterCallback(response)
def getProfileSettings(self): self.rotationValues = profile.getProfileSettingNumpy('rotation_matrix') self.translationValues = profile.getProfileSettingNumpy('translation_vector')
def getProfileSettings(self): self.coordinatesValues = profile.getProfileSettingNumpy('laser_coordinates') self.originValues = profile.getProfileSettingNumpy('laser_origin') self.normalValues = profile.getProfileSettingNumpy('laser_normal')
def getProfileSettings(self): self.distanceLeftValue = profile.getProfileSettingFloat('distance_left') self.normalLeftValues = profile.getProfileSettingNumpy('normal_left') self.distanceRightValue = profile.getProfileSettingFloat('distance_right') self.normalRightValues = profile.getProfileSettingNumpy('normal_right')
def getProfileSettings(self): self.cameraValues = profile.getProfileSettingNumpy('camera_matrix') self.distortionValues = profile.getProfileSettingNumpy('distortion_vector')