i'm sending images to a REST API and receiving some information like boundingboxes related to this image. Those bb's are described over x,y,with,height in Pixels. Now i want to add rectangle annotations with a transparent filling to visualize those bb's and show the result in an WpfAnnotationViewer.
My code looks similar to this:
Code: Select all
AnnotationDataController annotationDataController = new AnnotationDataController(new ImageCollection { new VintasoftImage(ocrImagePathTextBox.Text, true) });
AnnotationViewController annotationViewController = new AnnotationViewController(annotationDataController);
Rect bb = ...; // Let this be the position and size of the bb in Pixels.
RectangleAnnotationData annotationData = new RectangleAnnotationData();
annotationData.Location = new System.Drawing.PointF(
(float)UnitOfMeasureConverter.ConvertToDeviceIndependentPixels(bb.X, UnitOfMeasure.Pixels, annotationDataController.Images[0].Resolution.Horizontal),
(float)UnitOfMeasureConverter.ConvertToDeviceIndependentPixels(bb.Y, UnitOfMeasure.Pixels, фnnotationDataController.Images[0].Resolution.Vertical));
annotationData.Size = new System.Drawing.SizeF(
(float)UnitOfMeasureConverter.ConvertToDeviceIndependentPixels(bb.Width, UnitOfMeasure.Pixels, annotationDataController.Images[0].Resolution.Horizontal),
(float)UnitOfMeasureConverter.ConvertToDeviceIndependentPixels(bb.Height, UnitOfMeasure.Pixels, annotationDataController.Images[0].Resolution.Vertical));
annotationData.FillBrush = new AnnotationSolidBrush(System.Drawing.Color.Transparent);
annotationDataController.GetAnnotations(0).Add(annotationData);
annotationViewController.BurnAnnotationCollectionOnImage(0);
AnnotationViewer.Images = annotationDataController.Images;
What am i doing wrong here?
Thanks a lot.