图像直方图信息示例

# 本作品采用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)  # 或RGB565。
csi0.framesize(csi.QVGA)
csi0.snapshot(time=2000)
csi0.auto_gain(False)  # 必须关闭以进行颜色跟踪
csi0.auto_whitebal(False)  # 必须关闭以进行颜色跟踪

clock = time.clock()

while True:
    clock.tick()
    img = csi0.snapshot()
    # 将图像的灰度直方图分为8个bin。
    # bin默认为256,可以在2到256之间。
    print(img.get_histogram(bins=8))
    print(clock.fps())

# 您还可以传递 get_histogram() 一个 "roi=" 来获取该区域的直方图。
# get_histogram() 允许您快速确定图像的颜色通道信息。
# 图像中的任何区域。

results matching ""

    No results matching ""