Skip to content

Commit

Permalink
Fix: DPI with ML #3
Browse files Browse the repository at this point in the history
  • Loading branch information
LionelJouin committed Nov 4, 2018
1 parent cffccdf commit 13aeff4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 19 deletions.
12 changes: 0 additions & 12 deletions PiP-Tool.MachineLearning/DataModel/RegionPrediction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
20 changes: 16 additions & 4 deletions PiP-Tool/ViewModels/CropperViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public string Title
/// Gets selected region
/// </summary>
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;
Expand Down Expand Up @@ -345,11 +345,23 @@ private void SetRegion(Task<RegionPrediction> 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;
}

/// <summary>
Expand Down
3 changes: 0 additions & 3 deletions PiP-Tool/ViewModels/PiPModeViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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} " +
Expand Down

0 comments on commit 13aeff4

Please sign in to comment.