1, 绘制polygon
/*
** @name: draw_polygon
** @brief: draw a polygon on image
** @param: [io] image
** @param: [in] poly
** @param: [in] close
** @param: [in] color
** @param: [in] thick
** @return void
*/
void draw_polygon(cv::Mat& image, const std::vector<cv::Point>& poly, bool close, const cv::Scalar& color, int thick = 1){if (image.empty()) return;int num = poly.size();if (num < 2) return;for (int i = 0; i < num - 1; ++i){cv::line(image, poly[i], poly[i + 1], color, thick);}if (close){cv::line(image, poly[num - 1], poly[0], color, thick);}
}
2,轮廓最大内接圆
/*
** @name: find_inscribed_circle
** @brief: find max inscribed circle by polygon points
** @param: [in] pts, polygon points
** @param: [ou] circle, inscribed circle (center_x, center_y, radius)
** @return true