-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreal_time_pos_tracker.py
More file actions
37 lines (30 loc) · 960 Bytes
/
real_time_pos_tracker.py
File metadata and controls
37 lines (30 loc) · 960 Bytes
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
#modules
import cv2 as cv
import mediapipe as mp
import time
#variables
mpDraw = mp.solutions.drawing_utils
mpPose = mp.solutions.pose
pose = mpPose.Pose()
path = "C:\\Users\\ihsan\Pictures\Camera Roll\WIN_20221125_21_17_38_Pro.mp4"
url = 'https://192.168.1.5:8080/video'
cams = [0,1,2,url,path]
cap = cv.VideoCapture(cams[0])
pTime = 0
while True:
success,img = cap.read()
imgRGB = cv.cvtColor(img,cv.COLOR_BGR2RGB)
results = pose.process(imgRGB)
if results.pose_landmarks:
mpDraw.draw_landmarks(img,results.pose_landmarks,mpPose.POSE_CONNECTIONS) #to draw the lines
cTime=time.time()
fps = 1/(cTime-pTime)
pTime = cTime
cv.putText(img,str(int(fps)),(70,50),cv.FONT_HERSHEY_PLAIN, 2,(0,255,0),3) #for writing the number of frames per second
cv.imshow("image",img)
key = cv.waitKey(1)
#exit command
if key == ord('q') :
cap.release()
cv.destroyAllWindows()
exit(1)