logo

04-ulab ulab数学操作返回错误'module' object has no attribute 'array'

2021-04-18 12:13
U
_3vpc
import sensor, image, time, ulab as np

sensor.reset()                      # 复位并初始化传感器

sensor.set_pixformat(sensor.GRAYSCALE) # Set pixel format to RGB565 (or GRAYSCALE)
#设置图像色彩格式,有RGB565色彩图和GRAYSCALE灰度图两种

sensor.set_framesize(sensor.QQVGA)   # 将图像大小设置为 (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)))

返回的错误

File "<stdin>", line 13, in <module>

AttributeError: 'module' object has no attribute 'array'

固件版本为最新3.9.4

3b49cc9b-2668-4c0d-b066-0a80b8c815a6.png
2021-04-18 17:39
I
网红小智智 星瞳科技

更改为:

import sensor, image, time
from ulab import numpy as np
sensor.reset()                          # Reset and initialize the sensor.
sensor.set_pixformat(sensor.GRAYSCALE)  # Set pixel format to RGB565 (or GRAYSCALE)
sensor.set_framesize(sensor.QQVGA)      # Set frame size to QVGA (320x240)
clock = time.clock()                    # Create a clock object to track the FPS.

while (True):
    img = sensor.snapshot()         # Take a picture and return the image.
    a = np.array(img, dtype=np.uint8)
    print("mean: %d std:%d"%(np.mean(a), np.std(a)))
2021-04-18 17:54
I
网红小智智 星瞳科技

PR:https://github.com/openmv/openmv/pull/1268

2021-04-18 19:00
U
_3vpc

@kidswong999 好的 谢谢