Tutorial: Install OpenCV 2.4.2 for Windows Vista on Visual Studios 2008 Express

Categories Computer Vision, Uncategorized
This will be my first tutorial and actual blog post so please bear with me. So for those of you don’t know what OpenCV is: it’s a Open Source library for advanced computer vision algorithms which would otherwise require postgrad work. I think graphical computation is fascinating work because of the various things you can do with it (like make a real time sudoku solver) but I also think it is very difficult to implement. Humans perceive the world through their eyes and we are able to see objects, textures, curved surfaces, and many other things a computer cannot naturally do. Computers on the other hand see things as 1’s and 0’s or as a grid of pixels made of colours. We can easily distinguish objects and words (most of the time, if it’s not my handwriting) and we are also able to fill in things we can’t see with our brain. If something we see is blurry or obscured we are able to use our intuition to fill in what we can’t see. OpenCV allows computers to perceive images in similar ways but yet very differently from humans.

The OpenCV library is an open source library which means it is free to use but it also means that the documentation is not the greatest. Trying to install OpenCV and getting a program to run took me 3 hours going through various tutorials and guides. The legitimate OpenCV guide to installing did not work for me as well as the other guides. I combined a couple of methods together to get it finally working after hours of frustration.

Anyways that was my spiel on computer vision. I have Microsoft Visual Studio 2008 Express installed on my computer on a Windows Vista (x86 machine). These are the steps I used to get OpenCV working on my computer:

1. Download the OpenCV Project

Download the file at: http://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.4.2/OpenCV-2.4.2.exe/download and run the .exe. The application should have extracted a bunch of files into a folder called opencv.

2. Download CMake
 Now download CMake which will be used to “build” the project: http://www.cmake.org/files/v2.8/cmake-2.8.9-win32-x86.exe.

3. Run the CMake GUI program.
Where is the source code: <your  OpenCV folder>
Where to build: <your OpenCV folder/build>

4.  Build the binaries for your OpenCV library
Click configure and select Visual Studio 9 2008.

Click Finish and it will output some information on your compiler.

5. Keep clicking generate until you get no more red text.

6. Configure in Visual Studio 2008 Express
Once you’re done that, open up Visual Studio 2008 Express. Tools -> options

In your “include files” add the following directories:
<your opencv folder>buildinclude
<your opencv folder>buildincludeopencv

In your “library files” add the following directories:
<your opencv folder>buildx86vc9lib

7. Configure .dlls to be used in system

Computer-> right click (properties) -> Advanced system settings

In user variables, go to path and click edit.



Add this line exactly as it is to the variable value. Key word: add. If you delete everything in there, you’re going to have a bad time.
;<your OpenCV folder>buildx86vc9bin>;<your openCV folderbuildcommontbbia32vc9



8. Create Hello World in OpenCV 
Create a new Visual Studio 2008 Express projects. File-> New -> Project.
An empty win32 console project will be fine.

Create a new .cpp file and copy this hello world code into it:

 #include <cv.h>  
 #include <highgui.h>  
 int main ( int argc, char **argv )  
 {  
  cvNamedWindow( "My Window", 1 );  
  IplImage *img = cvCreateImage( cvSize( 640, 480 ), IPL_DEPTH_8U, 1 );  
  CvFont font;  
  double hScale = 1.0;  
  double vScale = 1.0;  
  int lineWidth = 1;  
  cvInitFont( &font, CV_FONT_HERSHEY_SIMPLEX | CV_FONT_ITALIC,  
        hScale, vScale, 0, lineWidth );  
  cvPutText( img, "Hello World!", cvPoint( 200, 400 ), &font,  
        cvScalar( 255, 255, 0 ) );  
  cvShowImage( "My Window", img );  
  cvWaitKey();  
  return 0;  
 }  

Before we can compile it, first we need to link the opencv libraries with our own project. This can be done by right clicking your project in visual studio and clicking properties.
Go to linker->input and add to additional dependencies:

opencv_core242d.lib
opencv_imgproc242d.lib
opencv_highgui242d.lib
opencv_ml242d.lib
opencv_video242d.lib
opencv_features2d242d.lib
opencv_calib3d242d.lib
opencv_objdetect242d.lib
opencv_contrib242d.lib
opencv_legacy242d.lib
opencv_flann242d.lib

You will need to do this for every project you make (I’m not sure how to make this work for all projects, but if you find out leave a comment)























9. Run your progam


You should get this:

I hope this helped you even if you didn’t have the exact specs as me.

If this isn’t working for you, leave a comment below and I’ll try to get back to you as soon as possible.

5 Comments

  • Emmanuel Lopez Lopez
    May 25, 2013

    Hi Michael, Opencv its working .
    Thank you

    • son cho
      November 20, 2015

      thần, còn lại cũng có sáu Đại La Kim Tiên, còn có hai cái là Đại La Kim Tiên trung kỳ.

      Trong khoảng thời gian tu luyện ở trong Hạo Thiên Tháp, mọi người thương thế cũng khôi phục không sai biệt lắm, thực lực cũng là cơ bản không có vấn đề, hơn nữa Diễm Ma, Lang Lễ, hiện tại cơ bản là tám Đại La Kim Tiên ở, Nhạc Thành đối với bình thường thế lực cũng không s i, vị đạo hữu này, bằng không ngươi gia nhậpdongtam
      game mu
      http://nhatroso.net/
      http://nhatroso.com/
      nhac san cuc manh
      tư vấn luật
      dịch vụ thành lập công ty trọn gói
      văn phòng luật
      tổng đài tư vấn pháp luật
      thành lập công ty
      http://we-cooking.com/
      chém gió
      trung tâm ngoại ngữ vào nhóm chúng ta được không, tại hạ Tương Văn Hoài, mọi người kêu là Lạc Nhạn đạo nhân." Ngay lúc Nhạc Thành ba người phải rời khỏi thời điểm, kia áo bào trắng thanh niên cũng tới Diễm Ma trước người nói, hai mắt thẳng thừng nhìn hướng về phía Diễm Ma.

      "Nguyên lai là Lạc Nhạn đạo nhân." Diễm Ma dễ thương cười, cặp kia mắt như là có thể chảy ra nước bình thường, càng thêm là làm cho kia Tương Văn trong lòng thèm muốn.

      "Không biết pháp danh tiên tử." Áo trắng thanh niên Tương Văn Hoài hai mắt mê ly, thi lễ hỏi.

      "Chúng ta xưng là Lấy mạng của ngươi." Diễm Ma đang nói vừa mới rơi xuống, trong tay cũng một đạo hồng mang chưởng ấn nháy mắt nghênh hướng về phía kia áo trắng thanh niên.

  • Punk Scriptum
    June 10, 2013

    Hi,
    It's working for me too!!!
    Thanxxxx

    Quentin

  • manick
    June 17, 2013

    i am having windows7 64 bit and visual studio 2010.
    I have followed your steps. i selected x64folder instead of x86
    and vc10 instead of vc9.

    I get linker errors to all the CV library related function calls.

  • madhur r
    October 29, 2013

    Why tesseract is giving misspell the letters and change o to 0 and 0 to O vice versa? Is it possible to correct it or improve it? can any one help?

Leave a Reply

Your email address will not be published. Required fields are marked *