forked from amkovkov/GranuSightSoftware2
fix: CameraService view finder
Image capturing while view finder work
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user