latch_ref['output'] >> draw_kpts_ref['image'],
              draw_kpts_ref['image'] >> imshow('reference orb display', name='ORB reference')['image'],
              )


# put in the estimator
posest = PoseEstimator3DProj(show_matches=True)
kmat = KeypointsToMat()
kmat_ref = KeypointsToMat()

plasm.connect(img_src >> posest['image'],
              latch_ref['output'] >> posest['image_ref'],
              orb['keypoints'] >> kmat['keypoints'],
              kmat['points'] >> posest['points'],
              orb_ref['keypoints'] >> kmat_ref['keypoints'],
              kmat_ref['points'] >> posest['points_ref'],
              orb['points3d'] >> posest['points3d'],
              orb_ref['points3d'] >> posest['points3d_ref'],
              orb['descriptors'] >> posest['desc'],
              orb_ref['descriptors'] >> posest['desc_ref'],
              capture['K'] >> posest['K']
              )

if __name__ == '__main__':
    from ecto.opts import doit
    doit(plasm, description='Pose estimation on an RGBD device.')

#sched = ecto.schedulers.Singlethreaded(plasm)
#sched.execute()

Пример #2
0
import ecto
import ecto_sim
from object_recognition.common.io.standalone.source import KinectReader
from object_recognition.observations import *
from ecto_opencv import highgui, calib, imgproc, cv_bp as cv
from object_recognition.observations import *
from ecto_object_recognition import capture

plasm = ecto.Plasm()
kinect = ecto_sim.FiducialSim(image_name='board.png', width=0.4, height=0.8)
poser = OpposingDotPoseEstimator(plasm,
                                 rows=5, cols=3,
                                 pattern_type=calib.ASYMMETRIC_CIRCLES_GRID,
                                 square_size=0.04, debug=True)

rgb2gray = imgproc.cvtColor('rgb -> gray', flag=imgproc.Conversion.RGB2GRAY)
display = highgui.imshow(name='Pose')
depth_display = highgui.imshow(name='Depth')
graph = [kinect['image'] >> (rgb2gray[:], poser['color_image']),
          rgb2gray[:] >> poser['image'],
          poser['debug_image'] >> display['image'],
          kinect['K'] >> poser['K'],
          kinect['depth'] >> depth_display[:],
          ]
plasm.connect(graph)

if __name__ == '__main__':
    from ecto.opts import doit
    doit(plasm, description='Simulate pose estimation')
Пример #3
0
#!/usr/bin/env python
"""
This example shows how to read/write pcd files.
"""

import ecto, ecto_pcl
import sys
import os

plasm = ecto.Plasm()

pcdfile = os.path.join(os.path.dirname(__file__), 'cloud.pcd')
if len(sys.argv) > 1:
    pcdfile = sys.argv[1]

reader = ecto_pcl.PCDReader("Reader", filename=pcdfile)
writer = ecto_pcl.PCDWriter("Writer",
                            filename_format="ascii_%04d.pcd",
                            binary=False)

plasm.connect(reader[:] >> writer[:])

if __name__ == "__main__":
    from ecto.opts import doit
    doit(plasm, description='Read/write pcd.', default_niter=1)
Пример #4
0
pattern_type = ASYMMETRIC_CIRCLES_GRID

pattern_show = imshow('Display', name='pattern')
rgb2gray = cvtColor('RGB -> Gray', flag=Conversion.RGB2GRAY)
video = VideoCapture(video_device=0)
circle_detector = PatternDetector(rows=rows, cols=cols,
                                  pattern_type=pattern_type,
                                  square_size=square_size)
circle_drawer = PatternDrawer(rows=rows, cols=cols)
poser = FiducialPoseFinder()
pose_drawer = PoseDrawer()
camera_intrinsics = CameraIntrinsics(camera_file=calibration_file)

plasm = ecto.Plasm()
plasm.connect(video['image'] >> (rgb2gray['image'], circle_drawer['input']),
            rgb2gray['image'] >> circle_detector['input'],
            circle_detector['out', 'found'] >> circle_drawer['points', 'found'],
            camera_intrinsics['K'] >> poser['K'],
            circle_detector['out', 'ideal', 'found'] >> poser['points', 'ideal', 'found'],
            poser['R', 'T'] >> pose_drawer['R', 'T'],
            circle_drawer['out'] >> pose_drawer['image'],
            camera_intrinsics['K'] >> pose_drawer['K'],
            pose_drawer['output'] >> pattern_show['image'],
            )

if __name__ == '__main__':
    from ecto.opts import doit
    doit(plasm, description='Estimate the pose of a dot pattern.')

Пример #5
0
#!/usr/bin/env python
import ecto
from ecto_opencv.highgui import VideoCapture, imshow, FPSDrawer
from ecto_opencv.imgproc import Scale, Interpolation
video_cap = VideoCapture(video_device=0, width=640, height=480)
fps = FPSDrawer()
factor = 0.1
scale_down = Scale(factor=factor, interpolation=Interpolation.AREA)
scale_up = Scale(factor=1 / factor, interpolation=Interpolation.LANCZOS4)

plasm = ecto.Plasm()
plasm.connect(
    video_cap['image'] >> scale_down['image'],
    scale_down['image'] >> scale_up['image'],
    scale_up['image'] >> fps['image'],
    fps['image'] >> imshow(name='Rescaled')['image'],
)

