首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Aruco教程代码无法编译

Aruco教程代码无法编译
EN

Stack Overflow用户
提问于 2016-04-04 05:51:20
回答 3查看 5.4K关注 0票数 1

你好,我得到一个错误,当使用aruco。我只是想从教程中获得一个有效的例子。我根据教程做了所有的事情,但是我得到了:

代码语言:javascript
复制
    /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

我的代码是:

代码语言:javascript
复制
#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;
}

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

EN

回答 3

Stack Overflow用户

发布于 2017-02-08 19:25:16

以下代码适用于我:

字典声明:

代码语言:javascript
复制
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)

要检测标记,请执行以下操作:

代码语言:javascript
复制
cv::aruco::detectMarkers(gray, dictionary, marker_corners, marker_ids);
票数 1
EN

Stack Overflow用户

发布于 2016-05-10 02:24:59

我和你有同样的问题。下面是这个技巧的用法:

而不是:

代码语言:javascript
复制
aruco::DetectorParameters parameters;
aruco::Dictionary dictionary=aruco::getPredefinedDictionary(aruco::DICT_6X6_250);

使用:

代码语言:javascript
复制
cv::Ptr<aruco::DetectorParameters> parameters;
cv::Ptr<aruco::Dictionary> dictionary=aruco::getPredefinedDictionary(aruco::DICT_6X6_250);

我希望它能对你有所帮助。

票数 0
EN

Stack Overflow用户

发布于 2021-03-02 20:13:03

我遗漏了一些包含文件。这些是我现在拥有的:

代码语言:javascript
复制
#include "opencv2/aruco.hpp"
#include <iostream>
#include <stdio.h>
#include <opencv2/highgui.hpp>
#include "opencv2/imgcodecs.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/core.hpp"
#include "opencv2/videoio/videoio.hpp"
#include <vector>

这些库是(这些库包含在Project-> Properties->settings->Linker->Input中):

代码语言:javascript
复制
opencv_core450.lib
opencv_highgui450.lib
opencv_objdetect450.lib
opencv_videoio450.lib
opencv_imgproc450.lib
opencv_imgcodecs450.lib
opencv_aruco450.lib
opencv_core450d.lib
opencv_highgui450d.lib
opencv_objdetect450d.lib
opencv_videoio450d.lib
opencv_imgproc450d.lib
opencv_imgcodecs450d.lib
opencv_aruco450d.lib

据我所知,opencv_aruco450.lib没有正确保存。这是我的问题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36391657

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档