I am trying to get the Aruco AR library working by trying out the simple test in my code.
For some reason I cannot get the call to detect() to work. My code is as follows:
cv::Mat image(480,640,CV_8UC3, mimFrameRGB.data());
MarkerDetector mDetector;
std::vector<Marker> markers;
CameraParameters cParams();
float markerSize = 0.1f;
mDetector.detect(image,markers,cParams,markerSize);
The compiler complains that there is no overloaded function that matches my input parameters. Specifically that parameter 3 should be of type cv::Mat.
Looking at the header file for the MarkerDetector, the following two method calls are found:
void detect(const cv::Mat &input,std::vector<Marker> &detectedMarkers,cv::Mat camMatrix=cv::Mat(),cv::Mat distCoeff=cv::Mat(),float markerSizeMeters=-1) throw (cv::Exception);
void detect(const cv::Mat &input,std::vector<Marker> &detectedMarkers, CameraParameters camParams,float markerSizeMeters=-1) throw (cv::Exception);
I am trying to call the second one, however it chooses the first one and gives me a compile error. What is going wrong? are my input parameters not matching either case?
I think the issue is this line:
This does not declare a variable of type
CameraParameters, but instead is a function prototype for a function calledcParamsthat takes no parameters and returns aCameraParameters. This is an extremely annoying part of the C++ language, since the code is legal but doesn’t do what you want.Because
cParamsis actually a function prototype and not a variable declaration, the C++ overload resolution mechanism is getting confused about the types of the arguments and is failing to correctly select the oveload you’d like. Removing the parentheses on this line and having it just readshould fix this problem.
Hope this helps!