Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCV Centroid of Irregular Shape

how do you get the centroid of an irregular shape using OpenCV?

like image 646
Og Namdik Avatar asked Sep 08 '12 03:09

Og Namdik


People also ask

How do you find the center of an irregular shape?

So, if you hang a shape from two different points (one at a time) and draw a line straight down from each point, the center of mass is where those lines intersect. This technique can be used for any irregular two-dimensional shape.


1 Answers

I'd recommend looking at the cv::Moments (C++) or cvMoments (C) function.

This StackOverflow thread gives some example code for a problem very similar to yours.

This post goes into some of the theory related to finding object center-points.

like image 196
solvingPuzzles Avatar answered Sep 30 '22 11:09

solvingPuzzles