Sunday, November 17, 2013

OpenCV 2.4.7 - How to install and Create Sample Project in Visual Studio

9:07 AM

Below are the sample programs


The program below is for opening webcam 

#include <opencv\cv.h>
#include <opencv\highgui.h>

using namespace cv;
int main(){


Mat image;

VideoCapture cap;
cap.set(CV_CAP_PROP_FRAME_WIDTH, 640);
cap.set(CV_CAP_PROP_FRAME_HEIGHT, 480);
cap.open(0);

namedWindow("window",1);
while(1)
{

try
{
cap>>image;

imshow("window",image);
}
catch (Exception& e)
{
const char* err_msg = e.what();
std::cout << "exception caught: imshow:\n" << err_msg << std::endl;
}
waitKey(33);
}

}




The program below is for opening an image



#include <opencv\cv.h>
#include <opencv\highgui.h>

using namespace cv;

int main(int argc, char** argv)
{
IplImage* img = cvLoadImage( "image.png" ); //change the name (image.jpg) according to your Image filename.
cvNamedWindow( "Example1", CV_WINDOW_NORMAL );
cvShowImage("Example1", img);
cvWaitKey(0);
cvReleaseImage( &img );
cvDestroyWindow( "Example1" );
return 0;
}

Version 2.4.7 Additional Dependencies

opencv_core247d.lib
opencv_imgproc247d.lib
opencv_highgui247d.lib
opencv_ml247d.lib
opencv_video247d.lib
opencv_features2d247d.lib
opencv_calib3d247d.lib


Written by

We are one of the initiators of the development of information technology in understanding the need for a solution that is familiar and close to us.

0 comments:

Post a Comment

 

© 2013 Klick Dev. All rights resevered.

Back To Top