diff --git a/squirrowse.client/ConnectionManager.cs b/squirrowse.client/ConnectionManager.cs index 3117012..04ddd7f 100644 --- a/squirrowse.client/ConnectionManager.cs +++ b/squirrowse.client/ConnectionManager.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Text; using System.Threading.Tasks; using Microsoft.AspNetCore.SignalR.Client; +using Microsoft.Extensions.DependencyInjection; namespace squirrowse.client { @@ -16,6 +17,7 @@ namespace squirrowse.client _connection = new HubConnectionBuilder() .WithUrl($"{url}:{port}/hub") .WithAutomaticReconnect() + .AddMessagePackProtocol() .Build(); } diff --git a/squirrowse.client/squirrowse.client.csproj b/squirrowse.client/squirrowse.client.csproj index f623ecc..677cb2a 100644 --- a/squirrowse.client/squirrowse.client.csproj +++ b/squirrowse.client/squirrowse.client.csproj @@ -6,8 +6,9 @@ - - + + + diff --git a/squirrowse.core/squirrowse.core.csproj b/squirrowse.core/squirrowse.core.csproj index ab3c922..d826af5 100644 --- a/squirrowse.core/squirrowse.core.csproj +++ b/squirrowse.core/squirrowse.core.csproj @@ -6,6 +6,9 @@ + + + diff --git a/squirrowse.db/squirrowse.db.csproj b/squirrowse.db/squirrowse.db.csproj index 8ffcb57..6b9df67 100644 --- a/squirrowse.db/squirrowse.db.csproj +++ b/squirrowse.db/squirrowse.db.csproj @@ -7,6 +7,7 @@ + diff --git a/squirrowse.web/Data/Detection.cs b/squirrowse.web/Data/Detection.cs index 7033b97..310406d 100644 --- a/squirrowse.web/Data/Detection.cs +++ b/squirrowse.web/Data/Detection.cs @@ -21,13 +21,13 @@ namespace squirrowse.web.Data public class Detection : IDetection { private readonly CascadeClassifier CascadeFace = new CascadeClassifier( - @".\StaticFiles\haarcascade_frontalface_alt.xml"); + @"./StaticFiles/haarcascade_frontalface_alt.xml"); private readonly CascadeClassifier CascadeLowerBody = new CascadeClassifier( - @".\StaticFiles\haarcascade_lowerbody.xml"); + @"./StaticFiles/haarcascade_lowerbody.xml"); private readonly CascadeClassifier CascadeUpperBody = new CascadeClassifier( - @".\StaticFiles\haarcascade_upperbody.xml"); + @"./StaticFiles/haarcascade_upperbody.xml"); public Mat DetectTypes(Mat frame, Filters filter) { diff --git a/squirrowse.web/Data/VideoQ.cs b/squirrowse.web/Data/VideoQ.cs index c7229d0..410d5b7 100644 --- a/squirrowse.web/Data/VideoQ.cs +++ b/squirrowse.web/Data/VideoQ.cs @@ -9,7 +9,7 @@ namespace squirrowse.web.Data { public class VideoQ { - public ConcurrentFixedSizeQueue _framebuffer = new ConcurrentFixedSizeQueue(255); + public ConcurrentFixedSizeQueue _framebuffer = new ConcurrentFixedSizeQueue(33); public Mat getFrame() { diff --git a/squirrowse.web/Pages/Client.razor b/squirrowse.web/Pages/Client.razor index b51d847..e838926 100644 --- a/squirrowse.web/Pages/Client.razor +++ b/squirrowse.web/Pages/Client.razor @@ -8,9 +8,9 @@

live

- + - +
@inject SaveVideo save @inject IAzureCV azureCv @inject VideoQ Video +@inject Detection detect -@code { - // private readonly Filters filter = new Filters(false, false, false); - private string _imgSrc; - private string _tempcogni; - private byte[] buffer; - private bool fetchDataFromAzure = true; +@code { private readonly Filters filter = new Filters(false, false, false); + private string _imgSrc; + private string _tempcogni; + private byte[] buffer; + private bool fetchDataFromAzure = true; - private readonly Frame Frametest = new Frame(); + private readonly Frame Frametest = new Frame(); - private Mat tempory = new Mat(); + private Mat tempory = new Mat(); - public Action Update(Action set) - { - return v => - { - set(v); - InvokeAsync(StateHasChanged); - }; - } - - protected override async Task OnInitializedAsync() - { - using var temp = new Mat(480, 640, MatType.CV_8UC3, new Scalar(0, 0, 100)); - - Cv2.PutText(temp, "No clients".ToUpper(), - new Point(240, 320), - HersheyFonts.HersheyComplex, 0.9f, Scalar.Yellow); - var base64T = Convert.ToBase64String(temp.ToBytes()); - - - while (true) - { - - try + public Action Update(Action set) { - using var frame = Video.getFrame(); - tempory = Frametest.CopyMat(frame); - // var face = detect.DetectTypes(frame, filter); - buffer = frame.ToBytes(); - var base64 = Convert.ToBase64String(buffer); - _imgSrc = $"data:image/gif;base64,{base64}"; - Cv2.WaitKey(1); - await Task.Delay(1000 / 33); - - StateHasChanged(); + return v => + { + set(v); + InvokeAsync(StateHasChanged); + }; } - catch (Exception e) + + protected override async Task OnInitializedAsync() { - _imgSrc = $"data:image/gif;base64,{base64T}"; - await Task.Delay(1000 / 33); + using var temp = new Mat(480, 640, MatType.CV_8UC3, new Scalar(0, 0, 100)); + + Cv2.PutText(temp, "No clients".ToUpper(), + new Point(240, 320), + HersheyFonts.HersheyComplex, 0.9f, Scalar.Yellow); + var base64T = Convert.ToBase64String(temp.ToBytes()); + + + while (true) + { + + try + { + using var frame = Video.getFrame(); + tempory = Frametest.CopyMat(frame); + var face = detect.DetectTypes(frame, filter); + buffer = face.ToBytes(); + var base64 = Convert.ToBase64String(buffer); + _imgSrc = $"data:image/gif;base64,{base64}"; + Cv2.WaitKey(1); + await Task.Delay(1000 / 33); + + StateHasChanged(); + } + catch (Exception e) + { + _imgSrc = $"data:image/gif;base64,{base64T}"; + await Task.Delay(1000 / 33); + + StateHasChanged(); + } + } - StateHasChanged(); } - } - - } - private async Task GetDataFromAzure() - { - while (fetchDataFromAzure) - { - var azrespons = await azureCv.GetObjects(tempory); - var azureFrame = azureCv.DrawResults(tempory, azrespons); - var b_tempcogni = Convert.ToBase64String(azureFrame.Result.ToBytes()); - _tempcogni = $"data:image/gif;base64,{b_tempcogni}"; - await Task.Delay(TimeSpan.FromSeconds(5)); - StateHasChanged(); - } - } - -} \ No newline at end of file + private async Task GetDataFromAzure() + { + while (fetchDataFromAzure) + { + var azrespons = await azureCv.GetObjects(tempory); + var azureFrame = azureCv.DrawResults(tempory, azrespons); + var b_tempcogni = Convert.ToBase64String(azureFrame.Result.ToBytes()); + _tempcogni = $"data:image/gif;base64,{b_tempcogni}"; + await Task.Delay(TimeSpan.FromSeconds(5)); + StateHasChanged(); + } + } } \ No newline at end of file diff --git a/squirrowse.web/Properties/launchSettings.json b/squirrowse.web/Properties/launchSettings.json index 98dd5eb..2d12a77 100644 --- a/squirrowse.web/Properties/launchSettings.json +++ b/squirrowse.web/Properties/launchSettings.json @@ -3,7 +3,7 @@ "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://10.230.115.112:80", + "applicationUrl": "http://192.168.0.13:8000", "sslPort": 443 } }, @@ -22,7 +22,7 @@ "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" }, - "applicationUrl": "http://10.230.115.112:80" + "applicationUrl": "http://192.168.0.13:8000" }, "Docker": { "commandName": "Docker", diff --git a/squirrowse.web/Startup.cs b/squirrowse.web/Startup.cs index 94ff952..9347b86 100644 --- a/squirrowse.web/Startup.cs +++ b/squirrowse.web/Startup.cs @@ -32,13 +32,13 @@ namespace squirrowse.web }); services.AddSingleton(); - //services.AddSingleton(); + services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); - services.AddSignalR(x => x.MaximumReceiveMessageSize = ((int)(int.MaxValue / 2))); + services.AddSignalR(x => x.MaximumReceiveMessageSize = ((int)(int.MaxValue / 2))).AddMessagePackProtocol(); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. diff --git a/squirrowse.web/db-log.db b/squirrowse.web/db-log.db index 8d63b33..7972c1b 100644 Binary files a/squirrowse.web/db-log.db and b/squirrowse.web/db-log.db differ diff --git a/squirrowse.web/squirrowse.web.csproj b/squirrowse.web/squirrowse.web.csproj index 41465ef..815b50a 100644 --- a/squirrowse.web/squirrowse.web.csproj +++ b/squirrowse.web/squirrowse.web.csproj @@ -9,6 +9,9 @@ + + + @@ -24,6 +27,12 @@ Always + + Always + + + Always +