Home > Backend Development > C++ > How to Set Up OpenCV 2.4.3 in Visual C 2010 Express?

How to Set Up OpenCV 2.4.3 in Visual C 2010 Express?

Susan Sarandon
Release: 2024-12-15 04:14:17
Original
417 people have browsed it

How to Set Up OpenCV 2.4.3 in Visual C   2010 Express?

How to Install OpenCV 2.4.3 in Visual C 2010 Express

To install OpenCV 2.4.3 in Visual C 2010 Express, follow these steps:

1. Installation

  • Download the OpenCV 2.4.3 source file from SourceForge.net.
  • Extract the contents to a designated directory.
  • Add the directory C:opencvbuildx86vc10bin to your system PATH (via Control Panel → System → Advanced system settings → Advanced → Environment variables...).

2. Project Configuration

  • Create a new empty project in Visual C with Debug configuration.
  • In the project properties → VC Directories, add C:opencvbuildinclude to Include Directories and C:opencvbuildx86vc10lib to Library Directories.
  • In the project properties → Linker → Input, add the following dependencies (with the "_d" suffix indicating the "Debug" configuration):

    opencv_calib3d243d.lib
    opencv_contrib243d.lib
    opencv_core243d.lib
    opencv_features2d243d.lib
    opencv_flann243d.lib
    opencv_gpu243d.lib
    opencv_haartraining_engined.lib
    opencv_highgui243d.lib
    opencv_imgproc243d.lib
    opencv_legacy243d.lib
    opencv_ml243d.lib
    opencv_nonfree243d.lib
    opencv_objdetect243d.lib
    opencv_photo243d.lib
    opencv_stitching243d.lib
    opencv_ts243d.lib
    opencv_video243d.lib
    opencv_videostab243d.lib
    Copy after login
  • For Release configuration (optional), replace the "_d" suffix with "_".

3. Code Example

  • Create a new C file in your project and enter the following code:

    #include <opencv2/highgui/highgui.hpp>
    #include <iostream>
    
    using namespace cv;
    using namespace std;
    
    int main()
    {
      // Load and display an image
      Mat im = imread("c:/full/path/to/lena.jpg");
      if (im.empty()) 
      {
          cout << "Cannot load image!" << endl;
          return -1;
      }
      imshow("Image", im);
      waitKey(0);
      return 0;
    }
    Copy after login
  • Compile the code (F5) and it should display an image in a window.

Going Further

After setting up your OpenCV environment, explore the samples in c:opencvsamplescpp to enhance your skills and develop your own OpenCV applications.

The above is the detailed content of How to Set Up 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