Пример #1
0
 def setUp(self):
     # rerun resize cell and set params
     options.rerun = 'resize'
     options.resize_to = 1600
     # rebuild app
     self.app, self.plasm = appSetup(options)
     run_plasm(options, self.plasm)
Пример #2
0
 def setUp(self):
     # rerun resize cell and set params
     options.rerun = 'resize'
     options.resize_to = 1600
     # rebuild app
     self.app, self.plasm = appSetup(options)
     run_plasm(options, self.plasm)
Пример #3
0
    def __init__(self):
        ecto_ros.init(sys.argv,"ecto_pcl_demo")
        
        parser = argparse.ArgumentParser(description='My awesome program thing.')
        
        scheduler_options(parser)
        options = parser.parse_args()

        plasm = ecto.Plasm()

        voxel_grid = VoxelGrid("voxel_grid", leaf_size=0.01)
        cropper = Cropper("cropper", x_min=-0.25, x_max=0.25, y_min=-0.25, y_max=0.25, z_min=0.0, z_max=1.0)
        ror = RadiusOutlierRemoval("ror", min_neighbors=1, search_radius=1.0)

        cloud_sub = ecto_sensor_msgs.Subscriber_PointCloud2("cloud_sub", topic_name='/camera/depth_registered/points')
        msg2cloud = ecto_pcl_ros.Message2PointCloud("msg2cloud", format=ecto_pcl.XYZRGB)
        
        cloud2msg = ecto_pcl_ros.PointCloud2Message("cloud2msg")
        cloud_pub = ecto_sensor_msgs.Publisher_PointCloud2("cloud_pub",topic_name='/ecto_pcl/cloud_filtered')

        plasm.connect(cloud_sub[:] >> msg2cloud[:],
                      msg2cloud[:] >> voxel_grid[:],
                      voxel_grid[:] >> ror[:],
                      ror[:] >> cloud2msg[:],
                      cloud2msg[:] >> cloud_pub[:])
    
        run_plasm(options, plasm, locals=vars())
Пример #4
0
    def __init__(self):
        ecto_ros.init(sys.argv, "ecto_pcl_demo")

        parser = argparse.ArgumentParser(
            description='My awesome program thing.')

        scheduler_options(parser)
        options = parser.parse_args()

        plasm = ecto.Plasm()

        voxel_grid = VoxelGrid("voxel_grid", leaf_size=0.01)
        cropper = Cropper("cropper",
                          x_min=-0.25,
                          x_max=0.25,
                          y_min=-0.25,
                          y_max=0.25,
                          z_min=0.0,
                          z_max=1.0)

        convex_hull = ConvexHull("convex_hull")
        ror = RadiusOutlierRemoval("ror", min_neighbors=1, search_radius=1.0)
        sor = StatisticalOutlierRemoval("sor", mean_k=1)

        extract_indices = ExtractIndices("extract_indices", negative=False)
        extract_clusters = EuclideanClusterExtraction("extract_clusters",
                                                      min_cluster_size=50,
                                                      cluster_tolerance=0.005)
        extract_largest_cluster = ExtractLargestCluster(
            "extract_largest_cluster")

        cloud_sub = ecto_sensor_msgs.Subscriber_PointCloud2(
            "cloud_sub", topic_name='/camera/depth_registered/points')
        msg2cloud = ecto_pcl_ros.Message2PointCloud("msg2cloud",
                                                    format=ecto_pcl.XYZRGB)

        cloud2msg = ecto_pcl_ros.PointCloud2Message("cloud2msg")
        cloud_pub = ecto_sensor_msgs.Publisher_PointCloud2(
            "cloud_pub", topic_name='/ecto_pcl/sample_output')

        plasm.connect(
            cloud_sub[:] >> msg2cloud[:], msg2cloud[:] >> extract_clusters[:],
            extract_clusters[:] >> extract_largest_cluster["clusters"],
            msg2cloud[:] >> extract_largest_cluster["input"],
            extract_largest_cluster[:] >> cloud2msg[:],
            cloud2msg[:] >> cloud_pub[:])

        #        plasm.connect(cloud_sub[:] >> msg2cloud[:],
        #                      msg2cloud[:] >> voxel_grid[:],
        #                      msg2cloud[:] >> extract_indices["input"],
        #                      voxel_grid[:] >> cropper[:],
        #                      cropper[:] >> extract_clusters[:],
        #                      extract_indices[:] >> extract_clusters[:],
        #                      extract_clusters[:] >> extract_largest_cluster["clusters"],
        #                      cropper[:] >>  extract_largest_cluster["input"],
        #                      extract_largest_cluster[:] >> cloud2msg[:],
        #                      cloud2msg[:] >> cloud_pub[:])

        run_plasm(options, plasm, locals=vars())
Пример #5
0
def setup_module():
    # Run tests
    print '%s' % options
    options.project_path = context.tests_data_path
    # options.rerun_all = True
    app, plasm = appSetup(options)
    print 'Run Setup: Initial Run'
    run_plasm(options, plasm)
Пример #6
0
def setup_module():
    # Run tests
    print '%s' % options
    options.project_path = context.tests_data_path
    # options.rerun_all = True
    app, plasm = appSetup(options)
    print 'Run Setup: Initial Run'
    run_plasm(options, plasm)
Пример #7
0
    def __init__(self):
        ecto_ros.init(sys.argv, "ecto_pcl_demo")

        parser = argparse.ArgumentParser(description='Ecto Largest Cluster')

        scheduler_options(parser)
        options = parser.parse_args()

        plasm = ecto.Plasm()

        voxel_grid = VoxelGrid("voxel_grid", leaf_size=0.015)
        cropper = Cropper("cropper",
                          x_min=-0.25,
                          x_max=0.25,
                          y_min=-0.25,
                          y_max=0.25,
                          z_min=0.0,
                          z_max=1.0)
        extract_clusters = EuclideanClusterExtraction("extract_clusters",
                                                      min_cluster_size=50,
                                                      cluster_tolerance=0.02)
        extract_largest_cluster = ExtractLargestCluster(
            "extract_largest_cluster")
        nan_filter = PassThrough("nan_removal")
        colorize = ColorizeClusters("colorize", max_clusters=100)
        extract_indices = ExtractIndices("extract_indices", negative=False)

        cloud_sub = ecto_sensor_msgs.Subscriber_PointCloud2(
            "cloud_sub", topic_name='/camera/depth_registered/points')
        msg2cloud = ecto_pcl_ros.Message2PointCloud("msg2cloud",
                                                    format=ecto_pcl.XYZRGB)

        cloud2msg = ecto_pcl_ros.PointCloud2Message("cloud2msg")
        cloud_pub = ecto_sensor_msgs.Publisher_PointCloud2(
            "cloud_pub", topic_name='/ecto_pcl/cloud_filtered')

        output = ecto_pcl.XYZRGB

        #        plasm.connect(cloud_sub[:] >>  msg2cloud[:],
        #                      msg2cloud[:] >> nan_filter[:],
        #                      nan_filter[:] >> voxel_grid[:],
        #                      voxel_grid[:] >> extract_clusters[:],
        #                      extract_clusters[:] >> extract_largest_cluster["clusters"],
        #                      voxel_grid[:] >> extract_largest_cluster["input"],
        #                      extract_largest_cluster[:] >> cloud2msg[:],
        #                      cloud2msg[:] >> cloud_pub[:])
        #
        #        run_plasm(options, plasm, locals=vars())

        plasm.connect(
            cloud_sub[:] >> msg2cloud[:], msg2cloud[:] >> nan_filter[:],
            nan_filter[:] >> voxel_grid[:],
            voxel_grid[:] >> extract_clusters[:],
            extract_clusters[:] >> extract_largest_cluster["clusters"],
            voxel_grid[:] >> extract_largest_cluster["input"],
            extract_largest_cluster["output"] >> 'out')

        run_plasm(options, plasm, locals=output)
Пример #8
0
def test_bb(options):
    mm = MyBlackBox(start=10, step=3, amount=2, niter=2)
    plasm = ecto.Plasm()
    plasm.insert(mm)
    options.niter = 5
    run_plasm(options, plasm)
    assert mm.outputs.value == 39
    run_plasm(options, plasm)
    assert mm.outputs.value == 69
Пример #9
0
def test_bb(options):
    mm = MyBlackBox(start=10, step=3, amount=2, niter=2)
    plasm = ecto.Plasm()
    plasm.insert(mm)
    options.niter = 5
    run_plasm(options, plasm)
    assert mm.outputs.value == 39
    run_plasm(options, plasm)
    assert mm.outputs.value == 69
Пример #10
0
    def __init__(self):
        ecto_ros.init(sys.argv, "ecto_pcl_demo")

        parser = argparse.ArgumentParser(
            description='My awesome program thing.')

        scheduler_options(parser)
        options = parser.parse_args()

        plasm = ecto.Plasm()

        voxel_grid = VoxelGrid("voxel_grid", leaf_size=0.01)
        passthru_z = PassThrough("passthru_z",
                                 filter_field_name="z",
                                 filter_limit_min=0.0,
                                 filter_limit_max=1.0)
        passthru_x = PassThrough("passthru_x",
                                 filter_field_name="x",
                                 filter_limit_min=-0.25,
                                 filter_limit_max=0.25)
        passthru_y = PassThrough("passthru_y",
                                 filter_field_name="y",
                                 filter_limit_min=-0.25,
                                 filter_limit_max=0.25)
        cropper = Cropper("cropper",
                          x_min=-0.25,
                          x_max=0.25,
                          y_min=-0.25,
                          y_max=0.25,
                          z_min=0.0,
                          z_max=1.0)
        viewer = CloudViewer("viewer", window_name="Clouds!")

        cloud_sub = ecto_sensor_msgs.Subscriber_PointCloud2(
            "cloud_sub", topic_name='/camera/depth_registered/points')
        msg2cloud = ecto_pcl_ros.Message2PointCloud("msg2cloud",
                                                    format=ecto_pcl.XYZRGB)

        cloud2msg = ecto_pcl_ros.PointCloud2Message("cloud2msg")
        cloud_pub = ecto_sensor_msgs.Publisher_PointCloud2(
            "cloud_pub", topic_name='/ecto_pcl/sample_output')

        plasm.connect(
            cloud_sub[:] >> msg2cloud[:], msg2cloud[:] >> voxel_grid[:],
            voxel_grid[:] >> passthru_z[:], passthru_z[:] >> passthru_x[:],
            passthru_x[:] >> passthru_y[:], passthru_y[:] >> cloud2msg[:],
            cloud2msg[:] >> cloud_pub[:])

        #        plasm.connect(cloud_sub[:] >> msg2cloud[:],
        #                      msg2cloud[:] >> voxel_grid[:],
        #                      voxel_grid[:] >> cropper[:],
        #                      cropper[:] >> cloud2msg[:],
        #                      cloud2msg[:] >> cloud_pub[:])

        run_plasm(options, plasm, locals=vars())
Пример #11
0
    def __init__(self):
        ecto_ros.init(sys.argv, "ecto_pcl_demo")

        parser = argparse.ArgumentParser(
            description='Ecto Euclidean Clustering')

        scheduler_options(parser)
        options = parser.parse_args()

        plasm = ecto.Plasm()

        voxel_grid = VoxelGrid("voxel_grid", leaf_size=0.015)
        cropper = Cropper("cropper",
                          x_min=-0.25,
                          x_max=0.25,
                          y_min=-0.25,
                          y_max=0.25,
                          z_min=0.3,
                          z_max=1.0)
        passthru_z = PassThrough("passthru_z",
                                 filter_field_name="z",
                                 filter_limit_min=0.3,
                                 filter_limit_max=1.0)
        passthru_x = PassThrough("passthru_x",
                                 filter_field_name="x",
                                 filter_limit_min=-0.25,
                                 filter_limit_max=0.25)
        passthru_y = PassThrough("passthru_y",
                                 filter_field_name="y",
                                 filter_limit_min=-0.25,
                                 filter_limit_max=0.25)
        extract_clusters = EuclideanClusterExtraction("extract_clusters",
                                                      min_cluster_size=50,
                                                      cluster_tolerance=0.02)
        nan_filter = PassThrough("nan_removal")
        colorize = ColorizeClusters("colorize", max_clusters=100)

        cloud_sub = ecto_sensor_msgs.Subscriber_PointCloud2(
            "cloud_sub", topic_name='/camera/depth_registered/points')
        msg2cloud = ecto_pcl_ros.Message2PointCloud("msg2cloud",
                                                    format=ecto_pcl.XYZRGB)

        cloud2msg = ecto_pcl_ros.PointCloud2Message("cloud2msg")
        cloud_pub = ecto_sensor_msgs.Publisher_PointCloud2(
            "cloud_pub", topic_name='/ecto_pcl/cloud_filtered')

        plasm.connect(
            cloud_sub[:] >> msg2cloud[:], msg2cloud[:] >> nan_filter[:],
            nan_filter[:] >> voxel_grid[:], voxel_grid[:] >> cropper[:],
            cropper["output"] >> extract_clusters["input"],
            extract_clusters[:] >> colorize["clusters"],
            cropper[:] >> colorize["input"], colorize[:] >> cloud2msg[:],
            cloud2msg[:] >> cloud_pub[:])

        run_plasm(options, plasm, locals=vars())
Пример #12
0
def test_bb(options):
    mm = MyBlackBox(start=10, step=3, amount=2, niter=2)
    plasm = ecto.Plasm()
    plasm.insert(mm)
    options.niter = 5
    run_plasm(options, plasm)
    # final value is start + step*(2*5-1)+amount
    assert mm.outputs.value == 39
    run_plasm(options, plasm)
    # final value is start + step*(2*(5+5)-1)+amount
    assert mm.outputs.value == 69
Пример #13
0
def test_bb(options):
    mm = MyBlackBox(start=10, step=3, amount=2, niter=2)
    plasm = ecto.Plasm()
    plasm.insert(mm)
    options.niter = 5
    run_plasm(options, plasm)
    # final value is start + step*(2*5-1)+amount
    assert mm.outputs.value == 39
    run_plasm(options, plasm)
    # final value is start + step*(2*(5+5)-1)+amount
    assert mm.outputs.value == 69
