Video Streaming issue with OpenCV

Hi,
Before powering up the Jetson Nano, when I hook up the pi camera, and then after powering the nano and running the OpenCV script, the camera works perfectly fine. But if I unplug the camera while the Jetson is still ON, and if I type ls /dev/video0 , it still shows the device (/dev/video)
But then when I plug in the camera instantly while the Jetson is still in On, and run the same OpenCV script, the image editor does not appear and I get multiple CRITICAL GStreamer messages in the command line as shown in the OpenCV log. And when I terminate and rerun the script again then it throws an error

Any idea why it is happening? It seems when I unplug the camera, it’s still locked by the hardware. But I do use cam.release() at the end of my script to release both software and hardware resource.
Here is cvlog
cvlog.txt (5.7 KB)

Further, I just realized that if I unplug and plug the camera (roughly after 30sec), the script again works!!
Anyway to rlease the CSI handle from the Jetson nano?

Hi,
After you remove the camera, please stop nvargus-daemon:

$ sudo service nvargus-daemon stop

And once the camera is re-plugged, please re-start the service:

$ sudo service nvargus-daemon start

It still doesn’t work. I just see black image editor.

I may be wrong, but I don’t think CSI or camera driver supports hot-plugging. Did you find any reference it should ?
It may work in some cases, but not sure the driver will properly handle any possible case.

I don’t think this is opencv related. You may just use nvgstcapture for checking.

Well, the hot-plugging certainly works for pi camera v2 but fails for other cameras so I thought if there was a way to release the CSI lock. But I guess you are right, it depends on how the hardware handles each camera pipeline.