选中内容(绿色)时除了会搜索文章名,还会搜索文章内容
点击结果中的文章名进入文章界面后可以按Ctrl+F在页面内搜索
  • 版权:CC BY-SA 4.0
  • 创建:2021-11-05
  • 更新:2021-11-06
V831使用AI 检测卡片速成教程 ,使用 V831 检测数字卡片(2021电赛F题智能送药小车数字识别)的一种方法


V831的效果:

K210的效果:

两个模型都有个缺点就是 1 容易识别成4, k210的模型识别远距离也不太行, v831的效果好些,总体比较粗糙了,但是也许你能用

k210的教程不在这里说了可以看这里: https://neucrack.com/p/325
K210的模型这里自取: 链接: https://pan.baidu.com/s/1mhpn1sUlG9KGfaZ9xq3pIg 提取码: cimy ,
k210的模型文件使用:板子确保先烧录了固件,然后把所有文件放到SD 卡根目录,包括代码和模型都在里面了,上电就可以看到效果了

下面是 V831 的上手教程(注意不是k210的! k210的到这里就结束辣!!!!):

首先需要一个开发板

淘宝购买: https://item.taobao.com/item.htm?spm=a1z10.1-c-s.w4004-24053782153.4.21f952b1lCLyEk&id=635874427363

买全功能套餐, 有摄像头和屏幕

另外你需要一个 type-c 线(套餐应该有,问客服)

烧录镜像

按照文档烧录: https://wiki.sipeed.com/hardware/zh/maixII/M2/flash.html

文档内容主要是下载镜像: https://dl.sipeed.com/shareURL/MaixII/MaixII-Dock/SDK/release , 系统密码是123,用户名是root, 然后按照文档用读卡器+PhoenixCard 烧录就好了

启动系统

  • 使用 type-c 线连接板子的 USB-UART 接口, 注意不是USB-OTG接口, 如上面封面图所示, 屏幕右下角的接口

  • 然后使用串口终端, 比如 putty , 选择串口连接, 输入串口号,串口号可以在资源管理器看到

putty

  • 修改 wifi SSID 和密码以连接wifi

手动修改

  1. vim /etc/wpa_supplicant.conf

然后最简单的方法,直接重启生效

  1. reboot

或者执行一键配置脚本:

  1. maixpy3_config.py

然后可以看到板子的 ip 地址,比如192.168.0.37

  1. ifconfig

下载模型文件

maixhub下载模型(需要注册登录)

或者百度云:

链接: https://pan.baidu.com/s/1mhpn1sUlG9KGfaZ9xq3pIg 提取码: cimy

会得到两个文件, 一个number_awnn.param和一个number_awnn.bin

下载源代码

使用如下源代码(复制后需要删掉后面的版权信息才能运行), 保存为文件run.py

注意, 复制代码要保证空格不要丢失,不然会无法运行, python 依靠缩进而不是大括号分段

  1. from maix import nn
  2. from PIL import Image, ImageDraw, ImageFont
  3. from maix import display, camera
  4. import time
  5. from maix.nn import decoder
  6. def draw_rectangle_with_title(draw, box, disp_str, bg_color=(255, 0, 0, 255), font_color=(255, 255, 255, 255)):
  7. # draw = ImageDraw.Draw(img)
  8. font = ImageFont.load_default()
  9. font_w, font_h = font.getsize(disp_str)
  10. draw.rectangle((box[0], box[1], box[0] + box[2], box[1] + box[3]), fill=None, outline=bg_color, width=2)
  11. draw.rectangle((box[0], box[1] - font_h, box[0] + font_w, box[1]), fill=bg_color)
  12. draw.text((box[0], box[1] - font_h), disp_str, fill=font_color, font=font)
  13. camera.config(size=(224, 224))
  14. labels = ["1", "2", "3", "4", "5", "6", "7", "8"]
  15. anchors = [2.44, 2.25, 5.03, 4.91, 3.5 , 3.53, 4.16, 3.94, 2.97, 2.84]
  16. model = {
  17. "param": "/root/number_awnn.param",
  18. "bin": "/root/number_awnn.bin"
  19. }
  20. options = {
  21. "model_type": "awnn",
  22. "inputs": {
  23. "input0": (224, 224, 3)
  24. },
  25. "outputs": {
  26. "output0": (7, 7, (1+4+len(labels))*5)
  27. },
  28. "mean": [127.5, 127.5, 127.5],
  29. "norm": [0.0078125, 0.0078125, 0.0078125],
  30. }
  31. print("-- load model:", model)
  32. m = nn.load(model, opt=options)
  33. print("-- load ok")
  34. w = options["inputs"]["input0"][1]
  35. h = options["inputs"]["input0"][0]
  36. yolo2_decoder = decoder.Yolo2(len(labels), anchors, net_in_size=(w, h), net_out_size=(7, 7))
  37. while 1:
  38. t = time.time()
  39. img = camera.capture()
  40. if not img:
  41. time.sleep(0.01)
  42. continue
  43. print("-- capture: ", time.time() - t )
  44. t = time.time()
  45. out = m.forward(img, quantize=True, layout="hwc")
  46. print("-- forward: ", time.time() - t )
  47. t = time.time()
  48. boxes, probs = yolo2_decoder.run(out, nms=0.3, threshold=0.5, img_size=(240, 240))
  49. print("-- decode: ", time.time() - t )
  50. t = time.time()
  51. for i, box in enumerate(boxes):
  52. class_id = probs[i][0]
  53. prob = probs[i][1][class_id]
  54. disp_str = "{}:{:.2f}%".format(labels[class_id], prob*100)
  55. draw_rectangle_with_title(display.get_draw(), box, disp_str)
  56. print("-- draw: ", time.time() - t )
  57. t = time.time()
  58. display.show()
  59. print("-- show: ", time.time() - t )

上传文件到开发板内的文件系统

系统密码是123,用户名是root (密码默认可能没有)

linux 直接使用 scp命令拷贝;
windows需要使用winscp传输文件, 不会使用请自行搜索

将上面的三个文件传输到/root/目录下

winscp_connect

执行识别程序

  1. cd /root
  2. python run.py

就可以看到屏幕显示图像, 摄像头对准卡片就可以识别到卡片了

开机自启

  1. vim /etc/init.d/S02app

start)部分添加

  1. case "$1" in
  2. start)
  3. echo "Starting app..."
  4. (cd /root && python run.py > /dev/null 2>&1 &)
  5. ;;

自定义程序

修改/root/run.py即可

如果需要使用串口输出信息,参考这里: https://wiki.sipeed.com/soft/maixpy3/zh/usage/hardware/UART.html

这个串口示例的硬件接口是板子上的G6G7

文章有误?有想法想讨论?查看或者发起勘误/讨论 主题
(发起评论需要先登录 github)

/wallpaper/wallhaven-737jo3.jpg