#include <highgui.h>
#include <stdio.h>
+// argument for cvFlip(src, dest, FLIP_TYPE)
+#define VERTICAL_FLIP 1
+
CvHaarClassifierCascade* load_object_detector(const char* cascade_path)
{
return (CvHaarClassifierCascade*)cvLoad(cascade_path);
// 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();
}
//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),
// Release the capture device housekeeping
cvReleaseCapture(&capture);
cvDestroyWindow("mywindow");
+ cvReleaseImage(&flipped);
return 0;
}