As the posnet.py start, the IP camera may not be ready, what is a proper way to keep the program from existing?
if(jetson.utils.videoSource(“rtsp…”)):?
I can do “try” in the loop just in case someone unplug the network cable…
try:
img = camera.Capture()
except:
print(“”)
Thx
import jetson.inference
import jetson.utils
net = jetson.inference.detectNet("ssd-mobilenet-v2", threshold=0.5)
#############################################
while not(jetson.utils.videoSource("rtsp........")):
camera = jetson.utils.videoSource("rtsp........")
#############################################
display = jetson.utils.videoOutput("display://0") # 'my_video.mp4' for file
while display.IsStreaming():
try:
img = camera.Capture()
except:
print("skip frame")
detections = net.Detect(img)
display.Render(img)
display.SetStatus("Object Detection | Network {:.0f} FPS".format(net.GetNetworkFPS()))
Hi @AK51, yes you can use the except handlers, and depending on the behavior of your IP camera you can eventually del camera and re-create it if you need to establish the pipeline again from scratch.
Also, there is an optional timeout parameter to videoSource.Capture() which specifies the timeout in milliseconds. The default is -1, which means never timeout. 0 means return immediately if no frame.
Do you delete (del) the previous videoSource before trying to create a new one? Also, you may need to add some sleep() statements to wait for some time before continually trying to re-connect.