例程讲解-03-keypoints_drawing绘制特征点

# 绘制特征点
#
# 此示例显示了OpenMV Cam上的绘制关键点。
# 通常你在一个关键点对象上调用draw_keypoints(),但你也可以在一个三值元组的列表上调用它...

import sensor, image, time, pyb

sensor.reset()
sensor.set_pixformat(sensor.RGB565) # or GRAYSCALE...
sensor.set_framesize(sensor.QVGA) # or QQVGA...
sensor.skip_frames(time = 2000)
clock = time.clock()

while(True):
    clock.tick()

    img = sensor.snapshot()

    for i in range(20):
        x = (pyb.rng() % (2*img.width())) - (img.width()//2)
        y = (pyb.rng() % (2*img.height())) - (img.height()//2)
        rot = pyb.rng() % 360

        r = (pyb.rng() % 127) + 128
        g = (pyb.rng() % 127) + 128
        b = (pyb.rng() % 127) + 128

        # 此方法绘制关键点对象或(x,y,rot)元组列表...
        img.draw_keypoints([(x, y, rot)], color = (r, g, b), size = 20, thickness = 2, fill = False)

    print(clock.fps())

results matching ""

    No results matching ""