//显示结果 imshow("轮廓绘制结果", edge); vector<Point2f>point_0; vector<Point2f>point_1; vector<Point2f>point_2; vector<Point2f>point_3; vector<Point2f>point_4; vector<Point2f>point_5; vector<Point2f>point_6; vector<Point2f>point_7; vector<Point2f>point_8; vector<Point2f>point_9; vector<Point2f>point_10; vector<Point2f>point_11; vector<Point2f>point_12; vector<Point2f>point_13; vector<Point2f>point_14; vector<Point2f>point_15; vector<Point2f>point_16; vector<Point2f>point_17; vector<Point2f>point_18; vector<Point2f>point_19; int m, n; for (m = 0; m < contours.size(); m++) { for (n = 0; n < contours[m].size(); n++) { switch (m) { case 0: point_0.push_back(contours[m][n]); break; case 1: point_1.push_back(contours[m][n]); break; case 2: point_2.push_back(contours[m][n]); break; case 3: point_3.push_back(contours[m][n]); break; case 4: point_4.push_back(contours[m][n]); break; case 5: point_5.push_back(contours[m][n]); break; case 6: point_6.push_back(contours[m][n]); break; case 7: point_7.push_back(contours[m][n]); break; case 8: point_8.push_back(contours[m][n]); break; case 9: point_9.push_back(contours[m][n]); break; case 10: point_10.push_back(contours[m][n]); break; case 11: point_11.push_back(contours[m][n]); break; case 12: point_12.push_back(contours[m][n]); break; case 13: point_13.push_back(contours[m][n]); break; case 14: point_14.push_back(contours[m][n]); break; case 15: point_15.push_back(contours[m][n]); break; case 16: point_16.push_back(contours[m][n]); break; case 17: point_17.push_back(contours[m][n]); break; case 18: point_18.push_back(contours[m][n]); break; case 19: point_19.push_back(contours[m][n]); break; default: cout << "input error" << endl; } } } Mat img(321, 432, CV_8UC1, cv::Scalar(0));
时间: 2023-06-27 18:06:03 浏览: 171
edge---point.rar_edge point_opencv边缘检测
这段代码的作用是将找到的轮廓分别存储到不同的 vector<Point2f> 中,并创建一个大小为321x432的空白图像。其中,vector<Point2f> 是一个存储二维点坐标的容器,contours[m][n] 表示第 m 个轮廓的第 n 个点的坐标。根据轮廓的数量,将每个轮廓中的点分别存储到对应的 vector<Point2f> 中。最后,创建一个大小为321x432的空白图像,类型为 CV_8UC1,即8位无符号单通道图像,像素值初始化为0。
阅读全文