Skip to content

Instantly share code, notes, and snippets.

@ethanrublee
Created March 13, 2012 23:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ethanrublee/2032771 to your computer and use it in GitHub Desktop.
Save ethanrublee/2032771 to your computer and use it in GitHub Desktop.
#!/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