السبت، 1 مارس 2014

USING OPENCV 2.4.3 WITH VISUAL STUDIO 2012 ON WINDOWS 7 ,8 (64-BIT)

STEP-1

Add the path to OpenCV runtime dll’s (Dynamic Linked Libraries) to your Environment Path variable:
[For 64-bit Machines]   C:\OpenCV-2.4.2\opencv\build\x64\vc10\bin;C:\OpenCV-2.4.2\opencv\build\; 

STEP-2

Create a new Visual Studio Project. Open Visual Studio -> New Project -> Visual C++ -> Win32 Console Application. Click OK. Then click Next -> Finish. 

STEP-3

[This step is for people with 64-bit machines. People with 32-bit machines can skip it.] Now change the build configuration by going to Build menu -> Configuration Manager.
Change the Platform. Click on Win32, Select New. Use the settings as shown in the figure.
Step 3
Step 3
Click OK. Close the Configuration Manager. Change the configuration in the main window to Release, if it isnt that already.

STEP-4

Now we add the OpenCV libraries to our OpenCV project properties. Go to View -> Other Windows -> Property Manager. Then open the Release | x64 (32-bit users should open Release | Win32) Property page by double clicking on it:
Step-4
Go to Linker -> General -> Additional Library Directories. Add this path over there:
[For 64-bit Machines]   C:\OpenCV-2.4.2\opencv\build\x64\vc10\lib;   
[For 32-bit Machines]   C:\OpenCV-2.4.2\opencv\build\x86\vc10\lib;
Next, go to Linker -> Input -> Additional Dependencies. 
Step-4i
Add the following dependencies to it:
"C:\opencv243\build\x64\vc10\lib\opencv_core243.lib";
"C:\opencv243\build\x64\vc10\lib\opencv_imgproc243.lib";
"C:\opencv243\build\x64\vc10\lib\opencv_highgui243.lib";
"C:\opencv243\build\x64\vc10\lib\opencv_ml243.lib";
"C:\opencv243\build\x64\vc10\lib\opencv_video243.lib";
"C:\opencv243\build\x64\vc10\lib\opencv_features2d243.lib";
"C:\opencv243\build\x64\vc10\lib\opencv_calib3d243.lib";
"C:\opencv243\build\x64\vc10\lib\opencv_objdetect243.lib";
"C:\opencv243\build\x64\vc10\lib\opencv_contrib243.lib";
"C:\opencv243\build\x64\vc10\lib\opencv_legacy243.lib";
"C:\opencv243\build\x64\vc10\lib\opencv_flann243.lib243";

try 
#include "iostream"
#include "cv.h"
#include "highgui.h"

using namespace std;
char key;
int main()
{
    cvNamedWindow("Camera_Output", 1);    //Create window
    CvCapture* capture = cvCaptureFromCAM(CV_CAP_ANY);  //Capture using any camera connected to your system
    while(1){ //Create infinte loop for live streaming

        IplImage* frame = cvQueryFrame(capture); //Create image frames from capture
        cvShowImage("Camera_Output", frame);   //Show image frames on created window
        key = cvWaitKey(10);     //Capture Keyboard stroke
        if (char(key) == 27){
            break;      //If you hit ESC key loop will break.
        }
    }
    cvReleaseCapture(&capture); //Release capture.
    cvDestroyWindow("Camera_Output"); //Destroy Window
    return 0;
}

remove " to <

by cooperation https://www.facebook.com/Islam.Seleem 

ليست هناك تعليقات: