Bounding Box is showing up in wrong place or not at all.

Hi, I am sending bounding box metadata from our analytics service to the recording server. These are the pixel locations we send for a 1920 x 1080 resolution camera stream:

Bottom: 474.0457

Top: 166.4543

Left: 845.4543

Right: 1153.046

Those pixel locations seem reasonable to me. The bounding box does not show up when queueing metadata to the channel using the following code snippet (which sends those pixel values for the bounding box):

Vector dummyCenterOfGravity = new Vector { X = 0f, Y = 0f }; // Value used here does not seem to have any effect
 };
 
            Rectangle boundingBox = new Rectangle
            {
                Top = rocDetection.y - (rocDetection.height / 2.0f),
                Left = rocDetection.x - (rocDetection.width / 2.0f),
                Bottom = rocDetection.y + (rocDetection.height / 2.0f),
                Right = rocDetection.x + (rocDetection.width / 2.0f),
                LineColor = DisplayColor.ParseArgbString("#FFF0F8FF"),
                FillColor = DisplayColor.ParseArgbString("#FFDC143C"),
                LineDisplayPixelThickness = 1
            };
 
            //var description = new DisplayText
            //{
            //    Value = "A square",
            //    FontFamily = "Helvetica",
            //    IsBold = false,
            //    IsItalic = false,
            //    Color = DisplayColor.ParseArgbString("#FFF0F8FF"),
            //    Size = 0.05f,
            //    CenterX = 0,
            //    CenterY = 0
            //};
 
            Transformation transformation = new Transformation
            {
                Translate = new Vector { X = 0.0f, Y = 0.0f },
                Scale = new Vector { X = 0.003125f, Y = 0.00416667f }
            };
 
            metadataFlow.Post(new CameraAnalyticsData // Post simply queues metadata
            {
                CameraGuid = mipCamera.FQID.ObjectId,
                AnalyticsMetadata = new VideoOS.Platform.Metadata.MetadataStream
                {
                    VideoAnalyticsItems =
                    {
                        new VideoAnalytics
                        {
                            Frames =
                            {
                                new Frame(DateTime.UtcNow)
                                {
                                    Objects =
                                    {
                                        new OnvifObject(1)
                                        {
                                            Appearance = new VideoOS.Platform.Metadata.Appearance
                                            {
                                                Shape = new Shape
                                                {
                                                    BoundingBox = boundingBox,
                                                    CenterOfGravity = dummyCenterOfGravity
                                                },
                                                //Description = description,
 
                                                //TODO: This has an effect but can't tell how it works?
                                               //Transformation = transformation
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            });

Trying various combinations of commenting/uncommenting the Transformation object, I can get the bounding box to show up in seemingly random places all over the camera view. Could you please point out if I’m doing something obviously wrong, or to an in-depth description of how the different properties of VideoOS.Platform.Metadata.OnvifObject (Appearance and Behavior) are used to draw the bounding box overlay? The VideoOS.Platform.Metadata.Shape class does not have very much description and most of the examples such as BoundingBoxMetadataProvider, MultiChannelMetadataProvider, or “Introduction to Metadata” use proportions of the camera image (values less than 1.0) rather than pixel values (values greater than 1.0) to draw the bounding box.

You must use values between -1.0 and 1.0, so you need to transform accordingly.

Hi Bo,

Thank you for your response. I have a few questions about your response as I still have been unable to get this box displaying correctly:

You must use values between -1.0 and 1.0” Is that just for the properties of the BoundingBox object (Top, Bottom, Left, Right), or for all object properties that are of type Metadata.Rectangle or Metadata.Vector, including CenterOfGravity, as well as Transformation.Translate and Transformation.Scale?

Also, I notice changing CenterOfGravity for the bounding box does not move it on the screen: Trying x,y values of (0.0f,0.0f), (0.1f, 0.0f), (0.5f, 0.0f), and (500.0f,0.0f) all result in a bounding box located in the center of the camera view rather than translating the box along the x axis as I had expected. Why doesn’t changing the values for CenterOfGravity result in the bounding box moving?

you need to transform accordingly” Are you referring to the Transformation class, and if so, do you have any examples of using this class? I have not found any examples of using this class in BoundingBoxMetadataProvider or MultiChannelMetadataProvider.

I have an idea that if you play with the BoundingBoxMetadataProvider sample you will see how the coordinates corresponds with the place the of display.