小弟现在在做自动上货机器人,实现功能为从仓库取出物品并放到指定的货架上(货架必须是空的)。现在苦于如何识别出某个货架是空的,要上货的货架正面跟背面为打开状态,可以通过一面看到货架之后。
18158518365 发布的帖子
-
请问如何识别某个货架是空的?
-
多特征点识别时提示错误Descriptors have different types!
代码如下:
```
import sensor, time, imageReset sensor
sensor.reset()
Sensor settings
sensor.set_contrast(3)
sensor.set_gainceiling(16)
sensor.set_framesize(sensor.VGA)
sensor.set_windowing((320, 240))
sensor.set_pixformat(sensor.GRAYSCALE)sensor.skip_frames(time = 2000)
sensor.set_auto_gain(False, value=100)
sensor.set_brightness(-3)
clock = time.clock()
kernel_size = 1 # kernel width = (size2)+1, kernel height = (size2)+1
kernel = [-1, -1, -1,
-1, +9, -1,
-1, -1, -1]
def draw_keypoints(img, kpts):
print(kpts)
img.draw_keypoints(kpts)
img = sensor.snapshot()
time.sleep(1000)NOTE: uncomment to load a keypoints descriptor from file
kpts1 = image.load_descriptor("/SWW_F.orb")
kpts2 = image.load_descriptor("/SWW_R.orb")
img = sensor.snapshot()
img.morph(kernel_size, kernel)
draw_keypoints(img, kpts1)clock = time.clock()
while (True):
clock.tick()
img = sensor.snapshot()
img.morph(kernel_size, kernel)
if (kpts1 == None):
# NOTE: By default find_keypoints returns multi-scale keypoints extracted from an image pyramid.
kpts3 = img.find_keypoints(max_keypoints=150, threshold=10, scale_factor=1.2)
draw_keypoints(img, kpts1)
else:
# NOTE: When extracting keypoints to match the first descriptor, we use normalized=True to extract
# keypoints from the first scale only, which will match one of the scales in the first descriptor.
kpts3 = img.find_keypoints(max_keypoints=150, threshold=10, normalized=True)
if (kpts2):
match1 = image.match_descriptor(kpts1, kpts3, threshold=85)
match2 = image.match_descriptor(kpts2, kpts3, threshold=85)
if (match1.count()>12):
# If we have at least n "good matches"
# Draw bounding rectangle and cross.
img.draw_rectangle(match1.rect())
img.draw_cross(match1.cx(), match1.cy(), size=10)
if (match2.count()>12):
# If we have at least n "good matches"
# Draw bounding rectangle and cross.
img.draw_rectangle(match2.rect())
img.draw_cross(match2.cx(), match2.cy(), size=10)# NOTE: uncomment if you want to draw the keypoints #img.draw_keypoints(kpts2, size=KEYPOINTS_SIZE, matched=True) # Draw FPS img.draw_string(0, 0, "FPS:%.2f"%(clock.fps()))
运行一段时间内识别正常,一段时间后于“match1 = image.match_descriptor(kpts1, kpts3, threshold=85)”这句提示错误Descriptors have different types!
-
RE: 如何用OPENMV识别钢丝球?
你好,我的项目是通过OPENMV区分各种物品,除了钢丝球外还有很多需要识别的东西,你的方案在腐蚀膨胀后很多东西都一样,无法进行区分了,我现在通过二值化加锐化得到这张很有特征的图片,但特征点识别在这里也不好用,请问还有什么方法吗