简体   繁体   English

使用OpenCV跟踪对象

[英]Object Tracking using OpenCV

I have a video clip with fish swimming in a flume and small particles floating on the surface. 我有一个视频剪辑,鱼在水槽里游泳,小颗粒浮在水面上。 So, the moving objects are the swimming fish and hundreds of particles. 因此,运动的对象是游泳的鱼和数百个粒子。 Here is the link of the video sample . 这是视频示例的链接。

My interest is to locate the fish correctly in each single frame. 我的兴趣是在每个单个帧中正确定位鱼。

Currently, my procedures are as below: 目前,我的程序如下:

  1. remove light reflection (moving noise) in each single frame by converting RGB to HSV color space. 通过将RGB转换为HSV颜色空间来消除每个单帧中的光反射(移动噪声)。
  2. apply background subtraction method cv2.BackgroundSubtractorMOG . 应用背景减法cv2.BackgroundSubtractorMOG
  3. use erosion and dilation to remove most of the moving particle noise. 使用腐蚀和膨胀来消除大部分移动的粒子噪声。
  4. find all contours of the blobs in binary images, and compute rotated bounding boxes for all blobs. 在二进制图像中找到斑点的所有轮廓,并为所有斑点计算旋转的边界框。
  5. compute aspect ratios for all rotated bounding boxes. 计算所有旋转边界框的长宽比。
  6. identify fish in the foreground frames by using simple criteria: if a blob occupies more than 1 pixel, then check the aspect ratio of its rotated bounding box. 通过使用简单的标准来识别前景帧中的鱼:如果斑点占据的像素超过1个,则检查其旋转边界框的长宽比。 If it has the largest aspect ratio, it is considered as fish. 如果长宽比最大,则将其视为鱼。

My questions are: 我的问题是:

  1. In the first 10 frames, the moving fish is not identified by the cv2.BackgroundSubtractorMOG , I adjusted history , nmixture in the function, it does not seems to work well in the first 10 frames. 在第10帧,移动的鱼不被认定cv2.BackgroundSubtractorMOG ,我调整historynmixture在功能上,它似乎并不在第10帧很好地工作。 How to pick up the moving objects in the first few frames? 如何在前几帧中拾取运动物体?
  2. In some frames, the cv2.BackgroundSubtractorMOG can pick up a vague outline of fish, as shown in the red circle in the pic below: 在某些框架中, cv2.BackgroundSubtractorMOG可以拾取模糊的鱼的轮廓,如下图的红色圆圈所示: 红色圆圈 Is there any method to fill up that spotted outline and identify it as a fish? 有什么方法可以填充发现的轮廓并将其标识为鱼吗?

Here is the link of my code . 这是我的代码的链接。

Thank you! 谢谢!

Assuming that the fish swim along only this direction (or the opposite), you can try to use custom morphological operations that help to grow elongated objects. 假设鱼只沿这个方向(或相反方向)游泳,则可以尝试使用自定义的形态学操作来帮助生长细长的物体。 It should at least increase the size of the blob, thereby giving more data to the MoG model for tracking. 它至少应增加Blob的大小,从而为MoG模型提供更多数据以进行跟踪。

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

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