Пример #14
0
def generate_pointclouds_in_object_space(dbs, session, args):
    object_name = dbs[session.object_id]['object_name']
    if not os.path.exists(object_name):
        os.mkdir(object_name)
    obs_ids = models.find_all_observations_for_session(dbs, session.id)
    if len(obs_ids) == 0:
        raise RuntimeError("There are no observations available.")
    db_reader = capture.ObservationReader(
        'Database Source', db_params=dbtools.args_to_db_params(args))

    #observation dealer will deal out each observation id.
    observation_dealer = ecto.Dealer(
        tendril=db_reader.inputs.at('observation'), iterable=obs_ids)
    depthTo3d = calib.DepthTo3d('Depth ~> 3D')
    rescale_depth = capture.RescaledRegisteredDepth(
        'Depth scaling')  #this is for SXGA mode scale handling.
    point_cloud_transform = reconstruction.PointCloudTransform(
        'Object Space Transform', do_transform=False
    )  #keeps the points in camera coordinates, but populates the global sensor position and orientatino.
    point_cloud_converter = conversion.MatToPointCloudXYZRGB('To Point Cloud')
    to_ecto_pcl = ecto_pcl.PointCloudT2PointCloud('converter',
                                                  format=ecto_pcl.XYZRGB)
    plasm = ecto.Plasm()
    plasm.connect(observation_dealer[:] >> db_reader['observation'],
                  db_reader['K'] >> depthTo3d['K'],
                  db_reader['image'] >> rescale_depth['image'],
                  db_reader['depth'] >> rescale_depth['depth'],
                  rescale_depth[:] >> depthTo3d['depth'],
                  depthTo3d['points3d'] >> point_cloud_converter['points'],
                  db_reader['image'] >> point_cloud_converter['image'],
                  db_reader['mask'] >> point_cloud_converter['mask'],
                  db_reader['R', 'T'] >> point_cloud_transform['R', 'T'],
                  point_cloud_converter['point_cloud'] >> to_ecto_pcl[:],
                  to_ecto_pcl[:] >> point_cloud_transform['cloud'])
    ply_writer = ecto_pcl.PLYWriter('PLY Saver',
                                    filename_format='%s/cloud_%%05d.ply' %
                                    (object_name))
    pcd_writer = ecto_pcl.PCDWriter('PCD Saver',
                                    filename_format='%s/cloud_%%05d.pcd' %
                                    (object_name))
    plasm.connect(point_cloud_transform['view'] >> (ply_writer['input'],
                                                    pcd_writer['input']))

    if args.visualize:
        global cloud_view
        plasm.connect(
            point_cloud_transform['view'] >> cloud_view,
            db_reader['image'] >> imshows['image'],
            db_reader['depth'] >> imshows['depth'],
            db_reader['mask'] >> imshows['mask'],
        )

    from ecto.opts import run_plasm
    run_plasm(args, plasm, locals=vars())
    def __init__(self):
        ecto_ros.init(sys.argv,"ecto_pcl_demo")

        # Create the argument parser        
        parser = argparse.ArgumentParser(description='Ecto Euclidean Clustering')
        
        # Use the parser to create scheduler options        
        scheduler_options(parser)
        options = parser.parse_args()

        # Create the overall plasm
        plasm = ecto.Plasm()

        # A VoxelGrid cell
        voxel_grid = ecto_pcl.VoxelGrid("voxel_grid", leaf_size=0.01)
        
        # A Cropper cell
        cropper = ecto_pcl.Cropper("cropper", x_min=-0.35, x_max=0.35, y_min=-0.35, y_max=0.35, z_min=0.3, z_max=1.5)
        
        # A EuclideanClusterExtraction cell
        extract_clusters = ecto_pcl.EuclideanClusterExtraction("extract_clusters", min_cluster_size=50, cluster_tolerance=0.02)
        
        # A cell to filter NaN values from the point cloud
        nan_filter = ecto_pcl.PassThrough("nan_removal")
        
        # A cell to colorize the clusters
        colorize = ecto_pcl.ColorizeClusters("colorize", max_clusters=100)
 
        # Create the subscriber cell with the appropriate point cloud topic     
        cloud_sub = ecto_sensor_msgs.Subscriber_PointCloud2("cloud_sub", topic_name='camera/depth_registered/points')

        # A cell to convert a point cloud ROS message to an Ecto/PCL point cloud object                
        msg2cloud = ecto_pcl_ros.Message2PointCloud("msg2cloud", format=ecto_pcl.XYZRGB)

        # A cell to convert a Ecto/PCL point cloud back to a point cloud message        
        cloud2msg = ecto_pcl_ros.PointCloud2Message("cloud2msg")
        
        # A cell to convert a point cloud ROS message to an Ecto/PCL point cloud object                
        cloud_pub = ecto_sensor_msgs.Publisher_PointCloud2("cloud_pub",topic_name='ecto_pcl/cloud_filtered')
        
        # Create the plasm by connecting the cells               
        plasm.connect(cloud_sub[:] >>  msg2cloud[:],
                      msg2cloud[:] >> nan_filter[:],
                      nan_filter[:] >> voxel_grid[:],
                      voxel_grid[:] >> cropper[:],
                      cropper[:] >> extract_clusters[:],
                      extract_clusters[:] >> colorize["clusters"],
                      cropper[:] >> colorize["input"],
                      colorize[:] >> cloud2msg[:],
                      cloud2msg[:] >> cloud_pub[:])
        
        # Run the plasm
        run_plasm(options, plasm, locals=vars())
    def do_ecto(self):

        plasm = ecto.Plasm()
        plasm.connect(self.graph)

        # sched = ecto.Scheduler(plasm)
        # sched.execute(niter=1)

        ecto.view_plasm(plasm)

        # add ecto scheduler args.
        run_plasm(self.options, plasm, locals=vars())
Пример #17
0
def test_bb_fail(options):
    mm = MyBlackBox("MaMaMa", start=10, step=3, fail=True)
    print mm.__doc__
    assert 'fail' in mm.__doc__
    assert mm.name() == 'MaMaMa'
    plasm = ecto.Plasm()
    plasm.insert(mm)
    try:
        run_plasm(options, plasm)
        fail()
    except ecto.CellException, e:
        print "Good:"
        print str(e)
        assert "I hate life" in str(e)
Пример #18
0
def test_bb_fail(options):
    mm = MyBlackBox("MaMaMa", start=10, step=3, fail=True)
    print mm.__doc__
    assert 'fail' in  mm.__doc__
    assert mm.name() == 'MaMaMa'
    plasm = ecto.Plasm()
    plasm.insert(mm)
    try:
        run_plasm(options, plasm)
        fail()
    except ecto.CellException, e:
        print "Good:"
        print str(e)
        assert "I hate life" in str(e)
def generate_pointclouds_in_object_space(dbs, session, args):
    object_name = dbs[session.object_id]['object_name']
    if not os.path.exists(object_name):
        os.mkdir(object_name)
    obs_ids = models.find_all_observations_for_session(dbs, session.id)
    if len(obs_ids) == 0:
        raise RuntimeError("There are no observations available.")
    db_reader = capture.ObservationReader('Database Source', db_params=dbtools.args_to_db_params(args))

    #observation dealer will deal out each observation id.
    observation_dealer = ecto.Dealer(tendril=db_reader.inputs.at('observation'), iterable=obs_ids)
    depthTo3d = calib.DepthTo3d('Depth ~> 3D')
    rescale_depth = capture.RescaledRegisteredDepth('Depth scaling') #this is for SXGA mode scale handling.
    point_cloud_transform = reconstruction.PointCloudTransform('Object Space Transform',do_transform=False)#keeps the points in camera coordinates, but populates the global sensor position and orientatino.
    point_cloud_converter = conversion.MatToPointCloudXYZRGB('To Point Cloud')
    to_ecto_pcl = ecto_pcl.PointCloudT2PointCloud('converter', format=ecto_pcl.XYZRGB)
    plasm = ecto.Plasm()
    plasm.connect(
      observation_dealer[:] >> db_reader['observation'],
      db_reader['K'] >> depthTo3d['K'],
      db_reader['image'] >> rescale_depth['image'],
      db_reader['depth'] >> rescale_depth['depth'],
      rescale_depth[:] >> depthTo3d['depth'],
      depthTo3d['points3d'] >> point_cloud_converter['points'],
      db_reader['image'] >> point_cloud_converter['image'],
      db_reader['mask'] >> point_cloud_converter['mask'],
      db_reader['R', 'T'] >> point_cloud_transform['R', 'T'],
      point_cloud_converter['point_cloud'] >> to_ecto_pcl[:],
      to_ecto_pcl[:] >> point_cloud_transform['cloud']
    )
    ply_writer = ecto_pcl.PLYWriter('PLY Saver',
                                      filename_format='%s/cloud_%%05d.ply' % (object_name))
    pcd_writer = ecto_pcl.PCDWriter('PCD Saver',
                                      filename_format='%s/cloud_%%05d.pcd' % (object_name))
    plasm.connect(point_cloud_transform['view'] >> (ply_writer['input'], pcd_writer['input'])
                  )

    if args.visualize:
        global cloud_view
        plasm.connect(
          point_cloud_transform['view'] >> cloud_view,
          db_reader['image'] >> imshows['image'],
          db_reader['depth'] >> imshows['depth'],
          db_reader['mask'] >> imshows['mask'],
          )

    from ecto.opts import run_plasm
    run_plasm(args, plasm, locals=vars())
