OpenCV 4.7和ArUco模块有问题

hc8w905p  于 2023-06-06  发布在  其他
关注(0)|答案(1)|浏览(228)

我在将旧的ArUco检测代码移植到新版本的OpenCV时遇到问题。尽管我使用了ArUco模块提供的方法,但我还是得到了ArUco模块的**getPredefinedDictionary()**函数的不合适的用户定义错误。因此,当我试图加载cv::ptr与预定义的字典像这样:

cv::Ptr<cv::aruco::Dictionary> arucoDictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);

我总是得到以下错误:

这些是我在头文件中使用的OpenCV包含:

#include <opencv2/imgproc.hpp>
#include <opencv2/features2d.hpp>
#include <opencv2/calib3d.hpp>
#include <opencv2/aruco.hpp>
#include <opencv2/objdetect.hpp>

从代码中删除cv::ptr解决了这个问题,但当我想在cv::aruco::detectMarkers中使用这个字典时,也会在代码中引入新的问题。我想知道是否有可能像OpenCV的旧版本一样使用cv指针。

  • 更多的上下文:* 我使用OpenCV 4.7Contrib_4x,因为这是我可以成功编译和构建Visual Studio 2022forARM64平台的唯一版本。我也设置了包含目录、链接器和附加库。最初的应用程序是为x86平台和OpenCV 3构建的,现在我需要为ARM64构建它,所以我从头开始完全重新创建了解决方案和项目。
vmdwslir

vmdwslir1#

在阅读了@Christoph拉克维茨的建议后,我修改了代码,所以现在看起来像这样:

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);

在此之后,我得到了新的错误,所以我用-DBUILD_opencv_world=ON选项重新编译了ARM 64的OpenCV 4.7,然后重新包含并重新链接了库,问题得到了解决。似乎是链接器找不到对应的库导致的错误。

相关问题