-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathread.py
More file actions
36 lines (24 loc) · 974 Bytes
/
Copy pathread.py
File metadata and controls
36 lines (24 loc) · 974 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
import cv2 as cv
img = cv.imread('Photos/cat1.jpg')
def rescaleFrame(frame, scale=0.75): # for pictures, videos, live videos
width = int(frame.shape[1]*scale) #frame shape 1 is width
height = int(frame.shape[0] * scale) #frame shape 0 is height
dimensions = (width, height)
return cv.resize(frame, dimensions, interpolation=cv.INTER_AREA)
def changeRes(width,height): # only for videos
capture.set(3,width) # 3 is width
capture.set(4,height) # 4 is height
resized_image = rescaleFrame(img)
cv.imshow("Image", img)
cv.imshow("Image Resized", resized_image)
capture = cv.VideoCapture('Videos/catvideo.mp4') # video capture yerine 0,1 yazıp kamerayı kullanabiliyoruz
while True:
isTrue, frame = capture.read()
frame_resized = rescaleFrame(frame)
cv.imshow('Video', frame)
cv.imshow('Video Resized', frame_resized)
if cv.waitKey(20) & 0xFF==ord('d'):
break
capture.release()
cv.destroyAllWindows()
cv.waitKey(0)