-
Notifications
You must be signed in to change notification settings - Fork 2
/
target2-p1.py
51 lines (34 loc) · 1002 Bytes
/
target2-p1.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 cv2 as cv
import time
def rescale(frame,scale=0.75):
width=int(frame.shape[1]*scale)
height=int(frame.shape[0]*scale)
dimension=(width,height)
return cv.resize(frame,dimension,interpolation=cv.INTER_AREA)
vidfilename="Seoul - 21985.mp4"
count =0
filename="IMG"
filecount=1
path="extract"
scale=float(input("Enter the rescale multiplier\n"))
frameskip=(int)(input("Enter how many frames to skip after each pick\n"))
frameskip+=1
capture = cv.VideoCapture(vidfilename)
length=int(capture.get(cv.CAP_PROP_FRAME_COUNT))
print(length)
#isTrue,prevframe=(cv.VideoCapture(vidfilename)).read()
#cv.imshow('first frame',prevframe)
time.sleep(2)
while(True):
isTrue, frame=capture.read()
count+=1
if(isTrue==False):
break
if(count%frameskip==0):
frame=rescale(frame,scale)
filename=path+"\\IMG"+str(filecount)+".png"
filecount+=1
cv.imwrite(filename,frame)
capture.release()
cv.destroyAllWindows()
cv.waitKey(0)