From: ozzloy Date: Mon, 9 Feb 2009 09:09:37 +0000 (-0800) Subject: making separate IplImage to hold mirrored image. this avoids flickering X-Git-Url: http://challenge-bot.com/repos/?p=ozzloy%40gmail.com%2Foble;a=commitdiff_plain;h=0d6b136c9c9782a65099c30269ce583ca70dd360 making separate IplImage to hold mirrored image. this avoids flickering --- diff --git a/hello-world.cpp b/hello-world.cpp index 62f59fa..f72a547 100644 --- a/hello-world.cpp +++ b/hello-world.cpp @@ -21,6 +21,9 @@ #include #include +// argument for cvFlip(src, dest, FLIP_TYPE) +#define VERTICAL_FLIP 1 + CvHaarClassifierCascade* load_object_detector(const char* cascade_path) { return (CvHaarClassifierCascade*)cvLoad(cascade_path); @@ -80,10 +83,18 @@ int main(int argc, char** argv) // Create a window in which the captured images will be presented cvNamedWindow("mywindow", CV_WINDOW_AUTOSIZE); + IplImage* frame = cvQueryFrame(capture); + if(!frame) { + fprintf(stderr, "ERROR: frame is null...\n"); + getchar(); + return -1; + } + IplImage* flipped = + cvCreateImage(cvGetSize(frame), frame->depth, frame->nChannels); // Show the image captured from the camera in the window and repeat while(1) { // Get one frame - IplImage* frame = cvQueryFrame(capture); + frame = cvQueryFrame(capture); if(!frame) { fprintf(stderr, "ERROR: frame is null...\n"); getchar(); @@ -91,10 +102,10 @@ int main(int argc, char** argv) } //flip the image so displayed right/left corresponds to physical right/left - cvFlip(frame, frame, 1); + cvFlip(frame, flipped, VERTICAL_FLIP); - detect_and_draw_objects(frame, cascade, 1); - cvShowImage("mywindow", frame); + detect_and_draw_objects(flipped, cascade, 1); + cvShowImage("mywindow", flipped); // Do not release the frame! //If ESC key pressed, Key=0x10001B under OpenCV 0.9.7(linux version), @@ -105,5 +116,6 @@ int main(int argc, char** argv) // Release the capture device housekeeping cvReleaseCapture(&capture); cvDestroyWindow("mywindow"); + cvReleaseImage(&flipped); return 0; }