Green Screen Issue on Nvidia Jetson Nano and Raspberry Pi V2.1 Camera

Hi, I am using Nvidia Jetson Nano and Raspberry Pi V2.1 Camera for color detection via Python and OpenCV. However, the codes that worked on my computer do not work on Jetson Nano and I keep getting errors. The camera is working, I checked it. Also, Jetson Nano is in operation but camera does not opened. For “Frame” window, it shows full of green screen.

Here my code:

import cv2

import numpy as np

def nothing(x):
#any operation

cap = cv2.VideoCapture(0)

cv2.createTrackbar(“Lower-Hue”, “Trackbars”, 0,180, nothing)
cv2.createTrackbar(“Lower-Saturation”, “Trackbars”, 66,255, nothing)
cv2.createTrackbar(“Lower-Value”, “Trackbars”, 134,255, nothing)
cv2.createTrackbar(“Upper-Hue”, “Trackbars”, 180,180, nothing)
cv2.createTrackbar(“Upper-Saturation”, “Trackbars”, 255,255, nothing)
cv2.createTrackbar(“Upper-Value”, “Trackbars”, 243,255, nothing)


while True:
_,frame =
hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)

u_h = cv2.getTrackbarPos("Upper-Hue", "Trackbars")
u_s = cv2.getTrackbarPos("Upper-Saturation", "Trackbars")
u_v = cv2.getTrackbarPos("Upper-Value", "Trackbars")
l_h = cv2.getTrackbarPos("Lower-Hue", "Trackbars")
l_s = cv2.getTrackbarPos("Lower-Saturation", "Trackbars")
l_v = cv2.getTrackbarPos("Lower-Value", "Trackbars")

lower = np.array([l_h,l_s,l_v])
upper = np.array([u_h,u_s,u_v])

mask = cv2.inRange(hsv, lower, upper)

cv2.imshow("Frame", frame)
cv2.imshow("Mask", mask)

if cv2.waitKey(10) & 0xFF == ord('q'):


And here is the error:

(Trackbars:12682): GLib-GObject-CRITICAL **: 20:19:40.872: g_object_unref: assertion `G_IS_OBJECT (object)’ failed

(Trackbars:12682): GLib-GObject-CRITICAL **: 20:19:41.362: g_object_unref: assertion ‘G_IS_OBJECT (object)’ failed

Which JetPack and OpenCV version you used?

You can refer to below threads to see if can help:

How to slove opencv green screen? - Jetson & Embedded Systems / Jetson Nano - NVIDIA Developer Forums
Green screen when using Raspberry pi camera v2 attached to Jetson nano and cv2 (openCV) - Jetson & Embedded Systems / Jetson Nano - NVIDIA Developer Forums

JetPack 4.6 and OpenCV 4.1.1. Unfortunately, I’ve already tried solutions that you linked, but they didn’t work.

Please try the gst-launch-1.0 command and see if you can see camera preview:

gst-launch-1.0 nvarguscamerasrc ! nvoverlaysink

Yes, I can see camera preview with this command. My camera works correctly, I don’t know why the green screen appear when I run the code.

This would use V4L API for getting frames from camera.
The problem is that IMX219 driver provides only bayer RG10 format, and opencv video capture only supports 8 bits bayer formats.

A solution is to use gstreamer backend, with nvarguscamerasrc that will debayer with ISP, and then use nvvidconv for converting into BGRx with HW, and finally use videoconvert for providing BGR format to opencv:

cap = cv2.VideoCapture("nvarguscamerasrc ! video/x-raw(memory:NVMM),format=NV12,width=640,height=480,framerate=30/1 ! nvvidconv ! video/x-raw,format=BGRx ! videoconvert ! video/x-raw,format=BGR ! appsink drop=1", cv2.CAP_GSTREAMER)
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.