OpenCV PS 3 Eye

时间:2011-02-17 16:48:11

标签: linux opencv

我正在使用Ubuntu 10.10并尝试从ps3eye相机捕获视频,但是OpenCV使用v4l从网络摄像头捕获,gucview,cheese,vlc都可以访问和使用相机但是当使用opencv从中捕获时我得到空白帧。

 /**
 * Display video from webcam
 *
 * Author  Nash
 * License GPL
 * Website http://nashruddin.com
 */

//gcc test.c -I /usr/include/opencv/ -L /usr/lib/ -lcv -lhighgui

#include <stdio.h>
#include "cv.h"
#include "highgui.h"

int main( int argc, char **argv )
{
    CvCapture *capture = 0;
    IplImage  *frame = 0;
    int       key = 0;

    /* initialize camera */
    capture = cvCaptureFromCAM( -1 );

    /* always check */
    if ( !capture ) {
        fprintf( stderr, "Cannot open initialize webcam!\n" );
        return 1;
    }

    /* create a window for the video */
    cvNamedWindow( "result", CV_WINDOW_AUTOSIZE );

    while( key != 'q' ) {
        /* get a frame */
      frame = cvQueryFrame( capture );

        /* always check */
      if( !frame ) break;

        /* display current frame */
        cvShowImage( "result", frame );

        /* exit if user press 'q' */
        key = cvWaitKey( 1 );
    }

    /* free memory */
    cvDestroyWindow( "result" );
    cvReleaseCapture( &capture );

    return 0;
}

0 个答案:

没有答案