-
Notifications
You must be signed in to change notification settings - Fork 13
/
vid_img_manager.py
44 lines (28 loc) · 1.11 KB
/
vid_img_manager.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Written by Lex Whalen
import cv2 as cv
from pose_estimator import PoseEstimator
from frame_operations import FrameOperations
class VideoImgManager():
def __init__(self):
self.POSE_ESTIMATOR = PoseEstimator()
self.FRAME_OPS = FrameOperations()
self.FIRST = True
def estimate_vid(self,webcam_id=0):
"""reads webcam, applies pose estimation on webcam"""
cap = cv.VideoCapture(webcam_id)
while(True):
has_frame, frame = cap.read()
if self.FIRST:
self.WEB_CAM_H,self.WEB_CAM_W = frame.shape[0:2]
self.FIRST = False
frame = self.POSE_ESTIMATOR.get_pose_key_angles(frame)
cv.imshow('frame',frame)
if cv.waitKey(1) & 0xFF == ord('q'):
break
def estimate_img(self,img_path):
"""applies pose estimation on img"""
img = cv.imread(img_path)
img = self.POSE_ESTIMATOR.get_pose_key_angles(img)
cv.imshow("Image Pose Estimation",img)
cv.waitKey(0)
cv.destroyAllWindows()