TITLE

AUTHOR
Version 
CREATEDATE

Table of Contents

Table of contents

Class Index
Class List
Here are the classes, structs, unions and interfaces with brief descriptions:
QOpenCamWidget  	pagenum
View  	pagenum

File Index
File List
Here is a list of all files with brief descriptions:
main.cpp  	pagenum
qopencamwidget.cpp  	pagenum
qopencamwidget.h  	pagenum
view.cpp  	pagenum
view.h  	pagenum

Class Documentation
QOpenCamWidget Class Reference
#include <qopencamwidget.h>

Public Slots
void grabFrame (void)
Grabs a frame and causes an update() when triggered. 
void startSnap ()
Trigger this slot to save a frame from the widget. 
Signals
void imageReady (QImage snapshot)
Public Member Functions
QOpenCamWidget (QWidget *parent=0)
Consctructs a QWidget based widget for displaying video coming from an OpenCV capture source. 
~QOpenCamWidget (void)
void paintEvent (QPaintEvent *event)
A paint event is a request to repaint all or part of a widget. 
void setSnapshotVisible (bool visible)
Changes the visibility of the optional built-in "Take snapshot" button. 
bool grabCapture (int source)
Grabs an OpenCV video capture source. 
void startCapture (void)
Starts up grabbing of video frames. 
QImage * Ipl2QImage (const IplImage *img)
Converts from the OpenCV IplImage data structure to a QImage. 
Private Attributes
CvCapture * capture
QTimer * frametimer
QImage * nextFrame
QLabel * canvas
QVBoxLayout * layout
QPushButton * trigger
bool trigger_active

Detailed Description
Definition at line 29 of file qopencamwidget.h.

