-
Notifications
You must be signed in to change notification settings - Fork 0
/
realtime_track_head.py
52 lines (41 loc) · 1.36 KB
/
realtime_track_head.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 os
os.path
os.getcwd()
import cv2
print(cv2.__version__)
# videoCapture = cv2.VideoCapture('IMG_2789.MOV')
# C:\Users\dongj\Desktop\courses\AI\Experiment\xihu
name='C:/Users/ps/Desktop/djz/datasets/video_todo/20200423_133926_2/20200423_133926_2.avi'
videoCapture = cv2.VideoCapture(name)
# print(frame.shape)
# Out[10]: (1024, 1280, 3)
fps = 30 # 保存视频的帧率
# size = (1024, 1280) # 保存视频的大小
size = (1280, 1024)
# videoWriter = cv2.VideoWriter('video4_20201024.avi', cv2.VideoWriter_fourcc('X', 'V', 'I', 'D'), fps, size)
OUTPUT_FILE='C:/Users/ps/Desktop/djz/video_20201024.avi'
videoWriter = cv2.VideoWriter(OUTPUT_FILE,
cv2.VideoWriter_fourcc('X', 'V', 'I', 'D'), fps, size)
# OUTPUT_FILE='C:/Users/ps/Desktop/djz/video4_20201024.avi'
# (width, height)=size
# videoWriter = cv2.VideoWriter(OUTPUT_FILE,
# cv2.VideoWriter_fourcc('I', '4', '2', '0'),
# 30, # fps
# (1280, 1024))
# (width, height))
i = 0
while True:
success, frame = videoCapture.read()
i += 1
if (i >= 0 and i <= fps * 10):
print('i = ', i)
videoWriter.write(frame)
else:
print('end')
break
# if success:
# i += 1
#
# if (i >= 0 and i <= fps*10):
# print('i = ', i)
# videoWriter.write(frame)