Why does the phone shutdown and battery drains super fast on 20% or less capacity when taking pictures? When the phone is 20%ish or lower battery, after taking pictures the os shuts down. 
I have observed this behavior on 5 different brands (lg, samsung, lenovo, xiaomi, oneplus), across different android os versions, across different camera apps, even on devices with the battery replaced with a new part.

The system takes a picture then shuts down. The battery drains almost visibly upon restart, going from 20 to 15 in a minute or two. 

I've seen it on official roms, flashed roms, rooted phones etc. Hopefully somebody who's an expert in these things can hit this nail on the head.
Long read with plenty of links. I will summarize so that one gets the key points and if needed dive in for details

Battery levels are not accurate


Firstly, battery levels based on voltage are an approximation and not accurate.Android battery levels are based on voltage See Are battery monitors accurate ? . Key points:


See this answer to understand why voltage based battery levels are misleading 




  The voltage of a battery does not tell you how much charge a battery has, nor does any other characteristic of the battery. Battery voltage does drop as capacity drops, but the voltage drop is a function of the percentage of charge, not amount of charge.


In other words, voltage correlates to percentage of charge, not amount of charge.


Li Ion batteries display a "flattish" voltage drop even though the amount of charge falls relatively steep.
Frequency(how often) Voltage levels are updated to reflect the current state is 
up to the OEM (so,phones may show different battery levels under identical conditions


Voltage levels at extremities are again inaccurate for safety reasons


When your device says it is 100% , it is not really so (see this answer
When your device says it is O or low battery , it is not really so since a prevention circuit kicks in stopping further discharge


Camera draws a lot of power


Power drawn by a camera is quite high 1000- 2000 mW based on this old answer.This excludes the full screen power. Present day phones with multiple cameras and complex algorithmsfor image processing will surely draw a lot more likely to the tune of 3500 mW
As pointed out in comments, if you are using a flash even more power is drawn


Critical or low battery shut down

From Android 5 , IIRC, this feature was introduced , with later versions allowing you to configure the low battery level. High camera power drawn drops the voltage level to low battery shutdown

To summarise , we saw that voltage based battery levels are inaccurate, camera draws a lot of power and there is a critical battery shut down which is likely triggered 

Readings on reboot


When you reboot the phone , Hysteresis comes into play



  Hysteresis is simply the fact that once we've got the battery discharging, if we stop discharging it (say, by turning the phone off), it will keep on discharging by itself for a short while.


Your device is programmed to cater for this loss , maybe 2% or more or none


Voltage correction: Considerable power is drawn for reboot.In the first point , we said "voltage drop is a function of the percentage of charge, not amount of charge." . Percentage of change means there is a previous value needed to compare , i.e, N-1 (previous) value compared to N (current value). Now when it is 20% on reboot, it takes some time to estimate the current value (a minute or so in your question) and fall to the current value. 


Hysteresis plus adjusting to the current value contribute to the rapid fall in a short duration

To add to all this is the degradation of battery performance over time and aging effect as described here Battery capacity wear-down, and its relationship to charging practices to be taken into consideration to answer your query in comments (why did the estimate work properly in the first months of life)