<meta http-equiv="CONTENT-TYPE" content="text/html; charset=utf-8"/><title></title><meta name="GENERATOR" content="OpenOffice.org 3.2 (Win32)"/><style type="text/css">
        <!--
                @page { size: 21cm 29.7cm; margin: 2cm }
                P { margin-bottom: 0.21cm }
        -->
        </style>
<p style="margin-bottom: 0cm;"><span style="background: none repeat scroll 0% 0% rgb(255, 255, 255);">Thank
for your reply, <br/><br/>I did it like this: <br/><br/>uyvy2rgb24
(unsigned char * dest, unsigned char * src, int w, int h) <br/>/ /
Dest -> new buffer dest <br/>/ / Src -> with frame buffer from
device (UYVY) <br/></span>/ / In -> size of frame in RGB <br/><span style="background: none repeat scroll 0% 0% rgb(255, 255, 255);">/
/ H -> size of frame in UYVY <br/></span>( <br/> <span style="background: none repeat scroll 0% 0% rgb(255, 255, 255);">unsigned
int i; <br/> </span>dest_offset int = 0; <br/><br/><br/><span style="background: none repeat scroll 0% 0% rgb(255, 255, 255);">/
/ Iterate UYVY stream in the block of size 4 <br/>/ / Because in every
block there are two Y-Information (y1, y2) and a Cb (u) and a Cr (v)
<br/> </span>for (i = 0; i <h i + = 4) <br/> (
<br/>unsigned char * r, * b, * g; <br/><span style="background: none repeat scroll 0% 0% rgb(255, 255, 255);">unsigned
char * y1, * y2, * u * v; <br/><br/> </span>double fr, fg,
fb; <br/> <span style="background: none repeat scroll 0% 0% rgb(255, 255, 255);">FY1 double,
fy2, fu, fv; <br/><br/> </span>r = dest + dest_offset; <br/> g
= r + 1; <br/> b = g + 1; <br/><br/> u = src + i;
<br/> y1 = u + 1; <br/> v = y1 + 1; <br/> y2
= v + 1; <br/><br/> fu = * u; <br/> fv = * v;
<br/> <span style="background: none repeat scroll 0% 0% rgb(255, 255, 255);">FY1 = * y1; <br/> </span>fy2
= * y2; <br/><br/> fr = FY1 - 0.0009267 * (fu - 128) +
1.4016868 * (fv - 128); <br/> fg = FY1 - 0.3436954 * (Fu -
128) - 0.7141690 * (fv - 128); <br/> FY1 + fb = 1.7721604 *
(fu - 128) + 0.0009902 * (fv - 128); <br/><br/> * R =
(unsigned char) (fr> 255? 255: (fr <0? 0: fr)); <br/> *
G = (unsigned char) (fg> 255? 255: (fg <0? 0: fg)); <br/> *
B = (unsigned char) (fb> 255? 255 (fb <0? 0: fb));
<br/><br/><br/> dest_offset + = 3; <br/><br/> r =
dest + dest_offset; <br/> g = r + 1; <br/> b = g
+ 1; <br/><br/> <span style="background: none repeat scroll 0% 0% rgb(255, 255, 255);">fr = fy2 -
0.0009267 * (fu - 128) + 1.4016868 * (fv - 128); <br/> fg =
fy2 - 0.3436954 * (fu - 128) - 0.7141690 * (fv - 128); <br/> fb
= fy2 + 1.7721604 * (fu - 128) + 0.0009902 * (fv - 128); <br/><br/> *
R = (unsigned char) (fr> 255? 255: (fr <0? 0: fr)); <br/> *
G = (unsigned char) (fg> 255? 255: (fg <0? 0: fg)); <br/> *
B = (unsigned char) (fb> 255? 255 (fb <0? 0: fb));
<br/><br/> dest_offset + = 3; <br/> </span>) <br/><span style="background: none repeat scroll 0% 0% rgb(255, 255, 255);">return
h * 1.5; <br/> </span>) <br/><br/><span style="background: none repeat scroll 0% 0% rgb(255, 255, 255);">I
have only a slight problem with running it in
WebvamWinVideoImager.cxx. Any idea?</span>
</p>
<p style="margin-bottom: 0cm;"><br/>
</p>
<br/><br/>"Patrick Cheng" <cheng@isis.georgetown.edu> pisze:<br/><blockquote style="margin-left: 10px; border-left: 2px solid rgb(102, 102, 102); padding-left: 10px;">Hi Kuba,<br/><br/>
First, you can check if your device allow both RGB output mode, if so
you can try change the output to RGB mode.<br/><br/>
If your device doesn't support RGB output, then you need to some
hacking to get it to work. Here are some directions:<br/><br/>
1. Open the igstkWebcamWinVideoImager.cxx class, around line 278:<br/>
memcpy(frame->GetImagePtr(),<br/>
(unsigned char*)m_Cvframe->imageData,<br/>
frameDims[0]*frameDims[1]*frameDims[2]);<br/>
This where, we import the frame data from OpenCV to IGSTK<br/><br/>
2. You can try use CvtColor to convert the color space in OpenCV
(detailed documentation is pasted below)<br/>
or you can try iterate through that memory space and perform the
conversion, which might be less efficient.<br/>
You can find the conversion function here on wiki:<br/>
<a href="http://en.wikipedia.org/wiki/YUV#Converting_between_Y.27UV_and_RGB">http://en.wikipedia.org/wiki/YUV#Converting_between_Y.27UV_and_RGB</a><br/><br/>
Let me know how it goes. The VideoGrabber code is still in the
experimental stage. You are welcome to submit your hacks back into the
repository.<br/><br/>
Patrick<br/><br/><br/>
*************************************************************************************************************************************************************************************<br/>
>From OpenCV manual page:<br/><a href="http://www.seas.upenn.edu/~bensapp/opencvdocs/ref/opencvref_cv.htm">http://www.seas.upenn.edu/~bensapp/opencvdocs/ref/opencvref_cv.htm</a><br/>
*************************************************************************************************************************************************************************************<br/><span class="Apple-style-span" style="border-collapse:separate;color:rgb(0,0,0);font-family:'Times New Roman';font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;word-spacing:0px;font-size:medium;">
</span><h3 style="color:rgb(0,0,240);margin-bottom:0pt;font-family:Helvetica;"><a name="decl_cvCvtColor">CvtColor</a></h3>
<p class="Blurb" style="margin-top:0pt;color:rgb(0,0,0);font-style:italic;font-weight:bold;font-family:Helvetica;font-size:13px;">Converts
image from one color space to another</p>
<pre>void cvCvtColor( const CvArr* src, CvArr* dst, int code );<br/></pre>
<dl><dt style="font-family:monospace;">src</dt>
<dd>The source 8-bit (8u), 16-bit (16u) or single-precision
floating-point (32f) image.</dd>
<dt style="font-family:monospace;">dst</dt>
<dd>The destination image of the same data type as the source one.
The number of channels may be different.</dd>
<dt style="font-family:monospace;">code</dt>
<dd>Color conversion operation that can be specifed using
CV_<src_color_space>2<dst_color_space> constants (see
below).</dd>
</dl><p>The function<span class="Apple-converted-space"> </span><code>cvCvtColor</code><span class="Apple-converted-space"> </span>converts input image from one
color space to another. The function ignores<code>colorModel</code><span class="Apple-converted-space"> </span>and<span class="Apple-converted-space"> </span><code>channelSeq</code><span class="Apple-converted-space"> </span>fields of<span class="Apple-converted-space"> </span><code>IplImage</code><span class="Apple-converted-space"> </span>header, so the source image
color space should be specified correctly (including order of the
channels in case of RGB space, e.g. BGR means 24-bit format with B<sub>0</sub><span class="Apple-converted-space"> </span>G<sub>0</sub><span class="Apple-converted-space"> </span>R<sub>0</sub><span class="Apple-converted-space"> </span>B<sub>1</sub><span class="Apple-converted-space"> </span>G<sub>1</sub><span class="Apple-converted-space"> </span>R<sub>1</sub><span class="Apple-converted-space"> </span>... layout, whereas RGB means
24-bit format with R<sub>0</sub><span class="Apple-converted-space"> </span>G<sub>0</sub><span class="Apple-converted-space"> </span>B<sub>0</sub><span class="Apple-converted-space"> </span>R<sub>1</sub><span class="Apple-converted-space"> </span>G<sub>1</sub><span class="Apple-converted-space"> </span>B<sub>1</sub><span class="Apple-converted-space"> </span>... layout).</p>
<p>The conventional range for R,G,B channel values is:</p>
<ul><li>0..255 for 8-bit images</li>
<li>0..65535 for 16-bit images and</li>
<li>0..1 for floating-point images.</li>
</ul>
Of course, in case of linear transformations the range can be
arbitrary, but in order to get correct results in case of non-linear
transformations, the input image should be scaled if necessary.
<p>The function can do the following transformations:</p>
<ul><li>Transformations within RGB space like adding/removing alpha
channel, reversing the channel order, conversion to/from 16-bit RGB
color (R5:G6:B5 or R5:G5:B5) color, as well as conversion to/from
grayscale using:
<pre>RGB[A]->Gray: Y<-0.299*R + 0.587*G + 0.114*B<br/>Gray->RGB[A]: R<-Y G<-Y B<-Y A<-0<br/> </pre>
</li>
<li>RGB<=>CIE XYZ.Rec 709 with D65 white point (<code>CV_BGR2XYZ,
CV_RGB2XYZ, CV_XYZ2BGR, CV_XYZ2RGB</code>):
<pre>|X| |0.412453 0.357580 0.180423| |R|<br/>|Y| <- |0.212671 0.715160 0.072169|*|G|<br/>|Z| |0.019334 0.119193 0.950227| |B|<br/><br/>|R| | 3.240479 -1.53715 -0.498535| |X|<br/>|G| <- |-0.969256 1.875991 0.041556|*|Y|<br/>|B| | 0.055648 -0.204043 1.057311| |Z|<br/><br/>X, Y and Z cover the whole value range (in case of floating-point images Z may exceed 1).<br/> </pre>
</li>
<li>RGB<=>YCrCb JPEG (a.k.a. YCC) (<code>CV_BGR2YCrCb,
CV_RGB2YCrCb, CV_YCrCb2BGR, CV_YCrCb2RGB</code>)
<pre>Y <- 0.299*R + 0.587*G + 0.114*B<br/>Cr <- (R-Y)*0.713 + delta<br/>Cb <- (B-Y)*0.564 + delta<br/><br/>R <- Y + 1.403*(Cr - delta)<br/>G <- Y - 0.344*(Cr - delta) - 0.714*(Cb - delta)<br/>B <- Y + 1.773*(Cb - delta),<br/><br/> { 128 for 8-bit images,<br/>where delta = { 32768 for 16-bit images<br/> { 0.5 for floating-point images<br/><br/>Y, Cr and Cb cover the whole value range.<br/> </pre>
</li>
<li>RGB<=>HSV (<code>CV_BGR2HSV, CV_RGB2HSV, CV_HSV2BGR,
CV_HSV2RGB</code>)
<pre>// In case of 8-bit and 16-bit images<br/>// R, G and B are converted to floating-point format and scaled to fit 0..1 range<br/><br/>V <- max(R,G,B)<br/>S <- (V-min(R,G,B))/V if V≠0, 0 otherwise<br/><br/> (G - B)*60/S, if V=R<br/>H <- 180+(B - R)*60/S, if V=G<br/> 240+(R - G)*60/S, if V=B<br/><br/>if H<0 then H<-H+360<br/><br/>On output 0≤V≤1, 0≤S≤1, 0≤H≤360.<br/>The values are then converted to the destination data type:<br/> 8-bit images:<br/> V <- V*255, S <- S*255, H <- H/2 (to fit to 0..255)<br/> 16-bit images (currently not supported):<br/> V <- V*65535, S <- S*65535, H <- H<br/> 32-bit images:<br/> H, S, V are left as is<br/> </pre>
</li>
<li>RGB<=>HLS (<code>CV_BGR2HLS, CV_RGB2HLS, CV_HLS2BGR,
CV_HLS2RGB</code>)
<pre>// In case of 8-bit and 16-bit images<br/>// R, G and B are converted to floating-point format and scaled to fit 0..1 range<br/><br/>V<sub>max</sub> <- max(R,G,B)<br/>V<sub>min</sub> <- min(R,G,B)<br/><br/>L <- (V<sub>max</sub> + V<sub>min</sub>)/2<br/><br/>S <- (V<sub>max</sub> - V<sub>min</sub>)/(V<sub>max</sub> + V<sub>min</sub>) if L < 0.5<br/> (V<sub>max</sub> - V<sub>min</sub>)/(2 - (V<sub>max</sub> + V<sub>min</sub>)) if L ≥ 0.5<br/><br/> (G - B)*60/S, if V<sub>max</sub>=R<br/>H <- 180+(B - R)*60/S, if V<sub>max</sub>=G<br/> 240+(R - G)*60/S, if V<sub>max</sub>=B<br/><br/>if H<0 then H<-H+360<br/><br/>On output 0≤L≤1, 0≤S≤1, 0≤H≤360.<br/>The values are then converted to the destination data type:<br/> 8-bit images:<br/> L <- L*255, S <- S*255, H <- H/2<br/> 16-bit images (currently not supported):<br/> L <- L*65535, S <- S*65535, H <- H<br/> 32-bit images:<br/> H, L, S are left as is<br/> </pre>
</li>
<li>RGB<=>CIE L*a*b* (<code>CV_BGR2Lab, CV_RGB2Lab, CV_Lab2BGR,
CV_Lab2RGB</code>)
<pre>// In case of 8-bit and 16-bit images<br/>// R, G and B are converted to floating-point format and scaled to fit 0..1 range<br/><br/>// convert R,G,B to CIE XYZ<br/>|X| |0.412453 0.357580 0.180423| |R|<br/>|Y| <- |0.212671 0.715160 0.072169|*|G|<br/>|Z| |0.019334 0.119193 0.950227| |B|<br/><br/>X <- X/Xn, where Xn = 0.950456<br/>Z <- Z/Zn, where Zn = 1.088754<br/><br/>L <- 116*Y<sup>1/3</sup> for Y>0.008856<br/>L <- 903.3*Y for Y<=0.008856<br/><br/>a <- 500*(f(X)-f(Y)) + delta<br/>b <- 200*(f(Y)-f(Z)) + delta<br/>where f(t)=t<sup>1/3</sup> for t>0.008856<br/> f(t)=7.787*t+16/116 for t<=0.008856<br/><br/><br/>where delta = 128 for 8-bit images,<br/> 0 for floating-point images<br/><br/>On output 0≤L≤100, -127≤a≤127, -127≤b≤127<br/>The values are then converted to the destination data type:<br/> 8-bit images:<br/> L <- L*255/100, a <- a + 128, b <- b + 128<br/> 16-bit images are currently not supported<br/> 32-bit images:<br/> L, a, b are left as is<br/> </pre>
</li>
<li>RGB<=>CIE L*u*v* (<code>CV_BGR2Luv, CV_RGB2Luv, CV_Luv2BGR,
CV_Luv2RGB</code>)
<pre>// In case of 8-bit and 16-bit images<br/>// R, G and B are converted to floating-point format and scaled to fit 0..1 range<br/><br/>// convert R,G,B to CIE XYZ<br/>|X| |0.412453 0.357580 0.180423| |R|<br/>|Y| <- |0.212671 0.715160 0.072169|*|G|<br/>|Z| |0.019334 0.119193 0.950227| |B|<br/><br/>L <- 116*Y<sup>1/3</sup>-16 for Y>0.008856<br/>L <- 903.3*Y for Y<=0.008856<br/><br/>u' <- 4*X/(X + 15*Y + 3*Z)<br/>v' <- 9*Y/(X + 15*Y + 3*Z)<br/><br/>u <- 13*L*(u' - u<sub>n</sub>), where u<sub>n</sub>=0.19793943<br/>v <- 13*L*(v' - v<sub>n</sub>), where v<sub>n</sub>=0.46831096<br/><br/>On output 0≤L≤100, -134≤u≤220, -140≤v≤122<br/>The values are then converted to the destination data type:<br/> 8-bit images:<br/> L <- L*255/100, u <- (u + 134)*255/354, v <- (v + 140)*255/256<br/> 16-bit images are currently not supported<br/> 32-bit images:</pre>
</li>
<li>
<pre> L, u, v are left as is<br/> </pre>
The above formulae for converting RGB to/from various color spaces have
been taken from multiple sources on Web, primarily from<span class="Apple-converted-space"> </span><a href="#paper_ford98">Color
Space Conversions (<b>[Ford98]</b>)</a><span class="Apple-converted-space"> </span>document at Charles Poynton site.</li>
<li>Bayer=>RGB (<code>CV_BayerBG2BGR, CV_BayerGB2BGR,
CV_BayerRG2BGR, CV_BayerGR2BGR,<br/>
CV_BayerBG2RGB, CV_BayerGB2RGB, CV_BayerRG2RGB, CV_BayerGR2RGB</code>)
<p>Bayer pattern is widely used in CCD and CMOS cameras. It allows
to get color picture out of a single plane where R,G and B pixels
(sensors of a particular component) are interleaved like this:</p>
<table border="0" width="400"><tr><td>
<p align="center"><font color="#ff0000" size="5">R</font></p>
</td>
<td>
<p align="center"><font color="#008000" size="5">G</font></p>
</td>
<td>
<p align="center"><font color="#ff0000" size="5">R</font></p>
</td>
<td>
<p align="center"><font color="#008000" size="5">G</font></p>
</td>
<td>
<p align="center"><font color="#ff0000" size="5">R</font></p>
</td>
</tr><tr><td>
<p align="center"><font color="#008000" size="5">G</font></p>
</td>
<td>
<p align="center"><font color="#0000ff" size="5">B</font></p>
</td>
<td>
<p align="center"><font color="#008000" size="5">G</font></p>
</td>
<td>
<p align="center"><font color="#0000ff" size="5">B</font></p>
</td>
<td>
<p align="center"><font color="#008000" size="5">G</font></p>
</td>
</tr><tr><td>
<p align="center"><font color="#ff0000" size="5">R</font></p>
</td>
<td>
<p align="center"><font color="#008000" size="5">G</font></p>
</td>
<td>
<p align="center"><font color="#ff0000" size="5">R</font></p>
</td>
<td>
<p align="center"><font color="#008000" size="5">G</font></p>
</td>
<td>
<p align="center"><font color="#ff0000" size="5">R</font></p>
</td>
</tr><tr><td>
<p align="center"><font color="#008000" size="5">G</font></p>
</td>
<td>
<p align="center"><font color="#0000ff" size="5">B</font></p>
</td>
<td>
<p align="center"><font color="#008000" size="5">G</font></p>
</td>
<td>
<p align="center"><font color="#0000ff" size="5">B</font></p>
</td>
<td>
<p align="center"><font color="#008000" size="5">G</font></p>
</td>
</tr><tr><td>
<p align="center"><font color="#ff0000" size="5">R</font></p>
</td>
<td>
<p align="center"><font color="#008000" size="5">G</font></p>
</td>
<td>
<p align="center"><font color="#ff0000" size="5">R</font></p>
</td>
<td>
<p align="center"><font color="#008000" size="5">G</font></p>
</td>
<td>
<p align="center"><font color="#ff0000" size="5">R</font></p>
</td>
</tr><tr><td>
<p align="center"><font color="#008000" size="5">G</font></p>
</td>
<td>
<p align="center"><font color="#0000ff" size="5">B</font></p>
</td>
<td>
<p align="center"><font color="#008000" size="5">G</font></p>
</td>
<td>
<p align="center"><font color="#0000ff" size="5">B</font></p>
</td>
<td>
<p align="center"><font color="#008000" size="5">G</font></p>
</td>
</tr></table><p>The output RGB components of a pixel are interpolated from 1, 2
or 4 neighbors of the pixel having the same color. There are several
modifications of the above pattern that can be achieved by shifting the
pattern one pixel left and/or one pixel up. The two letters C<sub>1</sub><span class="Apple-converted-space"> </span>and C<sub>2</sub><span class="Apple-converted-space"> </span>in the conversion constants
CV_BayerC<sub>1</sub>C<sub>2</sub>2{BGR|RGB} indicate the particular
pattern type - these are components from the second row, second and
third columns, respectively. For example, the above pattern has very
popular "BG" type.</p>
</li>
</ul><br/><br/>
On 5/30/2010 10:47 AM, KubaP wrote:
<blockquote>
<pre>Hi,<br/>I would like to capture video from the camera in real time. <br/>I work with an example VideoFrameGrabberAndViewerWebcamWin (sandbox, WIndows),<br/>but I have a problem with the format of pixels:<br/>Program works with RGB , but the device provides e.g. YUV. How convert format YUV to RGB?<br/><br/>Thanks in advance for any help.<br/><br/>Kuba.P<br/><br/><br/>----------------------------------------------------------------------<br/>Kup wlasne mieszkanie za 72 tys. zl.<br/>Sprawdz najlepsze oferty >>> <a class="moz-txt-link-freetext" href="http://linkint.pl/f26c8">http://linkint.pl/f26c8</a><br/><br/>_______________________________________________<br/>Powered by <a class="moz-txt-link-abbreviated" href="http://www.kitware.com">www.kitware.com</a><br/><br/>Visit other Kitware open-source projects at <a class="moz-txt-link-freetext" href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><br/><br/>Follow this link to subscribe/unsubscribe:<br/><a class="moz-txt-link-freetext" href="http://public.kitware.com/cgi-bin/mailman/listinfo/igstk-users">http://public.kitware.com/cgi-bin/mailman/listinfo/igstk-users</a><br/><br/><br/> </pre>
</blockquote></blockquote>
<TABLE cellPadding="3" bgColor="#ffffff"><TBODY><TR><TD style="font: 12px Courier New, Courier, monotype.com; padding: 3px; background: #ffffff; color: #000000">----------------------------------------------------------------------
<BR>
Najlepsza wyszukiwarka tanich lotow!
<BR>
Sprawdz >>> <A href="http://linkint.pl/f2726">http://linkint.pl/f2726</a></TD></TR></TBODY></TABLE>