Example: 02-Image-Processing/00-Drawing/image_drawing.py

# 本作品采用MIT许可证授权。
# 版权所有 (c) 2013-2023 OpenMV LLC。保留所有权利。
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# 绘制图像示例
#
# 这个示例展示了如何在帧缓冲区中绘制图像。

import sensor
import time
import image

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()
    small_img = img.scale(x_scale=0.25, y_scale=0.25, hint=image.AREA, copy=True)

    x = (img.width() // 2) - (small_img.width() // 2)
    y = (img.height() // 2) - (small_img.height() // 2)
    # 在帧缓冲区中绘制图像。传递一个可选的
    # 遮罩图像以控制绘制哪些像素。
    img.draw_image(small_img, x, y, x_scale=1, y_scale=1)

    print(clock.fps())

results matching ""

    No results matching ""