2013-04-27 55 views

回答

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; 
} 
+1

我想在沒有openCV的情況下使用Directshow API來完成它。我想將靜態圖像作爲位圖存儲在磁盤上,以便稍後將它們轉換爲Avi文件。我已經完成了Avi部分,但無法從相機捕獲bmp圖像 – Shazi 2013-05-03 12:09:53

相關問題