zoukankan      html  css  js  c++  java
  • blob(斑点)特征,SimpleBlobDetector(OpenCV案例源码detect_blob.cpp解读)

    Blob是指图像中的一块连通区域,Blob分析就是对前景/背景分离后的二值图像,进行连通域提取和标记。

    知识点就是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;
    }
  • 相关阅读:
    设计师用的几个网站
    微信小程序开发框架
    数据模型
    数据库系统
    大话设计模式读书笔记(一)
    关于数据统计时的效率
    orcale同一条语句运行速度差异问题
    使用plspl创建orcale作业
    正则表达式(一)
    oracle游标小试
  • 原文地址:https://www.cnblogs.com/xixixing/p/12468235.html
Copyright © 2011-2022 走看看