Example: 02-Image-Processing/01-Image-Filters/perspective_correction.py

# 本作品采用MIT许可证授权。
# 版权所有 (c) 2013-2023 OpenMV LLC。保留所有权利。
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# 透视校正
#
# 此示例展示了如何使用rotation_corr()来修正因OpenMV Cam安装方式
# 引起的透视问题。

import sensor
import time

sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time=2000)
clock = time.clock()

# 图像将被扭曲,使得以下点成为新的:
#
#   (0,   0)
#   (w-1, 0)
#   (w-1, h-1)
#   (0,   h-1)
#
# Try setting the points below to the corners of a quadrilateral
# (in clock-wise order) in the field-of-view. You can get points
# 通过在帧缓冲区上点击并拖动
# 记录直方图部件中显示的值。

w = sensor.width()
h = sensor.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 = sensor.snapshot().rotation_corr(corners=TARGET_POINTS)

    print(clock.fps())

results matching ""

    No results matching ""