if __name__ == '__main__':
    from ecto.opts import doit
    doit(plasm,
         description='Capture a video from the device and display it.',
         locals=vars())
Пример #6
0
                      name='video_cap', triggers=dict(save=ord('s')),
                      )

saver = ecto.If(cell=ImageSaver('saver', filename_format='bilateral_%05d.jpg',
                                   start=1))

bl_begin = None
bl_end = None

plasm = ecto.Plasm()
#Build up a chain of bilateral filters.
for i in range(1, 10):
    next = BilateralFilter(d= -1, sigmaColor=10, sigmaSpace=5)
    if bl_begin == None: # beginning case
        bl_begin = next
        bl_end = next
        continue
    plasm.connect(bl_end[:] >> next[:])
    bl_end = next

plasm.connect(video_cap['image'] >> fps['image'],
              fps['image'] >> bl_begin[:],
              bl_end[:] >> (video_display['image'], saver['image']),
              video_display['save'] >> saver['__test__'],
              )

if __name__ == '__main__':
    from ecto.opts import doit
    doit(plasm, description='Run a chain of bilateral smoothing filters on a video stream.')

    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 += [
    cloud_generator[:] >> extract_stuff["input"],
    convex_hull[:] >> extract_stuff["planar_hull"],
    extract_stuff[:] >> extract_indices["indices"],
    cloud_generator[:] >> extract_indices["input"],
    extract_indices[:] >> viewer[:],
]

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

if __name__ == "__main__":
    from ecto.opts import doit

    doit(plasm, description="Execute tabletop segmentation.")
Пример #8
0
#!/usr/bin/env python

"""
This example shows how to read/write pcd files.
"""

import ecto, ecto_pcl
import sys
import os

plasm = ecto.Plasm()

pcdfile = os.path.join(os.path.dirname(__file__),'cloud.pcd')
if len(sys.argv) > 1:
    pcdfile = sys.argv[1]

reader = ecto_pcl.PCDReader("Reader", filename=pcdfile)
writer = ecto_pcl.PCDWriter("Writer",
                            filename_format="ascii_%04d.pcd", binary=False)

plasm.connect(reader[:] >> writer[:])

if __name__=="__main__":
    from ecto.opts import doit
    doit(plasm, description='Read/write pcd.', default_niter=1)
Пример #9
0
#!/usr/bin/env python
import ecto
from ecto_opencv.highgui import VideoCapture, imshow, FPSDrawer
from ecto_opencv.features2d import ORB, DrawKeypoints
from ecto_opencv.imgproc import cvtColor, Conversion

video = VideoCapture(video_device=0)
orb_m = ORB(n_features=2500)
draw_kpts = DrawKeypoints()
rgb2gray = cvtColor(flag=Conversion.RGB2GRAY)
fps = FPSDrawer()

plasm = ecto.Plasm()
plasm.connect(
    video["image"] >> rgb2gray["image"],
    rgb2gray["image"] >> orb_m["image"],
    orb_m["keypoints"] >> draw_kpts["keypoints"],
    video["image"] >> draw_kpts["image"],
    draw_kpts["image"] >> fps[:],
    fps[:] >> imshow("orb display", name="ORB")["image"],
)

if __name__ == "__main__":
    from ecto.opts import doit

    doit(plasm, description="Computes the ORB feature and descriptor on a video stream.")
Пример #10
0
#!/usr/bin/env python
import ecto
from ecto_opencv.highgui import VideoCapture, imshow, FPSDrawer, ImageSaver

video_cap = VideoCapture(video_device=0)
fps = FPSDrawer()
video_display = imshow(name='video_cap', triggers=dict(save=ord('s')))
saver = ecto.If(cell=ImageSaver('saver', filename_format='ecto_image_%05d.jpg',
                                   start=1))

plasm = ecto.Plasm()
plasm.connect(video_cap['image'] >> fps['image'],
              fps['image'] >> video_display['image'],
              video_display['save'] >> saver['__test__'],
              fps['image'] >> saver['image'],
              )

if __name__ == '__main__':
    from ecto.opts import doit
    doit(plasm, description='Save images from video stream.')
Пример #11
0
#!/usr/bin/env python
import ecto
from ecto_opencv.highgui import VideoCapture, imshow, FPSDrawer
from ecto_opencv.features2d import ORB, DrawKeypoints
from ecto_opencv.imgproc import cvtColor, Conversion

video = VideoCapture(video_device=0)
orb_m = ORB(n_features=2500)
draw_kpts = DrawKeypoints()
rgb2gray = cvtColor(flag=Conversion.RGB2GRAY)
fps = FPSDrawer()

plasm = ecto.Plasm()
plasm.connect(
    video['image'] >> rgb2gray['image'],
    rgb2gray['image'] >> orb_m['image'],
    orb_m['keypoints'] >> draw_kpts['keypoints'],
    video['image'] >> draw_kpts['image'],
    draw_kpts['image'] >> fps[:],
    fps[:] >> imshow('orb display', name='ORB')['image'],
)

if __name__ == '__main__':
    from ecto.opts import doit
    doit(
        plasm,
        description='Computes the ORB feature and descriptor on a video stream.'
    )
Пример #12
0
disp = imshow('orb display', name='ORB', triggers=dict(save=ord('s')))

