发送视频方法
parent
ca989dfffd
commit
05acbff6a3
@ -1 +1 @@
|
||||
{"log_path": "xznsh.log", "frame": 0.05, "camera": {"camera_01": "rtsp://admin:@192.168.10.18", "camera_02": "rtsp://admin:@192.168.10.12"}, "model_path": {"person": "person.pt", "head": "xxx", "phone": "xxx"}, "confidence": {"person": 0.5, "head": 0.5, "phone": 0.5}}
|
||||
{"log_path": "xznsh.log", "frame": 0.05, "camera": {"camera_01": "rtsp://admin:@192.168.10.18", "camera_02": "rtsp://admin:@192.168.10.12"}, "model_path": {"person": "person.pt", "head": "xxx", "phone": "xxx"}, "confidence": {"person": 0.5, "head": 0.5, "phone": 0.5}, "video_encoding": "MP42", "video_path": {"person": "xxx", "head": "xxx", "phone": "xxx"}, "username": "eWF4aW4=", "password": "eWF4aW5AMTIz", "url": ""}
|
@ -0,0 +1,40 @@
|
||||
import json
|
||||
import requests
|
||||
import base64
|
||||
|
||||
with open('cfg.json', 'r') as f:
|
||||
cfg_dict = json.load(f)
|
||||
|
||||
|
||||
def send_result(file_path, url):
|
||||
"""
|
||||
发送视频
|
||||
Args:
|
||||
file_path:
|
||||
url:
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
username = cfg_dict['username']
|
||||
password = cfg_dict['password']
|
||||
headers = {'Content-type': 'video/mp4', 'Authorization': 'Basic ' + f'<{username}>:<{password}>'}
|
||||
files = {'file': open(file_path, 'rb')}
|
||||
response = requests.post(url, files=files, headers=headers)
|
||||
return response
|
||||
|
||||
|
||||
def encode_info(info):
|
||||
"""
|
||||
加密
|
||||
"""
|
||||
encoded_info = base64.b64encode(info.encode('utf-8')).decode("utf-8")
|
||||
return encoded_info
|
||||
|
||||
|
||||
def decode_info(encoded_info):
|
||||
"""
|
||||
解密
|
||||
"""
|
||||
info = base64.b64decode(encoded_info.encode('utf-8')).decode('utf-8')
|
||||
return info
|
Loading…
Reference in New Issue