多特征点识别时提示错误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!
-
你好,我想请问一下你在前文定义的kernel是有什么作用吗?
-
-
@kidswong999 感觉你在卖队友哈哈哈
-
应该是先利用img.morph对图像进行了卷积运算。