depthai-python icon indicating copy to clipboard operation
depthai-python copied to clipboard

tryGet starts returning None

Open rr-yuki opened this issue 3 years ago • 9 comments

I'm running a script loosely based on the stereo_depth_from_host.py example, but I'm using tryGet() instead of get() for getting the estimated disparity since it seems to hang after 20 frames. However, tryGet also has a similar problem in which it starts returning None after the same amount of frames. Any idea what could be causing this?

rr-yuki avatar May 27 '22 05:05 rr-yuki

@rr-yuki when running stereo from host you need to send frames from the host. If you don't send frames from the host there's nothing to process, thus no output.

SzabolcsGergely avatar May 27 '22 08:05 SzabolcsGergely

Yeah, frames (left and right 640x400) are being sent from the host to the device constantly but eventually nothing gets output for some reason

rr-yuki avatar May 27 '22 08:05 rr-yuki

Make sure you send it in the same way as in the reference example. Right first, then left.

SzabolcsGergely avatar May 27 '22 08:05 SzabolcsGergely

Hmm it's still not working for me

Here's the chunk of code that gets stuck (using .get() this time)

Again, the weird thing is that it freezes after a certain amount of frames

def send_images(self, stereo: StereoImages):
        right_msg = create_img_msg(stereo.right, self.timestamp_ms, dai.CameraBoardSocket.RIGHT)
        self.q_in_right.send(right_msg)

        if self.timestamp_ms == 0:
            self.q_in_right.send(right_msg)

        left_msg = create_img_msg(stereo.left, self.timestamp_ms, dai.CameraBoardSocket.LEFT)
        self.q_in_left.send(left_msg)

        if self.timestamp_ms == 0:
            self.q_in_left.send(left_msg)

def calc_depth(self, stereo: StereoImages) -> dict:
        self.send_images(stereo)
        time.sleep(self.step_ms / 1000.0)

        self.timestamp_ms += self.step_ms
        data = {"stereo": stereo}

        outs = {k:self.out_qs[k].get() for k in self.q_names}
        data.update({k: v.getCvFrame() for k, v in outs.items()})

        return data

rr-yuki avatar May 30 '22 05:05 rr-yuki

@rr-yuki I suggest taking the following example as reference : https://github.com/luxonis/depthai-python/blob/main/examples/StereoDepth/stereo_depth_from_host.py, and modifying it to avoid mistakes. Are you able to run the above example without issues?

SzabolcsGergely avatar May 30 '22 05:05 SzabolcsGergely

I'll try that. Yes, I can run it without issue as far as I can tell.

rr-yuki avatar May 30 '22 06:05 rr-yuki

Ok, I think I figured it out. I didn't know that you have to make a DataOutputQueue for all XLinkOuts you create. Otherwise, it eventually silently freezes after some frames. Is this info somewhere in the documentation?

rr-yuki avatar May 30 '22 08:05 rr-yuki

Thanks for the valuable information. We will add it to docs/add a error check for it.

SzabolcsGergely avatar May 30 '22 08:05 SzabolcsGergely

@rr-yuki

By default, using dai::Device it creates the queues automatically, but with size of 16 and blocking. If you don't retrieve messages, it'll start blocking. We are yet to add better diagnostic information on such events, we'll address.

Thanks for the observation

themarpe avatar May 30 '22 08:05 themarpe