Esempio n. 1
0
    def startAnnotationPicker(self):

        view = robotSystem.view
        polyData = self.getPointCloud()
        self.picker = pointpicker.PointPicker(view, numberOfPoints=self.properties.getProperty('Number of points'), drawLines=True, callback=self.onAnnotationComplete, abortCallback=self.onAnnotationAborted)
        self.picker.annotationName = self.properties.getProperty('Annotation name')
        self.picker.annotationFolder = 'annotations'

        self.picker.pickType = 'points' if polyData.GetNumberOfCells() == polyData.GetNumberOfVerts() else 'render'

        self.aborted = False
        self.picker.start()
Esempio n. 2
0
    def __init__(self, robotSystem, cameraView):

        self.meshPoints = None
        self.imagePoints = None
        self.cameraView = cameraView

        self.robotMesh = vtk.vtkPolyData()
        robotSystem.robotStateModel.model.getModelMesh(self.robotMesh)
        self.robotBaseFrame = robotSystem.robotStateModel.getLinkFrame('base')

        self.view = PythonQt.dd.ddQVTKWidgetView()
        vis.showPolyData(self.robotMesh, 'robot mesh', view=self.view)

        self.imageFitter = ImageFitter(self)

        vis.showPolyData(self.imageFitter.getPointCloud(),
                         'pointcloud',
                         view=self.view,
                         colorByName='rgb_colors',
                         visible=False)

        self.picker = pointpicker.PointPicker(self.view)
        self.picker.pickType = 'cells'
        self.picker.numberOfPoints = 3
        self.picker.annotationName = 'mesh annotation'
        self.picker.annotationFunc = self.onPickPoints
        self.picker.start()

        self.widget = QtGui.QWidget()
        layout = QtGui.QHBoxLayout(self.widget)
        layout.addWidget(self.cameraView.view)
        layout.addWidget(self.view)
        self.widget.resize(800, 400)
        self.widget.setWindowTitle('Camera Alignment Tool')
        self.widget.show()

        self.viewBehaviors = viewbehaviors.ViewBehaviors(self.view)
        applogic.resetCamera(viewDirection=[0, 1, 0], view=self.view)
        applogic.setCameraTerrainModeEnabled(self.view, True)
    def __init__(self, cameraView, modelPolyData=None, pointCloud=None, resultsDict=None, visualize=True, callback=None):
        self.modelPolyData = modelPolyData
        self.pointCloud = pointCloud
        self.resultsDict = resultsDict
        self.visualize = visualize
        self.callback = callback
        self.parent = om.getOrCreateContainer('object alignment')

        self.meshPoints = None
        self.imagePoints = None
        self.cameraView = cameraView

        # viewer for the object
        self.view = PythonQt.dd.ddQVTKWidgetView()

        # add some special logic to show colors if they exist
        colorByName = 'RGB255'
        if not self.modelPolyData.GetPointData().GetArray(colorByName):
            colorByName = None
        vis.showPolyData(self.modelPolyData, 'object poly data', view=self.view,
                         parent=self.parent, colorByName=colorByName)

        self.imageFitter = ImageFitter(self, pointCloud)



        self.picker = pointpicker.PointPicker(self.view)
        self.picker.pickType = 'cells' # might need to change this
        self.picker.numberOfPoints = 3
        self.picker.annotationName = 'mesh annotation'
        self.picker.annotationFunc = self.onPickPoints
        self.picker.start()

        # viewer for the pointcloud
        self.sceneView = PythonQt.dd.ddQVTKWidgetView()
        vis.showPolyData(self.pointCloud, 'pointcloud', view=self.sceneView, colorByName='RGB', parent=self.parent)
        self.scenePicker = pointpicker.PointPicker(self.sceneView)
        self.scenePicker.pickType = 'points'  # might need to change this
        self.scenePicker.numberOfPoints = 3
        self.scenePicker.annotationName = 'pointcloud annotation'
        self.scenePicker.annotationFunc = self.onScenePickPoints
        self.scenePicker.start()

        # workaround bug in PointPicker implementation
        for name in [self.picker.annotationName, self.scenePicker.annotationName]:
            om.removeFromObjectModel(om.findObjectByName(name))

        self.widget = QtGui.QWidget()
        layout = QtGui.QHBoxLayout(self.widget)
        # layout.addWidget(self.cameraView.view)
        layout.addWidget(self.sceneView)
        layout.addWidget(self.view)
        # self.widget.resize(800, 400)
        self.widget.showMaximized()
        self.widget.setWindowTitle('Camera Alignment Tool')
        self.widget.show()

        self.viewBehaviors = viewbehaviors.ViewBehaviors(self.view)
        applogic.resetCamera(viewDirection=[0,1,0], view=self.view)
        applogic.setCameraTerrainModeEnabled(self.view, True)

        self.sceneViewBehaviors = viewbehaviors.ViewBehaviors(self.sceneView)
        applogic.resetCamera(viewDirection=[0, 1, 0], view=self.sceneView)
        applogic.setCameraTerrainModeEnabled(self.sceneView, True)