MMALSharp: Image capture delivers empty result and finally goes to endless loop
Hi,
first of all thank you for this great library! I have encountered a problem actually - and it might well be that I have misunderstood something here or used the library in a wrong way!
The scenario:
I try to capture an image every 5 seconds and store this to an Azure Blob storage. In a first step I went with the time lapse feature, but ditched that, because I could not find a way to resize the image before sending it to the capture handler. For this approach I created a dedicated AzureStorageCaptureHandler that was based on the MemoryStreamCaptureHandlerwhile implementing the IFileStreamCaptureHandler interface.
So I went and implemented my own mechanism. You can find a very stripped down implementation in the Spontifixus/mmalsharp-demo repository. The setup is derived from the “resizer component” example. In pseudo code it looks this way:
ConfigureCamera
For i = 0 To 100
memoryStreamHandler = new MemoryStreamCaptureHandler()
CaptureImage(memoryStreamHandler)
StoreImage(memoryStreamHandler)
memoryStreamHandler.Dispose()
Next
Expected behavior: I expect the code to store 100 images, without capturing empty images, and without going into an endless loop.
Actual behavior The application produces empty images every few captures and finally goes into an endless loop because a buffer cannot be released. Here’s a log of the test run: debug.log, with the following interesting parts:
- Lines 105 - 154: Successful capture
- Lines 155 - 162: Successful storage
- Lines 495 - 542: Failed capture
- Lines 3051 - End: Capture Started, resulting in infinite loop.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 27 (13 by maintainers)
Commits related to this issue
- #136 - Do not send buffer to port if we have reached end of stream. — committed to techyian/MMALSharp by techyian 4 years ago
Just to update you on this I’ve made some changes to the Resizer example which should hopefully clarify how this component would typically be used. Please also note my comments around using a ramdisk mount for performance reasons. If there’s anything that’s still unclear please let me know but I think at this stage we’re good to close this ticket off.
Yes I agree that example is fairly useless considering you can just set the resolution against the camera directly. By all means if you want to add some guidance to that section that would be very helpful. I’ll also put together an example which features both the Resizer and Splitter components to show how the two can compliment eachother.
You can change the amount of memory allocated to the GPU via
sudo raspi-config. Once you’re in the tool navigate to:Advanced Options -> Memory Split
In there you can assign a value in MB and then you’ll need to do a restart. By default 64MB is assigned to the GPU and sometimes you can require a little bit more when using the camera module.