Here is a testcase for this bug.
Compile with:
g++ testcase.cpp `pkg-config --cflags-only-I opencv `\
`pkg-config --libs-only-L opencv`\
`pkg-config --libs-only-l opencv`\
-o testcase
to reproduce.
Greetings,
Jan
#include <math.h>
#include "cv.h" // includes OpenCV definitions
#include "highgui.h" // includes highGUI definitions
#include <iostream> // includes C++ standard input/output definitions
using namespace std;
int main( int argc, char** argv ) {
CvCapture* capture = 0;
IplImage *frame, *frame_copy = 0;
const char* input_name;
input_name = argc > 1 ? argv[1] : 0;
if( !input_name || (isdigit(input_name[0]) && input_name[1] == '\0') ){
cout << "Capture from Camera! AAAAAAnd ACTION!" <<endl;
capture = cvCaptureFromCAM( !input_name ? 0 : input_name[0] - '0' );
}else{
cout << "Capturing from AVI. Test mode."<<endl;
capture = cvCaptureFromFile( input_name );
}
cvNamedWindow( "result", 1 );
if( capture ) {
for(;;) {
if( !cvGrabFrame( capture )) {break;}
frame = cvRetrieveFrame( capture );
if( !frame ) {break;}
if( !frame_copy ){
frame_copy = cvCreateImage( cvSize(frame->width,frame->height),
IPL_DEPTH_8U, frame->nChannels );
}
if( frame->origin == IPL_ORIGIN_TL ){
cvCopy( frame, frame_copy, 0 );
}else{
cvFlip( frame, frame_copy, 0 );
}
cvShowImage( "result", frame_copy ); //Let the image be displayed
if( cvWaitKey( 10 ) >= 0 ) {break;}
}
cvReleaseImage( &frame_copy );
cvReleaseCapture( &capture );
}else{
cout << "Capturing from image. Lame."<<endl;
const char* filename = input_name ? input_name : (char*)"redline.jpg";
IplImage* image = cvLoadImage( filename, 1 );
if( image ){
cvShowImage( "result", image ); //Let the image be displayed
cvWaitKey(0);
cvReleaseImage( &image );
}else{
cout << "No valid input. Use ./testcase [Cam|Video|Picture] " <<endl;
}
}
cvDestroyWindow("result");
return 0;
}