Skip to content

Commit

Permalink
* Tweak to how I get local ip address list
Browse files Browse the repository at this point in the history
* Force all enabled relevant objects to the top of the list
* Change default object list for new cameras (No longer contains Meat Popsicle :) )
* Fix Save button on Prediction Tolerances form - #333
* Checkboxes in AI Server list for easy enable/disable.
* AI Server list now has all enabled first, disabled last, and a few columns where reordered
* Prediction Details screen now works correctly when you multi select more than one item from the history list.
  • Loading branch information
VorlonCD committed Jun 7, 2023
1 parent 6101905 commit e7f9e6e
Show file tree
Hide file tree
Showing 26 changed files with 629 additions and 539 deletions.
4 changes: 2 additions & 2 deletions src/AITool.Setup/Script.iss
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
; This Is Full App Version Major.Minor.Build.Revision
; Store First 3 Parts of Version in ShortAppVersion to be used for SBS Assembly Installation Major.Minor.Build
#dim Version[4]
#expr ParseVersion("..\UI\bin\Debug\net6.0-windows\AITOOL.exe", Version[0], Version[1], Version[2], Version[3])
#expr ParseVersion("..\UI\bin\Debug\net6.0-windows10.0.19041.0\AITOOL.exe", Version[0], Version[1], Version[2], Version[3])
#define AppVersion Str(Version[0]) + "." + Str(Version[1]) + "." + Str(Version[2]) + "." + Str(Version[3])
#define ShortAppVersion Str(Version[0]) + "." + Str(Version[1]) + "." + Str(Version[2])
#define ShorterAppVersion Str(Version[0]) + "." + Str(Version[1])
Expand Down Expand Up @@ -54,7 +54,7 @@ Filename: "{app}\AITOOL.exe"; Flags: nowait postinstall skipifsilent

[Files]
//Source: "Script.iss"; DestDir: "{app}"
Source: "..\UI\bin\Debug\net6.0-windows\*"; DestDir: "{app}";Flags: recursesubdirs ignoreversion;Excludes: "AIToolSetup*,_Settings"
Source: "..\UI\bin\Debug\net6.0-windows10.0.19041.0\*"; DestDir: "{app}";Flags: recursesubdirs ignoreversion;Excludes: "AIToolSetup*,_Settings"
[Icons]
Name: "{group}\AITOOL"; Filename: "{app}\AITOOL.exe" ; Components: full; Tasks: startmenu
Name: "{userdesktop}\AITOOL"; Filename: "{app}\AITOOL.exe" ; Components: full; Tasks: desktopicon
Expand Down
6 changes: 5 additions & 1 deletion src/UI/AITOOL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,9 @@ public static void UpdateAIURLList(bool Force = false)
}
AppSettings.Settings.AIURLList = newlist;

//sort AIURLList so that all items enabled are at the top. Use OrderbyDescending so that the order is preserved
AppSettings.Settings.AIURLList = AppSettings.Settings.AIURLList.OrderByDescending(x => x.Enabled.ReadFullFence()).ToList();

//Check to see if we need to get updated URL list - In theory this should only happen once
bool hasold = !string.IsNullOrEmpty(AppSettings.Settings.deepstack_url);
if (((AppSettings.Settings.AIURLList.Count == 0 || Force) && hasold) || hasold)
Expand Down Expand Up @@ -938,6 +941,7 @@ public static void UpdateAIURLList(bool Force = false)

}