Пример #20
0
    def __init__(self):
        ecto_ros.init(sys.argv, "ecto_pcl_demo")

        # Create the argument parser
        parser = argparse.ArgumentParser(description="Ecto PCL Demo")

        # Use the parser to create scheduler options
        scheduler_options(parser)
        options = parser.parse_args()

        # Create the overall plasm
        plasm = ecto.Plasm()

        # Create three PassThrough cells along the x, y and z dimensions
        passthru_z = ecto_pcl.PassThrough(
            "passthru_z", filter_field_name="z", filter_limit_min=0.0, filter_limit_max=1.0
        )
        passthru_x = ecto_pcl.PassThrough(
            "passthru_x", filter_field_name="x", filter_limit_min=-0.25, filter_limit_max=0.25
        )
        passthru_y = ecto_pcl.PassThrough(
            "passthru_y", filter_field_name="y", filter_limit_min=-0.25, filter_limit_max=0.25
        )

        # Create the subscriber cell with the appropriate point cloud topic
        cloud_sub = ecto_sensor_msgs.Subscriber_PointCloud2("cloud_sub", topic_name="camera/depth_registered/points")

        # A cell to convert a point cloud ROS message to an Ecto/PCL point cloud object
        msg2cloud = ecto_pcl_ros.Message2PointCloud("msg2cloud", format=ecto_pcl.XYZRGB)

        # A cell to convert a point cloud ROS message to an Ecto/PCL point cloud object
        cloud2msg = ecto_pcl_ros.PointCloud2Message("cloud2msg")

        # A publisher cell with the desired topic name
        cloud_pub = ecto_sensor_msgs.Publisher_PointCloud2("cloud_pub", topic_name="ecto_pcl/cloud_filtered")

        # Create the plasm by connecting the cells
        plasm.connect(
            cloud_sub[:] >> msg2cloud[:],
            msg2cloud[:] >> passthru_z[:],
            passthru_z[:] >> passthru_x[:],
            passthru_x[:] >> passthru_y[:],
            passthru_y[:] >> cloud2msg[:],
            cloud2msg[:] >> cloud_pub[:],
        )
        # Run the plasm
        run_plasm(options, plasm, locals=vars())
    def __init__(self):
        ecto_ros.init(sys.argv,"ecto_pcl_demo")
        
        parser = argparse.ArgumentParser(description='Ecto Largest Cluster')
        
        scheduler_options(parser)
        options = parser.parse_args()

        plasm = ecto.Plasm()

        voxel_grid = VoxelGrid("voxel_grid", leaf_size=0.015)
        cropper = Cropper("cropper", x_min=-0.25, x_max=0.25, y_min=-0.25, y_max=0.25, z_min=0.0, z_max=1.0)
        extract_clusters = EuclideanClusterExtraction("extract_clusters", min_cluster_size=50, cluster_tolerance=0.02)
        extract_largest_cluster = ExtractLargestCluster("extract_largest_cluster")
        nan_filter = PassThrough("nan_removal")
        colorize = ColorizeClusters("colorize", max_clusters=100)
        extract_indices = ExtractIndices("extract_indices", negative=False)
      
        cloud_sub = ecto_sensor_msgs.Subscriber_PointCloud2("cloud_sub", topic_name='/camera/depth_registered/points')
        msg2cloud = ecto_pcl_ros.Message2PointCloud("msg2cloud", format=ecto_pcl.XYZRGB)
        
        cloud2msg = ecto_pcl_ros.PointCloud2Message("cloud2msg")
        cloud_pub = ecto_sensor_msgs.Publisher_PointCloud2("cloud_pub",topic_name='/ecto_pcl/cloud_filtered')
        
        output = ecto_pcl.XYZRGB
        
#        plasm.connect(cloud_sub[:] >>  msg2cloud[:],
#                      msg2cloud[:] >> nan_filter[:],
#                      nan_filter[:] >> voxel_grid[:],
#                      voxel_grid[:] >> extract_clusters[:],
#                      extract_clusters[:] >> extract_largest_cluster["clusters"],
#                      voxel_grid[:] >> extract_largest_cluster["input"],
#                      extract_largest_cluster[:] >> cloud2msg[:],
#                      cloud2msg[:] >> cloud_pub[:])
#        
#        run_plasm(options, plasm, locals=vars())

        plasm.connect(cloud_sub[:] >>  msg2cloud[:],
                      msg2cloud[:] >> nan_filter[:],
                      nan_filter[:] >> voxel_grid[:],
                      voxel_grid[:] >> extract_clusters[:],
                      extract_clusters[:] >> extract_largest_cluster["clusters"],
                      voxel_grid[:] >> extract_largest_cluster["input"],
                      extract_largest_cluster["output"] >> 'out')
        
        
        run_plasm(options, plasm, locals=output)
    def __init__(self):
        ecto_ros.init(sys.argv,"ecto_pcl_demo")
        
        parser = argparse.ArgumentParser(description='My awesome program thing.')
        
        scheduler_options(parser)
        options = parser.parse_args()

        plasm = ecto.Plasm()

        voxel_grid = VoxelGrid("voxel_grid", leaf_size=0.01)
        cropper = Cropper("cropper", x_min=-0.25, x_max=0.25, y_min=-0.25, y_max=0.25, z_min=0.0, z_max=1.0)
        
        convex_hull = ConvexHull("convex_hull")
        ror = RadiusOutlierRemoval("ror", min_neighbors=1, search_radius=1.0)
        sor = StatisticalOutlierRemoval("sor", mean_k=1)

        extract_indices = ExtractIndices("extract_indices", negative=False)
        extract_clusters = EuclideanClusterExtraction("extract_clusters", min_cluster_size=50, cluster_tolerance=0.005)
        extract_largest_cluster = ExtractLargestCluster("extract_largest_cluster")

        cloud_sub = ecto_sensor_msgs.Subscriber_PointCloud2("cloud_sub", topic_name='/camera/depth_registered/points')
        msg2cloud = ecto_pcl_ros.Message2PointCloud("msg2cloud", format=ecto_pcl.XYZRGB)
        
        cloud2msg = ecto_pcl_ros.PointCloud2Message("cloud2msg")
        cloud_pub = ecto_sensor_msgs.Publisher_PointCloud2("cloud_pub",topic_name='/ecto_pcl/sample_output')

        plasm.connect(cloud_sub[:] >> msg2cloud[:],
                      msg2cloud[:] >> extract_clusters[:],
                      extract_clusters[:] >> extract_largest_cluster["clusters"],
                      msg2cloud[:] >> extract_largest_cluster["input"],
                      extract_largest_cluster[:] >> cloud2msg[:],
                      cloud2msg[:] >> cloud_pub[:])
        
#        plasm.connect(cloud_sub[:] >> msg2cloud[:],
#                      msg2cloud[:] >> voxel_grid[:],
#                      msg2cloud[:] >> extract_indices["input"],
#                      voxel_grid[:] >> cropper[:],
#                      cropper[:] >> extract_clusters[:],
#                      extract_indices[:] >> extract_clusters[:],
#                      extract_clusters[:] >> extract_largest_cluster["clusters"],
#                      cropper[:] >>  extract_largest_cluster["input"],
#                      extract_largest_cluster[:] >> cloud2msg[:],
#                      cloud2msg[:] >> cloud_pub[:])
        
        run_plasm(options, plasm, locals=vars())
Пример #23
0
def execute_detection(cmd,path):
    parser = create_parser()

    # add ecto options
    scheduler_options(parser)
    pid = os.getpid()
    print("pid = ", pid)
    args = parser.parse_args(['-c', cmd])
    args = parser.parse_args(['--config_file', path])

    # create the plasm that will run the detection
    # args = parser.parse_args()
    ork_params, _args = read_arguments(args)
    plasm = create_plasm(ork_params)

    # run the detection plasm
    run_plasm(args, plasm)
    print "Exit Finished"
Пример #24
0
def test_bb2(options):
    # start is going to be ignored as it is set to 20 by default
    mm = MyBlackBox2(start=0, step=3, amount1=10, amount2=50)
    # make sure the declare functions work
    p = ecto.Tendrils()
    i = ecto.Tendrils()
    o = ecto.Tendrils()
    mm.declare_params(p)
    mm.declare_io(p, i, o)
    # run the BlackBox
    plasm = ecto.Plasm()
    plasm.insert(mm)
    options.niter = 5
    run_plasm(options, plasm)
    # final value is start + step*(5-1)+amount1+amount2
    assert mm.outputs.value == 92
    run_plasm(options, plasm)
    # final value is start + step*(5+5-1)+amount1+amount2
    assert mm.outputs.value == 107
