Jetson TX2 onboard camera is not available

Hello, I tried to capture and display video using opencv and jetson tx2 onboard camera.

I downloaded jetpack 4.3 for opencv and version of opencv is 4.1.1.

I saw cat /etc/nv_tegra_release

# R32 (release), REVISION: 3.1, GCID: 18186506, BOARD: t186ref, EABI: aarch64, DATE: Tue Dec 10 07:03:07 UTC 2019

And I executed some test code below:

import sys
import cv2
import gi
gi.require_version('Gst', '1.0')
from gi.repository import Gst
def read_cam():
    cap = cv2.VideoCapture("nvarguscamerasrc ! video/x-raw(memory:NVMM), width=(int)1920, height=(int)1080,format=(string)NV12, framerate=(fraction)30/1 ! nvvidconv ! video/x-raw, format=(string)BGRx ! videoconvert ! video/x-raw, format=(string)BGR ! appsink")
    if cap.isOpened():
        cv2.namedWindow("demo", cv2.WINDOW_AUTOSIZE)
        while True:
            ret_val, img = cap.read()
            cv2.imshow('demo',img)
            if cv2.waitKey(1) == ord('q'):
                break
            else:
                print ("camera open failed")

if __name__=="__main__":
    read_cam()

then I had the error

Error generated. /dvs/git/dirty/git-master_linux/multimedia/nvgstreamer/gst-nvarguscamera/gstnvarguscamerasrc.cpp, execute:532 No cameras available
[ WARN:0] global /home/nvidia/host/build_opencv/nv_opencv/modules/videoio/src/cap_gstreamer.cpp (933) open OpenCV | GStreamer warning: Cannot query video position: status=0, value=-1, duration=-1
Gtk-Message: 16:44:29.638: Failed to load module "canberra-gtk-module"
Traceback (most recent call last):
  File "thank.py", line 19, in <module>
    read_cam()
  File "thank.py", line 12, in read_cam
    cv2.imshow('demo',img)
cv2.error: OpenCV(4.1.1) /home/nvidia/host/build_opencv/nv_opencv/modules/highgui/src/window.cpp:352: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'imshow'

I tried to execute another example code for activating the camera but I got always ‘No cameras available’ :(

How can I solve this problem?

p.s Would you mind if I ask you a gentle document for activating camera step by step? :D
I’m sorry poor English. I’m in Non-English country.

Check this link

https://jkjung-avt.github.io/tx2-camera-with-python/

Thank you for your reply.
I executed tegra-cam.py.
I got an error like this.

Called with args:
Namespace(image_height=1080, image_width=1920, rtsp_latency=200, rtsp_uri=None, use_rtsp=False, use_usb=False, video_dev=1)
OpenCV version: 4.1.1
Traceback (most recent call last):
  File "camera_plz.py", line 154, in <module>
    main()
  File "camera_plz.py", line 141, in main
    args.image_height)
  File "camera_plz.py", line 60, in open_cam_onboard
    gst_elements = str(subprocess.check_output('gst-inspect-1.0'))
  File "/usr/lib/python3.6/subprocess.py", line 356, in check_output
    **kwargs).stdout
  File "/usr/lib/python3.6/subprocess.py", line 423, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/usr/lib/python3.6/subprocess.py", line 729, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.6/subprocess.py", line 1364, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'gst-inspect-1.0': 'gst-inspect-1.0'

Weird seems the gst-inspect-1.0 not install! It should be install as default image.
Check if can run gst-inspect-1.0 in console.

Thanks a lot for your fast answer.
I checked whether gst-inspect-1.0 installed and it doesn’t.
So I installed gst-inspect-1.0 libraries.
And I got this:

Called with args:
Namespace(image_height=1080, image_width=1920, rtsp_latency=200, rtsp_uri=None, use_rtsp=False, use_usb=False, video_dev=1)
OpenCV version: 4.1.1
Error generated. /dvs/git/dirty/git-master_linux/multimedia/nvgstreamer/gst-nvarguscamera/gstnvarguscamerasrc.cpp, execute:532 No cameras available
[ WARN:0] global /home/nvidia/host/build_opencv/nv_opencv/modules/videoio/src/cap_gstreamer.cpp (933) open OpenCV | GStreamer warning: Cannot query video position: status=0, value=-1, duration=-1
Traceback (most recent call last):
  File "camera_plz.py", line 154, in <module>
    main()
  File "camera_plz.py", line 147, in main
    read_cam(cap)
  File "camera_plz.py", line 108, in read_cam
    cv2.imshow(WINDOW_NAME, img)
cv2.error: OpenCV(4.1.1) /home/nvidia/host/build_opencv/nv_opencv/modules/highgui/src/window.cpp:352: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'imshow'

I think that the camera can not be accessed by the board or it aren’t activate.
I don’t know why. Maybe camera module is broken…? like my future…:(

If it would be solved, I will kiss you.

Looks like your system didn’t detect camera sensor.
check with v4l2-ctl --list-devices

I admire your answer!
Regrettably, there is no /dev/video0…

ailed to open /dev/video0: No such file or directory

What should I do…?
Help me… :( plz…

I read the camera module on jetson tx2 as a default.
Doesn’t it? Then why it doesn’t have /dev/video0 directory?

I disassembled the camera module and reassemble it once.
Does it matter?

Does your camera module are the default one?
Check the kernel message if can get more information. dmesg | grep -i ov5693

It is the default one.
I received NVIDIA JETSON TX@ DEVELOPER KIT which includes the camera(5 MP Fixed Focus MIPI CSI Camera) attached on the board.

[    5.411166] ov5693 2-0036: probing v4l2 sensor.
[    5.412089] ov5693 2-0036: tegracam sensor driver:ov5693_v2.0.6
[    6.493319] Modules linked in: bcmdhd cfg80211 spidev ov5693(+) binfmt_misc nvgpu bluedroid_pm ip_tables x_tables
[    6.703540] [<ffffff800116b0c0>] init_module+0x18/0x30 [ov5693]

I had been with this problem for a month!!!
It thwart me…

You are my angel.

Did you try to reflash the device?

I used OS originally installed, but when I installed jetpack, OS was newly installed.
Does it matter?

It’s could be HW or connector problem cause the camera detected failure.
Could you try remove the camera and reinstall it again to try.
If still have problem with the default camera sensor you can send the device to RMA.

After rebooting the device, the problem is solved.
I think reboot is the best solution. Ha Ha LOL~~~

Thank you very much :D YEee~~