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

# 本作品采用MIT许可证授权。
# 版权所有 (c) 2013-2023 OpenMV LLC。保留所有权利。
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# Midpoint Adaptive Threshold Filter Example
#
# This example shows off midpoint filtering with adaptive thresholding.
# When midpoint(threshold=True) the midpoint() method adaptive thresholds the image
# by comparing the midpoint 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. The "bias" argument
    # lets you select between min and max blending. 0.5 == midpoint filter,
    # 0.0 == min filter, and 1.0 == max filter. Note that the min filter
    # makes images darker while the max filter makes images lighter.
    img.midpoint(1, bias=0.5, threshold=True, offset=5, invert=True)

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

results matching ""

    No results matching ""