OpenCV installation in windows visual studio

32
OpenCV 2.4.9 In Windows

Transcript of OpenCV installation in windows visual studio

OpenCV 2.4.9

In Windows

IMPORTANT NOTES:

# In My System the location of OpenCv2.4.9 is C:\

and so have used C:\opencv\build\

# Prefer to extract The OpenCv file into drive C:\

# This settings is for WINDOWS With 64 Bit Operating system and you have to follow the

NOTES for 32Bit System

# Have Installed Visual Studio 2013

>>and so in the code ";%OPENCV_DIR%\x64\vc12\bin" and "$(OPENCV_DIR)\x64\vc12\lib"

I have used the vc12

# If you have installed Visual Studio 2012 then use vc11.

Step 5

OPENCV_DIR

C:\opencv\build\

Step 8

;%OPENCV_DIR%\x64\vc12\bin

NOTE:

For 32Bit (x86) System Replace x64 with x86

For 32Bit System SKIP The STEPS From 11 to

14.

NEED NOT CHANGE THE PLATFORM TO

x64 LEAVE IT AS WIN32.

Additional Include Directories

$(OPENCV_DIR)\include

Additional Library Directories

$(OPENCV_DIR)\x64\vc12\lib

NOTE:

For 32Bit (x86) System Replace x64 with x86

Depending on the Opencv Version the library names have to be

modified in the text given .

In the next slide you will see a set of library names like

“opencv_gpu249.lib”

Here 249 corresponds to the Opencv Version (2.4.9)

If you are using Opencv 2.4.5 Then replace 249 with 245

opencv_gpu249.lib

opencv_ocl249.lib

opencv_gpu249d.lib

opencv_ocl249d.lib

opencv_highgui249.lib

opencv_photo249.lib

opencv_highgui249d.lib

opencv_photo249d.lib

opencv_calib3d249.lib

opencv_imgproc249.lib

opencv_stitching249.lib

opencv_calib3d249d.lib

opencv_imgproc249d.lib

opencv_stitching249d.lib

opencv_contrib249.lib

opencv_legacy249.lib

opencv_superres249.lib

opencv_contrib249d.lib

opencv_legacy249d.lib

opencv_superres249d.lib

opencv_core249.lib

opencv_ml249.lib

opencv_ts249.lib

opencv_core249d.lib

opencv_ml249d.lib

opencv_ts249d.lib

opencv_features2d249.lib

opencv_nonfree249.lib

opencv_video249.lib

opencv_features2d249d.lib

opencv_nonfree249d.lib

opencv_video249d.lib

opencv_flann249.lib

opencv_objdetect249.lib

opencv_videostab249.lib

opencv_flann249d.lib

opencv_objdetect249d.lib

opencv_videostab249d.lib

Copy Paste the Entire set into Additional Dependencies

NEED NOT DO THE STEPS FOR DEBUG only

Release is necessary.

If you need to build in

DEBUG mode then do the steps from 23 to 25

Additional Include Directories

$(OPENCV_DIR)\include

Additional Library Directories

$(OPENCV_DIR)\x64\vc12\lib

NOTE:

For 32Bit (x86) System Replace x64 with x86

opencv_gpu249.lib

opencv_ocl249.lib

opencv_gpu249d.lib

opencv_ocl249d.lib

opencv_highgui249.lib

opencv_photo249.lib

opencv_highgui249d.lib

opencv_photo249d.lib

opencv_calib3d249.lib

opencv_imgproc249.lib

opencv_stitching249.lib

opencv_calib3d249d.lib

opencv_imgproc249d.lib

opencv_stitching249d.lib

opencv_contrib249.lib

opencv_legacy249.lib

opencv_superres249.lib

opencv_contrib249d.lib

opencv_legacy249d.lib

opencv_superres249d.lib

opencv_core249.lib

opencv_ml249.lib

opencv_ts249.lib

opencv_core249d.lib

opencv_ml249d.lib

opencv_ts249d.lib

opencv_features2d249.lib

opencv_nonfree249.lib

opencv_video249.lib

opencv_features2d249d.lib

opencv_nonfree249d.lib

opencv_video249d.lib

opencv_flann249.lib

opencv_objdetect249.lib

opencv_videostab249.lib

opencv_flann249d.lib

opencv_objdetect249d.lib

opencv_videostab249d.lib

Copy Paste the Entire set into Additional Dependencies

#include "stdafx.h"

#include "opencv2/highgui/highgui.hpp"

#include <iostream>

using namespace cv;

using namespace std;

int main(int argc, char* argv[])

{

VideoCapture cap(0); // open the video camera no. 0

if (!cap.isOpened()) // if not success, exit program

{

cout << "Cannot open the video file" << endl;

return -1;

}

double dWidth = cap.get(CV_CAP_PROP_FRAME_WIDTH); //get the width of frames of the video

double dHeight = cap.get(CV_CAP_PROP_FRAME_HEIGHT); //get the height of frames of the video

cout << "Frame size : " << dWidth << " x " << dHeight << endl;

namedWindow("MyVideo", CV_WINDOW_AUTOSIZE); //create a window called “MyVideo”

Mat frame;

while (1)

{

bool bSuccess = cap.read(frame); // read a new frame from video

if (!bSuccess) //if not success, break loop

{

cout << "Cannot read a frame from video file" << endl;

break;

}

imshow("MyVideo", frame); //show the frame in “MyVideo” window

if (waitKey(30) == 27) //wait for ‘esc’ key press for 30ms. If ‘esc’ key is pressed, break loop

{

cout << "esc key is pressed by user" << endl;

break;

}

}

return 0;

}

Sample Code

For Codes:

http://pastebin.com/fVzH4QcL

NOTE:

After Building the code ,the location where the .exe is located should contain a picture named

“ fish.jpg “. otherwise while running it shows error.

#include "stdafx.h"

#include "opencv2/opencv.hpp"

#include<iostream>

using namespace cv;

using namespace std;

int main(int argc, char* argv[])

{

Mat input_asb;

input_asb = imread("fish1.jpg",CV_LOAD_IMAGE_UNCHANGED);

namedWindow("mypic",CV_WINDOW_AUTOSIZE);

imshow ("mypic",input_asb);

waitKey(0);

return 0;

}

Sample Code

For codes:

http://pastebin.com/XZzDe6k0

THANKYOUBy

P E T E R J O S E

[email protected]

www.robocet.com