0

I am trying to use the camera pose from opencv. So I'm following this series of tutorial which leads me to include these :

#include <opencv2/core.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/aruco.hpp>
#include <opencv2/calib3d.hpp>

Everything works fine but the aruco one. First it wasn't in my package of opencv (ver 4.3) so I had to go look for it and put it in my opencv include directory (I added the aruco.hpp as well as the aruco folder containing charuco.hpp and dictionary.hpp). I searched for the opencv_aruco310d.lib file that I added in my opencv lib directory (x64).

I installed opencv using this tutorial

But when I try to run my code, it gives me this error:

Error LNK2019 external symbol unresolved "void __cdecl cv::aruco::drawMarker(struct cv::Ptr const &,int,int,class cv::debug_build_guard::_OutputArray const &,int)" (?drawMarker@aruco@cv@@YAXAEBU?$Ptr@VDictionary@aruco@cv@@@2@HHAEBV_OutputArray@debug_build_guard@2@H@Z) referenced in the function "void __cdecl createArucoMarkers(void)" (?createArucoMarkers@@YAXXZ) ConsoleApplication1

It seems to be related to this line of code:

aruco::drawMarker(markerDictionary, i, 500, outputMarker, 1);

I understand that I have a problem of version here, I think I saw somewhere that aruco was not supported after opencv3 so I tried with opencv3.4 but it still didn't work.

How can I solve my issue? Thank you in advance.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Jack
  • 695
  • 10
  • 29

1 Answers1

1

This is happening because you've downloaded a version of the aruco module that is not compatible with your current version of the OpenCV library. The best way to solve it is to compile OpenCV specifying that you want to add the opencv_contrib libraries. To avoid problems let's use the same versions for OpenCV contrib and OpenCV: for example 4.3.0.

First, download OpenCV 4.3.0 source code.

Second, download OpenCV Contrib 4.3.0 source code.

If you have downloaded them as a ZIP, then unpack them into two different folders.

Then you will need CMake, download and configure it for Windows (Maybe this link could be helpful).

To compile OpenCV with OpenCV contrib you will need to use CMake with this command:

cmake -DOPENCV_EXTRA_MODULES_PATH=<opencv_contrib>/modules <opencv_source_directory>

As specified here. In the GUI version of CMake, you'll need to specify the parameter OPENCV_EXTRA_MODULES_PATH with the path of 'modules' folder included in the OpenCV contrib source code.

After that, you'll only need to build the code (for example, setting Visual Studio as a compiler with CMake you'll have an sln solution that you can use to build the code).

EDIT: You'll probably need to set environment variables too, you can do this following what it is said here.

Doch88
  • 728
  • 1
  • 8
  • 22
  • It solved the problem that I had before but now it's telling me that `opencv_calib3d430d.dll ` can't be found while I have put the directory of where it is (_C:\opencv\builds\bin\Debug_) in the include... – Jack Jun 23 '20 at 15:42
  • So the program runs and then stops with a windows error saying : "Impossible to execute the code, because opencv_calib3d430d.dll cannot be found. Reinstalling the program may solve this problem." – Jack Jun 23 '20 at 17:15
  • Try with [this](https://stackoverflow.com/a/42361202/11289290), if it does not work try with [this hack](https://stackoverflow.com/a/31721884/11289290) – Doch88 Jun 23 '20 at 19:02
  • By the way, I think it is caused by environment variables that are not set, you could try [this](https://docs.opencv.org/master/d3/d52/tutorial_windows_install.html#tutorial_windows_install_path) (last section), to set them. – Doch88 Jun 23 '20 at 19:08
  • 1
    Thank you under some of the answers you sent, this one helped me : https://stackoverflow.com/a/37240552/7862279 I had an environment variable created for opencv but it wasn't added to `Path` – Jack Jun 24 '20 at 12:04