Open Source Computer Vision in Microsoft Visual Studio

Open Source Computer Vision in Microsoft Visual Studio Kodai Ishikawa March 28, 2014 Abstract Open Source Computer Vision (OpenCV) is an open source...
Author: Alexina Palmer
0 downloads 2 Views 674KB Size
Open Source Computer Vision in Microsoft Visual Studio Kodai Ishikawa March 28, 2014

Abstract Open Source Computer Vision (OpenCV) is an open source library that can be used in Microsoft Visual Studio to create various video and image related applications. The library allows users to easily create complex programs such as facial recognition, object identification, and motion tracking. This application note will go over the steps needed to set up the OpenCV library in Visual Studio.

Keywords Microsoft Visual Studio, Open Source Computer Vision (OpenCV) Library, C++

Introduction Imagine you wanted to create a program that could detect faces in a real time with a video camera. It would be a security program where the video camera would be pointed at the front porch of your house and would send you an email with an image when the camera sees a face. Creating a program that accomplishes the security program described would be extremely hard without open source libraries. For example, creating this application by scratch could be thousands of lines of code, but with libraries such as Open Source Computer Vision (OpenCV), this could be accomplished in less than a hundred lines. The C++ programming language comes with a standard library which includes features such as input/output, containers, expressions, and basic algorithms. Open source libraries such as OpenCV allow users to create complex programs without the need of programming the main components. The focus of this application note is to go over the steps required to install OpenCV in Microsoft Visual Studio. With the installation of the library, a user without a programming background could find publically available code and compile an application.

Objective The objective of this application note is to give detailed instructions on setting up the OpenCV Library with Microsoft Visual Studio. The goal is to become comfortable with including open source libraries into Visual Studio to create applications.

Instructions Note: A system with Microsoft Windows 7 x64, Microsoft Visual Studio 2010 Ultimate, and OpenCV 2.4.8 was used for this application note. Installation for other versions should be similar. OS Required: Microsoft Windows 7/8 Software Required: Microsoft Visual Studio (Available for free to Michigan State University students) – http://msdn.microsoft.com/en-US/vstudio/

Downloading and Extracting OpenCV 1a.) Download OpenCV for Windows – http://opencv.org/downloads.html 1b.) Extract the program to C:\

Setting up Environment Variables 2a.) Go to Start -> Control Panel -> System and Security -> System and check the system type (32-bit or 64-bit). Note this value. 2b.) In the left hand side of the window, select Advanced system settings then Environment Variables... (Figure 1)

Figure 1: System Properties

2c.) Find the variable Path under System Variables, select it then click on Edit…. Go to the end of Variable value and then add ;C:\opencv\build\x64\vc10\bin (Figure 2) The x64 is if you have a 64-bit system as you found out in 2a, if your system type is 32-bit replace x64 to x86 (;C:\opencv\build x86\vc10\bin). Also note the vc10 part of the path is the version of Visual Studio installed on the system (vc10 = Microsoft Visual Studio 2010). Click OK and then restart the computer.

Figure 2: Environment Variables

Creating a New Project 3.) Start Microsoft Visual Studio; go to File -> New Project…. Select Visual C++ on the left pane and then select Win32 Console Application in the center pane. Enter the name and location of the project. Click OK and then Finish.

Configuring Visual Studio 4a.) Go to Project -> Properties. Under Configuration at the top, select All Configurations. 4b.) On the left pane, select Configuration Properties -> C/C++ -> General. 4c.) Under Additional Include Directories in the center pane, add C:\opencv\build \include, then press Enter. (Figure 3)

Figure 3: Additional Include Directories

4d.) On the left pane, select Configuration Properties -> Linker -> General. 4e.) Under Additional Library Directories in the center pane, add C:\opencv\build \x64\vc10\lib (Change values as necessary for 32-bit processors and also different versions of Visual Studio). (Figure 4)

Figure 4: Additional Library Directories

4f.) On the left pane, select Configuration Properties -> Linker -> Input. 4g.) Click on Additional Dependencies, click on the down arrow, and lastly click on . (Figure 5)

Figure 5: Additional Dependencies

4h.) In the Additional Dependencies window copy and paste the following libraries and click on OK. (Figure 6)(Note: Depending on the version of OpenCV that is being used, the library names could be slightly different. C:\opencv\build\x64\vc10\lib is the location of the files to check filenames.) opencv_calib3d248d.lib opencv_contrib248d.lib opencv_core248d.lib opencv_features2d248d.lib opencv_flann248d.lib opencv_gpu248d.lib opencv_haartraining_engined.lib opencv_highgui248d.lib opencv_imgproc248d.lib opencv_legacy248d.lib

opencv_ml248d.lib opencv_nonfree248d.lib opencv_objdetect248d.lib opencv_photo248d.lib opencv_stitching248d.lib opencv_superres248d.lib opencv_ts248d.lib opencv_video248d.lib opencv_videostab248d.lib

Figure 6: Additional Dependencies Window

4i.) Click OK on the Additional Dependencies window, and then OK on the Property Pages window. The setup is finished and the Visual Studio project is now ready to use OpenCV libraries.

Conclusion OpenCV library allow users to create complex video and image applications. Numerous code examples are available online which would allow to easily create applications. This application note should have given users the information on how to include external libraries into Visual Studio.

Recommendations Further reading on C++ programming should be done for beginner programmers to understand the concepts and techniques.

References Microsoft Visual Studio – http://msdn.microsoft.com/en-US/vstudio/ OpenCV – http://opencv.org/ The C++ Resources Network – http://www.cplusplus.com/

Suggest Documents