Skip to content

yukebrillianth/opencv-object-tracking-with-distance-measurement

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Object Tracking By Color With Distance Measurement By Polynomial Regression

Name: Yuke Brilliant Hestiavin
Departement: Computer Engineering
Nrp: 5024241016

This project is related to the task as an intern software engineer in the Robotics UKM Research Team (IRIS) week 2, Computer Vision chapter.

Demo

demo.mp4

TO-DO: Implementing Polynomial Regression for Distance Calculation

Step 1: Data Collection

  • Set up the camera in a fixed position
  • Prepare an object with known dimensions (preferably the same color as your tracking target)
  • Mark several distances on the floor (e.g., every 10cm from 10cm to 100cm)
  • Collect radius measurements at each distance point
  • Record at least 4 data pairs of radius (pixels) and actual distance (cm)

Step 2: Regression Analysis

  • Use regression calculator (arachnoid.com)
  • Input the collected data pairs
  • Set polynomial degree

Step 3: Code Implementation

  • Create calculateDistance() function using polynomial coefficients
  • Implement quadratic equation solver
  • Add error handling for invalid radius values
  • Add boundary checking for calculated distances
  • Integrate the function with the main tracking loop

Step 4: Testing and Calibration

  • Test the system at known distances
  • Calculate error margins
  • Adjust coefficients if necessary
  • Document the accuracy at different distances

Current Progress

  • Basic color tracking implemented
  • Contour detection working
  • Minimum enclosing circle calculation added

Next Steps

  • Complete the polynomial regression implementation
  • Add detailed documentation
  • Optimize for better accuracy

Dependencies

  • OpenCV 4.x
  • C++ 11 or higher

How to Use

1. Installation

Clone this repo

git clone https://github.com/yukebrillianth/opencv-object-tracking-with-distance-measurement.git distance-measuring

cd distance-measuring

Make a build directory

mkdir build
cd build

run cmake

cmake ..

2. Usage

compile before run the program (run in build directory)

make

run the program

./DistanceMeasurement

Calibration Data

Radius (pixels) | Distance (cm)
----------------|---------------
254             | 10
142             | 20
105             | 30
78              | 40
65              | 50
46              | 70

Mode: normal x,y analysis
Polynomial degree 3, 8 x,y data pairs.
Correlation coefficient = 0.9943957141940097
Standard error = 2.64455698786371

Output form: simple list (ordered x^0 to x^n):

 1.7015679224939916e+002
-2.8134763868498247e+000
 1.7367481282684945e-002
-3.4546683821398511e-005

About

Object Tracking By Color With Distance Measurement By Polynomial Regression

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published