hub config #2
@ -8,9 +8,16 @@ namespace Squirrowse.Client.Service
|
|||||||
{
|
{
|
||||||
public class CameraService : ICameraService
|
public class CameraService : ICameraService
|
||||||
{
|
{
|
||||||
public VideoCapture GetCamera()
|
public VideoCapture GetCamera(int height=480,int widght=640,double fps=15f,bool disposable = false)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
|
||||||
|
var cam = new VideoCapture(CaptureDevice.Any);
|
||||||
|
cam.Fps = fps;
|
||||||
|
cam.FrameHeight = height;
|
||||||
|
cam.FrameWidth = widght;
|
||||||
|
cam.IsEnabledDispose = disposable;
|
||||||
|
|
||||||
|
return cam;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<Mat> GetFrame(VideoCapture video)
|
public Task<Mat> GetFrame(VideoCapture video)
|
||||||
|
@ -8,7 +8,7 @@ namespace Squirrowse.Client.Service
|
|||||||
{
|
{
|
||||||
public interface ICameraService
|
public interface ICameraService
|
||||||
{
|
{
|
||||||
public VideoCapture GetCamera();
|
public VideoCapture GetCamera(int height = 480, int widght = 640, double fps = 15f, bool disposable = false);
|
||||||
public Task<Mat> GetFrame(VideoCapture video);
|
public Task<Mat> GetFrame(VideoCapture video);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ namespace Squirrowse.Client.Service
|
|||||||
public interface IStreamService
|
public interface IStreamService
|
||||||
{
|
{
|
||||||
Task SendStreamAsync(IAsyncEnumerable<byte[]> asb);
|
Task SendStreamAsync(IAsyncEnumerable<byte[]> asb);
|
||||||
|
Task SayHello();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using Microsoft.AspNetCore.SignalR.Client;
|
using Microsoft.AspNetCore.SignalR.Client;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Squirrowse.Core.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@ -11,27 +12,38 @@ namespace Squirrowse.Client.Service
|
|||||||
{
|
{
|
||||||
private readonly IConnectionManager connectionManager;
|
private readonly IConnectionManager connectionManager;
|
||||||
private readonly ILogger<StreamService> logger;
|
private readonly ILogger<StreamService> logger;
|
||||||
|
private readonly HubConnection session;
|
||||||
public StreamService(ILogger<StreamService> logger, IConnectionManager connectionManager)
|
public StreamService(ILogger<StreamService> logger, IConnectionManager connectionManager)
|
||||||
{
|
{
|
||||||
this.connectionManager = connectionManager;
|
this.connectionManager = connectionManager;
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
|
session = connectionManager.Connect();
|
||||||
|
session.StartAsync().ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task SayHello()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await session.SendAsync("AddToGroup",Groups.debug);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task SendStreamAsync(IAsyncEnumerable<byte[]> asb)
|
public async Task SendStreamAsync(IAsyncEnumerable<byte[]> asb)
|
||||||
{
|
{
|
||||||
var con = connectionManager.Connect();
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
logger.LogInformation($"{nameof(SendStreamAsync)} Start stream");
|
logger.LogInformation($"{nameof(SendStreamAsync)} Start stream");
|
||||||
await con.StartAsync();
|
await session.SendAsync("UploadByteStream", asb, default);
|
||||||
await con.SendAsync("UploadByteStream", asb, default);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
logger.LogInformation($"{nameof(SendStreamAsync)} End stream");
|
logger.LogInformation($"{nameof(SendStreamAsync)} End stream");
|
||||||
await con.StopAsync();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,4 +11,8 @@
|
|||||||
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" Version="3.0.0" />
|
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" Version="3.0.0" />
|
||||||
<PackageReference Include="OpenCvSharp4.Windows" Version="4.1.1.20191021" />
|
<PackageReference Include="OpenCvSharp4.Windows" Version="4.1.1.20191021" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Squirrowse.Core\Squirrowse.Core.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
Loading…
Reference in New Issue
Block a user