- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在使用 SimpleBlobDetector
来定位小数点和其他类型的标点符号,如下图所示,有时检测器会从文本的实心区域中拾取 Blob (中间 9 的底部),我正在寻找一种方法来通过 SimpleBlobDetector
或在后期处理中过滤掉这些检测。
有没有办法指定 Blob 必须与其背景颜色分开?也许是一种边缘检测方法?
感谢您的帮助。
检测器代码是:
params = cv2.SimpleBlobDetector_Params()
params.filterByArea = True
params.minArea = 30
params.minThreshold = 50
params.maxThreshold = 200
params.filterByConvexity = True
params.minConvexity = 0.87
params.filterByColor = True
detector = cv2.SimpleBlobDetector_create(params)
detections = detector.detect(img)
带检测的输出图像
最佳答案
这里没有使用 SimpleBlobDetector
,而是使用边缘/轮廓检测的解决方案,它允许更多的过滤控制。主要思想是
阈值图像
Canny边缘检测
扩张以增强轮廓
根据区域检测和过滤轮廓
输出结果
contours detected: 1
import numpy as np
import cv2
original_image = cv2.imread("1.jpg")
image = original_image.copy()
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
blurred = cv2.GaussianBlur(gray, (3, 3), 0)
thresh = cv2.threshold(blurred, 110, 255,cv2.THRESH_BINARY)[1]
canny = cv2.Canny(thresh, 150, 255, 1)
kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (5,5))
dilate = cv2.dilate(canny, kernel, iterations=1)
cv2.imshow("dilate", dilate)
cv2.imshow("thresh", thresh)
cv2.imshow("canny", canny)
# Find contours in the image
cnts = cv2.findContours(dilate.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
cnts = cnts[0] if len(cnts) == 2 else cnts[1]
contours = []
threshold_min_area = 1100
threshold_max_area = 1200
for c in cnts:
area = cv2.contourArea(c)
if area > threshold_min_area and area < threshold_max_area:
cv2.drawContours(original_image,[c], 0, (0,255,0), 3)
contours.append(c)
cv2.imshow("detected", original_image)
print('contours detected: {}'.format(len(contours)))
cv2.waitKey(0)
关于python - SimpleBlobDetector - 隔离与周围不同的 Blob ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56066247/
我想检测一些 Blob ,但只有一定大小 - 在最小和最大区域之间。 当我这样设置参数时: cv::SimpleBlobDetector::Params params; params.filterBy
我正在尝试编写用于 Blob 检测的代码,并且我正在按照此处的教程进行操作 https://www.learnopencv.com/blob-detection-using-opencv-python
我正在使用具有以下指定参数的 SimpleBlobDetector: # Parameters params = cv2.SimpleBlobDetector_Params() params.filt
我是 OpenCV 新手,我使用 this repo将 OpenCV Java 导入我的项目。 我在那里导入了最新版本4.3.0我想尝试 Blob 检测功能但不能。 我发现 SimpleBlobDet
我输入的mask是一维灰度图像: detector = cv2.SimpleBlobDetector() print('mask.shape', mask.shape) # print('mask.d
我正在尝试使用 opencv SimpleBlobDetector。 我当前的程序是一个简单的测试程序,如下所示: import cv2 import numpy as np; im = cv2.im
如何确定在 Python 2.7 中使用 SimpleBlobDetector 找到的 Blob 数?我有示例代码在我的图像中查找和标记 Blob ,但还需要知道有多少 Blob 与我的参数匹配。 #
我正在使用 SimpleBlobDetector 来定位小数点和其他类型的标点符号,如下图所示,有时检测器会从文本的实心区域中拾取 Blob (中间 9 的底部),我正在寻找一种方法来通过 Simpl
我不明白 filterByInertia 是什么意思...我也不明白文档的小描述: 通过最小惯量与最大惯量之比。提取的 Blob 将具有 minInertiaRatio(含)和 maxInertiaR
我如何使用 cv::SimpleBlobDetector 类及其函数 detectblobs() 而不是任何额外的 blob 检测库? 最佳答案 Python:读取图像 blob.jpg 并使用不同的
我正在使用 OpenCV 3.1 使用 SimpleBlobDetector 进行一些 blob 检测,但我没有运气,也没有教程能够解决这个问题。我的环境是 x64 上的 XCode。 我从这张图片开
什么是SimpleBlobDetector实际上呢? 它返回一些点给我,但这些点是什么? Blob 检测器是否找到具有相似属性(包括颜色)的图像区域? 我可以检索找到的 Blob 的轮廓吗?我在网络上
我正在尝试检测图像中的 Blob ,如下图所示: 然而,没有检测到 Blob 。我检查了一些测试图像,下面的代码工作正常。我也尝试调整参数,但没有成功。知道我做错了什么吗? 这是我使用的代码: pro
我已仔细阅读此网站以寻求解释,但无济于事...希望有人知道答案。 我正在使用 simpleBlobDetector 来跟踪一些 Blob 。我想通过检测方法指定一个 mask ,但由于某种原因, ma
@robot_sherrick 回答了我 this question ,这是他回答的后续问题。Opencv 2.4 中的 cv::SimpleBlobDetector 看起来非常令人兴奋,但我不确定我
我有一个简单的 OpenCV SimpleBlobDetector 任务 cv::SimpleBlobDetector::Params params; cv::Ptr detector = cv::S
我对将 OpenCV 与 C++ 结合使用还很陌生,目前我正在使用它通过 blob 检测来计算托盘中的对象数量。 当我使用 SimpleBlobDetector 时,我不断得到一个特定的关键点,该关键
在OpenCV的SimpleBlobDetector中有一个minRepeatability参数。这个参数有什么用。如果我将它从 1 变为 20,它会如何影响 blob 检测? 最佳答案 相关代码在b
我正在尝试使用一些简单的代码来运行 blob 检测: img = cv2.imread(args["image"]) height, width, channels = img.shape param
我正在使用 opencv 中的 simpleblobdetector 和 python 来识别图像中的 Blob 。 我能够让简单的 Blob 检测器工作,并为我提供已识别 Blob 的位置。但是我也
我是一名优秀的程序员,十分优秀!