|
|
@@ -5,7 +5,7 @@ from typing import Callable
|
|
|
|
|
|
import cv2
|
|
|
|
|
|
-from config import UPLOAD_DIR
|
|
|
+from config import UPLOAD_DIR, FILE_URL
|
|
|
from service.ai.util.torch_openpose import torch_openpose
|
|
|
from service.ai.util.util import draw_bodypose
|
|
|
from service.ai.video.classify.balancebeam import classify_balancebeam
|
|
|
@@ -61,9 +61,10 @@ def run_openpose_for_npy_and_video(video_uuid, callback: Callable):
|
|
|
results[str(c)] = poses # this is evil, but the AI code expect it to be so.
|
|
|
|
|
|
canvas = draw_bodypose(frame, poses, 'body_25')
|
|
|
+ cv2.imwrite(UPLOAD_DIR + "result/" + video_uuid + "." + str(c) + ".jpg", canvas)
|
|
|
|
|
|
if out is None:
|
|
|
- out = cv2.VideoWriter(UPLOAD_DIR + video_uuid + ".result.mp4", cv2.VideoWriter_fourcc(*"mp4v"), FPS,
|
|
|
+ out = cv2.VideoWriter(UPLOAD_DIR + "result/" + video_uuid + ".result.mp4", cv2.VideoWriter_fourcc(*"mp4v"), FPS,
|
|
|
(canvas.shape[1], canvas.shape[0])) # So fucking stupid
|
|
|
out.write(canvas)
|
|
|
|
|
|
@@ -98,7 +99,15 @@ class BaseVideoAnalyzer:
|
|
|
else: # read cache
|
|
|
self.results = pickle.load(open(PICKLE_DUMP_PATH, "rb"))
|
|
|
|
|
|
- callback("FINISHED", result=self._do_analyze())
|
|
|
+ result = {**self._do_analyze(), "file": FILE_URL + self.video_uuid + ".result.mp4"}
|
|
|
+ # inject file url here
|
|
|
+ try:
|
|
|
+ for i in result['data']:
|
|
|
+ result['data'][i]['file'] = FILE_URL + self.video_uuid + "." + result['data'][i]['index'] + ".jpg"
|
|
|
+ except Exception as e:
|
|
|
+ logging.warning("file index in data not found, %s" % e)
|
|
|
+
|
|
|
+ callback("FINISHED", result=result)
|
|
|
except Exception as e:
|
|
|
callback("ERROR", error=e)
|
|
|
raise e
|