Home > Backend Development > C++ > How to Install and Use OpenCV 2.4.3 in Visual C 2010 Express?

How to Install and Use OpenCV 2.4.3 in Visual C 2010 Express?

Susan Sarandon
Release: 2024-12-08 17:30:10
Original
798 people have browsed it

How to Install and Use OpenCV 2.4.3 in Visual C   2010 Express?

Installing and Using OpenCV 2.4.3 in Visual C 2010 Express

Getting Started

To install OpenCV 2.4.3, begin by downloading the self-extracting archive from its official repository. Once extracted, it will create a directory where all the required files are located.

System Configuration

To use OpenCV effectively, add the directory containing OpenCV's DLLs to your system's PATH variable. This directory, located at C:opencvbuildx86vc10bin, is where the necessary libraries reside.

Visual C Setup

  1. Create a new project in Visual C .
  2. Configure Visual C 's include and library directories to match OpenCV's corresponding directories:

    • Include Directory: C:opencvbuildinclude
    • Library Directory: C:opencvbuildx86vc10lib
  3. Add the following additional dependencies to your project's linker:

    opencv_calib3d243d.lib
    opencv_contrib243d.lib
    opencv_core243d.lib
    ...
    opencv_videostab243d.lib
    Copy after login

Example Code

To test your setup, create a new source file and enter the following code:

#include <opencv2/highgui/highgui.hpp>
#include <iostream>

using namespace cv;
using namespace std;

int main()
{
    // Load an image
    Mat im = imread("c:/full/path/to/lena.jpg");
    if (im.empty()) 
    {
        cout << "Cannot load image!" << endl;
        return -1;
    }
    // Display the image
    imshow("Image", im);
    waitKey(0);
}
Copy after login

Compile and run the code using F5, and a window should appear displaying the loaded image.

Next Steps

Once OpenCV is integrated into your development environment, explore its samples and documentation to expand your knowledge and begin creating computer vision applications with ease.

The above is the detailed content of How to Install and Use OpenCV 2.4.3 in Visual C 2010 Express?. 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