Color Tracking Menggunakan Particle Filter

4

1. Introduction

The particle filter is a sequential Monte Carlo algorithm, i.e. a sampling method for approximating a distribution that makes use of its temporal structure. A  particle representation” of distributions is used. In particular, we will be concerned with the distribution p(x_t|z_{0:t}) where x_t is the unobserved state at time t, and z_{0:t} is the sequence of observations from time 0 to time t.

2. Explanation of Project

a. Problem : Track specified color using Particle Filter

This project is aimed to track a red target object with RGB value \text{R}=200 \text{, G}=0\text{, B}=0.

b. Program Flow

–          Initialize particles

\text{for } t=0 \text{ to } N \newline ;

x_t = \text{rand}(0,\text{max(width)}) \newline ;

y_t = \text{rand}(0,\text{max(height)}) \newline ;

v=0;

–          Sampling (Prediction)

x_t=x_{t-1}+vx_{t-1}+\text{rand}(-\text{transition},+ \text{transition});

y_t=y_{t-1}+vy_{t-1}+\text{rand}(-\text{transition},+ \text{transition});

Velocity (v) of each particle is used to predict where and how fast the particle moves, even the object kidnapped from scene. Transition is obtained from minimum distance of particles, it means that if the object disappears from the scene or closed by something else, its distances will be higher and we have to attempt larger uncertainty for next sampling.

–          Calculation of likelihood (correction)

Distance calculation of each particle :

d = \sqrt{{(I(red)-R)}^2+{(I(green)-G)}^2+{(I(blue)-B)}^2};

Likelihood calculation :

p(z|x) = \frac{1}{\sigma \sqrt{2\pi}}e^{\frac{d^2}{2{\sigma}^2}};

\text{transition} = \text{min(distance)};

–          Resampling

Make another set of particles with replacement using weights/sum of likelihood as probabilities. This step is a way of keeping the number of effective sample constant.

–          Drawing

Draw each position of particle as yellow dot, and make estimation of object current position by green circle. Here is the result for number of particles 500, 1000, and 2000.

N=500

N=1000

N=2000

Please don’t hesitate to make a discussion

Reference :

This tutorial based on Final Project of Advance Robotics Course on Toyohashi University of Technology

About the Author

Igi Ardiyanto
Administrator