no match for call to ‘(cv::Moments) (std::vector<cv::Point_<int> >&)’ 38 | Moments moments = moments(max_contour);
时间: 2024-05-05 19:16:51 浏览: 9
To solve this error, you need to make sure that you are passing the correct data type to the cv::Moments function. The error message suggests that you are passing a std::vector<cv::Point_<int>> data type, which is not compatible with the cv::Moments function.
One possible solution is to convert the std::vector<cv::Point_<int>> data type into a cv::Mat data type before passing it to the cv::Moments function. You can do this by using the cv::Mat constructor that takes a std::vector<cv::Point_<int>> as an argument.
Here's an example:
```
std::vector<cv::Point> contour; // assume this is your contour data
// convert the contour data into a cv::Mat data type
cv::Mat contourMat(contour);
// calculate the moments of the contour
cv::Moments moments = cv::moments(contourMat);
```
Note that the cv::Mat constructor that takes a std::vector<cv::Point_<int>> as an argument assumes that each element of the vector is a 2-dimensional point (i.e., has an x and y coordinate). If your data has more than 2 dimensions or if the data type of the coordinates is different, you may need to modify this code accordingly.