你好我使用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;
}
我知道有太多的包括和代码需要一些工作,但我只需要它来编译和我不知道那里发生了什么。功能是否改变了?
能够 你在编译时会收到异常吗? –
@TahTatsumoto它在问题的顶部。从错误信息看来,必须将字典包装在一个'cv :: Ptr'中,除非他们参与了一些buffoonery,[这与我看到的不一样最近的文档](http://docs.opencv.org/3.1.0/d9/d6a/group__aruco.html#ga306791ee1aab1513bc2c2b40d774f370&gsc.tab=0)。我也没有看到3.0文档中的aruco,所以它可能会在早期开发中发生颠簸。 –
user4581301
嘿,我包括'cv :: Ptr dictionaryPtr(&字典)'和参数相同,并在函数中使用。现在它可以工作,但是我仍然遇到麻烦,因为当程序结束时,我得到一个'numpad_chunk():无效指针......'。我知道我正在使用Ptr错误,但我不知道发生了什么。 –
Martinator