首页 > 其他 > 详细

blob(斑点)特征,SimpleBlobDetector(OpenCV案例源码detect_blob.cpp解读)

时间:2020-03-12 12:46:55      阅读:569      评论:0      收藏:0      [点我收藏+]

技术分享图片技术分享图片

知识点就是SimpleBlobDetector的使用,blob(斑点)筛选条件:斑点颜色、面积、圆度、惯性率、凸度,参数解读链接

#include<opencv2/opencv.hpp>
#include <iostream>

using namespace std;
using namespace cv;
int main()
{
    Mat src=imread("D:/sunflower.png");
    //*参数设置,以下都是默认参数
    SimpleBlobDetector::Params pDefaultBLOB;
    pDefaultBLOB.thresholdStep = 10;
    pDefaultBLOB.minThreshold = 50;
    pDefaultBLOB.maxThreshold = 220;
    pDefaultBLOB.minRepeatability = 2;
    pDefaultBLOB.minDistBetweenBlobs = 10;
    pDefaultBLOB.filterByColor = true;
    pDefaultBLOB.blobColor = 0;
    pDefaultBLOB.filterByArea = true;
    pDefaultBLOB.minArea = 25;
    pDefaultBLOB.maxArea = 5000;
    pDefaultBLOB.filterByCircularity = false;
    pDefaultBLOB.minCircularity = 0.8f;
    pDefaultBLOB.maxCircularity = (float)3.40282e+038;
    pDefaultBLOB.filterByInertia = true;
    pDefaultBLOB.minInertiaRatio = 0.1f;
    pDefaultBLOB.maxInertiaRatio = (float)3.40282e+038;
    pDefaultBLOB.filterByConvexity = true;
    pDefaultBLOB.minConvexity = 0.95f;
    pDefaultBLOB.maxConvexity = (float)3.40282e+038;
    //*用参数创建对象
    Ptr<SimpleBlobDetector> blob=SimpleBlobDetector::create(pDefaultBLOB);
    //Ptr<SimpleBlobDetector> blob=SimpleBlobDetector::create();//默认参数创建
    //*blob检测
    vector<KeyPoint> key_points;
    blob->detect(src,key_points);
    Mat outImg;
    //*绘制结果
    drawKeypoints(src,key_points,outImg,Scalar(0,0,255));
    imshow("blob",outImg);

    waitKey();
    return 0;
}

 

blob(斑点)特征,SimpleBlobDetector(OpenCV案例源码detect_blob.cpp解读)

原文:https://www.cnblogs.com/xixixing/p/12468235.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!