برای محاسبه مرکز ثقل بایستی از مومنت مرتبه اول استفاده کنید.
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
using namespace cv;
using namespace std;
#include <numeric>
int _tmain(int argc, _TCHAR* argv[])
{
vector<Point> points;
for (size_t i = 0; i < 5; i++)
points.push_back(Point(rand()%100,rand()%100));
Moments m = moments(Mat(points));
Point center_of_mas(m.m01 / m.m00, m.m01 / m.m00);
cout << center_of_mas;
}
در ضمن این پست ها هم می تونه بهتون کمک کنه.