核滤波示例

# 本作品采用MIT许可证授权。
# 版权所有 (c) 2013-2023 OpenMV LLC。保留所有权利。
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# 核滤波示例
#
# 本示例展示了如何使用通用内核过滤器。

import csi
import time

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

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

kernel_size = 1  # 3x3==1, 5x5==2, 7x7==3, 以此类推

kernel = [-2, -1, 0, -1, 1, 1, 0, 1, 2]

while True:
    clock.tick()  # 跟踪snapshots()之间经过的毫秒数。
    img = csi0.snapshot()  # 拍照并返回图像。

    # 在图像的每个像素上运行内核。
    img.morph(kernel_size, kernel)

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

results matching ""

    No results matching ""