Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
26 changes: 26 additions & 0 deletions doc/Analytics.xml
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,32 @@
</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:element name="Translate" type="Vector" minOccurs="0"/>
<xs:element name="Scale" type="Vector" minOccurs="0"/>
...
</xs:sequence>
</xs:complexType>
]]></programlisting>
<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 (320,240). The video source aspect ratio is 4:3. 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
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
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
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
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

<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
8 changes: 8 additions & 0 deletions wsdl/ver10/schema/common.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,14 @@ 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: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
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
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