468,117 Members | 1,457 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Share your developer knowledge by writing an article on Bytes.

K210 maixpy AI function: pedestrian detection

sipeed
1
582 data sets, 224*224

Video web address:
https://www.bilibili.com/video/BV1Ra4y1s7Ei

The code is as follows:
Expand|Select|Wrap|Line Numbers
  1. import sensor,image,lcd,time
  2. import KPU as kpu
  3. lcd.init(freq=15000000)
  4. sensor.reset(dual_buff=1)
  5. sensor.set_pixformat(sensor.RGB565)
  6. sensor.set_framesize(sensor.QVGA)
  7. sensor.set_hmirror(1)
  8. sensor.set_vflip(0)
  9. sensor.set_windowing((224, 224))
  10.  
  11.  
  12. sensor.run(1)
  13. clock = time.clock()
  14. classes = ['person']
  15. task = kpu.load(0x300000)
  16. anchor = (0.76,1.98, 1.20,3.06, 1.51,4.30, 2.06,5.32, 2.87,6.02)
  17. a = kpu.init_yolo2(task, 0.3, 0.3, 5, anchor)
  18. while(True):
  19.     clock.tick()
  20.     img = sensor.snapshot()
  21.     code = kpu.run_yolo2(task, img)
  22.     print(clock.fps())
  23.     fps =clock.fps()
  24.     img.draw_string(2,2, ("%2.1ffps" %(fps)), color=(0,255,0), scale=2)
  25.     if code:
  26.         for i in code:
  27.             a=img.draw_rectangle(i.rect())
  28.             a = lcd.display(img)
  29.             print(i.classid(),i.value())
  30.             for i in code:
  31.                 lcd.draw_string(i.x(), i.y(), classes[i.classid()], lcd.RED, lcd.WHITE)
  32.                 lcd.draw_string(i.x(), i.y()+12, '%.2f'%i.value(), lcd.RED, lcd.WHITE)
  33.     else:
  34.         a = lcd.display(img)
  35. a = kpu.deinit(task)
4 Weeks Ago #1
1 2095
Niheel
2,418 Expert Mod 2GB
Thank you for posting! This is pretty neat.
Is that the video of this AI function in action?
4 Weeks Ago #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

60 posts views Thread by Fotios | last post: by
18 posts views Thread by Mickey Segal | last post: by
reply views Thread by Stuart Ferguson | last post: by
5 posts views Thread by The Eclectic Electric | last post: by
reply views Thread by origami.takarana | last post: by
7 posts views Thread by Gregor Kofler | last post: by
53 posts views Thread by souporpower | last post: by
10 posts views Thread by Conrad Lender | last post: by
13 posts views Thread by didacticone | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.