|
@@ -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)
|