1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| //-------------------------------------------------------------------#include "opencv2/opencv.hpp"
//#include "opencv2/core.hpp"
//#include "opencv2/highgui/highgui.hpp"
//#include "opencv2/imgproc/imgproc.hpp"
using namespace cv;
#pragma comment(lib,"opencv_core2413.lib")
#pragma comment(lib,"opencv_highgui2413.lib")
#pragma comment(lib,"opencv_imgproc2413.lib")
int GlobalActions::TestWebCam()
{
VideoCapture cap(0); // open the default camera
if(!cap.isOpened()) // check if we succeeded
return -1;
//Mat edges;
//namedWindow("edges",1);
for(;;)
{
Mat imageIn;
cap >> imageIn; // get a new frame from camera
if(imageIn.empty())
{
break;
}
//cvtColor(imageIn,edges,COLOR_BGR2GRAY);
//GaussianBlur(edges,edges,Size(7,7),1.5,1.5);
//Canny(edges,edges,0,30,3);
//imshow("edges",edges);
namedWindow("image",WINDOW_AUTOSIZE);
imshow("image",imageIn);
waitKey(30);
bool bOk=imwrite("test.jpg",imageIn);
break;
}
// the camera will be deinitialized automatically in VideoCapture destructor
return 0;
} |
Partager