update edge

This commit is contained in:
2023-11-23 15:11:14 +08:00
parent 926f9d3768
commit 0fb07b84a7
4 changed files with 76 additions and 23 deletions

View File

@ -2,22 +2,15 @@ from obs import ObsClient
from datetime import datetime
#from config import cfg
from utils.config import cfg
import os,threading
import os, sys
import time as ti
import base64,requests,cv2,shutil
lock = threading.Lock()
obsClient = ObsClient(
access_key_id='LHXJC7GIC2NNUUHHTNVI',
secret_access_key='sVWvEItrFKWPp5DxeMvX8jLFU69iXPpzkjuMX3iM',
server='https://obs.cn-east-3.myhuaweicloud.com'
)
bucketName = 'ieemoo-ai'
from utils.up_load_file import up_load
up_load_data = up_load()
def AddObs(file_path, status):
#with lock:
if not cfg.flag:
addobs(file_path, status)
#os.remove(file_path)
else:
if status == '02':
addobs(file_path, status)
@ -42,19 +35,13 @@ def addobs(file_path, status): #save videos
else:
break
if not 'data' in status:
# os.remove(file_path)
return 'can not get the status'
status = status['data']
objectkey = os.path.basename(file_path)
status_ = get_weightStatus(objectkey)
# backups_path = os.sep.join([cfg.backups, status+'_'+objectkey])
time = os.path.basename(file_path).split('-')[0]
if objectkey.split('.')[-1] in ['avi','mp4']:
objectkey = 'videos/'+time+'/'+status+'/'+status+'_'+objectkey
if status == '02' or status_:
resp = obsClient.putFile(bucketName, objectkey, file_path)
# shutil.move(file_path, backups_path)
#os.remove(file_path)
objectkey = 'videos/'+time+'/'+status+'/'+status+'_'+objectkey
if status == '02' or get_weightStatus(objectkey):
up_load_data.upLoad(objectkey, file_path)
def Addimg(uuid_barcode):
time = uuid_barcode.split('-')[0].split('_')[-1]
@ -64,20 +51,24 @@ def Addimg(uuid_barcode):
file_path = os.sep.join([cfg.Tempimg, '3_'+uuid_barcode+'.jpg'])
if not os.path.exists(file_path):
file_path = os.sep.join([cfg.Tempimg, 'ex_'+uuid_barcode+'.jpg'])
resp = obsClient.putFile(bucketName, objectkey, file_path)
uuid = uuid_barcode.split('_')[-1]
if get_weightStatus(uuid):
up_load_data.upLoad(objectkey, file_path)
def Addimg_content(uuid_barcode, context):
file_path = "context.jpg"
cv2.imwrite(file_path, context)
success, encoded_image = cv2.imencode(".jpg",context)
context = encoded_image.tobytes()
time = uuid_barcode.split('-')[0]
objectkey = 'imgs/'+time+'/'+uuid_barcode+'.jpg'
resp = obsClient.putContent(bucketName, objectkey, context)
if get_weightStatus(uuid_barcode):
up_load_data.upLoad(objectkey, file_path)
def get_weightStatus(uuid):
uuid = uuid.split('_')[1]
resp = requests.post(url = cfg.riskControl)
up_uuid = resp.json()['data']
#print('>>>>>>>>>>>>>',up_uuid)
if uuid in up_uuid:
return True
return False