提交 193c7a25 authored 作者: blu's avatar blu

video.ai

上级 50ee1463
...@@ -10,7 +10,7 @@ print(json.dumps( { ...@@ -10,7 +10,7 @@ print(json.dumps( {
})) }))
m = re.match(r".*? found (\w+) ([\d\.]+) .*? image: ([_\w\d]+.jpg)", "ObjectDetector found human 0.857669 x: 655, y: 379, w: 300, h: 309; written image: detect_person_1577696746490.jpg") m = re.match(r".*? found (\w+) ([\d\.]+) .*? image: .*?/([_\w\d]+.jpg)", "ObjectDetector found human 0.857669 x: 655, y: 379, w: 300, h: 309; written image: /Users/blu/work/opencv-projects/opencv-yolo/D72154040/1550143347000-Rhwjpb/detect_person_1577774106607.jpg")
if m: if m:
print("matched", m.group(1)) print("matched", m.group(1))
......
...@@ -45,6 +45,12 @@ def downloadFile(ipcSn, dirName, fileName, destDir): ...@@ -45,6 +45,12 @@ def downloadFile(ipcSn, dirName, fileName, destDir):
data = fc.download_file() data = fc.download_file()
data.readinto(f) data.readinto(f)
def uploadFile(ipcSn, dirName, fileName, srcPath):
file_path=ipcSn + '/'+dirName+'/' + fileName
fc = ShareFileClient.from_connection_string(conn_str=CONNSTR, share_name=SHARENAME, file_path=file_path)
with open(srcPath + '/' + fileName, "rb") as source_file:
fc.upload_file(source_file)
class VAMMQTTClient: class VAMMQTTClient:
# The callback for when the client receives a CONNACK response from the server. # The callback for when the client receives a CONNACK response from the server.
@staticmethod @staticmethod
...@@ -144,7 +150,7 @@ def video_analysis(data): ...@@ -144,7 +150,7 @@ def video_analysis(data):
print("downloaded file {} into {}".format(fileName, downloadDir)) print("downloaded file {} into {}".format(fileName, downloadDir))
# analyze # analyze
#cmdLine = '/Users/blu/work/opencv-projects/opencv-yolo/detector /Users/blu/work/opencv-projects/opencv-yolo/web/1550143347000-1577267418999.mp4 -c /Users/blu/work/opencv-projects/opencv-yolo/' #cmdLine = '/Users/blu/work/opencv-projects/opencv-yolo/detector /Users/blu/work/opencv-projects/opencv-yolo/web/1550143347000-1577267418999.mp4 -c /Users/blu/work/opencv-projects/opencv-yolo/'
cmdLine = workd + '/' + binName + ' ' + downloadDir + fileName + ' -c ' + configDir cmdLine = workd + '/' + binName + ' ' + downloadDir + fileName + ' -c ' + configDir + ' -o ' + downloadDir + '/detect.jpg'
cmdArgs = shlex.split(cmdLine) cmdArgs = shlex.split(cmdLine)
print(cmdLine, '\n\n', cmdArgs) print(cmdLine, '\n\n', cmdArgs)
output = subprocess.check_output(cmdArgs) output = subprocess.check_output(cmdArgs)
...@@ -152,7 +158,7 @@ def video_analysis(data): ...@@ -152,7 +158,7 @@ def video_analysis(data):
# parse # parse
for line in output.decode('utf-8').split('\n'): for line in output.decode('utf-8').split('\n'):
print("\n", line) print("\n", line)
m = re.match(r".*? found (\w+) ([\d\.]+) .*? image: ([_\w\d]+.jpg)", line) m = re.match(r".*? found (\w+) ([\d\.]+) .*? image: .*?/([_\w\d]+.jpg)", line)
ret['data'] = {} ret['data'] = {}
ret['data']['humanDetect'] = {} ret['data']['humanDetect'] = {}
if m: if m:
...@@ -160,6 +166,13 @@ def video_analysis(data): ...@@ -160,6 +166,13 @@ def video_analysis(data):
ret['data']['humanDetect']['level'] = m.group(2) ret['data']['humanDetect']['level'] = m.group(2)
ret['data']['humanDetect']['image'] = m.group(3) ret['data']['humanDetect']['image'] = m.group(3)
print('found {}: {}, img: {}'.format(m.group(1), m.group(2), m.group(3))) print('found {}: {}, img: {}'.format(m.group(1), m.group(2), m.group(3)))
# write json
jsonFile = downloadDir + '/' + 'result.json'
with open(jsonFile, 'w') as outfile:
json.dump(ret, outfile)
# upload
uploadFile(ipcSN, dirName, 'result.json', downloadDir)
uploadFile(ipcSN, dirName, m.group(3), downloadDir)
break break
else: else:
ret['data']['humanDetect']['found'] = 0 ret['data']['humanDetect']['found'] = 0
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论