|
|
@@ -46,6 +46,7 @@ def run_openpose_for_frames(video_uuid):
|
|
|
for i in os.listdir(frames_dir):
|
|
|
if i.endswith(".jpg") and "result" not in i:
|
|
|
|
|
|
+ # Already processed
|
|
|
if os.path.exists(frames_dir + i.replace(".jpg", ".result.jpg")) and os.path.exists(
|
|
|
frames_dir + i + ".npy"):
|
|
|
continue
|
|
|
@@ -57,7 +58,6 @@ def run_openpose_for_frames(video_uuid):
|
|
|
np.save(frames_dir + i + ".npy", poses)
|
|
|
|
|
|
canvas = draw_bodypose(oriImg, poses, 'body_25')
|
|
|
-
|
|
|
cv2.imwrite(frames_dir + i.replace(".jpg", ".result.jpg"), canvas)
|
|
|
|
|
|
|
|
|
@@ -65,82 +65,40 @@ class BaseVideoAnalyzer:
|
|
|
def __init__(self, video_uuid):
|
|
|
self.video_uuid = video_uuid
|
|
|
|
|
|
+ def _do_analyze(self):
|
|
|
+ assert False, "Internal error: You should override this with a subclass!"
|
|
|
+
|
|
|
def analyze(self, callback: Callable):
|
|
|
try:
|
|
|
callback("RUNNING")
|
|
|
split_video(self.video_uuid)
|
|
|
run_openpose_for_frames(self.video_uuid)
|
|
|
- callback("FINISHED", result={})
|
|
|
+ callback("FINISHED", result=self._do_analyze())
|
|
|
except Exception as e:
|
|
|
callback("ERROR", error=e)
|
|
|
raise e
|
|
|
|
|
|
|
|
|
class HighKneesVideoAnalyzer(BaseVideoAnalyzer):
|
|
|
- def __init__(self, video_uuid):
|
|
|
- super().__init__(video_uuid)
|
|
|
-
|
|
|
- def analyze(self, callback: Callable):
|
|
|
- try:
|
|
|
- callback("RUNNING")
|
|
|
-
|
|
|
- callback("FINISHED", result={})
|
|
|
- except Exception as e:
|
|
|
- callback("ERROR", error=e)
|
|
|
- raise e
|
|
|
+ def _do_analyze(self):
|
|
|
+ pass
|
|
|
|
|
|
|
|
|
class CrunchVideoAnalyzer(BaseVideoAnalyzer):
|
|
|
- def __init__(self, video_uuid):
|
|
|
- super().__init__(video_uuid)
|
|
|
-
|
|
|
- def analyze(self, callback: Callable):
|
|
|
- try:
|
|
|
- callback("RUNNING")
|
|
|
-
|
|
|
- callback("FINISHED", result={})
|
|
|
- except Exception as e:
|
|
|
- callback("ERROR", error=e)
|
|
|
- raise e
|
|
|
+ def _do_analyze(self):
|
|
|
+ pass
|
|
|
|
|
|
|
|
|
class StandingLongJumpVideoAnalyzer(BaseVideoAnalyzer):
|
|
|
- def __init__(self, video_uuid):
|
|
|
- super().__init__(video_uuid)
|
|
|
-
|
|
|
- def analyze(self, callback: Callable):
|
|
|
- try:
|
|
|
- callback("RUNNING")
|
|
|
-
|
|
|
- callback("FINISHED", result={})
|
|
|
- except Exception as e:
|
|
|
- callback("ERROR", error=e)
|
|
|
- raise e
|
|
|
+ def _do_analyze(self):
|
|
|
+ pass
|
|
|
|
|
|
|
|
|
class PlankVideoAnalyzer(BaseVideoAnalyzer):
|
|
|
- def __init__(self, video_uuid):
|
|
|
- super().__init__(video_uuid)
|
|
|
-
|
|
|
- def analyze(self, callback: Callable):
|
|
|
- try:
|
|
|
- callback("RUNNING")
|
|
|
-
|
|
|
- callback("FINISHED", result={})
|
|
|
- except Exception as e:
|
|
|
- callback("ERROR", error=e)
|
|
|
- raise e
|
|
|
+ def _do_analyze(self):
|
|
|
+ pass
|
|
|
|
|
|
|
|
|
class SquatVideoAnalyzer(BaseVideoAnalyzer):
|
|
|
- def __init__(self, video_uuid):
|
|
|
- super().__init__(video_uuid)
|
|
|
-
|
|
|
- def analyze(self, callback: Callable):
|
|
|
- try:
|
|
|
- callback("RUNNING")
|
|
|
-
|
|
|
- callback("FINISHED", result={})
|
|
|
- except Exception as e:
|
|
|
- callback("ERROR", error=e)
|
|
|
- raise e
|
|
|
+ def _do_analyze(self):
|
|
|
+ pass
|