Beispiel #1
0
        public ClsURLItem(String url, int Order, int Count, URLTypeEnum type = URLTypeEnum.DeepStack)
        {
            if (!string.IsNullOrWhiteSpace(url))
            {
                this.Enabled.WriteFullFence(true);
                this.url   = url.Trim();
                this.Type  = type;
                this.Order = Order;
                this.Count = Count;

                if (this.Type == URLTypeEnum.DeepStack)
                {
                    if (!this.url.Contains("://"))
                    {
                        this.url = "http://" + this.url;
                    }
                    if (!this.url.ToLower().Contains("/v1/vision/detection"))
                    {
                        this.url = this.url + "/v1/vision/detection";
                    }
                }

                this.HttpClient = new HttpClient();
                //set httpclient timeout:
                this.HttpClient.Timeout = TimeSpan.FromSeconds(AppSettings.Settings.HTTPClientTimeoutSeconds);
            }
        }
Beispiel #2
0
 public ClsURLItem(String url, int Order, URLTypeEnum type)
 {
     this.UrlFixed = false;
     this.url      = url.Trim();
     this.Type     = type;
     this.Order    = Order;
     this.Update(true);
 }
Beispiel #3
0
        public static ClsURLItem GetURL(string url = "", URLTypeEnum type = URLTypeEnum.Unknown)
        {
            ClsURLItem ret = null;

            foreach (var cu in Settings.AIURLList)
            {
                if (string.Equals(cu.url, url, StringComparison.OrdinalIgnoreCase) || cu.Type == type)
                {
                    return(cu);
                }
            }
            return(ret);
        }
Beispiel #4
0
 public ClsURLItem(String url, URLTypeEnum type = URLTypeEnum.DeepStack)
 {
     if (!string.IsNullOrWhiteSpace(url))
     {
         this.Enabled = true;
         this.url     = url.Trim();
         this.Type    = type;
         if (this.Type == URLTypeEnum.DeepStack)
         {
             if (!this.url.Contains("://"))
             {
                 this.url = "http://" + this.url;
             }
             if (!this.url.ToLower().Contains("/v1/vision/detection"))
             {
                 this.url = this.url + "/v1/vision/detection";
             }
         }
     }
 }
Beispiel #5
0
        public ClsURLItem(String url, int Order, int Count, URLTypeEnum type)
        {
            if (!string.IsNullOrWhiteSpace(url))
            {
                this.Enabled.WriteFullFence(true);
                this.url = url.Trim();

                this.Type  = type;
                this.Order = Order;
                this.Count = Count;

                if (!this.url.Contains("://"))
                {
                    this.url = "http://" + this.url;
                }

                if (this.Type == URLTypeEnum.DOODS || this.url.EndsWith("/detect", StringComparison.OrdinalIgnoreCase))
                {
                    this.Type = URLTypeEnum.DOODS;
                    if (!(this.url.IndexOf("/detect", StringComparison.OrdinalIgnoreCase) >= 0))
                    {
                        this.url = this.url + "/detect";
                    }
                }
                else // assume deepstack //if (this.Type == URLTypeEnum.DeepStack || this.url.IndexOf("/v1/vision/detection", StringComparison.OrdinalIgnoreCase) >= 0)
                {
                    this.Type = URLTypeEnum.DeepStack;
                    if (!(this.url.IndexOf("/v1/vision/detection", StringComparison.OrdinalIgnoreCase) >= 0))
                    {
                        this.url = this.url + "/v1/vision/detection";
                    }
                }

                Uri uri = new Uri(this.url);
                this.CurSrv = uri.Host + ":" + uri.Port;

                this.HttpClient = new HttpClient();
                //set httpclient timeout:
                this.HttpClient.Timeout = TimeSpan.FromSeconds(AppSettings.Settings.HTTPClientTimeoutSeconds);
            }
        }
