logo

为什么此代码设置RGB模式不能正确识别数字?

2021-12-19 22:48
Y
vysq
# Hello World Example
#
# Welcome to the OpenMV IDE! Click on the green run arrow button below to run the script!

import sensor, image, time,nn

sensor.reset()                      # Reset and initialize the sensor.
sensor.set_pixformat(sensor.GRAYSCALE) # Set pixel format to RGB565 (or GRAYSCALE)
sensor.set_framesize(sensor.QVGA)   # Set frame size to QVGA (320x240)
sensor.skip_frames(time = 100)     # Wait for settings take effect.
net = nn.load('/lenet.network')
labels = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']

clock = time.clock()                # 创建一个时钟对象来跟踪FPS帧率。
while(True):
    clock.tick()                    # 更新FPS帧率时钟。
    img = sensor.snapshot()         # 拍一张照片并返回图像。
    out = net.forward(img.copy().binary([(150, 255)], invert=True))
    max_idx = out.index(max(out))
    score = int(out[max_idx]*100)
    if (score < 70):
       score_str = "??:??"
    else:
       score_str = "%s:%d%% "%(labels[max_idx], score)
    img.draw_string(0, 0, score_str,color=(0,0,0))

    print(score)
    # 注意: 当连接电脑后,OpenMV会变成一半的速度。当不连接电脑,帧率会增加。
    #打印当前的帧率。

此代码的作用是识别数字,但是为什么我在识别数字的时候必须设置成灰度GRAYSCALE,不能用RGB565的模式输出,设置成RGB模式 的时候无法正确识别数字,只有设置成灰度的时候才能识别数字

Y
vysq

能不能使用RGB模式来识别?

2021-12-20 21:10
I
网红小智智 星瞳科技

cmsis-nn早就被删除了,不再更新代码。