I bought my Rpi 4B, 4 months ago with an official Pi camera v2.1. Everything was working fine but now, I can't seem to receive frames with openCvpython library.

import cv2
cap = cv2.VideoCapture(0)

ret, frame = cap.read()

print(cap) #<VideoCapture 0xaa792f70>
print(ret) #False
print(frame) #None

It does seems to find the camera when printing cap.

Please note that all libcamera command are working properly on the terminal.

Also, the camera works with openCv on another Rpi with my same SdCard.

When the camera is plugged in, i see a rainbow screen on boot.

Can you help me? Do I need to reset my sdcard? Do I need to re-install the bootloader on the board?

Is there any other way i can get the camera stream live and make operation with openCv on it in python??

1 Answer 1


These are more or less two questions in one.

Also, the camera works with openCv on another Rpi with my same SdCard. should already suggest to you that the camera still works, so this must be a software problem. Is there any version differences between the Pi where your CV2 library does work, and the one where it doesn't? Do you get any errors?

I don't really see how plugging in your camera randomly shows the rainbow screen on boot. Have you disabled the splash screen completely from the /boot/config.txt file (disable_splash=1)?

  • Why should I disable splash screen? Isn't it a sign of something going wrong on boot?
    – Justin
    Mar 30, 2022 at 17:30
  • Sorry what? The rainbow coloured screen is a splash screen. It is enabled by default to show the user of the Raspberry that their display can show all those colours. I usually disable it, because I think it looks bad. It is not a sign of something going wrong. It is default behaviour. Mar 31, 2022 at 6:50
  • I understand, didn't know about that. I though of this because at first the rpi wasn't doing it and suddenly started to show the splash screen
    – Justin
    Apr 2, 2022 at 4:49
  • Splash screen removed. From cmdline.txt file btw. Since the sdcard is the same on both boards no difference between version of openCv and the os, ( an 11(bullseyes) . However, the only difference I know is that one is a rpi 3 and one is a rpi 4B after enabling legacy camera stack, openCv worked. That mean that the problem is coming from libcamera on my rpi 4B, since libcamera and openCv were working well on the rpi 3
    – Justin
    Apr 3, 2022 at 8:09
  • Then I didn't understand your question. Try and write a clear and reproducible question. Glad that you solved it. Please create a quick answer and solve your own thread so others can easily see how you fixed this :) Apr 4, 2022 at 9:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.