Beispiel #6
0
        public ClsURLItem(String url, int Order, URLTypeEnum type)
        {
            this.UrlFixed = false;

            if (string.IsNullOrWhiteSpace(url))
            {
                if (type == URLTypeEnum.DOODS)
                {
                    this.DefaultURL = "http://127.0.0.1:8080/detect";
                    url             = this.DefaultURL;
                }
                else if (type == URLTypeEnum.AWSRekognition) // || this.url.Equals("aws", StringComparison.OrdinalIgnoreCase) || this.url.Equals("rekognition", StringComparison.OrdinalIgnoreCase))
                {
                    this.DefaultURL = "Amazon";
                    url             = this.DefaultURL;
                }
                else if (type == URLTypeEnum.SightHound_Vehicle)
                {
                    this.DefaultURL = "https://dev.sighthoundapi.com/v1/recognition?objectType=vehicle,licenseplate";
                    url             = this.DefaultURL;
                }
                else if (type == URLTypeEnum.SightHound_Person)
                {
                    this.DefaultURL = "https://dev.sighthoundapi.com/v1/detections?type=face,person&faceOption=gender,landmark,age,pose,emotion";
                    url             = this.DefaultURL;
                }
                else // assume deepstack //if (this.Type == URLTypeEnum.DeepStack || this.url.IndexOf("/v1/vision/detection", StringComparison.OrdinalIgnoreCase) >= 0)
                {
                    this.DefaultURL = "http://127.0.0.1:80/v1/vision/detection";
                    url             = this.DefaultURL;
                }
            }

            this.url = url.Trim();

            this.Type  = type;
            this.Order = Order;


            if (this.Type == URLTypeEnum.DOODS || this.url.EndsWith("/detect", StringComparison.OrdinalIgnoreCase))
            {
                this.DefaultURL = "http://127.0.0.1:8080/detect";
                this.HelpURL    = "https://github.com/snowzach/doods";
                if (!this.url.Contains("://"))
                {
                    this.UrlFixed = true;
                    this.url      = "http://" + this.url;
                }
                this.Type = URLTypeEnum.DOODS;
                if (!(this.url.IndexOf("/detect", StringComparison.OrdinalIgnoreCase) >= 0))
                {
                    this.UrlFixed = true;
                    this.url      = this.url + "/detect";
                }

                Uri uri = new Uri(this.url);
                this.CurSrv             = uri.Host + ":" + uri.Port;
                this.Port               = uri.Port;
                this.IsLocalHost        = Global.IsLocalHost(uri.Host);
                this.HttpClient         = new HttpClient();
                this.HttpClient.Timeout = TimeSpan.FromSeconds(AppSettings.Settings.HTTPClientTimeoutSeconds);
                this.IsValid            = true;
                this.Enabled.WriteFullFence(true);
            }
            else if (this.Type == URLTypeEnum.AWSRekognition || this.url.Equals("amazon", StringComparison.OrdinalIgnoreCase)) // || this.url.Equals("aws", StringComparison.OrdinalIgnoreCase) || this.url.Equals("rekognition", StringComparison.OrdinalIgnoreCase))
            {
                this.DefaultURL = "Amazon";

                this.HelpURL     = "https://docs.aws.amazon.com/rekognition/latest/dg/setting-up.html";
                this.Type        = URLTypeEnum.AWSRekognition;
                this.IsLocalHost = false;

                string error = AITOOL.UpdateAmazonSettings();

                if (string.IsNullOrEmpty(error))
                {
                    this.CurSrv  = "Amazon:" + AppSettings.Settings.AmazonRegionEndpoint;
                    this.IsValid = true;
                    this.Enabled.WriteFullFence(true);
                    this.MaxImagesPerMonth = 5000;
                }
                else
                {
                    AITOOL.Log($"Error: {error}");
                    this.IsValid = false;
                    this.Enabled.WriteFullFence(false);
                }
            }
            else if (this.Type == URLTypeEnum.SightHound_Person || this.url.IndexOf("/v1/detections", StringComparison.OrdinalIgnoreCase) >= 0)
            {
                this.MaxImagesPerMonth     = 5000;
                this.UseAsRefinementServer = true;
                this.RefinementObjects     = "person";
                this.DefaultURL            = "https://dev.sighthoundapi.com/v1/detections?type=face,person&faceOption=gender,landmark,age,pose,emotion";
                this.HelpURL = "https://docs.sighthound.com/cloud/detection/";
                if (!this.url.Contains("://"))
                {
                    this.UrlFixed = true;
                    this.url      = "https://" + this.url;
                }
                this.Type = URLTypeEnum.SightHound_Person;
                if (!(this.url.IndexOf("/v1/detections", StringComparison.OrdinalIgnoreCase) >= 0))
                {
                    this.UrlFixed = true;
                    this.url      = this.url + "/v1/detections?type=face,person&faceOption=gender,landmark,age,pose,emotion";
                }

                Uri uri = new Uri(this.url);
                this.CurSrv      = uri.Host + ":" + uri.Port;
                this.Port        = uri.Port;
                this.IsLocalHost = false;
                this.HttpClient  = null;
                this.IsValid     = true;
                this.Enabled.WriteFullFence(true);
            }
            else if (this.Type == URLTypeEnum.SightHound_Vehicle || this.url.IndexOf("/v1/recognition", StringComparison.OrdinalIgnoreCase) >= 0)
            {
                //https://docs.sighthound.com/cloud/recognition/
                this.MaxImagesPerMonth     = 5000;
                this.UseAsRefinementServer = true;
                this.RefinementObjects     = "car,truck,bus,suv,van,motorcycle";
                this.DefaultURL            = "https://dev.sighthoundapi.com/v1/recognition?objectType=vehicle,licenseplate";
                this.HelpURL = "https://docs.sighthound.com/cloud/recognition/";
                if (!this.url.Contains("://"))
                {
                    this.UrlFixed = true;
                    this.url      = "https://" + this.url;
                }
                this.Type = URLTypeEnum.SightHound_Vehicle;
                if (!(this.url.IndexOf("/v1/recognition", StringComparison.OrdinalIgnoreCase) >= 0))
                {
                    this.UrlFixed = true;
                    this.url      = this.url + "/v1/recognition?objectType=vehicle,licenseplate";
                }

                Uri uri = new Uri(this.url);
                this.CurSrv      = uri.Host + ":" + uri.Port;
                this.Port        = uri.Port;
                this.IsLocalHost = false;
                this.HttpClient  = null;
                this.IsValid     = true;
                this.Enabled.WriteFullFence(true);
            }
            else // assume deepstack //if (this.Type == URLTypeEnum.DeepStack || this.url.IndexOf("/v1/vision/detection", StringComparison.OrdinalIgnoreCase) >= 0)
            {
                this.DefaultURL = "http://127.0.0.1:80/v1/vision/detection";
                this.HelpURL    = "https://ipcamtalk.com/threads/tool-tutorial-free-ai-person-detection-for-blue-iris.37330/";

                if (!this.url.Contains("://"))
                {
                    this.UrlFixed = true;
                    this.url      = "http://" + this.url;
                }


                this.Type = URLTypeEnum.DeepStack;

                bool valid = Global.IsValidURL(this.url);

                //only add path if none already given, for example /vision/custom/model-name
                if (!valid)
                {
                    this.UrlFixed = true;
                    this.url      = this.url.Trim() + "/v1/vision/detection";
                }

                Uri uri = new Uri(this.url);
                this.CurSrv = uri.Host + ":" + uri.Port;
                this.Port   = uri.Port;

                this.IsLocalHost = Global.IsLocalHost(uri.Host);

                this.HttpClient         = new HttpClient();
                this.HttpClient.Timeout = TimeSpan.FromSeconds(AppSettings.Settings.HTTPClientTimeoutSeconds);
                this.IsValid            = true;
                this.Enabled.WriteFullFence(true);
            }


            this.UpdateIsValid();
        }
