Skip to content

Instantly share code, notes, and snippets.

@ethanrublee
Created August 25, 2011 00:45
Show Gist options
  • Save ethanrublee/1169684 to your computer and use it in GitHub Desktop.
Save ethanrublee/1169684 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
#
# Simple vid cap
#
import ecto
import ecto.opts
from ecto_opencv import highgui, calib, imgproc
def video_capture_plasm(device=0, width=640, height=480):
video_cap = highgui.VideoCapture(video_device=device, width=width, height=height)
fps = highgui.FPSDrawer()
video_display = highgui.imshow('imshow',
name='video_cap', waitKey=2)
plasm = ecto.Plasm()
plasm.connect(video_cap['image'] >> fps['image'],
fps['image'] >> video_display['input'],
)
return plasm
plasm = video_capture_plasm()
if __name__ == '__main__':
import argparse
parser = argparse.ArgumentParser(description='Capture a video from the device and display it.')
parser.add_argument('-d,--device', metavar='DEVICE_ID', dest='device', type=int, default=0, help='The device ID of a video camera. Take the number off of\n\t% ls /dev/video*')
parser.add_argument('--width', metavar='WIDTH', dest='width', type=int, default=640, help='Desired image width.')
parser.add_argument('--height', metavar='HEIGHT', dest='height', type=int, default=480, help='Desired image height.')
group = parser.add_argument_group('ecto scheduler options')
ecto.opts.scheduler_options(group)
options = parser.parse_args()
plasm = video_capture_plasm(device=options.device, height=options.height, width=options.width)
ecto.opts.run_plasm(options, plasm)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment