2012-01-26 4 views
3

をキャプチャすることができません、私のウェブカメラは、それが他のlaptop.The出力で動作open.Butすることができません「エラー:キャプチャがnullである」である他のノートパソコンで動作し、画像をキャプチャすることができません画像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; 
} 

答えて

0

CV_CAP_ANYの代わりに異なる番号を試してみることもできます。

OpenCVが適切にインストールされていない可能性もありますので、libv4lで再インストールする必要があります(here)。

あなたのカメラがOpenCVのcompatibleではないことが多少あります。

+0

1.私は私のUSBウェブカメラを試しました。それはまだ仕事をしませんでした。2.私はvisual studio.23を使用しています。私はあなたの.exeセットアップとgetbackを使ってそれを再インストールしようとします... thanks @ rics –

+0

Windowsで作業しているなら、このページ(http://code.google.com/p/javaac/wiki/Windows7AndOpenCV)あなたに役立つことがあります。これはキャプチャではなくVideoInputFrameGrabberを示唆しています。 (私はそれまでこれを試していない) – rics

+0

ya私は感謝.. @ rics働いた –

0

CV_CAP_ANYの代わりに-1を試してみてください。

+0

私もそれを試してみました –

関連する問題