Pdraw crashes after few seconds using Olympe

Hi,

I’m working on a solution that will take the video stream for the Anafi Drone and publish it on a ROS topic. I’m working on this drone since just a few weeks so I’m relatively new on Olympe.

I have issues with the video stream acquisition part. I managed to get a stream for a few seconds but after that, my all computer start to freeze.
The ROS part is perfectly working so I removed this part for testing the stream one.
I understood that Pdraw is the software that can display the stream on my computer, So I tried to display the stream only using:

./out/groundsdk-linux/staging/native-wrapper.sh pdraw -u rtsp://192.168.42.1/live

This worked perfectly but when I tried to do the same thing using a python script I had the freeze issue.
I guess that it comes from an memory overflow somewhere but I don’t know where.

Thanking you in advance.

class StreamingExample:

    def __init__(self):
        # Create the olympe.Drone object from its IP address
        self.drone = olympe.Drone(DRONE_IP)
        self.frame_queue = queue.Queue()
        self.flush_queue_lock = threading.Lock()
        self.renderer = None
        
        #Pdraw
        self.pdraw = Pdraw()
        self.pdraw.set_callbacks(
            raw_cb = self.yuv_frame_cb,
            flush_raw_cb = self.flush_cb  
        )

    def yuv_frame_cb(self, yuv_frame):
        """
        This function will be called by Olympe for each decoded YUV frame.

            :type yuv_frame: olympe.VideoFrame
        """
        # the VideoFrame.info() dictionary contains some useful information
        # such as the video resolution
        
        info = yuv_frame.info()
        height, width = (  # noqa
            info["raw"]["frame"]["info"]["height"],
            info["raw"]["frame"]["info"]["width"],
        )
        
        # yuv_frame.vmeta() returns a dictionary that contains additional
        # metadata from the drone (GPS coordinates, battery percentage, ...)

        # convert pdraw YUV flag to OpenCV YUV flag
        cv2_cvt_color_flag = {
            olympe.VDEF_I420: cv2.COLOR_YUV2BGR_I420,
            olympe.VDEF_NV12: cv2.COLOR_YUV2BGR_NV12,
        }[yuv_frame.format()]

        # yuv_frame.as_ndarray() is a 2D numpy array with the proper "shape"
        # i.e (3 * height / 2, width) because it's a YUV I420 or NV12 frame

        yuv_frame.ref()
        self.frame_queue.put_nowait(yuv_frame)

        print('Image received')

    def flush_cb(self, stream):
        if stream["vdef_format"] != olympe.VDEF_I420:
            return True
        with self.flush_queue_lock:
            while not self.frame_queue.empty():
                self.frame_queue.get_nowait().unref()
        return True

            
    def start(self):

        self.pdraw.play(url=DRONE_STREAM)

    def stop(self):
        self.pdraw.close()
        self.pdraw.dispose()

def streaming():
    streaming_anafi` = StreamingExample()
    streaming_anafi.start()
    time.sleep(10)
    streaming_anafi.stop()

if __name__ == "__main__":
    streaming()

Quit Edit.
I used the Pdraw.py script given by Parrot. It is working correctly but when I change the time.sleep from 10 to 100 it crashes with all my computer.
You can find the script here:

Do you know what is the issue ?

Second edit, it seems that the script is registering all the images on the memory which j is causing the freeze is talked about above.

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