flood_fill.py

# 本作品采用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.RGB565)  # 或GRAYSCALE...
csi0.framesize(csi.QVGA)  # 或QQVGA...
csi0.snapshot(time=2000)

clock = time.clock()

while True:
    clock.tick()

    # seed_threshold控制初始像素与填充像素间
    # 允许的最大差异。关键在于
    # 设置此值,使泛洪填充不会填满整幅图像。

    # floating_threshold控制任意两个像素之间
    # 允许的最大差值。即使阈值很低,
    # 它也很容易填满整幅图像。

    # flood_fill会填充同时满足两个阈值的像素。

    # 您可以用“invert”反转填充的内容,并用“clear_background”
    # 清除填充区域以外的所有内容。

    img = csi0.snapshot().flood_fill(
        (csi0.width() // 2, csi0.height() // 2),
        seed_threshold=0.05,
        floating_threshold=0.05,
        color=(255, 0, 0),
        invert=False,
        clear_background=False,
    )

    print(clock.fps())

results matching ""

    No results matching ""