首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ArUco -未处理异常

ArUco -未处理异常
EN

Stack Overflow用户
提问于 2016-02-05 11:38:40
回答 1查看 508关注 0票数 0

我已经设置了ArUco库,现在我想编写一个小代码来测试它是否正常工作。守则如下:

代码语言:javascript
复制
#include<opencv2/opencv.hpp>
#include<iostream>
#include<aruco.h>
#include<cvdrawingutils.h>

using namespace cv;
using namespace std;
using namespace aruco;

int main()
{
    Mat image;
    //Read image and display it
    image = imread("E:/../Capture.PNG", 1);
    if (image.empty()) //check whether the image is loaded or not
    {
        cout << "Error : Image cannot be loaded..!!" << endl;
        //system("pause"); //wait for a key press
        return -1;
    }
    namedWindow("Image", CV_WINDOW_AUTOSIZE);
    imshow("Image", image);
    waitKey(1000);

    //Marker detection
    MarkerDetector MDetector;
    vector<Marker> Markers;

   //I am not sure if we need to read the pattern of the marker. So I read it.
    Markers = imread("E:/.../pattern.PNG", 1);
    MDetector.detect(image, Markers);

    //draw infor and its boundaries
    for (int i = 0; i < Markers.size(); i++)
    {
        Markers[i].draw(image, Scalar(0, 0, 255), 2);
    }
    imshow("ouput", image);
    waitKey(0);
} 

这段代码构建为零错误,但当我运行它时,它会给出错误。

错误是:

这就是我在休息的时候得到的。

我使用Windows8.1、2013、OpenCV3.0和ArUco 1.3.0

任何帮助都会有帮助。非常感谢你的帮助。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-02-05 18:42:38

这个问题解决了。我用的是错误的标记图案。我们应该使用ArUco提供的标记模式。您可以在这里找到生成它们:http://terpconnect.umd.edu/~jwelsh12/enes100/markergen.html

代码中也有错误。正确的代码如下:

代码语言:javascript
复制
#include<opencv2/opencv.hpp>
#include<iostream>
#include<aruco.h>
#include<cvdrawingutils.h>

using namespace cv;
using namespace std;
using namespace aruco;

int main()
{
    Mat image;
    //Read image and display it
    image = imread("E:/Studies/Master Thesis/Markers/arucoTest.PNG", 1);
    if (image.empty()) //check whether the image is loaded or not
    {
        cout << "Error : Image cannot be loaded..!!" << endl;
        //system("pause"); //wait for a key press
        return -1;
    }
    namedWindow("Image", CV_WINDOW_AUTOSIZE);
    imshow("Image", image);
    waitKey(1000);

    //Marker detection
    MarkerDetector MDetector;
    vector<Marker> Markers;
    MDetector.detect(image, Markers);

    //draw information and its boundaries
    for (unsigned int i = 0; i<Markers.size(); i++) {
        cout << Markers[i] << endl;
        Markers[i].draw(image, Scalar(0, 0, 255), 2);
    }
    imshow("ouput", image);
    waitKey(0);
}

我希望这个测试代码能帮助新手使用ArUco(像我这样的其他人)。

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

https://stackoverflow.com/questions/35223267

复制
相关文章

相似问题

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