想在OSX上的OpenCV中实时镜像视频,不知道从哪里开始 [英] Wanting to live-mirror video in OpenCV on OSX, not sure where to start
问题描述
如果还不是很明显,这是我第一天玩OpenCV。
我希望做的是mirror frame2,然后upsample它。
If it isn't already obvious, this is my first day playing around with OpenCV. What I am hoping to do is mirror frame2, and then upsample it.
我不知道如何在这些类型为IplImage的帧上使用矩阵运算。我如何镜像我的frame2,然后上传到Webcam2窗口?以下是我的代码:
I am not sure how to use a matrix operation on these frames which are of type IplImage. How could I mirror my frame2, and then upsample 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;
}
推荐答案
OpenCV,调用 flip()
。 C对应名为 cvFlip()
。我确定它会帮助你。
There is a neat function in OpenCV, called flip()
. The C counterpart is named cvFlip()
. And I am sure it will help you.
我也会给你我总是给出的建议:从C接口移动到C ++!更清洁,更安全,更容易!
And I will also give you the advice I always give: Move from the C interface to C++! Much cleaner, much safer, much easier!
您可以检查这个答案看看两者之间的区别。
You can check this answer to see the differences between the two.
这篇关于想在OSX上的OpenCV中实时镜像视频,不知道从哪里开始的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!