透视校正
# 本作品采用MIT许可证授权。
# 版权所有 (c) 2013-2023 OpenMV LLC。保留所有权利。
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# 透视校正
#
# 此示例展示了如何使用rotation_corr()来修正因OpenMV Cam安装方式
# 引起的透视问题。
import csi
import time
csi0 = csi.CSI()
csi0.reset()
csi0.pixformat(csi.RGB565)
csi0.framesize(csi.QVGA)
csi0.snapshot(time=2000)
clock = time.clock()
# 图像将被扭曲,使得以下点成为新的:
#
# (0, 0)
# (w-1, 0)
# (w-1, h-1)
# (0, h-1)
#
# 试着将下面的点设置为视野中一个四边形的
# 四个角(按顺时针顺序)。您可以
# 通过在帧缓冲区上点击并拖动
# 记录直方图部件中显示的值。
w = csi0.width()
h = csi0.height()
TARGET_POINTS = [
(0, 0), # (x, y) 请修改此处!
(w - 1, 0), # (x, y) 请修改此处!
(w - 1, h - 1), # (x, y) 请修改此处!
(0, h - 1),
] # (x, y) 请修改此处!
while True:
clock.tick()
img = csi0.snapshot().rotation_corr(corners=TARGET_POINTS)
print(clock.fps())