4

I'm new on OpenCV e VS2010. I work on windows7 x64. I want to detect a marker, so I downloaded the ARuco Library from this site: and I wrote this simple code:

#include <iostream>
#include <stdio.h>
#include "C:/Users/Cristina/Desktop/OpenCV/dep/aruco/src/aruco.h"
#include "C:/Users/Cristina/Desktop/OpenCV/dep/aruco/src/cvdrawingutils.h"
#include "C:/Users/Cristina/Desktop/OpenCV/dep/aruco/src/cameraparameters.hpp"
#include "C:/Users/Cristina/Desktop/OpenCV/opencv/include/opencv/cv.h"
#include "C:/Users/Cristina/Desktop/OpenCV/opencv/include/opencv/highgui.h"
#include "C:/Users/Cristina/Desktop/OpenCV/opencv/modules/imgproc/include/opencv2/imgproc/imgproc.hpp"
#include "C:/Users/Cristina/Desktop/OpenCV/opencv/modules/highgui/include/opencv2/highgui/highgui.hpp"
#include "C:/Users/Cristina/Desktop/OpenCV/opencv/modules/core/include/opencv2/core/core.hpp"

using namespace cv;
using namespace aruco;

int main() {

    aruco::CameraParameters CamParam;
    aruco::MarkerDetector MDetector;
    vector <Marker> Markers;
    cv::Mat img;

    img = imread("prova marker", 0);

    cv::namedWindow("originale", 1);
    cv::namedWindow("risultato", 1);

    cv::Mat risultato;

    img.copyTo(risultato);

    MDetector.detect(img, Markers, CamParam, -1);

    for (int i=0; i< Markers.size(); i++) {

        Markers[i].draw(risultato, Scalar(0,0, 255));
    }

    cv::imshow("originale", img);
    cv::imshow("risultato", risultato);
    waitKey(0);

return 0;
}

When I compile this, I get this errors:

1>main.obj : error LNK2019: riferimento al simbolo esterno "public: __thiscall aruco::MarkerDetector::~MarkerDetector(void)" (??1MarkerDetector@aruco@@QAE@XZ) non risolto nella funzione _main
1>main.obj : error LNK2019: riferimento al simbolo esterno "public: void __thiscall aruco::Marker::draw(class cv::Mat &,class cv::Scalar_<double>,int,bool)const " (?draw@Marker@aruco@@QBEXAAVMat@cv@@V?$Scalar_@N@4@H_N@Z) non risolto nella funzione _main
1>main.obj : error LNK2019: riferimento al simbolo esterno "public: void __thiscall aruco::MarkerDetector::detect(class cv::Mat const &,class std::vector<class aruco::Marker,class std::allocator<class aruco::Marker> > &,class aruco::CameraParameters,float,bool)" (?detect@MarkerDetector@aruco@@QAEXABVMat@cv@@AAV?$vector@VMarker@aruco@@V?$allocator@VMarker@aruco@@@std@@@std@@VCameraParameters@2@M_N@Z) non risolto nella funzione _main
1>main.obj : error LNK2019: riferimento al simbolo esterno "public: __thiscall aruco::CameraParameters::CameraParameters(class aruco::CameraParameters const &)" (??0CameraParameters@aruco@@QAE@ABV01@@Z) non risolto nella funzione _main
1>main.obj : error LNK2019: riferimento al simbolo esterno "public: __thiscall aruco::MarkerDetector::MarkerDetector(void)" (??0MarkerDetector@aruco@@QAE@XZ) non risolto nella funzione _main
1>main.obj : error LNK2019: riferimento al simbolo esterno "public: __thiscall aruco::CameraParameters::CameraParameters(void)" (??0CameraParameters@aruco@@QAE@XZ) non risolto nella funzione _main
1>C:\Users\Cristina\Desktop\OpenCV\Progetti\MIEI PROGETTI\aruco marker\Debug\aruco marker.exe : fatal error LNK1120: 6 esterni non risolti
========== Compilazione: 0 completate, 1 non riuscite, 0 aggiornate, 0 ignorate ==========

Can someone help me? Thanks!

karlphillip
  • 92,053
  • 36
  • 243
  • 426
Cristina1986
  • 505
  • 1
  • 8
  • 21
  • You need to go compile aruco on Visual Studio to build the libraries. Then you need to copy them to the proper libraries folder inside Visual Studio and edit the properties of your project and add the name of the libraries as a dependency of the linker. – karlphillip Dec 06 '12 at 20:58
  • thanks for the quick reply,but still my concern is about how to compile aruco inside visual studio could you please enlight me again? – Cristina1986 Dec 06 '12 at 21:48
  • SOLVED! BY suggesting Karlphillip, I created a static library (.lib) following this guide: http://msdn.microsoft.com/it-it/library/ms235627(v=vs.90).aspx and including all files (.h and .cpp)of ARuco library. Then I compiled the library .lib and added it as a dependency of the linker. – Cristina1986 Dec 06 '12 at 22:47
  • I'll make my answer official so others can benefit from that. – karlphillip Dec 06 '12 at 23:45

1 Answers1

3

You need to go compile Aruco on Visual Studio to build the libraries.

After that, copy the resulting lib files to the proper libraries folder of Visual Studio.

Finally, edit the properties of your project and add the name of the libraries as a dependency of the linker.

karlphillip
  • 92,053
  • 36
  • 243
  • 426