0

How are you?

I am trying to create a video like this: https://youtu.be/L0JkjIwz2II

or like this: https://youtu.be/hPCTwxF0qf4

I am trying to getting this code working: https://github.com/Tubeliar/HAARCascadeVisualization

I am using Visual Studio 2017 on Windows 10. I have added correctly the include directory and the library directory. I created it as a console application. I added the #include "stdafx.h" at the start of the main file.

This are the errors that Microsoft Visual Studio show to me:

First image of errors

Second image of errors

Can you help me solve this? There is anything that I should know for making this work correctly?

Thank you to everyone, Andrea

Kinght 金
  • 17,681
  • 4
  • 60
  • 74
  • 2
    looks like linker errors. Did you add the single libraries to the linker input in the project settings: linker->input->additional dependencies? There should be some files mentioned like opencv_objdetect*.lib where * is your version number without points. The libs with *d.lib are debug libraries, the ones without are release build libraries. – Micka Jan 23 '18 at 13:14
  • Thank you for the reply (= Actualli in linker->input->additional dependencies I only have one library and it is: opencv_world331d.lib (I am in debug config, that's why there is a d library). In the original OpenCV folder I cannot find any other useful library :S Should I put there some other library? If yes, where I can find the right library? – Andrea Zamuner Cervi Jan 23 '18 at 17:20
  • the *world library should be ok. Was it compiled with the same compiler and same platform (x86 or x64) as your current project? – Micka Jan 23 '18 at 17:37
  • Absolutely yes, and I already tried it with some other OpenCV projects. In matter of fact, unitl today everything was fine. This code is the only one that I can not get running fine :S I also have a blog (in Italian) where I share some of my OpenCV code, and with my own code everything was fine! – Andrea Zamuner Cervi Jan 23 '18 at 18:15
  • can you show your code where you access the cascade classifier? – Micka Jan 23 '18 at 18:34
  • Here we have the code :D `code` string cascadeName = "C:\\opencv\\sources\\data\\haarcascades\\haarcascade_frontalface_alt.xml"; `code` ...tell me if maybe I missunderstood your request :P – Andrea Zamuner Cervi Jan 23 '18 at 19:00
  • sorry, didnt see that thr github with code was linked. Can you try to create your own project, just with a main function and cv::cascadeClassifier and test whether it compiles and links succesfully? – Micka Jan 23 '18 at 20:54
  • ab one more thing: Can you show the FIRST error please? – Micka Jan 23 '18 at 20:58
  • I tried the following code. With the following code there aren't any error in compilation. So, it compiles right. `code` #include "stdafx.h" #include "opencv2/objdetect.hpp" #include "opencv2/imgcodecs.hpp" #include "opencv2/videoio.hpp" #include "opencv2/highgui.hpp" #include "opencv2/imgproc.hpp" #include #include #include #include #include "VisualCascade.hpp" using namespace std; using namespace cv; string cascadeName = "C:\\opencv\\sources\\data\\haarcascades\\haarcascade_frontalface_alt.xml"; int main(){ } `code` – Andrea Zamuner Cervi Jan 24 '18 at 16:06
  • Here we have the first two errors and the last two errors [link] https://ibb.co/iSA2Db [link] – Andrea Zamuner Cervi Jan 24 '18 at 16:10
  • did you create the VS project/solution yourself? Are the VisualCascade.cpp and all other cpp files part or the project (source)? – Micka Jan 24 '18 at 16:12

1 Answers1

0

Those errors are as has been noted indeed linker errors. If the compiler does not complain that means you have you include paths set up correctly, so you have won half the battle.

For linker errors you can try these things:

  • Make sure your *.lib files are built for the same target you're building your own project for.
    • If you use NuGet then you can look in the /packages folder of your project. Browse down to /packages/[package name]/build/native/lib/[architecture]/. There you will find folders like v120 or v140. For Visual Studio 2017 they need to be v141. If they are missing then you can tell VS to target the older platform (project properties -> general -> platform toolset)
    • If you've built the libraries yourself then maybe you did that similarly targeting a different platform? Try building the OpenCV library again and make sure the target is set to v141 (or whatever you want to use).
  • Make sure the linker can find your libraries. If you're using NuGet this step isn't necessary but if you built the library yourself or if you downloaded a prebuilt one then go into project settings and:
    • Go to VC++ directories -> Library Directories, edit that value and make sure the folder that contains the *.lib files is in there.
    • Go to Linker -> Input -> Additional Dependencies, edit it and put in all the *.lib files. Just their names, not full paths. In your case you'd just put opencv_world331d.lib there.

Be aware that any of the above settings need to be done for each configuration. Usually there is a x86 and x64 architecture combined with debug or release configuration. If you switch any of these you'd have to check the above steps again. This is a bit of a hassle so you're better off defining a property sheet once which you can then reuse every time you do a OpenCV project. There was a tutorial for this in OpenCV 2.4's documentation, and some people have made premade ones.

Tubeliar
  • 836
  • 7
  • 20