http://hi.baidu.com/maxint/blog/item/564f2913d2005b25dc54013e.html
opencv安装方法:http://www.opencv.org.cn/index.php/VC6%E4%B8%8B%E5%AE%89%E8%A3%85%E4%B8%8E%E9%85%8D%E7%BD%AE
[zz]OpenCV设置摄像头的分辨率
OpenCV中原本是有设置视频捕捉属性的函数的,如下: CVAPI(int)
cvSetCaptureProperty( CvCapture* capture, int property_id, double
value ); //cvSetCaptureProperty(pCapture, CV_CAP_PROP_FPS, 30); //cvSetCaptureProperty(pCapture, CV_CAP_PROP_FRAME_WIDTH, 1024); //cvSetCaptureProperty(pCapture, CV_CAP_PROP_FRAME_HEIGHT, 768); 不过我用了之后没效果,就google到这篇文章了,也仅此一篇,实践过可行,源码也蛮清楚的,保存下。 查看文档,opencv1目前还不支持,只留了接口 Opencv是提供了一系列的摄像头设置函数的,但是没有提供相应的实现,使用的话,需要如下设置: 1 把下面几个定义添加到
highgui.h(C:\Program
Files\OpenCV\otherlibs\highgui)中 #define CV_CAP_PROP_DIALOG_DISPLAY 8 #define CV_CAP_PROP_DIALOG_FORMAT 9 #define CV_CAP_PROP_DIALOG_SOURCE 10 #define CV_CAP_PROP_DIALOG_COMPRESSION 11 #define CV_CAP_PROP_FRAME_WIDTH_HEIGHT 12 2 把页面中的函数 static int icvSetPropertyCAM_VFW( CvCaptureCAM_VFW* capture, int
property_id, double value )【看下面补充函数体】 添加到cvcap_vfw.cpp中,放在typedef struct CvCaptureCAM_VFW 这个结构之后。(见下文) 3 用下面的函数代替cvcap_vfw.cpp中的同名函数 static CvCaptureVTable captureCAM_VFW_vtable = { 6,
(CvCaptureCloseFunc)icvCloseCAM_VFW,
(CvCaptureGrabFrameFunc)icvGrabFrameCAM_VFW,
(CvCaptureRetrieveFrameFunc)icvRetrieveFrameCAM_VFW,
(CvCaptureGetPropertyFunc)icvGetPropertyCAM_VFW,
(CvCaptureSetPropertyFunc)icvSetPropertyCAM_VFW, // was NULL 原来此处代码为0 (CvCaptureGetDescriptionFunc)0 }; 4 编译highgui 注:first use win32 Debug mode to build
highgui, then use release mode to rebuild it 用的时候调用如下函数即可 cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH_HEIGHT, 640480 ) 补充,需要的函数: static int icvSetPropertyCAM_VFW( CvCaptureCAM_VFW* capture, int property_id, double value ) { int result = -1; CAPSTATUS capstat; CAPTUREPARMS capparam; BITMAPINFO btmp; switch( property_id ) { case
CV_CAP_PROP_DIALOG_DISPLAY: result =
capDlgVideoDisplay(capture->capWnd); //SendMessage(capture->capWnd,WM_CAP_DLG_VIDEODISPLAY,0,0); break; case
CV_CAP_PROP_DIALOG_FORMAT: result =
capDlgVideoFormat(capture->capWnd);
//SendMessage(capture->capWnd,WM_CAP_DLG_VIDEOFORMAT,0,0); break; case CV_CAP_PROP_DIALOG_SOURCE: result =
capDlgVideoSource(capture->capWnd);
//SendMessage(capture->capWnd,WM_CAP_DLG_VIDEOSOURCE,0,0); break; case
CV_CAP_PROP_DIALOG_COMPRESSION: result =
capDlgVideoCompression(capture->capWnd); break; case CV_CAP_PROP_FRAME_WIDTH_HEIGHT:
capGetVideoFormat(capture->capWnd, &btmp, sizeof(BITMAPINFO)); btmp.bmiHeader.biWidth =
floor(value/1000); btmp.bmiHeader.biHeight =
value-floor(value/1000)*1000; btmp.bmiHeader.biSizeImage
= btmp.bmiHeader.biHeight * btmp.bmiHeader.biWidth *
btmp.bmiHeader.biPlanes * btmp.bmiHeader.biBitCount
/ 8;
capSetVideoFormat(capture->capWnd, &btmp, sizeof(BITMAPINFO)); break; default: break; } return result; } |
碰到问题的解决:
1 VC 6.0中怎样设置才能生成Debug或Release版本的程序?
vc右上角菜单栏或工具栏的空白处右键,选上Build项,使build工具栏可见,在Build工具栏上就可以选择工程的Debug或Release版本。
或者菜单栏Build->Batch Build,在弹出的对话框中选择编译哪个版本,或者两个版本都编译。
2 找不到long PR 类似错误:(在XP中可能需要改动
如win7不要这么改!)
C:\Program Files\OpenCV\otherlibs\highgui\window_w32.cpp
为了防止中间部分编译
#if defined WIN64 || defined EM64T修改为: #if defined WIN64y999 || defined EM64Ty999
3.把编译好的bin覆盖。。。。。