//add a default DeepStack server if none found
//if (AppSettings.Settings.AIURLList.Count == 0)
//{
Expand Down Expand Up @@ -3711,7 +3715,7 @@ public static async Task<DetectObjectsResult> DetectObjects(ClsImageQueueItem Cu
else
{
//could not access the file for 30 seconds?? Or unexpected error
ret.Error = $"Error: {CurImg.LastError}. ({CurImg.FileLockMS}ms, with {CurImg.FileLockErrRetryCnt} retries)";
ret.Error = $"Error: Last Image message: '{CurImg.LastError}'. ({CurImg.FileLockMS}ms, with {CurImg.FileLockErrRetryCnt} retries)";
CurImg.ErrCount.AtomicIncrementAndGet();
CurImg.ResultMessage = ret.Error;
Log(ret.Error, AISRV, cam, CurImg);
Expand Down
4 changes: 2 additions & 2 deletions src/UI/AssemblyInfo1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@
// Build Number
// Revision
//
[assembly: AssemblyVersion("2.5.25.8556")]
[assembly: AssemblyFileVersion("2.5.25.8556")]
[assembly: AssemblyVersion("2.5.44.8558")]
[assembly: AssemblyFileVersion("2.5.44.8558")]
4 changes: 2 additions & 2 deletions src/UI/Camera.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ public class Camera : IEquatable<Camera>
public string Prefix { get; set; } = "";
public string BICamName { get; set; } = "";
public string MaskFileName { get; set; } = "";
public string triggering_objects_as_string { get; set; } = "person, people, face, bear, elephant, car, truck, pickup truck, SUV, van, bicycle, motorcycle, motorbike, bus, dog, horse, boat, train, airplane, zebra, giraffe, cow, sheep, cat, bird";
public string triggering_objects_as_string { get; set; } = ""; //"person, people, face, bear, elephant, car, truck, pickup truck, SUV, van, bicycle, motorcycle, motorbike, bus, dog, horse, boat, train, airplane, zebra, giraffe, cow, sheep, cat, bird";

public string additional_triggering_objects_as_string { get; set; } = "SUV, VAN, Pickup Truck, Meat Popsicle";
public string additional_triggering_objects_as_string { get; set; } = ""; //"SUV, VAN, Pickup Truck, Meat Popsicle";
public ClsRelevantObjectManager DefaultTriggeringObjects { get; set; } = null;
public ClsRelevantObjectManager TelegramTriggeringObjects { get; set; } = null;
public ClsRelevantObjectManager PushoverTriggeringObjects { get; set; } = null;
Expand Down
3 changes: 2 additions & 1 deletion src/UI/ClsImageAdjust.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Newtonsoft.Json;

using System;
using System.Collections.Generic;
using System.Linq;
Expand Down Expand Up @@ -29,7 +30,7 @@ public ClsImageAdjust(string name)
}
public ClsImageAdjust(string name, string jpegqualitypercent, string imagesizepercent, string imagewidth, string imageheight, string brightness, string contrast)
{
this.Update(name, jpegqualitypercent, imagesizepercent, imagewidth, imageheight, brightness, contrast);
this.Update(name.Trim(), jpegqualitypercent.Trim(), imagesizepercent.Trim(), imagewidth.Trim(), imageheight.Trim(), brightness.Trim(), contrast.Trim());
}

public void Update(string name, string jpegqualitypercent, string imagesizepercent, string imagewidth, string imageheight, string brightness, string contrast)
Expand Down
2 changes: 1 addition & 1 deletion src/UI/ClsPrediction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1110,7 +1110,7 @@ private void GetObjectType()
return;
}

if (tmp.Equals("person"))
if (tmp.Equals("person") || tmp.Equals("people"))
this.ObjType = ObjectType.Person;
else if (tmp.Equals("face") || this.Detail.IndexOf("face", StringComparison.OrdinalIgnoreCase) >= 0)
this.ObjType = ObjectType.Face;
Expand Down
16 changes: 12 additions & 4 deletions src/UI/ClsRelevantObjectManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,14 @@ public void Update(double MinLowerThreshold = 0, double MaxUpperThreshold = 0, b
}
public override string ToString()
{
if (this.Trigger)
return this.Name;
else
return "-" + this.Name;
string ret = this.Name;
if (!this.Trigger)
ret = "-" + ret;

if (!this.Enabled)
ret = "(" + ret + ")";

return ret;
}

public override bool Equals(object obj)
Expand Down Expand Up @@ -246,6 +250,9 @@ public void Update(bool ResetIfNeeded = true)

bool restrict = !this.cam.IsNull() && !this.cam.DefaultTriggeringObjects.IsNull() && this.cam.DefaultTriggeringObjects.TypeName != this.TypeName;

//sort ObjectList so that enabled objects are first, then by priority
this.ObjectList = this.ObjectList.OrderByDescending(ro => ro.Enabled).ToList();

//make sure no priority is in order and the minimum is not less than the main cameras list
for (int i = 0; i < this.ObjectList.Count; i++)
{
Expand All @@ -266,6 +273,7 @@ public void Update(bool ResetIfNeeded = true)

}


