如何读取视频文件以在 openCV 中使用?

发布于 2024-12-09 20:20:33 字数 112 浏览 1 评论 0原文

我想从“avi 文件”读取视频文件,然后逐帧输入它以在 openCV 中处理它。 我怎样才能做到这一点? openCV中有相关的函数吗?我应该使用视频阅读框架吗?

有哪些好的读取视频文件的框架?

I want to read a video file from an "avi file" and then enter it frame by frame to process it in openCV.
How can I do that?
Are there functions for that in openCV? Should I use a video reading framwork?

What are good frameworks for reading video files?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

っ左 2024-12-16 20:20:33

处理视频序列
从视频序列中捕获帧

初始化从摄像机的捕获:

CvCapture* capture = cvCaptureFromCAM(0); // capture from video device #0

初始化从文件的捕获:

CvCapture* capture = cvCaptureFromAVI("infile.avi");
Capturing a frame:

IplImage* img = 0; 
if(!cvGrabFrame(capture)){              // capture a frame 
    printf("Could not grab a frame\n\7");
    exit(0);
}
img=cvRetrieveFrame(capture);// retrieve the captured frame

要同时从多个摄像机获取图像,请首先从每个摄像机抓取图像。抓取完成后检索捕获的图像。

释放捕获源:

cvReleaseCapture(&capture);

注意设备捕获的图像是由捕获函数分配/释放的。没有必要明确地释放它。

Working with video sequences
Capturing a frame from a video sequence

Initializing capture from a camera:

CvCapture* capture = cvCaptureFromCAM(0); // capture from video device #0

Initializing capture from a file:

CvCapture* capture = cvCaptureFromAVI("infile.avi");
Capturing a frame:

IplImage* img = 0; 
if(!cvGrabFrame(capture)){              // capture a frame 
    printf("Could not grab a frame\n\7");
    exit(0);
}
img=cvRetrieveFrame(capture);// retrieve the captured frame

To obtain images from several cameras simultaneously, first grab an image from each camera. Retrieve the captured images after the grabbing is complete.

Releasing the capture source:

cvReleaseCapture(&capture);

Note that the image captured by the device is allocated/released by the capture function. There is no need to release it explicitly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文