I have problems porting an old ArUco dectection code to work with newer version of OpenCV. I'm getting non-suitable user defined errors for getPredefinedDictionary() function of the ArUco module despite I'm using their provided method. So when ever I try to load the cv::ptr with a predefined dictionary like this:
cv::Ptr<cv::aruco::Dictionary> arucoDictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
I always get the following error:
These are the OpenCV includes I'm using in the header file:
#include <opencv2/imgproc.hpp>
#include <opencv2/features2d.hpp>
#include <opencv2/calib3d.hpp>
#include <opencv2/aruco.hpp>
#include <opencv2/objdetect.hpp>
Removing the cv::ptr from the code solves this particular problem but also introduces new ones later in the code when I want to use this dictionary in cv::aruco::detectMarkers
. I would like to know if it is even possible to use it with cv pointer like it was with the older releases of OpenCV.
A bit more context: I'm using OpenCV 4.7 with Contrib_4x because this was the only version I could successfully compile and build with Visual Studio 2022 for ARM64 platform. I setup the include directories, the linker and the additional libraries too. The original application was built for x86 platforms with OpenCV 3, and now I'm required to build it for ARM64 so I fully recreated the solution and projects from scratch.
I changed the code after reading what @Christoph Rackwitz suggested, so it now looks like this:
std::vector<int> markerIds;
std::vector<std::vector<cv::Point2f>> markerCorners, rejectedCandidates;
cv::aruco::DetectorParameters detectorParams = cv::aruco::DetectorParameters();
cv::aruco::Dictionary dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
cv::aruco::ArucoDetector detector(dictionary, detectorParams);
detector.detectMarkers(inputImage, markerCorners, markerIds, rejectedCandidates);
After this I got new errors, so I recompiled OpenCV 4.7 for ARM64 with -DBUILD_opencv_world=ON
option and then reincluded and relinked the libraries and the issue is fixed. It seems like the errors were caused by the linker could not find the corresponding libraries.