Home > Backend Development > C++ > How Do I Configure OpenCV 2.3 for Visual Studio 2010 Express?

How Do I Configure OpenCV 2.3 for Visual Studio 2010 Express?

Linda Hamilton
Release: 2024-12-29 10:32:11
Original
268 people have browsed it

How Do I Configure OpenCV 2.3 for Visual Studio 2010 Express?

Setting Up OpenCV-2.3 for Visual Studio 2010 Express

To use OpenCV 2.3 with Visual Studio 2010 Express, follow these steps:

Project Setup

  1. Create a new Win32 Console Application project and select "Empty Project."
  2. Add the following code to the main.cpp file:
#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

OpenCV Configuration

  1. In Project Properties (ALT F7), select "All Configurations" under Configuration.
  2. In C/C > General > Additional Include Directories, add the following paths:

    • C:OpenCV2.3buildincludeopencv
    • C:OpenCV2.3buildincludeopencv2
    • C:OpenCV2.3buildinclude
  3. In Linker > General > Additional Library Directories, add:

    • C:OpenCV2.3buildx86vc9lib
  4. In Linker > Input > Additional Dependencies, add:

    • opencv_core230.lib
    • opencv_highgui230.lib

Runtime Setup

  1. Add the following to the end of your PATH environment variable:

    • ; C:OpenCV2.3buildx86vc9bin
  2. Build the solution using F7.

Troubleshooting

If you encounter errors related to missing '.obj' files, ensure that you have added the correct library directories and that you are specifying '.lib' files in Linker > Input > Additional Dependencies.

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

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