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.
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:
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
© 2024 OneMinuteCode. All rights reserved.