Table Of Contents

Previous topic

Cells

This Page

Examples

Kinect Viewer

Download: kinect_standalone.py

#!/usr/bin/env python
import ecto

from ecto_opencv import imgproc, calib, highgui

def kinect_highres(device_n):
    from ecto_openni import Capture, ResolutionMode, Device
    return Capture('ni device', rgb_resolution=ResolutionMode.SXGA_RES,
                   depth_resolution=ResolutionMode.VGA_RES,
                   rgb_fps=15, depth_fps=30,
                   device_number=device_n,
                   registration=True,
                   synchronize=False,
                   device=Device.KINECT
                   )

def kinect_vga(device_n):
    from ecto_openni import Capture, ResolutionMode, Device
    return Capture('ni device', rgb_resolution=ResolutionMode.VGA_RES,
                   depth_resolution=ResolutionMode.VGA_RES,
                   rgb_fps=30, depth_fps=30,
                   device_number=device_n,
                   registration=True,
                   synchronize=False,
                   device=Device.KINECT
                   )
def xtion_highres(device_n):
    from ecto_openni import Capture, ResolutionMode, Device
    return Capture('ni device', rgb_resolution=ResolutionMode.SXGA_RES,
                   depth_resolution=ResolutionMode.VGA_RES,
                   rgb_fps=30, depth_fps=30,
                   device_number=device_n,
                   registration=True,
                   synchronize=True,
                   device=Device.ASUS_XTION_PRO_LIVE
                   )

def xtion_vga(device_n):
    from ecto_openni import Capture, ResolutionMode, Device
    return Capture('ni device', rgb_resolution=ResolutionMode.VGA_RES,
                   depth_resolution=ResolutionMode.VGA_RES,
                   rgb_fps=30, depth_fps=30,
                   device_number=device_n,
                   registration=True,
                   synchronize=True,
                   device=Device.ASUS_XTION_PRO_LIVE
                   )

device = 0
#capture = xtion_highres(device)
capture = xtion_vga(device)
#capture = kinect_vga(device)
#capture = kinect_highres(device)


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

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

if __name__ == '__main__':
    sched = ecto.schedulers.Singlethreaded(plasm)
    sched.execute()

