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

# 本作品采用MIT许可证授权。
# 版权所有 (c) 2013-2023 OpenMV LLC。保留所有权利。
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# Ulab 是 MicroPython 中一个类似 numpy 的模块,旨在简化和加速对数组的常见
# 数学运算。此基础示例展示了图像上的均值与标准差计算。
#
# 注意:ndarrays 容易导致堆内存碎片化。如果内存不足,
# 除了降低分辨率可能有所帮助外,没有太多解决办法。

import sensor
import time
from ulab import numpy as np

sensor.reset()  # 重置并初始化传感器。
sensor.set_pixformat(sensor.GRAYSCALE)  # 将像素格式设置为RGB565 (or GRAYSCALE)
sensor.set_framesize(sensor.QQVGA)  # 将帧大小设置为QVGA (320x240)
clock = time.clock()  # 创建一个时钟对象来跟踪FPS。

while True:
    img = sensor.snapshot()  # 拍照并返回图像。
    a = np.array(img, dtype=np.uint8)
    print("mean: %d std:%d" % (np.mean(a), np.std(a)))

results matching ""

    No results matching ""