gpt4 book ai didi

c - 如何将输出视频保存到 OpenCV 中的文件中

转载 作者:太空宇宙 更新时间:2023-11-03 21:20:14 25 4
gpt4 key购买 nike

我想将输出视频保存到文件中而不是显示它并尝试使用 cvcaptureimage 但仍然无法获得结果

#include <highgui.h>

int main(int argc, char *argv[])
{
// Create a "Capture" object from 1st command line argument
CvCapture *video = cvCaptureFromFile(argv[1]);
// this is the structure that will store the frames
IplImage *frame = NULL;
// create a window to display the video
cvNamedWindow("Video", CV_WINDOW_AUTOSIZE);
// get the next frame
while (frame = cvQueryFrame(video) )
{
// display it in the window we created
cvShowImage("Video", frame);
// wait 1000/fps milliseconds
cvWaitKey((int)(1000/cvGetCaptureProperty(video, CV_CAP_PROP_FPS)));
//reading into .avi file
CvCapture*capture=0
capture=cvcreateFileCapture(arg[1]);
if(!capture)
{
// intiate the video read
IpLImage *bgr_frame=cvQueryFrame(capture);
double fps=cvGetCaptureProperty(capture,CV_CAP_PROP_FPS);
}
}
}

我能知道我在代码中重复的错误吗?

最佳答案

我知道这已经很老了,但我不能同意关于 OSX 的说法。

您可以在 OSX 上轻松构建和编译 FFMPEG。无需使用 QTKIT/Quicktime。我实际上在 OSX 上编写视频没有任何问题。

另一个建议是使用新的 OpenCV 2.0+ 结构,而不是使用那些已弃用的结构。 (使用 Mat 代替 IplImage/cvMat,使用 VideoWriter 和 VideoCapture。)

Mat image;
VideoCapture capture;
VideoWriter out;

capture = VideoCapture(-1);
image << capture;

out.write(image);

关于c - 如何将输出视频保存到 OpenCV 中的文件中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3400908/

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