So I have a python program in which I'm using the picamera library to shoot pictures and record video. I'm using my program for scientific purposes and my goal is keep each picture as close to the previous picture as possible, both visually and in file size (post & pre-processing). I'm aware that I most likely should be creating YUV images or getting the Bayer data, but JPEGs allow me to visually inspect the images easily and I want to see if they will be good enough.
So what I am doing is similar to both this recipe and this question. In that I'm trying to keep all picamera parameters held constant: resolution, no denoise, LED off, shutter speed, iso and AWB. The issue is that I create a new PiCamera() instance everytime I call my take_picture() function. So what I believe it happening is in the time from when I create the camera instance to when I turn off exposure_mode the digital_gain and analog_gain could settle on different values based on light conditions. This could skew the results of my tests.
So what I believe I'll do is make my camera module a class and create the PiCamera() instance in init so that it is persistent through program scope and all parameters are held constant. The question I have is that I usually exit my program by pressing CTRL+C, A.K.A. raising a KeyboardInterrupt. If I do this will the camera instance never call close() and be left in a weird state?