This video has a good overview. https://www.youtube.com/watch?v=unSce_GPwto
To summarize the points in the video:
- Install OpenCV, add dll to path if required, add OPENCV_DIR env var if required. If doing these, we would need to close and open the command prompt or Visual Studio for these to take effect.
- Empty project (or Console project)
- If right-clicking through Solution Explorer to "create new c++ file" inside Visual Studio, the file would be automatically added to the project.
- Project -> (name of project) Properties,
Configuration Release in dropdown
Platform x64 in dropdown - C/C++ -> General -> Additional Include directories -> %OPENCV_DIR%\build\include
- Linker -> General -> Additional Library directories -> %OPENCV_DIR%\build\x64\vc15\lib
- Linker -> Input -> Additional dependencies -> (add the lib file of opencv, like opencv_world480.lib for version 4.80)
My older post about Visual Studio 2019 with opencv and spinnaker might probably still work, with the appropriate build tools installed. Creation of props (properties) file which contains the opencv dependencies is another possibility, which I have used in my projects. For example, this github actions build works fine with the latest windows runner, where Visual Studio 2022 is installed, and where the older build tools are also installed.
Notes on failed builds on Visual Studio 2022:
Cannot find float.h
Similarly, for VS19 upwards, there are some differences due to a different way of precompiled header handling - no need to add an include for windows.h as in earlier versions, as seen in the code used for the youtube example linked at the top of this post.
Another issue with Visual Studio builds would be the SDK version(s) which are installed. An answer at this post points to the location in the configuration as
Project properties -> Configuration properties -> General -> Windows SDK version
If it just says latest, then we must install the latest SDK - now it is for Windows 11, but the version number is still 10.<something>. And after the install, we may need to restart Windows too. And then in VS, may need to do "Retarget solution" and then Rebuild.
No comments:
Post a Comment