I want to know how to find the center of gravity using OpenCV.

Asked 2 years ago, Updated 2 years ago, 103 views

We used Facemark:Facial Landmark Detection using opencv as a program to detect facial features, from which we drew only mouth lines.

At that time, I want to find the center of gravity of my mouth, but I don't know what to do.
Please tell me how to do it.

c++ opencv

2022-09-30 19:28

2 Answers

OpenCV provides the cv::moments function to find the moment of polygon, which also allows you to calculate the mass center.

Please refer to the following article:


2022-09-30 19:28

Mathematically, it is the application of the addition of the center of gravity of a triangle.

Consider the polygonal assembly found as the assembly of small triangles connecting one side of the reference point + polygon
If you follow the outer peripheral point around the right, you can add it when you move to the right, and subtract it when you move to the left. Calculate the position of the center of gravity.

Specifically... I'm not so confident, so I searched the internet.
They seem to be explaining it mathematically, so
www5d.biglobe.ne.jp/~noocyte/Programming/Geometry/PolygonMoment-jp.html
Try implementing it with reference to


2022-09-30 19:28

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.