fix: CameraService view finder

Image capturing while view finder work
This commit is contained in:
2026-02-09 09:42:39 +03:00
parent 47b8d60c52
commit 47ca758fbb
6 changed files with 43 additions and 24 deletions
+10 -8
View File
@@ -391,8 +391,10 @@ public partial class CameraView : OpenGlControlBase
try
{
(LibCameraSharp.FrameBuffer, LibCameraSharp.StreamConfiguration)? frame = null;
while (frame is null)
while (frame is null && (DataContext as CameraViewModel)?.CanGrabViewFinderFrame() == true)
frame = (DataContext as CameraViewModel)?.GrabViewFinderFrame();
if (frame is null)
return;
var (frameBuffer, streamConfiguration) = frame.Value;
// 0. Проверяем что полученый фрейм ожидаемый праильный формат
@@ -429,12 +431,12 @@ public partial class CameraView : OpenGlControlBase
return;
}
var plane = frameBuffer.Planes.First();
if (plane.Length != width * height * 4)
{
_logger.LogError("Cannot render frame, plane validation error, expected plane size 0x{:X}, got 0x{:X}", width * height * 4, plane.Length);
(DataContext as CameraViewModel)?.ReturnViewFinderFrame(frameBuffer);
return;
}
// if (plane.Length != width * height * 4)
// {
// _logger.LogError("Cannot render frame, plane validation error, expected plane size 0x{:X}, got 0x{:X}", width * height * 4, plane.Length);
// (DataContext as CameraViewModel)?.ReturnViewFinderFrame(frameBuffer);
// return;
// }
var fd = plane.Fd.Get();
if (fd <= 0)
{
@@ -468,7 +470,7 @@ public partial class CameraView : OpenGlControlBase
OpenGLContext.EGL_LINUX_DRM_FOURCC_EXT, unchecked((int)OpenGLContext.DRM_FORMAT_BGRX8888),
OpenGLContext.EGL_DMA_BUF_PLANE0_FD_EXT, fd,
OpenGLContext.EGL_DMA_BUF_PLANE0_OFFSET_EXT, 0,
OpenGLContext.EGL_DMA_BUF_PLANE0_PITCH_EXT, (int)(width * 4),
OpenGLContext.EGL_DMA_BUF_PLANE0_PITCH_EXT, (int)(plane.Length / height),
EglConsts.EGL_NONE
};
image = _openGLContext.EglCreateImageKHR.Invoke(_openGLContext.EglDisplay, IntPtr.Zero, OpenGLContext.EGL_LINUX_DMA_BUF_EXT, IntPtr.Zero, attribs);