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