c++ - 如何在 C++ 中从相机流式传输图像/数据

标签 c++ image camera streaming

我有一个 USB 相机插入我的电脑(使用 Windows 7),我正在尝试创建一个程序来从相机流式传输图像。

我该怎么做呢?我有摄像头的 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;
 }

关于c++ - 如何在 C++ 中从相机流式传输图像/数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10551423/

相关文章:

c++ - 通过定义默认私有(private)构造函数使类不可继承

c++ - 无法在 Windows 上编译 SQLCipher

php - 如何在MySQL数据库中保存上传的图片名称

html - 为什么图片不放在html页面的最左上角?

安卓录像机: failed to get surface

cordova - 使用cordova相机插件时如何检查低分辨率照片?

c++ - 使用命名空间代替类

c++ - valgrind 发现错误将指针传递给函数,但当代码在同一范围内时没有错误

html - 无法移动 css div 中的元素

opencv - 测量相机发出的光的亮度