How to slove opencv green screen?

When I use cv2.VideoCapture(0), no matter use opencv3.3.1 or opencv4.1.0 and use cap.Open(0) it will print green screen.
like this

import cv2

cap = cv2.VideoCapture(0)

ret, frame =
cv2.imshow(‘frame’, frame)

if cv2.waitKey(1) & 0xFF == ord(‘q’):


camera is used raspberry camera V2.1
At the beginning I am thinking that the camera may have problems but i used jetson inference sample,the camera can work normaly.
Is there any way to solve this problem?

You may try to use nvarguscamerasrc with ISP instead of V4L API:

cap = cv2.VideoCapture('nvarguscamerasrc ! video/x-raw(memory:NVMM), width=3280, height=2464, format=(string)NV12, framerate=(fraction)20/1 ! nvvidconv ! video/x-raw, format=(string)BGRx ! videoconvert ! video/x-raw, format=(string)BGR ! appsink' , cv2.CAP_GSTREAMER)

Thank you for your help i have another question can i change the camera mode to 640X480?Because i need more ram to run Tensorflow modle

I don’t have a Nano nor RPi cam for checking, but probably yes. This would also result in significantly decreased CPU load for videoconvert (you might also try to add plugin queue after videoconvert).
Just try to change width and height in the caps after nvarguscamerasrc. If it doesn’t work you may try to convert with nvvidconv, setting this resolution in caps after it (the ones with format BGRx).

Does anyone know how to fix this same issue but with a MIPI CSI camera? I tried this solution and it resulted in an exception.

Hi luwhatley.4576,

Please open a new topic for your own issue with clear information.