Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

IplImage data access problem

Hello, I am newbee to OpenCV so if I am making silly mistakes and assumptions, please ignore me!

I am trying access the data contents of IplImage structure. To clarify, I am trying to access the data contents that are pointed by IplImage.imageData. I am trying to access it using widthStep and height like this:

uchar* ptr;
for(int i=0; i<myIplImage.height; i++) {
    ptr = (uchar*)(myIplImage.imageData + (i*myIplImage.widthStep));
   for(int j=0; j < myIplImage.width; j++) {
        std::cout << ptr[j];
   }
}

However, i am constantly getting exception and cannot even catch it to print the actual problem message so that I can fix it. Is it the correct way to access IplImage data? If not, what is it that I am doing wrong and where can I find more information about this?