//
#include "stdafx.h"
#include <cv.h>
#include <cxcore.h>
#include <highgui.h>
#include<iostream.h>
int main( int argc, char** argv )
{
//声明IplImage指针
IplImage* pFrame = NULL;
//获取摄像头
CvCapture* pCapture = cvCreateCameraCapture(-1);
//创建窗口
cvNamedWindow("video", 1);
//显示视屏
while(1)
{
pFrame=cvQueryFrame( pCapture );
if(!pFrame)break;
cvShowImage("video",pFrame);
char c=cvWaitKey(33);
if(c==27)break;
}
cvReleaseCapture(&pCapture);
cvDestroyWindow("video");
}
--------------------Configuration: kkk_install - Win32 Debug--------------------
Compiling...
kkk_install.cpp
c:\program files\microsoft visual studio\myprojects\kkk_install\kkk_install.cpp(31) : warning C4508: 'main' : function should return a value; 'void' return type assumed
kkk_install.obj - 0 error(s), 0 warning(s)
--------------------Configuration: kkk_install - Win32 Debug--------------------
Linking...
kkk_install.obj : error LNK2001: unresolved external symbol _cvDestroyWindow
kkk_install.obj : error LNK2001: unresolved external symbol _cvReleaseCapture
kkk_install.obj : error LNK2001: unresolved external symbol _cvWaitKey
kkk_install.obj : error LNK2001: unresolved external symbol _cvShowImage
kkk_install.obj : error LNK2001: unresolved external symbol _cvQueryFrame
kkk_install.obj : error LNK2001: unresolved external symbol _cvNamedWindow
kkk_install.obj : error LNK2001: unresolved external symbol _cvCreateCameraCapture
Debug/kkk_install.exe : fatal error LNK1120: 7 unresolved externals
执行 link.exe 时出错.
fatal error C1083: Cannot open precompiled header file: 'Debug/14.pch': No such file or directory
或者
kkk_install.exe - 1 error(s), 0 warning(s)
此时需要在工程-设置-编译-对象/库模块下加入vc.lib highgui.lib cxcore.lib
-------------------Configuration: kkk_install - Win32 Debug--------------------
Compiling...
Skipping... (no relevant changes detected)
kkk_install.cpp
kkk_install.obj - 0 error(s), 0 warning(s)
--------------------Configuration: kkk_install - Win32 Debug--------------------
Linking...
kkk_install.exe - 0 error(s), 0 warning(s)
但是运行后视频闪一下就消失了不知道为什么