digraph G {
graph [rankdir=TB, ranksep=1]
edge [labelfontsize=8]
node [shape=plaintext]
0[label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">  <TR> <TD ROWSPAN="9" COLSPAN="7" BGCOLOR="khaki">ni device</TD> <TD PORT="p_depth_fps" BGCOLOR="lightblue">depth_fps</TD>
 </TR> <TR> <TD PORT="p_depth_resolution" BGCOLOR="lightblue">depth_resolution</TD> </TR>
<TR> <TD PORT="p_device" BGCOLOR="lightblue">device</TD> </TR>
<TR> <TD PORT="p_device_number" BGCOLOR="lightblue">device_number</TD> </TR>
<TR> <TD PORT="p_device_uid" BGCOLOR="lightblue">device_uid</TD> </TR>
<TR> <TD PORT="p_registration" BGCOLOR="lightblue">registration</TD> </TR>
<TR> <TD PORT="p_rgb_fps" BGCOLOR="lightblue">rgb_fps</TD> </TR>
<TR> <TD PORT="p_rgb_resolution" BGCOLOR="lightblue">rgb_resolution</TD> </TR>
<TR> <TD PORT="p_synchronize" BGCOLOR="lightblue">synchronize</TD> </TR>
 <TR>
<TD PORT="o_depth_buffer" BGCOLOR="indianred1">depth_buffer</TD>
<TD PORT="o_depth_height" BGCOLOR="indianred1">depth_height</TD>
<TD PORT="o_depth_width" BGCOLOR="indianred1">depth_width</TD>
<TD PORT="o_image_buffer" BGCOLOR="indianred1">image_buffer</TD>
<TD PORT="o_image_channels" BGCOLOR="indianred1">image_channels</TD>
<TD PORT="o_image_height" BGCOLOR="indianred1">image_height</TD>
<TD PORT="o_image_width" BGCOLOR="indianred1">image_width</TD>
</TR> </TABLE>>];
1[label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4"> <TR>
<TD PORT="i_depth_buffer" BGCOLOR="springgreen">depth_buffer</TD>
<TD PORT="i_depth_height" BGCOLOR="springgreen">depth_height</TD>
<TD PORT="i_depth_width" BGCOLOR="springgreen">depth_width</TD>
<TD PORT="i_image_buffer" BGCOLOR="springgreen">image_buffer</TD>
<TD PORT="i_image_channels" BGCOLOR="springgreen">image_channels</TD>
<TD PORT="i_image_height" BGCOLOR="springgreen">image_height</TD>
<TD PORT="i_image_width" BGCOLOR="springgreen">image_width</TD>
</TR> <TR> <TD ROWSPAN="1" COLSPAN="7" BGCOLOR="khaki">verter</TD> <TD PORT="p_rescale" BGCOLOR="lightblue">rescale</TD>
 </TR>  <TR>
<TD PORT="o_depth" BGCOLOR="indianred1">depth</TD>
<TD PORT="o_image" BGCOLOR="indianred1">image</TD>
</TR> </TABLE>>];
2[label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4"> <TR>
<TD PORT="i_image" BGCOLOR="springgreen">image</TD>
</TR> <TR> <TD ROWSPAN="1" COLSPAN="1" BGCOLOR="khaki">fps</TD>  </TR>  <TR>
<TD PORT="o_image" BGCOLOR="indianred1">image</TD>
</TR> </TABLE>>];
3[label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4"> <TR>
<TD PORT="i_image" BGCOLOR="springgreen">image</TD>
</TR> <TR> <TD ROWSPAN="5" COLSPAN="1" BGCOLOR="khaki">image display</TD> <TD PORT="p_autoSize" BGCOLOR="lightblue">autoSize</TD>
 </TR> <TR> <TD PORT="p_maximize" BGCOLOR="lightblue">maximize</TD> </TR>
<TR> <TD PORT="p_name" BGCOLOR="lightblue">name</TD> </TR>
<TR> <TD PORT="p_triggers" BGCOLOR="lightblue">triggers</TD> </TR>
<TR> <TD PORT="p_waitKey" BGCOLOR="lightblue">waitKey</TD> </TR>
  </TABLE>>];
4[label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4"> <TR>
<TD PORT="i_image" BGCOLOR="springgreen">image</TD>
</TR> <TR> <TD ROWSPAN="5" COLSPAN="1" BGCOLOR="khaki">depth display</TD> <TD PORT="p_autoSize" BGCOLOR="lightblue">autoSize</TD>
 </TR> <TR> <TD PORT="p_maximize" BGCOLOR="lightblue">maximize</TD> </TR>
<TR> <TD PORT="p_name" BGCOLOR="lightblue">name</TD> </TR>
<TR> <TD PORT="p_triggers" BGCOLOR="lightblue">triggers</TD> </TR>
<TR> <TD PORT="p_waitKey" BGCOLOR="lightblue">waitKey</TD> </TR>
  </TABLE>>];
0->1 [headport="i_depth_buffer" tailport="o_depth_buffer"];
0->1 [headport="i_depth_height" tailport="o_depth_height"];
0->1 [headport="i_depth_width" tailport="o_depth_width"];
0->1 [headport="i_image_buffer" tailport="o_image_buffer"];
0->1 [headport="i_image_channels" tailport="o_image_channels"];
0->1 [headport="i_image_height" tailport="o_image_height"];
0->1 [headport="i_image_width" tailport="o_image_width"];
1->2 [headport="i_image" tailport="o_image"];
2->3 [headport="i_image" tailport="o_image"];
1->4 [headport="i_image" tailport="o_depth"];
}