-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_pose_estimate.py
40 lines (31 loc) · 1.13 KB
/
test_pose_estimate.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
import cv2
import argparse
from imutil import FPS
from pose_estimate import PoseEstimator
if __name__ == "__main__":
# will take mobilenet_thin as base model and
# image will be resized to 432x368 before processing
obj = PoseEstimator()
ap = argparse.ArgumentParser()
ap.add_argument("-n", "--num-frames", type=int, default=200,
help="# of frames to loop over FPS test")
args = vars(ap.parse_args())
# grab a pointer to video stream and initialize the counter
print ("[INFO] sampling frames from webcam")
stream = cv2.VideoCapture(0)
fps = FPS().start()
# loop over some frames
while fps._numFrames < args["num_frames"]:
(grabbed, frame) = stream.read()
# send the frame for inference
obj.infer(frame)
obj.showResults()
# update the fps counter
fps.update()
# stop the timer and display the information
fps.stop()
print ("[INFO] elapsed time : {:.2f}".format(fps.elapsed()))
print ("[INFO] approx. FPS: {:.2f}".format(fps.fps()))
# cleanup
stream.release()
cv2.destroyAllWindows()