ExcludeObjects();

}
Expand Down
41 changes: 21 additions & 20 deletions src/UI/ClsURLItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,30 @@ public enum URLTypeEnum
}
public class ClsURLItem : IEquatable<ClsURLItem>
{
private bool isValid = false;

public string Name { get; set; } = "";
public URLTypeEnum Type { get; set; } = URLTypeEnum.Unknown;
public ThreadSafe.Boolean Enabled { get; set; } = new ThreadSafe.Boolean(true);
public bool IsValid
public string Name { get; set; } = "";
[JsonIgnore]
public bool IsValid { get; set; } = false;
public string LastResultMessage { get; set; } = "";
public int Order { get; set; } = 0;
public long LastTimeMS { get; set; } = 0;
public long AvgTimeMS
{
get { return isValid; }
set { isValid = value; }
get { return Convert.ToInt64(this.AITimeCalcs.Avg); }
}
public int Order { get; set; } = 0;

public string url { get; set; } = "";
[JsonIgnore]
public ThreadSafe.Boolean Enabled { get; set; } = new ThreadSafe.Boolean(true);
public ThreadSafe.Boolean InUse { get; set; } = new ThreadSafe.Boolean(false);
public string ActiveTimeRange { get; set; } = "00:00:00-23:59:59";
[JsonIgnore]
public ThreadSafe.Integer CurErrCount { get; set; } = new ThreadSafe.Integer(0);
public ThreadSafe.Boolean ErrDisabled { get; set; } = new ThreadSafe.Boolean(false);
public ThreadSafe.Integer ErrCount { get; set; } = new ThreadSafe.Integer(0);
public ThreadSafe.Integer ErrsInRowCount { get; set; } = new ThreadSafe.Integer(0);

public string Cameras { get; set; } = "";
public int MaxImagesPerMonth { get; set; } = 0;
public string ImageAdjustProfile { get; set; } = "Default";
public int Threshold_Lower { get; set; } = 0; //override the cameras threshold since different AI servers may need to be tuned to different values
public int Threshold_Upper { get; set; } = 100;
public bool UseAsRefinementServer { get; set; } = false;
Expand All @@ -61,21 +67,16 @@ public bool IsValid
public bool UseOnlyAsLinkedServer { get; set; } = false;
public bool LinkServerResults { get; set; } = false;
public string LinkedResultsServerList { get; set; } = "";
public string ActiveTimeRange { get; set; } = "00:00:00-23:59:59";
public string ImageAdjustProfile { get; set; } = "Default";
[JsonIgnore]
public int CurOrder { get; set; } = 0;
[JsonIgnore]
public ThreadSafe.Integer CurErrCount { get; set; } = new ThreadSafe.Integer(0);
[JsonIgnore]
public ThreadSafe.Boolean ErrDisabled { get; set; } = new ThreadSafe.Boolean(false);
public ThreadSafe.Integer ErrCount { get; set; } = new ThreadSafe.Integer(0);
public ThreadSafe.Integer ErrsInRowCount { get; set; } = new ThreadSafe.Integer(0);
public bool IsLocalHost { get; set; } = false;
public bool IsLocalNetwork { get; set; } = false;
public string HelpURL { get; set; } = "";
public DateTime LastUsedTime { get; set; } = DateTime.MinValue;
public bool LastResultSuccess { get; set; } = false;
public string LastResultMessage { get; set; } = "";
public long LastTimeMS { get; set; } = 0;
public MovingCalcs AITimeCalcs { get; set; } = new MovingCalcs(250, "Images", true); //store deepstack time calc in the url
public string CurSrv { get; set; } = "";
public int Port { get; set; } = 0;
Expand Down Expand Up @@ -167,7 +168,7 @@ public bool Update(bool Init)



bool ShouldInit = Init || !this.isValid || string.IsNullOrWhiteSpace(this.url) || (!this.url.Contains("/") && !this.url.Contains("_")) || this.Type == URLTypeEnum.Unknown;
bool ShouldInit = Init || !this.IsValid || string.IsNullOrWhiteSpace(this.url) || (!this.url.Contains("/") && !this.url.Contains("_")) || this.Type == URLTypeEnum.Unknown;

if (ShouldInit)
{
Expand Down Expand Up @@ -537,7 +538,7 @@ public bool Update(bool Init)
AITOOL.Log($"Error: '{this.Type.ToString()}' URL is not known/valid: '{this.url}'");
}

if (!IsAWS && this.isValid && this.HttpClient == null)
if (!IsAWS && this.IsValid && this.HttpClient == null)
{
this.HttpClient = new HttpClient();
this.HttpClient.Timeout = this.GetTimeout();
Expand Down Expand Up @@ -569,7 +570,7 @@ public override bool Equals(object obj)

public bool Equals(ClsURLItem other)
{
return other != null && this.url.EqualsIgnoreCase(other.url);
return other != null && this.url.EqualsIgnoreCase(other.url) && this.Name.EqualsIgnoreCase(other.Name) && this.Type == other.Type;
}

}
Expand Down
11 changes: 11 additions & 0 deletions src/UI/Extensions/DoubleExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ public static float ToFloat(this double val, bool Abs = false)

return 0;
}
public static decimal Round(this decimal val, int Places = 1)
{
try
{
if (!val.IsNull())
return Math.Round(val, Places);
}
catch { }

return 0;
}
public static double Round(this double val, int Places = 1)
{
try
Expand Down
Loading

0 comments on commit e7f9e6e

Please sign in to comment.