簡體   English   中英

無法捕獲圖像Opencv

[英]Not able to capture image 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_CAP_ANY的位置嘗試不同的數字。

您的OpenCV也可能沒有正確安裝,那么您應該按照此處的建議使用libv4l重新安裝它。

您的相機很可能與OpenCV不兼容

嘗試傳遞-1而不是CV_CAP_ANY

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM