Home > Backend Development > C++ > How to Configure OpenCV-2.3 with Visual Studio 2010?

How to Configure OpenCV-2.3 with Visual Studio 2010?

Patricia Arquette
Release: 2024-12-22 17:54:10
Original
752 people have browsed it

How to Configure OpenCV-2.3 with Visual Studio 2010?

Configuring OpenCV-2.3 for Visual Studio 2010

While the official guide focuses on installing OpenCV-2.1, this article provides comprehensive instructions for properly setting up OpenCV-2.3 (x86 version) in Visual Studio 2010 (Express).

Setup Steps:

  1. Extract OpenCV Library: Download and extract OpenCV-2.3.0-win-superpack.exe to your desired location, such as C:OpenCV2.3.
  2. Create Visual Studio Project: Start a new Win32 Console Application project in Visual Studio. Choose "Empty Project" in the Application Settings.
  3. Add Sample Code: Create a main.cpp file and insert the sample code provided below:
#include <stdio.h>
#include <cv.h>
#include <highgui.h>

int main(int argc, char* argv[]) {
    if (argc < 2) {
        printf("Usage: ./opencv_hello <file.png>\n");
        return -1;
    }

    IplImage* img = cvLoadImage(argv[1], CV_LOAD_IMAGE_UNCHANGED);
    if (!img) {
        return -1;
    }

    cvNamedWindow("display", CV_WINDOW_AUTOSIZE);
    cvShowImage("display", img);

    cvWaitKey(0);

    return 0;
}
Copy after login
  1. Configure Include Directories: In Project Properties > C/C > General, add these paths to Additional Include Directories:

    • C:OpenCV2.3buildincludeopencv
    • C:OpenCV2.3buildincludeopencv2
    • C:OpenCV2.3buildinclude
  2. Configure Library Directories: In Project Properties > Linker > General, add this path to Additional Library Directories:

    • C:OpenCV2.3buildx86vc9lib
  3. Link OpenCV Libraries: In Project Properties > Linker > Input, add the following libraries:

    • opencv_core230.lib
    • opencv_highgui230.lib
  4. Set PATH Environment Variable: Append the following path to your PATH environment variable:

    • ; C:OpenCV2.3buildx86vc9bin

Execution:

Press F7 to build the solution. Ensure it succeeds without errors. To execute the application, make sure the PATH modification is applied and you can run OpenCV commands directly from the command prompt.

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

source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template