High Tech Imaging IMA 4509 | Visual Content Analysis OpenCV Programming with Visual Studio Nicolas ROUGON ARTEMIS Department Nicolas.Rougon@telecom-sudparis.eu Institut Mines-Télécom
Installing OpenCV for Windows ■ Download / install latest version opencv.org/releases.html > OPENCVDIR ● Precompiled multi-architecture build tree OPENCVDIR/build = BUILD − Architecture / IDE-specific * subtrees BUILD/x{64|86}/vc{14|15} = LOCAL * vc14 | vc15 > Visual Studio 2015 | 2017 ● Build tree structure − BUILD/include − LOCAL/lib − LOCAL/bin header files static libraries dynamic libraries *.h *.hpp *.lib | *d.lib *.dll | *d.dll Release | Debug configurations Institut Mines-Télécom IMA 4509 - Nicolas ROUGON
Installing OpenCV for Windows ■ System configuration ● If administration rights − Open Windows Control panel | Système et Sécurité | Système − Open dialog Paramètres système avancés − Open dialog Variables d’environnement − Update PATH from list Variables système ► add LOCAL/bin ● If no administration rights − Go to directory x{64|86}/{Release|Debug} of your current Visual Studio solution tree ► copy LOCAL/bin/*.dll Institut Mines-Télécom IMA 4509 - Nicolas ROUGON
Installing Visual Studio ■ Download Visual Studio 2017 ● 3 versions available Community Professional | Enterprise − Free − Commercial − Targeted to students & − Targeted to small | large open-source developers teams/projects/firms − Modular, with a variety of − Extended | end-to-end supported languages & solution frameworks ► sufficient for standard use visualstudio.com/fr/vs/community Institut Mines-Télécom IMA 4509 - Nicolas ROUGON
Installing Visual Studio ■ Download Visual Studio 2017 ● 2 platforms available Windows 7/10 macOS − C++ not supported ► Install package Desktop development with C++ ► A solution for Mac users is to create a Virtual Machine and install Visual Studio 2017 for Windows on it Institut Mines-Télécom IMA 4509 - Nicolas ROUGON
OpenCV for Windows @ TSP ■ Computer Labs configuration 4.1.0 for Windows OPENCVDIR = C:/Program Files/OpenCV BUILD = OPENCVDIR /build LOCAL = BUILD/x64/vc15 Community 2017 Full installation System PATH includes LOCAL/bin Institut Mines-Télécom IMA 4509 - Nicolas ROUGON
Configuring Visual Studio for OpenCV ■ Create generic Visual Studio project for OpenCV ● Create a new project = PROJECT ► set project type as Visual C++ | Application console Windows Institut Mines-Télécom IMA 4509 - Nicolas ROUGON
Configuring Visual Studio for OpenCV ■ Create generic Visual Studio project for OpenCV ● Create a new project ► set configuration as Release for platform x64 Institut Mines-Télécom IMA 4509 - Nicolas ROUGON
Configuring Visual Studio for OpenCV ■ Configure project properties ● From the Solution Explorer panel − Right-click over project name to pop project menu ► select menu item Properties Institut Mines-Télécom IMA 4509 - Nicolas ROUGON
Configuring Visual Studio for OpenCV ■ Configure project properties > Include path ● Category C/C++ | Général − Item Autres répertoires Include ► add BUILD/include Institut Mines-Télécom IMA 4509 - Nicolas ROUGON
Configuring Visual Studio for OpenCV ■ Configure project properties > Library path ● Category Editeur de liens | Général − Item Répertoires de bibliothèques supplémentaires ► add LOCAL/lib Institut Mines-Télécom IMA 4509 - Nicolas ROUGON
Configuring Visual Studio for OpenCV ■ Configure project properties > Libraries ● Category Editeur de liens | Entrée − Item Dépendances supplémentaires ► add opencv_world410.lib Institut Mines-Télécom IMA 4509 - Nicolas ROUGON
Configuring Visual Studio for OpenCV ■ Configure project properties > MS secured C/C++ routines ● Category C/C++ | Préprocesseur − Item Définitions de préprocesseur ► add _CRT_SECURE_NO_WARNINGS Institut Mines-Télécom IMA 4509 - Nicolas ROUGON
Configuring Visual Studio for OpenCV ■ Configure project properties > Precompiled headers ● Category C/C++ | En-têtes précompilés − Item En-têtes précompilés ► set option Sans utiliser les en-têtes précompilés Institut Mines-Télécom IMA 4509 - Nicolas ROUGON
Configuring Visual Studio for OpenCV ■ Remove precompiled headers-related files from solution ● ● List Fichiers source List Fichiers d’en -têtes ► delete stdafx.cpp ► delete stdafx.h targetver.h Institut Mines-Télécom IMA 4509 - Nicolas ROUGON
Configuring Visual Studio for OpenCV ■ Save all ► The resulting Visual Studio solution folder provides a template which can used for developing your own OpenCV applications ● Solution folder structure AppName Solution configuration file AppName.sln AppName AppName.vcxproj AppName.vcxproj.filters Project configuration files AppName.vcxproj.user x64 Built solution subfolders x64 Institut Mines-Télécom IMA 4509 - Nicolas ROUGON
Configuring Visual Studio for OpenCV ■ Instantiating the template ● In Windows Explorer − Create a copy of the template folder = NewApp ► rename solution & project configuration files accordingly NewApp Solution configuration file NewApp.sln NewApp NewApp.vcxproj NewApp.vcxproj.filters Project configuration files NewApp.vcxproj.user ► delete built solution folders Institut Mines-Télécom IMA 4509 - Nicolas ROUGON
Configuring Visual Studio for OpenCV ■ Instantiating the template ● Use a text editor to replace references to template AppName by NewApp in configuration files − solution configuration = NewApp.sln ► section Project Project("{8BC9CEB8-8B4A-11D0-8D11- 00A0C91BC942}") = “ NewApp ", “ NewApp \ NewApp .vcxproj", "{E5E08792-BA04-4B4B-86AA- 991FF5F578BF}“ − project configuration = NewApp.vcxproj ► XML tag RootNamespace <RootNamespace> NewApp </RootNamespace> Institut Mines-Télécom IMA 4509 - Nicolas ROUGON
Configuring Visual Studio for OpenCV ■ Instantiating the template ● Open the solution NewApp.sln in Visual Studio ● In the Solution Explorer − Update source & header file lists according to your application features ● Build the solution Institut Mines-Télécom IMA 4509 - Nicolas ROUGON
Configuring Visual Studio for OpenCV ■ Instantiating the template ● Solution folder structure > built solution subfolders AppName AppName x64 Compilation subtree > objects & logs Release | Debug x64 Application subtree Release | Debug > executable AppName.exe Institut Mines-Télécom IMA 4509 - Nicolas ROUGON
Helpers ■ Sample project www-public.tem-tsp.eu/~rougon/IMA4103 Slides | Helpers > OpenCV Sample Routines ! project properties compliant with OpenCV installation @ TSP ■ Sample code Available in OpenCV source tree OPENCVDIR/source = SOURCE SOURCE samples C++ sample routines cpp tutorial_code Complete tutorial Institut Mines-Télécom IMA 4509 - Nicolas ROUGON
Helpers ■ Online documentation docs.opencv.org Reference | Tutorials | QuickStart | Examples ■ Online resources opencv.org > Resources Books | Publications | Useful links ■ Q&A Forum anwers.opencv.org Institut Mines-Télécom IMA 4509 - Nicolas ROUGON
High Tech Imaging IMA 4509 | Visual Content Analysis OpenCV Programming with Visual Studio Nicolas ROUGON ARTEMIS Department Nicolas.Rougon@telecom-sudparis.eu Institut Mines-Télécom
Recommend
More recommend