libcvd-members
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [libcvd-members] Copying images from a Windows DirectShow buffer int


From: Gerhard Reitmayr
Subject: Re: [libcvd-members] Copying images from a Windows DirectShow buffer into a LibCVD Image object
Date: Wed, 25 Feb 2009 11:05:50 +0000
User-agent: Thunderbird 2.0.0.16 (X11/20080720)

Hi John,

I am not sure about the details of using DirectShow, but I know that
Windows uses BGR format (instead of RGB) quite a lot. I guess that you
are simply getting a buffer in BGR format. Therefore, you need your code
below to convert it then into an RGB format and stores the result in the
image data.

LibCVD does not support BGR at the moment. It's possible to add this
(look at rgb.h) but requires also some conversion functions similar to
the one you wrote.

fill and copy do not deal with conversion between image formats but
simply copy the data as it is laid out in memory. therefore they cannot
do the necessary byte swizzeling to get from BGR to RGB.

your current code is probably the best solution without adding full
support for BGR to libCVD. in the end, if you want the image from the
webcam in RGB format, this conversion has to happen anyway, whether in
libcvd or in your code.

cheers,
  Gerhard

John Ryding wrote:
> Hello,
> 
> I am currently using LibCVD for a personal project on using Windows.
> 
> The problem that I am getting is that whenever I use any of the native
> methods for copying an image buffer from the Windows (using DirectShow),
> the image is output as larger than my program's window and looks as if 2
> images are placed over each other.
> 
> Playing around with my code, I come to find that this problem does not
> occur when I manually copy the data from my image buffer (an unsigned
> char*) into the objects like so:
> 
> 
> 
> 
> 
> 
> unsigned char* pImage = m_buffer; //The image from my webcam in windows
> unsigned char *rgbDest = (unsigned char *)image.data();
> 
> rgbDest += 2; //start by advancing to first Blue byte of dest
>         for(int i=0; i<CAPTURE_SIZE_X*CAPTURE_SIZE_Y; ++i) {
>             *rgbDest = *pImage;
>            
>             ++pImage;
>             --rgbDest; // backup to Green
>            
>             *rgbDest = *pImage;
>            
>             ++pImage;
>             --rgbDest; // backup to Red
>            
>             *rgbDest = *pImage;
>            
>             ++pImage;
>             rgbDest += 5; // advance to Blue of next pixel
> }
> 
> 
> 
> 
> Looking at this code, it is obvious that I must first start at the Blue
> pixel of my image and copy the image from the buffer as if it was a BGR
> image. 
> 
> I am just wondering if this is a bug in the libCVD code as I am unable
> to use any of the libCVD copy() or fill() methods, which from looking at
> the documentation, use MUCH faster methods of copying the images from
> buffer to object.
> 
> If this is not a bug, then why must I copy the image like a BGR image?
> 
> lastly, is there any faster way to copy the image from my USB webcam's
> buffer into a CVD::Image object?
> 
> Thank you.
> 
> -John Ryding
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> libcvd-members mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/libcvd-members


-- 
Gerhard Reitmayr
MIL, Engineering Department, Cambridge University
http://www.eng.cam.ac.uk/~gr281/
tel: +44 1223 765150




reply via email to

[Prev in Thread] Current Thread [Next in Thread]