# Object meta dimensions don't match source

**URL:** <https://forums.developer.nvidia.com/t/object-meta-dimensions-dont-match-source/277383>\
**Category:** DeepStream SDK\
**Tags:** opencv, python, nvbugs, gstreamer\
**Created:** [December 28, 2023, 5:36pm UTC](https://forums.developer.nvidia.com/t/object-meta-dimensions-dont-match-source/277383 "2023-12-28T17:36:55Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![haydn.morris](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@haydn.morris](https://forums.developer.nvidia.com/u/haydn.morris)\
**Post date:** [December 28, 2023, 5:36pm UTC](https://forums.developer.nvidia.com/t/object-meta-dimensions-dont-match-source/277383/1 "2023-12-28T17:36:55Z")

</div>

Please provide complete information as applicable to your setup.

**• Hardware Platform (Jetson / GPU)** Jetson Orin  
**• DeepStream Version** 6.2  
**• JetPack Version (valid for Jetson only)** 5.1

Hi

I am a little confused by the numbers that I am seeing for the top, left, width and height values of the NvOSD\_RectParams object from my frame meta objects.

If I get print the CV2 image shape, I get the resolution 960 x 544  
If I print the source\_width and source\_height of the frame meta (NvDsFrameMeta) I get 704 x 576 (which matches the original camera res)

However, if I print the properties of the object rectangle (NvOSD\_RectParams) I get the following values (as an example):  
Top: 677  
Left: 1015  
Width: 6  
Height: 22

These dimensions don’t fit inside either of the images (that I would expect them to fit inside)

Do you know what these dimensions represent? In the docs it just says “pixels”, but I’m struggling to find which pixels. The application I am using is structured similarly to `deepstream_imagedata-multistream_redaction.py`

---

<div class="post-metadata">

**Author:** ![junshengy](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/junshengy/32/251332_2.png) [@junshengy](https://forums.developer.nvidia.com/u/junshengy)\
**Post date:** [December 29, 2023, 8:47am UTC](https://forums.developer.nvidia.com/t/object-meta-dimensions-dont-match-source/277383/3 "2023-12-29T08:47:01Z")

</div>

How did you print these values? As you understand, these values represent pixels.

Can you share the code and configuration files? Or tell me how to reproduce your problem using sample code

---

<div class="post-metadata">

**Author:** ![haydn.morris](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@haydn.morris](https://forums.developer.nvidia.com/u/haydn.morris)\
**Post date:** [December 29, 2023, 10:53am UTC](https://forums.developer.nvidia.com/t/object-meta-dimensions-dont-match-source/277383/4 "2023-12-29T10:53:35Z")

</div>

This is how I am printing them (`obj_meta` is a `NvDsObjectMeta`):

```auto
    ...
    rect_params = obj_meta.rect_params
    top = int(rect_params.top)
    left = int(rect_params.left)
    width = int(rect_params.width)
    height = int(rect_params.height)
    print(top, left, width, height, classification, confidence)

```

My pipeline has:

- a nvstreammux with dimensions of 960x544
- a nvinfer pgie with the default `config_infer_primary_peoplenet.yml` config from DS tao (infer-dims: 3;544;960)
- a nvtracker with dimensions of 640 x 384
- a nvdsanalytics with the same dimensions as the tracker
- a nvvideoconvert
- a capsfilter
- a fake sink which my probe is added to (same setup as `deepstream_imagedata-multistream_redaction.py`)

The pipeline elements are linked in the order as described above.

As stated in the original question, if I do:

```auto
n_frame = pyds.get_nvds_buf_surface(hash(gst_buffer), frame_meta.batch_id)
print(n_frame.shape)

```

I get 960 x 544 as the resolution.

If I do:

```auto
frame_meta = pyds.NvDsFrameMeta.cast(l_frame.data)
print(frame_meta.source_width, frame_meta.source_height)

```

I get 704 x 576, which is the resolution that the camera is set to.

---

<div class="post-metadata">

**Author:** ![junshengy](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/junshengy/32/251332_2.png) [@junshengy](https://forums.developer.nvidia.com/u/junshengy)\
**Post date:** [January 2, 2024, 8:53am UTC](https://forums.developer.nvidia.com/t/object-meta-dimensions-dont-match-source/277383/5 "2024-01-02T08:53:31Z")

</div>

> [@haydn.morris](#):
>
> `print(frame_meta.source_width, frame_meta.source_height)`

Do you mean `frame_meta.source_frame_width` and `frame_meta.source_frame_height` ？

As described in the documentation:

- **source\_frame\_width** – _int_, Holds the width of the frame at input to Gst-streammux.
- **source\_frame\_height** – _int_, Holds the height of the frame at input to Gst-streammux.

So they refer to the unscaled width and height of the video

> **[NvDsFrameMeta — Deepstream Deepstream Version: 6.2 documentation](https://docs.nvidia.com/metropolis/deepstream/6.2/dev-guide/python-api/PYTHON_API/NvDsMeta/NvDsFrameMeta.html)**

> [@haydn.morris](#):
>
> ```auto
> n_frame = pyds.get_nvds_buf_surface(hash(gst_buffer), frame_meta.batch_id)
> print(n_frame.shape)
> 
> ```

This refers to the width and height of the batch size, which is inferred after scaling by nvinfer.

> **[unmap\_nvds\_buf\_surface() - alloc\_custom\_struct — Deepstream Deepstream Version:...](https://docs.nvidia.com/metropolis/deepstream/6.2/dev-guide/python-api/PYTHON_API/Methods/methodsdoc.html#get-nvds-buf-surface)**
>
> Allocate an CustomDataStruct.

---

<div class="post-metadata">

**Author:** ![haydn.morris](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@haydn.morris](https://forums.developer.nvidia.com/u/haydn.morris)\
**Post date:** [January 2, 2024, 9:00am UTC](https://forums.developer.nvidia.com/t/object-meta-dimensions-dont-match-source/277383/6 "2024-01-02T09:00:49Z")

</div>

Sorry, yes I do mean **source\_frame\_width** / **source\_frame\_height**

So if the unscaled dimensions of the frame are 704 x 576, and the scaled dimensions are 960 x 544, how is it possible that the bounding box in the NvOSD\_RectParams can start at left: 1015, top: 677 (see original question)?

Those dimensions are out of both the unscaled and the scaled dimensions of the frame.

For more context: I am using the function `draw_bounding_boxes` from the examples to try to draw the bounding boxes on the images, but the boxes are outside of the frame.

---

<div class="post-metadata">

**Author:** ![junshengy](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/junshengy/32/251332_2.png) [@junshengy](https://forums.developer.nvidia.com/u/junshengy)\
**Post date:** [January 2, 2024, 9:05am UTC](https://forums.developer.nvidia.com/t/object-meta-dimensions-dont-match-source/277383/7 "2024-01-02T09:05:26Z")

</div>

Can you provide a test stream to reproduce the problem?

I tested `deepstream-imagedata-multistream-redaction` and did not find this problem.

I use `/opt/nvidia/deepstream/deepstream/samples/streams/sample_720p.h264` to test.

---

<div class="post-metadata">

**Author:** ![haydn.morris](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@haydn.morris](https://forums.developer.nvidia.com/u/haydn.morris)\
**Post date:** [January 2, 2024, 9:51am UTC](https://forums.developer.nvidia.com/t/object-meta-dimensions-dont-match-source/277383/8 "2024-01-02T09:51:23Z")

</div>

I just tried my code with [this stock video](https://www.istockphoto.com/video/view-from-cctv-cameras-at-flight-of-stairs-gm1470456587-501298323) and the bounding boxes were drawn correctly, so I assume the issue is related to the stream that I am using.

The issue also seems to be intermittent with our own streams. I have tried ~200 streams and the problem exists for some but not others.

It would help me to know how the NvOSD\_RectParams is calculated. In the documentation it says that it is just “pixels”, but what are the pixels based on? The scaled image or the unscaled image? Or something else?

---

<div class="post-metadata">

**Author:** ![junshengy](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/junshengy/32/251332_2.png) [@junshengy](https://forums.developer.nvidia.com/u/junshengy)\
**Post date:** [January 3, 2024, 6:38am UTC](https://forums.developer.nvidia.com/t/object-meta-dimensions-dont-match-source/277383/10 "2024-01-03T06:38:14Z")

</div>

> [@haydn.morris](#):
>
> but what are the pixels based on? The scaled image or the unscaled image? Or something else?

Scaled image，The coordinates will be drawn by `nvdsosd`

---

<div class="post-metadata">

**Author:** ![haydn.morris](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@haydn.morris](https://forums.developer.nvidia.com/u/haydn.morris)\
**Post date:** [January 3, 2024, 8:33am UTC](https://forums.developer.nvidia.com/t/object-meta-dimensions-dont-match-source/277383/12 "2024-01-03T08:33:03Z")

</div>

So how is it possible for the “left” coordinate to be \>1000 if the scaled image is only 960px wide?

---

<div class="post-metadata">

**Author:** ![junshengy](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/junshengy/32/251332_2.png) [@junshengy](https://forums.developer.nvidia.com/u/junshengy)\
**Post date:** [January 3, 2024, 9:06am UTC](https://forums.developer.nvidia.com/t/object-meta-dimensions-dont-match-source/277383/13 "2024-01-03T09:06:04Z")

</div>

**There is no update from you for a period, assuming this is not an issue anymore.  
Hence we are closing this topic. If need further support, please open a new one. Thanks**

I think this is normal, but it depends on the output of the model.

If you can upgrade to DS-6.4, setting the `crop-objects-to-roi-boundary` property to true can avoid this problem.

[https://docs.nvidia.com/metropolis/deepstream/dev-guide/text/DS\_plugin\_gst-nvinfer.html#id2](https://docs.nvidia.com/metropolis/deepstream/dev-guide/text/DS_plugin_gst-nvinfer.html#id2)

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/system/32/68080_2.png) [@system](https://forums.developer.nvidia.com/u/system)\
**Post date:** [January 17, 2024, 9:06am UTC](https://forums.developer.nvidia.com/t/object-meta-dimensions-dont-match-source/277383/14 "2024-01-17T09:06:58Z")

</div>

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