Created
July 5, 2018 19:16
-
-
Save elbruno/235691e7a7b9967f909a22a39fe47017 to your computer and use it in GitHub Desktop.
UwpYoloModelResizeToCurrentSize.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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