Пример #25
0
    def __init__(self):
        ecto_ros.init(sys.argv, "ecto_pcl_demo")

        # Create the argument parser
        parser = argparse.ArgumentParser(description='Ecto PCL Cropper Demo')

        # Use the parser to create scheduler options
        scheduler_options(parser)
        options = parser.parse_args()

        # Create the overall plasm
        plasm = ecto.Plasm()

        # Create the Cropper cell with the desired dimensions (in meters)
        cropper = ecto_pcl.Cropper("cropper",
                                   x_min=-0.25,
                                   x_max=0.25,
                                   y_min=-0.25,
                                   y_max=0.25,
                                   z_min=0.0,
                                   z_max=1.0)

        # Create the subscriber cell with the appropriate point cloud topic
        cloud_sub = ecto_sensor_msgs.Subscriber_PointCloud2(
            "cloud_sub", topic_name='camera/depth_registered/points')

        # A cell to convert a point cloud ROS message to an Ecto/PCL point cloud object
        msg2cloud = ecto_pcl_ros.Message2PointCloud("msg2cloud",
                                                    format=ecto_pcl.XYZRGB)

        # A cell to convert a point cloud ROS message to an Ecto/PCL point cloud object
        cloud2msg = ecto_pcl_ros.PointCloud2Message("cloud2msg")

        # A publisher cell with the desired topic name
        cloud_pub = ecto_sensor_msgs.Publisher_PointCloud2(
            "cloud_pub", topic_name='ecto_pcl/cloud_filtered')

        # Create the plasm by connecting the cells
        plasm.connect(cloud_sub[:] >> msg2cloud[:], msg2cloud[:] >> cropper[:],
                      cropper[:] >> cloud2msg[:], cloud2msg[:] >> cloud_pub[:])

        # Run the plasm
        run_plasm(options, plasm, locals=vars())
Пример #26
0
def test_bb2(options):
    # start is going to be ignored as it is set to 20 by default
    mm = MyBlackBox2(start=0, step=3, amount1=10, amount2=50)
    # make sure the declare functions work
    p=ecto.Tendrils()
    i=ecto.Tendrils()
    o=ecto.Tendrils()
    mm.declare_params(p)
    mm.declare_io(p,i,o)
    # run the BlackBox
    plasm = ecto.Plasm()
    plasm.insert(mm)
    options.niter = 5
    run_plasm(options, plasm)
    # final value is start + step*(5-1)+amount1+amount2
    assert mm.outputs.value == 92
    run_plasm(options, plasm)
    # final value is start + step*(5+5-1)+amount1+amount2
    assert mm.outputs.value == 107
Пример #27
0
    def __init__(self):
        ecto_ros.init(sys.argv, "ecto_pcl_demo")

        parser = argparse.ArgumentParser(description="My awesome program thing.")

        scheduler_options(parser)
        options = parser.parse_args()

        plasm = ecto.Plasm()

        voxel_grid = VoxelGrid("voxel_grid", leaf_size=0.01)
        passthru_z = PassThrough("passthru_z", filter_field_name="z", filter_limit_min=0.0, filter_limit_max=1.0)
        passthru_x = PassThrough("passthru_x", filter_field_name="x", filter_limit_min=-0.25, filter_limit_max=0.25)
        passthru_y = PassThrough("passthru_y", filter_field_name="y", filter_limit_min=-0.25, filter_limit_max=0.25)
        cropper = Cropper("cropper", x_min=-0.25, x_max=0.25, y_min=-0.25, y_max=0.25, z_min=0.0, z_max=1.0)
        viewer = CloudViewer("viewer", window_name="Clouds!")

        cloud_sub = ecto_sensor_msgs.Subscriber_PointCloud2("cloud_sub", topic_name="/camera/depth_registered/points")
        msg2cloud = ecto_pcl_ros.Message2PointCloud("msg2cloud", format=ecto_pcl.XYZRGB)

        cloud2msg = ecto_pcl_ros.PointCloud2Message("cloud2msg")
        cloud_pub = ecto_sensor_msgs.Publisher_PointCloud2("cloud_pub", topic_name="/ecto_pcl/sample_output")

        plasm.connect(
            cloud_sub[:] >> msg2cloud[:],
            msg2cloud[:] >> voxel_grid[:],
            voxel_grid[:] >> passthru_z[:],
            passthru_z[:] >> passthru_x[:],
            passthru_x[:] >> passthru_y[:],
            passthru_y[:] >> cloud2msg[:],
            cloud2msg[:] >> cloud_pub[:],
        )

        #        plasm.connect(cloud_sub[:] >> msg2cloud[:],
        #                      msg2cloud[:] >> voxel_grid[:],
        #                      voxel_grid[:] >> cropper[:],
        #                      cropper[:] >> cloud2msg[:],
        #                      cloud2msg[:] >> cloud_pub[:])

        run_plasm(options, plasm, locals=vars())
Пример #28
0
    def __init__(self):
        ecto_ros.init(sys.argv,"ecto_pcl_demo")

        # Create the argument parser
        parser = argparse.ArgumentParser(description='Ecto PCL Demo')

        # Use the parser to create scheduler options        
        scheduler_options(parser)
        options = parser.parse_args()

        # Create the overall plasm
        plasm = ecto.Plasm()
        
        # Create three PassThrough cells along the x, y and z dimensions
        passthru_z = ecto_pcl.PassThrough("passthru_z", filter_field_name="z", filter_limit_min=0.0, filter_limit_max=1.0)
        passthru_x = ecto_pcl.PassThrough("passthru_x", filter_field_name="x", filter_limit_min=-0.25, filter_limit_max=0.25)
        passthru_y = ecto_pcl.PassThrough("passthru_y", filter_field_name="y", filter_limit_min=-0.25, filter_limit_max=0.25)
      
        # Create the subscriber cell with the appropriate point cloud topic
        cloud_sub = ecto_sensor_msgs.Subscriber_PointCloud2("cloud_sub", topic_name='camera/depth_registered/points')
        
        # A cell to convert a point cloud ROS message to an Ecto/PCL point cloud object                
        msg2cloud = ecto_pcl_ros.Message2PointCloud("msg2cloud", format=ecto_pcl.XYZRGB)
        
        # A cell to convert a point cloud ROS message to an Ecto/PCL point cloud object                
        cloud2msg = ecto_pcl_ros.PointCloud2Message("cloud2msg")
        
        # A publisher cell with the desired topic name
        cloud_pub = ecto_sensor_msgs.Publisher_PointCloud2("cloud_pub",topic_name='ecto_pcl/cloud_filtered')

        # Create the plasm by connecting the cells               
        plasm.connect(cloud_sub[:] >> msg2cloud[:],
                      msg2cloud[:] >> passthru_z[:],
                      passthru_z[:] >> passthru_x[:],
                      passthru_x[:] >> passthru_y[:],
                      passthru_y[:] >> cloud2msg[:],
                      cloud2msg[:] >> cloud_pub[:])
        # Run the plasm
        run_plasm(options, plasm, locals=vars())
Пример #29
0
    def __init__(self):
        ecto_ros.init(sys.argv,"ecto_pcl_demo")

        parser = argparse.ArgumentParser(description='Ecto Euclidean Clustering')

        scheduler_options(parser)
        options = parser.parse_args()

        plasm = ecto.Plasm()

        voxel_grid = VoxelGrid("voxel_grid", leaf_size=0.015)
        cropper = Cropper("cropper", x_min=-0.25, x_max=0.25, y_min=-0.25, y_max=0.25, z_min=0.3, z_max=1.0)
        passthru_z = PassThrough("passthru_z", filter_field_name="z", filter_limit_min=0.3, filter_limit_max=1.0)
        passthru_x = PassThrough("passthru_x", filter_field_name="x", filter_limit_min=-0.25, filter_limit_max=0.25)
        passthru_y = PassThrough("passthru_y", filter_field_name="y", filter_limit_min=-0.25, filter_limit_max=0.25)
        extract_clusters = EuclideanClusterExtraction("extract_clusters", min_cluster_size=50, cluster_tolerance=0.02)
        nan_filter = PassThrough("nan_removal")
        colorize = ColorizeClusters("colorize", max_clusters=100)

        cloud_sub = ecto_sensor_msgs.Subscriber_PointCloud2("cloud_sub", topic_name='/camera/depth_registered/points')
        msg2cloud = ecto_pcl_ros.Message2PointCloud("msg2cloud", format=ecto_pcl.XYZRGB)

        cloud2msg = ecto_pcl_ros.PointCloud2Message("cloud2msg")
        cloud_pub = ecto_sensor_msgs.Publisher_PointCloud2("cloud_pub",topic_name='/ecto_pcl/cloud_filtered')

        plasm.connect(cloud_sub[:] >>  msg2cloud[:],
                      msg2cloud[:] >> nan_filter[:],
                      nan_filter[:] >> voxel_grid[:],
                      voxel_grid[:] >> cropper[:],
                      cropper["output"] >> extract_clusters["input"],
                      extract_clusters[:] >> colorize["clusters"],
                      cropper[:] >> colorize["input"],
                      colorize[:] >> cloud2msg[:],
                      cloud2msg[:] >> cloud_pub[:])

        run_plasm(options, plasm, locals=vars())
