ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

opencv inRange

2022-01-15 08:32:08  阅读:15  来源: 互联网

标签:img opencv Scalar vec img1 inRange contours


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);


}

 

 

 

#########################

标签:img,opencv,Scalar,vec,img1,inRange,contours
来源: https://www.cnblogs.com/herd/p/15790159.html

专注分享技术,共同学习,共同进步。侵权联系[admin#icode9.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有