13_qrCodeScanner.py 933 B

123456789101112131415161718192021222324252627
  1. #!/usr/bin/env python
  2. #version : 2023.12.31
  3. #language : en
  4. from maix import camera, display, zbar, image
  5. import sys
  6. sys.path.append('/root/CocoPi.py')
  7. image.load_freetype("/root/preset/fonts/CascadiaCodePL-Italic.ttf")
  8. camera.camera.config(size=(320,240))
  9. while True:
  10. canvas = camera.capture()
  11. mks = canvas.find_qrcodes()
  12. for mk in mks:
  13. #外框数据
  14. X = mk['x']
  15. Y = mk['y']
  16. W = mk['w']
  17. H = mk['h']
  18. #二维码信息
  19. string = mk['payload']
  20. #画外框
  21. canvas.draw_rectangle(X, Y, X + W, Y + H, color=(0, 0, 255), thickness = 2)
  22. #打印信息
  23. canvas.draw_string(int(X) , int(Y - 35) , str(string), scale = 1, color = (255, 0, 0), thickness = 2) #内框ID
  24. canvas.draw_image(image.open("/root/preset/img/exit_ff0000_24x24.png"),288,216,alpha=1)
  25. display.show(canvas)