Added proper Exposure adjustment
This commit is contained in:
parent
e77d20900b
commit
810297ac46
@ -1,6 +1,7 @@
|
|||||||
#!//usr/bin/python3
|
#!//usr/bin/python3
|
||||||
|
|
||||||
import numpyHDR
|
import numpyHDR
|
||||||
|
from PIL import Image
|
||||||
from picamera2 import Picamera2
|
from picamera2 import Picamera2
|
||||||
from libcamera import controls
|
from libcamera import controls
|
||||||
import time
|
import time
|
||||||
@ -8,21 +9,64 @@ import time
|
|||||||
picam2 = Picamera2()
|
picam2 = Picamera2()
|
||||||
config = picam2.create_still_configuration()
|
config = picam2.create_still_configuration()
|
||||||
picam2.configure(config)
|
picam2.configure(config)
|
||||||
|
picam2.set_controls({"AwbEnable": 1})
|
||||||
|
picam2.set_controls({"AeEnable": 1})
|
||||||
|
#picam2.set_controls({"AnalogueGain": 1.0})
|
||||||
picam2.start()
|
picam2.start()
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
ctrls = controls(picam2)
|
|
||||||
ctrls.AwbEnable = 1
|
print(picam2.capture_metadata())
|
||||||
ctrls.AeEnable = 1
|
start = picam2.capture_metadata()
|
||||||
ctrls.ConstraintModeEnum.Highlight
|
exposure_start = start["ExposureTime"]
|
||||||
np_array_ev0 = picam2.capture_array()
|
gain_start = start["AnalogueGain"]
|
||||||
#picam2.set_controls({"AwbEnable": 1, "AeEnable": 1, "AeConstraintMode": controls.AeConstraintModeEnum.Shadows})
|
|
||||||
#np_array_ev1 = picam2.capture_array()
|
|
||||||
#picam2.set_controls({"AwbEnable": 1, "AeEnable": 1, "AeConstraintMode": controls.AeConstraintModeEnum.Normal})
|
ev1 = picam2.capture_array()
|
||||||
#np_array_ev_neg1 = picam2.capture_array()
|
print("Picture one is done")
|
||||||
meta = "nichts"
|
|
||||||
picam2.helpers.save(np_array_ev0, meta, "1.jpg")
|
picam2.set_controls({"AeEnable": 0})
|
||||||
#picam2.helpers.save(np_array_ev1, meta ,"2.jpg")
|
confirmed = picam2.capture_metadata()["AeLocked"]
|
||||||
#picam2.helpers.save(np_array_ev_neg1, meta, "3.jpg")
|
while confirmed != True:
|
||||||
|
confimed = picam2.capture_metadata()["AeLocked"]
|
||||||
|
time.sleep(.1)
|
||||||
|
|
||||||
|
|
||||||
|
picam2.set_controls({"AnalogueGain": gain_start})
|
||||||
|
confirmed = picam2.capture_metadata()["AnalogueGain"]
|
||||||
|
while confirmed != gain_start in range(gain_start -0.1, gain_start +0.1):
|
||||||
|
confimed = picam2.capture_metadata()["AnalogueGain"]
|
||||||
|
time.sleep(.1)
|
||||||
|
|
||||||
|
ev_low = int(exposure_start / 4)
|
||||||
|
picam2.set_controls({"ExposureTime": ev_low})
|
||||||
|
confirmed = picam2.capture_metadata()["ExposureTime"]
|
||||||
|
while confirmed not in range(ev_low -100, ev_low + 100 ):
|
||||||
|
confirmed = picam2.capture_metadata()["ExposureTime"]
|
||||||
|
time.sleep(.01)
|
||||||
|
|
||||||
|
print("2",confirmed)
|
||||||
|
ev2 = picam2.capture_array()
|
||||||
|
print("Picture 2 is captured to array")
|
||||||
|
|
||||||
|
ev_high = int(exposure_start * 4)
|
||||||
|
picam2.set_controls({"ExposureTime": ev_high})
|
||||||
|
confirmed = picam2.capture_metadata()["ExposureTime"]
|
||||||
|
while confirmed not in range(ev_high -100, ev_high + 100 ):
|
||||||
|
confirmed = picam2.capture_metadata()["ExposureTime"]
|
||||||
|
time.sleep(.01)
|
||||||
|
|
||||||
|
print("3",confirmed)
|
||||||
|
ev3 = picam2.capture_array()
|
||||||
|
print("Picture 3 is captured")
|
||||||
|
print("Saving..")
|
||||||
|
|
||||||
|
image = Image.fromarray(ev1)
|
||||||
|
image.save(f"test_hdr0.jpg", quality=50)
|
||||||
|
|
||||||
|
image = Image.fromarray(ev2)
|
||||||
|
image.save(f"test_hdr1.jpg", quality=50)
|
||||||
|
|
||||||
|
image = Image.fromarray(ev3)
|
||||||
|
image.save(f"test_hdr2.jpg", quality=50)
|
||||||
|
|
||||||
picam2.stop()
|
picam2.stop()
|
Loading…
Reference in New Issue
Block a user