Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using cvGet2D OpenCV function

Tags:

opencv

I'm trying to get information from an image using the function cvGet2D in OpenCV.

I created an array of 10 IplImage pointers:

IplImage *imageArray[10];  

and I'm saving 10 images from my webcam:

imageArray[numPicture] = cvQueryFrame(capture);  

when I call the function:

info = cvGet2D(imageArray[0], 250, 100);  

where info:

CvScalar info;  

I got the error:

OpenCV Error: Bad argument (unrecognized or unsupported array type) in cvPtr2D, file /build/buildd/opencv-2.1.0/src/cxcore/cxarray.cpp, line 1824
terminate called after throwing an instance of 'cv::Exception'
what(): /build/buildd/opencv-2.1.0/src/cxcore/cxarray.cpp:1824: error: (-5) unrecognized or unsupported array type in function cvPtr2D

If I use the function cvLoadImage to initialize an IplImage pointer and then I pass it to the cvGet2D function, the code works properly:

IplImage* imagen = cvLoadImage("test0.jpg");
info = cvGet2D(imagen, 250, 100);  

however, I want to use the information already stored in my array.

Do you know how can I solve it?

like image 210
Eric Bautista Avatar asked Nov 30 '22 04:11

Eric Bautista


1 Answers

Even though its a very late response, but I guess someone might be still searching for the solution with CvGet2D. Here it is.

For CvGet2D, we need to pass the arguments in the order of Y first and then X.

Example:

CvScalar s = cvGet2D(img, Y, X);

Its not mentioned anywhere in the documentation, but you find it only inside core.h/ core_c.h. Try to go to the declaration of CvGet2D(), and above the function prototypes, there are few comments that explain this.

like image 131
Chakradhar Avatar answered Dec 04 '22 04:12

Chakradhar