1234567891011121314151617181920212223242526272829303132333435363738394041 |
- #!/usr/bin/env python
- #version : 2023.04.04
- #language : ch
- from maix import camera, display, zbar, image
- import sys
- sys.path.append('/root/CocoPi.py')
- ScreenOrientation = False
- image.load_freetype("/root/preset/fonts/SourceHanSansCN-Regular.otf")
- camera.camera.config(size=(240,320))
- def lcdRotation(inputImg,rotationAngle):
- from maix import image
- imageRotationBuffer = inputImg.crop(0, 0, 240, 320)
- if ScreenOrientation:
- imgRotationAim = image.new(size = (240, 320))
- else:
- imgRotationAim = image.new(size = (320, 240))
- return imgRotationAim.draw_image(imageRotationBuffer.rotate(rotationAngle, adjust=1),0,0,alpha=1)
- if ScreenOrientation:
- CAMERAROTATE = +180
- else:
- CAMERAROTATE = +90
- while True:
- canvas = lcdRotation(camera.capture(),CAMERAROTATE)
- mks = canvas.find_qrcodes()
- for mk in mks:
- #外框数据
- X = mk['x']
- Y = mk['y']
- W = mk['w']
- H = mk['h']
- #二维码信息
- string = mk['payload']
- #画外框
- canvas.draw_rectangle(X, Y, X + W, Y + H, color=(0, 0, 255), thickness = 2)
- #打印信息
- canvas.draw_string(int(X) , int(Y - 35) , str(string), scale = 1, color = (255, 0, 0), thickness = 2) #内框ID
- canvas.draw_image((image.open("/root/preset/img/exit_ff0000_24x24.png")).rotate(0, adjust=0),288,216,alpha=1)
- display.show(canvas)
-
|