Setting Camera Parameters | Computer Vision | Python
Nov 17, 2023
Source code
import cv2
cap = cv2.VideoCapture(0)
print(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
print(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
# Set property using set() method
cap.set(3, 6000)
cap.set(4, 6000)
print('New width and height of frame after setting')
print(cap.get(3))
print(cap.get(4))
while(cap.isOpened()):
ret, frame = cap.read()
if ret == True:
# Convert colored (BGR) image into gray scale image
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
cv2.imshow('Frame', gray)
k = cv2.waitKey(1)
if k == ord('q'):
break
else:
break
cap.release()
cv2.destroyAllWindows()
Webcam senario
Output in terminal