PDA

View Full Version : Use data from MemBuffer::getPtr()



Unregistered
July 8, 2004, 15:25:37
I´m use IC Controll 1.4 SP 1 (trial version). When i am grabb frame i read data from buffer :

buffer is MemBuffer`s pointer;

const SIZE& size = this->buffer->getSize();

this->width = size.cx;
this->height = size.cy;

int length = this->width * this->height;
this->data = new BYTE[length];

BYTE * rgbData = buffer->getPtr();
BYTE * data = this->data;
BYTE r,g,b;

for(int index=0; index<length; index++) {
r = (*rgbData);
rgbData++;
g = (*rgbData);
rgbData++;
b = (*rgbData);
rgbData++;

(*data) = GrayScaleImage::rgbToGray(r,g,b);

histogram.registerValue((*data));
data++;
}

Problem: in rows is pixels shifted(circular) . Where are problem?

Stefan Geissler
July 9, 2004, 08:30:59
Hello,

You must be sure, that the sinktype has been set to RGB24.

The colors are in BGR order, therefore you must change your loop as follows:


for(int index=0; index<length; index++)
{
b = (*rgbData);
rgbData++;
g = (*rgbData);
rgbData++;
r = (*rgbData);
rgbData++;

(*data) = GrayScaleImage::rgbToGray(r,g,b);

histogram.registerValue((*data));
data++;
}


I was not able to found another problem in your code, it seems to be correct. ( I would rename this->data to this->m_data to avoid confusion using the data varaiable.)
What do you mean with circlar shifted? Are all pixels moved to the right? Or is each image line shifted one pixel to the right, so you get a diagonal shift on the image?

hurdes
July 9, 2004, 09:37:50
Yes sink type i`m set to RGB24. when i`m save image from memBuffer.save(filename). its OK, but when i use memBuffer.getPtr() data in this algorithm image is bad. Can I send saved images to your e-mail? My e-mai is j.hurdes@volny.cz. Thanks.

Stefan Geissler
July 9, 2004, 09:51:41
Hello,

please send the images to support@imagincontrol.com