Example: 05-Feature-Detection/keypoints_save.py

# 本作品采用MIT许可证授权。
# 版权所有 (c) 2013-2023 OpenMV LLC。保留所有权利。
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# 关键点描述符示例
# 本示例展示如何将关键点描述符保存至文件。向摄像头展示物体
# 后运行脚本。脚本将提取并保存关键点描述符及对应图像
# 可使用keypoints_editor.py工具移除不需要的关键点
import sensor
import time
import image

# 重置传感器
sensor.reset()

# 传感器设置
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)

FILE_NAME = "desc"
img = sensor.snapshot()
# 注意:其他参数请参阅文档
# 注意:默认情况下find_keypoints会返回从图像金字塔中提取的多尺度关键点
kpts = img.find_keypoints(max_keypoints=150, threshold=10, scale_factor=1.2)

if kpts is None:
    raise (Exception("Couldn't find any keypoints!"))

image.save_descriptor(kpts, "/%s.orb" % (FILE_NAME))
img.save("/%s.pgm" % (FILE_NAME))

img.draw_keypoints(kpts)
sensor.snapshot()
time.sleep_ms(1000)

raise (Exception("Please reset the camera to see the new file."))

results matching ""

    No results matching ""