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

# 本作品采用MIT许可证授权。
# 版权所有 (c) 2013-2023 OpenMV LLC。保留所有权利。
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# 均值自适应阈值滤波示例
#
# 此示例展示了带有自适应阈值的均值滤波。
# When mean(threshold=True) the mean() method adaptive thresholds the image
# by comparing the mean of the pixels around a pixel, minus an offset, with that pixel.

import sensor
import time

sensor.reset()  # 初始化相机传感器。
sensor.set_pixformat(sensor.RGB565)  # 或 sensor.GRAYSCALE
sensor.set_framesize(sensor.QQVGA)  # 或 sensor.QVGA(或其他)
sensor.skip_frames(time=2000)  # 让新设置生效。
clock = time.clock()  # 跟踪FPS。

while True:
    clock.tick()  # Track elapsed milliseconds between snapshots().
    img = sensor.snapshot()  # 拍照并返回图像。

    # The first argument is the kernel size. N corresponds to a ((N*2)+1)^2
    # kernel size. E.g. 1 == 3x3 kernel, 2 == 5x5 kernel, etc. Note: You
    # shouldn't ever need to use a value bigger than 2.
    img.mean(1, threshold=True, offset=5, invert=True)

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

results matching ""

    No results matching ""