def onPlayToolClicked(self, event): if self.currentScan.inactive: #-- Resume self.enableLabelTool(self.pauseTool, True) self.enableLabelTool(self.playTool, False) self.currentScan.resume() self.pointCloudTimer.Start(milliseconds=50) else: result = True if self.sceneView._object is not None: dlg = wx.MessageDialog( self, _("Your current model will be erased.\nDo you really want to do it?" ), _("Clear Point Cloud"), wx.YES_NO | wx.ICON_QUESTION) result = dlg.ShowModal() == wx.ID_YES dlg.Destroy() if result: value = profile.getProfileSetting('scan_type') print value if value == _("Without Texture"): self.currentScan = self.simpleScan self.driver.camera.setExposure( profile.getProfileSettingInteger( 'laser_exposure_scanning')) elif value == _("With Texture"): self.currentScan = self.textureScan self.driver.camera.setExposure( profile.getProfileSettingInteger( 'color_exposure_scanning')) self.currentScan.setCallbacks( self.beforeScan, None, lambda r: wx.CallAfter(self.afterScan, r)) self.currentScan.start()
def onScanTypeComboBoxChanged(self, event): value = self.scanTypeDict[event.GetEventObject().GetValue()] profile.putProfileSetting('scan_type', value) if value == 'Simple Scan': self.driver.camera.setExposure(profile.getProfileSettingInteger('laser_exposure_scanning')) elif value == 'Texture Scan': self.driver.camera.setExposure(profile.getProfileSettingInteger('color_exposure_scanning'))
def onScanTypeComboBoxChanged(self, event): value = self.scanTypeDict[event.GetEventObject().GetValue()] profile.putProfileSetting('scan_type', value) if value == 'Simple Scan': self.driver.camera.setExposure( profile.getProfileSettingInteger('laser_exposure_scanning')) elif value == 'Texture Scan': self.driver.camera.setExposure( profile.getProfileSettingInteger('color_exposure_scanning'))
def setPatternDistance(self, patternDistance): profile.putProfileSetting('pattern_distance', patternDistance) patternRows = profile.getProfileSettingInteger('pattern_rows') patternColumns = profile.getProfileSettingInteger('pattern_columns') squareWidth = profile.getProfileSettingInteger('square_width') self.cameraIntrinsics.setPatternParameters(patternRows, patternColumns, squareWidth, patternDistance) self.simpleLaserTriangulation.setPatternParameters(patternRows, patternColumns, squareWidth, patternDistance) self.laserTriangulation.setPatternParameters(patternRows, patternColumns, squareWidth, patternDistance) self.platformExtrinsics.setPatternParameters(patternRows, patternColumns, squareWidth, patternDistance)
def setCurrentScan(self, value): if self.lastScan != value: self.lastScan = value self.parent.updateProfile() if not self.main.currentScan.run or self.main.currentScan.inactive: if value == 'Simple Scan': self.main.currentScan = self.simpleScan self.driver.camera.setExposure(profile.getProfileSettingInteger('laser_exposure_scanning')) elif value == 'Texture Scan': self.main.currentScan = self.textureScan self.driver.camera.setExposure(profile.getProfileSettingInteger('color_exposure_scanning')) else: print "Error: Can not change Scan Type"
def __init__(self, parent, name, engineCallback=None): """ """ SectionItem.__init__(self, parent, name, engineCallback) self.flagFirstMove = True #-- Elements self.label = wx.StaticText(self, label=self.setting.getLabel()) self.control = wx.Slider(self, wx.ID_ANY, profile.getProfileSettingInteger(self.name), int(eval(self.setting.getMinValue(), {}, {})), int(eval(self.setting.getMaxValue(), {}, {})), style=wx.SL_LABELS) #-- Layout hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(self.label, 0, wx.TOP|wx.RIGHT|wx.EXPAND, 20) hbox.Add(self.control, 1, wx.RIGHT|wx.EXPAND, 12) self.SetSizer(hbox) self.Layout() #-- Events self.control.Bind(wx.EVT_COMMAND_SCROLL_LINEUP, self.onSlider) self.control.Bind(wx.EVT_COMMAND_SCROLL_LINEDOWN, self.onSlider) self.control.Bind(wx.EVT_SCROLL_THUMBRELEASE, self.onSliderReleased) self.control.Bind(wx.EVT_SCROLL_THUMBTRACK, self.onSliderTracked)
def onScanFinished(self): self.buttonShowVideoViews.Hide() self.comboVideoViews.Hide() self.enableLabelTool(self.disconnectTool, True) self.enableLabelTool(self.playTool, True) self.enableLabelTool(self.stopTool, False) self.enableLabelTool(self.pauseTool, False) self.driver.camera.setExposure( profile.getProfileSettingInteger('exposure_scanning')) self.videoView.setMilliseconds(5) self.combo.Enable() self.GetParent().menuFile.Enable( self.GetParent().menuLaunchWizard.GetId(), True) self.GetParent().menuFile.Enable( self.GetParent().menuLoadModel.GetId(), True) self.GetParent().menuFile.Enable( self.GetParent().menuSaveModel.GetId(), True) self.GetParent().menuFile.Enable( self.GetParent().menuClearModel.GetId(), True) self.GetParent().menuFile.Enable( self.GetParent().menuOpenProfile.GetId(), True) self.GetParent().menuFile.Enable( self.GetParent().menuSaveProfile.GetId(), True) self.GetParent().menuFile.Enable( self.GetParent().menuResetProfile.GetId(), True) self.pointCloudTimer.Stop()
def __init__(self, parent, name, engineCallback=None): """ """ SectionItem.__init__(self, parent, name, engineCallback) self.flagFirstMove = True #-- Elements self.label = wx.StaticText(self, label=self.setting.getLabel()) self.control = wx.Slider(self, wx.ID_ANY, profile.getProfileSettingInteger(self.name), int(eval(self.setting.getMinValue(), {}, {})), int(eval(self.setting.getMaxValue(), {}, {})), size=(1, -1), style=wx.SL_LABELS) #-- Layout hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(self.label, 0, wx.TOP|wx.RIGHT|wx.EXPAND, 20) hbox.Add(self.control, 1, wx.RIGHT|wx.EXPAND, 12) self.SetSizer(hbox) self.Layout() #-- Events self.control.Bind(wx.EVT_COMMAND_SCROLL_LINEUP, self.onSlider) self.control.Bind(wx.EVT_COMMAND_SCROLL_LINEDOWN, self.onSlider) self.control.Bind(wx.EVT_SCROLL_THUMBRELEASE, self.onSliderReleased) self.control.Bind(wx.EVT_SCROLL_THUMBTRACK, self.onSliderTracked)
def updateDriverProfile(self): self.driver.camera.setCameraId( int(profile.getProfileSetting('camera_id')[-1:])) self.driver.board.setSerialName( profile.getProfileSetting('serial_name')) self.driver.board.setBaudRate( profile.getProfileSettingInteger('baud_rate'))
def initialize(self): self.fig = Figure(facecolor=(0.7490196,0.7490196,0.7490196,1), tight_layout=True) self.canvas = FigureCanvasWxAgg(self, -1, self.fig) self.canvas.SetExtraStyle(wx.EXPAND) self.ax = self.fig.gca(projection='3d', axisbg=(0.7490196,0.7490196,0.7490196,1)) # Parameters of the pattern self.rows = profile.getProfileSettingInteger('pattern_rows') self.columns = profile.getProfileSettingInteger('pattern_columns') self.squareWidth = profile.getProfileSettingInteger('square_width') self.printCanvas() self.Bind(wx.EVT_SIZE, self.onSize) self.Layout()
def onSliderTracked(self, event): if self.flagFirstMove: value = profile.getProfileSettingInteger(self.name) self.undoValues.append(value) if self.appendUndoCallback is not None: self.appendUndoCallback(self) self.flagFirstMove = False value = self.control.GetValue() profile.putProfileSetting(self.name, value) self._updateEngine(value)
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 onSlider(self, event): value = profile.getProfileSettingInteger(self.name) self.undoValues.append(value) if self.appendUndoCallback is not None: self.appendUndoCallback(self) value = self.control.GetValue() profile.putProfileSetting(self.name, value) self._updateEngine(value) if self.releaseUndoCallback is not None: self.releaseUndoCallback()
def onScanningPageNextClicked(self): self.driver.board.setLeftLaserOff() self.driver.board.setRightLaserOff() profile.saveProfile( os.path.join(profile.getBasePath(), 'current-profile.ini')) dlg = wx.MessageDialog( self, _("You have finished the wizard.\nPress Play button to start scanning." ), _("Ready to scan!"), wx.OK | wx.ICON_INFORMATION) result = dlg.ShowModal() == wx.ID_OK dlg.Destroy() if result: self.connectionPage.videoView.stop() self.calibrationPage.videoView.stop() self.scanningPage.videoView.stop() profile.putPreference('workbench', 'scanning') self.parent.updatePCGProfile() self.parent.updateCalibrationProfile() self.parent.workbenchUpdate() self.driver.camera.setExposure( profile.getProfileSettingInteger('exposure_scanning')) self.Destroy()
def updateProfileToAllControls(self): self.controls.updateProfile() self.driver.camera.setExposure( profile.getProfileSettingInteger('exposure_scanning'))
def updatePatternParameters(self): self.cameraIntrinsics.setPatternParameters(profile.getProfileSettingInteger('pattern_rows'), profile.getProfileSettingInteger('pattern_columns'), profile.getProfileSettingInteger('square_width'), profile.getProfileSettingFloat('pattern_distance')) self.simpleLaserTriangulation.setPatternParameters(profile.getProfileSettingInteger('pattern_rows'), profile.getProfileSettingInteger('pattern_columns'), profile.getProfileSettingInteger('square_width'), profile.getProfileSettingFloat('pattern_distance')) self.laserTriangulation.setPatternParameters(profile.getProfileSettingInteger('pattern_rows'), profile.getProfileSettingInteger('pattern_columns'), profile.getProfileSettingInteger('square_width'), profile.getProfileSettingFloat('pattern_distance')) self.platformExtrinsics.setPatternParameters(profile.getProfileSettingInteger('pattern_rows'), profile.getProfileSettingInteger('pattern_columns'), profile.getProfileSettingInteger('square_width'), profile.getProfileSettingFloat('pattern_distance'))
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 updateDriverProfile(self): self.driver.camera.setCameraId(int(profile.getProfileSetting('camera_id')[-1:])) self.driver.board.setSerialName(profile.getProfileSetting('serial_name')) self.driver.board.setBaudRate(profile.getProfileSettingInteger('baud_rate')) self.driver.board.setInvertMotor(profile.getProfileSettingBool('invert_motor'))
def updateProfile(self): if hasattr(self,'control'): value = profile.getProfileSettingInteger(self.name) self.update(value)
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'))