Skip to content

Instantly share code, notes, and snippets.

@elbruno
Created July 5, 2018 19:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elbruno/235691e7a7b9967f909a22a39fe47017 to your computer and use it in GitHub Desktop.
Save elbruno/235691e7a7b9967f909a22a39fe47017 to your computer and use it in GitHub Desktop.
UwpYoloModelResizeToCurrentSize.cs
private uint _overlayCanvasActualWidth;
private uint _overlayCanvasActualHeight;
private void DrawYoloBoundingBox(YoloBoundingBox box, Canvas overlayCanvas)
{
// get current webcam and canvas size
_overlayCanvasActualWidth = (uint)YoloCanvas.ActualWidth;
_overlayCanvasActualHeight = (uint)YoloCanvas.ActualHeight;
// process output boxes
var x = (uint)Math.Max(box.X, 0);
var y = (uint)Math.Max(box.Y, 0);
var w = (uint)Math.Min(overlayCanvas.ActualWidth - x, box.Width);
var h = (uint)Math.Min(overlayCanvas.ActualHeight - y, box.Height);
// fit to current canvas and webcam size
x = _overlayCanvasActualWidth * x / 416;
y = _overlayCanvasActualHeight * y / 416;
w = _overlayCanvasActualWidth * w / 416;
h = _overlayCanvasActualHeight * h / 416;
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment