Color classification

The egg sensor reads four variables describing the egg. A range of similar eggs can be sampled to calibrate the sensor. From these readings, a normal distribution can be fitted to each variable and egg. Considering covariances, we can then generalize to a 4-variable normal distribution for each egg.

To identify the egg, the find the normal distribution with the highest probability density at a given point in variable-space.

The following steppable animation shows how this works for just two variables (red and blue).

The conversion of the raw recorded data to a set of normal distribution parameters is done with a small python script, that leverages the numpy numeric toolkit, and generates the egg_stats.cc file.

Api documentation

enum type EggType

Values:

std::array<MultivariateNormal<4>, EGG_TYPE_COUNT> egg_stats::expectations

We model each egg as a normal distribution over all readings for that egg.

The four variables of the distribution are the red, blue, white, and ambient components of the reading

The parameters for these models are in egg_stats.cc, which is auto-generated by a python script from a set of calibration readings

template <int N>
struct

Represents a generalized normal distribution over N variables, described by the mean and covariance matrices.

Public Functions

double MultivariateNormal::mahalanobisDistanceSq(Matrix<float, N, 1> value) const

generalization of \( \frac{x - \mu}{\sigma}^2 \) to N variables

see: http://en.wikipedia.org/wiki/Mahalanobis_distance

Public Members

Matrix<float, N, 1> MultivariateNormal::mean
Matrix<float, N, N> MultivariateNormal::covariance