简体   繁体   English

如何使用OpenCV在视频上查找对象

[英]How to find object on video using OpenCV

To track object on video frame, first of all I extract image frames from video and save those images to a folder. 要跟踪视频帧上的对象,首先我从视频中提取图像帧并将这些图像保存到文件夹中。 Then I am supposed to process those images to find an object. 然后我应该处理这些图像以找到一个对象。 Actually I do not know if this is a practical thing, because all the algorithm did this for one step. 实际上我不知道这是否是实用的,因为所有的算法都是一步完成的。 Is this correct? 它是否正确?

Well, your approach will consume a lot of space on your disk depending on the size of the video and the size of the frames, plus you will spend a considerable amount of time reading frames from the disk. 那么,根据视频的大小和帧的大小,您的方法会占用磁盘上的大量空间,而且您将花费大量时间从磁盘读取帧。

Have you tried to perform real-time video processing instead? 您是否尝试过执行实时视频处理? If your algorithm is not too slow, there are some posts that show the things that you need to do: 如果您的算法不是太慢,那么有些帖子会显示您需要执行的操作:

  • This post demonstrates how to use the C interface of OpenCV to execute a function to convert frames captured by the webcam (on-the-fly) to grayscale and displays them on the screen; 这篇文章演示了如何使用OpenCV的C接口执行一个功能,将网络摄像头捕获的帧(即时)转换为灰度,并在屏幕上显示;
  • This post shows a simple way to detect a square in an image using the C++ interface; 这篇文章展示了一种使用C ++接口检测图像中的正方形的简单方法;
  • This post is a slight variation of the one above, and shows how to detect a paper sheet; 这篇文章略有变化,并展示了如何检测纸张;
  • This thread shows several different ways to perform advanced square detection. 该线程显示了几种不同的方法来执行高级方形检测。

I trust you are capable of converting code from the C interface to the C++ interface. 我相信您能够将代码从C接口转换为C ++接口。

There is no point in storing frames of a video if you're using OpenCV, as it has really handy methods for capturing frames from a camera/stored video real-time. 如果您正在使用OpenCV,那么存储视频帧是没有意义的,因为它具有实时捕获来自摄像机/存储视频的帧的方便方法。

In this post you have an example code for capturing frames from a video. 在这篇文章中,您有一个用于捕获视频帧的示例代码。

Then, if you want to detect objects on those frames, you need to process each frame using a detection algorithm. 然后,如果要检测这些帧上的对象,则需要使用检测算法处理每个帧。 OpenCV brings some sample code related to the topic. OpenCV带来了一些与该主题相关的示例代码。 You can try to use SIFT algorithm, to detect a picture, for example. 例如,您可以尝试使用SIFT算法来检测图片。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM