Ask Your Question
0

moments vs manually finding the center of mass

asked 2015-01-05 01:36:43 -0600

andunhill gravatar image

Which method is faster? Manually computing the center of mass or by using moments? I tried to compute it by iterating over the matrix and the fps of the video stream dropped from 16 to 4.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
3

answered 2015-01-05 07:08:11 -0600

updated 2015-01-05 07:09:10 -0600

Using the moments to calculate a blob's centroid is quite fast. I run a 30 fps system using this method

inline cv::Point calculateBlobCentroid(const std::vector<cv::Point> blob)
{
    cv::Moments mu = cv::moments(blob);
    cv::Point centroid = cv::Point (mu.m10/mu.m00 , mu.m01/mu.m00);

    return centroid;
}

In which the input blob comes from the findContours method.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-01-05 01:36:43 -0600

Seen: 3,686 times

Last updated: Jan 05 '15