-
Notifications
You must be signed in to change notification settings - Fork 118
Add metadata aspect ratio transformation #667
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: development
Are you sure you want to change the base?
Conversation
| </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"> |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
| <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"/> |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
The metadata stream uses the camera’s sensor image as the transformation reference.
The client needs to transform the coordinates of the elements from the video source's aspect ratio to the resolution's aspect ratio.
Add to the Frame node a new transformation for each supported aspect ratio.