Update ulab.py

This commit is contained in:
王开智 2021-04-18 17:52:23 +08:00 committed by GitHub
parent aef64ab673
commit 8da5a21b60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,8 +4,8 @@
# NOTE: ndarrays cause the heap to be fragmented easily. If you run out of memory, # NOTE: ndarrays cause the heap to be fragmented easily. If you run out of memory,
# there's not much that can be done about it, lowering the resolution might help. # there's not much that can be done about it, lowering the resolution might help.
import sensor, image, time, ulab as np import sensor, image, time
from ulab import numerical from ulab import numpy as np
sensor.reset() # Reset and initialize the sensor. sensor.reset() # Reset and initialize the sensor.
sensor.set_pixformat(sensor.GRAYSCALE) # Set pixel format to RGB565 (or GRAYSCALE) sensor.set_pixformat(sensor.GRAYSCALE) # Set pixel format to RGB565 (or GRAYSCALE)
@ -15,4 +15,5 @@ clock = time.clock() # Create a clock object to track the FPS
while (True): while (True):
img = sensor.snapshot() # Take a picture and return the image. img = sensor.snapshot() # Take a picture and return the image.
a = np.array(img, dtype=np.uint8) a = np.array(img, dtype=np.uint8)
print("mean: %d std:%d"%(numerical.mean(a), numerical.std(a))) print("mean: %d std:%d"%(np.mean(a), np.std(a)))