0

It seemed that I am the only one who got this problem with Opencv 2.4.3.

http://docs.opencv.org/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html The following codes are published on that official website:

Size patternsize(8,6); //interior number of corners Mat gray = ....; //source image vector<Point2f> corners; //this will be filled by the detected corners //CALIB_CB_FAST_CHECK saves a lot of time on images //that do not contain any chessboard corners bool patternfound = findChessboardCorners(gray, patternsize, corners, CALIB_CB_ADAPTIVE_THRESH + CALIB_CB_NORMALIZE_IMAGE + CALIB_CB_FAST_CHECK); if(patternfound) cornerSubPix(gray, corners, Size(11, 11), Size(-1, -1), TermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 30, 0.1)); drawChessboardCorners(img, patternsize, Mat(corners), patternfound); 

gray is Mat, and it is directly used as void*

But on my visual studio 2010, it kept saying Error

Error 1 error C2664: 'cvFindChessboardCorners' : cannot convert parameter 1 from 'cv::Mat' to 'const void *' 22 

And, I have tried the following, but still the same error.

static_cast<void*>(gray) Error 1 error C2440: 'static_cast' : cannot convert from 'cv::Mat' to 'void *' 21 (void*)gray Error 1 error C2440: 'type cast' : cannot convert from 'cv::Mat' to 'void *' 21 

I m using OpenCV 2.4.3. Please help.

1 Answer 1

1

The example code in the OpenCV documentation uses the C++ interface (findChessboardCorners). You're calling the C interface (cvFindChessboardCorners). If it's possible for you to use the C++ interface, I'd highly recommend it. I think you should be able to use the C++ interface, because if your code were compiling as C, I don't think it would complain about a cast to a void pointer (although maybe I'm mistaken there!).

Note: Depending upon namespaces, you may have to call the function like this:

cv::findChessboardCorners

You should be able to directly pass your gray object without any casting.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks, that helps. But why the C function does not accept any cast?
It may have compiled using using reinterpret_cast<void*>(gray). But the trouble is that even still, that's not the behaviour you want. The C interface is not meant to work with objects generated by OpenCV's C++ interface. cv::Mat is the C++ way of dealing with images -- it's part of the C++ interface. The C way of dealing with images was the IplImage* type. That would have casted directly to void* with no explicit cast required, but then you'd be using OpenCV's C interface. Stick with C++!
Thanks, I think I should look up more about casting. If I have got 15 reputation, I would thumb up. :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.