能不能使用RGB模式来识别?
V
vysq 发布的帖子
-
为什么此代码设置RGB模式不能正确识别数字?
# 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模式 的时候无法正确识别数字,只有设置成灰度的时候才能识别数字
-
为什么会出现错误OSError:0,是我代码错了还是买到盗版openmv了,我都是按着视频操作来的
Edge Impulse - OpenMV Image Classification Example
import sensor, image, time, os, tf
sensor.reset() # Reset and initialize the sensor.
sensor.set_pixformat(sensor.RGB565) # Set pixel format to RGB565 (or GRAYSCALE)
sensor.set_framesize(sensor.QVGA) # Set frame size to QVGA (320x240)
sensor.set_windowing((240, 240)) # Set 240x240 window.
sensor.skip_frames(time=2000) # Let the camera adjust.net = "trained.tflite"
labels = [line.rstrip('\n') for line in open("labels.txt")]clock = time.clock()
while(True):
clock.tick()img = sensor.snapshot() # default settings just do one detection... change them to search the image... for obj in tf.classify(net, img, min_scale=1.0, scale_mul=0.8, x_overlap=0.5, y_overlap=0.5): print("**********\nPredictions at [x=%d,y=%d,w=%d,h=%d]" % obj.rect()) img.draw_rectangle(obj.rect()) # This combines the labels and confidence values into a list of tuples predictions_list = list(zip(labels, obj.output())) for i in range(len(predictions_list)): print("%s = %f" % (predictions_list[i][0], predictions_list[i][1])) print(clock.fps(), "fps")