gpt4 book ai didi

c - 如何在 OpenCV 中逐帧读取视频文件?

转载 作者:行者123 更新时间:2023-11-30 19:24:00 32 4
gpt4 key购买 nike

使用 C API(不是 C++),如何逐帧读取简单的视频文件,并将该帧(作为 CvMat*)传递出去进行处理?

最佳答案

类似于以下内容:

CvCapture* cap = cvCreateFileCapture(MyVideoFile);
if (!cap) { /* handle error */ }

for(;;) {
IplImage* frame = cvQueryFrame(cap);
if (!frame) { /* EOF */ break; }

CvMat tempMat;
CvMat* myMat = cvGetMat( frame, &tempMat, 0, 0);

// use myMat

// Note: Don't free the frame returned by cvQueryFrame!
}

cvReleaseCapture(&cap);

关于c - 如何在 OpenCV 中逐帧读取视频文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8314744/

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