Home >Backend Development >C++ >How to Install and Configure OpenCV 2.3 in Visual Studio 2010?

How to Install and Configure OpenCV 2.3 in Visual Studio 2010?

DDD
DDDOriginal
2024-12-27 05:26:13703browse

How to Install and Configure OpenCV 2.3 in Visual Studio 2010?

Install OpenCV-2.3 in Visual Studio 2010

In this guide, we will explain how to install OpenCV-2.3 in Visual Studio 2010 (Express) correctly Install and configure OpenCV version 2.3 x86 as many users seem to have difficulty installing it correctly.

Download and unzip OpenCV

Download OpenCV-2.3.0-win-superpack.exe and execute the file to unzip all files to a file called OpenCV2.3 in the folder. This folder contains two subdirectories: build and opencv. All settings in VS2010 will reference the build directory. For convenience, we moved the OpenCV2.3 folder to the C: drive, so please pay attention to the paths suggested in this guide as yours may be different.

Create Visual Studio Project

In Visual Studio, create a new Win32 Console Application project and name it. Once completed, a new window will appear. Click the "Application Settings" tab and make sure the "Empty Project" option is selected:

Add OpenCV code

Add a new file main to the Source Files folder .cpp, and then add the following code to main.cpp:

Configure Visual Studio Project

At this point we need to configure the project so that it looks for OpenCV headers and libraries. Go to the project properties (ALT F7) and once you see the new window do the following:

  • In the Configurations box, select "All Configurations"
  • Open Configuration Properties > C/C > General and edit the "Additional Include Directories" field to add the following 3 Paths (for header files):

    • C:OpenCV2.3buildincludeopencv
    • C:OpenCV2.3buildincludeopencv2
    • C:OpenCV2.3buildinclude
  • Then, add the library path in Configuration Properties >Linker >General, and add the following in the "Additional Library Directories" field:
    C :OpenCV2.3buildx86vc9lib
  • Finally, for this simple test we will add the library opencv_core230.lib and opencv_highgui230.lib. So go to Configuration Properties > Linker > Inputs and add them:

Build and run the application

Press F7 to build the solution and you should see:

Modify PATH Environment Variables

In order to be able to execute your application, you need to modify your system's PATH environment variable to add the location of the OpenCV DLL. Add the following to the end of your PATH:

; C:OpenCV2.3buildx86vc9bin

Now you can run your application and load images just like you would with OpenCV enkelt!

The above is the detailed content of How to Install and Configure OpenCV 2.3 in Visual Studio 2010?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn