@@ -238,13 +238,8 @@ def camera_record(record_type, unique_id, duration_sec=None, tmp_filename=None):
238238 logger .exception ("raspistill" )
239239
240240 elif settings .library == 'libcamera' :
241- # Check for rpicam-still first (Bookworm), then fallback to libcamera-still
242- if os .path .exists ("/usr/bin/rpicam-still" ):
243- camera_cmd = "/usr/bin/rpicam-still"
244- elif os .path .exists ("/usr/bin/libcamera-still" ):
245- camera_cmd = "/usr/bin/libcamera-still"
246- else :
247- logger .error ("Neither /usr/bin/rpicam-still nor /usr/bin/libcamera-still found" )
241+ if not os .path .exists ("/usr/bin/libcamera-still" ):
242+ logger .error ("/usr/bin/libcamera-still found" )
248243 return None , None
249244
250245 try :
@@ -254,7 +249,7 @@ def camera_record(record_type, unique_id, duration_sec=None, tmp_filename=None):
254249 filename = f"{ filename } .{ settings .output_format .lower ()} "
255250 path_file = os .path .join (save_path , filename )
256251
257- cmd = f"{ camera_cmd } " \
252+ cmd = f"/usr/bin/libcamera-still " \
258253 f"--width { settings .width } " \
259254 f"--height { settings .height } " \
260255 f"--brightness { settings .brightness } " \
@@ -297,6 +292,61 @@ def camera_record(record_type, unique_id, duration_sec=None, tmp_filename=None):
297292 except :
298293 logger .exception ("libcamera" )
299294
295+ elif settings .library == 'rpicam' :
296+ if not os .path .exists ("/usr/bin/rpicam-still" ):
297+ logger .error ("/usr/bin/rpicam-still found" )
298+ return None , None
299+
300+ try :
301+ if settings .output_format :
302+ # replace extension
303+ filename = filename .rsplit ('.' , 1 )[0 ]
304+ filename = f"{ filename } .{ settings .output_format .lower ()} "
305+ path_file = os .path .join (save_path , filename )
306+
307+ cmd = f"/usr/bin/rpicam-still " \
308+ f"--width { settings .width } " \
309+ f"--height { settings .height } " \
310+ f"--brightness { settings .brightness } " \
311+ f"-o { path_file } "
312+
313+ if settings .output_format :
314+ cmd += f" --encoding { settings .output_format } "
315+ if not settings .show_preview :
316+ cmd += " --nopreview"
317+ if settings .contrast is not None :
318+ cmd += f" --contrast { int (settings .contrast )} "
319+ if settings .saturation is not None :
320+ cmd += f" --saturation { int (settings .saturation )} "
321+ if settings .picamera_sharpness is not None :
322+ cmd += f" --sharpness { int (settings .picamera_sharpness )} "
323+ if settings .picamera_shutter_speed is not None :
324+ cmd += f" --shutter { int (settings .picamera_shutter_speed )} "
325+ if settings .gain is not None :
326+ cmd += f" --gain { settings .gain } "
327+ if settings .picamera_awb not in ["off" , None ]:
328+ cmd += f" --awb { settings .picamera_awb } "
329+ elif (settings .picamera_awb == "off" and
330+ settings .picamera_awb_gain_blue is not None and
331+ settings .picamera_awb_gain_red is not None ):
332+ cmd += f" --awb custom"
333+ cmd += f" --awbgains { settings .picamera_awb_gain_red :.1f} ,{ settings .picamera_awb_gain_blue :.1f} "
334+ if settings .hflip :
335+ cmd += " --hflip"
336+ if settings .vflip :
337+ cmd += " --vflip"
338+ if settings .rotation :
339+ cmd += f" --rotation { settings .rotation } "
340+ if settings .custom_options :
341+ cmd += f" { settings .custom_options } "
342+
343+ out , err , status = cmd_output (cmd , stdout_pipe = False , user = 'root' )
344+ logger .debug (
345+ "Camera debug message: "
346+ f"cmd: { cmd } ; out: { out } ; error: { err } ; status: { status } " )
347+ except :
348+ logger .exception ("rpicam" )
349+
300350 elif settings .library == 'opencv' :
301351 try :
302352 import cv2
0 commit comments