This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TDA4AL-Q1: GStreamer issue: Padding images with borders while keeping aspect ratio

Part Number: TDA4AL-Q1

Tool/software:

Hi,

I'm working with the apps_python code under edgeai-gst-apps to process input images of size 640x360, padding them to 640x640 by adding borders to both top and bottom for neural network inference as belows:

     =====================>> 


 I attempted to modify the gst_wrapper.py file by deleting  the red code and adding the green code as belows:

Original code within the function:
------------------------------------------------------------------------------------------------
def get_dl_scaler_elements(flow, is_multi_src):
...
        dl_scaler_caps = "video/x-raw, width=%d, height=%d" % tuple(resize) #640*640
...
...
    elif flow.input.width / resize[0] < 1 or flow.input.height / resize[1] < 1:
        caps = "video/x-raw, width=%d, height=%d" % (
        flow.input.width, #640
        flow.input.height, #360
        )
        queue_element = make_element("queue", caps=caps)
        scale_element = make_element("videoscale", caps=dl_scaler_caps)

        else:
            queue_element = make_element("queue", caps=dl_scaler_caps)

        elem_list = queue_element

        if scale_element != None:
            elem_list += scale_element

        return elem_list


The modified code is as follows:
------------------------------------------------------------------------------------------------
def get_dl_scaler_elements(flow, is_multi_src):
...
        dl_scaler_caps = "video/x-raw, width=%d, height=%d" % tuple(resize) #640*640
...
...
        elif flow.input.width / resize[0] < 1 or flow.input.height / resize[1] < 1:
            caps = "video/x-raw, width=%d, height=%d" % (
                flow.input.width,
                flow.input.height,
            )

            queue_element = make_element("queue", caps=caps)
            scale_element = make_element("videobox", property = {"top":-140,"bottom":-140,"fill":1})            
            scale_element += make_element("capsfilter", caps=dl_scaler_caps)

        else:

            queue_element = make_element("queue", caps=dl_scaler_caps)


        elem_list = queue_element

        if scale_element != None:
            elem_list += scale_element

        return elem_list

 but  the pipeline stopped executing after the added videobox element. What is the reason for that?  How should I fix this code? The edgeai-gst-apps version I'm using is 09.02.00.05‌13.

Thanks,

BR,

Rata