Beispiel #7
0
        public ClsURLItem(String url, int Order, int Count, URLTypeEnum type)
        {
            if (!string.IsNullOrWhiteSpace(url))
            {
                this.url = url.Trim();

                this.Type      = type;
                this.OrigOrder = Order;
                this.Count     = Count;


                if (this.Type == URLTypeEnum.DOODS || this.url.EndsWith("/detect", StringComparison.OrdinalIgnoreCase))
                {
                    if (!this.url.Contains("://"))
                    {
                        this.url = "http://" + this.url;
                    }
                    this.Type = URLTypeEnum.DOODS;
                    if (!(this.url.IndexOf("/detect", StringComparison.OrdinalIgnoreCase) >= 0))
                    {
                        this.url = this.url + "/detect";
                    }
                    Uri uri = new Uri(this.url);
                    this.CurSrv             = uri.Host + ":" + uri.Port;
                    this.HttpClient         = new HttpClient();
                    this.HttpClient.Timeout = TimeSpan.FromSeconds(AppSettings.Settings.HTTPClientTimeoutSeconds);
                    this.IsValid            = true;
                    this.Enabled.WriteFullFence(true);
                }
                else if (this.Type == URLTypeEnum.AWSRekognition || this.url.Equals("amazon", StringComparison.OrdinalIgnoreCase)) // || this.url.Equals("aws", StringComparison.OrdinalIgnoreCase) || this.url.Equals("rekognition", StringComparison.OrdinalIgnoreCase))
                {
                    this.Type = URLTypeEnum.AWSRekognition;

                    string error = AITOOL.UpdateAmazonSettings();

                    if (string.IsNullOrEmpty(error))
                    {
                        this.CurSrv  = "Amazon:" + AppSettings.Settings.AmazonRegionEndpoint;
                        this.IsValid = true;
                        this.Enabled.WriteFullFence(true);
                        this.MaxImagesPerMonth = 5000;
                    }
                    else
                    {
                        AITOOL.Log($"Error: {error}");
                    }
                }
                else // assume deepstack //if (this.Type == URLTypeEnum.DeepStack || this.url.IndexOf("/v1/vision/detection", StringComparison.OrdinalIgnoreCase) >= 0)
                {
                    if (!this.url.Contains("://"))
                    {
                        this.url = "http://" + this.url;
                    }
                    this.Type = URLTypeEnum.DeepStack;
                    if (!(this.url.IndexOf("/v1/vision/detection", StringComparison.OrdinalIgnoreCase) >= 0))
                    {
                        this.url = this.url.Trim() + "/v1/vision/detection";
                    }
                    Uri uri = new Uri(this.url);
                    this.CurSrv             = uri.Host + ":" + uri.Port;
                    this.HttpClient         = new HttpClient();
                    this.HttpClient.Timeout = TimeSpan.FromSeconds(AppSettings.Settings.HTTPClientTimeoutSeconds);
                    this.IsValid            = true;
                    this.Enabled.WriteFullFence(true);
                }
            }
        }