在光线良好且无遮挡的情况下,k230对倾斜的二维码识别率低

Viewed 69

问题描述


k230对倾斜的二维码识别率低,使用过img.rotation_corr函数进行旋转矫正但是没有效果

复现步骤


try:
# 构造一个具有默认配置的摄像头对象
sensor = Sensor(id=sensor_id)
# 重置摄像头sensor
sensor.reset()

# 无需进行镜像翻转
# 设置水平镜像
sensor.set_hmirror(True)
# 设置垂直翻转
sensor.set_vflip(True)

# 设置通道0的输出尺寸
sensor.set_framesize(width=picture_width, height=picture_height, chn=CAM_CHN_ID_0)
# 设置通道0的输出像素格式为GRAYSCALE(灰度)
sensor.set_pixformat(Sensor.GRAYSCALE, chn=CAM_CHN_ID_0)
#sensor.set_pixformat(Sensor.RGB565, chn=CAM_CHN_ID_0)

# 根据模式初始化显示器
if DISPLAY_MODE == "VIRT":
    Display.init(Display.VIRT, width=DISPLAY_WIDTH, height=DISPLAY_HEIGHT, fps=60)
elif DISPLAY_MODE == "LCD":
    Display.init(Display.ST7701, width=DISPLAY_WIDTH, height=DISPLAY_HEIGHT, to_ide=True)
elif DISPLAY_MODE == "HDMI":
    Display.init(Display.LT9611, width=DISPLAY_WIDTH, height=DISPLAY_HEIGHT, to_ide=True)

# 初始化媒体管理器
MediaManager.init()
# 启动传感器
sensor.run()

# 创建一个FPS计时器,用于实时计算每秒帧数
fps = time.clock()

while True:
    os.exitpoint()
    # 更新FPS计时
    fps.tick()

    # 捕获通道0的图像
    img = sensor.snapshot(chn=CAM_CHN_ID_0)
    img.rotation_corr(x_rotation=15,y_rotation=-40)

    # 遍历捕获到的所有条形码
    for code in img.find_qrcodes():
        # 在图像上绘制条形码矩形框
        rect = code.rect()
        img.draw_rectangle([v for v in rect], color=(255, 0, 0), thickness = 5)
        # 打印条形码信息
        img.draw_string_advanced(rect[0], rect[1], 32, code.payload())
        print(code)
    # 显示捕获的图像,中心对齐,居中显示
    Display.show_image(img)

except KeyboardInterrupt as e:
print("用户停止: ", e)
except BaseException as e:
print(f"异常: {e}")
finally:
# 停止传感器运行
if isinstance(sensor, Sensor):
sensor.stop()
# 反初始化显示模块
Display.deinit()
os.exitpoint(os.EXITPOINT_ENABLE_SLEEP)
time.sleep_ms(100)
# 释放媒体缓冲区
MediaManager.deinit()

硬件板卡


庐山派

软件版本


CanMV v1.2.2

1 Answers

弄好,请问一下更新到1.4版本的固件会不会导致1.3版本的代码和aicube模型不能运行

不会,1.4没升级nncase

你好,更新了固件后二维码可以正常识别了,但是串口不能正常使用了,使用的是原来1.3版本的代码