找回密码
 立即注册
楼主: Lvp***

国二,2023电赛 【G题】空地协同智能消防系

[复制链接]

该用户从未签到

1

主题

33

回帖

109

积分

注册会员

积分
109
 楼主| 发表于 2023-10-9 15:10:22 | 显示全部楼层
图片如下
截图202310091510193807.jpg
回复 送花

使用道具 举报

该用户从未签到

1

主题

33

回帖

109

积分

注册会员

积分
109
 楼主| 发表于 2023-10-9 15:10:49 | 显示全部楼层
接上文
截图202310091510414227.jpg
回复 送花

使用道具 举报

该用户从未签到

1

主题

33

回帖

109

积分

注册会员

积分
109
 楼主| 发表于 2023-10-9 15:11:16 | 显示全部楼层
再接上文
截图202310091511023037.jpg
回复 送花

使用道具 举报

该用户从未签到

1

主题

33

回帖

109

积分

注册会员

积分
109
 楼主| 发表于 2023-10-9 15:11:58 | 显示全部楼层
YOLO2训练代码
  1. # generated by maixhub, tested on maixpy3 v0.4.8
  2. # copy files to TF card and plug into board and power on
  3. import sensor, image, lcd, time
  4. import KPU as kpu
  5. import gc, sys
  6. input_size = (224, 224)
  7. labels = ['FlightPark']
  8. anchors = [3.83, 3.58, 3.47, 3.41, 3.25, 3.25, 2.5, 2.5, 2.84, 2.84]
  9. def lcd_show_except(e):
  10.     import uio
  11.     err_str = uio.StringIO()
  12.     sys.print_exception(e, err_str)
  13.     err_str = err_str.getvalue()
  14.     img = image.Image(size=input_size)
  15.     img.draw_string(0, 10, err_str, scale=1, color=(0xff,0x00,0x00))
  16.     lcd.display(img)
  17. def main(anchors, labels = None, model_addr="/sd/Models/m.kmodel", sensor_window=input_size, lcd_rotation=0, sensor_hmirror=False, sensor_vflip=False):
  18.     sensor.reset()
  19.     sensor.set_pixformat(sensor.RGB565)
  20.     sensor.set_framesize(sensor.QVGA)
  21.     sensor.set_windowing(sensor_window)
  22.     sensor.set_hmirror(sensor_hmirror)
  23.     sensor.set_vflip(sensor_vflip)
  24.     sensor.run(1)
  25.     lcd.init(type=1)
  26.     lcd.rotation(lcd_rotation)
  27.     lcd.clear(lcd.WHITE)
  28.     if not labels:
  29.         with open('labels.txt','r') as f:
  30.             exec(f.read())
  31.     if not labels:
  32.         print("no labels.txt")
  33.         img = image.Image(size=(320, 240))
  34.         img.draw_string(90, 110, "no labels.txt", color=(255, 0, 0), scale=2)
  35.         lcd.display(img)
  36.         return 1
  37.     try:
  38.         img = image.Image("startup.jpg")
  39.         lcd.display(img)
  40.     except Exception:
  41.         img = image.Image(size=(320, 240))
  42.         img.draw_string(90, 110, "loading model...", color=(255, 255, 255), scale=2)
  43.         lcd.display(img)
  44.     try:
  45.         task = None
  46.         kpu.init_yolo2(task, 0.5, 0.3, 5, anchors) # threshold:[0,1], nms_value: [0, 1]
  47.         while(True):
  48.             img = sensor.snapshot()
  49.             t = time.ticks_ms()
  50.             objects = kpu.run_yolo2(task, img)
  51.             t = time.ticks_ms() - t
  52.             if objects:
  53.                 for obj in objects:
  54.                     pos = obj.rect()
  55.                     img.draw_rectangle(pos)
  56.                     img.draw_string(pos[0], pos[1], "%s : %.2f" %(labels[obj.classid()], obj.value()), scale=2, color=(255, 0, 0))
  57.             img.draw_string(0, 200, "t:%dms" %(t), scale=2, color=(255, 0, 0))
  58.             lcd.display(img)
  59.     except Exception as e:
  60.         raise e
  61.     finally:
  62.         if not task is None:
  63.             kpu.deinit(task)
  64. if __name__ == "__main__":
  65.     try:
  66.         # main(anchors = anchors, labels=labels, model_addr=0x300000, lcd_rotation=0)
  67.         main(anchors = anchors, labels=labels, model_addr="/sd/Models/Parking.kmodel")
  68.     except Exception as e:
  69.         sys.print_exception(e)
  70.         lcd_show_except(e)
  71.     finally:
  72.         gc.collect()
复制代码
回复 支持 反对 送花

使用道具 举报

该用户从未签到

1

主题

33

回帖

109

积分

注册会员

积分
109
 楼主| 发表于 2023-10-9 15:13:27 | 显示全部楼层
飞控代码主函数(来自匿名凌霄)
  1. /******************** (C) COPYRIGHT 2017 ANO Tech ********************************
  2. * 作者    :匿名科创
  3. * 官网    :www.anotc.com
  4. * 淘宝    :anotc.taobao.com
  5. * 技术Q群 :190169595
  6. * 描述    :主循环
  7. **********************************************************************************/
  8. #include "SysConfig.h"
  9. #include "Ano_Scheduler.h"
  10. #include "Drv_Uart.h"
  11. #include "My_main.h"
  12. #ifdef USE_FULL_ASSERT
  13. void assert_failed(uint8_t *file, uint32_t line)
  14. {
  15.         while (1)
  16.         {
  17.                 //当系统出错后,会进入这个死循环
  18.                
  19.         }
  20. }
  21. #endif
  22. //=======================================================================================
  23. //=======================================================================================
  24. int main(void)
  25. {
  26.         //进行所有设备的初始化,并将初始化结果保存
  27.         All_Init();
  28.         //调度器初始化,系统为裸奔,这里人工做了一个时分调度器
  29.         Scheduler_Setup();
  30.         Process_Init();
  31. //用户初始化       
  32.         UWBMapInit();                                //UWB地图初始化
  33.         IMU_KalmanInit();                //IMU卡尔曼滤波器初始化
  34.        
  35.         PTZ.Angle1 =0x69;PTZ.Angle2 =0x30;
  36.         UWB_ENABLE;
  37.         while (1)
  38.         {
  39.                 //运行任务调度器,所有系统功能,除了中断服务函数,都在任务调度器内完成
  40.                 Scheduler_Run();
  41.                
  42.         }
  43. }
  44. /******************* (C) COPYRIGHT 2014 ANO TECH *****END OF FILE************/
复制代码
回复 支持 反对 送花

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|深圳国芯人工智能有限公司 ( 粤ICP备2022108929号-2 )

GMT+8, 2024-4-29 03:39 , Processed in 0.059868 second(s), 45 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表