Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

filtering the image is one option, filtering the point positions(over time) another.

alternatively to the kalman filter, one could use a simple lowpass interpolation:

//
// e.g. to smooth noisy landmarks ;)
//
template<class T>
struct Ipol
{
    size_t N;
    std::deque<T> q;

    Ipol(size_t n=10) : N(n) {}

    T operator ()(T t)
    {
        q.push_back(t);
        if (q.size() > N)
            q.pop_front();

        T acc(0,0,0);
        for (size_t i=0; i<q.size(); ++i)
            acc += q[i];
        return acc / double(q.size());
    }
};

int nInterpolations = 5;
vector<Ipol<Point>> ipo(4, nInterpolations); // one for each box corner

while(true) {
    ... process image, find contours, retrieve box points
    for each box point:
         Point newVertex = ipo[i](oldVertex);
 }