QStreamer is a Qt class that captures images from a webcam. It requires Linux and xawtv's streamer program.


QStreamer Functions QStreamer Signals


QStreamer provides a very simple webcam-capture API. It is integrated into the Qt framework, and emits a signal whenever a new image is available. QStreamer uses xawtv's streamer program to retrieve webcam images, which is only available under Linux. The streamer program normally outputs the images to hard drive, but QStreamer re-directs them to RAM. Streamer is started as a separate process, and is terminated by stopStream, or when QStreamer is deleted.


QStreamer, a camera-capture library version 1.0.0, Feb 6, 2010

Copyright (C) 2010 David C. McCallum

This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.

Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:

  1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.

David McCallum dmccallum9@gmail.com


QStreamer only works with Qt programs, and was tested with Qt version 4.5.2. QStreamer requires the streamer program from xawtv. Under Ubuntu, streamer can be installed with:

sudo apt-get install streamer

Copy QStreamer.hpp and QStreamer.cpp into your source directory, and add #include "QStreamer.hpp" to your program. You should then be able to compile as normal with qmake.

QStreamer Functions


The QStreamer constructor.

bool startStream(QString deviceName, int fps, unsigned int xRes, unsigned int yRes);

Start getting images from the specified device. Stops the existing stream if startStream was previously called.

Returns false if an error occurred, and sets errMsg appropriately.

bool stopStream(void);

Stop getting images and terminate the streamer program. Returns false if we couldn't stop streamer, and sets errMsg. If streamer couldn't be stopped, it's generally because the streamer program had already stopped running.

void setRamdriveDir(QString newDir);

The streamer program is normally set to write images to the system's ramdrive, /dev/shm. Use setRamdriveDir to tell streamer to write to a different directory. Takes effect the next time startStream is called.

QString getErrMsg(void);

Returns a description of the most recent error.

QStreamer Signals

void newImage(QImage &theImage);

Emitted when we get a new image from the camera.