Merge remote-tracking branch 'origin/msgpck' into client

This commit is contained in:
ziomus5555 2020-06-20 14:03:39 +02:00
commit 470b364fbc
11 changed files with 90 additions and 76 deletions

View File

@ -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();
}

View File

@ -6,8 +6,9 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="3.1.2" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Common" Version="3.1.2" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="3.1.5" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Common" Version="3.1.5" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" Version="3.1.5" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.2" />
<PackageReference Include="OpenCvSharp4" Version="4.2.0.20200208" />
<PackageReference Include="OpenCvSharp4.runtime.win" Version="4.2.0.20200208" />

View File

@ -6,6 +6,9 @@
<ItemGroup>
<PackageReference Include="LiteDB" Version="5.0.3" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="3.1.5" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Common" Version="3.1.5" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" Version="3.1.5" />
<PackageReference Include="Microsoft.Azure.CognitiveServices.Vision.ComputerVision" Version="6.0.0-dev.20190919.3" />
<PackageReference Include="OpenCvSharp4" Version="4.2.0.20200208" />
<PackageReference Include="OpenCvSharp4.runtime.ubuntu.18.04-x64" Version="4.2.0.20200208" />

View File

@ -7,6 +7,7 @@
<ItemGroup>
<PackageReference Include="Azure.Storage.Blobs" Version="12.3.0" />
<PackageReference Include="LiteDB" Version="5.0.3" />
<PackageReference Include="OpenCvSharp4.runtime.ubuntu.18.04-x64" Version="4.2.0.20200208" />
</ItemGroup>
<ItemGroup>

View File

@ -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)
{

View File

@ -9,7 +9,7 @@ namespace squirrowse.web.Data
{
public class VideoQ
{
public ConcurrentFixedSizeQueue<byte[]> _framebuffer = new ConcurrentFixedSizeQueue<byte[]>(255);
public ConcurrentFixedSizeQueue<byte[]> _framebuffer = new ConcurrentFixedSizeQueue<byte[]>(33);
public Mat getFrame()
{

View File

@ -8,9 +8,9 @@
<h1>live</h1>
<img src="@_imgSrc"/>
<img src="@_imgSrc" />
<img src="@_tempcogni"/>
<img src="@_tempcogni" />
<div style="padding-top: 10px">
<button id="Save" class="btn btn-success btn-sm" @onclick="() => GetDataFromAzure()">
@ -24,7 +24,7 @@
<li class="list-group-item d-flex justify-content-between" style="background-color: transparent; color: inherit;">
<DxCheckBox CheckType="CheckType.Switch" LabelPosition="@LabelPosition.Left" style="width: 100%" Checked="@fetchDataFromAzure" CheckedChanged="@Update(v => fetchDataFromAzure = v)">Fetch Data from azure</DxCheckBox>
</li>
@*<li class="list-group-item d-flex justify-content-between" style="background-color: transparent; color: inherit;">
<li class="list-group-item d-flex justify-content-between" style="background-color: transparent; color: inherit;">
<DxCheckBox CheckType="CheckType.Switch" LabelPosition="@LabelPosition.Left" style="width: 100%" Checked="@filter.Face" CheckedChanged="@Update(v => filter.Face = v)">Face</DxCheckBox>
</li>
<li class="list-group-item d-flex justify-content-between" style="background-color: transparent; color: inherit;">
@ -32,81 +32,79 @@
</li>
<li class="list-group-item d-flex justify-content-between" style="background-color: transparent; color: inherit;">
<DxCheckBox CheckType="CheckType.Switch" LabelPosition="@LabelPosition.Left" style="width: 100%" Checked="@filter.LowerBody" CheckedChanged="@Update(v => filter.LowerBody = v)">Lower Body</DxCheckBox>
</li>*@
</li>
</ul>
</div>
@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<bool> Update(Action<bool> 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<bool> Update(Action<bool> 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();
}
}
}
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();
}
} }

View File

@ -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",

View File

@ -32,13 +32,13 @@ namespace squirrowse.web
});
services.AddSingleton<SaveVideo>();
//services.AddSingleton<Detection>();
services.AddSingleton<Detection>();
services.AddSingleton<IAzureCV, AzureCV>();
services.AddSingleton<DbContext>();
services.AddSingleton<GaleryService>();
services.AddSingleton<Bloob>();
services.AddSingleton<VideoQ>();
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.

Binary file not shown.

View File

@ -9,6 +9,9 @@
<ItemGroup>
<PackageReference Include="CNTK.Deps.OpenCV.Zip" Version="2.8.0-rc0.dev20200201" />
<PackageReference Include="DevExpress.Blazor" Version="19.2.4-preview" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="3.1.5" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Common" Version="3.1.5" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" Version="3.1.5" />
<PackageReference Include="Microsoft.Azure.CognitiveServices.Vision.ComputerVision" Version="6.0.0-dev.20190919.3" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.9.10" />
<PackageReference Include="OpenCvSharp4" Version="4.2.0.20200208" />
@ -24,6 +27,12 @@
<None Update="StaticFiles\haarcascade_frontalface_alt.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="StaticFiles\haarcascade_lowerbody.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="StaticFiles\haarcascade_upperbody.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ProjectExtensions>