Example #1
0
def do_ecto():
    baggers = dict(image=ImageBagger(topic_name='/camera/rgb/image_color'),
                   depth=ImageBagger(topic_name='/camera/depth/image'),
                   )

    bagreader = ecto_ros.BagReader('Bag Ripper',
                                    baggers=baggers,
                                    bag=sys.argv[1],
                                  )
    im2mat_rgb = ecto_ros.Image2Mat()
    im2mat_depth = ecto_ros.Image2Mat()

    graph = [
                bagreader["image"] >> im2mat_rgb["image"],
                im2mat_rgb["image"] >> highgui.imshow("rgb show", name="rgb")[:],
                bagreader["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.Scheduler(plasm)
    sched.execute()
    def connect_background_source(self):
        json_db_str = '{"type": "CouchDB", "root": "http://localhost:5984", "collection": "object_recognition"}'
        self.json_db = ecto.Constant(value=json_db_str)

        object_id_str = '4680aac58c1d263b9449d57bd2000f27'
        self.object_id = ecto.Constant(value=object_id_str)

        self.image_ci = ecto_ros.CameraInfo2Cv('camera_info -> cv::Mat')
        self.image = ecto_ros.Image2Mat()
        self.depth = ecto_ros.Image2Mat()

        bag = "/home/sam/rosbags/sigverse/no_objects.bag"

        ImageBagger = ecto_sensor_msgs.Bagger_Image
        CameraInfoBagger = ecto_sensor_msgs.Bagger_CameraInfo

        baggers = dict(
            image=ImageBagger(
                topic_name='/hsrb/head_rgbd_sensor/rgb/image_raw'),
            image_ci=CameraInfoBagger(
                topic_name='/hsrb/head_rgbd_sensor/rgb/camera_info'),
            depth=ImageBagger(
                topic_name='/hsrb/head_rgbd_sensor/depth/image_raw'),
        )

        # this will read all images in the path
        path = '/home/sam/Code/vision/VOCdevkit/VOC2012/JPEGImages'
        self.file_source = ImageReader(path=os.path.expanduser(path))

        self.bag_reader = ecto_ros.BagReader('Bag Reader',
                                             baggers=baggers,
                                             bag=bag,
                                             random_access=True,
                                             )

        self.rgb = imgproc.cvtColor(
            'bgr -> rgb', flag=imgproc.Conversion.BGR2RGB)
        self.display = highgui.imshow(name='Training Data', waitKey=10000)
        self.image_mux = ecto_yolo.ImageMux()

        self.graph += [
            self.bag_reader['image'] >> self.image['image'],
            self.bag_reader['depth'] >> self.depth['image'],
            self.image[:] >> self.rgb[:],
            self.bag_reader['image_ci'] >> self.image_ci['camera_info'],
            self.image_ci['K'] >> self.image_mux['K1'],
            self.rgb['image'] >> self.image_mux['image1'],
            self.depth['image'] >> self.image_mux['depth1'],
            self.file_source['image'] >> self.image_mux['image2'],
        ]
Example #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
        cells = BaseSource.declare_cells(p)
        baggers = dict(
            image=ImageBagger(topic_name='/bogus_topic'),
            depth=ImageBagger(topic_name='/bogus_topic'),
            image_info=CameraInfoBagger(topic_name='/bogus_topic'),
            depth_info=CameraInfoBagger(topic_name='/bogus_topic'),
        )
        cells.update(baggers)
        cells['source'] = ecto_ros.BagReader('Bag Reader',
                                             bag='/bogus',
                                             baggers=baggers)

        return cells
Example #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?
     baggers = dict(
         image=ImageBagger(topic_name='/camera/rgb/image_color'),
         depth=ImageBagger(topic_name='/camera/depth/image'),
         image_info=CameraInfoBagger(topic_name='/camera/rgb/camera_info'),
         depth_info=CameraInfoBagger(
             topic_name='/camera/depth/camera_info'),
     )
     #Creating this in declare io, so that i can declare the output with a concrete type.
     self._source = ecto_ros.BagReader('Bag Reader',
                                       bag=p.bag,
                                       baggers=baggers)
     #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'))
Example #5
0
def convert_bag(folder, file_name):
    bag_path = '%s/%s' % (folder, file_name)
    # TOD use that one and delete
    tmp_bag_path = bag_path + str(random.random()) + '.tmp'
    tmp_bag_path = '/tmp/' + str(random.random()) + '.tmp'
    print 'converting the bags to the new format in file "%s"' % tmp_bag_path

    baggers_reader = dict(
        info=CameraInfoBagger(topic_name='camera_info'),
        rgb=ImageBagger(topic_name='image_color'),
        depth=PointCloud2Bagger(topic_name='points'),
    )
    bagreader = ecto_ros.BagReader('bag reader',
                                   baggers=baggers_reader,
                                   bag=bag_path)

    baggers_writer = dict(
        info_rgb=CameraInfoBagger(topic_name='/camera/rgb/camera_info'),
        info_depth=CameraInfoBagger(topic_name='/camera/depth/camera_info'),
        rgb=ImageBagger(topic_name='/camera/rgb/image_color'),
        depth=ImageBagger(topic_name='/camera/depth/image'))
    bagwriter = ecto_ros.BagWriter('bag writer',
                                   baggers=baggers_writer,
                                   bag=tmp_bag_path)

    pcd_msg2depth_msg = ecto_ros.PointCloud22DepthImage()
    plasm = ecto.Plasm()
    plasm.connect([
        bagreader['info'] >> bagwriter['info_rgb'],
        bagreader['info'] >> bagwriter['info_depth'],
        bagreader['rgb'] >> bagwriter['rgb'],
        bagreader['depth'] >> pcd_msg2depth_msg['cloud'],
        pcd_msg2depth_msg['image'] >> bagwriter['depth']
    ])
    sched = ecto.schedulers.Singlethreaded(plasm)
    sched.execute()
    return tmp_bag_path
import object_recognition_yolo.ecto_cells.ecto_yolo as ecto_yolo

parser = argparse.ArgumentParser(description='Test detection.')

bag = "/home/sam/rosbags/sigverse/stroll.bag"
ImageBagger = ecto_sensor_msgs.Bagger_Image
CameraInfoBagger = ecto_sensor_msgs.Bagger_CameraInfo
baggers = dict(
    image=ImageBagger(topic_name='/hsrb/head_rgbd_sensor/rgb/image_raw'),
    image_ci=CameraInfoBagger(topic_name='/hsrb/head_rgbd_sensor/rgb/camera_info'),
)

source = ecto_ros.BagReader(
    'Bag Reader',
    baggers=baggers,
    bag=bag,
    random_access=False,
)

image = ecto_ros.Image2Mat()
rgb = imgproc.cvtColor('bgr -> rgb', flag=imgproc.Conversion.BGR2RGB)
display = imshow(name='RGB', triggers=dict(save=ord('s')))

detector = ecto_yolo.Detector(
    data_config="/home/sam/OrkData/cfg/ork.dataset",
    network_config="/home/sam/OrkData/cfg/yolov3-ork.cfg",
    weights="/home/sam/OrkData/weights/yolov3-ork_34000.weights",
    detection_threshold=0.2,
)

# ecto options
Example #7
0
bag = "/home/sam/rosbags/sigverse/no_objects.bag"

baggers = dict(
    image=ImageBagger(topic_name='/hsrb/head_rgbd_sensor/rgb/image_raw'),
    image_ci=CameraInfoBagger(
        topic_name='/hsrb/head_rgbd_sensor/rgb/camera_info'),
    depth=ImageBagger(topic_name='/hsrb/head_rgbd_sensor/depth/image_raw'),
)

# this will read all images in the path
path = '/home/sam/Code/vision/VOCdevkit/VOC2012/JPEGImages'
file_source = ImageReader(path=os.path.expanduser(path))

bag_reader = ecto_ros.BagReader(
    'Bag Reader',
    baggers=baggers,
    bag=bag,
    random_access=True,
)

rgb = imgproc.cvtColor('bgr -> rgb', flag=imgproc.Conversion.BGR2RGB)

display = highgui.imshow(name='Training Data', waitKey=10000)

image_mux = ecto_yolo.ImageMux()

pose_drawer = PoseDrawer()

rt_2_pose = ecto_ros.RT2PoseStamped(frame_id=frame_id_str)

graph = []