TL;DR: Disable legacy camera support with raspi-config and run sudo apt install python3-picamera2. Then try again (with Thonny or any other IDE).
@DougKoebler I had suggested using picamera2 without thinking of the number of steps you’d have to take to use it. You’ll have to disable legacy camera support using raspi-config and during the time that it’s disabled you will not be able to use the openflexure software (at least I don’t think so, never tried it). Then you’ll need to install picamera2. You can try sudo apt get install python3-picamera2. I don’t know much about the openflexure debian distribution, so you may run into snags here that I’m not aware of.
Another option would be to use picamera. I just gave this a shot (pun intended?) and found that getting the bayer data is a little bit difficult. Happy to get some insight from the OpenFlexure folks here if there is some. What I found is that the bayer data is not actually included in the EXIF data when all you’re doing is setting bayer=True in the picamera interface. Perhaps the OpenFlexure software places it in the EXIF section, I haven’t checked. When using just the picamera interface, the bayer data is (at least appears to be) appended to the end of the JPEG. I wrote a script to search for the EOI marker (End of Image marker) and found that immediately passed it is a “BRCM” magic number. This indicates to me that the bayer data is actually in some kind of proprietary file format. Normal raw bayer data (like what you get from picamera2) does not usually contain anything other than the raw color data. So I’m not actually sure how to proceed extracting bayer data from picamera. Maybe someone has reverse engineered the format.
What I did notice was that the JPEG file I got was 13M (13 * 1024 * 1024 bytes), which includes the bayer data and JPEG data. A 10 bit raw bayer array with 6 bits of padding per pixel, like what picamera2 does, takes up about 15M. My guess is that in the v1 version of picamera the data is packed into 10 bits with no padding, which would make it about 9M (3280246410/8 bytes).
So you might need to try disabling legacy camera support with raspi-config for a bit. You can enable it again when you want to run the OpenFlexure software again. Unless someone here knows how to actually decode the proprietary bayer data with the picamera v1. Sorry for the long post. Initially I was going to send you a script to capture data with picamera v1, but could never get it to work due to not knowing the data format.









