Skip to content
This repository has been archived by the owner on Mar 28, 2024. It is now read-only.

Commit

Permalink
techyian#108 - Allow raw frames to be passed to Image Processors. Do …
Browse files Browse the repository at this point in the history
…not call Callback Handler if buffer is empty for still ports.
  • Loading branch information
techyian committed Sep 12, 2020
1 parent 5fa6ea2 commit 8b07ab3
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/MMALSharp.Processing/Handlers/StreamCaptureHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public override void PostProcess()
}
catch(Exception e)
{
MMALLog.Logger.LogWarning($"Something went wrong while processing stream: {e.InnerException?.Message}. {e.StackTrace}");
MMALLog.Logger.LogWarning($"Something went wrong while processing stream: {e.Message}. {e.InnerException?.Message}. {e.StackTrace}");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@ public void ApplyConvolution(double[,] kernel, int kernelWidth, int kernelHeight

Task.WaitAll(t1, t2, t3, t4);

if (context.Raw)
if (context.Raw && context.StoreFormat == null)
{
store = new byte[bytes];
Marshal.Copy(pNative, store, 0, bytes);
}

bmp.UnlockBits(bmpData);

if (!context.Raw)
if (!context.Raw || context.StoreFormat != null)
{
using (var ms2 = new MemoryStream())
{
Expand Down Expand Up @@ -128,7 +128,7 @@ private Bitmap LoadBitmap(ImageContext imageContext, MemoryStream stream)

if (format == default)
{
throw new Exception("Unsupported pixel format for Bitmap");
throw new Exception($"Unsupported pixel format for Bitmap: {imageContext.PixelFormat}.");
}

return new Bitmap(imageContext.Resolution.Width, imageContext.Resolution.Height, format);
Expand Down
2 changes: 1 addition & 1 deletion src/MMALSharp/Components/MMALCameraComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ private void InitialiseStill(IOutputCaptureHandler handler)

portConfig = new MMALPortConfig(
encoding,
null,
encoding,
width: currentWidth,
height: currentHeight,
framerate: MMALCameraConfig.Framerate,
Expand Down
5 changes: 3 additions & 2 deletions src/MMALSharp/Ports/Outputs/OutputPort.cs
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,11 @@ internal virtual void NativeOutputPortCallback(MMAL_PORT_T* port, MMAL_BUFFER_HE
bufferImpl.PrintProperties();

var failed = bufferImpl.AssertProperty(MMALBufferProperties.MMAL_BUFFER_HEADER_FLAG_TRANSMISSION_FAILED);

var eos = bufferImpl.AssertProperty(MMALBufferProperties.MMAL_BUFFER_HEADER_FLAG_FRAME_END) ||
bufferImpl.AssertProperty(MMALBufferProperties.MMAL_BUFFER_HEADER_FLAG_EOS) ||
this.ComponentReference.ForceStopProcessing;
this.ComponentReference.ForceStopProcessing ||
bufferImpl.Length == 0;

if ((bufferImpl.CheckState() && bufferImpl.Length > 0 && !eos && !failed && !this.Trigger.Task.IsCompleted) || (eos && !this.Trigger.Task.IsCompleted))
{
Expand Down

0 comments on commit 8b07ab3

Please sign in to comment.