PiCamera Flask, start and stop preview
First of all, the start_preview
and stop_preview
methods of picamera just start and stop the preview, which is the overlay video that appears on the Pi's own display. These methods do not start or stop the camera itself.
To stop the camera, you have to get the background thread in method _thread
to exit, in a similar way as it exits when 10 seconds of inactivity pass.
For example, you could add a stop_camera
variable to the object, initialized with False
. In your stop method you just flip the variable to True
and return. Then in the background thread, you add a second condition based on the value of this variable in the conditional that checks for 10 seconds of inactivity.
Hope this helps!