Constructor & Destructor Documentation
QOpenCamWidget::QOpenCamWidget (QWidget * parent = 0)
Consctructs a QWidget based widget for displaying video coming from an OpenCV capture source. 
Including webcam data in a Qt application can be problematic, at least as long as Phonon does not support webcams, and the Phonon GStreamer backend only supports simple pipelines.
This class solves the complexity of adding a webcam view, by using the cross-platform available OpenCV library.
Limitations, i.e. reasons to read this code and reimplement, are: saving or streaming video is not really available (unless you do repeated timer-triggered connections to the startSnap slot), the widget size is identical to the video source dimensions (it resizes the wodget using setMinimuSize to the video dimensions, and does not handle resizing to sizes above this dimension.
A brief summary of how to use this class: 
 QOpenCamWidget *cw = new QOpenCamWidget(this);
 if ( cw->grabCapture(-1) ) {
   cw->setSnapshotVisible(true);
   cw->startCapture();
 }
 connect( cw, SIGNAL(imageReady(QImage)), this, SLOT(saveImage(QImage)));

Parameters:
*parent The parent widget containing this widget, defaults to NULL. 
Definition at line 60 of file qopencamwidget.cpp.
References canvas, frametimer, layout, nextFrame, trigger, and trigger_active.
QOpenCamWidget::~QOpenCamWidget (void)

Definition at line 88 of file qopencamwidget.cpp.
References canvas, capture, and trigger.

Member Function Documentation
void QOpenCamWidget::paintEvent (QPaintEvent * event)
A paint event is a request to repaint all or part of a widget. 
It can happen for one of the following reasons:

repaint() or update() was invoked, 
the widget was obscured and has now been uncovered, or 
many other reasons.
QOpenCamWidget uses the paintEvent to draw each frame onto the screen. The paintEvent itself is regularily triggered by explicit update() calls in QOpenCamWidget::grabFrame(). 
Definition at line 144 of file qopencamwidget.cpp.
References canvas, and nextFrame.
void QOpenCamWidget::setSnapshotVisible (bool visible)
Changes the visibility of the optional built-in "Take snapshot" button. 
The widget contains a push-button that optionally can be displayed. When visible, this button is located at the bottom of the widget, and causes the SLOT QOpenCamWidget::startSnap to be triggered when clicked.
Parameters:
visible True makes the button display, and trigger, false turns the feature off. False, i.e. no button, is default. 
Definition at line 110 of file qopencamwidget.cpp.
References layout, startSnap(), trigger, and trigger_active.
Referenced by View::View().
bool QOpenCamWidget::grabCapture (int source)
Grabs an OpenCV video capture source. 
By grabbing a source, it is meant to open the capture source, and have it ready to start streaming/capturing frames. Returns true on success, false on error. The grabCapture is separated from the constructor and/or frame-grabbing, so that you may do the error-checking you really should do before proceeding.
Parameters:
source The OpenCV capture source enumeration index to open 
Definition at line 183 of file qopencamwidget.cpp.
References canvas, and capture.
Referenced by View::View().
void QOpenCamWidget::startCapture (void)
Starts up grabbing of video frames. 
The actual grabbing and displaying of video frames is performed by a QTimer triggering the SLOT QOpenCamWidget::grabFrame(). startCapture() sets up the timer running this captureFrame loop.
The SLOT QOpenCamWidget::startSnap() is used to get image frames out from the widget for other uses, like saving or processing. This function relies on the timer created and configured by startCapture(), and as such, this function is the only permitted way to start the actual capture/streaming of video from the source. 
Definition at line 217 of file qopencamwidget.cpp.
References frametimer, grabFrame(), and trigger.
Referenced by View::View().
QImage * QOpenCamWidget::Ipl2QImage (const IplImage * img)
Converts from the OpenCV IplImage data structure to a QImage. 
OpenCV uses a data strcuture calles IplImage, optimized for computer vision image processing tasks. This code was adapted from kcamwidget.cpp, part of the KDE SVN at playground/multimedia/kcam/kcamwidget.cpp
In regard that the IplImage can be forced into a format that aligns well with a RBG888-format, the conversion becomes one of the shortes, simples IplImage->QImage I've seen.
Parameters:
*img The IplImage to be converted to a QImage. 
Definition at line 241 of file qopencamwidget.cpp.
Referenced by grabFrame().
void QOpenCamWidget::grabFrame (void) [slot]
Grabs a frame and causes an update() when triggered. 
This is the SLOT that actually reads the video source and causes the widget to display live video. Preferably this slot will never be called my any other signal that a timeout() on the frametimer, which is controlled by QOpenCamWidget::startCapture() 
Definition at line 266 of file qopencamwidget.cpp.
References capture, Ipl2QImage(), and nextFrame.
Referenced by startCapture().
void QOpenCamWidget::startSnap (void) [slot]
Trigger this slot to save a frame from the widget. 
When this slot is triggered, the widgets capture loop is temporarily stopped, and the last displayed frame is "captured", and made available through the emitting of the class imageReady SIGNAL.
With the "Take snapshot" button visible (setSnapshotVisible(true)), this SLOT is triggered when the user clicks on the trigger button. If you do not wish to use the internal trigger button, you will have to add a different mechanism to trigger this SLOT.
It is possible, though I would not recommend, to use repeated triggering of this slot to do repeated frame-capture, and thus make a form of "Animation" or "Video" capture. 
Definition at line 306 of file qopencamwidget.cpp.
References frametimer, imageReady(), and nextFrame.
Referenced by setSnapshotVisible().
void QOpenCamWidget::imageReady (QImage snapshot) [signal]

Referenced by startSnap().

Member Data Documentation
CvCapture* QOpenCamWidget::capture [private]

Definition at line 35 of file qopencamwidget.h.
Referenced by grabCapture(), grabFrame(), and ~QOpenCamWidget().
QTimer* QOpenCamWidget::frametimer [private]

Definition at line 36 of file qopencamwidget.h.
Referenced by QOpenCamWidget(), startCapture(), and startSnap().
QImage* QOpenCamWidget::nextFrame [private]

Definition at line 37 of file qopencamwidget.h.
Referenced by grabFrame(), paintEvent(), QOpenCamWidget(), and startSnap().
QLabel* QOpenCamWidget::canvas [private]

Definition at line 39 of file qopencamwidget.h.
Referenced by grabCapture(), paintEvent(), QOpenCamWidget(), and ~QOpenCamWidget().
QVBoxLayout* QOpenCamWidget::layout [private]

Definition at line 40 of file qopencamwidget.h.
Referenced by QOpenCamWidget(), and setSnapshotVisible().
QPushButton* QOpenCamWidget::trigger [private]

Definition at line 41 of file qopencamwidget.h.
Referenced by QOpenCamWidget(), setSnapshotVisible(), startCapture(), and ~QOpenCamWidget().
bool QOpenCamWidget::trigger_active [private]

Definition at line 42 of file qopencamwidget.h.
Referenced by QOpenCamWidget(), and setSnapshotVisible().

The documentation for this class was generated from the following files:
qopencamwidget.h
qopencamwidget.cpp

View Class Reference
#include <view.h>

Public Slots
void saveImage (QImage image)
Public Member Functions
View (QWidget *parent=0)
~View (void)

Detailed Description
Definition at line 5 of file view.h.

Constructor & Destructor Documentation
View::View (QWidget * parent = 0)

Definition at line 32 of file view.cpp.
References QOpenCamWidget::grabCapture(), saveImage(), QOpenCamWidget::setSnapshotVisible(), and QOpenCamWidget::startCapture().
View::~View (void)

Definition at line 74 of file view.cpp.

Member Function Documentation
void View::saveImage (QImage image) [slot]

Definition at line 78 of file view.cpp.
Referenced by View().

The documentation for this class was generated from the following files:
view.h
view.cpp

File Documentation
main.cpp File Reference
#include <QtGui/QApplication>
#include "view.h"
Functions
int main (int argc, char *argv[])

Function Documentation
int main (int argc,   char * argv[])

Definition at line 28 of file main.cpp.

qopencamwidget.cpp File Reference
#include "qopencamwidget.h"

qopencamwidget.h File Reference
#include <QtGui>
#include <opencv/cv.h>
#include <opencv/highgui.h>
Classes
class QOpenCamWidget

view.cpp File Reference
#include "view.h"
#include "qopencamwidget.h"

view.h File Reference
#include <QtGui>
Classes
class View

Index
INDEX