My camera shows a green screen. I am using IMX 219 I don' know why the camera gives this output
import cv2
cap=cv2.VideoCapture(0)
while True:
r,im=cap.read()
cv2.imshow('dd',im)
k=cv2.waitKey(30) & 0xff
if k==27:
break
cap.release()
cv2.destroyAllWindows()
General theory
As said in this link, you can use
v4l2-ctl
to determine the camera capabilities.v4l2-ctl
is in thev4l-utils
:and then:
Looking to the same link and to this other, I saw that you can also quickly test your camera launching:
This simple
gst-launch
example can be used to determine the camera modes that are reported by the sensor you are using. Say for example that you get this output:then you should adjust accordingly the next command:
sensor_id=1
represents the right CSI camera slot, it can be either0
or1
. As you can see from this link, newer Jetson Nano Development Kits come with two CSI camera slots and you can use this attribute to specify the right one [0
is the default]. Please notice that at the same link they usesensor_mode
instead ofsensor_id
, I'd try with both. You don't necessarily need to includeflip-method
which is documented here though. All of this should give you an idea for the values to be inserted in the codeAlso, it has been noticed that the display transform is sensitive to width and height [in the above example,
width=816, height=616
]. If you experience issues, check to see if your display width and height is the same ratio as the camera frame size selected [in the above example, 816 and 616 are respectively a quarter of 3264 and 2464]OpenCV
Looking around on nVidia forum I found this post. The solution in that case was to use:
In your case though, the 20fps for your IMX 219 would be too high with a frame size equal to
3280x2464
. As you can see from the first table of this link the suggested value is 15fps while here they suggest 21fps. I would suggest you to start with thewidth
,height
,framerate
values retrieved in the previous section. Aframerate
value lower than the nominal one should help you test the connectivityA full sample where to include the previous line updated with the right values is available from here:
There is also a full snippet available at this other link that can help you find the reasons for failure
Lastly, if you can open the camera in GStreamer from the command line but not in Python have a check of the OpenCV version with the previous
print(cv2.getBuildInformation())
or more shortly with:Starting with L4T 32.2.1 / JetPack 4.2.2, GStreamer support is built into OpenCV. The OpenCV version is 3.3.1 for those versions and if you are using earlier versions of OpenCV [most likely installed from the Ubuntu repository] you will get
Unable to open camera
errors