def do_ecto():
    # ecto options
    parser = argparse.ArgumentParser(
        description='Publish images from directory.')
    scheduler_options(parser)
    args = parser.parse_args()

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

    pub_rgb = ImagePub("image_pub", topic_name='/camera/rgb/image_raw')
    display = imshow(name='image', waitKey=5000)

    plasm = ecto.Plasm()
    plasm.connect(
        images['image'] >> mat2image['image'],
        images['image'] >> display['image'],
        mat2image['image'] >> pub_rgb['input'],
    )

    ecto.view_plasm(plasm)
    run_plasm(args, plasm, locals=vars())
    def __init__(self):
        ecto_ros.init(sys.argv,"ecto_pcl_demo")
        
        # Create the argument parser
        parser = argparse.ArgumentParser(description='Ecto PCL Cropper Demo')
        
        # Use the parser to create scheduler options
        scheduler_options(parser)
        options = parser.parse_args()

        # Create the overall plasm
        plasm = ecto.Plasm()

        # Create the Cropper cell with the desired dimensions (in meters)
        cropper = ecto_pcl.Cropper("cropper", x_min=-0.25, x_max=0.25, y_min=-0.25, y_max=0.25, z_min=0.0, z_max=1.0)
      
        # Create the subscriber cell with the appropriate point cloud topic
        cloud_sub = ecto_sensor_msgs.Subscriber_PointCloud2("cloud_sub", topic_name='camera/depth_registered/points')
        
        # A cell to convert a point cloud ROS message to an Ecto/PCL point cloud object                
        msg2cloud = ecto_pcl_ros.Message2PointCloud("msg2cloud", format=ecto_pcl.XYZRGB)
        
        # A cell to convert a point cloud ROS message to an Ecto/PCL point cloud object                
        cloud2msg = ecto_pcl_ros.PointCloud2Message("cloud2msg")
        
        # A publisher cell with the desired topic name
        cloud_pub = ecto_sensor_msgs.Publisher_PointCloud2("cloud_pub",topic_name='ecto_pcl/cloud_filtered')

        # Create the plasm by connecting the cells
        plasm.connect(cloud_sub[:] >> msg2cloud[:],
                      msg2cloud[:] >> cropper[:],
                      cropper[:] >> cloud2msg[:],
                      cloud2msg[:] >> cloud_pub[:])
        
        # Run the plasm
        run_plasm(options, plasm, locals=vars())
Пример #32
0
 def setUp(self):
     options.rerun = 'odm_georeferencing'
     self.app, self.plasm = appSetup(options)
     run_plasm(options, self.plasm)
Пример #33
0
 def setUp(self):
     options.rerun = 'odm_orthophoto'
     self.app, self.plasm = appSetup(options)
     run_plasm(options, self.plasm)
Пример #34
0
    def __init__(self):
        ecto_ros.init(sys.argv,"ecto_pcl_demo")

        # Create the argument parser        
        parser = argparse.ArgumentParser(description='Ecto Tabletop Segmentation')
        
        # Use the parser to create scheduler options        
        scheduler_options(parser)
        options = parser.parse_args()

        # Create the overall plasm
        plasm = ecto.Plasm()

        cloud_sub = ecto_sensor_msgs.Subscriber_PointCloud2("cloud_sub", topic_name='/camera/depth_registered/points')
        msg2cloud = ecto_pcl_ros.Message2PointCloud("msg2cloud", format=ecto_pcl.XYZRGB)
        
        cloud2msg = ecto_pcl_ros.PointCloud2Message("cloud2msg")
        cloud_pub = ecto_sensor_msgs.Publisher_PointCloud2("cloud_pub",topic_name='ecto_pcl/cloud_filtered')
        
        voxel_grid = VoxelGrid("voxel_grid", leaf_size=0.01)
        
        graph = [cloud_sub["output"] >> msg2cloud[:],
                 msg2cloud[:] >> voxel_grid[:]
                 ]
        
        # estimate normals, segment and find convex hull
        normals = NormalEstimation("normals", k_search=0, radius_search=0.02)
        planar_segmentation = SACSegmentationFromNormals("planar_segmentation",
                                                         model_type=SACMODEL_NORMAL_PLANE,
                                                         eps_angle=0.09, distance_threshold=0.1)
        project_inliers = ProjectInliers("project_inliers", model_type=SACMODEL_NORMAL_PLANE)
        nan_filter = PassThrough('nan_removal')
        convex_hull = ConvexHull("convex_hull")
        
        graph += [voxel_grid[:] >> normals[:],
                  voxel_grid[:] >> planar_segmentation["input"],
                  normals[:] >> planar_segmentation["normals"],
                  voxel_grid[:] >> project_inliers["input"],
                  planar_segmentation["model"] >> project_inliers["model"],
                  project_inliers[:] >> nan_filter[:],
                  nan_filter[:] >> convex_hull[:]
                  ]
        
        
        # extract stuff on table from original high-res cloud and show in viewer
        extract_stuff = ExtractPolygonalPrismData("extract_stuff", height_min=0.01, height_max=0.2)
        extract_indices = ExtractIndices("extract_indices", negative=False)
        viewer = CloudViewer("viewer", window_name="Clouds!")
        
        graph += [msg2cloud[:] >> extract_stuff["input"],
                  convex_hull[:] >> extract_stuff["planar_hull"],
                  extract_stuff[:] >> extract_indices["indices"],
                  msg2cloud[:] >> extract_indices["input"],
                  extract_indices[:] >> cloud2msg[:],
                  cloud2msg[:] >> cloud_pub[:]
                  ]
        
        plasm.connect(graph)
        
        # Run the plasm
        run_plasm(options, plasm, locals=vars())
Пример #35
0
#!/usr/bin/env python
import argparse
from object_recognition.capture import create_openni_bag_capture_plasm
from ecto.opts import scheduler_options, run_plasm
import ecto_ros
import sys
parser = argparse.ArgumentParser(
    description='Capture a bag of data from the kinect.')
scheduler_options(parser)
parser.add_argument('bagname', nargs=1, type=str)
options = parser.parse_args()
plasm = create_openni_bag_capture_plasm(options.bagname[0])
ecto_ros.init(sys.argv, 'data_capture')
run_plasm(options, plasm, locals)
Пример #36
0
from ecto.opts import run_plasm, scheduler_options

import argparse
import sys
import os

parser = argparse.ArgumentParser(description='Saves images from a connect on keystroke.')
parser.add_argument('-o,--output', dest='output', help='The output directory. Default: %(default)s', default='./images')

#ecto options
scheduler_options(parser.add_argument_group('Scheduler Options'))
args = parser.parse_args()

if not os.path.exists(args.output):
    os.makedirs(args.output)

source = create_source(package_name='image_pipeline', source_type='OpenNISource') #optionally pass keyword args here...

depth_saver = ecto.If('depth saver', cell=ImageSaver(filename_format=os.path.join(args.output, 'depth%04d.png')))
image_saver = ecto.If('rgb saver', cell=ImageSaver(filename_format=os.path.join(args.output, 'image%04d.png')))

display = imshow(name='RGB', triggers=dict(save=ord('s')))

plasm = ecto.Plasm()
plasm.connect(source['image'] >> (display['image'], image_saver['image']),
              source['depth'] >> (imshow(name='Depth')['image'], depth_saver['image']),
              display['save'] >> (image_saver['__test__'], depth_saver['__test__'])
              )

run_plasm(args, plasm, locals=vars())
Пример #37
0
 def setUp(self):
     options.rerun = 'pmvs'
     self.app, self.plasm = appSetup(options)
     run_plasm(options, self.plasm)
