gpt4 book ai didi

c++ - OpenCV VideoWriters 的输出目录有问题

转载 作者:太空宇宙 更新时间:2023-11-04 14:26:04 24 4
gpt4 key购买 nike

我是一名数学本科生,几乎没有编程经验。不过,我对计算机视觉很感兴趣。试图遵循 Learning OpenCV 这本书,但它有点过时了。如何将生成的视频文件保存在我的 linux 主目录中?例如“/home/user/..”,在此先感谢,这是我的第一篇文章,我知道我不会失望的。顺便说一句,我正在 eclipse 上编译,我不太熟悉参数设置。

#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <cv.h>
#include <highgui.h>


int main(int argc, char *argv[]) {

int isColor = 1;
int frameW = 640;
int frameH = 480;
int fps = 25;

CvCapture* capture = cvCaptureFromCAM(0);
assert( capture != NULL );

cvNamedWindow( "Webcam", CV_WINDOW_AUTOSIZE);

CvVideoWriter *writer = cvCreateVideoWriter(
"out.avi",
CV_FOURCC('M','J','P','G'),
fps,
cvSize(frameW,frameH),
isColor
);

IplImage* frame = cvQueryFrame( capture );

while( (frame = cvQueryFrame( capture )) != NULL ) {
cvWriteFrame(writer, frame);
cvShowImage("Webcam", frame);
char c = cvWaitKey( 33 );
if ( c == 27 ) break;
}

cvReleaseVideoWriter( &writer );
cvReleaseCapture( &capture );
return(0);

}

最佳答案

您是否尝试过将完整路径传递给 cvCreateVideoWriter

 CvVideoWriter *writer = cvCreateVideoWriter(
"/home/user/out.avi",
CV_FOURCC('M','J','P','G'),
fps,
cvSize(frameW,frameH),
isColor
);

关于c++ - OpenCV VideoWriters 的输出目录有问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3924957/

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