I am trying to write some code to find the contour with the maximum size in a std::vector of contour.
I have the following error
error: conversion from ‘__gnu_cxx::__normal_iterator<std::vector<cv::Point_<int> >*, std::vector<std::vector<cv::Point_<int> > > >’ to non-scalar type
‘std::vector<cv::Point_<int> >::iterator {aka __gnu_cxx::__normal_iterator<cv::Point_<int>*, std::vector<cv::Point_<int> > >}’ requested
std::vector<cv::Point2i>::iterator it = std::max_element(contours.begin(), contours.end()
Below is my code
std::vector<std::vector <cv::Point2i>> contours;
std::vector<cv::Vec4i> hierarchy;
cv::findContours(rImg, contours, hierarchy,CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE, cv::Point(0, 0));
cv::Mat blank = cv::Mat::zeros(frame.size(), CV_8UC3);
cv::RNG rng;
std::vector<cv::Point2i>::iterator it = std::max_element(contours.begin(), contours.end(),
[](const std::vector<cv::Point2i>& p1,
const std::vector<cv::Point2i>& p2)
{ return p1.size()< p2.size(); });
std::vector<std::vector<cv::Point2i> > contourV;
contourV.push_back(it);
Would like to know what is wrong and how to correct them