cassianorabelo / opencv-target-tracking

Code for an OpenCV based target tracker

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

opencv-target-tracking

Computer vision RC plane tracking

https://www.youtube.com/watch?v=VXD6au13Ubs

The following code was developed as an exercise to learn how to use the OpenCV Computer Vision Library in C++. The proposed objective was to detect and track, in realtime a given 2D pattern (target). There can never be a false positive.

2D target to be tracked

Due to the complexity of the job at hand, it was necessary to divide it in a series of steps that in the end converge to a satisfactory solution. The following figure shows some of the adopted steps.

Some of the steps taken to track the target.

  • (a) Raw footage showing the target that must be tracked and a QR code that cannot be detected (as everything else in the scene except the target);
  • (b) conversion from color to grayscale;
  • (c) binarization;
  • (d) contour detection;
  • (e) Filtering based on diverse geometrical properties;
  • (f) Perspective correction;
  • (g) Filtering based on circle detection;
  • (h) Filtering based on the existence of straight lines at certain angles;
  • (i) Displaying the detected target.

In order to improve performance, it was decided to parallelize certain parts of the code. Since findContours operation generates a large number of contours and we only want those with specific characteristics, each contour can be evaluated independently of the rest, which is an ideal situation for the use of parallel processing. OpenCV has handy class for parallel data processors called ParallelLoopBody. For this part of the code to work, it is necessary to compile OpenCV with support for the TBB - Threading Building Blocks library from Intel.

Part of the code was based on the ArUco module from OpenCV.

About

Code for an OpenCV based target tracker


Languages

Language:C++ 100.0%