chao 9 月之前
父节点
当前提交
04fc406a32

+ 4 - 4
main.py

@@ -291,8 +291,8 @@ demoListText=(
     "CocoTerminal",
     "Picture Analysis",
     "Speech To Image",
-    "Jumpbot",
-    "Gluttonous Snake",
+    # "Jumpbot",
+    # "Gluttonous Snake",
     "Sound Loudness Analysis",
     "Sound Spectrum Analysis",
     "checkout",
@@ -338,8 +338,8 @@ demoNameList=(
     "35_CocoTerminal",
     "36_pictureAnalysis",
     "37_speechToImageSynthesis",
-    "38_jumpbot",
-    "39_gluttonousSnake",
+    # "38_jumpbot",
+    # "39_gluttonousSnake",
     "40_soundLoudnessAnalysis",
     "41_soundSpectrumAnalysis",
     "checkout",

+ 65 - 7
preset/app/01_camera.py

@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 #version    :       2024.03.14
-#language   :       en
+#language   :       ch
 #camera     :       CR5205
 
 from maix import camera
@@ -10,8 +10,66 @@ import time
 import sys
 sys.path.append('/root/')
 from CocoPi import BUTTON
+import os
+ScreenOrientation = False
+try:
+    if os.path.exists("/etc/cameraSize.cfg"):
+        cameraSize = True
+    else:
+        cameraSize = False
+except:
+    cameraSize = False
+def getLcdRotation(cameraCapture):
+    global cameraSize
+    if cameraSize:
+        return lcdRotationNew(cameraCapture)
+    else:
+        return lcdRotation(cameraCapture)
+
+def lcdRotationNew(inputImg):
+    global cameraSize,ScreenOrientation
+    imageRotationBuffer = inputImg.crop(0, 0, 320, 240)
+    if ScreenOrientation:
+        imgRotationAim = image.new(size = (240, 320))
+        rotationAngle = 90
+        GETROTATION = imageRotationBuffer.rotate(+rotationAngle, adjust=1)
+    else:
+        imgRotationAim = image.new(size = (320, 240))
+        GETROTATION = imageRotationBuffer
+
+    GETROTATION = imgRotationAim.draw_image(GETROTATION,0,0,alpha=1)
+    return GETROTATION
+
+def lcdRotation(inputImg):
+    global cameraSize,ScreenOrientation
+    imageRotationBuffer = inputImg.crop(0, 0, 240, 320)
+    if ScreenOrientation:
+        imgRotationAim = image.new(size = (240, 320))
+        rotationAngle = 180
+    else:
+        imgRotationAim = image.new(size = (320, 240))
+        rotationAngle = 90
+    GETROTATION = imageRotationBuffer.rotate(+rotationAngle, adjust=1)
+    GETROTATION = imgRotationAim.draw_image(GETROTATION,0,0,alpha=1)
+    return GETROTATION
+_canvas_y,_canvas_x = 0,0
+def v831_display_show_canvas(displayShow):
+    global _canvas_y,_canvas_x,ScreenOrientation,cameraSize
+    if ScreenOrientation:
+        displayShowCanvas = image.new(size = (240, 320))
+        displayShowCanvas.draw_rectangle(0,0,240,320, color=(0,0,0), thickness=-1)
+        displayShowCanvas.draw_image(displayShow,_canvas_x,_canvas_y,alpha=1)
+        displayShowVER = displayShowCanvas.crop(0,0,240,320)
+        displayShowVER = displayShowVER.rotate(-90, adjust=1)
+        display.show(displayShowVER)
+    else:
+        displayShowCanvas = image.new(size = (320, 240))
+        displayShowCanvas.draw_rectangle(0,0,320,240, color=(0,0,0), thickness=-1)
+        displayShowCanvas.draw_image(displayShow,_canvas_x,_canvas_y,alpha=1)
+        display.show(displayShowCanvas)
 
-image.load_freetype("/root/preset/fonts/CascadiaCodePL-Italic.ttf")
+   
+image.load_freetype("/root/preset/fonts/SourceHanSansCN-Regular.otf")
 buttonState=0
 newState=0
 oldState=0
@@ -35,28 +93,28 @@ def timeStampConvert():
     return timeListOutput
 
 key_C = BUTTON(13)
-camera.camera.config(size=(320, 240))
+camera.camera.config(size=(240, 320))
 while True:
     buttonDetect()
     savePathHead="/root/user/img/photo_"
     savePathTail=".jpg"
     if buttonState!=2:
         img_backdrop = image.new(size=(320,240),color=(0, 0, 0))    #创建背景画布
-        camera_img = camera.capture()    #从摄像头中获取一张图像
+        camera_img = getLcdRotation(camera.capture())    #从摄像头中获取一张图像
         #camera_img_capture = camera_img.crop(0, 0, 320, 240)        #截取图像
         img_backdrop.draw_image(camera_img)
         img_backdrop.draw_image((image.open("/root/preset/img/camera_bfbfbf_24x24.png")).rotate(0, adjust=0),292,2,alpha=1)
         img_backdrop.draw_image((image.open("/root/preset/img/exit_ff0000_24x24.png")).rotate(0, adjust=0),288,216,alpha=1)
-        display.show(img_backdrop)         #将图像显示出来
+        v831_display_show_canvas(img_backdrop)         #将图像显示出来
     else:
         img_backdrop = image.new(size=(320,240),color=(0, 0, 0))    #创建背景画布
-        camera_img = camera.capture()    #从摄像头中获取一张图像
+        camera_img = getLcdRotation(camera.capture())    #从摄像头中获取一张图像
         camera_img_capture = camera_img.crop(0, 0, 320, 240)        #截取图像
         # camera_img_rotate=camera_img_capture.rotate(90,adjust=1)
         camera_img_capture.save(savePathHead+timeStampConvert()+savePathTail)
         img_backdrop.draw_image(camera_img_capture.resize(280, 210),20,15)
         img_backdrop.draw_image((image.open("/root/preset/img/camera_bfbfbf_24x24.png")).rotate(0, adjust=0),292,2,alpha=1)
         img_backdrop.draw_image((image.open("/root/preset/img/exit_ff0000_24x24.png")).rotate(0, adjust=0),288,216,alpha=1)
-        display.show(img_backdrop)         #将图像显示出来
+        v831_display_show_canvas(img_backdrop)         #将图像显示出来
         time.sleep(0.5)
         

+ 47 - 4
preset/app/13_qrCodeScanner.py

@@ -1,14 +1,57 @@
 #!/usr/bin/env python
 #version    :       2023.12.31
-#language   :       en
+#language   :       ch
 from maix import camera, display, zbar, image
 import sys
+import os
+ScreenOrientation = False
+try:
+    if os.path.exists("/etc/cameraSize.cfg"):
+        cameraSize = True
+    else:
+        cameraSize = False
+except:
+    cameraSize = False
+def getLcdRotation(cameraCapture):
+    global cameraSize
+    if cameraSize:
+        return lcdRotationNew(cameraCapture)
+    else:
+        return lcdRotation(cameraCapture)
+
+def lcdRotationNew(inputImg):
+    global cameraSize,ScreenOrientation
+    imageRotationBuffer = inputImg.crop(0, 0, 320, 240)
+    if ScreenOrientation:
+        imgRotationAim = image.new(size = (240, 320))
+        rotationAngle = 90
+        GETROTATION = imageRotationBuffer.rotate(+rotationAngle, adjust=1)
+    else:
+        imgRotationAim = image.new(size = (320, 240))
+        GETROTATION = imageRotationBuffer
+
+    GETROTATION = imgRotationAim.draw_image(GETROTATION,0,0,alpha=1)
+    return GETROTATION
+
+def lcdRotation(inputImg):
+    global cameraSize,ScreenOrientation
+    imageRotationBuffer = inputImg.crop(0, 0, 240, 320)
+    if ScreenOrientation:
+        imgRotationAim = image.new(size = (240, 320))
+        rotationAngle = 180
+    else:
+        imgRotationAim = image.new(size = (320, 240))
+        rotationAngle = 90
+    GETROTATION = imageRotationBuffer.rotate(+rotationAngle, adjust=1)
+    GETROTATION = imgRotationAim.draw_image(GETROTATION,0,0,alpha=1)
+    return GETROTATION
+   
 sys.path.append('/root/CocoPi.py')
-image.load_freetype("/root/preset/fonts/CascadiaCodePL-Italic.ttf")
-camera.camera.config(size=(320,240))
+image.load_freetype("/root/preset/fonts/SourceHanSansCN-Regular.otf")
+camera.camera.config(size=(240,320))
 
 while True:
-    canvas = camera.capture()
+    canvas = getLcdRotation(camera.capture())
     mks = canvas.find_qrcodes()
     for mk in mks:
         #外框数据

+ 45 - 2
preset/app/14_humanDetection.py

@@ -1,8 +1,51 @@
 #!/usr/bin/env python
 #version    :       2023.12.31
-#language   :       en
+#language   :       ch
 from time import time
 from maix import image
+import os
+ScreenOrientation = False
+try:
+    if os.path.exists("/etc/cameraSize.cfg"):
+        cameraSize = True
+    else:
+        cameraSize = False
+except:
+    cameraSize = False
+def getLcdRotation(cameraCapture):
+    global cameraSize
+    if cameraSize:
+        return lcdRotationNew(cameraCapture)
+    else:
+        return lcdRotation(cameraCapture)
+
+def lcdRotationNew(inputImg):
+    global cameraSize,ScreenOrientation
+    imageRotationBuffer = inputImg.crop(0, 0, 320, 240)
+    if ScreenOrientation:
+        imgRotationAim = image.new(size = (240, 320))
+        rotationAngle = 90
+        GETROTATION = imageRotationBuffer.rotate(+rotationAngle, adjust=1)
+    else:
+        imgRotationAim = image.new(size = (320, 240))
+        GETROTATION = imageRotationBuffer
+
+    GETROTATION = imgRotationAim.draw_image(GETROTATION,0,0,alpha=1)
+    return GETROTATION
+
+def lcdRotation(inputImg):
+    global cameraSize,ScreenOrientation
+    imageRotationBuffer = inputImg.crop(0, 0, 240, 320)
+    if ScreenOrientation:
+        imgRotationAim = image.new(size = (240, 320))
+        rotationAngle = 180
+    else:
+        imgRotationAim = image.new(size = (320, 240))
+        rotationAngle = 90
+    GETROTATION = imageRotationBuffer.rotate(+rotationAngle, adjust=1)
+    GETROTATION = imgRotationAim.draw_image(GETROTATION,0,0,alpha=1)
+    return GETROTATION
+   
 class Person:
     mud_path = "/root/preset/model/person_int8.mud"
     labels = ["person"]
@@ -48,7 +91,7 @@ def main():
     #camera.config((224,224))
     while True:
         canvasImg.clear()
-        img = camera.capture().crop(0, 0,224, 224)
+        img = getLcdRotation(camera.capture()).crop(0, 0,224, 224)
         app.process(img)
         canvasImg.draw_image(img,48,8)
         canvasImg.draw_image(image.open("/root/preset/img/exit_ff0000_24x24.png"),288,216,alpha=1)

+ 47 - 4
preset/app/15_faceDetection.py

@@ -1,6 +1,6 @@
 #!/usr/bin/env python
-#version    :       2023.04.04
-#language   :       en
+#version    :       2023.12.31
+#language   :       ch
 from maix import camera
 from maix import display
 
@@ -9,9 +9,52 @@ from maix import image
 from maix import nn
 from maix.nn import decoder
 
+import os
+ScreenOrientation = False
+try:
+    if os.path.exists("/etc/cameraSize.cfg"):
+        cameraSize = True
+    else:
+        cameraSize = False
+except:
+    cameraSize = False
+def getLcdRotation(cameraCapture):
+    global cameraSize
+    if cameraSize:
+        return lcdRotationNew(cameraCapture)
+    else:
+        return lcdRotation(cameraCapture)
+
+def lcdRotationNew(inputImg):
+    global cameraSize,ScreenOrientation
+    imageRotationBuffer = inputImg.crop(0, 0, 320, 240)
+    if ScreenOrientation:
+        imgRotationAim = image.new(size = (240, 320))
+        rotationAngle = 90
+        GETROTATION = imageRotationBuffer.rotate(+rotationAngle, adjust=1)
+    else:
+        imgRotationAim = image.new(size = (320, 240))
+        GETROTATION = imageRotationBuffer
+
+    GETROTATION = imgRotationAim.draw_image(GETROTATION,0,0,alpha=1)
+    return GETROTATION
+
+def lcdRotation(inputImg):
+    global cameraSize,ScreenOrientation
+    imageRotationBuffer = inputImg.crop(0, 0, 240, 320)
+    if ScreenOrientation:
+        imgRotationAim = image.new(size = (240, 320))
+        rotationAngle = 180
+    else:
+        imgRotationAim = image.new(size = (320, 240))
+        rotationAngle = 90
+    GETROTATION = imageRotationBuffer.rotate(+rotationAngle, adjust=1)
+    GETROTATION = imgRotationAim.draw_image(GETROTATION,0,0,alpha=1)
+    return GETROTATION
+   
 camera.camera.config(size=(320,240))
 
-image.load_freetype("/root/preset/fonts/CascadiaCodePL-Italic.ttf")
+image.load_freetype("/root/preset/fonts/SourceHanSansCN-Regular.otf")
 
 model = {
     "param": "/root/preset/model/yolo2_face_awnn.param",
@@ -37,7 +80,7 @@ yolo2_decoder = decoder.Yolo2(len(labels), anchors, net_in_size=(options["inputs
 canvasImg = image.new(size = (240, 320))
 while True:
     canvasImg.clear()
-    img_facedetection = camera.capture()
+    img_facedetection = getLcdRotation(camera.capture())
     img_facedetection = img_facedetection.crop(0, 0,224, 224)
     out = m.forward(img_facedetection.tobytes(), quantize=True, layout="hwc")
     boxes, probs = yolo2_decoder.run(out, nms=0.3, threshold=0.3, img_size=(options["inputs"]["input0"][0], options["inputs"]["input0"][1]))

+ 46 - 18
preset/app/16_faceComparison.py

@@ -1,5 +1,5 @@
 '''
-    Face recognize demo, download modle from maixhub first:
+    Face recognize demo, download model from maixhub first:
             https://maixhub.com/
 '''
 
@@ -11,11 +11,54 @@ import sys
 sys.path.append('/root/')
 from CocoPi import BUTTON
 
+import os
+ScreenOrientation = False
+try:
+    if os.path.exists("/etc/cameraSize.cfg"):
+        cameraSize = True
+    else:
+        cameraSize = False
+except:
+    cameraSize = False
+def getLcdRotation(cameraCapture):
+    global cameraSize
+    if cameraSize:
+        return lcdRotationNew(cameraCapture)
+    else:
+        return lcdRotation(cameraCapture)
+
+def lcdRotationNew(inputImg):
+    global cameraSize,ScreenOrientation
+    imageRotationBuffer = inputImg.crop(0, 0, 320, 240)
+    if ScreenOrientation:
+        imgRotationAim = image.new(size = (240, 320))
+        rotationAngle = 90
+        GETROTATION = imageRotationBuffer.rotate(+rotationAngle, adjust=1)
+    else:
+        imgRotationAim = image.new(size = (320, 240))
+        GETROTATION = imageRotationBuffer
+
+    GETROTATION = imgRotationAim.draw_image(GETROTATION,0,0,alpha=1)
+    return GETROTATION
+
+def lcdRotation(inputImg):
+    global cameraSize,ScreenOrientation
+    imageRotationBuffer = inputImg.crop(0, 0, 240, 320)
+    if ScreenOrientation:
+        imgRotationAim = image.new(size = (240, 320))
+        rotationAngle = 180
+    else:
+        imgRotationAim = image.new(size = (320, 240))
+        rotationAngle = 90
+    GETROTATION = imageRotationBuffer.rotate(+rotationAngle, adjust=1)
+    GETROTATION = imgRotationAim.draw_image(GETROTATION,0,0,alpha=1)
+    return GETROTATION
+   
 key_A = BUTTON(14)
 key_B = BUTTON(8)
 key_C = BUTTON(13)
 key_D = BUTTON(7)
-ScreenOrientation = False
+
 class Face_Recognizer:
     def __init__(self, threshold = 0.5, nms = 0.3, max_face_num = 1):
         model = "/root/preset/model/retinaface.mud"
@@ -107,26 +150,11 @@ names = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "
 face_recognizer = Face_Recognizer(detect_threshold, detect_nms, max_face_num = max_face_num)
 camera.config(size=face_recognizer.get_input_size()[:2])
 
-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
-
-
 
 canvasImg = image.new(size = (240, 320))
 while 1:
     canvasImg.clear()
-    img = camera.capture().crop(0, 0,224, 224)
+    img = getLcdRotation(camera.capture()).crop(0, 0,224, 224)
     if not img:
         time.sleep(0.02)
         continue

+ 50 - 21
preset/app/17_objectRecognition.py

@@ -1,6 +1,6 @@
 #!/usr/bin/env python
-#version    :       2023.04.04
-#language   :       en
+#version    :       2023.12.31
+#language   :       ch
 from maix import camera
 from maix import display
 
@@ -9,10 +9,53 @@ from maix import image
 from maix import nn
 from maix.nn import decoder
 
+import os
+ScreenOrientation = False
+try:
+    if os.path.exists("/etc/cameraSize.cfg"):
+        cameraSize = True
+    else:
+        cameraSize = False
+except:
+    cameraSize = False
+def getLcdRotation(cameraCapture):
+    global cameraSize
+    if cameraSize:
+        return lcdRotationNew(cameraCapture)
+    else:
+        return lcdRotation(cameraCapture)
+
+def lcdRotationNew(inputImg):
+    global cameraSize,ScreenOrientation
+    imageRotationBuffer = inputImg.crop(0, 0, 320, 240)
+    if ScreenOrientation:
+        imgRotationAim = image.new(size = (240, 320))
+        rotationAngle = 90
+        GETROTATION = imageRotationBuffer.rotate(+rotationAngle, adjust=1)
+    else:
+        imgRotationAim = image.new(size = (320, 240))
+        GETROTATION = imageRotationBuffer
+
+    GETROTATION = imgRotationAim.draw_image(GETROTATION,0,0,alpha=1)
+    return GETROTATION
+
+def lcdRotation(inputImg):
+    global cameraSize,ScreenOrientation
+    imageRotationBuffer = inputImg.crop(0, 0, 240, 320)
+    if ScreenOrientation:
+        imgRotationAim = image.new(size = (240, 320))
+        rotationAngle = 180
+    else:
+        imgRotationAim = image.new(size = (320, 240))
+        rotationAngle = 90
+    GETROTATION = imageRotationBuffer.rotate(+rotationAngle, adjust=1)
+    GETROTATION = imgRotationAim.draw_image(GETROTATION,0,0,alpha=1)
+    return GETROTATION
+   
 camera.camera.config(size=(320,240))
 
 ScreenOrientation = False
-image.load_freetype("/root/preset/fonts/CascadiaCodePL-Italic.ttf")
+image.load_freetype("/root/preset/fonts/SourceHanSansCN-Regular.otf")
 
 model = {
     "param": "/root/preset/model/yolo2_20class_awnn.param",
@@ -29,32 +72,18 @@ options = {
     "mean": [127.5, 127.5, 127.5],
     "norm": [0.0078125, 0.0078125, 0.0078125],
 }
-#labels = ['飞机', '自行车', '鸟', '船', '瓶子', '公共汽车', '汽车', '猫', '椅子', '牛', '餐桌', '狗', '马', '摩托车', '人', '盆栽', '羊', '沙发', '火车', '电视监视器']
-labels = ['plane', 'bicycle', 'bird', 'ship', 'bottle', 'bus', 'car', 'cat', 'chair', 'cow', 'table', 'dog', 'horse', 'motobike', 'human', 'Pot plant', 'sheep', 'sofa', 'train', 'tv']
+labels = ['飞机', '自行车', '鸟', '船', '瓶子', '公共汽车', '汽车', '猫', '椅子', '牛', '餐桌', '狗', '马', '摩托车', '人', '盆栽', '羊', '沙发', '火车', '电视监视器']
+#labels = ['plane', 'bicycle', 'bird', 'ship', 'bottle', 'bus', 'car', 'cat', 'chair', 'cow', 'table', 'dog', 'horse', 'motobike', 'human', 'Pot plant', 'sheep', 'sofa', 'train', 'tv']
 anchors = [5.4, 5.38, 1.65, 2.09, 0.8, 1.83, 2.45, 4.14, 0.46, 0.8]
 m = nn.load(model, opt=options)
 yolo2_decoder = decoder.Yolo2(len(labels), anchors, net_in_size=(options["inputs"]["input0"][0], options["inputs"]["input0"][1]), net_out_size=(7, 7))
 
-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
-
 
 
 canvasImg = image.new(size = (240, 320))
 while True:
     canvasImg.clear()
-    img_objectrecognition = camera.capture()
+    img_objectrecognition = getLcdRotation(camera.capture())
     img_objectrecognition = img_objectrecognition.crop(0, 0,224, 224)
     out = m.forward(img_objectrecognition.tobytes(), quantize=True, layout="hwc")
     boxes, probs = yolo2_decoder.run(out, nms=0.3, threshold=0.3, img_size=(options["inputs"]["input0"][0], options["inputs"]["input0"][1]))
@@ -66,7 +95,7 @@ while True:
             img_objectrecognition.draw_string(10,0, (str(str(labels[i[4][0]])) + str(round(i[4][1][i[4][0]]*100, 2))), scale = 1, color = (255,0,0) , thickness = 1)
             img_objectrecognition.draw_rectangle(i[0],i[1], int(i[0]+i[2]),int(i[1]+i[3]), color=(255,0,0), thickness=1)
     else:
-        img_objectrecognition.draw_string(10,0, "Not recognize any object", scale = 1, color = (255,0,0) , thickness = 1)
+        img_objectrecognition.draw_string(10,0, "未识别到任何目标!", scale = 1, color = (255,0,0) , thickness = 1)
     if ScreenOrientation:
         img_objectrecognitionVER = img_objectrecognition.crop(0,0,240,320)
         img_objectrecognitionVER = img_objectrecognitionVER.rotate(-90, adjust=1)

+ 47 - 19
preset/app/18_edgeDetection.py

@@ -1,6 +1,6 @@
 #!/usr/bin/env python
-#version    :       2023.04.04
-#language   :       en
+#version    :       2023.12.31
+#language   :       ch
 from maix import camera
 from maix import display
 
@@ -8,10 +8,52 @@ from maix import image
 
 import numpy as np
 
+import os
+ScreenOrientation = False
+try:
+    if os.path.exists("/etc/cameraSize.cfg"):
+        cameraSize = True
+    else:
+        cameraSize = False
+except:
+    cameraSize = False
+def getLcdRotation(cameraCapture):
+    global cameraSize
+    if cameraSize:
+        return lcdRotationNew(cameraCapture)
+    else:
+        return lcdRotation(cameraCapture)
+
+def lcdRotationNew(inputImg):
+    global cameraSize,ScreenOrientation
+    imageRotationBuffer = inputImg.crop(0, 0, 320, 240)
+    if ScreenOrientation:
+        imgRotationAim = image.new(size = (240, 320))
+        rotationAngle = 90
+        GETROTATION = imageRotationBuffer.rotate(+rotationAngle, adjust=1)
+    else:
+        imgRotationAim = image.new(size = (320, 240))
+        GETROTATION = imageRotationBuffer
+
+    GETROTATION = imgRotationAim.draw_image(GETROTATION,0,0,alpha=1)
+    return GETROTATION
+
+def lcdRotation(inputImg):
+    global cameraSize,ScreenOrientation
+    imageRotationBuffer = inputImg.crop(0, 0, 240, 320)
+    if ScreenOrientation:
+        imgRotationAim = image.new(size = (240, 320))
+        rotationAngle = 180
+    else:
+        imgRotationAim = image.new(size = (320, 240))
+        rotationAngle = 90
+    GETROTATION = imageRotationBuffer.rotate(+rotationAngle, adjust=1)
+    GETROTATION = imgRotationAim.draw_image(GETROTATION,0,0,alpha=1)
+    return GETROTATION
+   
 camera.camera.config(size=(320,240))
 
-ScreenOrientation = False
-image.load_freetype("/root/preset/fonts/CascadiaCodePL-Italic.ttf")
+image.load_freetype("/root/preset/fonts/SourceHanSansCN-Regular.otf")
 
 class Edge:
     model = {
@@ -40,26 +82,12 @@ class Edge:
         del self.model
 
 m = Edge()
-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
-
 
 
 canvas = image.new(size = (320, 240))
 while True:
     canvas.clear()
-    img_edgedetection = camera.capture()
+    img_edgedetection = getLcdRotation(camera.capture())
     img_edgedetection = img_edgedetection.resize(224, 224, padding = 0)
     out = m.model.forward(img_edgedetection, quantize=True, layout="hwc")
     out = out.astype(np.float32).reshape(m.output_size)

+ 40 - 14
preset/app/19_handWrittenDigiRecognition.py

@@ -1,6 +1,6 @@
 #!/usr/bin/env python
-#version    :       2023.04.04
-#language   :       en
+#version    :       2023.12.31
+#language   :       ch
 from maix import camera
 from maix import display
 
@@ -9,26 +9,52 @@ from maix import image
 from maix import nn
 from maix.nn import decoder
 
-camera.camera.config(size=(320,240))
-
+import os
 ScreenOrientation = False
-image.load_freetype("/root/preset/fonts/CascadiaCodePL-Italic.ttf")
+try:
+    if os.path.exists("/etc/cameraSize.cfg"):
+        cameraSize = True
+    else:
+        cameraSize = False
+except:
+    cameraSize = False
+def getLcdRotation(cameraCapture):
+    global cameraSize
+    if cameraSize:
+        return lcdRotationNew(cameraCapture)
+    else:
+        return lcdRotation(cameraCapture)
 
-def lcdRotation(inputImg,rotationAngle):
-    from maix import image
-    imageRotationBuffer = inputImg.crop(0, 0, 240, 320)
+def lcdRotationNew(inputImg):
+    global cameraSize,ScreenOrientation
+    imageRotationBuffer = inputImg.crop(0, 0, 320, 240)
     if ScreenOrientation:
         imgRotationAim = image.new(size = (240, 320))
+        rotationAngle = 90
+        GETROTATION = imageRotationBuffer.rotate(+rotationAngle, adjust=1)
     else:
         imgRotationAim = image.new(size = (320, 240))
-    return imgRotationAim.draw_image(imageRotationBuffer.rotate(rotationAngle, adjust=1),0,0,alpha=1)
+        GETROTATION = imageRotationBuffer
 
-if ScreenOrientation:
-    CAMERAROTATE = +180
-else:
-    CAMERAROTATE = +90
+    GETROTATION = imgRotationAim.draw_image(GETROTATION,0,0,alpha=1)
+    return GETROTATION
 
+def lcdRotation(inputImg):
+    global cameraSize,ScreenOrientation
+    imageRotationBuffer = inputImg.crop(0, 0, 240, 320)
+    if ScreenOrientation:
+        imgRotationAim = image.new(size = (240, 320))
+        rotationAngle = 180
+    else:
+        imgRotationAim = image.new(size = (320, 240))
+        rotationAngle = 90
+    GETROTATION = imageRotationBuffer.rotate(+rotationAngle, adjust=1)
+    GETROTATION = imgRotationAim.draw_image(GETROTATION,0,0,alpha=1)
+    return GETROTATION
+   
+camera.camera.config(size=(320,240))
 
+image.load_freetype("/root/preset/fonts/SourceHanSansCN-Regular.otf")
 
 
 class Number_recognition:
@@ -52,7 +78,7 @@ number_recognition = Number_recognition()
 canvasImg = image.new(size = (240, 320))
 while True:
     canvasImg.clear()
-    img_mnist = camera.capture()
+    img_mnist = getLcdRotation(camera.capture())
     img_mnist = img_mnist.crop(0, 0,224, 224)
     out = number_recognition.model.forward(img_mnist, quantize=1, layout = "hwc")
     boxes, probs = number_recognition.decoder.run(out, nms=0.5, threshold=0.3, img_size=(224,224))

+ 47 - 17
preset/app/20_carLicensePlateRecognition.py

@@ -1,9 +1,52 @@
 #!/usr/bin/env python
-#version    :       2023.04.04
-#language   :       en
+#version    :       2023.12.31
+#language   :       ch
 from time import time
+from maix import display, camera , image
 
+import os
 ScreenOrientation = False
+try:
+    if os.path.exists("/etc/cameraSize.cfg"):
+        cameraSize = True
+    else:
+        cameraSize = False
+except:
+    cameraSize = False
+def getLcdRotation(cameraCapture):
+    global cameraSize
+    if cameraSize:
+        return lcdRotationNew(cameraCapture)
+    else:
+        return lcdRotation(cameraCapture)
+
+def lcdRotationNew(inputImg):
+    global cameraSize,ScreenOrientation
+    imageRotationBuffer = inputImg.crop(0, 0, 320, 240)
+    if ScreenOrientation:
+        imgRotationAim = image.new(size = (240, 320))
+        rotationAngle = 90
+        GETROTATION = imageRotationBuffer.rotate(+rotationAngle, adjust=1)
+    else:
+        imgRotationAim = image.new(size = (320, 240))
+        GETROTATION = imageRotationBuffer
+
+    GETROTATION = imgRotationAim.draw_image(GETROTATION,0,0,alpha=1)
+    return GETROTATION
+
+def lcdRotation(inputImg):
+    global cameraSize,ScreenOrientation
+    imageRotationBuffer = inputImg.crop(0, 0, 240, 320)
+    if ScreenOrientation:
+        imgRotationAim = image.new(size = (240, 320))
+        rotationAngle = 180
+    else:
+        imgRotationAim = image.new(size = (320, 240))
+        rotationAngle = 90
+    GETROTATION = imageRotationBuffer.rotate(+rotationAngle, adjust=1)
+    GETROTATION = imgRotationAim.draw_image(GETROTATION,0,0,alpha=1)
+    return GETROTATION
+   
 
 class LPR:
     loc_model_path = '/root/preset/model/loc.mud'
@@ -76,28 +119,15 @@ class LPR:
             self.draw_paste(input , reg_in)
             self.draw_rectangle(input,box)
             self.draw_point(input , landmarks[i])
-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
 def main():
-    from maix import display, camera , image
-    image.load_freetype("/home/res/sans.ttf")
+    image.load_freetype("/root/preset/fonts/SourceHanSansCN-Regular.otf")
     app  = LPR()
     
     canvasImg = image.new(size = (240, 320))
     while True:
         canvasImg.clear()
-        img = camera.capture().crop(0, 0,224, 224)
+        img = getLcdRotation(camera.capture()).crop(0, 0,224, 224)
         app.process(img)
         canvasImg.draw_image(img,48,8)
         canvasImg.draw_image((image.open("/root/preset/img/exit_ff0000_24x24.png")).rotate(0, adjust=0),288,216,alpha=1)

+ 45 - 16
preset/app/21_maskDetection.py

@@ -1,10 +1,52 @@
 #!/usr/bin/env python
-#version    :       2023.04.04
-#language   :       en
+#version    :       2023.12.31
+#language   :       ch
 from time import time
 from maix import display, camera,image
 
+import os
 ScreenOrientation = False
+try:
+    if os.path.exists("/etc/cameraSize.cfg"):
+        cameraSize = True
+    else:
+        cameraSize = False
+except:
+    cameraSize = False
+def getLcdRotation(cameraCapture):
+    global cameraSize
+    if cameraSize:
+        return lcdRotationNew(cameraCapture)
+    else:
+        return lcdRotation(cameraCapture)
+
+def lcdRotationNew(inputImg):
+    global cameraSize,ScreenOrientation
+    imageRotationBuffer = inputImg.crop(0, 0, 320, 240)
+    if ScreenOrientation:
+        imgRotationAim = image.new(size = (240, 320))
+        rotationAngle = 90
+        GETROTATION = imageRotationBuffer.rotate(+rotationAngle, adjust=1)
+    else:
+        imgRotationAim = image.new(size = (320, 240))
+        GETROTATION = imageRotationBuffer
+
+    GETROTATION = imgRotationAim.draw_image(GETROTATION,0,0,alpha=1)
+    return GETROTATION
+
+def lcdRotation(inputImg):
+    global cameraSize,ScreenOrientation
+    imageRotationBuffer = inputImg.crop(0, 0, 240, 320)
+    if ScreenOrientation:
+        imgRotationAim = image.new(size = (240, 320))
+        rotationAngle = 180
+    else:
+        imgRotationAim = image.new(size = (320, 240))
+        rotationAngle = 90
+    GETROTATION = imageRotationBuffer.rotate(+rotationAngle, adjust=1)
+    GETROTATION = imgRotationAim.draw_image(GETROTATION,0,0,alpha=1)
+    return GETROTATION
+   
 class Mask:
     mud_path = "/root/preset/model/mask_int8.mud"
     labels = ["no wear","wear"]
@@ -44,22 +86,9 @@ class Mask:
 
 app = Mask()
 
-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)
-image.load_freetype("/root/preset/fonts/CascadiaCodePL-Italic.ttf")
-if ScreenOrientation:
-    CAMERAROTATE = +180
-else:
-    CAMERAROTATE = +90
 canvasImg = image.new(size = (320, 240))
 while True:
-    img = camera.capture().crop(0, 0,224, 224)
+    img = getLcdRotation(camera.capture()).crop(0, 0,224, 224)
     app.process(img)
     canvasImg.draw_image(img,48,8)
     canvasImg.draw_image((image.open("/root/preset/img/exit_ff0000_24x24.png")).rotate(0, adjust=0),288,216,alpha=1)

+ 45 - 19
preset/app/22_gestureRecognition.py

@@ -1,12 +1,54 @@
 #!/usr/bin/env python
-#version    :       2023.04.04
+#version    :       2023.12.31
 #language   :       en
 from time import time
 from maix import image
 
+import os
 ScreenOrientation = False
+try:
+    if os.path.exists("/etc/cameraSize.cfg"):
+        cameraSize = True
+    else:
+        cameraSize = False
+except:
+    cameraSize = False
+def getLcdRotation(cameraCapture):
+    global cameraSize
+    if cameraSize:
+        return lcdRotationNew(cameraCapture)
+    else:
+        return lcdRotation(cameraCapture)
+
+def lcdRotationNew(inputImg):
+    global cameraSize,ScreenOrientation
+    imageRotationBuffer = inputImg.crop(0, 0, 320, 240)
+    if ScreenOrientation:
+        imgRotationAim = image.new(size = (240, 320))
+        rotationAngle = 90
+        GETROTATION = imageRotationBuffer.rotate(+rotationAngle, adjust=1)
+    else:
+        imgRotationAim = image.new(size = (320, 240))
+        GETROTATION = imageRotationBuffer
+
+    GETROTATION = imgRotationAim.draw_image(GETROTATION,0,0,alpha=1)
+    return GETROTATION
 
-image.load_freetype("/root/preset/fonts/CascadiaCodePL-Italic.ttf")
+def lcdRotation(inputImg):
+    global cameraSize,ScreenOrientation
+    imageRotationBuffer = inputImg.crop(0, 0, 240, 320)
+    if ScreenOrientation:
+        imgRotationAim = image.new(size = (240, 320))
+        rotationAngle = 180
+    else:
+        imgRotationAim = image.new(size = (320, 240))
+        rotationAngle = 90
+    GETROTATION = imageRotationBuffer.rotate(+rotationAngle, adjust=1)
+    GETROTATION = imgRotationAim.draw_image(GETROTATION,0,0,alpha=1)
+    return GETROTATION
+   
+
+image.load_freetype("/root/preset/fonts/SourceHanSansCN-Regular.otf")
 class Hand:
     mud_path = "/root/preset/model/hand_int8.mud"
     labels = ["0","1","2","3","4","5"]
@@ -45,29 +87,13 @@ class Hand:
             self.draw_rectangle_with_title(input, box, disp_str, fps)
 
 
-
-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
-
-
 def main():
     from maix import display, camera,image
     global Hand
     app =  Hand()
     canvasImg = image.new(size = (320, 240))
     while True:
-        img = camera.capture().crop(0, 0,224, 224)
+        img = getLcdRotation(camera.capture()).crop(0, 0,224, 224)
         app.process(img)
         canvasImg.draw_image(img,48,8)
         canvasImg.draw_image((image.open("/root/preset/img/exit_ff0000_24x24.png")).rotate(0, adjust=0),288,216,alpha=1)

+ 47 - 19
preset/app/23_fingerGuessing.py

@@ -1,10 +1,53 @@
 #!/usr/bin/env python
-#version    :       2023.04.04
-#language   :       en
+#version    :       2023.12.31
+#language   :       ch
 from time import time
 from maix import image
-image.load_freetype("/root/preset/fonts/CascadiaCodePL-Italic.ttf")
+image.load_freetype("/root/preset/fonts/SourceHanSansCN-Regular.otf")
+
+import os
 ScreenOrientation = False
+try:
+    if os.path.exists("/etc/cameraSize.cfg"):
+        cameraSize = True
+    else:
+        cameraSize = False
+except:
+    cameraSize = False
+def getLcdRotation(cameraCapture):
+    global cameraSize
+    if cameraSize:
+        return lcdRotationNew(cameraCapture)
+    else:
+        return lcdRotation(cameraCapture)
+
+def lcdRotationNew(inputImg):
+    global cameraSize,ScreenOrientation
+    imageRotationBuffer = inputImg.crop(0, 0, 320, 240)
+    if ScreenOrientation:
+        imgRotationAim = image.new(size = (240, 320))
+        rotationAngle = 90
+        GETROTATION = imageRotationBuffer.rotate(+rotationAngle, adjust=1)
+    else:
+        imgRotationAim = image.new(size = (320, 240))
+        GETROTATION = imageRotationBuffer
+
+    GETROTATION = imgRotationAim.draw_image(GETROTATION,0,0,alpha=1)
+    return GETROTATION
+
+def lcdRotation(inputImg):
+    global cameraSize,ScreenOrientation
+    imageRotationBuffer = inputImg.crop(0, 0, 240, 320)
+    if ScreenOrientation:
+        imgRotationAim = image.new(size = (240, 320))
+        rotationAngle = 180
+    else:
+        imgRotationAim = image.new(size = (320, 240))
+        rotationAngle = 90
+    GETROTATION = imageRotationBuffer.rotate(+rotationAngle, adjust=1)
+    GETROTATION = imgRotationAim.draw_image(GETROTATION,0,0,alpha=1)
+    return GETROTATION
+   
 class Mora:
     mud_path = "/root/preset/model/mora_int8.mud"
     labels = ["Scissors", "Stone" ,"Paper"]
@@ -42,27 +85,12 @@ class Mora:
             fps = self.cal_fps(t, time())
             self.draw_rectangle_with_title(input, box, disp_str, fps)
 
-
-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
-
 def main():
     from maix import display, camera,image
     app = Mora()
     canvasImg = image.new(size = (320, 240))
     while True:
-        img = camera.capture().crop(0, 0,224, 224)
+        img = getLcdRotation(camera.capture()).crop(0, 0,224, 224)
         app.process(img)
         canvasImg.draw_image(img,48,8)
         canvasImg.draw_image((image.open("/root/preset/img/exit_ff0000_24x24.png")).rotate(0, adjust=0),288,216,alpha=1)

+ 67 - 31
preset/app/24_connectWiFi.py

@@ -1,6 +1,6 @@
 #!/usr/bin/env python
-#version    :       2024.03.07
-#language   :       en
+#version    :       2023.12.31
+#language   :       ch
 from maix import camera, display, zbar, image
 import socket
 import os
@@ -10,33 +10,65 @@ import http.client
 from CocoPi import BUTTON
 import time
 import ssl
-ssl._create_default_https_context = ssl._create_unverified_context
-
-key_A = BUTTON(14)
-key_B = BUTTON(8)
-key_C = BUTTON(13)
-key_D = BUTTON(7)
+import os
 ScreenOrientation = False
-image.load_freetype("/root/preset/fonts/CascadiaCodePL-Italic.ttf")
-camera.camera.config(size=(320,240))
-def lcdRotation(inputImg,rotationAngle):
-    from maix import image
+try:
+    if os.path.exists("/etc/cameraSize.cfg"):
+        cameraSize = True
+    else:
+        cameraSize = False
+except:
+    cameraSize = False
+def getLcdRotation(cameraCapture):
+    global cameraSize
+    if cameraSize:
+        return lcdRotationNew(cameraCapture)
+    else:
+        return lcdRotation(cameraCapture)
+
+def lcdRotationNew(inputImg):
+    global cameraSize,ScreenOrientation
+    imageRotationBuffer = inputImg.crop(0, 0, 320, 240)
+    if ScreenOrientation:
+        imgRotationAim = image.new(size = (240, 320))
+        rotationAngle = 90
+        GETROTATION = imageRotationBuffer.rotate(+rotationAngle, adjust=1)
+    else:
+        imgRotationAim = image.new(size = (320, 240))
+        GETROTATION = imageRotationBuffer
+
+    GETROTATION = imgRotationAim.draw_image(GETROTATION,0,0,alpha=1)
+    return GETROTATION
+
+def lcdRotation(inputImg):
+    global cameraSize,ScreenOrientation
     imageRotationBuffer = inputImg.crop(0, 0, 240, 320)
     if ScreenOrientation:
         imgRotationAim = image.new(size = (240, 320))
+        rotationAngle = 180
     else:
         imgRotationAim = image.new(size = (320, 240))
-    return imgRotationAim.draw_image(imageRotationBuffer.rotate(rotationAngle, adjust=1),0,0,alpha=1)
+        rotationAngle = 90
+    GETROTATION = imageRotationBuffer.rotate(+rotationAngle, adjust=1)
+    GETROTATION = imgRotationAim.draw_image(GETROTATION,0,0,alpha=1)
+    return GETROTATION
+   
+ssl._create_default_https_context = ssl._create_unverified_context
+
+key_A = BUTTON(14)
+key_B = BUTTON(8)
+key_C = BUTTON(13)
+key_D = BUTTON(7)
+image.load_freetype("/root/preset/fonts/SourceHanSansCN-Regular.otf")
+camera.camera.config(size=(240,320))
 
 def getPublicIp():
     import requests
     url = 'https://myip.ipip.net'
-    res = requests.get(url).text.split(" ")
+    res = requests.get(url,verify=False).text.split(" ")
     return res[1][3:]
-if ScreenOrientation:
-    CAMERAROTATE = +180
-else:
-    CAMERAROTATE = +90
+
+    
 
 def getNetworkDate_noexit():
     global getDateNum
@@ -78,10 +110,14 @@ def getWifiConnectState():
     return wifiInfo
 
 def getPrivateIp():
-    import os
-    cmd="ifconfig"
-    rec=os.popen(cmd).read()
-    IP=print(rec[[rec.find("inet addr:192.")+10:rec.find("  Bcast:192.")])
+    st = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
+    try:
+        st.connect(("10.255.255.255",1))
+        IP = st.getsockname()[0]
+    except Exception:
+        IP = "127.0.0.1"
+    finally:
+        st.close()
     return IP
 
 ssidInfo = ""
@@ -95,13 +131,13 @@ PrivateIP=""
 runConnectSig=True
 connectSuccessSig=False
 while True:
-    canvas = camera.capture()
+    canvas = getLcdRotation(camera.capture())
     IP = getPrivateIp()
     if ssidInfo!="" and passwordInfo!="":
         startConnect=True
         #connectText = "Waitting for Connection..."
         #canvas.draw_string(10,40, ssidInfo+" "+str(len(ssidInfo))+" "+str(type(ssidInfo)), scale = 1.5, color = (0,0,0), thickness = 1)
-        canvas.draw_string(10,50, "Waitting for Connection...", scale = 1.5, color = (0,0,0), thickness = 1)
+        canvas.draw_string(10,50, "正在连接WIFI,请等待...", scale = 1.5, color = (0,0,0), thickness = 1)
         display.show(canvas)
     if startConnect==True:
         canvas_1 = image.new(size = (320, 320), color = (255,255,255), mode = "RGB")
@@ -123,9 +159,9 @@ while True:
                     # PublicIp=getPublicIp()
                     PrivateIP=getPrivateIp()
                     connectSuccessSig = True
-                connectText = "WiFi connection is successful"
-                # canvas.draw_string(10,80, "PrivateIP :" + PublicIp, scale = 1.5, color = (0,0,0), thickness = 1)
-                canvas.draw_string(10,80, "PrivateIP  :" + PrivateIP, scale = 1.5, color = (0,0,0), thickness = 1)
+                connectText = "WiFi连接成功!"
+                # canvas.draw_string(10,80, "路由器公网IP:" + PublicIp, scale = 1.5, color = (0,0,0), thickness = 1)
+                canvas.draw_string(10,80, "局域网IP:" + PrivateIP, scale = 1.5, color = (0,0,0), thickness = 1)
                 canvas.draw_image((image.open("/root/preset/img/restart_ff0000_24x24.png")).rotate(0, adjust=0),8,216,alpha=1)
                 ssidInfo=""
                 passwordInfo=""
@@ -151,12 +187,12 @@ while True:
                     ssidInfo = ""
                 else:
                     if runConnectSig== True:
-                        connectText = "Waitting for Connection..."
+                        connectText = "正在连接WIFI,请等待..."
                         runConnectSig= False
                     else:
                         passwordInfo = ""
                         ssidInfo = ""
-                        connectText = "WiFi connection is failed"
+                        connectText = "WIFI连接失败!"
                         canvas.draw_image((image.open("/root/preset/img/restart_ff0000_24x24.png")).rotate(0, adjust=0),8,216,alpha=1)
                 
         
@@ -177,8 +213,8 @@ while True:
             #画外框
             canvas.draw_rectangle(X, Y, X + W, Y + H, color=(0, 0, 255), thickness = 2) 
             #打印信息
-            canvas.draw_string(int(X) , int(Y - 45) , "SSID:"+ssidInfo, scale = 1, color = (255, 0, 0), thickness = 2)  #内框ID
-            canvas.draw_string(int(X) , int(Y - 25) , "PASSWORD:"+passwordInfo, scale = 1, color = (255, 0, 0), thickness = 2)  #内框ID
+            canvas.draw_string(int(X) , int(Y - 45) , "WIFI名:"+ssidInfo, scale = 1, color = (255, 0, 0), thickness = 2)  #内框ID
+            canvas.draw_string(int(X) , int(Y - 25) , "密码:"+passwordInfo, 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)
     #canvas.draw_image((image.open("/root/preset/img/camera_bfbfbf_24x24.png")).rotate(0, adjust=0),292,2,alpha=1)
     display.show(canvas)

+ 51 - 8
preset/app/26_internetCamera.py

@@ -1,6 +1,6 @@
 #!/usr/bin/env python
-#version    :       2023.04.03
-#language   :       en
+#version    :       2023.12.31
+#language   :       pi
 from maix import image     #引入python模块包
 from maix import camera, mjpg, utils, display
 import time
@@ -11,6 +11,49 @@ import socket
 sys.path.append('/root/')
 from CocoPi import BUTTON
 
+import os
+ScreenOrientation = False
+try:
+    if os.path.exists("/etc/cameraSize.cfg"):
+        cameraSize = True
+    else:
+        cameraSize = False
+except:
+    cameraSize = False
+def getLcdRotation(cameraCapture):
+    global cameraSize
+    if cameraSize:
+        return lcdRotationNew(cameraCapture)
+    else:
+        return lcdRotation(cameraCapture)
+
+def lcdRotationNew(inputImg):
+    global cameraSize,ScreenOrientation
+    imageRotationBuffer = inputImg.crop(0, 0, 320, 240)
+    if ScreenOrientation:
+        imgRotationAim = image.new(size = (240, 320))
+        rotationAngle = 90
+        GETROTATION = imageRotationBuffer.rotate(+rotationAngle, adjust=1)
+    else:
+        imgRotationAim = image.new(size = (320, 240))
+        GETROTATION = imageRotationBuffer
+
+    GETROTATION = imgRotationAim.draw_image(GETROTATION,0,0,alpha=1)
+    return GETROTATION
+
+def lcdRotation(inputImg):
+    global cameraSize,ScreenOrientation
+    imageRotationBuffer = inputImg.crop(0, 0, 240, 320)
+    if ScreenOrientation:
+        imgRotationAim = image.new(size = (240, 320))
+        rotationAngle = 180
+    else:
+        imgRotationAim = image.new(size = (320, 240))
+        rotationAngle = 90
+    GETROTATION = imageRotationBuffer.rotate(+rotationAngle, adjust=1)
+    GETROTATION = imgRotationAim.draw_image(GETROTATION,0,0,alpha=1)
+    return GETROTATION
+   
 def getWifiConnectState():
     wifiConnectState=False
     cmd = "wifi_get_connection_info_test 1"
@@ -32,10 +75,10 @@ def getPrivateIp():
         st.close()
     return IP
 
-image.load_freetype("/root/preset/fonts/CascadiaCodePL-Italic.ttf")
+image.load_freetype("/root/preset/fonts/SourceHanSansCN-Regular.otf")
 PrivateIP=""
 canvas = image.new(size=(320, 240),color = (15,21,46),mode = "RGB")
-canvas.draw_string(8 , 100 , "Checking Wi-Fi connection", scale = 1, color = (255,255,255), thickness = 1)
+canvas.draw_string(8 , 100 , "检查网络连接状态...", scale = 1, color = (255,255,255), thickness = 1)
 display.show(canvas)
 wirelessTransmitPath=" "
 
@@ -47,9 +90,9 @@ try:
         wirelessTransmitPath=pathHead+PrivateIP+pathTail
     else:
         PrivateIP="N/A"
-        wirelessTransmitPath="Please connect the Internet."
+        wirelessTransmitPath="请先连接网络"
 except:
-    wirelessTransmitPath="Please connect the Internet."
+    wirelessTransmitPath="请先连接网络"
     pass
 
 os.system("rm /root/user/img/wirelessPictureTransmit.jpg")
@@ -81,13 +124,13 @@ mjpg.MjpgServerThread(
 
 
 
-camera.camera.config(size=(320, 240))
+camera.camera.config(size=(240, 320))
 qrShowState=0
 while True:
     buttonDetect()
     
     img_backdrop = image.new(size=(320,240),color=(0, 0, 0))    #创建背景画布
-    camera_img = camera.capture()    #从摄像头中获取一张图像
+    camera_img = getLcdRotation(camera.capture())    #从摄像头中获取一张图像
     camera_img_capture = camera_img.crop(0, 0, 320, 240)        #截取图像
     jpg = utils.rgb2jpg(camera_img.convert("RGB").tobytes(), 320, 240)
     queue.put(mjpg.BytesImage(jpg))

+ 61 - 23
preset/app/30_training_data_collect.py

@@ -1,6 +1,6 @@
 #!/usr/bin/env python
-#version    :       2023.05.05
-#language   :       en
+#version    :       2023.12.31
+#language   :       ch
 
 from maix import camera, display, zbar, image
 import socket
@@ -13,18 +13,56 @@ import time
 import json
 import requests
 
+import os
+ScreenOrientation = False
+try:
+    if os.path.exists("/etc/cameraSize.cfg"):
+        cameraSize = True
+    else:
+        cameraSize = False
+except:
+    cameraSize = False
+def getLcdRotation(cameraCapture):
+    global cameraSize
+    if cameraSize:
+        return lcdRotationNew(cameraCapture)
+    else:
+        return lcdRotation(cameraCapture)
+
+def lcdRotationNew(inputImg):
+    global cameraSize,ScreenOrientation
+    imageRotationBuffer = inputImg.crop(0, 0, 320, 240)
+    if ScreenOrientation:
+        imgRotationAim = image.new(size = (240, 320))
+        rotationAngle = 90
+        GETROTATION = imageRotationBuffer.rotate(+rotationAngle, adjust=1)
+    else:
+        imgRotationAim = image.new(size = (320, 240))
+        GETROTATION = imageRotationBuffer
+
+    GETROTATION = imgRotationAim.draw_image(GETROTATION,0,0,alpha=1)
+    return GETROTATION
+
+def lcdRotation(inputImg):
+    global cameraSize,ScreenOrientation
+    imageRotationBuffer = inputImg.crop(0, 0, 240, 320)
+    if ScreenOrientation:
+        imgRotationAim = image.new(size = (240, 320))
+        rotationAngle = 180
+    else:
+        imgRotationAim = image.new(size = (320, 240))
+        rotationAngle = 90
+    GETROTATION = imageRotationBuffer.rotate(+rotationAngle, adjust=1)
+    GETROTATION = imgRotationAim.draw_image(GETROTATION,0,0,alpha=1)
+    return GETROTATION
+   
 key_A = BUTTON(14)
 key_B = BUTTON(8)
 key_C = BUTTON(13)
 key_D = BUTTON(7)
-ScreenOrientation = False
-image.load_freetype("/root/preset/fonts/CascadiaCodePL-Italic.ttf")
-camera.camera.config(size=(320,240))
 
-if ScreenOrientation:
-    CAMERAROTATE = +180
-else:
-    CAMERAROTATE = +90
+image.load_freetype("/root/preset/fonts/CascadiaCodePL-Italic.ttf")
+camera.camera.config(size=(240,320))
 
 def getWifiConnectState():
     cmd = "wifi_get_connection_info_test 1"
@@ -99,13 +137,13 @@ PrivateIP=""
 runConnectSig=True
 connectSuccessSig=False
 while True:
-    canvas = camera.capture()
+    canvas = getLcdRotation(camera.capture())
     IP = getPrivateIp()
     if ssidInfo!="" and passwordInfo!="":
         startConnectWifi=True
         #connectText = "Waitting for Connection..."
         #canvas.draw_string(10,40, ssidInfo+" "+str(len(ssidInfo))+" "+str(type(ssidInfo)), scale = 1.5, color = (0,0,0), thickness = 1)
-        canvas.draw_string(10,50, "Waitting for Connection...", scale = 1.5, color = (0,0,0), thickness = 1)
+        canvas.draw_string(10,50, "正在连接WIFI,请等待...", scale = 1.5, color = (0,0,0), thickness = 1)
         display.show(canvas)
     if startConnectWifi==True:
         canvas_1 = image.new(size = (320, 320), color = (255,255,255), mode = "RGB")
@@ -127,9 +165,9 @@ while True:
                     # PublicIp=getPublicIp()
                     PrivateIP=getPrivateIp()
                     connectSuccessSig = True
-                connectText = "WiFi connection is successful"
-                canvas.draw_string(10,50, "WiFi connection is successful", scale = 1.5, color = (0,0,0) , thickness = 1)
-                canvas.draw_string(10,80, "PrivateIP  :" + PrivateIP, scale = 1.5, color = (0,0,0), thickness = 1)
+                connectText = "WiFi连接成功!"
+                canvas.draw_string(10,50, "WiFi连接成功!", scale = 1.5, color = (0,0,0) , thickness = 1)
+                canvas.draw_string(10,80, "局域网IP:" + PrivateIP, scale = 1.5, color = (0,0,0), thickness = 1)
                 canvas.draw_image((image.open("/root/preset/img/restart_ff0000_24x24.png")).rotate(0, adjust=0),8,216,alpha=1)
                 ssidInfo=""
                 passwordInfo=""
@@ -160,12 +198,12 @@ while True:
                     ssidInfo = ""
                 else:
                     if runConnectSig== True:
-                        connectText = "Waitting for Connection..."
+                        connectText = "正在连接WIFI,请等待..."
                         runConnectSig= False
                     else:
                         passwordInfo = ""
                         ssidInfo = ""
-                        connectText = "WiFi connection is failed"
+                        connectText = "WIFI连接失败!"
                         canvas.draw_image((image.open("/root/preset/img/restart_ff0000_24x24.png")).rotate(0, adjust=0),8,216,alpha=1)
                 
         
@@ -186,15 +224,15 @@ while True:
             #画外框
             canvas.draw_rectangle(X, Y, X + W, Y + H, color=(0, 0, 255), thickness = 2) 
             #打印信息
-            canvas.draw_string(int(X) , int(Y - 45) , "SSID:"+ssidInfo, scale = 1, color = (255, 0, 0), thickness = 2)  #内框ID
-            canvas.draw_string(int(X) , int(Y - 25) , "PASSWORD:"+passwordInfo, scale = 1, color = (255, 0, 0), thickness = 2)  #内框ID
+            canvas.draw_string(int(X) , int(Y - 45) , "WIFI名:"+ssidInfo, scale = 1, color = (255, 0, 0), thickness = 2)  #内框ID
+            canvas.draw_string(int(X) , int(Y - 25) , "密码:"+passwordInfo, 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)
     #canvas.draw_image((image.open("/root/preset/img/camera_bfbfbf_24x24.png")).rotate(0, adjust=0),292,2,alpha=1)
     display.show(canvas)
   
 while True:
     canvas.clear()
-    canvas = camera.capture()
+    canvas = getLcdRotation(camera.capture())
     # IP = extract_ip()
     if str(name) != '' and str(host) != '':
         startConnect=True
@@ -231,8 +269,8 @@ while True:
             #打印信息
             canvas.draw_string(int(X) , int(Y - 35) , str(string), scale = 1, color = (255, 0, 0), thickness = 2)  #内框ID
 
-    canvas.draw_string(0, 0 , "Scann the QRcode to Connect the", scale = 1, color = (255, 0, 0), thickness = 2)  #内框ID
-    canvas.draw_string(0, 20 , "Image Tagging Server", scale = 1, color = (255, 0, 0), thickness = 2)  #内框ID
+    canvas.draw_string(0, 0 , "扫描二维码来访问图片标注服务器", scale = 1, color = (255, 0, 0), thickness = 2)  #内框ID
+    canvas.draw_string(0, 20 , "", scale = 1, color = (255, 0, 0), thickness = 2)  #内框ID
     # canvas.draw_image((image.open("/root/preset/img/camera_ff0000_24x24.png")).rotate(0, adjust=0),290,2,alpha=1)
     canvas.draw_image((image.open("/root/preset/img/exit_ff0000_24x24.png")).rotate(0, adjust=0),290,208,alpha=1)
         
@@ -240,7 +278,7 @@ while True:
 
 isAlTake = False
 while True:
-    canvas1 = camera.capture()
+    canvas1 = getLcdRotation(camera.capture())
     if isCollect:
         if not isAlTake:
             if key_C.is_pressed() :
@@ -250,7 +288,7 @@ while True:
                 save_path = ''.join([str(x) for x in ["/root/user/img/image", str(image_num), ".jpg"]])
                 canvas1.save(save_path)
                 isAlTake = True
-            canvas1.draw_string(0, 0 , "Please take a photo", scale = 1, color = (255, 0, 0), thickness = 2)  #内框ID
+            canvas1.draw_string(0, 0 , "请拍照来采集图片数据", scale = 1, color = (255, 0, 0), thickness = 2)  #内框ID
             canvas1.draw_image((image.open("/root/preset/img/camera_ff0000_24x24.png")).rotate(0, adjust=0),290,2,alpha=1)
             canvas1.draw_image((image.open("/root/preset/img/exit_ff0000_24x24.png")).rotate(0, adjust=0),290,208,alpha=1)
             display.show(canvas1)

+ 58 - 20
preset/app/31_training_deploy_model.py

@@ -1,6 +1,6 @@
 #!/usr/bin/env python
-#version    :       2023.05.05
-#language   :       en
+#version    :       2023.12.31
+#language   :       ch
 
 from maix import camera, display, zbar, image
 import socket
@@ -13,13 +13,56 @@ import time
 import json
 import requests
 
+import os
+ScreenOrientation = False
+try:
+    if os.path.exists("/etc/cameraSize.cfg"):
+        cameraSize = True
+    else:
+        cameraSize = False
+except:
+    cameraSize = False
+def getLcdRotation(cameraCapture):
+    global cameraSize
+    if cameraSize:
+        return lcdRotationNew(cameraCapture)
+    else:
+        return lcdRotation(cameraCapture)
+
+def lcdRotationNew(inputImg):
+    global cameraSize,ScreenOrientation
+    imageRotationBuffer = inputImg.crop(0, 0, 320, 240)
+    if ScreenOrientation:
+        imgRotationAim = image.new(size = (240, 320))
+        rotationAngle = 90
+        GETROTATION = imageRotationBuffer.rotate(+rotationAngle, adjust=1)
+    else:
+        imgRotationAim = image.new(size = (320, 240))
+        GETROTATION = imageRotationBuffer
+
+    GETROTATION = imgRotationAim.draw_image(GETROTATION,0,0,alpha=1)
+    return GETROTATION
+
+def lcdRotation(inputImg):
+    global cameraSize,ScreenOrientation
+    imageRotationBuffer = inputImg.crop(0, 0, 240, 320)
+    if ScreenOrientation:
+        imgRotationAim = image.new(size = (240, 320))
+        rotationAngle = 180
+    else:
+        imgRotationAim = image.new(size = (320, 240))
+        rotationAngle = 90
+    GETROTATION = imageRotationBuffer.rotate(+rotationAngle, adjust=1)
+    GETROTATION = imgRotationAim.draw_image(GETROTATION,0,0,alpha=1)
+    return GETROTATION
+   
 key_A = BUTTON(14)
 key_B = BUTTON(8)
 key_C = BUTTON(13)
 key_D = BUTTON(7)
-ScreenOrientation = False
+
 image.load_freetype("/root/preset/fonts/CascadiaCodePL-Italic.ttf")
-camera.camera.config(size=(320,240))
+camera.camera.config(size=(240,320))
 def getWifiConnectState():
     cmd = "wifi_get_connection_info_test 1"
     res = os.popen(cmd).read()
@@ -43,11 +86,6 @@ def getWifiConnectState():
     return wifiInfo
   
 
-if ScreenOrientation:
-    CAMERAROTATE = +180
-else:
-    CAMERAROTATE = +90
-
 
 def urldownload(url,filepath=None,filename=None,canvas1=image.new(size = (320, 40))):
     """
@@ -68,8 +106,8 @@ def urldownload(url,filepath=None,filename=None,canvas1=image.new(size = (320, 4
             now_jd = (data_count / content_size) * 100
             # print("\r 文件下载进度:%d%%(%d/%d) - %s" % (now_jd, data_count, content_size, filename), end=" ")
             canvas1.clear()
-            canvas1.draw_string(0,0,str("Downloading: ") + filename, scale = 1, color = (255, 0, 0), thickness = 2)
-            canvas1.draw_string(0,20 , str("Progress: %d%%(%d/%d)" % (now_jd, data_count, content_size)), scale = 1, color = (255, 0, 0), thickness = 2)  #内框ID
+            canvas1.draw_string(0,0,str("下载中: ") + filename, scale = 1, color = (255, 0, 0), thickness = 2)
+            canvas1.draw_string(0,20 , str("进度: %d%%(%d/%d)" % (now_jd, data_count, content_size)), scale = 1, color = (255, 0, 0), thickness = 2)  #内框ID
             display.show(canvas1)
             # time.sleep(1)
 
@@ -126,13 +164,13 @@ PrivateIP=""
 runConnectSig=True
 connectSuccessSig=False
 while True:
-    canvas = camera.capture()
+    canvas = getLcdRotation(camera.capture())
     IP = getPrivateIp()
     if ssidInfo!="" and passwordInfo!="":
         startConnectWifi=True
         #connectText = "Waitting for Connection..."
         #canvas.draw_string(10,40, ssidInfo+" "+str(len(ssidInfo))+" "+str(type(ssidInfo)), scale = 1.5, color = (0,0,0), thickness = 1)
-        canvas.draw_string(10,50, "Waitting for Connection...", scale = 1.5, color = (0,0,0), thickness = 1)
+        canvas.draw_string(10,50, "正在连接WIFI...", scale = 1.5, color = (0,0,0), thickness = 1)
         display.show(canvas)
     if startConnectWifi==True:
         canvas_1 = image.new(size = (320, 320), color = (255,255,255), mode = "RGB")
@@ -154,9 +192,9 @@ while True:
                     # PublicIp=getPublicIp()
                     PrivateIP=getPrivateIp()
                     connectSuccessSig = True
-                connectText = "WiFi connection is successful"
-                canvas.draw_string(10,50, "WiFi connection is successful", scale = 1.5, color = (0,0,0) , thickness = 1)
-                canvas.draw_string(10,80, "PrivateIP  :" + PrivateIP, scale = 1.5, color = (0,0,0), thickness = 1)
+                connectText = "WiFi连接成功!"
+                canvas.draw_string(10,50, "WiFi连接成功!", scale = 1.5, color = (0,0,0) , thickness = 1)
+                canvas.draw_string(10,80, "局域网IP地址:" + PrivateIP, scale = 1.5, color = (0,0,0), thickness = 1)
                 canvas.draw_image((image.open("/root/preset/img/restart_ff0000_24x24.png")).rotate(0, adjust=0),8,216,alpha=1)
                 ssidInfo=""
                 passwordInfo=""
@@ -186,12 +224,12 @@ while True:
                     ssidInfo = ""
                 else:
                     if runConnectSig== True:
-                        connectText = "Waitting for Connection..."
+                        connectText = "正在连接WIFI..."
                         runConnectSig= False
                     else:
                         passwordInfo = ""
                         ssidInfo = ""
-                        connectText = "WiFi connection is failed"
+                        connectText = "WiFi连接失败!"
                         canvas.draw_image((image.open("/root/preset/img/restart_ff0000_24x24.png")).rotate(0, adjust=0),8,216,alpha=1)
                 
         
@@ -220,7 +258,7 @@ while True:
     
 
 while True:
-    canvas = lcdRotation(camera.capture(),CAMERAROTATE)
+    canvas = getLcdRotation(camera.capture())
     # IP = extract_ip()
     if(str(param) != '' and str(bin) != '' and str(py) != ''):
         startConnect=True
@@ -254,7 +292,7 @@ while True:
             #打印信息
             canvas.draw_string(int(X) , int(Y - 35) , str(string), scale = 1, color = (255, 0, 0), thickness = 2)  #内框ID
                 
-    canvas.draw_string(0, 0 , "Photo scanning code download model", scale = 1, color = (255, 0, 0), thickness = 2)  #内框ID
+    canvas.draw_string(0, 0 , "扫描二维码来下载模型", scale = 1, color = (255, 0, 0), thickness = 2)  #内框ID
     # canvas.draw_image((image.open("/root/preset/img/camera_ff0000_24x24.png")).rotate(0, adjust=0),280,2,alpha=1)
     canvas.draw_image((image.open("/root/preset/img/exit_ff0000_24x24.png")).rotate(0, adjust=0),290,208,alpha=1)
     display.show(canvas)

+ 47 - 4
preset/app/33_mnistCameraTest.py

@@ -1,6 +1,6 @@
 #!/usr/bin/env python
-#version    :       2023.09.07
-#language   :       en
+#version    :       2023.12.31
+#language   :       ch
 from maix import camera
 from maix import display
 from maix import image
@@ -9,6 +9,49 @@ from maix.nn import decoder
 import os
 import numpy as np
 
+import os
+ScreenOrientation = False
+try:
+    if os.path.exists("/etc/cameraSize.cfg"):
+        cameraSize = True
+    else:
+        cameraSize = False
+except:
+    cameraSize = False
+def getLcdRotation(cameraCapture):
+    global cameraSize
+    if cameraSize:
+        return lcdRotationNew(cameraCapture)
+    else:
+        return lcdRotation(cameraCapture)
+
+def lcdRotationNew(inputImg):
+    global cameraSize,ScreenOrientation
+    imageRotationBuffer = inputImg.crop(0, 0, 320, 240)
+    if ScreenOrientation:
+        imgRotationAim = image.new(size = (240, 320))
+        rotationAngle = 90
+        GETROTATION = imageRotationBuffer.rotate(+rotationAngle, adjust=1)
+    else:
+        imgRotationAim = image.new(size = (320, 240))
+        GETROTATION = imageRotationBuffer
+
+    GETROTATION = imgRotationAim.draw_image(GETROTATION,0,0,alpha=1)
+    return GETROTATION
+
+def lcdRotation(inputImg):
+    global cameraSize,ScreenOrientation
+    imageRotationBuffer = inputImg.crop(0, 0, 240, 320)
+    if ScreenOrientation:
+        imgRotationAim = image.new(size = (240, 320))
+        rotationAngle = 180
+    else:
+        imgRotationAim = image.new(size = (320, 240))
+        rotationAngle = 90
+    GETROTATION = imageRotationBuffer.rotate(+rotationAngle, adjust=1)
+    GETROTATION = imgRotationAim.draw_image(GETROTATION,0,0,alpha=1)
+    return GETROTATION
+   
 def sigmoid(x):
     return 1/(1+np.exp(-x))
 
@@ -110,11 +153,11 @@ else:
         net_model = pickle.loads(b_data)
 print(net_model)
 
-camera.camera.config(size=(320, 240))
+camera.camera.config(size=(240, 320))
 img_path="/root/user/image_1.png"
 img_gray_path="/root/user/image_gray.png"
 while True:
-    img = camera.capture()                               #从摄像头中获取一张图像
+    img = getLcdRotation(camera.capture())                              #从摄像头中获取一张图像
     mk = img.crop(0, 0, 240, 240)                        #裁剪图像为320*240
     mk1=img.crop(0, 0, 240, 240).resize(224,224)        #继续裁剪图像为224*224
     canvas= image.new(size = (320, 240), color = (0,255,0), mode = 'RGB')    #创建背景图

+ 58 - 18
preset/app/34_CocoGPT.py

@@ -1,5 +1,5 @@
 #!/usr/bin/env python
-#version    :       2023.09.07
+#version    :       2024.08.08
 #language   :       en
 from maix import display
 from maix import image
@@ -14,9 +14,53 @@ from evdev import InputDevice, categorize, ecodes
 import os
 import sys
 sys.path.append("/root/")
+sys.path.append("/root/preset/drivers/pylib/")
 from CocoPi import BUTTON
 
-camera.camera.config(size=(320,240))
+import os
+ScreenOrientation = False
+try:
+    if os.path.exists("/etc/cameraSize.cfg"):
+        cameraSize = True
+    else:
+        cameraSize = False
+except:
+    cameraSize = False
+def getLcdRotation(cameraCapture):
+    global cameraSize
+    if cameraSize:
+        return lcdRotationNew(cameraCapture)
+    else:
+        return lcdRotation(cameraCapture)
+
+def lcdRotationNew(inputImg):
+    global cameraSize,ScreenOrientation
+    imageRotationBuffer = inputImg.crop(0, 0, 320, 240)
+    if ScreenOrientation:
+        imgRotationAim = image.new(size = (240, 320))
+        rotationAngle = 90
+        GETROTATION = imageRotationBuffer.rotate(+rotationAngle, adjust=1)
+    else:
+        imgRotationAim = image.new(size = (320, 240))
+        GETROTATION = imageRotationBuffer
+
+    GETROTATION = imgRotationAim.draw_image(GETROTATION,0,0,alpha=1)
+    return GETROTATION
+
+def lcdRotation(inputImg):
+    global cameraSize,ScreenOrientation
+    imageRotationBuffer = inputImg.crop(0, 0, 240, 320)
+    if ScreenOrientation:
+        imgRotationAim = image.new(size = (240, 320))
+        rotationAngle = 180
+    else:
+        imgRotationAim = image.new(size = (320, 240))
+        rotationAngle = 90
+    GETROTATION = imageRotationBuffer.rotate(+rotationAngle, adjust=1)
+    GETROTATION = imgRotationAim.draw_image(GETROTATION,0,0,alpha=1)
+    return GETROTATION
+   
+camera.camera.config(size=(240,320))
 image.load_freetype("/root/preset/fonts/simhei.ttf")
 canvas = image.new(size = (320, 240))
 try:
@@ -26,7 +70,7 @@ except:
     keyboard = ""
 
 if keyboard=="":
-    canvas.draw_string(0,12, "Keyboard not detected", scale = 1.3, color = (255,255,255) , thickness = 1)
+    canvas.draw_string(0,12, "未检测到键盘", scale = 1.3, color = (255,255,255) , thickness = 1)
     display.show(canvas)
     time.sleep(3)
     sys.exit()
@@ -71,10 +115,9 @@ def get_post_chatgpt(datas):
     else:
         keyboardStr[list_num] = "fail"
 
-ScreenOrientation = False
 _canvas_x = 0
 _canvas_y = 0
-keyboardStr = ["Enter here:",""]
+keyboardStr = ["请输入:",""]
 list_num = 1
 # 判断是否联网
 key_B = BUTTON(8)
@@ -90,10 +133,7 @@ def wifi_is_content():
         data = True
 
     return data
-if ScreenOrientation:
-    CAMERAROTATE = +180
-else:
-    CAMERAROTATE = +90
+
 
 ssidInfo = ""
 passwordInfo = ""
@@ -109,12 +149,12 @@ while True:
     if wifi_is_content():
         break
     else:
-        canvas = camera.capture()
+        canvas = getLcdRotation(camera.capture())
         if ssidInfo!="" and passwordInfo!="":
             startConnect=True
             #connectText = "Waitting for Connection..."
             #canvas.draw_string(10,40, ssidInfo+" "+str(len(ssidInfo))+" "+str(type(ssidInfo)), scale = 1.5, color = (0,0,0), thickness = 1)
-            canvas.draw_string(10,50, "Connecting to wifi...", scale = 1.5, color = (0,0,0), thickness = 1)
+            canvas.draw_string(10,50, "正在连接WIFI,请等待...", scale = 1.5, color = (0,0,0), thickness = 1)
             display.show(canvas)
         if startConnect==True:
             canvas_1 = image.new(size = (320, 320), color = (255,255,255), mode = "RGB")
@@ -137,7 +177,7 @@ while True:
                         connectSuccessSig = True
                     connectText = "Wifi connection successfully!"
                     # canvas.draw_string(10,80, "The WLAN PUBLIC IP:" + PublicIp, scale = 1.5, color = (0,0,0), thickness = 1)
-                    canvas.draw_string(10,110, "THE WLAN PRIVATE IP:" + PrivateIP, scale = 1.5, color = (0,0,0), thickness = 1)
+                    canvas.draw_string(10,110, "局域网IP:" + PrivateIP, scale = 1.5, color = (0,0,0), thickness = 1)
                     # canvas.draw_image((image.open("/root/preset/img/restart_ff0000_24x24.png")).rotate(0, adjust=0),8,216,alpha=1)
                     ssidInfo=""
                     passwordInfo=""
@@ -164,12 +204,12 @@ while True:
                         ssidInfo = ""
                     else:
                         if runConnectSig== True:
-                            connectText = "Connecting to wifi,please wait..."
+                            connectText = "正在连接WIFI,请等待..."
                             runConnectSig= False
                         else:
                             passwordInfo = ""
                             ssidInfo = ""
-                            connectText = "Wifi connection failed!"
+                            connectText = "WIFI连接失败!"
                             canvas.draw_image((image.open("/root/preset/img/restart_ff0000_24x24.png")).rotate(0, adjust=0),8,216,alpha=1)
                     
             
@@ -190,12 +230,12 @@ while True:
                 #画外框
                 canvas.draw_rectangle(X, Y, X + W, Y + H, color=(0, 0, 255), thickness = 2) 
                 #打印信息
-                canvas.draw_string(int(X) , int(Y - 45) , "wifi name:"+ssidInfo, scale = 1, color = (255, 0, 0), thickness = 2)  #内框ID
-                canvas.draw_string(int(X) , int(Y - 25) , "password:"+passwordInfo, scale = 1, color = (255, 0, 0), thickness = 2)  #内框ID
+                canvas.draw_string(int(X) , int(Y - 45) , "WIFI名:"+ssidInfo, scale = 1, color = (255, 0, 0), thickness = 2)  #内框ID
+                canvas.draw_string(int(X) , int(Y - 25) , "密码:"+passwordInfo, 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)
         v831_display_show_canvas(canvas)
 # 键盘事件
-canvas.draw_string(0,0, str("Enter here:"), scale = 1, color = (255,255,255) , thickness = 1)
+canvas.draw_string(0,0, str("请输入:"), scale = 1, color = (255,255,255) , thickness = 1)
 v831_display_show_canvas(canvas)
 for event in keyboard.read_loop():
     if event.type == ecodes.EV_KEY:
@@ -225,6 +265,6 @@ for event in keyboard.read_loop():
             else:
                 for i in range(list_num+1):
                     canvas.draw_string(0,15*i, str(keyboardStr[i]), scale = 1, color = (255,255,255) , thickness = 1)
-            canvas.draw_string(0,0, str("Enter here:"), scale = 1, color = (255,255,255) , thickness = 1)
+            canvas.draw_string(0,0, str("请输入:"), scale = 1, color = (255,255,255) , thickness = 1)
             v831_display_show_canvas(canvas)
 

+ 49 - 12
preset/app/36_pictureAnalysis.py

@@ -1,9 +1,3 @@
-#!/usr/bin/env python
-#version    :       2024.03.13
-#language   :       en
-#hardware   :       PI
-#camera     :       CR5205
-
 from maix import display
 from maix import image
 from maix import camera
@@ -24,10 +18,53 @@ import sys
 sys.path.append('/root/')
 from CocoPi import BUTTON
 
+import os
+ScreenOrientation = False
+try:
+    if os.path.exists("/etc/cameraSize.cfg"):
+        cameraSize = True
+    else:
+        cameraSize = False
+except:
+    cameraSize = False
+def getLcdRotation(cameraCapture):
+    global cameraSize
+    if cameraSize:
+        return lcdRotationNew(cameraCapture)
+    else:
+        return lcdRotation(cameraCapture)
+
+def lcdRotationNew(inputImg):
+    global cameraSize,ScreenOrientation
+    imageRotationBuffer = inputImg.crop(0, 0, 320, 240)
+    if ScreenOrientation:
+        imgRotationAim = image.new(size = (240, 320))
+        rotationAngle = 90
+        GETROTATION = imageRotationBuffer.rotate(+rotationAngle, adjust=1)
+    else:
+        imgRotationAim = image.new(size = (320, 240))
+        GETROTATION = imageRotationBuffer
+
+    GETROTATION = imgRotationAim.draw_image(GETROTATION,0,0,alpha=1)
+    return GETROTATION
+
+def lcdRotation(inputImg):
+    global cameraSize,ScreenOrientation
+    imageRotationBuffer = inputImg.crop(0, 0, 240, 320)
+    if ScreenOrientation:
+        imgRotationAim = image.new(size = (240, 320))
+        rotationAngle = 180
+    else:
+        imgRotationAim = image.new(size = (320, 240))
+        rotationAngle = 90
+    GETROTATION = imageRotationBuffer.rotate(+rotationAngle, adjust=1)
+    GETROTATION = imgRotationAim.draw_image(GETROTATION,0,0,alpha=1)
+    return GETROTATION
+   
 key_B = BUTTON(8)
 key_C = BUTTON(13)
 key_D = BUTTON(7)
-camera.camera.config(size=(320,240))
+camera.camera.config(size=(240,320))
 image.load_freetype("/root/preset/fonts/simhei.ttf")
 canvas = image.new(size = (320, 240))
 # 播放
@@ -112,7 +149,7 @@ def getImage():
             {
                 "role": "user",
                 "content":[
-                    {"text": "What does the film talk about?","type": "text"},
+                    {"text": "图片讲述了什么?","type": "text"},
                     {"image_url": {"url": f"data:image/jpeg;base64,{strBase}"},"type": "image_url"}
                 ]
             }
@@ -128,10 +165,10 @@ def getImage():
         if res.status_code == 200:
             isStateVoice = 3
             aa = json.loads(res.text)["FunctionResponse"]["choices"][0]["message"]["content"]
-            result_num = len(aa)//45
+            result_num = len(aa)//20
             for i in range(result_num + 1):
                 imgUrlStr.append("")
-                imgUrlStr[i] = str(aa)[i*45:(i+1)*45]
+                imgUrlStr[i] = str(aa)[i*20:(i+1)*20]
             
             url = "https://gpt4.cocorobo.cn/getV831Audio"
             payload = json.dumps({"input": aa,"response_format":"mp3","voice": "shimmer","uid":uid})
@@ -193,7 +230,7 @@ while True:
     if wifi_is_content():
         break
     else:
-        canvas = camera.capture()
+        canvas = getLcdRotation(camera.capture())
         if ssidInfo!="" and passwordInfo!="":
             startConnect=True
             #connectText = "Waitting for Connection..."
@@ -299,7 +336,7 @@ while True:
                 canvas.draw_string(0,15*(i + 2), str(imgUrlStr[i]), scale = 1, color = (255,255,255) , thickness = 1)
     elif isStateVoice != 2 and isStateVoice != 1:
         canvas.clear()
-        canvas = camera.capture()
+        canvas = getLcdRotation(camera.capture())
         if key_C.is_pressed():
             while not (key_C.is_pressed() == False):
                 time.sleep(0.1)

+ 51 - 12
preset/app/37_speechToImageSynthesis.py

@@ -1,7 +1,3 @@
-#!/usr/bin/env python
-#version    :       2024.03.07
-#language   :       en
-
 from maix import display
 from maix import image
 from maix import camera
@@ -22,11 +18,54 @@ import sys
 sys.path.append('/root/')
 from CocoPi import BUTTON
 
+import os
+ScreenOrientation = False
+try:
+    if os.path.exists("/etc/cameraSize.cfg"):
+        cameraSize = True
+    else:
+        cameraSize = False
+except:
+    cameraSize = False
+def getLcdRotation(cameraCapture):
+    global cameraSize
+    if cameraSize:
+        return lcdRotationNew(cameraCapture)
+    else:
+        return lcdRotation(cameraCapture)
+
+def lcdRotationNew(inputImg):
+    global cameraSize,ScreenOrientation
+    imageRotationBuffer = inputImg.crop(0, 0, 320, 240)
+    if ScreenOrientation:
+        imgRotationAim = image.new(size = (240, 320))
+        rotationAngle = 90
+        GETROTATION = imageRotationBuffer.rotate(+rotationAngle, adjust=1)
+    else:
+        imgRotationAim = image.new(size = (320, 240))
+        GETROTATION = imageRotationBuffer
+
+    GETROTATION = imgRotationAim.draw_image(GETROTATION,0,0,alpha=1)
+    return GETROTATION
+
+def lcdRotation(inputImg):
+    global cameraSize,ScreenOrientation
+    imageRotationBuffer = inputImg.crop(0, 0, 240, 320)
+    if ScreenOrientation:
+        imgRotationAim = image.new(size = (240, 320))
+        rotationAngle = 180
+    else:
+        imgRotationAim = image.new(size = (320, 240))
+        rotationAngle = 90
+    GETROTATION = imageRotationBuffer.rotate(+rotationAngle, adjust=1)
+    GETROTATION = imgRotationAim.draw_image(GETROTATION,0,0,alpha=1)
+    return GETROTATION
+   
 key_B = BUTTON(8)
 key_C = BUTTON(13)
 key_D = BUTTON(7)
-camera.camera.config(size=(320,240))
-image.load_freetype("/root/preset/fonts/simhei.ttf")
+camera.camera.config(size=(240,320))
+image.load_freetype("/root/preset/fonts/SourceHanSansCN-Regular.otf")
 canvas = image.new(size = (320, 240))
 # 录音
 WAVE_OUTPUT_FILENAME = "/root/user/audio/record.wav"
@@ -194,12 +233,12 @@ while True:
     if wifi_is_content():
         break
     else:
-        canvas = camera.capture()
+        canvas = getLcdRotation(camera.capture())
         if ssidInfo!="" and passwordInfo!="":
             startConnect=True
             #connectText = "Waitting for Connection..."
             #canvas.draw_string(10,40, ssidInfo+" "+str(len(ssidInfo))+" "+str(type(ssidInfo)), scale = 1.5, color = (0,0,0), thickness = 1)
-            canvas.draw_string(10,50, "Connecting to wifi...", scale = 1.5, color = (0,0,0), thickness = 1)
+            canvas.draw_string(10,50, "正在连接WiFi...", scale = 1.5, color = (0,0,0), thickness = 1)
             display.show(canvas)
         if startConnect==True:
             canvas_1 = image.new(size = (320, 320), color = (255,255,255), mode = "RGB")
@@ -222,7 +261,7 @@ while True:
                         connectSuccessSig = True
                     connectText = "Wifi connection successfully!"
                     # canvas.draw_string(10,80, "The WLAN PUBLIC IP:" + PublicIp, scale = 1.5, color = (0,0,0), thickness = 1)
-                    canvas.draw_string(10,110, "THE WLAN PRIVATE IP:" + PrivateIP, scale = 1.5, color = (0,0,0), thickness = 1)
+                    canvas.draw_string(10,110, "局域网IP:" + PrivateIP, scale = 1.5, color = (0,0,0), thickness = 1)
                     # canvas.draw_image((image.open("/root/preset/img/restart_ff0000_24x24.png")).rotate(0, adjust=0),8,216,alpha=1)
                     ssidInfo=""
                     passwordInfo=""
@@ -249,12 +288,12 @@ while True:
                         ssidInfo = ""
                     else:
                         if runConnectSig== True:
-                            connectText = "Connecting to wifi,please wait..."
+                            connectText = "正在连接WiFi,请等待..."
                             runConnectSig= False
                         else:
                             passwordInfo = ""
                             ssidInfo = ""
-                            connectText = "Wifi connection failed!"
+                            connectText = "WiFi连接失败!"
                             canvas.draw_image((image.open("/root/preset/img/restart_ff0000_24x24.png")).rotate(0, adjust=0),8,216,alpha=1)
                     
             
@@ -293,7 +332,7 @@ while True:
         imgUrlStr = ""
     if isStateVoice == 2:
         canvas.clear()
-        canvas.draw_string(0,0, "Picture generation in...", scale = 1, color = (0,255,255) , thickness = 1)
+        canvas.draw_string(0,0, "图片生成中...", scale = 1, color = (0,255,255) , thickness = 1)
     elif isStateVoice != 2 and isStateVoice != 1:
         canvas.clear()
         if len(imgUrlStr)>0: