資源簡介
【實(shí)例簡介】opencv2.4.9 VS2013打開攝像頭
【核心代碼】while(1)
{
frame = cvQueryFrame(capture);
if(!frame) break;
//轉(zhuǎn)化為灰度圖
IplImage* GrayImage = cvCreateImage(cvGetSize(frame),frame->depth,1);
//cvCvtColor(frame,GrayImage,CV_BGR2GRAY);
//Canny(GrayImage,GrayImage,10,100,3);
cvCanny(frame,GrayImage,0,100,3);
cvShowImage("Video",GrayImage);
char c = cvWaitKey(33);
if(c == 27) break;
}
【核心代碼】while(1)
{
frame = cvQueryFrame(capture);
if(!frame) break;
//轉(zhuǎn)化為灰度圖
IplImage* GrayImage = cvCreateImage(cvGetSize(frame),frame->depth,1);
//cvCvtColor(frame,GrayImage,CV_BGR2GRAY);
//Canny(GrayImage,GrayImage,10,100,3);
cvCanny(frame,GrayImage,0,100,3);
cvShowImage("Video",GrayImage);
char c = cvWaitKey(33);
if(c == 27) break;
}
代碼片段和文件信息
#include?“cv.h“
#include?“highgui.h“
int?main(int?argc??char**?argv)
{
CvCapture*?capture;
if?(argc?==?1)
{
capture?=?cvCreateCameraCapture(0);
printf(“argc?=?%d\n“argc);
}?
else
{
capture?=?cvCreateFileCapture(argv[1]);
}
IplImage*?frame;
while(1)
{
frame?=?cvQueryframe(capture);
if(!frame)?break;
//轉(zhuǎn)化為灰度圖
IplImage*?GrayImage?=?cvCreateImage(cvGetSize(frame)frame->depth1);
//cvCvtColor(frameGrayImageCV_BGR2GRAY);
//Canny(GrayImageGrayImage101003);
cvCanny(frameGrayImage01003);
cvShowImage(“Video“GrayImage);
char?c?=?cvWaitKey(33);
if(c?==?27)?break;
}
cvReleaseCapture(&capture);
cvDestroyWindow(“Video“);
return?0;
}
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2014-08-11?10:13??open_cam\
?????目錄???????????0??2014-08-11?10:07??open_cam\ipch\
?????目錄???????????0??2014-08-11?10:07??open_cam\ipch\open_cam-b2cd7a57\
?????文件????56557568??2014-08-11?10:07??open_cam\ipch\open_cam-b2cd7a57\open_cam-c89cf8c.ipch
?????目錄???????????0??2014-08-11?10:08??open_cam\open_cam\
?????文件????????8033??2014-08-11?10:08??open_cam\open_cam\open_cam.vcxproj
?????文件?????????946??2014-08-11?10:08??open_cam\open_cam\open_cam.vcxproj.filters
?????文件?????????143??2014-08-11?10:04??open_cam\open_cam\open_cam.vcxproj.user
?????文件?????????738??2014-08-11?10:10??open_cam\open_cam\opencam1.cpp
?????目錄???????????0??2014-08-11?10:08??open_cam\open_cam\x64\
?????目錄???????????0??2014-08-11?10:10??open_cam\open_cam\x64\Debug\
?????文件???????19862??2014-08-11?10:10??open_cam\open_cam\x64\Debug\CL.read.1.tlog
?????文件?????????296??2014-08-11?10:10??open_cam\open_cam\x64\Debug\CL.write.1.tlog
?????文件?????????604??2014-08-11?10:10??open_cam\open_cam\x64\Debug\cl.command.1.tlog
?????文件???????????2??2014-08-11?10:10??open_cam\open_cam\x64\Debug\li
?????文件???????????2??2014-08-11?10:10??open_cam\open_cam\x64\Debug\li
?????文件???????????2??2014-08-11?10:10??open_cam\open_cam\x64\Debug\li
?????文件???????????2??2014-08-11?10:10??open_cam\open_cam\x64\Debug\li
?????文件???????????2??2014-08-11?10:10??open_cam\open_cam\x64\Debug\li
?????文件???????????2??2014-08-11?10:10??open_cam\open_cam\x64\Debug\li
?????文件????????2004??2014-08-11?10:10??open_cam\open_cam\x64\Debug\li
?????文件????????4402??2014-08-11?10:10??open_cam\open_cam\x64\Debug\li
?????文件?????????666??2014-08-11?10:10??open_cam\open_cam\x64\Debug\li
?????文件?????????390??2014-08-11?10:10??open_cam\open_cam\x64\Debug\mt.command.1.tlog
?????文件?????????290??2014-08-11?10:10??open_cam\open_cam\x64\Debug\mt.read.1.tlog
?????文件?????????290??2014-08-11?10:10??open_cam\open_cam\x64\Debug\mt.write.1.tlog
?????文件?????????406??2014-08-11?10:08??open_cam\open_cam\x64\Debug\open_cam.exe.em
?????文件?????????472??2014-08-11?10:08??open_cam\open_cam\x64\Debug\open_cam.exe.em
?????文件?????????381??2014-08-11?10:10??open_cam\open_cam\x64\Debug\open_cam.exe.intermediate.manifest
?????文件??????????45??2014-08-11?10:10??open_cam\open_cam\x64\Debug\open_cam.lastbuildstate
?????文件????????2494??2014-08-11?10:10??open_cam\open_cam\x64\Debug\open_cam.log
............此處省略15個(gè)文件信息
評論
共有 條評論