techyian / MMALSharp

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

cam.Cleanup() Turns off light But Can't get instance again. #122

Closed uastephen45 closed 4 years ago

uastephen45 commented 4 years ago

When i run cam.Cleanup(); i can no longer use the camera even if i run cam = MMALCamera.Instance;

I have to start my app up again.

how can i turn off the camera and then turn it on again once a client is trying to view the feed?

techyian commented 4 years ago

Hi, this is by design. The call to MMALCamera.Instance initialises the MMALCamera class lazily so it will only initialise when you first call it. The call to cam.Cleanup() will unload the Broadcom library and disposes of any unmanaged resources still in use - it should only be called when you don't want to do anything else with the camera. If the issue is seeing the LED on your camera then you can turn it off completely with the following config change in /boot/config.txt:

disable_camera_led=1