Skip to content
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions doc/Analytics.xml
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,37 @@
</tt:Frame>
]]></programlisting>
</section>
</section>
<section>
<title>Aspect Ratio Dependant Transformation</title>
<para>This section describes the transformation specific to a scene aspect ratio.</para>
<para>Same as the transformation node, this node is used to apply final geometric transformations to the scene elements when the device supports more than one aspect ratio. This node allows the client to choose which transformation to apply, matching the metadata aspect ratio to the rendered aspect ratio.</para>
<para>The aspect ratio transformation node can contain the following elements:</para>
<programlisting><![CDATA[<xs:complexType name="AspectRatioTransformation">
<xs:sequence>
<xs:attribute name="ratio" type="xs:float" use="required"/>
<xs:element name="Translate" type="Vector" minOccurs="0"/>
<xs:element name="Scale" type="Vector" minOccurs="0"/>
...
</xs:sequence>
</xs:complexType>
]]></programlisting>
<para>If the transformation is a centered crop on one axis, no Translate vector is needed and Scale vector is calculated with this formula.</para>
<para>For the rendered aspect ratios greater than the video source aspect ratio, fix ScaleX = 1 and compute ScaleY = RenderedAspectRatio / VideoSourceAspectRatio.</para>
<para>For the rendered aspect ratios less than the video source aspect ratio, fix ScaleY = 1 and compute ScaleX = VideoSourceAspectRatio / RenderedAspectRatio.</para>
<para>For example, the coordinates of the scene description are given in a frame coordinate system, where the lower-left corner has coordinates (0,0) and the upper-right corner coordinates (1920,1440). The video source aspect ratio is 4:3. The device supports resolutions 1920x1080 and 960x576 corresponding aspect ratio 16:9 = 1.77777778 and 5:3 = 1.66666667.</para>
<para>The frame node resembles the following code, where the scale is set to crop the image to other supported aspect ratios:</para>
<programlisting><![CDATA[<tt:Frame UtcTime="2008-10-10T12:24:57.321">
Copy link
Copy Markdown
Contributor

@sujithhanwha sujithhanwha Dec 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be helpful to include an example here, since this scale differs from the normalization scale used in the transformation.

Ratio = ProfileResolutionWidth / ProfileResolutionHeight
Scale X = VideoSourceWidth / ProfileWidth
Scale Y = VideoSourceHeight / ProfileHeight

Currently this assumes a centered crop (equal offsets on top and bottom, right and left). If the crop offset is not equal, should we consider applying an optional Translate to reposition the cropped region correctly ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the Translate is optional, but needed if it is not a centered crop. Do you recommend having one Frame example for centered use-case and one whole Frame example for a non-centered crop ?
I think a device should not have both for a video source.

Copy link
Copy Markdown
Author

@cemond-genetec cemond-genetec Dec 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the Scale for the centered case, we concluded 2 simple formulas.
When Resolution aspect ratio is greater than video source aspect ratio,
ScaleX = 1 and ScaleY = ResolutionAspectRatio / VideoSourceAspectRatio.

When Resolution aspect ratio is greater than video source aspect ratio,
ScaleY = 1 and ScaleX = VideoSourceAspectRatio / ResolutionAspectRatio.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cemond-genetec,

Thanks for the clarification.

Request to add an example also for clarity, please check if this kind of example is ok ?

Aspect Ratio Based Scaling

  • If ProfileAspectRatio > VideoSourceAspectRatio → the profile is wider than the source

    • Fix ScaleX = 1
    • Compute ScaleY = ProfileAspectRatio / VideoSourceAspectRatio
  • If VideoSourceAspectRatio > ProfileAspectRatio → the source is wider than the profile

    • Fix ScaleY = 1
    • Compute ScaleX = VideoSourceAspectRatio / ProfileAspectRatio

Example

Suppose:

  • Video source = 1920×1080 → Aspect ratio = 1920 /1080 = 1.78
  • Profile resolution = 640×480 → Aspect ratio = 640/480 = 1.33

Since VideoSourceAspectRatio > ProfileAspectRatio:

  • Fix ScaleY = 1
  • Calculate:
    ScaleX = 1.78/1.33 = Appx 1.34

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed an update with this idea.

<tt:AspectRatioTransformation ratio="1.66666667">
<tt:Scale x="1" y="1.25"/>
</tt:AspectRatioTransformation>
<tt:AspectRatioTransformation ratio="1.77777778>
<tt:Scale x="1" y="1.33333333"/>
</tt:AspectRatioTransformation>
...
</tt:Frame>
]]></programlisting>
<para>In every Frame, the device must add the nodes for at least the currently configured aspect ratios. The node for the video source aspect ratio should be omitted.</para>
</section>
<section>
<title>Scene Elements</title>
Expand Down
9 changes: 9 additions & 0 deletions wsdl/ver10/schema/common.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,15 @@ IN NO EVENT WILL THE CORPORATION OR ITS MEMBERS OR THEIR AFFILIATES BE LIABLE FO
<xs:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> <!-- first Vendor then ONVIF -->
</xs:sequence>
</xs:complexType>
<xs:complexType name="AspectRatioTransformation">
<xs:sequence>
<xs:attribute name="ratio" type="xs:float" use="required"/>
<xs:element name="Translate" type="tt:Vector" minOccurs="0"/>
<xs:element name="Scale" type="tt:Vector" minOccurs="0"/>
<xs:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:anyAttribute processContents="lax"/>
</xs:complexType>
<!--===============================-->
<!-- Location/Orientation Types -->
<!--===============================-->
Expand Down
1 change: 1 addition & 0 deletions wsdl/ver10/schema/metadatastream.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ IN NO EVENT WILL THE CORPORATION OR ITS MEMBERS OR THEIR AFFILIATES BE LIABLE FO
<xs:element name="Extension" type="tt:FrameExtension" minOccurs="0"/>
<xs:element name="SceneImageRef" type="xs:anyURI" minOccurs="0"/>
<xs:element name="SceneImage" type="xs:base64Binary" minOccurs="0"/>
<xs:element name="AspectRatioTranformation" type="tt:AspectRatioTransformation" minOccurs="0"/>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest to add the same as optional element inside object also, to keep it consistent with "ObjectTrack" Event.

Copy link
Copy Markdown
Author

@cemond-genetec cemond-genetec Dec 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you are referring to A.10 Object Track Aggregation.
I agree the same issue applies if the VMS needs to draw or compare the tt::Object data on a specific resolution.
However, I am not sure the best place to put AspectRatioTransformation. To me, Object data should only contain the position in the video source area.

<xs:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> <!-- reserved for ONVIF -->
</xs:sequence>
<xs:attribute name="UtcTime" type="xs:dateTime" use="required"/>
Expand Down