0

ウェブカメラからほんの数秒の短いビデオを録画してファイルに保存する簡単なプログラムを作成しようとしましたが、そうすることができません。誰かが以前にこのことを経験したことがあるなら、私を助けてください。ありがとう

4

1 に答える 1

0

代わりにopencvを使用することをお勧めします。多くの書籍やオープンソース プロジェクトがあります。( http://opencv.willowgarage.com/wiki/CameraCaptureからの例)

これは、カメラに接続してウィンドウに画像を表示するための簡単なフレームワークです。

#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;
}
于 2013-04-27T17:38:00.153 に答える