plasm.connect(img_src >> orb['image'],
              orb['keypoints'] >> draw_kpts['keypoints'],
              capture['image'] >> draw_kpts['image'],
              draw_kpts['image'] >> fps[:],
              fps[:] >> disp['image'],
              )

# connect up the reference ORB
orb_ref = ORB(n_features=n_feats)
draw_kpts_ref = DrawKeypoints()
latch_ref = LatchMat(init=True)

plasm.connect(img_src >> latch_ref['input'],
              latch_ref['output'] >> orb_ref['image'],
              disp['save'] >> latch_ref['set'],
              orb_ref['keypoints'] >> draw_kpts_ref['keypoints'],
              latch_ref['output'] >> draw_kpts_ref['image'],
              draw_kpts_ref['image'] >> imshow('reference orb display', name='ORB reference')['image'],
              )


if __name__ == '__main__':
    from ecto.opts import doit
    doit(plasm, description='Computes the ORB feature and descriptor on an RGBD device.')

#sched = ecto.schedulers.Singlethreaded(plasm)
#sched.execute()

Пример #13
0
pattern_show = imshow('Display', name='pattern')
rgb2gray = cvtColor('RGB -> Gray', flag=Conversion.RGB2GRAY)
video = VideoCapture(video_device=0)
circle_detector = PatternDetector(rows=rows,
                                  cols=cols,
                                  pattern_type=pattern_type,
                                  square_size=square_size)
circle_drawer = PatternDrawer(rows=rows, cols=cols)
poser = FiducialPoseFinder()
pose_drawer = PoseDrawer()
camera_intrinsics = CameraIntrinsics(camera_file=calibration_file)

plasm = ecto.Plasm()
plasm.connect(
    video['image'] >> (rgb2gray['image'], circle_drawer['input']),
    rgb2gray['image'] >> circle_detector['input'],
    circle_detector['out', 'found'] >> circle_drawer['points', 'found'],
    camera_intrinsics['K'] >> poser['K'],
    circle_detector['out', 'ideal', 'found'] >> poser['points', 'ideal',
                                                      'found'],
    poser['R', 'T'] >> pose_drawer['R', 'T'],
    circle_drawer['out'] >> pose_drawer['image'],
    camera_intrinsics['K'] >> pose_drawer['K'],
    pose_drawer['output'] >> pattern_show['image'],
)

if __name__ == '__main__':
    from ecto.opts import doit
    doit(plasm, description='Estimate the pose of a dot pattern.')
Пример #14
0
#       documentation and/or other materials provided with the distribution.
#     * Neither the name of the Willow Garage, Inc. nor the names of its
#       contributors may be used to endorse or promote products derived from
#       this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
import ecto
from ecto_test import Printer, Add
from ecto_X import Sink

p = Printer(print_type='double')
sink = Sink(url='localhost', port=2932)

plasm = ecto.Plasm()
plasm.connect(sink[:] >> p[:])

if __name__ == '__main__':
    from ecto.opts import doit
    doit(plasm, description='Run a simple ecto client graph.')
Пример #15
0
#!/usr/bin/env python

import ecto, ecto_pcl, ecto_openni
from ecto_image_pipeline import conversion
from ecto.opts import run_plasm, scheduler_options
from ecto_openni import OpenNICapture, DEPTH_RGB

capture = OpenNICapture(stream_mode=DEPTH_RGB, registration=True, sync=False)

mat2pcl = conversion.MatToPointCloudXYZRGBOrganized('mat2pcl')
pcl2ecto = ecto_pcl.PointCloudT2PointCloud('pcl2ecto')

viewer = ecto_pcl.CloudViewer("viewer", window_name="Clouds!")

graph = [
    capture['image'] >> mat2pcl['image'],
    capture['depth'] >> mat2pcl['points'], mat2pcl[:] >> pcl2ecto[:],
    pcl2ecto[:] >> viewer[:]
]

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

if __name__ == "__main__":
    from ecto.opts import doit
    doit(plasm, description='Execute test kinect.')
Пример #16
0
#       documentation and/or other materials provided with the distribution.
#     * Neither the name of the Willow Garage, Inc. nor the names of its
#       contributors may be used to endorse or promote products derived from
#       this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
import ecto
from ecto_X import Source
from ecto_opencv.highgui import VideoCapture

video_cap = VideoCapture(video_device=0, width=640, height=480)
source = Source(port=2932)

plasm = ecto.Plasm()
plasm.connect(video_cap['image'] >> source['in'], )

if __name__ == '__main__':
    from ecto.opts import doit
    doit(plasm, description='Run a simple ecto video capture server.')
Пример #17
0
#!/usr/bin/env python
import ecto
from ecto_opencv.highgui import VideoCapture, imshow, FPSDrawer

video_cap = VideoCapture(video_device=0, width=640, height=480)
fps = FPSDrawer()

plasm = ecto.Plasm()
plasm.connect(video_cap['image'] >> fps['image'],
              fps['image'] >> imshow(name='video_cap')['image'],
              )

if __name__ == '__main__':
    from ecto.opts import doit
    doit(plasm, description='Capture a video from the device and display it.')
Пример #18
0
saver = ecto.If(
    cell=ImageSaver('saver', filename_format='bilateral_%05d.jpg', start=1))

bl_begin = None
bl_end = None

