techyian / MMALSharp

C# wrapper to Broadcom's MMAL with an API to the Raspberry Pi camera.
MIT License
195 stars 33 forks source link

Setting ShutterSpeed not taking #191

Closed stwolfe closed 3 years ago

stwolfe commented 3 years ago

I have tried simple snapshot using the settings you have in the example docs:

MMALCameraConfig.ShutterSpeed = 2000000; // Set to 2s exposure time. Default is 0 (auto). MMALCameraConfig.ISO = 400; // Set ISO to 400. Default is 0 (auto).

When inspecting the image that is taken, the ISO is correct but the shutter speed used is always 1/30s.

stwolfe commented 3 years ago

I see the settings for framerate have changed in the dev branch from master. And I have tried to compare what is going on in MMALSharp vs Raspistill.

Raspistill setting just the ShutterSpeed does works.

techyian commented 3 years ago

The shutter speed is constrained by the camera still port's frame rate. Raspistill uses a variable frame rate by setting the value to 0. If you want to see the same behaviour as Raspistill, depending on whether you're using v0.6 or the current dev branch, you'll want to do one of the following:

For v0.6 (current NuGet build): MMALCameraConfig.VideoFramerate = new MMAL_RATIONAL_T(0, 1); - see here for context.

For v0.7 (current dev branch): MMALCameraConfig.Framerate = 0;

Please let me know if that fixes the problem for you.

stwolfe commented 3 years ago

@techyian,

Yes, setting the VideoFramerate allowed the shutter speed to take. I was setting the StillFramerate, I assume that bit of confusion is why the dev build only has 1 setting.

The only difference I see between my simple application just setting the VideoFramerate and shutter speed is the selected resolution. My program with MMALSharp takes picture @ 2560 x 1920, where as rapsistill with just setting shutter speed takes picture @ 3280 x 2464

Thanks for the quick response, this has me moving forward.

techyian commented 3 years ago

No problem. On v0.6, MMALCameraConfig.StillResolution is set to Resolution.As5MPixel by default and you can override it with your desired resolution.

stwolfe commented 3 years ago

Thanks again for your responses, and thanks for creating such a great library.