Previous topic

Samples

Next topic

Saving images

This Page

Simple video captureΒΆ

Does video capture direct from the device, via opencv. Uses the fps cell to draw the framerate on the displayed image.

Download: vidcap.py

#!/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.')

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="4" COLSPAN="2" BGCOLOR="khaki">ecto_opencv::VideoCapture</TD> <TD PORT="p_height" BGCOLOR="lightblue">height</TD>
 </TR> <TR> <TD PORT="p_video_device" BGCOLOR="lightblue">video_device</TD> </TR>
<TR> <TD PORT="p_video_file" BGCOLOR="lightblue">video_file</TD> </TR>
<TR> <TD PORT="p_width" BGCOLOR="lightblue">width</TD> </TR>
 <TR>
<TD PORT="o_frame_number" BGCOLOR="indianred1">frame_number</TD>
<TD PORT="o_image" BGCOLOR="indianred1">image</TD>
</TR> </TABLE>>];
1[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">ecto_opencv::FPSDrawer</TD>  </TR>  <TR>
<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="5" COLSPAN="1" BGCOLOR="khaki">ecto_opencv::imshow</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_image" tailport="o_image"];
1->2 [headport="i_image" tailport="o_image"];
}