IplImage to Mat returns no data
Hello,
I'm new to OpenCV so sorry if this is a basic question.
I'm converting from the IplImage structure into a Mat matrix however there seem to be a problem because when I try to access an element within the matrix, it return no data. Naturally I have tried debugging it and checking (using visual studios debug tools) to see if the matrix structure contains any data. From what I can see it does not.
Heres my code:
Mat imageMatrix(image);
cout << "Data: " << imageMatrix.at<unsigned char>(0, 0) << endl;
cvWaitKey();
The fact i'm having to use unsigned char is a little worrying as well as the image is binary. It should just be int, should it not?
Can anyone help me at all with this>
Thanks.
imageMatrix.empty()
(but if it is, you must not try to access its pixels)I guess it's just the cout which doesn't work w. uchar as expected, cast it to an int before that, i.e. (int) imageMatrix.at<uchar)(0.0) and you should see a value.
Since a typical RGB image is coded with 1 byte=8 bit for each channel = 24bit / 3byte. There exist images with a wider color range using more bits, see http://en.wikipedia.org/wiki/Color_depth#Deep_color_.2830.2F36.2F48-bit.29 . Also note that OpenCV processes color-images in the BGR order (not RGB).