File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import time
2+ from picamera2 import Picamera2
3+
4+ # Initialize camera
5+ picam2 = Picamera2 ()
6+ config = picam2 .create_still_configuration ()
7+ picam2 .configure (config )
8+ picam2 .start ()
9+
10+ def take_long_exposure (duration_seconds = 10 , filename = "long_exposure.jpg" ):
11+ print (f"📸 Preparing { duration_seconds } s exposure..." )
12+
13+ # Convert seconds to microseconds
14+ exposure_time_us = int (duration_seconds * 1_000_000 )
15+
16+ # Set manual controls
17+ # Note: We set these BEFORE capturing
18+ picam2 .set_controls ({
19+ "ExposureTime" : exposure_time_us ,
20+ "AeEnable" : False , # Disable Auto Exposure
21+ "AnalogueGain" : 1.0 , # Keep gain low to reduce 'noise' (graininess)
22+ "AwbEnable" : False , # Disable Auto White Balance for consistency
23+ "ColourGains" : (1.5 , 1.5 )
24+ })
25+
26+ # Wait for settings to settle
27+ time .sleep (2 )
28+
29+ print ("🚀 Shutter OPEN..." )
30+ picam2 .capture_file (filename )
31+ print (f"✅ Shutter CLOSED. Saved as { filename } " )
32+
33+ try :
34+ take_long_exposure (10 ) # 10-second exposure
35+ finally :
36+ picam2 .stop ()
You can’t perform that action at this time.
0 commit comments