gpt4 book ai didi

c++ - 想要在 OSX 上的 OpenCV 中实时镜像视频,不知道从哪里开始

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:31:19 28 4
gpt4 key购买 nike

如果它还不是很明显,这是我第一天使用 OpenCV。我希望做的是镜像 frame2,然后对其进行上采样。

我不确定如何对这些 IplImage 类型的帧使用矩阵运算。我如何镜像我的 frame2,然后将其上采样到 Webcam2 窗口?下面是我的代码:

 #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()。我相信它会对您有所帮助。

我也会给你我一直给的建议:从 C 接口(interface)转向 C++!更清洁、更安全、更轻松!

可以查看this回答以查看两者之间的差异。

关于c++ - 想要在 OSX 上的 OpenCV 中实时镜像视频,不知道从哪里开始,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8613881/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com