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

# 本作品采用MIT许可证授权。
# Copyright (c) 2013-2026 OpenMV LLC. All rights reserved.
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# Log Polar Mapping Off-Center Example
#
# 本示例展示了通过对数极坐标变换对图像进行
# transformation centered on a user-specified point rather than the
# image center. This is useful when the optical axis of the lens does
# not align with the sensor center (e.g. a fisheye lens mounted with
# an offset adapter), so the polar transform can be re-centered on the
# true optical center.
#
# Pass `x` and `y` keyword arguments to set the polar center. Both
# default to the image center when omitted.

import csi
import time

csi0 = csi.CSI()
csi0.reset()  # 初始化相机传感器。
csi0.pixformat(csi.RGB565)  # or csi.GRAYSCALE
csi0.framesize(csi.QQVGA)  # or csi.QVGA (or others)
csi0.snapshot(time=2000)  # 让新设置生效。

# Center the polar transform 20 pixels to the right and 10 pixels down
# from the sensor center. Tune these for your lens.
CENTER_X_OFFSET = 20
CENTER_Y_OFFSET = 10

clock = time.clock()  # 跟踪FPS。

while True:
    clock.tick()  # Track elapsed milliseconds between snapshots().
    img = csi0.snapshot()
    cx = (img.width() // 2) + CENTER_X_OFFSET
    cy = (img.height() // 2) + CENTER_Y_OFFSET
    img.logpolar(reverse=False, x=cx, y=cy)

    print(clock.fps())  # 注意:您的 OpenMV Cam 在连接到
    # 计算机时运行速度会减半。断开连接后,FPS 应该会增加。

results matching ""

    No results matching ""