Image not capture;only showes blank screen

asked 2014-05-19 05:42:27 -0500

Shanal gravatar image

Heading

I want to run this easy code to capture image. but it gives only blank screen as output.

#include <opencv2/objdetect/objdetect.hpp>

include <opencv2 highgui="" highgui.hpp="">

include <opencv2 imgproc="" imgproc.hpp="">

include <iostream>

include <stdio.h>

using namespace std; using namespace cv;

int main( int argc, const char* argv ) { CvCapture capture = 0; Mat frame; Mat frameCopy; Mat image;

capture = cvCaptureFromCAM( 0 ); //0=default, -1=any camera, 1..99=your camera
if(!capture) cout << "No camera detected" << endl;

cvNamedWindow( "result",0 );

if( capture )
{
    cout << "In capture ..." << endl;

IplImage* iplImg = cvQueryFrame( capture ); frame = iplImg; for(;;)

  {
       IplImage* iplImg = cvQueryFrame( capture );
        frame = iplImg;
  if( frame.empty())

 if( iplImg->origin == IPL_ORIGIN_TL )
            frame.copyTo( frameCopy );
        else
            flip( frame, frameCopy, 0 );

       if( waitKey( 10 ) >= 0 )

cvReleaseCapture( &capture ); }

   waitKey(0);

cvDestroyWindow("result");

return 0;
}

} the ou#include <opencv2 objdetect="" objdetect.hpp="">

include <opencv2 highgui="" highgui.hpp="">

include <opencv2 imgproc="" imgproc.hpp="">

include <iostream>

include <stdio.h>

using namespace std; using namespace cv;

int main( int argc, const char* argv ) { CvCapture capture = 0; Mat frame; Mat frameCopy; Mat image;

capture = cvCaptureFromCAM( 0 ); //0=default, -1=any camera, 1..99=your camera
if(!capture) cout << "No camera detected" << endl;

cvNamedWindow( "result",0 );

if( capture )
{
    cout << "In capture ..." << endl;

IplImage* iplImg = cvQueryFrame( capture ); frame = iplImg; for(;;)

  {
       IplImage* iplImg = cvQueryFrame( capture );
        frame = iplImg;
  if( frame.empty())

 if( iplImg->origin == IPL_ORIGIN_TL )
            frame.copyTo( frameCopy );
        else
            flip( frame, frameCopy, 0 );

       if( waitKey( 10 ) >= 0 )

cvReleaseCapture( &capture ); }

   waitKey(0);

cvDestroyWindow("result");

return 0;
}

} and output is: Screenshot from 2014-05-19 16:04:08.png

edit retag flag offensive close merge delete

Comments

hi shanal, please re-edit and format your code properly (mark it and press the 10101 button)

berak gravatar imageberak ( 2014-05-19 05:45:54 -0500 )edit