初始化SimpleBlobDetector
时间: 2024-01-26 22:02:20 浏览: 44
vue初始化模板
5星 · 资源好评率100%
在OpenCV中,可以通过以下代码初始化SimpleBlobDetector:
```
// Set up SimpleBlobDetector parameters.
SimpleBlobDetector::Params params;
// Change thresholds
params.minThreshold = 10;
params.maxThreshold = 200;
// Filter by Area.
params.filterByArea = true;
params.minArea = 1500;
// Filter by Circularity
params.filterByCircularity = true;
params.minCircularity = 0.1;
// Filter by Convexity
params.filterByConvexity = true;
params.minConvexity = 0.87;
// Filter by Inertia
params.filterByInertia = true;
params.minInertiaRatio = 0.01;
// Set up detector with params
Ptr<SimpleBlobDetector> detector = SimpleBlobDetector::create(params);
```
以上代码中,我们首先定义一个SimpleBlobDetector::Params对象params,然后对其成员进行设置(例如阈值、面积、圆形度、凸性等),最后使用这些参数初始化了一个SimpleBlobDetector对象detector。在这个过程中,我们可以通过修改params的成员自定义Blob检测器的参数。
阅读全文