-
Notifications
You must be signed in to change notification settings - Fork 3
/
app.py
executable file
·51 lines (40 loc) · 1.64 KB
/
app.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
45
46
47
48
49
50
51
import time
import edgeiq
def main():
pose_estimator = edgeiq.PoseEstimation("alwaysai/human_pose")
pose_estimator.load(engine=edgeiq.Engine.DNN)
print("Loaded model:\n{}\n".format(pose_estimator.model_id))
print("Engine: {}".format(pose_estimator.engine))
print("Accelerator: {}\n".format(pose_estimator.accelerator))
fps = edgeiq.FPS()
try:
with edgeiq.WebcamVideoStream(cam=0) as video_stream, \
edgeiq.Streamer() as streamer:
# Allow Webcam to warm up
time.sleep(2.0)
fps.start()
# loop detection
while True:
frame = video_stream.read()
results = pose_estimator.estimate(frame)
# Generate text to display on streamer
text = ["Model: {}".format(pose_estimator.model_id)]
text.append(
"Inference time: {:1.3f} s".format(results.duration))
for ind, pose in enumerate(results.poses):
text.append("Person {}".format(ind))
text.append('-'*10)
text.append("Key Points:")
for key_point in pose.key_points:
text.append(str(key_point))
streamer.send_data(results.draw_poses(frame), text)
fps.update()
if streamer.check_exit():
break
finally:
fps.stop()
print("elapsed time: {:.2f}".format(fps.get_elapsed_seconds()))
print("approx. FPS: {:.2f}".format(fps.compute_fps()))
print("Program Ending")
if __name__ == "__main__":
main()