Hi @andrea_Faction, I’ve not tried using these objects inside Python threads, as the videoSource interface already uses threading internally (inside it’s C++ implementation), so not sure additional threading from the Python side is needed. Does the same program flow work without threading?
A couple things to try:
- As a test, inside Run() comment out the other stuff besides
display.Render()
. Is the display still black?
self.display.Render(img)
#detections = self.net.Detect(img)
# do something with the detectors
# convert to jpeg and ....
#jetson.utils.cudaDeviceSynchronize()
#image = jetson.utils.cudaToNumpy(img)
#encoded = cv2.imencode(".jpg", image)[1].tostring()
- Starting the stream with Capture() in another thread shouldn’t be necessary, as the stream will automatically start the first time you call Capture(). So skip start_streaming() and just do that inside Run(), and try creating the resources inside the there too. Something like this:
def run(self):
camera_URI = "/dev/video"+str(self.cn)
self.cap = jetson.utils.videoSource(camera_URI)
self.display = jetson.utils.videoOutput("display://0") # 'my_video.mp4' for file
while True:
img = self.cap.Capture()
self.display.Render(img)