#!/usr/bin/env python
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 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
#!/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.')
示例#3
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.')
示例#4
0
#!/usr/bin/env python
import ecto
from ecto_opencv.highgui import imshow, ImageSaver
from ecto_opencv.calib import PatternDetector, PatternDrawer, CameraCalibrator, ASYMMETRIC_CIRCLES_GRID, CHESSBOARD, GatherPoints
from ecto_opencv.imgproc import cvtColor, RGB2GRAY
from ecto_openni import OpenNICapture, DEPTH_RGB, DEPTH_IR, RGB, IR, IRGamma
from image_pipeline import StereoCalibration, LatchBool
import os

from pattern_helpers import *

create_detector_drawer = create_detector_drawer_chessboard
capture = OpenNICapture(stream_mode=RGB, registration=False, latched=True)
next_mode = IR
conversion = IRGamma()  # scale the IR so that we can visualize it.
rgb2gray = cvtColor(flag=RGB2GRAY)

plasm = ecto.Plasm()
plasm.insert(capture)
plasm.connect(
    capture['image'] >> rgb2gray[:],
    capture['ir'] >> conversion[:],
)

ir_detector, ir_drawer = create_detector_drawer()
rgb_detector, rgb_drawer = create_detector_drawer()

rgb_display = imshow(name="RGB Points", triggers=dict(save=ord('s')))
trigger_latch = LatchBool()
reset_source, reset_sink = ecto.EntangledPair(
    value=trigger_latch.inputs.at('reset'),