【DigiKey创意大赛】自助计价系统+项目汇总提交
[复制链接]
自助计价系统
作者:奇迹12
一、作品简介
本项目是基于seeed的wio lite ai板卡设计的一款具有智能识别食物类型,智能计价的自助计价系统。本设备运行本地神经网络识别,无需联网。用户将取好的餐盘放到设备下面,摄像头会自动采集图像,识别出来餐盘里面的食物类型,并自动计算价格。
二、系统框图
设计思路:
本设计主要有四个阶段构成:
1.图像采集,这里我使用部分网上数据集与自己拍摄的图像作为训练数据集,主要数据以网上数据为主。
2.模型训练量化,使用ST提供的工具进行。
3.驱动开发。
4.模型部署。
硬件介绍:
Seeed Studio Wio Lite AI单板是一款功能强大的AI视觉开发板,基于STM32H725AE芯片。STM32H725AE芯片是一款Arm® Cortex®-M7 32位550MHz高性能微处理器。Cortex-M7内核具有浮点单元 (FPU) 精度,支持Arm双精度(符合IEEE 754标准)和单精度数据处理指令与类型。
Seeed Studio Wio Lite AI单板具有16MB SPI NOR闪存、8MB PSRAM、双频2.4GHz/5GHz Wi-Fi和蓝牙® 5.1。Wio Lite板设有一个40引脚FPC端口(用于LCD RGB565或RGB888 )和一个24引脚FPC端口(用于DCMI摄像头)。得益于这些特性和端口,该板成为视觉项目的高性价比解决方案。此外,在这个套件包含 200万像素的 DCMI 摄像头和2.8英寸电阻触摸屏 RGB LCD,这使得很容易设计一个视觉项目。
硬件框图:
软件流程图:
三、各部分功能说明
部署模型:
主要代码:
1.显示初始化
-
- HAL_GPIO_WritePin(GPIOG, GPIO_PIN_5, GPIO_PIN_RESET);
- HAL_Delay(10);
- HAL_GPIO_WritePin(GPIOG, GPIO_PIN_5, GPIO_PIN_SET);
- HAL_Delay(10);
- HAL_GPIO_WritePin(GPIOF, GPIO_PIN_5, GPIO_PIN_SET);
-
- HAL_Delay(100);
-
- ST7789V_Init();
-
-
- LTDC_LayerCfgTypeDef pLayerCfg = {0};
-
-
-
-
- hltdc.Instance = LTDC;
- hltdc.Init.HSPolarity = LTDC_HSPOLARITY_AL;
- hltdc.Init.VSPolarity = LTDC_VSPOLARITY_AL;
- hltdc.Init.DEPolarity = LTDC_DEPOLARITY_AL;
- hltdc.Init.PCPolarity = LTDC_PCPOLARITY_IPC;
- hltdc.Init.HorizontalSync = 9;
- hltdc.Init.VerticalSync = 3;
- hltdc.Init.AccumulatedHBP = 19;
- hltdc.Init.AccumulatedVBP = 5;
- hltdc.Init.AccumulatedActiveW = 259;
- hltdc.Init.AccumulatedActiveH = 325;
- hltdc.Init.TotalWidth = 297;
- hltdc.Init.TotalHeigh = 327;
- hltdc.Init.Backcolor.Blue = 0;
- hltdc.Init.Backcolor.Green = 0;
- hltdc.Init.Backcolor.Red = 0;
- if (HAL_LTDC_Init(&hltdc) != HAL_OK)
- {
- Error_Handler();
- }
- pLayerCfg.WindowX0 = 0;
- pLayerCfg.WindowX1 = 240;
- pLayerCfg.WindowY0 = 0;
- pLayerCfg.WindowY1 = 320;
- pLayerCfg.PixelFormat = LTDC_PIXEL_FORMAT_RGB565;
- pLayerCfg.Alpha = 255;
- pLayerCfg.Alpha0 = 0;
- pLayerCfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_PAxCA;
- pLayerCfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_PAxCA;
- pLayerCfg.FBStartAdress = (uint32_t)LCD_BUFFER;
- pLayerCfg.ImageWidth = 240;
- pLayerCfg.ImageHeight = 320;
- pLayerCfg.Backcolor.Blue = 0;
- pLayerCfg.Backcolor.Green = 0;
- pLayerCfg.Backcolor.Red = 0;
- if (HAL_LTDC_ConfigLayer(&hltdc, &pLayerCfg, 0) != HAL_OK)
- {
- Error_Handler();
- }
-
2.摄像头配置
- const unsigned char OV2640_UXGA[][2] =
- {
- 0xff, 0x00,
- 0x2c, 0xff,
- 0x2e, 0xdf,
- 0xff, 0x01,
- 0x3c, 0x32,
- 0x11, 0x00,
- 0x09, 0x02,
- 0x04, 0xA0,
- 0x13, 0xe5,
- 0x14, 0x48,
- 0x2c, 0x0c,
- 0x33, 0x78,
- 0x3a, 0x33,
- 0x3b, 0xfB,
- 0x3e, 0x00,
- 0x43, 0x11,
- 0x16, 0x10,
- 0x4a, 0x81,
- 0x21, 0x99,
- 0x24, 0x40,
- 0x25, 0x38,
- 0x26, 0x82,
- 0x5c, 0x00,
- 0x63, 0x00,
- 0x46, 0x3f,
- 0x0c, 0x38,
- 0x61, 0x70,
- 0x62, 0x80,
- 0x7c, 0x05,
- 0x20, 0x80,
- 0x28, 0x30,
- 0x6c, 0x00,
- 0x6d, 0x80,
- 0x6e, 0x00,
- 0x70, 0x02,
- 0x71, 0x94,
- 0x73, 0xc1,
- 0x3d, 0x34,
- 0x5a, 0x57,
- 0x12, 0x00,
- 0x11, 0x00,
- 0x17, 0x11,
- 0x18, 0x75,
- 0x19, 0x01,
- 0x1a, 0x97,
- 0x32, 0x36,
- 0x03, 0x0f,
- 0x37, 0x40,
- 0x4f, 0xbb,
- 0x50, 0x9c,
- 0x5a, 0x57,
- 0x6d, 0x80,
- 0x6d, 0x38,
- 0x39, 0x02,
- 0x35, 0x88,
- 0x22, 0x0a,
- 0x37, 0x40,
- 0x23, 0x00,
- 0x34, 0xa0,
- 0x36, 0x1a,
- 0x06, 0x02,
- 0x07, 0xc0,
- 0x0d, 0xb7,
- 0x0e, 0x01,
- 0x4c, 0x00,
- 0xff, 0x00,
- 0xe5, 0x7f,
- 0xf9, 0xc0,
- 0x41, 0x24,
- 0xe0, 0x14,
- 0x76, 0xff,
- 0x33, 0xa0,
- 0x42, 0x20,
- 0x43, 0x18,
- 0x4c, 0x00,
- 0x87, 0xd0,
- 0x88, 0x3f,
- 0xd7, 0x03,
- 0xd9, 0x10,
- 0xd3, 0x80,
- 0xc8, 0x08,
- 0xc9, 0x80,
- 0x7d, 0x00,
- 0x7c, 0x03,
- 0x7d, 0x48,
- 0x7c, 0x08,
- 0x7d, 0x20,
- 0x7d, 0x10,
- 0x7d, 0x0e,
- 0x90, 0x00,
- 0x91, 0x0e,
- 0x91, 0x1a,
- 0x91, 0x31,
- 0x91, 0x5a,
- 0x91, 0x69,
- 0x91, 0x75,
- 0x91, 0x7e,
- 0x91, 0x88,
- 0x91, 0x8f,
- 0x91, 0x96,
- 0x91, 0xa3,
- 0x91, 0xaf,
- 0x91, 0xc4,
- 0x91, 0xd7,
- 0x91, 0xe8,
- 0x91, 0x20,
- 0x92, 0x00,
- 0x93, 0x06,
- 0x93, 0xe3,
- 0x93, 0x02,
- 0x93, 0x02,
- 0x93, 0x00,
- 0x93, 0x04,
- 0x93, 0x00,
- 0x93, 0x03,
- 0x93, 0x00,
- 0x93, 0x00,
- 0x93, 0x00,
- 0x93, 0x00,
- 0x93, 0x00,
- 0x93, 0x00,
- 0x93, 0x00,
- 0x96, 0x00,
- 0x97, 0x08,
- 0x97, 0x19,
- 0x97, 0x02,
- 0x97, 0x0c,
- 0x97, 0x24,
- 0x97, 0x30,
- 0x97, 0x28,
- 0x97, 0x26,
- 0x97, 0x02,
- 0x97, 0x98,
- 0x97, 0x80,
- 0x97, 0x00,
- 0x97, 0x00,
- 0xc3, 0xef,
- 0xff, 0x00,
- 0xba, 0xdc,
- 0xbb, 0x08,
- 0xb6, 0x24,
- 0xb8, 0x33,
- 0xb7, 0x20,
- 0xb9, 0x30,
- 0xb3, 0xb4,
- 0xb4, 0xca,
- 0xb5, 0x43,
- 0xb0, 0x5c,
- 0xb1, 0x4f,
- 0xb2, 0x06,
- 0xc7, 0x00,
- 0xc6, 0x51,
- 0xc5, 0x11,
- 0xc4, 0x9c,
- 0xbf, 0x00,
- 0xbc, 0x64,
- 0xa6, 0x00,
- 0xa7, 0x1e,
- 0xa7, 0x6b,
- 0xa7, 0x47,
- 0xa7, 0x33,
- 0xa7, 0x00,
- 0xa7, 0x23,
- 0xa7, 0x2e,
- 0xa7, 0x85,
- 0xa7, 0x42,
- 0xa7, 0x33,
- 0xa7, 0x00,
- 0xa7, 0x23,
- 0xa7, 0x1b,
- 0xa7, 0x74,
- 0xa7, 0x42,
- 0xa7, 0x33,
- 0xa7, 0x00,
- 0xa7, 0x23,
- 0xc0, 0xc8,
- 0xc1, 0x96,
- 0x8c, 0x00,
- 0x86, 0x3d,
- 0x50, 0x92,
- 0x51, 0x90,
- 0x52, 0x2c,
- 0x53, 0x00,
- 0x54, 0x00,
- 0x55, 0x88,
- 0x5a, 0x50,
- 0x5b, 0x3c,
- 0x5c, 0x00,
- 0xd3, 0x04,
- 0x7f, 0x00,
- 0xda, 0x00,
- 0xe5, 0x1f,
- 0xe1, 0x67,
- 0xe0, 0x00,
- 0xdd, 0x7f,
- 0x05, 0x00,
- 0xff, 0x00,
- 0xe0, 0x04,
- 0xc0, 0xc8,
- 0xc1, 0x96,
- 0x86, 0x3d,
- 0x50, 0x92,
- 0x51, 0x90,
- 0x52, 0x2c,
- 0x53, 0x00,
- 0x54, 0x00,
- 0x55, 0x88,
- 0x57, 0x00,
- 0x5a, 0x50,
- 0x5b, 0x3c,
- 0x5c, 0x00,
- 0xd3, 0x04,
- 0xe0, 0x00,
- 0xFF, 0x00,
- 0x05, 0x00,
- 0xDA, 0x08,
- 0xda, 0x09,
- 0x98, 0x00,
- 0x99, 0x00,
- 0x00, 0x00,
-
- 0xff, 0x01,
- 0x11, 0x00,
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- };
3.模型加载
- network_handle = AI_HANDLE_NULL;
-
-
- ai_network_create(&network_handle, AI_NETWORK_DATA_CONFIG);
-
-
- const ai_network_params params = AI_NETWORK_PARAMS_INIT(
- AI_NETWORK_DATA_WEIGHTS(ai_network_data_weights_get()),
- AI_NETWORK_DATA_ACTIVATIONS(activations)
- );
-
-
- ai_network_init(network_handle, ¶ms);
-
-
- ai_network_get_info(network_handle, &desc_report);
-
-
- ai_input[0]= desc_report.inputs[0];
- ai_output[0]= desc_report.outputs[0];
-
- return desc_report.inputs->data;
-
4.业务代码
- uint8_t person_flag;
-
-
- int i,j;
- for(i=0; i<224; i++)
- {
- for(j=0; j<224; j++)
- {
- uint16_t bg_color = ((uint16_t *)_OV2640->frame->buffer)[i*320 + j];
- network_input[3*i*224 + 3*j + 0] = ((bg_color>>11)&0xff)<<3;
- network_input[3*i*224 + 3*j + 1] = ((bg_color>>5)&0x3f)<<2;
- network_input[3*i*224 + 3*j + 2] = (bg_color&0x1f)<<2;
- }
- }
- ai_run(network_input, network_output);
-
-
- for(int i=0;i<192;i++)
- {
- LCD_Draw_Point(i+64, 192+24,0xf100);
- LCD_Draw_Point(192+64,i+24, 0xf100);
- LCD_Draw_Point(i+64, 0+24, 0xf100);
- LCD_Draw_Point(64, i+24, 0xf100);
- }
-
- uint8_t numm = network_max();
-
- LCD_Draw_Image(0, 0, 320, 240, (uint16_t *)_OV2640->frame->buffer);
- if(numm != 0)
- {
- for(int i=0;i<5;i++)
- {
- if(output_labels[numm][i] == -1)
- {
- LCD_Draw_String(i*32+8, 0, 320, 240, 32, (char*)jiage[numm]);
- LCD_Draw_hanzi(i*32+32+8, 0, 44, 0);
- break;
- }
- LCD_Draw_hanzi(i*32, 0, output_labels[numm][i], 0);
- }
- }
-
- OV2640_DMA_Config(_OV2640->frame->buffer, (_OV2640->frame->length)/4);
-
功能演示:
四、作品源码
https://download.eeworld.com.cn/detail/%E5%A5%87%E8%BF%B912/630683
五、作品功能演示视频
播放器加载失败: 未检测到Flash Player,请到 安装
自助计价系统演示视频
六、项目总结
折腾了挺久,终于把这个项目完成了,或许并不完美,但是还是很开心的。
【DigiKey“智造万物,快乐不停”创意大赛】器件开箱 https://bbs.eeworld.com.cn/thread-1260338-1-1.html
【DigiKey创意大赛】食堂自助计价系统+图像采集完成 https://bbs.eeworld.com.cn/thread-1267195-1-1.html
|