-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathball_trajectory2.py
39 lines (34 loc) · 1.54 KB
/
ball_trajectory2.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
import numpy as np
import cv2
import os
from os import path, getcwd, chdir
import glob
import matplotlib.pyplot as plt
import scipy.io
cap = cv2.VideoCapture('L5_clip1_15s.mp4')
script_dir = os.path.dirname(__file__)
mat = scipy.io.loadmat('centr.mat')
new_data = mat['whiteBlob_matrix']
fourcc = cv2.VideoWriter_fourcc(*'X264')
out = cv2.VideoWriter('1c_output.mp4',fourcc, 60.0, (int(cap.get(3)),int(cap.get(4))),isColor=1)
p = 0
f=0
while(cap.isOpened()):
ret, frame = cap.read()
for g in range(0,20,1):
if(p > 50 and p<=85):
cv2.line(frame,(int(new_data[p-g-25,0]),int(new_data[p-g-25,1])),(int(new_data[p-g,0]),int(new_data[p-g,1])),(255,255,255),3)
cv2.line(frame,(int(new_data[p-g-48,0]),int(new_data[p-g-48,1])),(int(new_data[p-g-25,0]),int(new_data[p-g-25,1])),(255,255,255),3)
if(p > 85):
cv2.line(frame,(int(new_data[p-g-25,0]),int(new_data[p-g-25,1])),(int(new_data[p-g,0]),int(new_data[p-g,1])),(255,255,255),3)
cv2.line(frame,(int(new_data[p-g-40,0]),int(new_data[p-g-40,1])),(int(new_data[p-g-25,0]),int(new_data[p-g-25,1])),(255,255,255),3)
cv2.line(frame,(int(new_data[p-g-83,0]),int(new_data[p-g-83,1])),(int(new_data[p-g-39,0]),int(new_data[p-g-39,1])),(255,255,255),3)
cv2.circle(frame,(int(new_data[p,0]),int(new_data[p,1])), 9, (0,0,255), -1)
p+=1
cv2.imshow("Do U see line",frame)
out.write(frame)
if cv2.waitKey(10) & 0xFF == ord('q'):
break
cap.release()
out.release()
cv2.destroyAllWindows()