plasm = ecto.Plasm()
#Build up a chain of bilateral filters.
for i in range(1, 10):
    next = BilateralFilter(d=-1, sigmaColor=10, sigmaSpace=5)
    if bl_begin == None:  # beginning case
        bl_begin = next
        bl_end = next
        continue
    plasm.connect(bl_end[:] >> next[:])
    bl_end = next

plasm.connect(
    video_cap['image'] >> fps['image'],
    fps['image'] >> bl_begin[:],
    bl_end[:] >> (video_display['image'], saver['image']),
    video_display['save'] >> saver['__test__'],
)

if __name__ == '__main__':
    from ecto.opts import doit
    doit(plasm,
         description=
         'Run a chain of bilateral smoothing filters on a video stream.')
Пример #19
0
#!/usr/bin/env python
import ecto
from ecto_opencv.highgui import VideoCapture, imshow, FPSDrawer
from ecto_opencv.imgproc import Scale, Interpolation

video_cap = VideoCapture(video_device=0, width=640, height=480)
fps = FPSDrawer()
factor = 0.1
scale_down = Scale(factor=factor, interpolation=Interpolation.AREA)
scale_up = Scale(factor=1 / factor, interpolation=Interpolation.LANCZOS4)

plasm = ecto.Plasm()
plasm.connect(
    video_cap["image"] >> scale_down["image"],
    scale_down["image"] >> scale_up["image"],
    scale_up["image"] >> fps["image"],
    fps["image"] >> imshow(name="Rescaled")["image"],
)

if __name__ == "__main__":
    from ecto.opts import doit

    doit(plasm, description="Capture a video from the device and display it.", locals=vars())
Пример #20
0
#     * Neither the name of the Willow Garage, Inc. nor the names of its
#       contributors may be used to endorse or promote products derived from
#       this software without specific prior written permission.
# 
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
# 
import ecto
from ecto_X import Source
from ecto_opencv.highgui import VideoCapture

video_cap = VideoCapture(video_device=0, width=640, height=480)
source = Source(port=2932)

plasm = ecto.Plasm()
plasm.connect(video_cap['image'] >> source['in'],
              )

if __name__ == '__main__':
    from ecto.opts import doit
    doit(plasm, description='Run a simple ecto video capture server.')
Пример #21
0
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 += [
    cloud_generator[:] >> extract_stuff["input"],
    convex_hull[:] >> extract_stuff["planar_hull"],
    extract_stuff[:] >> extract_indices["indices"],
    cloud_generator[:] >> extract_indices["input"],
    extract_indices[:] >> viewer[:]
]

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

if __name__ == "__main__":
    from ecto.opts import doit
    doit(plasm, description='Execute tabletop segmentation.')
Пример #22
0
#!/usr/bin/env python
import ecto
from ecto_opencv import highgui
from ecto_opencv.highgui import V4LCapture, VideoCapture, imshow, FPSDrawer, NiConverter
from image_pipeline import Rectifier, RectifierNC, StereoModelLoader, DepthRegister
from ecto_openni import OpenNICapture, DEPTH_RGB, DEPTH_IR, RGB, IR, IRGamma

capture = OpenNICapture(stream_mode=IR, registration=False, latched=False)
stereo_model = StereoModelLoader(left_fname='left.yml', right_fname="right.yml", stereo_fname = 'stereo.yml');
rect_depth = Rectifier()
conversion = IRGamma() # scale the IR so that we can visualize it.


plasm = ecto.Plasm()
plasm.connect(
    capture['ir'] >> conversion[:],
    conversion[:] >> rect_depth['image'],
    stereo_model['right_model'] >> rect_depth['camera'],
    )


#display stuff
plasm.connect(
       rect_depth['image'] >> imshow(name='Rectified IR')['image'],
       conversion[:] >> imshow(name='Original IR')['image']
       )

if __name__ == '__main__':
    from ecto.opts import doit
    doit(plasm, description='Capture Kinect IR images and rectify.')
Пример #23
0
cols = 3
square_size = 0.04  #4 cm
pattern_type = ASYMMETRIC_CIRCLES_GRID
n_obs = 50
calibration_file = 'camera_new.yml'

video = VideoCapture(video_device=0)
rgb2gray = cvtColor(flag=Conversion.RGB2GRAY)
circle_detector = PatternDetector(rows=rows,
                                  cols=cols,
                                  pattern_type=pattern_type,
                                  square_size=square_size)
camera_calibrator = CameraCalibrator(output_file_name=calibration_file,
                                     n_obs=n_obs)
circle_drawer = PatternDrawer(rows=rows, cols=cols)

plasm = ecto.Plasm()
plasm.connect(
    video['image'] >>
    (circle_drawer['input'], camera_calibrator['image'], rgb2gray['image']),
    rgb2gray['image'] >> circle_detector['input'],
    circle_drawer['out'] >> imshow(name='pattern')['image'],
    circle_detector['ideal', 'out',
                    'found'] >> camera_calibrator['ideal', 'points', 'found'],
    circle_detector['out', 'found'] >> circle_drawer['points', 'found'],
)

if __name__ == '__main__':
    from ecto.opts import doit
    doit(plasm, description='Calibrate a camera using a dot pattern.')
Пример #24
0
                                  square_size=square_size,
                                  offset_x=offset_x,
                                  offset_y=offset_y)

