这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » 活动中心 » 板卡试用 » 【ArduinoNiclaVision】成果贴-图像识别

共1条 1/1 1 跳转至

【ArduinoNiclaVision】成果贴-图像识别

助工
2026-01-05 17:59:03     打赏

一、硬件介绍

Arduino Nicla Vision 是一款设计紧凑、功能强大的机器视觉边缘计算开发板,它将高性能处理能力与丰富的传感功能集成在一起,非常适合在资源受限的设备端直接进行图像分析和人工智能推理。板载的 200万像素 彩色摄像头(GC2145传感器)能够捕获清晰的图像,为机器视觉任务提供基础,板卡还集成了多个传感器:6轴IMU(LSM6DSOX)、数字麦克风(MP34DT06)、ToF距离传感器(VL53L1CBV0FY)

ruimage.png

二、功能介绍

本次项目使用openmv试下一个图像识别的功能。数据集使用了两组数据:向日葵和玫瑰。

通过平台edgeimpulse 进行数据解析和建模训练。最后生成openmv固件,用于直接测试和使用。

三、功能实现

建项目,并导入数据,选择调试的目标设备。

1767605652332764.png

1767606201787260.png

导入数据后通过选中图片调整训练和测试的比例,如下

1767606030378072.png

创建impulse,如下图所示

选择image和transfer leaning模块,点击 save impulse按钮,生成impulse。

1767606159967539.png

分别点击image和transfer learning 模块,生成数据特征,和选择模型对数据进行训练。

1767606429959325.png

选择可以根据板卡的空间,选择相应的训练模型,防止编译失败

我选了,选v2版本,总出现nicla编译固件失败,更换了模型,空间需求少了,但是准确率下降挺多,会认错图像。

image.png

最后生成一份固件

1767606681534460.png

通过openmv ide 烧写固件,选中nicla的固件

1767606778627043.png

稍晚完毕后,打开代码:ei_image_classification.py

修改代码,把识别结果写道图像上。

四、代码编写

# Edge Impulse - OpenMV Image Classification Example
#
# This work is licensed under the MIT license.
# Copyright (c) 2013-2024 OpenMV LLC. All rights reserved.
# https://github.com/openmv/openmv/blob/master/LICENSE

import sensor
import time
import ml

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.

model = ml.Model("trained")#mobilenet, load_to_fb=True)

clock = time.clock()
while True:
    clock.tick()
   # time.sleep_ms(500)
    img = sensor.snapshot()

    print("**********\nPredictions for each class")
    # This combines the labels and confidence values into a list of tuples
    # and then sorts that list by the confidence values.
    sorted_list = sorted(
        zip(model.labels, model.predict([img])[0].flatten().tolist()), key=lambda x: x[1], reverse=True
    )
    max_val = sorted_list[0][1]
    max_lbl = sorted_list[0][0]


    #for i in range(len(sorted_list)):
       # print("%s = %f" % (sorted_list[i][0], sorted_list[i][1]))
    print("{} with a prob of {:.2f}".format(max_lbl, max_val))
    if max_val < 0.5:
        max_lbl = 'uncertain'

    img.draw_string(
        10, 10,
        max_lbl + "\n{:.2f}".format(max_val),
        mono_space = False,
        scale=3
    )
    print(clock.fps(), "fps")

五、效果演示

六、心得体会

Arduino Nicla Vision板卡设计紧凑,外设丰富,性能强劲,非常适合学习用。通过本次活动,学习到了edgeimpulse平台的开发流程,增加自己的未知区域的了解。

感谢eepw 提供的活动,能够学习到更多好东西,希望平台越办越好,板卡质量越来越高。加油








关键词: ArduinoNiclaVision     成果     识别         

共1条 1/1 1 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]