OpenCV 2 Centroid
问题 I am trying to find the centroid of a contour but am having trouble implementing the example code in C++ (OpenCV 2.3.1). Can anyone help me out? 回答1: To find the centroid of a contour, you can use the method of moments. And functions are implemented OpenCV. Check out these moments function (central and spatial moments). Below code is taken from OpenCV 2.3 docs tutorial. Full code here. /// Find contours findContours( canny_output, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE,