i'm new to openCv, i just wrote a little program in python for a real time camera capture. I wanted to change the frame size in px, from the standard 640x480 to 1280x720. My Logitech camera has a HD resolution (720p) so i know that that's not a camera problem...
This is the code:
import numpy as np
from time import sleep
import cv2
import time
cap = cv2.VideoCapture(0)
cap.set(3,1280)
cap.set(4,720)
sleep(2)
while(True):
ret, s = cap.read()
cv2.imshow('frame', s)
if cv2.waitKey(20) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
but when i run it, i get this error:
================== RESTART: C:/Users/Mattia/Desktop/fgs.py ==================
Traceback (most recent call last):
File "C:/Users/Mattia/Desktop/fgs.py", line 18, in <module>
cv2.imshow('frame', s)
cv2.error: OpenCV(4.0.0) C:\projects\opencv-python\opencv\modules\highgui\src\window.cpp:350: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'cv::imshow'
I'm using python 3.6 and openCv 4.0
Can someone help me? Thanks!
retisFalsebut that you're still trying to displaysas an image in that case? Have you triedcontinueing ifretisFalse?cap.set(3,1280) cap.set(4,720). Thanks for answering btw.sudo apt-get install v4l-utilsand runv4l2-ctl --list-formats-extto check supported resolutions.