#!/usr/bin/env python #version : 2023.04.06 #language : ch from maix import display from maix import image from maix import camera camera.camera.config(size=(240,320)) ScreenOrientation = False 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 image.load_freetype("/root/preset/fonts/SourceHanSansCN-Regular.otf") while True: canvas = lcdRotation(camera.capture(),CAMERAROTATE) RGB = canvas.get_blob_color((154, 114, 10, 10), 0, 0) canvas.draw_rectangle(154,114, 164,124, color=(255,0,0), thickness=1) canvas.draw_rectangle(0,0, 319,20, color=((int(RGB[0])),(int(RGB[1])),(int(RGB[2]))), thickness=-1) canvas.draw_string(120,0, (''.join([str(x) for x in ["(", int(RGB[0]), ",", int(RGB[1]), ",", int(RGB[2]), ")"]])), scale = 1, color = ((255 - int(RGB[0])),(255 - int(RGB[1])),(255 - int(RGB[2]))), thickness = 1) if ScreenOrientation: canvasVER = canvas.crop(0,0,240,320) canvasVER = canvasVER.rotate(-90, adjust=1) display.show(canvasVER) else: display.show(canvas)