1 <!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN">
2 <html><head><meta http-equiv=
"Content-Type" content=
"text/html;charset=UTF-8">
3 <title>QOpenCamWidget: qopencamwidget.cpp Source File
</title>
4 <link href=
"doxygen.css" rel=
"stylesheet" type=
"text/css">
5 <link href=
"tabs.css" rel=
"stylesheet" type=
"text/css">
7 <!-- Generated by Doxygen 1.5.6 -->
8 <div class=
"navigation" id=
"top">
11 <li><a href=
"main.html"><span>Main
Page
</span></a></li>
12 <li><a href=
"annotated.html"><span>Classes
</span></a></li>
13 <li class=
"current"><a href=
"files.html"><span>Files
</span></a></li>
16 <h1>qopencamwidget.cpp
</h1><a href=
"qopencamwidget_8cpp.html">Go to the documentation of this file.
</a><div class=
"fragment"><pre class=
"fragment"><a name=
"l00001"></a>00001 <span class=
"comment">/*
</span>
17 <a name=
"l00002"></a>00002 <span class=
"comment"> This file is one part of two, that together make
</span>
18 <a name=
"l00003"></a>00003 <span class=
"comment"> QOpenCamWidget, a Qt
4 widget that displays video input
</span>
19 <a name=
"l00004"></a>00004 <span class=
"comment"> from a webcam, along with an optional snapshot button.
</span>
20 <a name=
"l00005"></a>00005 <span class=
"comment"></span>
21 <a name=
"l00006"></a>00006 <span class=
"comment"> Copyright (C)
2009 Jon Langseth
</span>
22 <a name=
"l00007"></a>00007 <span class=
"comment"></span>
23 <a name=
"l00008"></a>00008 <span class=
"comment"> This program is free software; you can redistribute it and/or
</span>
24 <a name=
"l00009"></a>00009 <span class=
"comment"> modify it under the terms of the GNU General Public License
</span>
25 <a name=
"l00010"></a>00010 <span class=
"comment"> as published by the Free Software Foundation in its version
2</span>
26 <a name=
"l00011"></a>00011 <span class=
"comment"> of the License.
</span>
27 <a name=
"l00012"></a>00012 <span class=
"comment"></span>
28 <a name=
"l00013"></a>00013 <span class=
"comment"> This program is distributed in the hope that it will be useful,
</span>
29 <a name=
"l00014"></a>00014 <span class=
"comment"> but WITHOUT ANY WARRANTY; without even the implied warranty of
</span>
30 <a name=
"l00015"></a>00015 <span class=
"comment"> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
</span>
31 <a name=
"l00016"></a>00016 <span class=
"comment"> GNU General Public License for more details.
</span>
32 <a name=
"l00017"></a>00017 <span class=
"comment"></span>
33 <a name=
"l00018"></a>00018 <span class=
"comment"> You should have received a copy of the GNU General Public License
</span>
34 <a name=
"l00019"></a>00019 <span class=
"comment"> along with this program; if not, write to the Free Software
</span>
35 <a name=
"l00020"></a>00020 <span class=
"comment"> Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA
02110-
1301, USA.
</span>
36 <a name=
"l00021"></a>00021 <span class=
"comment"> */
</span>
37 <a name=
"l00022"></a>00022
38 <a name=
"l00023"></a>00023 <span class=
"preprocessor">#include
"<a class="code
" href="qopencamwidget_8h.html
">qopencamwidget.h</a>"</span>
39 <a name=
"l00024"></a>00024
40 <a name=
"l00025"></a>00025 <span class=
"comment">// ------------------------------------------------------------- //
</span>
41 <a name=
"l00026"></a>00026 <span class=
"comment">// Constructor and Destructor
</span>
42 <a name=
"l00027"></a>00027 <span class=
"comment">// ------------------------------------------------------------- //
</span>
43 <a name=
"l00028"></a>00028
44 <a name=
"l00060"></a><a class=
"code" href=
"classQOpenCamWidget.html#5835e06a54f1b09b4fd157d88dc72b6e">00060</a> <a class=
"code" href=
"classQOpenCamWidget.html#5835e06a54f1b09b4fd157d88dc72b6e" title=
"Consctructs a QWidget based widget for displaying video coming from an OpenCV capture...">QOpenCamWidget::QOpenCamWidget
</a>(QWidget *parent)
45 <a name=
"l00061"></a>00061 : QWidget(parent)
46 <a name=
"l00062"></a>00062 {
47 <a name=
"l00063"></a>00063 <span class=
"comment">// private CvCapture *nextFrame from class definition
</span>
48 <a name=
"l00064"></a>00064 <a class=
"code" href=
"classQOpenCamWidget.html#92dab283a477c1b8a6d6d5470d5ef94d">nextFrame
</a> = NULL;
49 <a name=
"l00065"></a>00065 <span class=
"comment">// private QTimer *frametimer from class definition
</span>
50 <a name=
"l00066"></a>00066 <a class=
"code" href=
"classQOpenCamWidget.html#2e70551b39fd2bd15fc99ca4fa12107f">frametimer
</a> = NULL;
51 <a name=
"l00067"></a>00067 <span class=
"comment">// private QVBoxLayout *layout from class definition
</span>
52 <a name=
"l00068"></a>00068 <a class=
"code" href=
"classQOpenCamWidget.html#e91d147fdd20819b56ebd7861d7ab44e">layout
</a> =
<span class=
"keyword">new
</span> QVBoxLayout(
<span class=
"keyword">this
</span>);
53 <a name=
"l00069"></a>00069
54 <a name=
"l00070"></a>00070 <span class=
"comment">// private QLabel *canvas from class definition
</span>
55 <a name=
"l00071"></a>00071 <a class=
"code" href=
"classQOpenCamWidget.html#7ac719f26d5f4a0a80ac6e4ffd4fe46d">canvas
</a> =
<span class=
"keyword">new
</span> QLabel(
<span class=
"keyword">this
</span>);
56 <a name=
"l00072"></a>00072 <a class=
"code" href=
"classQOpenCamWidget.html#7ac719f26d5f4a0a80ac6e4ffd4fe46d">canvas
</a>-
>setMinimumSize(
200,
100);
57 <a name=
"l00073"></a>00073 <a class=
"code" href=
"classQOpenCamWidget.html#7ac719f26d5f4a0a80ac6e4ffd4fe46d">canvas
</a>-
>setAlignment(Qt::AlignCenter);
58 <a name=
"l00074"></a>00074
59 <a name=
"l00075"></a>00075 <span class=
"comment">// private QPushButton *trigger from class definition
</span>
60 <a name=
"l00076"></a>00076 <a class=
"code" href=
"classQOpenCamWidget.html#a0aaf9bfc43d01979a7af03741620624">trigger
</a> =
<span class=
"keyword">new
</span> QPushButton(
<span class=
"keyword">this
</span>);
61 <a name=
"l00077"></a>00077 <a class=
"code" href=
"classQOpenCamWidget.html#a0aaf9bfc43d01979a7af03741620624">trigger
</a>-
>setText(
<span class=
"stringliteral">"Take picture"</span>);
62 <a name=
"l00078"></a>00078 <a class=
"code" href=
"classQOpenCamWidget.html#a0aaf9bfc43d01979a7af03741620624">trigger
</a>-
>setEnabled(
<span class=
"keyword">false
</span>);
63 <a name=
"l00079"></a>00079 <a class=
"code" href=
"classQOpenCamWidget.html#a0aaf9bfc43d01979a7af03741620624">trigger
</a>-
>hide();
64 <a name=
"l00080"></a>00080
65 <a name=
"l00081"></a>00081 <span class=
"comment">// private bool trigger_active from class definition
</span>
66 <a name=
"l00082"></a>00082 <a class=
"code" href=
"classQOpenCamWidget.html#1718e4971977520cfe642daa78e1997e">trigger_active
</a> =
<span class=
"keyword">false
</span>;
67 <a name=
"l00083"></a>00083
68 <a name=
"l00084"></a>00084 <a class=
"code" href=
"classQOpenCamWidget.html#e91d147fdd20819b56ebd7861d7ab44e">layout
</a>-
>addWidget(
<a class=
"code" href=
"classQOpenCamWidget.html#7ac719f26d5f4a0a80ac6e4ffd4fe46d">canvas
</a>);
69 <a name=
"l00085"></a>00085 this-
>setLayout(
<a class=
"code" href=
"classQOpenCamWidget.html#e91d147fdd20819b56ebd7861d7ab44e">layout
</a>);
70 <a name=
"l00086"></a>00086 }
71 <a name=
"l00087"></a>00087
72 <a name=
"l00088"></a><a class=
"code" href=
"classQOpenCamWidget.html#b0ad4890d7d638354289e074a6f71a3f">00088</a> <a class=
"code" href=
"classQOpenCamWidget.html#b0ad4890d7d638354289e074a6f71a3f">QOpenCamWidget::~QOpenCamWidget
</a>(
<span class=
"keywordtype">void
</span>)
73 <a name=
"l00089"></a>00089 {
74 <a name=
"l00090"></a>00090 cvReleaseCapture(
&<a class=
"code" href=
"classQOpenCamWidget.html#fde0c9d47e2ea44f2aeea499fd570368">capture
</a> );
75 <a name=
"l00091"></a>00091 <span class=
"keyword">delete
</span> <a class=
"code" href=
"classQOpenCamWidget.html#7ac719f26d5f4a0a80ac6e4ffd4fe46d">canvas
</a>;
76 <a name=
"l00092"></a>00092 <span class=
"keyword">delete
</span> <a class=
"code" href=
"classQOpenCamWidget.html#a0aaf9bfc43d01979a7af03741620624">trigger
</a>;
77 <a name=
"l00093"></a>00093 }
78 <a name=
"l00094"></a>00094 <span class=
"comment">// ------------------------------------------------------------- //
</span>
79 <a name=
"l00095"></a>00095 <span class=
"comment">// Public methods (not signals/slots)
</span>
80 <a name=
"l00096"></a>00096 <span class=
"comment">// ------------------------------------------------------------- //
</span>
81 <a name=
"l00097"></a>00097
82 <a name=
"l00109"></a>00109 <span class=
"keywordtype">void
</span>
83 <a name=
"l00110"></a><a class=
"code" href=
"classQOpenCamWidget.html#8f885a8bb88870cd19cfc9eb4e02e2ce">00110</a> <a class=
"code" href=
"classQOpenCamWidget.html#8f885a8bb88870cd19cfc9eb4e02e2ce" title=
"Changes the visibility of the optional built-in &quot;Take snapshot&quot; button...">QOpenCamWidget::setSnapshotVisible
</a>(
<span class=
"keywordtype">bool
</span> visible)
84 <a name=
"l00111"></a>00111 {
85 <a name=
"l00112"></a>00112 <span class=
"comment">// Checking both parameter and private
"sanity" variable,
</span>
86 <a name=
"l00113"></a>00113 <span class=
"comment">// as a sanity- and error-control
</span>
87 <a name=
"l00114"></a>00114 <span class=
"keywordflow">if
</span> ( visible
&& !
<a class=
"code" href=
"classQOpenCamWidget.html#1718e4971977520cfe642daa78e1997e">trigger_active
</a> )
88 <a name=
"l00115"></a>00115 {
89 <a name=
"l00116"></a>00116 connect(
<a class=
"code" href=
"classQOpenCamWidget.html#a0aaf9bfc43d01979a7af03741620624">trigger
</a>, SIGNAL(clicked()),
<span class=
"keyword">this
</span>, SLOT(
<a class=
"code" href=
"classQOpenCamWidget.html#82540c90d3efa85631f13af3a60fa94b" title=
"Trigger this slot to save a frame from the widget.">startSnap
</a>()));
90 <a name=
"l00117"></a>00117 <a class=
"code" href=
"classQOpenCamWidget.html#e91d147fdd20819b56ebd7861d7ab44e">layout
</a>-
>addWidget(
<a class=
"code" href=
"classQOpenCamWidget.html#a0aaf9bfc43d01979a7af03741620624">trigger
</a>);
91 <a name=
"l00118"></a>00118 <a class=
"code" href=
"classQOpenCamWidget.html#a0aaf9bfc43d01979a7af03741620624">trigger
</a>-
>show();
92 <a name=
"l00119"></a>00119 <a class=
"code" href=
"classQOpenCamWidget.html#1718e4971977520cfe642daa78e1997e">trigger_active
</a> =
<span class=
"keyword">true
</span>;
93 <a name=
"l00120"></a>00120 }
94 <a name=
"l00121"></a>00121 <span class=
"keywordflow">if
</span> ( !visible
&& <a class=
"code" href=
"classQOpenCamWidget.html#1718e4971977520cfe642daa78e1997e">trigger_active
</a> )
95 <a name=
"l00122"></a>00122 {
96 <a name=
"l00123"></a>00123 <a class=
"code" href=
"classQOpenCamWidget.html#e91d147fdd20819b56ebd7861d7ab44e">layout
</a>-
>removeWidget(
<a class=
"code" href=
"classQOpenCamWidget.html#a0aaf9bfc43d01979a7af03741620624">trigger
</a>);
97 <a name=
"l00124"></a>00124 disconnect(
<a class=
"code" href=
"classQOpenCamWidget.html#a0aaf9bfc43d01979a7af03741620624">trigger
</a>, SIGNAL(clicked()),
0,
0 );
98 <a name=
"l00125"></a>00125 <a class=
"code" href=
"classQOpenCamWidget.html#a0aaf9bfc43d01979a7af03741620624">trigger
</a>-
>hide();
99 <a name=
"l00126"></a>00126 <a class=
"code" href=
"classQOpenCamWidget.html#1718e4971977520cfe642daa78e1997e">trigger_active
</a> =
<span class=
"keyword">false
</span>;
100 <a name=
"l00127"></a>00127 }
101 <a name=
"l00128"></a>00128 }
102 <a name=
"l00143"></a>00143 <span class=
"keywordtype">void
</span>
103 <a name=
"l00144"></a><a class=
"code" href=
"classQOpenCamWidget.html#c6186d1e510b5c8635b2d3bf5d94def6">00144</a> <a class=
"code" href=
"classQOpenCamWidget.html#c6186d1e510b5c8635b2d3bf5d94def6" title=
"A paint event is a request to repaint all or part of a widget.">QOpenCamWidget::paintEvent
</a> ( QPaintEvent * event )
104 <a name=
"l00145"></a>00145 {
105 <a name=
"l00146"></a>00146 QPainter * paint =
<span class=
"keyword">new
</span> QPainter;
106 <a name=
"l00147"></a>00147 paint-
>begin(
<span class=
"keyword">this
</span>);
107 <a name=
"l00148"></a>00148
108 <a name=
"l00149"></a>00149 <span class=
"keywordflow">if
</span> (
<a class=
"code" href=
"classQOpenCamWidget.html#92dab283a477c1b8a6d6d5470d5ef94d">nextFrame
</a> )
109 <a name=
"l00150"></a>00150 {
110 <a name=
"l00151"></a>00151 <span class=
"comment">// Using this objects painter to draw the image
</span>
111 <a name=
"l00152"></a>00152 <span class=
"comment">// causes a cute, but not desired effect..
</span>
112 <a name=
"l00153"></a>00153 <span class=
"comment">//paint-
>drawImage(event-
>rect(), *nextFrame);
</span>
113 <a name=
"l00154"></a>00154
114 <a name=
"l00155"></a>00155 <span class=
"comment">// Until I find a better solution on how to do the
</span>
115 <a name=
"l00156"></a>00156 <span class=
"comment">// redraw of the image, setPixmap on the canvas
</span>
116 <a name=
"l00157"></a>00157 <span class=
"comment">// does do the job. This may cause a performance
</span>
117 <a name=
"l00158"></a>00158 <span class=
"comment">// penalty though, and is considered a FIXME
</span>
118 <a name=
"l00159"></a>00159 <span class=
"comment">// Another drawback is that the widget does not resize..
</span>
119 <a name=
"l00160"></a>00160 <a class=
"code" href=
"classQOpenCamWidget.html#7ac719f26d5f4a0a80ac6e4ffd4fe46d">canvas
</a>-
>setPixmap( QPixmap::fromImage(*
<a class=
"code" href=
"classQOpenCamWidget.html#92dab283a477c1b8a6d6d5470d5ef94d">nextFrame
</a>) );
120 <a name=
"l00161"></a>00161 }
121 <a name=
"l00162"></a>00162 <span class=
"keywordflow">else
</span>
122 <a name=
"l00163"></a>00163 {
123 <a name=
"l00164"></a>00164 <a class=
"code" href=
"classQOpenCamWidget.html#7ac719f26d5f4a0a80ac6e4ffd4fe46d">canvas
</a>-
>setText(
<span class=
"stringliteral">"No data, check/test camera"</span>);
124 <a name=
"l00165"></a>00165 }
125 <a name=
"l00166"></a>00166 paint-
>end();
126 <a name=
"l00167"></a>00167 }
127 <a name=
"l00168"></a>00168
128 <a name=
"l00169"></a>00169
129 <a name=
"l00182"></a>00182 <span class=
"keywordtype">bool
</span>
130 <a name=
"l00183"></a><a class=
"code" href=
"classQOpenCamWidget.html#23574314cbd7a74bc6f32a640041d55a">00183</a> <a class=
"code" href=
"classQOpenCamWidget.html#23574314cbd7a74bc6f32a640041d55a" title=
"Grabs an OpenCV video capture source.">QOpenCamWidget::grabCapture
</a>(
<span class=
"keywordtype">int
</span> source)
131 <a name=
"l00184"></a>00184 {
132 <a name=
"l00185"></a>00185 <a class=
"code" href=
"classQOpenCamWidget.html#fde0c9d47e2ea44f2aeea499fd570368">capture
</a> = cvCaptureFromCAM(
0);
133 <a name=
"l00186"></a>00186 <span class=
"keywordflow">if
</span> (!
<a class=
"code" href=
"classQOpenCamWidget.html#fde0c9d47e2ea44f2aeea499fd570368">capture
</a>)
134 <a name=
"l00187"></a>00187 {
135 <a name=
"l00188"></a>00188 qDebug()
<< <span class=
"stringliteral">"QOpenCamWidget::grabCapture("</span> << source
<< <span class=
"stringliteral">") failed"</span>;
136 <a name=
"l00189"></a>00189 <span class=
"keywordflow">return
</span> <span class=
"keyword">false
</span>;
137 <a name=
"l00190"></a>00190 }
138 <a name=
"l00191"></a>00191 cvGrabFrame(
<a class=
"code" href=
"classQOpenCamWidget.html#fde0c9d47e2ea44f2aeea499fd570368">capture
</a>);
<span class=
"comment">// Grab a single frame, do resizing based on it.
</span>
139 <a name=
"l00192"></a>00192 IplImage *image = cvRetrieveFrame(
<a class=
"code" href=
"classQOpenCamWidget.html#fde0c9d47e2ea44f2aeea499fd570368">capture
</a>);
140 <a name=
"l00193"></a>00193 QSize t_size = QSize(image-
>width,image-
>height);
141 <a name=
"l00194"></a>00194
142 <a name=
"l00195"></a>00195 qDebug()
<< <span class=
"stringliteral">"Device image format: "</span> << image-
>width
<< <span class=
"stringliteral">"x"</span> << image-
>height;
143 <a name=
"l00196"></a>00196 <a class=
"code" href=
"classQOpenCamWidget.html#7ac719f26d5f4a0a80ac6e4ffd4fe46d">canvas
</a>-
>setMinimumSize(t_size);
144 <a name=
"l00197"></a>00197 <a class=
"code" href=
"classQOpenCamWidget.html#7ac719f26d5f4a0a80ac6e4ffd4fe46d">canvas
</a>-
>setMaximumSize(t_size);
145 <a name=
"l00198"></a>00198
146 <a name=
"l00199"></a>00199 <span class=
"keywordflow">return
</span> <span class=
"keyword">true
</span>;
147 <a name=
"l00200"></a>00200 }
148 <a name=
"l00201"></a>00201
149 <a name=
"l00216"></a>00216 <span class=
"keywordtype">void
</span>
150 <a name=
"l00217"></a><a class=
"code" href=
"classQOpenCamWidget.html#b378daa447e8d9b94e1c7c8c6853b880">00217</a> <a class=
"code" href=
"classQOpenCamWidget.html#b378daa447e8d9b94e1c7c8c6853b880" title=
"Starts up grabbing of video frames.">QOpenCamWidget::startCapture
</a>(
<span class=
"keywordtype">void
</span>)
151 <a name=
"l00218"></a>00218 {
152 <a name=
"l00219"></a>00219 <a class=
"code" href=
"classQOpenCamWidget.html#2e70551b39fd2bd15fc99ca4fa12107f">frametimer
</a> =
<span class=
"keyword">new
</span> QTimer(
<span class=
"keyword">this
</span>);
153 <a name=
"l00220"></a>00220 <a class=
"code" href=
"classQOpenCamWidget.html#2e70551b39fd2bd15fc99ca4fa12107f">frametimer
</a>-
>start(
70);
154 <a name=
"l00221"></a>00221 connect(
<a class=
"code" href=
"classQOpenCamWidget.html#2e70551b39fd2bd15fc99ca4fa12107f">frametimer
</a>,SIGNAL(timeout()),
<span class=
"keyword">this
</span>,SLOT(
<a class=
"code" href=
"classQOpenCamWidget.html#27c30cec9a8d44c1802e4218bea7bdb4" title=
"Grabs a frame and causes an update() when triggered.">grabFrame
</a>()));
155 <a name=
"l00222"></a>00222 <a class=
"code" href=
"classQOpenCamWidget.html#a0aaf9bfc43d01979a7af03741620624">trigger
</a>-
>setEnabled(
<span class=
"keyword">true
</span>);
156 <a name=
"l00223"></a>00223 }
157 <a name=
"l00224"></a>00224
158 <a name=
"l00240"></a>00240 QImage*
159 <a name=
"l00241"></a><a class=
"code" href=
"classQOpenCamWidget.html#aba8721f46b41d76326e048e3c876f1d">00241</a> <a class=
"code" href=
"classQOpenCamWidget.html#aba8721f46b41d76326e048e3c876f1d" title=
"Converts from the OpenCV IplImage data structure to a QImage.">QOpenCamWidget::Ipl2QImage
</a>(
<span class=
"keyword">const
</span> IplImage *img)
160 <a name=
"l00242"></a>00242 {
161 <a name=
"l00243"></a>00243 IplImage *tmp=cvCloneImage(img);
162 <a name=
"l00244"></a>00244 cvConvertImage(img,tmp, CV_CVTIMG_SWAP_RB );
163 <a name=
"l00245"></a>00245 QImage * qimage =
<span class=
"keyword">new
</span> QImage(reinterpret_cast
<uchar*
>(tmp-
>imageData),
164 <a name=
"l00246"></a>00246 tmp-
>width,
165 <a name=
"l00247"></a>00247 tmp-
>height,
166 <a name=
"l00248"></a>00248 3* tmp-
>width,
167 <a name=
"l00249"></a>00249 QImage::Format_RGB888);
168 <a name=
"l00250"></a>00250 <span class=
"keywordflow">return
</span> qimage;
169 <a name=
"l00251"></a>00251
170 <a name=
"l00252"></a>00252 }
171 <a name=
"l00253"></a>00253 <span class=
"comment">// ------------------------------------------------------------- //
</span>
172 <a name=
"l00254"></a>00254 <span class=
"comment">// Public SLOTS
</span>
173 <a name=
"l00255"></a>00255 <span class=
"comment">// ------------------------------------------------------------- //
</span>
174 <a name=
"l00256"></a>00256
175 <a name=
"l00266"></a><a class=
"code" href=
"classQOpenCamWidget.html#27c30cec9a8d44c1802e4218bea7bdb4">00266</a> <span class=
"keywordtype">void
</span> <a class=
"code" href=
"classQOpenCamWidget.html#27c30cec9a8d44c1802e4218bea7bdb4" title=
"Grabs a frame and causes an update() when triggered.">QOpenCamWidget::grabFrame
</a>(
<span class=
"keywordtype">void
</span>)
176 <a name=
"l00267"></a>00267 {
177 <a name=
"l00268"></a>00268 <span class=
"keywordflow">if
</span> ( !
<a class=
"code" href=
"classQOpenCamWidget.html#fde0c9d47e2ea44f2aeea499fd570368">capture
</a> )
178 <a name=
"l00269"></a>00269 {
179 <a name=
"l00270"></a>00270 qDebug()
<< <span class=
"stringliteral">"Capture device not ready!"</span>;
180 <a name=
"l00271"></a>00271 <span class=
"keywordflow">return
</span>;
181 <a name=
"l00272"></a>00272 }
182 <a name=
"l00273"></a>00273
183 <a name=
"l00274"></a>00274 cvGrabFrame(
<a class=
"code" href=
"classQOpenCamWidget.html#fde0c9d47e2ea44f2aeea499fd570368">capture
</a>);
184 <a name=
"l00275"></a>00275
185 <a name=
"l00276"></a>00276 IplImage *iplimage = cvRetrieveFrame(
<a class=
"code" href=
"classQOpenCamWidget.html#fde0c9d47e2ea44f2aeea499fd570368">capture
</a>);
186 <a name=
"l00277"></a>00277
187 <a name=
"l00278"></a>00278 <span class=
"keywordflow">if
</span> (iplimage)
188 <a name=
"l00279"></a>00279 {
189 <a name=
"l00280"></a>00280 <a class=
"code" href=
"classQOpenCamWidget.html#92dab283a477c1b8a6d6d5470d5ef94d">nextFrame
</a> =
<a class=
"code" href=
"classQOpenCamWidget.html#aba8721f46b41d76326e048e3c876f1d" title=
"Converts from the OpenCV IplImage data structure to a QImage.">Ipl2QImage
</a>(iplimage);
190 <a name=
"l00281"></a>00281 }
191 <a name=
"l00282"></a>00282 <span class=
"keywordflow">else
</span>
192 <a name=
"l00283"></a>00283 {
193 <a name=
"l00284"></a>00284 <a class=
"code" href=
"classQOpenCamWidget.html#92dab283a477c1b8a6d6d5470d5ef94d">nextFrame
</a> = NULL;
194 <a name=
"l00285"></a>00285 }
195 <a name=
"l00286"></a>00286 update();
196 <a name=
"l00287"></a>00287 }
197 <a name=
"l00288"></a>00288
198 <a name=
"l00306"></a><a class=
"code" href=
"classQOpenCamWidget.html#82540c90d3efa85631f13af3a60fa94b">00306</a> <span class=
"keywordtype">void
</span> <a class=
"code" href=
"classQOpenCamWidget.html#82540c90d3efa85631f13af3a60fa94b" title=
"Trigger this slot to save a frame from the widget.">QOpenCamWidget::startSnap
</a>(
<span class=
"keywordtype">void
</span>)
199 <a name=
"l00307"></a>00307 {
200 <a name=
"l00308"></a>00308 <span class=
"keywordflow">if
</span> (
<a class=
"code" href=
"classQOpenCamWidget.html#2e70551b39fd2bd15fc99ca4fa12107f">frametimer
</a> ) {
201 <a name=
"l00309"></a>00309 <span class=
"keywordflow">if
</span> (
<a class=
"code" href=
"classQOpenCamWidget.html#2e70551b39fd2bd15fc99ca4fa12107f">frametimer
</a>-
>isActive())
202 <a name=
"l00310"></a>00310 {
203 <a name=
"l00311"></a>00311 <a class=
"code" href=
"classQOpenCamWidget.html#2e70551b39fd2bd15fc99ca4fa12107f">frametimer
</a>-
>stop();
204 <a name=
"l00312"></a>00312 qDebug()
<< <span class=
"stringliteral">"SNAP!"</span>;
205 <a name=
"l00313"></a>00313
206 <a name=
"l00314"></a>00314 emit
<a class=
"code" href=
"classQOpenCamWidget.html#d410be92ce25ff591726ba255070d09e">imageReady
</a>(QImage(*
<a class=
"code" href=
"classQOpenCamWidget.html#92dab283a477c1b8a6d6d5470d5ef94d">nextFrame
</a>));
207 <a name=
"l00315"></a>00315 <a class=
"code" href=
"classQOpenCamWidget.html#2e70551b39fd2bd15fc99ca4fa12107f">frametimer
</a>-
>start();
208 <a name=
"l00316"></a>00316 }
209 <a name=
"l00317"></a>00317 }
210 <a name=
"l00318"></a>00318 }
211 <a name=
"l00319"></a>00319
213 <hr size=
"1"><address style=
"text-align: right;"><small>Generated on Thu Jun
11 01:
49:
57 2009 for QOpenCamWidget by
214 <a href=
"http://www.doxygen.org/index.html">
215 <img src=
"doxygen.png" alt=
"doxygen" align=
"middle" border=
"0"></a> 1.5.6 </small></address>