gpt4 book ai didi

opencv - Aruco 教程代码无法编译

转载 作者:太空宇宙 更新时间:2023-11-03 22:52:30 24 4
gpt4 key购买 nike

您好,我在使用 aruco 时遇到错误。我只是想从教程中获取一个例子。我按照教程做了一切,但我得到:

    /home/pi/Programs/markerDetection/markerDetection.cpp: In function ‘int main(int, char**)’:
/home/pi/Programs/markerDetection/markerDetection.cpp:26:104: error: invalid initialization of reference of type ‘cv::Ptr<cv::aruco::Dictionary>&’ from expression of type ‘cv::aruco::Dictionary’
aruco::detectMarkers(inputImage, dictionary, markerCorners, markerIds, parameters, rejectedCandidates);
^
In file included from /home/pi/Programs/markerDetection/markerDetection.cpp:6:0:
/home/pi/opencv/include/opencv2/aruco.hpp:176:19: note: in passing argument 2 of ‘void cv::aruco::detectMarkers(cv::InputArray, cv::Ptr<cv::aruco::Dictionary>&, cv::OutputArrayOfArrays, cv::OutputArray, const cv::Ptr<cv::aruco::DetectorParameters>&, cv::OutputArrayOfArrays)’
CV_EXPORTS_W void detectMarkers(InputArray image, Ptr<Dictionary> &dictionary, OutputArrayOfArrays corners,
^
CMakeFiles/marker.dir/build.make:54: recipe for target 'CMakeFiles/marker.dir/markerDetection.cpp.o' failed
make[2]: *** [CMakeFiles/marker.dir/markerDetection.cpp.o] Error 1
CMakeFiles/Makefile2:60: recipe for target 'CMakeFiles/marker.dir/all' failed
make[1]: *** [CMakeFiles/marker.dir/all] Error 2
Makefile:76: recipe for target 'all' failed
make: *** [all] Error 2

我的代码是:

#include "opencv2/opencv.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/videoio/videoio.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/aruco.hpp"
#include <vector>

using namespace cv;
using namespace std;

int main (int argc, char** argv)
{
VideoCapture cap;

if(!cap.open(0)){
return 0;
}
for(;;){
Mat inputImage;
cap >> inputImage;
vector< int > markerIds;
vector< vector<Point2f> > markerCorners, rejectedCandidates;
aruco::DetectorParameters parameters;
aruco::Dictionary dictionary = aruco::getPredefinedDictionary(aruco::DICT_6X6_250);
aruco::detectMarkers(inputImage, dictionary, markerCorners, markerIds, parameters, rejectedCandidates);
Mat outputImage;
aruco::drawDetectedMarkers(outputImage, markerCorners, markerIds);
if(inputImage.empty()) break;
imshow("Webcam", outputImage);
if(waitKey(1) >= 0) break;
}

return 0;
}

我知道包含的内容太多,代码需要一些工作,但我只需要编译它,我不知道那里发生了什么。功能有变化吗?

最佳答案

以下代码适用于我:

字典声明:

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

作为函数getPredefinedDictionary返回 Ptr<Dictionary>( http://docs.opencv.org/trunk/d9/d6a/group__aruco.html )

检测标记:

cv::aruco::detectMarkers(gray, dictionary, marker_corners, marker_ids);

关于opencv - Aruco 教程代码无法编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36391657/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com