-
Notifications
You must be signed in to change notification settings - Fork 0
/
rescale.py
40 lines (30 loc) · 947 Bytes
/
rescale.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
import cv2 as cv
def rescaleFrame(frame, scale=0.5):
# for image, video and live video
height = int(frame.shape[0] * scale)
width = int(frame.shape[1] * scale)
dimention = (width, height)
return cv.resize(frame, dimention, interpolation=cv.INTER_AREA)
def changeRes(width, height):
# for live video
# 3 refrences width and 4 refrences height
capture.set(3, width)
capture.set(4, height)
img = cv.imread("Resources/Photos/cat_large.jpg")
# cv.imshow("cat", img)
# cv.waitKey(0)
img_resized = rescaleFrame(img)
cv.imshow("cat", img_resized)
# cv.waitKey(0)
capture = cv.VideoCapture("Resources/Videos/dog.mp4")
while True:
isTrue, frame = capture.read()
if isTrue:
resized_frame = rescaleFrame(frame)
cv.imshow("dog", resized_frame)
if cv.waitKey(20) & 0xff==ord('d'):
break
else:
break
capture.release()
cv.destroyAllWindows()