首页 > 解决方案 > 从列表中删除 cv2.KeyPoint 对象

问题描述

我正在尝试检测图像中的某些圆圈。我确实设法检测到所有圈子,但是当我尝试删除其中一些时,它失败了。

# Detect blobs
keypoints = detector.detect(image) # creates list with elements of the class cv2.KeyPoint

print(len(keypoints)) # prints 263

for key in keypoints:
    if key.size > 50:
        keypoints.remove(key)

print(len(keypoints)) # prints 131

只有大约 20 个小于 50 的圆圈(我打印了每个圆圈的大小),所以我无法删除一半想要的元素。

我不知道为什么它不起作用,很想为你提供帮助

谢谢!

标签: python-3.xopencv-pythonopencv-contourkeypoint

解决方案


推荐阅读