Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tracking of rotating objects using opencv

I need to track cars on the road from top-view video.

My application contain two main parts:

  1. Detecting cars on the frame (Tensorflow trained network)
  2. Tracking detected cars (opencv trackers)

I have troubles with opencv trackers. Initially i tried to different trackers, but only MOSSE is fast enough. This tracker works almost perfect for case with straight road, but i faced problems with rotating cars. This situation appears on crossroads.

As i understood, bounding box of rotated object is bigger that bbox of horizontal or vertical object. As result bbox contains big part of static background and the tracker lose target object.

Are there any alternative trackers which can track contours (not bounding boxes)? Can i adjust quality of existing opencv trackers results by any settings or by adjusting picture?

Schema: Example

Real image: Real image

like image 939
Max Avatar asked Nov 15 '19 12:11

Max


People also ask

How do I track an object in OpenCV?

The OpenCV object tracking API provides a variety of trackers. You can try some of the other tracking algorithms by simply changing the value of the tracker variable. Mean Shift is a object tracking algorithm that uses the logic of pixel density in different images/histograms to track objects.

What kind of tracking is available in OpenCV 4?

OpenCV 4 comes with a tracking API that contains implementations of many single object tracking algorithms. There are 8 different trackers available in OpenCV 4.2 — BOOSTING, MIL, KCF, TLD, MEDIANFLOW, GOTURN, MOSSE, and CSRT.

What is KCF object tracking in OpenCV?

In simple words, the KCF tracker focuses on the direction of change in an image (could be motion, extension or, orientation) and tries to generate the probabilistic position of the object that is to be tracked. The KCF object tracking is implemented in the TrackerKCF_create () module of OpenCV python. Below is the code along with the explanation.

Can a video picture be represented in frames using OpenCV?

In this paper, we found that a video picture is moving and that moving object is detected using OpenCV and the detected picture has been represented in frames with the help of contour by computer vision (CV) in a computer system. Detecting and recognizing an object is the initial stage of image systems in computer vision.


2 Answers

If your camera is stationary the following scenario is feasible:

  1. use ‌background subtraction methods to separate background image from foreground blobs.
  2. Improve the foreground results using morphological operations.
  3. Detect car blobs and remove other blobs.
  4. Track foreground blobs in video i.e. binary track (simply use this or even apply KF).
like image 150
ma.mehralian Avatar answered Sep 23 '22 13:09

ma.mehralian


A very basic but effective approach in this scenario might be to track the center coordinates of the bounding box, if the center coordinates only change along one axis (with a small tolerance for either axis), its a linear motion (not a rotation). If both x and y change, the car is moving in the roundabout.

This only has the weakness that it will detect diagonal motion, but since you are looking at a centered roundabout, that shouldn't be an issue.

It will also be very efficient memory-wise.

like image 24
code-lukas Avatar answered Sep 21 '22 13:09

code-lukas