KVideo
KVideo is a simple C++ wrapper for v4l[2] framegrabber devices and standards compliant Firewire
cameras. This is intended for developers that want to add video capture to their applications
and don't want a common API for the different libraries that handle these different cameras.
The video.h header allows for two methods for accessing video frames. The simpler
is to just call call open() with the width and height you want and then calling
Video::capture() which returns a buffer with the video format you request
and dimentions of Video::width() and Video::height. If you are just
using capture() you never need to call stopCapture(), that will be called in
the Video destructor. But if you want to switch to the other mode of frame capture you
will need to call it after you've finished using the last captured frame. One thing to
note is that the Video class owns the captured frame so it is only valid until the
next capture or stopCapture call.
The more complex capture method is to use streaming. First you call startStreaming()
for which you can specify the frames per second and the number of buffers you want. Once you make
the call the buffers will be filled via DMA transfer, and when you call
streamingFrameGet() it will simply give you a pointer to one of them in FIFO order.
The catch to using this interface is that you must call streamingFrameReturn() with
the pointer returned from streamingFrameGet() when you are done with it. Depending on
the driver you may have to call streamingFrameReturn() before you can call
streamingFrameGet() again. It's safest to always do this, if you look at kvideo
which uses this interface it draws a frame as soon as it gets it and does not draw anything
in it's draw method. The alternative is to copy the buffer and return the original. When you
are done you should call stopStreaming which will stop the background DMA transfers.
Here's what you really need to know
cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/kvideo login
cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/kvideo co kvideo
Just hit return for the login password then use the second command to download the
source you will want to read the README. You will also want to look at these projects:
Here's a screenshot of the kvideo config dialog.
Here's the full video.h interface:
// -*- Mode: c++ -*-
// $Id: video.h,v 1.1.1.1 2003/05/20 13:47:16 kristjansson Exp $
// $Source: /cvsroot/kvideo/kvideo/src/video.h,v $
#ifndef __VIDEO_H__
#define __VIDEO_H__
#define VIDEO_DBG 1
#define VIDEO_STREAMING_DBG 1
#include
#include