Previous topic

Simple video capture

Next topic

Bilateral Filter Chain

This Page

Saving imagesΒΆ

Demonstration of saving images on a keystroke.

Download: image_saving.py

#!/usr/bin/env python
import ecto
from ecto_opencv.highgui import VideoCapture, imshow, FPSDrawer, ImageSaver

video_cap = VideoCapture(video_device=0)
fps = FPSDrawer()
video_display = imshow(name='video_cap', triggers=dict(save=ord('s')))
saver = ecto.If(cell=ImageSaver('saver', filename_format='ecto_image_%05d.jpg',
                                   start=1))

plasm = ecto.Plasm()
plasm.connect(video_cap['image'] >> fps['image'],
              fps['image'] >> video_display['image'],
              video_display['save'] >> saver['__test__'],
              fps['image'] >> saver['image'],
              )

if __name__ == '__main__':
    from ecto.opts import doit
    doit(plasm, description='Save images from video stream.')

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>
 <TR>
<TD PORT="o_save" BGCOLOR="indianred1">save</TD>
</TR> </TABLE>>];
3[label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4"> <TR>
<TD PORT="i___test__" BGCOLOR="springgreen">__test__</TD>
<TD PORT="i_filename" BGCOLOR="springgreen">filename</TD>
<TD PORT="i_image" BGCOLOR="springgreen">image</TD>
</TR> <TR> <TD ROWSPAN="1" COLSPAN="3" BGCOLOR="khaki">ecto::If</TD> <TD PORT="p_cell" BGCOLOR="lightblue">cell</TD>
 </TR>  <TR>
<TD PORT="o_filename" BGCOLOR="indianred1">filename</TD>
</TR> </TABLE>>];
0->1 [headport="i_image" tailport="o_image"];
1->2 [headport="i_image" tailport="o_image"];
2->3 [headport="i___test__" tailport="o_save"];
1->3 [headport="i_image" tailport="o_image"];
}