opencv inRange
void checkContours1() { Mat img1_2 = imread("L:\\2021_12_!7\\img1\\2021-12-18_112921.jpg"); Mat contours_img; //inRange(img1_2, Scalar(104, 104, 104), Scalar(135, 135, 135), contours_img); inRange(img1_2, Scalar(225, 225, 225), Scalar(245, 245, 245), contours_img); imshow("inRange", contours_img); Mat img12 = img1_2.clone(); vector<vector<Point>> vec_p; vector<Vec4i> vec_4i; findContours(contours_img, vec_p, vec_4i, RETR_TREE, CHAIN_APPROX_SIMPLE, Point(0, 0)); for (size_t j = 0; j < vec_p.size(); j++) { double area1 = contourArea(vec_p[j]); cout << "area1:" << area1 << endl; if (area1>25200) { //continue; drawContours(img12, vec_p, j, cv::Scalar(0, 0, 255), 2, LINE_8, vec_4i, 0, Point(0, 0)); } } imshow("img12", img12); }
#########################