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;
    }
  • 相关阅读:
    如何优雅的使用mybatis
    Spring Data JPA、MyBatis还有Hibernate有什么区别
    微服务RPC框架选美
    微服务 Rpc和Rest协议
    开源PaaS工具CloudFoundry落地阿里云
    JS中的位置和宽度:clientWidth、offsetWidth、scrollWidth等区别
    vue cli3.X项目打包
    前端实现文件下载功能
    vue elementui 页面监控form表单数据变化
    vue 刮刮乐功能实现
  • 原文地址:https://www.cnblogs.com/xixixing/p/12468235.html
Copyright © 2011-2022 走看看