circle_drawer = PatternDrawer(rows=rows, cols=cols)
poser = FiducialPoseFinder()
pose_drawer = PoseDrawer()
gt_drawer = PoseDrawer()
plasm = ecto.Plasm()
plasm.connect(
    simulator['image'] >> (rgb2gray['image'], circle_drawer['input']),
    rgb2gray['image'] >> circle_detector['input'],
    circle_detector['out', 'found'] >> circle_drawer['points', 'found'],
    simulator['K'] >> poser['K'],
    circle_detector['out', 'ideal', 'found'] >> poser['points', 'ideal',
                                                      'found'],
    poser['R', 'T'] >> pose_drawer['R', 'T'],
    circle_detector['found'] >> pose_drawer['trigger'],
    circle_drawer['out'] >> pose_drawer['image'],
    simulator['K'] >> pose_drawer['K'],
    pose_drawer['output'] >> pattern_show['image'],
)

plasm.connect(
    simulator['image', 'R', 'T', 'K'] >> gt_drawer['image', 'R', 'T', 'K'],
    gt_drawer['output'] >> imshow(name='Ground Truth')['image'])

if __name__ == '__main__':
    from ecto.opts import doit
    doit(plasm, description='Simulate pose estimation')
Пример #25
0
#!/usr/bin/env python

"""
This sample shows how to use the ecto_openni capture and cloud viewer.
"""

import ecto, ecto_pcl, ecto_openni

plasm = ecto.Plasm()

device = ecto_openni.Capture('device')
cloud_generator = ecto_pcl.NiConverter('cloud_generator')
viewer = ecto_pcl.CloudViewer("viewer", window_name="Clouds!")

plasm.connect(device[:] >> cloud_generator[:],
              cloud_generator[:] >> viewer[:])

if __name__ == "__main__":
    from ecto.opts import doit
    doit(plasm, description='View the current point cloud.')
Пример #26
0
#!/usr/bin/env python
import ecto
from ecto_opencv.highgui import VideoCapture, imshow, FPSDrawer, ImageSaver

video_cap = VideoCapture(video_device=0)
fps = FPSDrawer()
video_display = imshow(name='video_cap', triggers=dict(save=ord('s')))
saver = ecto.If(
    cell=ImageSaver('saver', filename_format='ecto_image_%05d.jpg', start=1))

plasm = ecto.Plasm()
plasm.connect(
    video_cap['image'] >> fps['image'],
    fps['image'] >> video_display['image'],
    video_display['save'] >> saver['__test__'],
    fps['image'] >> saver['image'],
)

if __name__ == '__main__':
    from ecto.opts import doit
    doit(plasm, description='Save images from video stream.')
Пример #27
0
    orb['keypoints'] >> draw_kpts['keypoints'],
    capture['image'] >> draw_kpts['image'],
    draw_kpts['image'] >> fps[:],
    fps[:] >> disp['image'],
)

# connect up the reference ORB
orb_ref = ORB(n_features=n_feats)
draw_kpts_ref = DrawKeypoints()
latch_ref = LatchMat(init=True)

plasm.connect(
    img_src >> latch_ref['input'],
    latch_ref['output'] >> orb_ref['image'],
    disp['save'] >> latch_ref['set'],
    orb_ref['keypoints'] >> draw_kpts_ref['keypoints'],
    latch_ref['output'] >> draw_kpts_ref['image'],
    draw_kpts_ref['image'] >> imshow('reference orb display',
                                     name='ORB reference')['image'],
)

if __name__ == '__main__':
    from ecto.opts import doit
    doit(
        plasm,
        description='Computes the ORB feature and descriptor on an RGBD device.'
    )

#sched = ecto.schedulers.Singlethreaded(plasm)
#sched.execute()
Пример #28
0
#!/usr/bin/env python
import ecto
from ecto_opencv.highgui import imshow, ImageReader
import os

#this will read all images on the user's Desktop
images = ImageReader(path=os.path.expanduser('~/Desktop'))

#this is similar to a slide show... Wait for half a second
imshow = imshow(name='image', waitKey=500)

plasm = ecto.Plasm()
plasm.connect(images['image'] >> imshow['image'])

if __name__ == '__main__':
    from ecto.opts import doit
    doit(plasm, description='Displays images from the user\'s Desktop.')
Пример #29
0
#!/usr/bin/env python

"""
This sample shows how to interact with ROS cloud subscribers and publishers.
"""

import sys, ecto, ecto_pcl, ecto_ros, ecto_pcl_ros, ecto_ros.ecto_sensor_msgs as ecto_sensor_msgs

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/sample_output')

plasm.connect(cloud_sub['output'] >> msg2cloud[:],
              msg2cloud[:] >> cloud2msg[:],
              cloud2msg[:] >> cloud_pub[:])


if __name__ == "__main__":
    from ecto.opts import doit
    ecto_ros.init(sys.argv,"ecto_pcl_rossample")
    ecto.view_plasm(plasm)
    doit(plasm, description='Read a pcd through ROS.')
Пример #30
0
#     * Neither the name of the Willow Garage, Inc. nor the names of its
#       contributors may be used to endorse or promote products derived from
#       this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
import ecto
from ecto_test import Generate
from ecto_X import Source

plasm = ecto.Plasm()
g = Generate()

source = Source(port=2932)

