I have a vector of a 2-dimensional points in OpenCV
std::vector points;
I would like to calculate the mean values for x and
You can use stl's std::accumulate as follows:
cv::Point2f sum = std::accumulate(
points.begin(), points.end(), // Run from begin to end
cv::Point2f(0.0f,0.0f), // Initialize with a zero point
std::plus() // Use addition for each point (default)
);
cv::Point2f mean = sum / points.size(); // Divide by count to get mean