The USB ports on Raspberry Pi 4 goes blank for a few seconds and returns back to normal

Thread Starter


Joined Jun 30, 2022
Hey there, I'm using Raspberry Pi 4B and running OpenCV on it. I have attached webcam for video steam to detect objects using OpenCV, also, a mouse and keyboard. I'm facing a very unique problem here, when I run the python script containing the OpenCV program, it runs smoothly without any errors, and the frame window (webcam) is opened for detection. But after some time (say 50 frames), the RGB lights on my mouse and keyboard turns off meaning that they stop working (goes blank) as well as the webcam which is also connected to one of the USB ports, stops working, but everything turns back on after a second or two. So, the whole problem process takes like 1~2 seconds. Due to this problem, the program shows an error.

frame = imutils.resize(frame, width=400)
File "home\pi\python\lib\site-packages\imutils\", line 69, in resize
(h, w) = image.shape[:2]
AttributeError: 'NoneType' object has no attribute 'shape'

which basically means that the program is unable to read frames from the webcam as it gets non-responsive for like 1~2 seconds.
Not to mention that this problem doesn't occur while idling or doing anything else.

What could be the cause that is making Raspberry Pi do that weird thing?