4
我的電腦中安裝了USB攝像頭(使用Windows 7),我試圖創建一個程序來傳輸攝像頭中的圖像。如何在C++中以攝像頭流式傳輸圖像/數據
我該如何去做這件事?我已經獲得了相機的VID和PID,但對此不瞭解更多。請幫忙。
感謝
我的電腦中安裝了USB攝像頭(使用Windows 7),我試圖創建一個程序來傳輸攝像頭中的圖像。如何在C++中以攝像頭流式傳輸圖像/數據
我該如何去做這件事?我已經獲得了相機的VID和PID,但對此不瞭解更多。請幫忙。
感謝
如果你可以使用OpenCV的,有一個非常好的例子here
#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;
}
你因子評分關於使用DirectShow?我已經寫了關於它[這裏](http://stackoverflow.com/questions/7859442/grab-video-stream-from-firewire/7865752#7865752)。也許它會很有用。 – baderman