0


I have set up ArUco library and now want to write a small code to test if it is working correctly. The code is as below:

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


This code builds with zero error, but when I run it, it gives me error.
Error is:
enter image description here
This is what I get when I hit break.
enter image description here
I use Windows 8.1, Microsoft visual studio 2013, opencv 3.0 and ArUco 1.3.0
Any help would be helpful. Thank you very much for help.

SNS
  • 195
  • 1
  • 3
  • 13
  • 1
    This may sound obvious, but why didn't you just hit *"Break"*, and have a look at the callstack yourself? – IInspectable Feb 05 '16 at 12:07
  • @IInspectable I do not understand what the error is, that is the reason I posted it here. I have edited the question and added what I get while break is clicked. I hope you can point out where my mistake is. Thank you. – SNS Feb 05 '16 at 13:37
  • You need to get debug symbols for opencv, and whatever else is towards the top of the callstack. See [Debugging with Symbols](https://msdn.microsoft.com/en-us/library/windows/desktop/ee416588.aspx) for instructions on setting up your development environment to use debug symbols. – IInspectable Feb 05 '16 at 13:42
  • Ok thank you @IInspectable . This same code works fine until I added the pattern reading line. It works fine for just openCv. I am guessing the problem is with the ArUco code. – SNS Feb 05 '16 at 14:41

1 Answers1

0

This question is solved. I was making use of wrong marker pattern. we are supposed to use the marker pattern provided by ArUco. You can find generate them here: http://terpconnect.umd.edu/~jwelsh12/enes100/markergen.html
There were mistake in the code too. The correct code is below:

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


I hope this test code helps newbies to ArUco(others like me).

SNS
  • 195
  • 1
  • 3
  • 13