31 lines
743 B
C#
31 lines
743 B
C#
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
using OpenCvSharp;
|
|
using Squirrowse.Core.Services;
|
|
|
|
namespace Squirrowse.Client.Service
|
|
{
|
|
public class CameraService : ICameraService
|
|
{
|
|
private readonly VideoCapture _videoCapture;
|
|
|
|
public CameraService(CameraFactory cam)
|
|
{
|
|
_videoCapture = cam.GetCamera();
|
|
}
|
|
|
|
|
|
public async Task<Mat> GetFrame()
|
|
{
|
|
var video = _videoCapture.RetrieveMat();
|
|
return video;
|
|
}
|
|
|
|
public async IAsyncEnumerable<byte[]> GetFramesAsyncEnumerator()
|
|
{
|
|
using var fr = await GetFrame();
|
|
yield return fr.ConvertToJpgByte();
|
|
//fr.Dispose();
|
|
}
|
|
}
|
|
} |