update
This commit is contained in:
@ -1,4 +1,5 @@
|
|||||||
from obs import ObsClient
|
from obs import ObsClient
|
||||||
|
import obs
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
#from config import cfg
|
#from config import cfg
|
||||||
from utils.config import cfg
|
from utils.config import cfg
|
||||||
@ -12,6 +13,8 @@ obsClient = ObsClient(
|
|||||||
server='https://obs.cn-east-3.myhuaweicloud.com'
|
server='https://obs.cn-east-3.myhuaweicloud.com'
|
||||||
)
|
)
|
||||||
bucketName = 'ieemoo-ai'
|
bucketName = 'ieemoo-ai'
|
||||||
|
headers = obs.SetObjectMetadataHeader()
|
||||||
|
headers.cacheControl = "no-cache"
|
||||||
|
|
||||||
def AddObs(file_path, status):
|
def AddObs(file_path, status):
|
||||||
with lock:
|
with lock:
|
||||||
@ -52,7 +55,7 @@ def addobs(file_path, status): #save videos
|
|||||||
time = os.path.basename(file_path).split('-')[0]
|
time = os.path.basename(file_path).split('-')[0]
|
||||||
if objectkey.split('.')[-1] in ['avi','mp4']:
|
if objectkey.split('.')[-1] in ['avi','mp4']:
|
||||||
objectkey = 'videos/'+time+'/'+status+'/'+status+'_'+objectkey
|
objectkey = 'videos/'+time+'/'+status+'/'+status+'_'+objectkey
|
||||||
resp = obsClient.putFile(bucketName, objectkey, file_path)
|
resp = obsClient.putFile(bucketName, objectkey, file_path, hearders=headers)
|
||||||
#os.remove(file_path)
|
#os.remove(file_path)
|
||||||
|
|
||||||
def updateAgain():
|
def updateAgain():
|
||||||
@ -70,7 +73,7 @@ def updateAgain():
|
|||||||
time = os.path.basename(file_path).split('-')[0]
|
time = os.path.basename(file_path).split('-')[0]
|
||||||
if objectkey.split('.')[-1] in ['avi','mp4']:
|
if objectkey.split('.')[-1] in ['avi','mp4']:
|
||||||
objectkey = 'videos/'+time+'/'+status+'/'+status+'_'+objectkey
|
objectkey = 'videos/'+time+'/'+status+'/'+status+'_'+objectkey
|
||||||
resp = obsClient.putFile(bucketName, objectkey, file_path)
|
resp = obsClient.putFile(bucketName, objectkey, file_path, hearders=headers)
|
||||||
os.remove(file_path)
|
os.remove(file_path)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
@ -83,14 +86,14 @@ def Addimg(uuid_barcode):
|
|||||||
file_path = os.sep.join([cfg.Tempimg, '3_'+uuid_barcode+'.jpg'])
|
file_path = os.sep.join([cfg.Tempimg, '3_'+uuid_barcode+'.jpg'])
|
||||||
if not os.path.exists(file_path):
|
if not os.path.exists(file_path):
|
||||||
file_path = os.sep.join([cfg.Tempimg, 'ex_'+uuid_barcode+'.jpg'])
|
file_path = os.sep.join([cfg.Tempimg, 'ex_'+uuid_barcode+'.jpg'])
|
||||||
resp = obsClient.putFile(bucketName, objectkey, file_path)
|
resp = obsClient.putFile(bucketName, objectkey, file_path, hearders=headers)
|
||||||
|
|
||||||
def Addimg_content(uuid_barcode, context):
|
def Addimg_content(uuid_barcode, context):
|
||||||
success, encoded_image = cv2.imencode(".jpg",context)
|
success, encoded_image = cv2.imencode(".jpg",context)
|
||||||
context = encoded_image.tobytes()
|
context = encoded_image.tobytes()
|
||||||
time = uuid_barcode.split('-')[0]
|
time = uuid_barcode.split('-')[0]
|
||||||
objectkey = 'imgs/'+time+'/'+uuid_barcode+'.jpg'
|
objectkey = 'imgs/'+time+'/'+uuid_barcode+'.jpg'
|
||||||
resp = obsClient.putContent(bucketName, objectkey, context)
|
resp = obsClient.putContent(bucketName, objectkey, context, hearders=headers)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
import cv2
|
import cv2
|
||||||
|
Reference in New Issue
Block a user