plasm.connect(g['out'] >> source['in'], )

if __name__ == '__main__':
    from ecto.opts import doit
    doit(plasm, description='Run a simple ecto server graph.')
capture = OpenNICapture(stream_mode=DEPTH_RGB, registration=True, sync=False)

mat2pcl = conversion.MatToPointCloudXYZRGBOrganized('mat2pcl')
pcl2ecto = ecto_pcl.PointCloudT2PointCloud('pcl2ecto')

verter = highgui.NiConverter('verter')
fps = highgui.FPSDrawer('fps')

plasm = ecto.Plasm()
graph = [capture[:] >> verter[:],
	verter['image'] >> fps[:],
	fps[:] >> highgui.imshow('image display', name='image')[:],
	verter['depth'] >> highgui.imshow('depth display', name='depth')[:]
	]

cloud_generator = ecto_pcl.NiConverter('cloud_generator')
viewer = ecto_pcl.CloudViewer("viewer", window_name="Clouds!")

graph += [verter['image'] >> mat2pcl['image'],
	verter['depth'] >> mat2pcl['points'],
	mat2pcl[:] >> pcl2ecto[:],
	pcl2ecto[:] >> viewer[:]
	]

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

if __name__ == "__main__":
    from ecto.opts import doit
    doit(plasm, description='Execute test kinect.')
Пример #32
0
          project_inliers[:] >> nan_filter[:],
          nan_filter[:] >> convex_hull[:]
          ]

# extract stuff on table from original high-res cloud, find clusters, colorize, merge and show in viewer
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)
colorize = ColorizeClusters("colorize")
merge = MergeClouds("merge")
viewer = CloudViewer("viewer", window_name="Clouds!")

graph += [cloud_generator[:] >> extract_stuff["input"],
          convex_hull[:] >> extract_stuff["planar_hull"],
          extract_stuff[:] >> extract_indices["indices"],
          cloud_generator[:] >> extract_indices["input"],
          extract_indices[:] >> extract_clusters[:],
          extract_clusters[:] >> colorize["clusters"],
          extract_indices[:] >> colorize["input"],
          cloud_generator[:] >> merge["input"],
          colorize[:] >> merge["input2"],
          colorize[:] >> viewer[:]
          ]

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

if __name__ == "__main__":
    from ecto.opts import doit
    doit(plasm, description='Execute tabletop segmentation and colorize clusters.')
#database ritual
couch = couchdb.Server(db_url)
dbs = dbtools.init_object_databases(couch)
sessions = dbs['sessions']
observations = dbs['observations']
results = models.Session.all(sessions)
obs_ids = []

for session in results:
    obs_ids += models.find_all_observations_for_session(observations, session.id)

if len(obs_ids) == 0:
    raise RuntimeError("There are no observations available.")

db_reader = capture.ObservationReader('db_reader', db_params=ObjectDbParameters({'type':'CouchDB', 'root':db_url,
                                                                                 'collection':'observations'}))
#observation dealer will deal out each observation id.
observation_dealer = ecto.Dealer(tendril=db_reader.inputs.at('observation'), iterable=obs_ids)
fps = highgui.FPSDrawer('FPS drawer')
plasm = ecto.Plasm()
#View all of the observations.
plasm.connect(
    observation_dealer[:] >> db_reader['observation'],
    db_reader['image'] >> fps[:],
    fps[:] >> highgui.imshow('image display', name='image')[:],
    db_reader['depth'] >> highgui.imshow('depth display', name='depth')[:],
    db_reader['mask'] >> highgui.imshow('mask display', name='mask')[:],
)
from ecto.opts import doit
doit(plasm, "View observations from the database.", locals=vars())
#!/usr/bin/env python
import ecto
from ecto_opencv.highgui import imshow
from ecto_openni import OpenNICapture, DEPTH_RGB, enumerate_devices
from image_pipeline_conversion import MatToPointCloudXYZRGB
from ecto_pcl import PointCloudT2PointCloud, CloudViewer, XYZRGB
from object_recognition.common.io.standalone import OpenNISource

capture = OpenNISource()
to_xyzrgb = MatToPointCloudXYZRGB('OpenCV ~> PCL')
pcl_cloud = PointCloudT2PointCloud('conversion', format=XYZRGB)
cloud_viewer = CloudViewer('Cloud Display')

plasm = ecto.Plasm()
plasm.connect(capture['image'] >> imshow('Image Display')[:],
              capture['points3d'] >> to_xyzrgb['points'],
              capture['image'] >> to_xyzrgb['image'],
              to_xyzrgb[:] >> pcl_cloud[:],
              pcl_cloud[:] >> cloud_viewer[:]
              )

if __name__ == '__main__':
    from ecto.opts import doit
    doit(plasm, description='Capture Kinect depth and RGB and register them.', locals=vars())
Пример #35
0
              rot_depthTo3d['points3d'] >> orb_ref['points3d'],
              rot_image['rotated_image'] >> orb_ref['image'],
              )


# put in the estimator
posest = PoseEstimator3DProj(show_matches=True)
kmat = KeypointsToMat()
kmat_ref = KeypointsToMat()

