Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 使用C+;中的directshow在windows中从网络摄像头捕获简单视频+;_C++_Visual Studio 2010 - Fatal编程技术网

C++ 使用C+;中的directshow在windows中从网络摄像头捕获简单视频+;

C++ 使用C+;中的directshow在windows中从网络摄像头捕获简单视频+;,c++,visual-studio-2010,C++,Visual Studio 2010,我一直在尝试编写一个简单的程序,只需几秒钟就可以从网络摄像头录制一段短视频,并将其存储在一个文件中,但我无法做到这一点。如果有人曾经经历过这件事,请帮助我。谢谢我建议改用opencv。有很多书和开源项目。示例取自() 下面是一个简单的框架,用于连接到相机并在窗口中显示图像 #include "cv.h" #include "highgui.h" #include <stdio.h> // A Simple Camera Capture Framework int main(

我一直在尝试编写一个简单的程序,只需几秒钟就可以从网络摄像头录制一段短视频,并将其存储在一个文件中,但我无法做到这一点。如果有人曾经经历过这件事,请帮助我。谢谢

我建议改用opencv。有很多书和开源项目。示例取自()

下面是一个简单的框架,用于连接到相机并在窗口中显示图像

#include "cv.h" 
#include "highgui.h" 
#include <stdio.h>  
// A Simple Camera Capture Framework 
int main() {
  CvCapture* capture = cvCaptureFromCAM( CV_CAP_ANY );
  if ( !capture ) {
    fprintf( stderr, "ERROR: capture is NULL \n" );
    getchar();
    return -1;
  }
 // Create a window in which the captured images will be presented
 cvNamedWindow( "mywindow", CV_WINDOW_AUTOSIZE );
 // Show the image captured from the camera in the window and repeat
 while ( 1 ) {
   // Get one frame
   IplImage* frame = cvQueryFrame( capture );
   if ( !frame ) {
     fprintf( stderr, "ERROR: frame is null...\n" );
     getchar();
     break;
   }
   cvShowImage( "mywindow", frame );
   // Do not release the frame!
   //If ESC key pressed, Key=0x10001B under OpenCV 0.9.7(linux version),
   //remove higher bits using AND operator
   if ( (cvWaitKey(10) & 255) == 27 ) break;
 }
 // Release the capture device housekeeping
 cvReleaseCapture( &capture );
 cvDestroyWindow( "mywindow" );
 return 0;
}
#包括“cv.h”
#包括“highgui.h”
#包括
//一个简单的摄像机捕获框架
int main(){
CvCapture*capture=cvCaptureFromCAM(CV\u CAP\u ANY);
如果(!捕获){
fprintf(stderr,“错误:捕获为空\n”);
getchar();
返回-1;
}
//创建一个显示捕获图像的窗口
cvNamedWindow(“mywindow”,CV_WINDOW_AUTOSIZE);
//在窗口中显示从相机捕获的图像,然后重复
而(1){
//得到一帧
IplImage*frame=cvQueryFrame(捕获);
如果(!帧){
fprintf(stderr,“错误:帧为空…\n”);
getchar();
打破
}
cvShowImage(“我的窗口”,框架);
//不要松开框架!
//如果按下ESC键,则在OpenCV 0.9.7(linux版本)下的键=0x10001B,
//使用AND运算符删除高位
如果((cvWaitKey(10)&255)==27)中断;
}
//释放捕获设备
cvReleaseCapture(&capture);
CvWindow(“mywindow”);
返回0;
}

我想在没有使用Directshow API的openCV的情况下完成这项工作。我想将静态图像作为位图存储在磁盘上,以便稍后将其转换为Avi文件。我已经完成了Avi部分,但无法从相机中捕获bmp图像