Пример #38
0
#!/usr/bin/env python
import argparse
from object_recognition.capture import create_openni_bag_capture_plasm
from ecto.opts import scheduler_options, run_plasm
import ecto_ros
import sys
parser = argparse.ArgumentParser(description='Capture a bag of data from the kinect.')
scheduler_options(parser)
parser.add_argument('bagname', nargs=1, type=str)
options = parser.parse_args()
plasm = create_openni_bag_capture_plasm(options.bagname[0])
ecto_ros.init(sys.argv, 'data_capture')
run_plasm(options, plasm, locals)

Пример #39
0
 def setUp(self):
     options.rerun = 'pmvs'
     self.app, self.plasm = appSetup(options)
     run_plasm(options, self.plasm)
Пример #40
0
    def __init__(self):
        ecto_ros.init(sys.argv, "ecto_pcl_demo")

        # Create the argument parser
        parser = argparse.ArgumentParser(
            description='Ecto Euclidean Clustering')

        # Use the parser to create scheduler options
        scheduler_options(parser)
        options = parser.parse_args()

        # Create the overall plasm
        plasm = ecto.Plasm()

        # A VoxelGrid cell
        voxel_grid = ecto_pcl.VoxelGrid("voxel_grid", leaf_size=0.01)

        # A Cropper cell
        cropper = ecto_pcl.Cropper("cropper",
                                   x_min=-0.35,
                                   x_max=0.35,
                                   y_min=-0.35,
                                   y_max=0.35,
                                   z_min=0.3,
                                   z_max=1.5)

        # A EuclideanClusterExtraction cell
        extract_clusters = ecto_pcl.EuclideanClusterExtraction(
            "extract_clusters", min_cluster_size=50, cluster_tolerance=0.02)

        # A cell to filter NaN values from the point cloud
        nan_filter = ecto_pcl.PassThrough("nan_removal")

        # A cell to colorize the clusters
        colorize = ecto_pcl.ColorizeClusters("colorize", max_clusters=100)

        # Create the subscriber cell with the appropriate point cloud topic
        cloud_sub = ecto_sensor_msgs.Subscriber_PointCloud2(
            "cloud_sub", topic_name='camera/depth_registered/points')

        # A cell to convert a point cloud ROS message to an Ecto/PCL point cloud object
        msg2cloud = ecto_pcl_ros.Message2PointCloud("msg2cloud",
                                                    format=ecto_pcl.XYZRGB)

        # A cell to convert a Ecto/PCL point cloud back to a point cloud message
        cloud2msg = ecto_pcl_ros.PointCloud2Message("cloud2msg")

        # A cell to convert a point cloud ROS message to an Ecto/PCL point cloud object
        cloud_pub = ecto_sensor_msgs.Publisher_PointCloud2(
            "cloud_pub", topic_name='ecto_pcl/cloud_filtered')

        # Create the plasm by connecting the cells
        plasm.connect(
            cloud_sub[:] >> msg2cloud[:], msg2cloud[:] >> nan_filter[:],
            nan_filter[:] >> voxel_grid[:], voxel_grid[:] >> cropper[:],
            cropper[:] >> extract_clusters[:],
            extract_clusters[:] >> colorize["clusters"],
            cropper[:] >> colorize["input"], colorize[:] >> cloud2msg[:],
            cloud2msg[:] >> cloud_pub[:])

        # Run the plasm
        run_plasm(options, plasm, locals=vars())
Пример #41
0
        '-a',
        '--angle_thresh',
        metavar='RADIANS',
        dest='angle_thresh',
        type=float,
        default=math.pi / 36,
        help='''The delta angular threshold in pose. Default is pi/36 radians.
                            Frames will not be recorded unless they are not closer to any other pose by this amount.
                            ''')

    from ecto.opts import scheduler_options
    #add ecto scheduler args.
    group = parser.add_argument_group('ecto scheduler options')
    scheduler_options(group, default_scheduler='Threadpool')
    args = parser.parse_args()
    if len(args.bag) < 1:
        print parser.print_help()
        sys.exit(1)
    return args


if "__main__" == __name__:
    argv = sys.argv[:]
    ecto_ros.strip_ros_args(sys.argv)
    options = parse_args()
    ecto_ros.init(argv, "openni_capture", False)
    plasm = openni_capture.create_capture_plasm(options.bag,
                                                options.angle_thresh)
    from ecto.opts import run_plasm
    run_plasm(options, plasm)
Пример #42
0
    def __init__(self):
        ecto_ros.init(sys.argv,"ecto_tracker")
        
        parser = argparse.ArgumentParser(description='Ecto Tracker.')
        
        scheduler_options(parser)
        options = parser.parse_args()

        plasm = ecto.Plasm()
                
        voxel_grid = VoxelGrid("voxel_grid", leaf_size=0.01)
        passthru_z = PassThrough("passthru_z", filter_field_name="z", filter_limit_min=0.2, filter_limit_max=1.0)
        passthru_x = PassThrough("passthru_x", filter_field_name="x", filter_limit_min=-0.5, filter_limit_max=0.5)
        passthru_y = PassThrough("passthru_y", filter_field_name="y", filter_limit_min=-0.5, filter_limit_max=0.5)
        nan_filter = PassThrough("nan_removal")
        cropper = Cropper("cropper", x_min=-0.5, x_max=0.5, y_min=-0.5, y_max=0.5, z_min=0.0, z_max=1.0)
        #convex_hull = ConvexHull("convex_hull")
#        
        extract_stuff = ExtractPolygonalPrismData("extract_stuff", height_min=0.01, height_max=0.2)
        extract_indices = ExtractIndices("extract_indices", negative=False)
        extract_clusters = EuclideanClusterExtraction("extract_clusters", min_cluster_size=50, cluster_tolerance=0.005)
        extract_largest_cluster = ExtractLargestCluster("extract_largest_cluster")
        colorize = ColorizeClusters("colorize", max_clusters=3)
        merge = MergeClouds("merge")
        viewer = CloudViewer("viewer", window_name="Clouds!")

#        
        cloud_sub = ecto_sensor_msgs.Subscriber_PointCloud2("cloud_sub", topic_name='/camera/depth_registered/points')
        msg2cloud = ecto_pcl_ros.Message2PointCloud("msg2cloud", format=ecto_pcl.XYZRGB)
        
        cloud2msg = ecto_pcl_ros.PointCloud2Message("cloud2msg")
        cloud_pub = ecto_sensor_msgs.Publisher_PointCloud2("cloud_pub",topic_name='/ecto_pcl/sample_output')
        
#        plasm.connect(cloud_sub["output"] >> msg2cloud[:],
#                      msg2cloud[:] >> voxel_grid[:],
##                      voxel_grid[:] >> extract_indices[:],
#                      voxel_grid[:] >> cloud2msg[:],  
#                      cloud2msg[:] >> cloud_pub[:],)
#
##        plasm += [voxel_grid['output'] >> extract_clusters[:],
##                  extract_clusters[:] >> colorize["clusters"],
##                  cloud_generator[:] >> merge["input"],
##          colorize[:] >> merge["input2"],
##          colorize[:] >> viewer[:]
##          ]
#        
#

        plasm.connect(cloud_sub[:] >> msg2cloud[:],
                      msg2cloud[:] >> voxel_grid[:],
                      voxel_grid[:] >> cropper[:],
                      cropper[:] >> extract_clusters[:],
                      msg2cloud[:] >> extract_indices["input"],
                      extract_clusters[:] >> colorize["clusters"],
                      extract_indices[:] >> colorize["input"],
                      msg2cloud[:] >> merge["input"],
                      colorize[:] >> merge["input2"],
                      merge[:] >> cloud2msg[:],
                      cloud2msg[:] >> cloud_pub[:],)

#        plasm.connect(cloud_sub["output"] >> msg2cloud[:],
#                      msg2cloud[:] >> voxel_grid[:],
#                      #voxel_grid[:] >> nan_filter[:],
#                      #nan_filter[:] >> extract_indices["indices"],
#                      voxel_grid[:] >> extract_indices["indices"],
#                      msg2cloud[:] >> extract_indices["input"],)
#                      #extract_indices[:] >> extract_clusters[:],)
##                      extract_clusters[:] >> colorize["clusters"],
##                      extract_indices[:] >> colorize["input"],
##                      msg2cloud[:] >> merge["input"],
##                      colorize[:] >> merge["input2"],
##                      colorize[:] >> viewer[:],)