plasm.connect(img_src >> posest['image'],
              rot_depth['rotated_image'] >> posest['image_ref'],
              orb['keypoints'] >> kmat['keypoints'],
              kmat['points'] >> posest['points'],
              orb_ref['keypoints'] >> kmat_ref['keypoints'],
              kmat_ref['points'] >> posest['points_ref'],
              orb['points3d'] >> posest['points3d'],
              orb_ref['points3d'] >> posest['points3d_ref'],
              orb['descriptors'] >> posest['desc'],
              orb_ref['descriptors'] >> posest['desc_ref'],
              capture['K'] >> posest['K']
              )

if __name__ == '__main__':
    from ecto.opts import doit
    doit(plasm, description='Pose estimation on an RGBD device.')

#sched = ecto.schedulers.Singlethreaded(plasm)
#sched.execute()

    obs_ids += models.find_all_observations_for_session(
        observations, session.id)

if len(obs_ids) == 0:
    raise RuntimeError("There are no observations available.")

db_reader = capture.ObservationReader('db_reader',
                                      db_params=ObjectDbParameters({
                                          'type':
                                          'CouchDB',
                                          'root':
                                          db_url,
                                          'collection':
                                          'observations'
                                      }))
#observation dealer will deal out each observation id.
observation_dealer = ecto.Dealer(tendril=db_reader.inputs.at('observation'),
                                 iterable=obs_ids)
fps = highgui.FPSDrawer('FPS drawer')
plasm = ecto.Plasm()
#View all of the observations.
plasm.connect(
    observation_dealer[:] >> db_reader['observation'],
    db_reader['image'] >> fps[:],
    fps[:] >> highgui.imshow('image display', name='image')[:],
    db_reader['depth'] >> highgui.imshow('depth display', name='depth')[:],
    db_reader['mask'] >> highgui.imshow('mask display', name='mask')[:],
)
from ecto.opts import doit
doit(plasm, "View observations from the database.", locals=vars())
Пример #37
0
#!/usr/bin/env python
import ecto
from ecto_opencv.highgui import VideoCapture, imshow, FPSDrawer
from ecto_opencv.imgproc import Canny, RGB2GRAY, cvtColor

video_cap = VideoCapture(video_device=0, width=640, height=480)
fps = FPSDrawer()
canny = Canny()
gray = cvtColor(flag=RGB2GRAY)
plasm = ecto.Plasm()
plasm.connect(
    video_cap['image'] >> gray[:],
    gray[:] >> canny['image'],
    canny['image'] >> fps['image'],
    fps['image'] >> imshow(name='Canny Image')['image'],
    video_cap['image'] >> imshow(name='Original Image')['image'],
)

if __name__ == '__main__':
    from ecto.opts import doit
    doit(plasm, description='Capture a video from the device and display it.')
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 += [cloud_generator[:] >> extract_stuff["input"],
          convex_hull[:] >> extract_stuff["planar_hull"],
          extract_stuff[:] >> extract_indices["indices"],
          cloud_generator[:] >> extract_indices["input"],
          extract_indices[:] >> viewer[:]
          ]

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

if __name__ == "__main__":
    from ecto.opts import doit
    doit(plasm, description='Execute tabletop segmentation.')
sync = ecto_ros.Synchronizer('Synchronizator', subs=subs
                             )

im2mat_rgb = ecto_ros.Image2Mat('rgb -> cv::Mat')
camera_info = ecto_ros.CameraInfo2Cv('camera_info -> cv::Mat')
poser = OpposingDotPoseEstimator(plasm,
                                 rows=5, cols=3,
                                 pattern_type=calib.ASYMMETRIC_CIRCLES_GRID,
                                 square_size=0.04, debug=True)

bgr2rgb = imgproc.cvtColor('rgb -> bgr', flag=imgproc.Conversion.RGB2BGR)
rgb2gray = imgproc.cvtColor('rgb -> gray', flag=imgproc.Conversion.RGB2GRAY)
display = highgui.imshow('Poses', name='Poses', waitKey=5, autoSize=True)

graph = [sync['image'] >> im2mat_rgb[:],
          im2mat_rgb[:] >> (rgb2gray[:], bgr2rgb[:]),
          bgr2rgb[:] >> poser['color_image'],
          rgb2gray[:] >> poser['image'],
          poser['debug_image'] >> display['input'],
          sync['image_ci'] >> camera_info['camera_info'],
          camera_info['K'] >> poser['K'],
          ]
plasm.connect(graph)

if __name__ == '__main__':
    import sys
    ecto_ros.init(sys.argv, "opposing_dots_pose", False)
    from ecto.opts import doit
    doit(plasm, description='Estimate the pose of an opposing dot fiducial.')

Пример #40
0
from ecto_opencv import highgui, calib, imgproc, cv_bp as cv
from object_recognition.observations import *
from ecto_object_recognition import capture

plasm = ecto.Plasm()

video_cap = highgui.VideoCapture(video_device=0, width=640, height=480)
camera_intrinsics = calib.CameraIntrinsics(camera_file='camera.yml')

poser = OpposingDotPoseEstimator(rows=5, cols=3,
                                 pattern_type=calib.ASYMMETRIC_CIRCLES_GRID,
                                 square_size=0.04, debug=True
                                 )

bgr2rgb = imgproc.cvtColor('rgb -> bgr', flag=imgproc.RGB2BGR)
rgb2gray = imgproc.cvtColor('rgb -> gray', flag=imgproc.RGB2GRAY)
display = highgui.imshow('Poses', name='Poses')

