The desire to live-mirror video in OpenCV on OSX, not sure where to start

If this is not yet obvious, this is my first day playing with OpenCV. What I hope to do is mirror frame2, and then enlarge it.

I'm not sure how to use the matrix operation for these frames that are of type IplImage. How can I mirror my frame2 and then enlarge it to the Webcam2 window? Below is my code:

#include "cv.h" #include "highgui.h" #include <stdio.h> // A Simple Camera Capture Framework int main() { CvCapture* capture = cvCaptureFromCAM( CV_CAP_ANY ); if ( !capture ) { fprintf( stderr, "ERROR: capture is NULL \n" ); getchar(); return -1; } // Create a window in which the captured images will be presented cvNamedWindow( "Webcam", CV_WINDOW_AUTOSIZE ); cvNamedWindow( "Webcam2", CV_WINDOW_AUTOSIZE ); // Show the image captured from the camera in the window and repeat while ( 1 ) { // Get one frame IplImage* frame = cvQueryFrame( capture ); IplImage* frame2 = cvCreateImage(cvSize (frame->width*2, frame->height*2), frame->depth, frame->nChannels); cvPyrUp (frame, frame2); if ( !frame ) { fprintf( stderr, "ERROR: frame is null...\n" ); getchar(); break; } cvShowImage( "Webcam", frame ); cvShowImage( "Webcam2", frame2 ); // Do not release the frame! //If ESC key pressed, Key=0x10001B under OpenCV 0.9.7(linux version), //remove higher bits using AND operator if ( (cvWaitKey(10) & 255) == 27 ) break; } // Release the capture device housekeeping cvReleaseCapture( &capture ); cvDestroyWindow( "Webcam" ); cvDestroyWindow( "Webcam2" ); return 0; } 
+4
source share
1 answer

OpenCV has a neat feature called flip() . The C parameter is called cvFlip() . And I'm sure this will help you.

And I will also give you the advice that I always give: Switch from the C interface to C ++! Much cleaner, much safer, much easier!

You can check this answer to see the differences between them.

+7
source

Source: https://habr.com/ru/post/1387701/


All Articles