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 add(self, args): R, t, center, point, normal, [x,y,z], circle = args # plot the surface, data, and synthetic circle self.ax.scatter(x, z, y, c='b', marker='o') #self.ax.scatter(center[0], center[2], center[1], c='b', marker='o') self.ax.plot(circle[0], circle[2], circle[1], c='r') d = profile.getProfileSettingFloat('pattern_distance') self.ax.plot([t[0],t[0]+50*R[0][0]], [t[2],t[2]+50*R[2][0]], [t[1],t[1]+50*R[1][0]], linewidth=2.0, color='red') self.ax.plot([t[0],t[0]+50*R[0][1]], [t[2],t[2]+50*R[2][1]], [t[1],t[1]+50*R[1][1]], linewidth=2.0, color='green') self.ax.plot([t[0],t[0]+d*R[0][2]], [t[2],t[2]+d*R[2][2]], [t[1],t[1]+d*R[1][2]], linewidth=2.0, color='blue') self.ax.plot([0,50], [0,0], [0,0], linewidth=2.0, color='red') self.ax.plot([0,0], [0,0], [0,50], linewidth=2.0, color='green') self.ax.plot([0,0], [0,50], [0,0], linewidth=2.0, color='blue') self.ax.set_xlabel('X') self.ax.set_ylabel('Z') self.ax.set_zlabel('Y') self.ax.set_xlim(-150, 150) self.ax.set_ylim(0, 400) self.ax.set_zlim(-150, 150) self.ax.invert_xaxis() self.ax.invert_yaxis() self.ax.invert_zaxis() self.canvas.draw() self.Layout()
def __init__(self): Calibration.__init__(self) self.criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 100, 0.001) self.image = None self.threshold = profile.getProfileSettingFloat( 'laser_threshold_value')
def onCalibrationButtonClicked(self, event): self.phase = 'laserTriangulation' self.laserTriangulation.setCallbacks(self.beforeCalibration, lambda p: wx.CallAfter(self.progressLaserCalibration,p), lambda r: wx.CallAfter(self.afterLaserCalibration,r)) if profile.getProfileSettingFloat('pattern_distance') == 0: PatternDistanceWindow(self) else: self.laserTriangulation.start()
def onCalibrationButtonClicked(self, event): self.phase = 'laserTriangulation' self.laserTriangulation.setCallbacks( self.beforeCalibration, lambda p: wx.CallAfter(self.progressLaserCalibration, p), lambda r: wx.CallAfter(self.afterLaserCalibration, r)) if profile.getProfileSettingFloat('pattern_distance') == 0: PatternDistanceWindow(self) else: self.laserTriangulation.start()
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 onPlatformExtrinsicsStartCallback(self): if profile.getProfileSettingFloat('pattern_distance') == 0: PatternDistanceWindow(self) self.updateProfileToAllControls() else: self.calibrating = True self.enableLabelTool(self.disconnectTool, False) self.controls.setExpandable(False) self.controls.panels['platform_extrinsics_panel'].buttonsPanel.Disable() self.combo.Disable() self.videoView.stop() self.videoView.Hide() self.platformExtrinsicsMainPage.Show() self.Layout()
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 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 __init__(self, parent): super(PatternDistanceWindow, self).__init__(parent, title=_('Pattern distance'), size=(420,-1), style=wx.DEFAULT_FRAME_STYLE^wx.RESIZE_BORDER) self.value = float(profile.getProfileSetting('pattern_distance')) self.cameraIntrinsics = calibration.CameraIntrinsics.Instance() self.simpleLaserTriangulation = calibration.SimpleLaserTriangulation.Instance() self.laserTriangulation = calibration.LaserTriangulation.Instance() self.platformExtrinsics = calibration.PlatformExtrinsics.Instance() #-- Elements self.description = wx.StaticText(self, label=_('Pattern distance value must be a number higher than 0. Please, change it in the textbox below.')) self.description.Wrap(400) tooltip = _("Minimum distance between the origin of the pattern (bottom-left corner) and the pattern's base surface") self.image = wx.Image(resources.getPathForImage("pattern-distance.jpg"), wx.BITMAP_TYPE_ANY) self.patternImage = wx.StaticBitmap(self, wx.ID_ANY, wx.BitmapFromImage(self.image)) self.patternImage.SetToolTip(wx.ToolTip(tooltip)) self.patternLabel = wx.StaticText(self, label=_('Pattern distance (mm)')) self.patternLabel.SetToolTip(wx.ToolTip(tooltip)) self.patternTextbox = wx.TextCtrl(self, value = str(profile.getProfileSettingFloat('pattern_distance'))) self.okButton = wx.Button(self, label=_('OK')) self.cancelButton = wx.Button(self, label=_('Cancel')) #-- Events self.patternTextbox.Bind(wx.EVT_TEXT, self.onTextBoxChanged) self.cancelButton.Bind(wx.EVT_BUTTON, self.onClose) self.okButton.Bind(wx.EVT_BUTTON, self.onOk) self.Bind(wx.EVT_CLOSE, self.onClose) #-- Layout vbox = wx.BoxSizer(wx.VERTICAL) vbox.Add(self.description, 0, wx.ALL|wx.CENTER, 10) vbox.Add(self.patternImage, 0, wx.ALL|wx.CENTER, 10) hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(self.patternLabel, 0, wx.ALL, 7) hbox.Add(self.patternTextbox, 0, wx.ALL, 3) hbox.Add(self.okButton, 0, wx.ALL, 3) hbox.Add(self.cancelButton, 0, wx.ALL, 3) vbox.Add(hbox, 0, wx.ALL|wx.CENTER, 10) self.SetSizer(vbox) self.Center() self.Fit() self.ShowModal()
def __init__(self, parent): super(SettingsWindow, self).__init__(parent, title=_('Settings'), size=(420, -1), style=wx.DEFAULT_FRAME_STYLE ^ wx.RESIZE_BORDER) self.driver = Driver.Instance() self.cameraIntrinsics = calibration.CameraIntrinsics.Instance() self.simpleLaserTriangulation = calibration.SimpleLaserTriangulation.Instance( ) self.laserTriangulation = calibration.LaserTriangulation.Instance() self.platformExtrinsics = calibration.PlatformExtrinsics.Instance() #-- Elements _choices = [] choices = profile.getProfileSettingObject('luminosity').getType() for i in choices: _choices.append(_(i)) self.initLuminosity = profile.getProfileSetting('luminosity') self.luminosityDict = dict(zip(_choices, choices)) self.luminosityText = wx.StaticText(self, label=_('Luminosity')) self.luminosityText.SetToolTip( wx.ToolTip( _('Change the luminosity until colored lines appear over the chess pattern in the video' ))) self.luminosityComboBox = wx.ComboBox(self, wx.ID_ANY, value=_(self.initLuminosity), choices=_choices, style=wx.CB_READONLY) invert = profile.getProfileSettingBool('invert_motor') self.invertMotorCheckBox = wx.CheckBox( self, label=_("Invert the motor direction")) self.invertMotorCheckBox.SetValue(invert) tooltip = _( "Minimum distance between the origin of the pattern (bottom-left corner) and the pattern's base surface" ) self.image = wx.Image( resources.getPathForImage("pattern-distance.jpg"), wx.BITMAP_TYPE_ANY) self.patternDistance = float( profile.getProfileSetting('pattern_distance')) self.patternImage = wx.StaticBitmap(self, wx.ID_ANY, wx.BitmapFromImage(self.image)) self.patternImage.SetToolTip(wx.ToolTip(tooltip)) self.patternLabel = wx.StaticText(self, label=_('Pattern distance (mm)')) self.patternLabel.SetToolTip(wx.ToolTip(tooltip)) self.patternTextbox = wx.TextCtrl( self, value=str(profile.getProfileSettingFloat('pattern_distance'))) self.okButton = wx.Button(self, label=_('OK')) self.cancelButton = wx.Button(self, label=_('Cancel')) #-- Events self.luminosityComboBox.Bind(wx.EVT_COMBOBOX, self.onLuminosityComboBoxChanged) self.invertMotorCheckBox.Bind(wx.EVT_CHECKBOX, self.onInvertMotor) self.patternTextbox.Bind(wx.EVT_TEXT, self.onTextBoxChanged) self.cancelButton.Bind(wx.EVT_BUTTON, self.onClose) self.okButton.Bind(wx.EVT_BUTTON, self.onOk) self.Bind(wx.EVT_CLOSE, self.onClose) #-- Layout vbox = wx.BoxSizer(wx.VERTICAL) hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(self.luminosityText, 0, wx.ALL, 7) hbox.Add(self.luminosityComboBox, 1, wx.ALL, 3) vbox.Add(hbox, 0, wx.ALL ^ wx.BOTTOM | wx.EXPAND, 7) vbox.Add(wx.StaticLine(self), 0, wx.ALL ^ wx.BOTTOM | wx.EXPAND, 10) hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(self.invertMotorCheckBox, 0, wx.ALL, 10) vbox.Add(hbox) vbox.Add(wx.StaticLine(self), 0, wx.ALL ^ wx.BOTTOM ^ wx.TOP | wx.EXPAND, 10) hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(self.patternLabel, 0, wx.ALL, 7) hbox.Add(self.patternTextbox, 1, wx.ALL, 3) vbox.Add(hbox, 0, wx.ALL ^ wx.BOTTOM | wx.EXPAND, 10) vbox.Add(self.patternImage, 0, wx.ALL | wx.CENTER, 10) hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(self.cancelButton, 1, wx.ALL, 3) hbox.Add(self.okButton, 1, wx.ALL, 3) vbox.Add(hbox, 0, wx.ALL | wx.EXPAND, 10) self.SetSizer(vbox) self.Center() self.Fit() self.ShowModal()
def _drawMachine(self): glEnable(GL_BLEND) machine = profile.getMachineSetting('machine_type') if machine.startswith('ciclop'): glEnable(GL_CULL_FACE) #-- Draw Platform if machine not in self._platformMesh: mesh = meshLoader.loadMesh( resources.getPathForMesh(machine + '_platform.stl')) if mesh is not None: self._platformMesh[machine] = mesh else: self._platformMesh[machine] = None self._platformMesh[machine]._drawOffset = numpy.array( [0, 0, 8.05], numpy.float32) glColor4f(0.6, 0.6, 0.6, 0.5) self._objectShader.bind() self._renderObject(self._platformMesh[machine]) self._objectShader.unbind() glDisable(GL_CULL_FACE) glDepthMask(False) size = numpy.array([ profile.getProfileSettingFloat('roi_diameter'), profile.getProfileSettingFloat('roi_diameter'), profile.getProfileSettingFloat('roi_height') ], numpy.float32) if profile.getProfileSettingBool('view_roi'): polys = profile.getSizePolygons(size) height = profile.getProfileSettingFloat('roi_height') circular = profile.getMachineSetting('machine_shape') == 'Circular' # Draw the sides of the build volume. glBegin(GL_QUADS) for n in xrange(0, len(polys[0])): if not circular: if n % 2 == 0: glColor4ub(5, 171, 231, 96) else: glColor4ub(5, 171, 231, 64) else: glColor4ub(5, 171, 231, 96) #glColor4ub(200, 200, 200, 150) glVertex3f(polys[0][n][0], polys[0][n][1], height) glVertex3f(polys[0][n][0], polys[0][n][1], 0) glVertex3f(polys[0][n - 1][0], polys[0][n - 1][1], 0) glVertex3f(polys[0][n - 1][0], polys[0][n - 1][1], height) glEnd() #Draw bottom and top of build volume. glColor4ub(5, 171, 231, 150) #128) #glColor4ub(200, 200, 200, 200) glBegin(GL_TRIANGLE_FAN) for p in polys[0][::-1]: glVertex3f(p[0], p[1], 0) glEnd() glBegin(GL_TRIANGLE_FAN) for p in polys[0][::-1]: glVertex3f(p[0], p[1], height) glEnd() #view center: center = self.getObjectCenterPos() quadric = gluNewQuadric() gluQuadricNormals(quadric, GLU_SMOOTH) gluQuadricTexture(quadric, GL_TRUE) glColor4ub(255, 0, 0, 255) #lower center: gluCylinder(quadric, 6, 6, 1, 32, 16) gluDisk(quadric, 0.0, 6, 32, 1) glTranslate(0, 0, height - 1) gluDisk(quadric, 0.0, 6, 32, 1) gluCylinder(quadric, 6, 6, 1, 32, 16) glTranslate(0, 0, -height + 1) polys = profile.getMachineSizePolygons() #-- Draw checkerboard if self._platformTexture is None: self._platformTexture = openglHelpers.loadGLTexture( 'checkerboard.png') glBindTexture(GL_TEXTURE_2D, self._platformTexture) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST) glColor4f(1, 1, 1, 0.5) glBindTexture(GL_TEXTURE_2D, self._platformTexture) glEnable(GL_TEXTURE_2D) glBegin(GL_TRIANGLE_FAN) for p in polys[0]: glTexCoord2f(p[0] / 20, p[1] / 20) glVertex3f(p[0], p[1], 0) glEnd() glDepthMask(True) glDisable(GL_BLEND)
def _drawMachine(self): glEnable(GL_BLEND) machine = profile.getMachineSetting('machine_type') if machine.startswith('ciclop'): glEnable(GL_CULL_FACE) #-- Draw Platform if machine not in self._platformMesh: mesh = meshLoader.loadMesh(resources.getPathForMesh(machine + '_platform.stl')) if mesh is not None: self._platformMesh[machine] = mesh else: self._platformMesh[machine] = None self._platformMesh[machine]._drawOffset = numpy.array([0,0,8.05], numpy.float32) glColor4f(0.6,0.6,0.6,0.5) self._objectShader.bind() self._renderObject(self._platformMesh[machine]) self._objectShader.unbind() glDisable(GL_CULL_FACE) glDepthMask(False) size = numpy.array([profile.getProfileSettingFloat('roi_diameter'), profile.getProfileSettingFloat('roi_diameter'), profile.getProfileSettingFloat('roi_height')], numpy.float32) if profile.getProfileSettingBool('view_roi'): polys = profile.getSizePolygons(size) height = profile.getProfileSettingFloat('roi_height') circular = profile.getMachineSetting('machine_shape') == 'Circular' # Draw the sides of the build volume. glBegin(GL_QUADS) for n in xrange(0, len(polys[0])): if not circular: if n % 2 == 0: glColor4ub(5, 171, 231, 96) else: glColor4ub(5, 171, 231, 64) else: glColor4ub(5, 171, 231, 96) #glColor4ub(200, 200, 200, 150) glVertex3f(polys[0][n][0], polys[0][n][1], height) glVertex3f(polys[0][n][0], polys[0][n][1], 0) glVertex3f(polys[0][n-1][0], polys[0][n-1][1], 0) glVertex3f(polys[0][n-1][0], polys[0][n-1][1], height) glEnd() #Draw bottom and top of build volume. glColor4ub(5, 171, 231, 150)#128) #glColor4ub(200, 200, 200, 200) glBegin(GL_TRIANGLE_FAN) for p in polys[0][::-1]: glVertex3f(p[0], p[1], 0) glEnd() glBegin(GL_TRIANGLE_FAN) for p in polys[0][::-1]: glVertex3f(p[0], p[1], height) glEnd() quadric=gluNewQuadric(); gluQuadricNormals(quadric, GLU_SMOOTH); gluQuadricTexture(quadric, GL_TRUE); glColor4ub(0, 100, 200, 150) gluCylinder(quadric,6,6,1,32,16); gluDisk(quadric, 0.0, 6, 32, 1); glTranslate(0,0,height-1) gluDisk(quadric, 0.0, 6, 32, 1); gluCylinder(quadric,6,6,1,32,16); glTranslate(0,0,-height+1) polys = profile.getMachineSizePolygons() #-- Draw checkerboard if self._platformTexture is None: self._platformTexture = openglHelpers.loadGLTexture('checkerboard.png') glBindTexture(GL_TEXTURE_2D, self._platformTexture) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST) glColor4f(1,1,1,0.5) glBindTexture(GL_TEXTURE_2D, self._platformTexture) glEnable(GL_TEXTURE_2D) glBegin(GL_TRIANGLE_FAN) for p in polys[0]: glTexCoord2f(p[0]/20, p[1]/20) glVertex3f(p[0], p[1], 0) glEnd() glDisable(GL_TEXTURE_2D) glDepthMask(True) glDisable(GL_BLEND)
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 __init__(self, parent): super(SettingsWindow, self).__init__(parent, title=_('Settings'), size=(420,-1), style=wx.DEFAULT_FRAME_STYLE^wx.RESIZE_BORDER) self.driver = Driver.Instance() self.cameraIntrinsics = calibration.CameraIntrinsics.Instance() self.simpleLaserTriangulation = calibration.SimpleLaserTriangulation.Instance() self.laserTriangulation = calibration.LaserTriangulation.Instance() self.platformExtrinsics = calibration.PlatformExtrinsics.Instance() #-- Elements _choices = [] choices = profile.getProfileSettingObject('luminosity').getType() for i in choices: _choices.append(_(i)) self.initLuminosity = profile.getProfileSetting('luminosity') self.luminosityDict = dict(zip(_choices, choices)) self.luminosityText = wx.StaticText(self, label=_('Luminosity')) self.luminosityText.SetToolTip(wx.ToolTip(_('Change the luminosity until colored lines appear over the chess pattern in the video'))) self.luminosityComboBox = wx.ComboBox(self, wx.ID_ANY, value=_(self.initLuminosity), choices=_choices, style=wx.CB_READONLY) invert = profile.getProfileSettingBool('invert_motor') self.invertMotorCheckBox = wx.CheckBox(self, label=_("Invert the motor direction")) self.invertMotorCheckBox.SetValue(invert) tooltip = _("Minimum distance between the origin of the pattern (bottom-left corner) and the pattern's base surface") self.image = wx.Image(resources.getPathForImage("pattern-distance.jpg"), wx.BITMAP_TYPE_ANY) self.patternDistance = float(profile.getProfileSetting('pattern_distance')) self.patternImage = wx.StaticBitmap(self, wx.ID_ANY, wx.BitmapFromImage(self.image)) self.patternImage.SetToolTip(wx.ToolTip(tooltip)) self.patternLabel = wx.StaticText(self, label=_('Pattern distance (mm)')) self.patternLabel.SetToolTip(wx.ToolTip(tooltip)) self.patternTextbox = wx.TextCtrl(self, value = str(profile.getProfileSettingFloat('pattern_distance'))) self.okButton = wx.Button(self, label=_('OK')) self.cancelButton = wx.Button(self, label=_('Cancel')) #-- Events self.luminosityComboBox.Bind(wx.EVT_COMBOBOX, self.onLuminosityComboBoxChanged) self.invertMotorCheckBox.Bind(wx.EVT_CHECKBOX, self.onInvertMotor) self.patternTextbox.Bind(wx.EVT_TEXT, self.onTextBoxChanged) self.cancelButton.Bind(wx.EVT_BUTTON, self.onClose) self.okButton.Bind(wx.EVT_BUTTON, self.onOk) self.Bind(wx.EVT_CLOSE, self.onClose) #-- Layout vbox = wx.BoxSizer(wx.VERTICAL) hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(self.luminosityText, 0, wx.ALL, 7) hbox.Add(self.luminosityComboBox, 1, wx.ALL, 3) vbox.Add(hbox, 0, wx.ALL^wx.BOTTOM|wx.EXPAND, 7) vbox.Add(wx.StaticLine(self), 0, wx.ALL^wx.BOTTOM|wx.EXPAND, 10) hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(self.invertMotorCheckBox, 0, wx.ALL, 10) vbox.Add(hbox) vbox.Add(wx.StaticLine(self), 0, wx.ALL^wx.BOTTOM^wx.TOP|wx.EXPAND, 10) hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(self.patternLabel, 0, wx.ALL, 7) hbox.Add(self.patternTextbox, 1, wx.ALL, 3) vbox.Add(hbox, 0, wx.ALL^wx.BOTTOM|wx.EXPAND, 10) vbox.Add(self.patternImage, 0, wx.ALL|wx.CENTER, 10) hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(self.cancelButton, 1, wx.ALL, 3) hbox.Add(self.okButton, 1, wx.ALL, 3) vbox.Add(hbox, 0, wx.ALL|wx.EXPAND, 10) self.SetSizer(vbox) self.Center() self.Fit() self.ShowModal()
def __init__(self): Calibration.__init__(self) self.criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 100, 0.001) self.image = None self.threshold = profile.getProfileSettingFloat('laser_threshold_value')