logo

我的神经网络nn报错,是没有这个模块?

2023-04-24 10:44
8
rnm2
7fefb176-c609-475e-b6e1-f56c3e61e7e0.jpg

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

sensor.set_pixformat(sensor.RGB565) # Set pixel format to RGB565 (or GRAYSCALE)

#设置图像色彩格式,有RGB565色彩图和GRAYSCALE灰度图两种

sensor.set_framesize(sensor.QVGA) # 将图像大小设置为QVGA (320x240)

sensor.set_windowing((128, 128)) # 设置128 x128窗口。

sensor.skip_frames(time=750) # 不要让自动增益运行太长时间。

sensor.set_auto_gain(False) # 关掉自动增益。

sensor.set_auto_exposure(False) # 关掉自动曝光。

# 加载cifar10网络。OpenMV3 M7上使用此网络可能会超出内存。

#net = nn.load('/cifar10.network')

net = nn.load('/cifar10_fast.network')

labels = ['airplane', 'automobile', 'bird', 'cat', 'deer', 'dog', 'frog', 'horse', 'ship', 'truck']

clock = time.clock()

while(True):

clock.tick()

img = sensor.snapshot()

for obj in net.search(img, threshold=0.6, min_scale=0.4, scale_mul=0.8, \

x_overlap=-1, y_overlap=-1, contrast_threshold=0.5):

print("Detected %s - Confidence %f%%" % (labels[obj.index()], obj.value()))

img.draw_rectangle(obj.rect(), color=(255, 0, 0))

print(clock.fps())