Created
March 13, 2012 23:54
-
-
Save ethanrublee/2032771 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import ecto | |
from ecto_opencv.highgui import imshow | |
from image_pipeline.io.source import create_source | |
import sys | |
import argparse | |
from ecto_opencv import cv_bp | |
import numpy as np | |
class DepthProc(ecto.Cell): | |
def declare_io(self, p, i, o): | |
i.declare('depth','Depth, 16 bit...') | |
i.declare('image','Image, 3 channel 8 bit RGB') | |
i.declare('K', '3x3 camera calibration matrix.') | |
def process(self, i, o): | |
#convert to numpy arrays | |
K = i.K.toarray() | |
image = i.image.toarray() | |
depth = i.depth.toarray() | |
print 'K=',K | |
print 'image', image.dtype, image.shape | |
print 'depth', depth.dtype, depth.shape | |
#do awesome processing here... | |
parser = argparse.ArgumentParser(description='OpenNI capture.') | |
args = parser.parse_args() | |
source = create_source(package_name='image_pipeline', source_type='OpenNISource', | |
sync=True) #optionally pass keyword args here... | |
proc = DepthProc() | |
plasm = ecto.Plasm() | |
plasm.connect(source['image'] >> imshow(name='RGB')['image'], | |
source['depth_raw'] >> imshow(name='Depth 16 bit')['image'], | |
source['image','depth_raw','K'] >> proc['image','depth','K'], | |
) | |
sched = ecto.schedulers.Singlethreaded(plasm) | |
sched.execute() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment