Example: 02-Image-Processing/00-Drawing/flood_fill.py

# 本作品采用MIT许可证授权。
# 版权所有 (c) 2013-2023 OpenMV LLC。保留所有权利。
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# Flood Fill
#
# 此示例展示图像中的区域泛洪填充

import sensor
import time

sensor.reset()
sensor.set_pixformat(sensor.RGB565)  # or GRAYSCALE...
sensor.set_framesize(sensor.QVGA)  # or QQVGA...
sensor.skip_frames(time=2000)
clock = time.clock()

while True:
    clock.tick()

    # seed_threshold控制初始像素与填充像素间
    # 允许的最大差异。关键在于
    # set this such that flood fill doesn't fill the whole image.

    # floating_threshold controls the maximum allowed difference
    # between any two pixels. This can easily fill the whole image
    # with even a very low threshold.

    # flood_fill will fill pixels that both thresholds.

    # You can invert what gets filled with "invert" and clear
    # everything but the filled area with "clear_background".

    x = sensor.width() // 2
    y = sensor.height() // 2
    img = sensor.snapshot().flood_fill(
        x,
        y,
        seed_threshold=0.05,
        floating_thresholds=0.05,
        color=(255, 0, 0),
        invert=False,
        clear_background=False,
    )

    print(clock.fps())

results matching ""

    No results matching ""