I'm trying to capture video/image feed from a USB 3.0 webcam. When ever I try to run this code,the code runs and captures feed. But, after a while I get 'select timeout'. The error is not grabbed by exception. Can someone help me with this issue?

select timeout OpenCV Error: Assertion failed (total() == 0 || data != __null) in Mat, file /home/opencv-3.4.0/modules/core/include/opencv2/core/mat.inl.hpp, line 500

try: while True: ret, frame = cap.read() if ret != True: break if stat == None: stat = ret print('[INFO] ---- Reading video feed') continue frame = cv2.resize(frame , (int(320/2),int(240/2))) video.write(frame) if stat1 == None: stat1 = ret print('[INFO] ---- Video recording on process') continue c+=1 print(c) key = cv2.waitKey(30) & 0xFF if key == 27: break elif c == 1200: break except Exception as e: print(e) sys.exit()

I have also tried editing the 'uvcvideo' driver parameters

$ modprobe uvcvideo nodrop=1 timeout=6000

And also, Enabled module traces,

$ sudo echo 0xffff > /sys/module/uvcvideo/parameters/trace

Observed these errors on 'dmesg' IMAGE

Link which I followed: Select Timeout error in Ubuntu - Opencv