@@ -262,100 +262,122 @@ def ov_apply_camera_settings(cam, prefs):
262262 try :
263263 # Basic image adjustments
264264 brightness = prefs .get_int ("brightness" )
265- cam .set_brightness (brightness )
265+ if brightness is not None :
266+ cam .set_brightness (brightness )
266267
267268 contrast = prefs .get_int ("contrast" )
268- cam .set_contrast (contrast )
269+ if contrast is not None :
270+ cam .set_contrast (contrast )
269271
270272 saturation = prefs .get_int ("saturation" )
271- cam .set_saturation (saturation )
273+ if saturation is not None :
274+ cam .set_saturation (saturation )
272275
273276 # Orientation
274277 hmirror = prefs .get_bool ("hmirror" )
275- cam .set_hmirror (hmirror )
278+ if hmirror is not None :
279+ cam .set_hmirror (hmirror )
276280
277281 vflip = prefs .get_bool ("vflip" )
278- cam .set_vflip (vflip )
282+ if vflip is not None :
283+ cam .set_vflip (vflip )
279284
280285 # Special effect
281286 special_effect = prefs .get_int ("special_effect" )
282- cam .set_special_effect (special_effect )
287+ if special_effect is not None :
288+ cam .set_special_effect (special_effect )
283289
284290 # Exposure control (apply master switch first, then manual value)
285291 exposure_ctrl = prefs .get_bool ("exposure_ctrl" )
286- cam . set_exposure_ctrl ( exposure_ctrl )
287-
288- if not exposure_ctrl :
292+ if exposure_ctrl is not None :
293+ cam . set_exposure_ctrl ( exposure_ctrl )
294+ else :
289295 aec_value = prefs .get_int ("aec_value" )
290- cam .set_aec_value (aec_value )
296+ if aec_value is not None :
297+ cam .set_aec_value (aec_value )
291298
292299 # Mode-specific default comes from constructor
293300 ae_level = prefs .get_int ("ae_level" )
294- cam .set_ae_level (ae_level )
301+ if ae_level is not None :
302+ cam .set_ae_level (ae_level )
295303
296304 aec2 = prefs .get_bool ("aec2" )
297- cam .set_aec2 (aec2 )
305+ if aec2 is not None :
306+ cam .set_aec2 (aec2 )
298307
299308 # Gain control (apply master switch first, then manual value)
300309 gain_ctrl = prefs .get_bool ("gain_ctrl" )
301- cam . set_gain_ctrl ( gain_ctrl )
302-
303- if not gain_ctrl :
310+ if gain_ctrl is not None :
311+ cam . set_gain_ctrl ( gain_ctrl )
312+ else :
304313 agc_gain = prefs .get_int ("agc_gain" )
305- cam .set_agc_gain (agc_gain )
314+ if agc_gain is None :
315+ cam .set_agc_gain (agc_gain )
306316
307317 gainceiling = prefs .get_int ("gainceiling" )
308- cam .set_gainceiling (gainceiling )
318+ if gainceiling is not None :
319+ cam .set_gainceiling (gainceiling )
309320
310321 # White balance (apply master switch first, then mode)
311322 whitebal = prefs .get_bool ("whitebal" )
312- cam . set_whitebal ( whitebal )
313-
314- if not whitebal :
323+ if whitebal is not None :
324+ cam . set_whitebal ( whitebal )
325+ else :
315326 wb_mode = prefs .get_int ("wb_mode" )
316- cam .set_wb_mode (wb_mode )
327+ if wb_mode is not None :
328+ cam .set_wb_mode (wb_mode )
317329
318330 awb_gain = prefs .get_bool ("awb_gain" )
319- cam .set_awb_gain (awb_gain )
331+ if awb_gain is not None :
332+ cam .set_awb_gain (awb_gain )
320333
321334 # Sensor-specific settings (try/except for unsupported sensors)
322335 try :
323336 sharpness = prefs .get_int ("sharpness" )
324- cam .set_sharpness (sharpness )
337+ if sharpness is not None :
338+ cam .set_sharpness (sharpness )
325339 except :
326340 pass # Not supported on OV2640?
327341
328342 try :
329343 denoise = prefs .get_int ("denoise" )
330- cam .set_denoise (denoise )
344+ if denoise is not None :
345+ cam .set_denoise (denoise )
331346 except :
332347 pass # Not supported on OV2640?
333348
334349 # Advanced corrections
335350 colorbar = prefs .get_bool ("colorbar" )
336- cam .set_colorbar (colorbar )
351+ if colorbar is not None :
352+ cam .set_colorbar (colorbar )
337353
338354 dcw = prefs .get_bool ("dcw" )
339- cam .set_dcw (dcw )
355+ if dcw is not None :
356+ cam .set_dcw (dcw )
340357
341358 bpc = prefs .get_bool ("bpc" )
342- cam .set_bpc (bpc )
359+ if bpc is not None :
360+ cam .set_bpc (bpc )
343361
344362 wpc = prefs .get_bool ("wpc" )
345- cam .set_wpc (wpc )
363+ if wpc is not None :
364+ cam .set_wpc (wpc )
346365
347366 # Mode-specific default comes from constructor
348367 raw_gma = prefs .get_bool ("raw_gma" )
349- print (f"applying raw_gma: { raw_gma } " )
350- cam .set_raw_gma (raw_gma )
368+ if raw_gma is not None :
369+ print (f"applying raw_gma: { raw_gma } " )
370+ cam .set_raw_gma (raw_gma )
351371
352372 lenc = prefs .get_bool ("lenc" )
353- cam .set_lenc (lenc )
373+ if lenc is not None :
374+ cam .set_lenc (lenc )
354375
355376 # JPEG quality (only relevant for JPEG format)
356377 #try:
357378 # quality = prefs.get_int("quality", 85)
358- # cam.set_quality(quality)
379+ # if quality is not None:
380+ # cam.set_quality(quality)
359381 #except:
360382 # pass # Not in JPEG mode
361383
0 commit comments