Exemple #1
0
def do_ecto():
    #Set up the ecto_ros subscribers, with a dict of output name -> subscriber cell
    subs = dict(
        image=ImageSub(topic_name='image', queue_size=0),
        depth=ImageSub(topic_name='depth', queue_size=0),
    )
    #The synchronizer expects this dict, and will have an output foreach key:value pair
    sync = ecto_ros.Synchronizer('Synchronizator', subs=subs)

    #some rosmsg ~> opencv type converters
    rgb = ecto_ros.Image2Mat()
    depth = ecto_ros.Image2Mat()

    #declare a graph that just shows the images using opencv highgui
    graph = [
        sync["image"] >> rgb["image"], sync["depth"] >> depth["image"],
        rgb["image"] >> imshow(name="rgb")["image"],
        depth["image"] >> imshow(name="depth")["image"]
    ]

    #add the graph to our ecto plasm
    plasm = ecto.Plasm()
    plasm.connect(graph)

    #We'll use a threadpool based scheduler to execute this one.
    sched = ecto.schedulers.Singlethreaded(plasm)
    sched.execute()  #execute forever
Exemple #2
0
def do_ecto():
    baggers = dict(
        image=ImageBagger(topic_name='/camera/rgb/image_mono'),
        depth=ImageBagger(topic_name='/camera/depth/image_raw'),
    )

    bagwriter = ecto_ros.BagWriter(
        'Bag Writer',
        baggers=baggers,
        bag=sys.argv[1],
    )
    subs = dict(
        image=ImageSub(topic_name='/camera/rgb/image_mono', queue_size=0),
        depth=ImageSub(topic_name='/camera/depth/image_raw', queue_size=0),
    )

    sync = ecto_ros.Synchronizer('Synchronizator', subs=subs)

    im2mat_rgb = ecto_ros.Image2Mat()
    im2mat_depth = ecto_ros.Image2Mat()

    graph = [
        sync["image"] >> im2mat_rgb["image"],
        im2mat_rgb["image"] >> highgui.imshow("rgb show", name="rgb")[:],
        sync[:] >> bagwriter[:], sync["depth"] >> im2mat_depth["image"],
        im2mat_depth["image"] >> highgui.imshow("depth show", name="depth")[:]
    ]
    plasm = ecto.Plasm()
    plasm.connect(graph)
    ecto.view_plasm(plasm)

    sched = ecto.schedulers.Threadpool(plasm)
    sched.execute(niter=30)  #capture a second.
Exemple #3
0
    def declare_cells(p):
        #this is the private synchronization subscriber setup.
        #NOTE that these are all ROS remappable on the command line in typical ros fashion
        qsize = 1
        cells = BaseSource.declare_cells(p)
        subs = dict(image=ImageSub(topic_name='/bogus_topic_image',
                                   queue_size=qsize),
                    image_info=CameraInfoSub(topic_name='/bogus_topic_image',
                                             queue_size=qsize),
                    depth=ImageSub(topic_name='/bogus_topic_depth',
                                   queue_size=qsize),
                    depth_info=CameraInfoSub(topic_name='/bogus_topic_depth',
                                             queue_size=qsize))
        cells.update(subs)
        cells['source'] = ecto_ros.Synchronizer('Synchronizator', subs=subs)

        return cells
Exemple #4
0
 def declare_io(self, p, i, o):
     BaseSource.declare_io(self, p, i, o)
     #this is the private synchronization subscriber setup.
     #NOTE that these are all ROS remappable on the command line in typical ros fashion
     #TODO Should these just be simple names where remapping is expected?
     subs = dict(
         image=ImageSub(topic_name='/camera/rgb/image_color', queue_size=0),
         depth=ImageSub(topic_name='/camera/depth/image', queue_size=0),
         depth_info=CameraInfoSub(topic_name='/camera/depth/camera_info',
                                  queue_size=0),
         image_info=CameraInfoSub(topic_name='/camera/rgb/camera_info',
                                  queue_size=0),
     )
     #Creating this in declare io, so that i can declare the output with a concrete type.
     self._source = ecto_ros.Synchronizer('Synchronizator', subs=subs)
     #notice that this is not a forward declare
     #its a declaration with the name, and a pointer to a tendril.
     o.declare('image_message', self._source.outputs.at('image'))
     o.declare('depth_message', self._source.outputs.at('depth'))
     o.declare('image_info_message', self._source.outputs.at('image_info'))
     o.declare('depth_info_message', self._source.outputs.at('depth_info'))
Exemple #5
0
    debug = True
    poser = OpposingDotPoseEstimator(plasm,
                                     rows=5,
                                     cols=3,
                                     pattern_type="acircles",
                                     square_size=0.04,
                                     debug=debug)
    camera_info = calib.CameraIntrinsics('Camera Info',
                                         camera_file="camera.yml")
    subs = dict(
        image=ImageSub(topic_name='camera/rgb/image_color', queue_size=0),
        depth=ImageSub(topic_name='camera/depth/image', queue_size=0),
    )

    sync = ecto_ros.Synchronizer('Synchronizator', subs=subs)

    brg2rgb = imgproc.cvtColor('bgr -> rgb', flag=4)
    rgb2gray = imgproc.cvtColor('rgb -> gray', flag=7)
    gray2rgb = imgproc.cvtColor('gray -> rgb', flag=8)
    print gray2rgb.__doc__

    display = highgui.imshow('Poses', name='Poses', waitKey=2, autoSize=True)
    mask_display = highgui.imshow('Masks',
                                  name='Masks',
                                  waitKey=-1,
                                  autoSize=True)
    object_display = highgui.imshow('Object',
                                    name='Object',
                                    waitKey=-1,
                                    autoSize=True)