From 13aeff40267dbc03e7dfda691fb7483e1777e56d Mon Sep 17 00:00:00 2001 From: Lionel Jouin Date: Sun, 4 Nov 2018 13:52:02 +0100 Subject: [PATCH] Fix: DPI with ML #3 --- .../DataModel/RegionPrediction.cs | 12 ----------- PiP-Tool/ViewModels/CropperViewModel.cs | 20 +++++++++++++++---- PiP-Tool/ViewModels/PiPModeViewModel.cs | 3 --- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/PiP-Tool.MachineLearning/DataModel/RegionPrediction.cs b/PiP-Tool.MachineLearning/DataModel/RegionPrediction.cs index c3d45b6..f883003 100644 --- a/PiP-Tool.MachineLearning/DataModel/RegionPrediction.cs +++ b/PiP-Tool.MachineLearning/DataModel/RegionPrediction.cs @@ -76,18 +76,6 @@ public void Predicted() Left = int.Parse(Region.Split(Delimiter)[1]); Height = int.Parse(Region.Split(Delimiter)[2]); Width = int.Parse(Region.Split(Delimiter)[3]); - - if (Width + Left > WindowWidth) - Width = (int)(WindowWidth - Left); - - if (Height + Top > WindowHeight) - Height = (int)(WindowHeight - Top); - - if (Height < Constants.MinCropperSize) - Height = Constants.MinCropperSize; - - if (Width < Constants.MinCropperSize) - Width = Constants.MinCropperSize; } public override string ToString() diff --git a/PiP-Tool/ViewModels/CropperViewModel.cs b/PiP-Tool/ViewModels/CropperViewModel.cs index 815de4e..020e6fe 100644 --- a/PiP-Tool/ViewModels/CropperViewModel.cs +++ b/PiP-Tool/ViewModels/CropperViewModel.cs @@ -41,7 +41,7 @@ public string Title /// Gets selected region /// public NativeStructs.Rect SelectedRegion => new NativeStructs.Rect(Left, Top, Width + Left, Top + Height); - + public const int DefaultPosition = 0; public bool RegionHasBeenModified => Top != DefaultPosition || Left != DefaultPosition || Height != Constants.MinCropperSize || Width != Constants.MinCropperSize; @@ -345,11 +345,23 @@ private void SetRegion(Task obj) { if (RegionHasBeenModified) return; - - Top = (int) (obj.Result.Top / _windowInfo.DpiY); - Left = (int) (obj.Result.Left / _windowInfo.DpiX); + + Top = (int)(obj.Result.Top / _windowInfo.DpiY); + Left = (int)(obj.Result.Left / _windowInfo.DpiX); Height = (int)(obj.Result.Height / _windowInfo.DpiY); Width = (int)(obj.Result.Width / _windowInfo.DpiX); + + if (Width + Left > WindowWidth) + Width = WindowWidth - Left; + + if (Height + Top > WindowHeight) + Height = WindowHeight - Top; + + if (Height < Constants.MinCropperSize) + Height = Constants.MinCropperSize; + + if (Width < Constants.MinCropperSize) + Width = Constants.MinCropperSize; } /// diff --git a/PiP-Tool/ViewModels/PiPModeViewModel.cs b/PiP-Tool/ViewModels/PiPModeViewModel.cs index a97bb05..d4759bc 100644 --- a/PiP-Tool/ViewModels/PiPModeViewModel.cs +++ b/PiP-Tool/ViewModels/PiPModeViewModel.cs @@ -360,9 +360,6 @@ private void Train() var windowNoBorder = _selectedWindow.WindowInfo.RectNoBorder; var regionNoBorder = _selectedWindow.SelectedRegionNoBorder; - //regionNoBorder.Height = (int) (regionNoBorder.Height * _selectedWindow.WindowInfo.DpiY); - //regionNoBorder.Width = (int)(regionNoBorder.Width * _selectedWindow.WindowInfo.DpiX); - var region = $"{regionNoBorder.Top} " + $"{regionNoBorder.Left} " +