Camera settings

This commit is contained in:
ziomus5555 2019-11-02 21:06:44 +01:00
parent 6fed61be4a
commit 93e692df9e
5 changed files with 32 additions and 9 deletions

View File

@ -8,9 +8,16 @@ namespace Squirrowse.Client.Service
{
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)

View File

@ -8,7 +8,7 @@ namespace Squirrowse.Client.Service
{
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);
}
}

View File

@ -8,7 +8,7 @@ namespace Squirrowse.Client.Service
public interface IStreamService
{
Task SendStreamAsync(IAsyncEnumerable<byte[]> asb);
Task SayHello();
}
}

View File

@ -1,5 +1,6 @@
using Microsoft.AspNetCore.SignalR.Client;
using Microsoft.Extensions.Logging;
using Squirrowse.Core.Models;
using System;
using System.Collections.Generic;
using System.Text;
@ -11,27 +12,38 @@ namespace Squirrowse.Client.Service
{
private readonly IConnectionManager connectionManager;
private readonly ILogger<StreamService> logger;
private readonly HubConnection session;
public StreamService(ILogger<StreamService> logger, IConnectionManager connectionManager)
{
this.connectionManager = connectionManager;
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)
{
var con = connectionManager.Connect();
try
{
logger.LogInformation($"{nameof(SendStreamAsync)} Start stream");
await con.StartAsync();
await con.SendAsync("UploadByteStream", asb, default);
await session.SendAsync("UploadByteStream", asb, default);
}
finally
{
logger.LogInformation($"{nameof(SendStreamAsync)} End stream");
await con.StopAsync();
}
}
}

View File

@ -11,4 +11,8 @@
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" Version="3.0.0" />
<PackageReference Include="OpenCvSharp4.Windows" Version="4.1.1.20191021" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Squirrowse.Core\Squirrowse.Core.csproj" />
</ItemGroup>
</Project>