Max
Max

Reputation: 146

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

Upvotes: 7

Views: 3890

Answers (5)

fogx
fogx

Reputation: 1810

There are no other trackers than the ones found in the library.
Your best bet is to filter the image and use findcontours. Optical flow and background subtraction will help with this. You can combine optical flow with your car detector to rule out false positives. https://docs.opencv.org/3.4/d4/dee/tutorial_optical_flow.html https://docs.opencv.org/3.4/d1/dc5/tutorial_background_subtraction.html

Upvotes: 1

Ziri
Ziri

Reputation: 736

Method 1 :

      - Detect bounding boxes and subtract the background to get blobs rotated rectangles.

Method 2 :

      - implement your own version of detector with  rotated boxes.

Method 3 :

      - Use segmentation instead  ... Unet for example. 

Upvotes: 1

code-lukas
code-lukas

Reputation: 1651

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.

Upvotes: 2

ma.mehralian
ma.mehralian

Reputation: 1284

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).

Upvotes: 2

Ben Parry
Ben Parry

Reputation: 35

You should use PCA method, which can calculate the orientation of an detected object and which way it is facing. You can change the threshold of detection to select objects more like the cars (based upon shape and colour - a HSV conversion which in your case is red) in your picture.

Link to an introduction to Principal Component Analysis (PCA)

Upvotes: 1

Related Questions