#        plasm.connect(cloud_sub["output"] >> msg2cloud[:],
#                      msg2cloud[:] >> voxel_grid["input"],
#                      voxel_grid["output"] >> passthru_z["input"],
#                      passthru_z["output"] >> passthru_x["input"],
#                      passthru_x["output"] >> passthru_y["input"],
#                      passthru_y["output"] >> extract_indices["input"],
#                      passthru_y["output"] >> extract_clusters["input"],
#                      extract_clusters[:] >> colorize["clusters"],
#                      extract_indices[:] >> colorize["input"],
#                      msg2cloud[:] >> merge["input"],
#                      colorize[:] >> merge["input2"],
#                      colorize[:] >> viewer[:],)
#
#                      #passthru_y["output"] >> cloud2msg[:],
#                      #cloud2msg[:] >> cloud_pub[:],)
        
        
        run_plasm(options, plasm, locals=vars())
        #sched = ecto.Scheduler(plasm)
        #sched.execute_async()

        time.sleep(10)
Пример #43
0
 def setUp(self):
     options.rerun = 'odm_texturing'
     self.app, self.plasm = appSetup(options)
     run_plasm(options, self.plasm)
Пример #44
0
def match(options,
        scale=1.0,
        train_scale=1 / 3.0,
        scale_factor=1.05,
        n_levels=5,
        n_features_train=10000,
        n_features_test=1000,
        match_distance=120,
    ):

    if not os.path.exists(options.output):
        os.makedirs(options.output)

    train = imread('Train image', image_file=options.train,
                   mode=ImageMode.GRAYSCALE)
    test = imread('Test image', image_file=options.test,
            mode=ImageMode.GRAYSCALE)
    train_name, _extension = os.path.splitext(os.path.basename(options.train))
    test_name, _extension = os.path.splitext(os.path.basename(options.test))

    print 'Scale %d is %f' % (0, scale)
    for i in range(n_levels - 1):
        scale *= 1.0 / scale_factor
        print 'Scale %d is %f' % (i + 1, scale)
    orb_train = ORB(n_features=n_features_train,
            n_levels=n_levels, scale_factor=scale_factor)
    orb_test = ORB(n_features=n_features_test, n_levels=1)

    plasm = ecto.Plasm()
    scale = Scale(factor=train_scale, interpolation=AREA)
    plasm.connect(train['image'] >> scale['image'])

    train_pts = hookup_orb(plasm, scale, orb_train)
    test_pts = hookup_orb(plasm, test, orb_test)

    matcher = Matcher()
    plasm.connect(orb_train['descriptors'] >> matcher['train'],
                 orb_test['descriptors'] >> matcher['test'],
                 )

    matchesMat = MatchesToMat()
    h_est = MatchRefinement(match_distance=match_distance)
    plasm.connect(train_pts['points'] >> h_est['train'],
                  test_pts['points'] >> h_est['test'],
                  matcher['matches'] >> h_est['matches'],
                  h_est['matches'] >> matchesMat['matches']
                  )

    match_draw = DrawMatches()
    output_base = os.path.join(options.output,
            '%(train)s_%(test)s' %
            dict(train=train_name, test=test_name))
    match_image = output_base + '.png'
    image_saver = ImageSaver(filename=match_image)

    plasm.connect(train_pts['points'] >> match_draw['train'],
                  test_pts['points'] >> match_draw['test'],
                  h_est['matches'] >> match_draw['matches'],
                  h_est['matches_mask'] >> match_draw['matches_mask'],
                  scale['image'] >> match_draw['train_image'],
                  test['image'] >> match_draw['test_image'],
                  match_draw[:] >> image_saver[:]
                  )

    match_eval = MatchEval(output=options.output)
    plasm.connect(matchesMat['matches'] >> match_eval['matches'],
                  train_pts['points'] >> match_eval['train'],
                  test_pts['points'] >> match_eval['test'],
                  h_est['matches_mask'] >> match_eval['inliers'],
                  )
    run_plasm(options, plasm, locals=vars())
viewer = cloud_treatment.CloudViewerCell("Viewer_ecto",
					window_name="PCD Viewer")

graph = [cloud_sub["output"] >> msg2cloud[:],
         msg2cloud[:] >> passthrough3d["input"],
         passthrough3d["output"] >> stepsegmenter["input"],
         #principalcomponent["centroids"] >> viewer["VIPoints"],
         #principalcomponent["rectangles"] >> viewer["rectangles"],
         stepsegmenter["clusters"] >> colorize["clusters"],
         passthrough3d["output"] >> colorize["input"], 
         stepsegmenter["clusters"] >> principalcomponent["clusters"],
         passthrough3d["output"] >> principalcomponent["input"],  
         #colorize[:] >> viewer["input"]
         passthrough3d["output"] >> cloud2msg_main[:],
         cloud2msg_main[:] >> cloud_pub_main[:],
         colorize[:] >> cloud2msg_seg[:],
         cloud2msg_seg[:] >> cloud_pub_seg[:]
	]
#graph = [cloud_sub["output"] >> msg2cloud[:],
#         msg2cloud[:] >> cloud2msg[:],
#         cloud2msg[:] >> cloud_pub[:]
#	]

plasm = ecto.Plasm()
plasm.connect(graph)

run_plasm(options, plasm, locals=vars())
#plasm.execute()
print "plasm_ecto executed"

Пример #46
0
 def setUp(self):
     options.rerun = 'odm_orthophoto'
     self.app, self.plasm = appSetup(options)
     run_plasm(options, self.plasm)
Пример #47
0
scheduler_options(parser.add_argument_group('Scheduler Options'))
args = parser.parse_args()

if not os.path.exists(args.output):
    os.makedirs(args.output)

#camera = VideoCapture(video_device=1,width=int(args.width),height=int(args.height))
source = create_source(
    package_name='image_pipeline',
    source_type='OpenNISource')  #optionally pass keyword args here...
depth_saver = ImageSaver(
    filename_format=os.path.join(args.output, 'frame_%010d_depth.png'))
image_saver = ImageSaver(
    filename_format=os.path.join(args.output, 'frame_%010d_image.png'))
#mono_saver = ImageSaver(filename_format=os.path.join(args.output, 'frame_%010d_mono.png'))

plasm = ecto.Plasm()
plasm.connect(
    #      camera['image'] >> imshow(name='Mono')['image'],
    source['depth'] >> imshow(name='Depth')['image'],
    source['image'] >> imshow(name='RGB')['image'])

if not args.preview:
    plasm.connect(
        source['image'] >> image_saver['image'],
        source['depth'] >> depth_saver['image'],
        #        camera['image'] >> mono_saver['image'],
    )

run_plasm(args, plasm, locals=vars())
Пример #48
0
 def setUp(self):
     options.rerun = 'odm_texturing'
     self.app, self.plasm = appSetup(options)
     run_plasm(options, self.plasm)
Пример #49
0
    return options


options = parse_args()

images = ImageReader(path=options.input)
orb_m = ORB(n_features=5000, n_levels=10)
rgb2gray = cvtColor(flag=Conversion.RGB2GRAY)
_stats = ORBstats()
stats = ecto.If(cell=_stats)
stats.inputs.__test__ = False
accum = DescriptorAccumulator()
plasm = ecto.Plasm()
plasm.connect(
    images['image'] >> rgb2gray['image'],
    rgb2gray['image'] >> orb_m['image'],
    orb_m['descriptors'] >> accum[:],
    accum[:] >> stats['descriptors'],
)

run_plasm(options, plasm, locals=vars())
_stats.process()
hist = _stats.outputs.distances.toarray()
np.savetxt('hist.txt', hist)

print np.sum(hist)
plt.plot(hist)
plt.xlim((0, 255))
plt.xticks((0, 64, 128, 192, 256))
plt.savefig('fig.pdf')
Пример #50
0
 def setUp(self):
     options.rerun = 'odm_georeferencing'
     self.app, self.plasm = appSetup(options)
     run_plasm(options, self.plasm)