#include <iostream> #include <vector> #include <opencv2/core/core.hpp> #include <opencv2/imgproc/imgproc.hpp> #include <opencv2/highgui/highgui.hpp> using namespace std; using namespace cv; int main() { // Read input binary image Mat image= imread("./binaryGroup.bmp",0); if (!image.data) return 0; namedWindow("Binary Image"); imshow("Binary Image",image); // Get the contours of the connected components vector<vector<Point>> contours; //findContours的输入是二值图像 findContours(image, contours, // a vector of contours CV_RETR_EXTERNAL, // retrieve the external contours CV_CHAIN_APPROX_NONE); // retrieve all pixels of each contours // Print contours' length轮廓的个数 cout << "Contours: " << contours.size() << endl; vector<vector<Point>>::const_iterator itContours= contours.begin(); for ( ; itContours!
opencv轮廓提取与轮廓拟合
最新推荐文章于 2024-05-04 09:47:30 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)