Only getting single-channel (grayscale) images when accessing onboard camera with OpenCV 3.1.0

I am running L4T 24.2.0 with OpenCV 3.1.0 that I compiled myself, and I’m trying to capture frames in Python from the onboard camera.

When I run the following command, I get frames that are single channel (grayscale). If I initiate a video capture from the command line with nvoverlaysink, I can see color video. I’ve tried all the combinations of gstreamer pipeline I could find here but nothing works. Any ideas what could be going wrong, and how I can get opencv-style BGR frames?

cap = cv2.VideoCapture('nvcamerasrc ! video/x-raw(memory:NVMM),width=(int)1280,height=(int)720,format=(string)I420,framerate=(fraction)24/1 ! nvvidconv flip-method=2 ! appsink')
ret,frame =

Try this pipeline:

"nvcamerasrc ! video/x-raw(memory:NVMM), width=(int)1280, height=(int)720,format=(string)I420, framerate=(fraction)24/1 ! nvvidconv flip-method=2 ! video/x-raw, format=(string)BGRx ! videoconvert ! video/x-raw, format=(string)BGR ! appsink"


Works, thanks very much!