Skip to content

Commit

Permalink
options: Fix HDR handling when camera num >= number of cameras
Browse files Browse the repository at this point in the history
This would attempt to access a camera that did not exist in the vector.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
  • Loading branch information
naushir committed Oct 26, 2023
1 parent 00e39d5 commit b7fab73
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions core/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,18 +200,20 @@ bool Options::Parse(int argc, char *argv[])
libcamera::logSetTarget(libcamera::LoggingTargetNone);

std::vector<std::shared_ptr<libcamera::Camera>> cameras = app_->GetCameras();
const std::string cam_id = *cameras[camera]->properties().get(libcamera::properties::Model);

if ((hdr == "sensor" || hdr == "auto") && cam_id == "imx708")
if (camera < cameras.size())
{
// Turn on sensor HDR. Reset the camera manager if we have switched the value of the control.
if (set_subdev_hdr_ctrl(1))
const std::string cam_id = *cameras[camera]->properties().get(libcamera::properties::Model);
if ((hdr == "sensor" || hdr == "auto") && cam_id == "imx708")
{
cameras.clear();
app_->initCameraManager();
cameras = app_->GetCameras();
// Turn on sensor HDR. Reset the camera manager if we have switched the value of the control.
if (set_subdev_hdr_ctrl(1))
{
cameras.clear();
app_->initCameraManager();
cameras = app_->GetCameras();
}
hdr = "sensor";
}
hdr = "sensor";
}

if (list_cameras)
Expand Down

0 comments on commit b7fab73

Please sign in to comment.