Camera open failed with rc.local

Hi, i want to open camera when i boot my jetson.
so i modify rc.local
#!/bin/bash
source ~/.bashrc
sudo -H -u username /usr/bin/python3 /home/username/tensorrt_demos/trt_yolo.py --usb 0
exit 0

so when i reboot, i receive '/tmp/pip-req-build-ofkf3yxb/opencv/modules/videoio/src/cap_v4l.cpp (890) open VIDEOIO(V4L2:/dev/video0): cant’t open camera by index.

so i tried modify cv2.VideoCapture(0) → cv2.VideoCaputre(cv2.CAP_V4L2)
but It was useless.

so how can i fix my error??

hello user18875,

may I know what’s the camera format you’re using, is it a bayer sensor or usb camera?

usb camera.

hello user18875,

you’ll need to ensure you’ve usb camera device registered to linux kernel.
please test with some workarounds by adding delay in the script file before execute the video capture,
thanks

i tired at command shell, it works.

but when i boot with rc.local, it doesn’t work.

hello user18875,

there should be dependency with the camera service, please check /etc/systemd/system/ for some service configurations.

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