plasm.connect(
         video_cap['image'] >> rgb2gray[:], 
         rgb2gray[:] >> poser['image'],
         video_cap['image'] >> poser['color_image'],
         poser['debug_image'] >> display['image'],
         camera_intrinsics['K'] >> poser['K']
         )

if __name__ == '__main__':
    from ecto.opts import doit
    doit(plasm, description='Estimate the pose of an opposing dot fiducial.')

Пример #41
0
#     * Neither the name of the Willow Garage, Inc. nor the names of its
#       contributors may be used to endorse or promote products derived from
#       this software without specific prior written permission.
# 
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
# 
import ecto
from ecto_test import Printer, Add
from ecto_X import Sink

p = Printer(print_type='double')
sink = Sink(url='localhost', port=2932)

plasm = ecto.Plasm()
plasm.connect(sink[:] >> p[:])

if __name__ == '__main__':
    from ecto.opts import doit
    doit(plasm, description='Run a simple ecto client graph.')

Пример #42
0
square_size = 0.04 #4 cm
pattern_type = ASYMMETRIC_CIRCLES_GRID
n_obs = 50
calibration_file = "camera_new.yml"

video = ecto.Passthrough()
pattern_display = imshow(name="pattern", waitKey=10)
rgb2gray = cvtColor(flag=Conversion.RGB2GRAY)
circle_detector = PatternDetector(rows=rows, cols=cols,
                                  pattern_type=pattern_type, square_size=square_size)
camera_calibrator = CameraCalibrator(output_file_name=calibration_file, n_obs=n_obs)
circle_drawer = PatternDrawer(rows=rows, cols=cols)

plasm = ecto.Plasm()
plasm.connect(verter['image'] >> fps[:],
              fps[:] >> imshow('image display', name='image')[:],
              verter['depth'] >> imshow('depth display', name='depth')[:],
              )
plasm.connect(capture[:] >> verter[:],
              verter['image'] >> video[:],
              video[:] >> (circle_drawer["input"], camera_calibrator["image"], rgb2gray["input"]),
              rgb2gray["out"] >> circle_detector["input"],
              circle_drawer["out"] >> pattern_display["input"],
              circle_detector[ "ideal", "out", "found"] >> camera_calibrator["ideal", "points", "found"],
              circle_detector["out", "found"] >> circle_drawer["points", "found"],
              )

if __name__ == '__main__':
    from ecto.opts import doit
    doit(plasm, description='Calibrate a camera using a dot pattern.')
from image_pipeline import Rectifier, StereoModelLoader, DepthRegister, CameraModelToCv, CV_INTER_NN
from ecto_openni import OpenNICapture, DEPTH_RGB, DEPTH_IR, RGB, IR, IRGamma, enumerate_devices
from ecto_object_recognition.conversion import MatToPointCloudXYZRGB
from ecto_pcl import PointCloudT2PointCloud, CloudViewer, XYZRGB

openni_reg = True
print enumerate_devices()

capture = OpenNICapture('Camera',
                        stream_mode=DEPTH_RGB,
                        registration=openni_reg,
                        latched=False)
depthTo3d = DepthTo3d('Depth ~> 3d')
to_xyzrgb = MatToPointCloudXYZRGB('OpenCV ~> PCL')
pcl_cloud = PointCloudT2PointCloud('conversion', format=XYZRGB)
cloud_viewer = CloudViewer('Cloud Display')

plasm = ecto.Plasm()
plasm.connect(capture['K'] >> depthTo3d['K'],
              capture['image'] >> imshow('Image Display')[:],
              capture['depth'] >> depthTo3d['depth'],
              depthTo3d['points3d'] >> to_xyzrgb['points'],
              capture['image'] >> to_xyzrgb['image'],
              to_xyzrgb[:] >> pcl_cloud[:], pcl_cloud[:] >> cloud_viewer[:])

if __name__ == '__main__':
    from ecto.opts import doit
    doit(plasm,
         description='Capture Kinect depth and RGB and register them.',
         locals=vars())
Пример #44
0
#

import ecto
from ecto_opencv.highgui import imshow
from ecto_opencv.calib import DepthTo3d
from image_pipeline import Rectifier, StereoModelLoader, DepthRegister, CameraModelToCv, CV_INTER_NN
from ecto_openni import Capture, OpenNICapture, DEPTH_RGB, DEPTH_IR, RGB, IR, IRGamma, enumerate_devices
from ecto_object_recognition.conversion import MatToPointCloudXYZRGB
from ecto_pcl import PointCloudT2PointCloud, CloudViewer, XYZRGB

print enumerate_devices()

openni_reg = True
openni_sync = True
capture = OpenNICapture(stream_mode=DEPTH_RGB, registration=openni_reg, synchronization=openni_sync, latched=False)
#capture = Capture(registration=openni_reg, synchronize=openni_sync)

plasm = ecto.Plasm()

camera_converter = CameraModelToCv()

plasm.connect(
#    stereo_model['left_model'] >> camera_converter['camera'],
    capture['image'] >> imshow(name='Original')['image'],
#    capture['depth'] >> imshow(name='Original Depth')['image']
    )
    
if __name__ == '__main__':
    from ecto.opts import doit
    doit(plasm, description='Capture RGBD depth and RGB.',locals=vars())