]> git.defcon.no Git - qopencamwidget/blob - doc/man/man3/QOpenCamWidget.3
New filename. Cleaner, leaner
[qopencamwidget] / doc / man / man3 / QOpenCamWidget.3
1 .TH "QOpenCamWidget" 3 "11 Jun 2009" "QOpenCamWidget" \" -*- nroff -*-
2 .ad l
3 .nh
4 .SH NAME
5 QOpenCamWidget \-
6 .SH SYNOPSIS
7 .br
8 .PP
9 \fC#include <qopencamwidget.h>\fP
10 .PP
11 .SS "Public Slots"
12
13 .in +1c
14 .ti -1c
15 .RI "void \fBgrabFrame\fP (void)"
16 .br
17 .RI "\fIGrabs a frame and causes an update() when triggered. \fP"
18 .ti -1c
19 .RI "void \fBstartSnap\fP ()"
20 .br
21 .RI "\fITrigger this slot to save a frame from the widget. \fP"
22 .in -1c
23 .SS "Signals"
24
25 .in +1c
26 .ti -1c
27 .RI "void \fBimageReady\fP (QImage snapshot)"
28 .br
29 .in -1c
30 .SS "Public Member Functions"
31
32 .in +1c
33 .ti -1c
34 .RI "\fBQOpenCamWidget\fP (QWidget *parent=0)"
35 .br
36 .RI "\fIConsctructs a QWidget based widget for displaying video coming from an OpenCV capture source. \fP"
37 .ti -1c
38 .RI "\fB~QOpenCamWidget\fP (void)"
39 .br
40 .ti -1c
41 .RI "void \fBpaintEvent\fP (QPaintEvent *event)"
42 .br
43 .RI "\fIA paint event is a request to repaint all or part of a widget. \fP"
44 .ti -1c
45 .RI "void \fBsetSnapshotVisible\fP (bool visible)"
46 .br
47 .RI "\fIChanges the visibility of the optional built-in 'Take snapshot' button. \fP"
48 .ti -1c
49 .RI "bool \fBgrabCapture\fP (int source)"
50 .br
51 .RI "\fIGrabs an OpenCV video capture source. \fP"
52 .ti -1c
53 .RI "void \fBstartCapture\fP (void)"
54 .br
55 .RI "\fIStarts up grabbing of video frames. \fP"
56 .ti -1c
57 .RI "QImage * \fBIpl2QImage\fP (const IplImage *img)"
58 .br
59 .RI "\fIConverts from the OpenCV IplImage data structure to a QImage. \fP"
60 .in -1c
61 .SS "Private Attributes"
62
63 .in +1c
64 .ti -1c
65 .RI "CvCapture * \fBcapture\fP"
66 .br
67 .ti -1c
68 .RI "QTimer * \fBframetimer\fP"
69 .br
70 .ti -1c
71 .RI "QImage * \fBnextFrame\fP"
72 .br
73 .ti -1c
74 .RI "QLabel * \fBcanvas\fP"
75 .br
76 .ti -1c
77 .RI "QVBoxLayout * \fBlayout\fP"
78 .br
79 .ti -1c
80 .RI "QPushButton * \fBtrigger\fP"
81 .br
82 .ti -1c
83 .RI "bool \fBtrigger_active\fP"
84 .br
85 .in -1c
86 .SH "Detailed Description"
87 .PP
88 Definition at line 29 of file qopencamwidget.h.
89 .SH "Constructor & Destructor Documentation"
90 .PP
91 .SS "QOpenCamWidget::QOpenCamWidget (QWidget * parent = \fC0\fP)"
92 .PP
93 Consctructs a QWidget based widget for displaying video coming from an OpenCV capture source.
94 .PP
95 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.
96 .PP
97 This class solves the complexity of adding a webcam view, by using the cross-platform available OpenCV library.
98 .PP
99 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.
100 .PP
101 A brief summary of how to use this class:
102 .PP
103 .nf
104 QOpenCamWidget *cw = new QOpenCamWidget(this);
105 if ( cw->grabCapture(-1) ) {
106 cw->setSnapshotVisible(true);
107 cw->startCapture();
108 }
109 connect( cw, SIGNAL(imageReady(QImage)), this, SLOT(saveImage(QImage)));
110
111 .fi
112 .PP
113 .PP
114 \fBParameters:\fP
115 .RS 4
116 \fI*parent\fP The parent widget containing this widget, defaults to NULL.
117 .RE
118 .PP
119
120 .PP
121 Definition at line 60 of file qopencamwidget.cpp.
122 .PP
123 References canvas, frametimer, layout, nextFrame, trigger, and trigger_active.
124 .SS "QOpenCamWidget::~QOpenCamWidget (void)"
125 .PP
126 Definition at line 88 of file qopencamwidget.cpp.
127 .PP
128 References canvas, capture, and trigger.
129 .SH "Member Function Documentation"
130 .PP
131 .SS "void QOpenCamWidget::paintEvent (QPaintEvent * event)"
132 .PP
133 A paint event is a request to repaint all or part of a widget.
134 .PP
135 It can happen for one of the following reasons:
136 .PP
137 .PD 0
138 .IP "\(bu" 2
139 repaint() or update() was invoked,
140 .IP "\(bu" 2
141 the widget was obscured and has now been uncovered, or
142 .IP "\(bu" 2
143 many other reasons.
144 .PP
145 \fBQOpenCamWidget\fP uses the paintEvent to draw each frame onto the screen. The paintEvent itself is regularily triggered by explicit update() calls in \fBQOpenCamWidget::grabFrame()\fP.
146 .PP
147 Definition at line 144 of file qopencamwidget.cpp.
148 .PP
149 References canvas, and nextFrame.
150 .SS "void QOpenCamWidget::setSnapshotVisible (bool visible)"
151 .PP
152 Changes the visibility of the optional built-in 'Take snapshot' button.
153 .PP
154 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 \fBQOpenCamWidget::startSnap\fP to be triggered when clicked.
155 .PP
156 \fBParameters:\fP
157 .RS 4
158 \fIvisible\fP True makes the button display, and trigger, false turns the feature off. False, i.e. no button, is default.
159 .RE
160 .PP
161
162 .PP
163 Definition at line 110 of file qopencamwidget.cpp.
164 .PP
165 References layout, startSnap(), trigger, and trigger_active.
166 .PP
167 Referenced by View::View().
168 .SS "bool QOpenCamWidget::grabCapture (int source)"
169 .PP
170 Grabs an OpenCV video capture source.
171 .PP
172 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.
173 .PP
174 \fBParameters:\fP
175 .RS 4
176 \fIsource\fP The OpenCV capture source enumeration index to open
177 .RE
178 .PP
179
180 .PP
181 Definition at line 183 of file qopencamwidget.cpp.
182 .PP
183 References canvas, and capture.
184 .PP
185 Referenced by View::View().
186 .SS "void QOpenCamWidget::startCapture (void)"
187 .PP
188 Starts up grabbing of video frames.
189 .PP
190 The actual grabbing and displaying of video frames is performed by a QTimer triggering the SLOT \fBQOpenCamWidget::grabFrame()\fP. \fBstartCapture()\fP sets up the timer running this captureFrame loop.
191 .PP
192 The SLOT \fBQOpenCamWidget::startSnap()\fP 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 \fBstartCapture()\fP, and as such, this function is the only permitted way to start the actual capture/streaming of video from the source.
193 .PP
194 Definition at line 217 of file qopencamwidget.cpp.
195 .PP
196 References frametimer, grabFrame(), and trigger.
197 .PP
198 Referenced by View::View().
199 .SS "QImage * QOpenCamWidget::Ipl2QImage (const IplImage * img)"
200 .PP
201 Converts from the OpenCV IplImage data structure to a QImage.
202 .PP
203 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
204 .PP
205 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.
206 .PP
207 \fBParameters:\fP
208 .RS 4
209 \fI*img\fP The IplImage to be converted to a QImage.
210 .RE
211 .PP
212
213 .PP
214 Definition at line 241 of file qopencamwidget.cpp.
215 .PP
216 Referenced by grabFrame().
217 .SS "void QOpenCamWidget::grabFrame (void)\fC [slot]\fP"
218 .PP
219 Grabs a frame and causes an update() when triggered.
220 .PP
221 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 \fBQOpenCamWidget::startCapture()\fP
222 .PP
223 Definition at line 266 of file qopencamwidget.cpp.
224 .PP
225 References capture, Ipl2QImage(), and nextFrame.
226 .PP
227 Referenced by startCapture().
228 .SS "void QOpenCamWidget::startSnap (void)\fC [slot]\fP"
229 .PP
230 Trigger this slot to save a frame from the widget.
231 .PP
232 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.
233 .PP
234 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.
235 .PP
236 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.
237 .PP
238 Definition at line 306 of file qopencamwidget.cpp.
239 .PP
240 References frametimer, imageReady(), and nextFrame.
241 .PP
242 Referenced by setSnapshotVisible().
243 .SS "void QOpenCamWidget::imageReady (QImage snapshot)\fC [signal]\fP"
244 .PP
245 Referenced by startSnap().
246 .SH "Member Data Documentation"
247 .PP
248 .SS "CvCapture* \fBQOpenCamWidget::capture\fP\fC [private]\fP"
249 .PP
250 Definition at line 35 of file qopencamwidget.h.
251 .PP
252 Referenced by grabCapture(), grabFrame(), and ~QOpenCamWidget().
253 .SS "QTimer* \fBQOpenCamWidget::frametimer\fP\fC [private]\fP"
254 .PP
255 Definition at line 36 of file qopencamwidget.h.
256 .PP
257 Referenced by QOpenCamWidget(), startCapture(), and startSnap().
258 .SS "QImage* \fBQOpenCamWidget::nextFrame\fP\fC [private]\fP"
259 .PP
260 Definition at line 37 of file qopencamwidget.h.
261 .PP
262 Referenced by grabFrame(), paintEvent(), QOpenCamWidget(), and startSnap().
263 .SS "QLabel* \fBQOpenCamWidget::canvas\fP\fC [private]\fP"
264 .PP
265 Definition at line 39 of file qopencamwidget.h.
266 .PP
267 Referenced by grabCapture(), paintEvent(), QOpenCamWidget(), and ~QOpenCamWidget().
268 .SS "QVBoxLayout* \fBQOpenCamWidget::layout\fP\fC [private]\fP"
269 .PP
270 Definition at line 40 of file qopencamwidget.h.
271 .PP
272 Referenced by QOpenCamWidget(), and setSnapshotVisible().
273 .SS "QPushButton* \fBQOpenCamWidget::trigger\fP\fC [private]\fP"
274 .PP
275 Definition at line 41 of file qopencamwidget.h.
276 .PP
277 Referenced by QOpenCamWidget(), setSnapshotVisible(), startCapture(), and ~QOpenCamWidget().
278 .SS "bool \fBQOpenCamWidget::trigger_active\fP\fC [private]\fP"
279 .PP
280 Definition at line 42 of file qopencamwidget.h.
281 .PP
282 Referenced by QOpenCamWidget(), and setSnapshotVisible().
283
284 .SH "Author"
285 .PP
286 Generated automatically by Doxygen for QOpenCamWidget from the source code.