vflip_hmirror_transpose.py

# 本作品采用MIT许可证授权。
# 版权所有 (c) 2013-2023 OpenMV LLC。保留所有权利。
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# 垂直翻转 - 水平镜像 - 转置
#
# 这个示例展示了如何垂直翻转、水平镜像或
# 转置图像。注意:
#
# vflip=False, hmirror=False, transpose=False -> 0度旋转
# vflip=True,  hmirror=False, transpose=True  -> 90度旋转
# vflip=True,  hmirror=True,  transpose=False -> 180度旋转
# vflip=False, hmirror=True,  transpose=True  -> 270度旋转

import csi
import time
import image

csi0 = csi.CSI()
csi0.reset()
csi0.pixformat(csi.RGB565)
csi0.framesize(csi.QVGA)
csi0.snapshot(time=2000)

clock = time.clock()

ticks = time.ticks_ms()
counter = 0

while True:
    clock.tick()

    # 你也可以使用 image.ROTATE_180, image.ROTATE_90, image.ROTATE_270 等。
    vflip = image.VFLIP if (counter // 2) % 2 else 0
    hmirror = image.HMIRROR if (counter // 4) % 2 else 0
    transpose = image.TRANSPOSE if (counter // 8) % 2 else 0
    img = csi0.snapshot().scale(hint=(vflip | hmirror | transpose))

    if time.ticks_diff(time.ticks_ms(), ticks) > 1000:
        ticks = time.ticks_ms()
        counter += 1

    print(clock.fps())

results matching ""

    No results matching ""