I managed to take a picture with Python and CV2 library, but I'd like to change the dimension of the image and get something not high quality and resize it down at 640.
My code is:
cam = VideoCapture(0) # 0 -> index of camera
s, img = cam.read()
if s: # frame captured without any errors
imwrite(filename,img) #save image
I have tried to use the method set but it doesn't work.
You can resize using opencv:
img = cv2.resize(img, (640, 640))
to set the resolution to 640x640, or
img = cv2.resize(img, (0,0), fx = 0.5, fy = 0.5)
to half each dimention of the image.
If you want worse quality, you can use a blur (I would recommend Gaussian):
img = cv2.GaussianBlur(img, (15,15), 0)
If you want more or less blurry, change the (15,15) (which is the Kernel size).
If you want to learn more about image processing, I found these quite useful:
OpenCV tutorials,
OpenCV image processing
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With