Example #1
0
def main():

    app = consoleapp.ConsoleApp()

    meshCollection = lcmobjectcollection.LCMObjectCollection(
        'MESH_COLLECTION_COMMAND')
    affordanceCollection = lcmobjectcollection.LCMObjectCollection(
        'AFFORDANCE_COLLECTION_COMMAND')

    meshCollection.sendEchoRequest()
    affordanceCollection.sendEchoRequest()

    def printCollection():
        print
        print '----------------------------------------------------'
        print datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
        print '%d affordances' % len(affordanceCollection.collection)
        for desc in affordanceCollection.collection.values():
            print
            print 'name:', desc['Name']
            print 'type:', desc['classname']

    timer = TimerCallback(targetFps=0.2)
    timer.callback = printCollection
    timer.start()

    #app.showPythonConsole()
    app.start()
Example #2
0
from director import visualization as vis
from director import consoleapp
from director import vtkAll as vtk
import numpy as np

app = consoleapp.ConsoleApp()
view = app.createView()
view.show()

t = vtk.vtkTransform()
obj = vis.showFrame(t, 'frame')
obj.setProperty('Trace', True)

# move the frame along a spiral to create a path trace
for theta in np.linspace(0, 30, 1000):
    p1 = np.array(t.GetPosition())
    p2 = np.array([theta * 0.03, np.sin(theta) * 0.1, np.cos(theta) * 0.1])
    t.Translate(p2 - p1)
    t.Modified()

view.resetCamera()
app.start()
Example #3
0
    def setup(self):

        args = self.parseArgs()
        imageManager = cameraview.ImageManager()
        self.imageManager = imageManager

        channel = args.channel
        imageType = args.imageType

        self.app = consoleapp.ConsoleApp()
        self.views = []

        if imageType == 'rgb':

            imageName = channel
            imageManager.queue.addCameraStream(channel, imageName, -1)
            imageManager.addImage(imageName)
            cameraView = cameraview.CameraImageView(
                imageManager, imageName, view=PythonQt.dd.ddQVTKWidgetView())
            cameraView.eventFilterEnabled = False
            cameraView.view.renderWindow().GetInteractor().SetInteractorStyle(
                vtk.vtkInteractorStyleImage())
            cameraView.view.resize(640, 480)
            self.views.append(cameraView.view)
            self.cameraView = cameraView

        elif imageType == 'rgbd':

            imageName = channel + '_LEFT'
            imageManager.queue.addCameraStream(channel, imageName, 0)
            imageManager.addImage(imageName)
            cameraView = cameraview.CameraImageView(
                imageManager, imageName, view=PythonQt.dd.ddQVTKWidgetView())
            cameraView.eventFilterEnabled = False
            cameraView.view.renderWindow().GetInteractor().SetInteractorStyle(
                vtk.vtkInteractorStyleImage())
            self.views.append(cameraView.view)

            imageName2 = channel + '_D'
            if args.disparity:
                imageManager.queue.addCameraStream(
                    channel, imageName2, lcmbotcore.images_t.DISPARITY_ZIPPED)
            else:
                imageManager.queue.addCameraStream(
                    channel, imageName2, lcmbotcore.images_t.DEPTH_MM_ZIPPED)
            imageManager.addImage(imageName2)
            cameraView2 = cameraview.CameraImageView(
                imageManager, imageName2, view=PythonQt.dd.ddQVTKWidgetView())
            cameraView2.eventFilterEnabled = False
            cameraView2.useImageColorMap = True
            cameraView2.view.renderWindow().GetInteractor().SetInteractorStyle(
                vtk.vtkInteractorStyleImage())
            self.views.append(cameraView2.view)

            if args.pointcloud:
                from director import segmentation
                cameraview.imageManager = imageManager
                pointCloudObj = segmentation.DisparityPointCloudItem(
                    'Point cloud', channel, imageName, imageManager)
                view = PythonQt.dd.ddQVTKWidgetView()
                pointCloudObj.addToView(view)
                om.addToObjectModel(pointCloudObj)
                pointCloudObj.setProperty('Visible', True)
                pointCloudObj.setProperty('Target FPS', 30)
                pointCloudObj.setProperty('Max Range', 30)
                pointCloudObj.setProperty('Remove Size', 0)
                viewBehaviors = viewbehaviors.ViewBehaviors(view)
                view.camera().SetPosition([0, 0, 0])
                view.camera().SetFocalPoint([0, 0, 1])
                view.camera().SetViewUp([0, -1, 0])
                view.camera().SetViewAngle(45)
                self.views.append(view)

            self.cameraView = cameraView
            self.cameraView2 = cameraView2

        w = QtGui.QWidget()
        l = QtGui.QHBoxLayout(w)
        for view in self.views:
            l.addWidget(view)
        l.setContentsMargins(0, 0, 0, 0)
        w.resize(640 * len(self.views), 480)
        w.show()
        self.addShortcuts(w)
        self.widget = w