News Archive (1999-2012) | 2013-current at LinuxGizmos | Current Tech News Portal |    About   

Linux device webcam programming explored

Jan 22, 2008 — by Eric Brown — from the LinuxDevices Archive — views

IBM's DeveloperWorks has published a three-part series on developing for the Linux-based Nokia N800 tablet. Using the example of developing a webcam application that uploads JPEGs to a remote site, author Peter Seebach (pictured at left) explores Scratchbox, GStreamer, Fmemopen, Libcurl, and more.

The Nokia N800 comes with a video-enabled chat program, but there's no webcam application, so Seebach sets out to write one. He begins be setting up a development host with the Nokia-funded Scratchbox cross-compilaton toolkit, which he describes as being an “incredibly cool toy.” The toolkit eases the testing and development cycle by running in a native environment on the host, while using CPU emulation to run native binaries, says Seebach. It enables multiple build environments where developers can mix and match target and host binaries. After exploring Scratchbox some more and installing the N800's Maemo tools, the author then sets up a target.


By default, the N800's click-out camera launches a GTalk video chat client

In the second article, Seebach develops the basics of an application that extracts frames from the camera and uploads them to a remote computer. Using a maemo.org tutorial as a starting point, he explores the GStreamer media-streaming tool. After loading a terminal program on the N800 and setting up an ssh shell server, he downloads GStreamer from maemo.org, and steps the reader through installing the package.

Seebach then explains how to create GStreamer pipelines, which combine various “plug-in” media tasks, each of which can define “pads” as connectors. Seebach sets out to create a pipeline that connects a video source to an image sink (such as the display) while grabbing copies of the frames to encode as JPEGs. Along the way, he takes advantage of GStreamer's automatic conversion capabilities, which ease the process of converting the video to RGB format. After a little manipulation of the color space filter to improve performance, Seebach achieves a simple program in which pressing a button compresses an image into a JPEG.

In part three of the series, the author describes how to upload the JPEGs to a remote site. Since the N800 is lacking in file uploading tools, the next step is to leverage the fmemopen() function from the GNU C library extension to create a “stdio FILE * object that refers to a buffer in memory,” says Seebach. This in turn enables the use of the libcurl tool, which automatically uploads the JPEGs to the intended destination. He then programs a file queue so that the device first stores up encoded messages while a background thread is assigned to upload them. Seebach packages the application by creating desktop and control files to handle the Debian binary, and the webcam applet is complete.

The entire three-part series on the Nokia N800 webcam application can be found here.


 
This article was originally published on LinuxDevices.com and has been donated to the open source community by QuinStreet Inc. Please visit LinuxToday.com for up-to-date news and articles about Linux and open source.



Comments are closed.