20
20
import os
21
21
import pathlib as plib
22
22
import shutil
23
+ import warnings
23
24
import tqdm
24
25
from picamerax import PiCamera
25
26
from fractions import Fraction
@@ -161,7 +162,26 @@ def collect_dataset(config):
161
162
camera .close ()
162
163
163
164
# -- now set up camera with desired settings
164
- camera = PiCamera (sensor_mode = 0 , resolution = tuple (res ), framerate = config .capture .framerate )
165
+ max_increase = (
166
+ config .capture .fact_increase * config .max_tries
167
+ if config .max_tries > 0
168
+ else 1
169
+ )
170
+ max_exposure = min (20 , config .capture .exposure * max_increase )
171
+ if config .capture .framerate is None :
172
+ framerate = 1 / max_exposure
173
+ warnings .warn (
174
+ f"Framerate is not given. Setting it to 1 / max_exposure = { framerate } "
175
+ )
176
+ elif config .capture .framerate > 1 / max_exposure :
177
+ warnings .warn (
178
+ f"Framerate should be less or equal 1 / max_exposure = { 1 / max_exposure } . Resetting framerate"
179
+ )
180
+ framerate = 1 / max_exposure
181
+ else :
182
+ framerate = config .capture .framerate
183
+
184
+ camera = PiCamera (sensor_mode = 0 , resolution = tuple (res ), framerate = framerate )
165
185
166
186
# Set ISO to the desired value
167
187
camera .resolution = tuple (res )
@@ -175,8 +195,8 @@ def collect_dataset(config):
175
195
init_shutter_speed = int (config .capture .exposure * 1e6 )
176
196
else :
177
197
init_shutter_speed = camera .exposure_speed
178
- camera .shutter_speed = init_shutter_speed
179
198
camera .exposure_mode = "off"
199
+ camera .shutter_speed = init_shutter_speed
180
200
181
201
# AWB
182
202
if config .capture .awb_gains :
@@ -362,8 +382,10 @@ def capture_screen(
362
382
fact_decrease = config .capture .fact_decrease
363
383
n_tries = 0
364
384
365
- camera .shutter_speed = int (init_shutter_speed )
366
- time .sleep (config .capture .config_pause )
385
+ if MAX_TRIES > 0 :
386
+ # shutter speed is constant for MAX_TRIES == 0
387
+ camera .shutter_speed = int (init_shutter_speed )
388
+ time .sleep (config .capture .config_pause )
367
389
current_shutter_speed = camera .shutter_speed
368
390
369
391
current_screen_brightness = init_brightness
0 commit comments