Programming the camera

From OLPC
Revision as of 15:20, 13 April 2007 by Follower (talk | contribs) (Add how to get moving video)
Jump to navigation Jump to search

This page explores how to interact with the laptop's built-in video camera.

Getting started

First, let's see the quickest way we can capture a still image from the camera--using a GStreamer command-line tool:

 gst-launch-0.10 v4l2src ! ffmpegcolorspace ! pngenc ! filesink location=foo.png

You'll need to run the above command in either a terminal in the developer console (alt-=) or one of the virtual terminals (e.g. ctrl-alt-f1). Note this means you don't need the Sugar GUI to be running to access the camera.

You can view the PNG image created as a result of the command in the Web activity.

Now, let's try and get some video on the screen:

 gst-launch-0.10 v4l2src ! ximagesink

Unlike the first command this command will only work when executed in a terminal in the developer console. The resulting video will appear behind the developer console window so you'll need to move the developer console window aside to see the video.


Camera
  • Have to script v4l2 via gstreamer to capture a single frame from the camera. See sugar/shell/intro/glive.py for sample code
Camera-as-video-camera (v4l2?)
  • Is a regular v4l2 device available via gstreamer (gst module)