mirror of
https://github.com/raspberrypi/userland.git
synced 2025-12-06 12:59:12 +00:00
RaspiStill: Read sensor information correctly if one of each type is attached.
On a CM with one OV5647 and one IMX219, the setup of whichever sensor is camera 0 was taken for both sensors. That meant the default resolution and EXIF headers were wrong for the second camera.
This commit is contained in:
@@ -271,8 +271,6 @@ static void set_sensor_defaults(RASPISTILL_STATE *state)
|
||||
MMAL_STATUS_T status;
|
||||
|
||||
// Default to the OV5647 setup
|
||||
state->width = 2592;
|
||||
state->height = 1944;
|
||||
strncpy(state->camera_name, "OV5647", MMAL_PARAMETER_CAMERA_INFO_MAX_STR_LEN);
|
||||
|
||||
// Try to get the camera name and maximum supported resolution
|
||||
@@ -289,12 +287,14 @@ static void set_sensor_defaults(RASPISTILL_STATE *state)
|
||||
// Running on newer firmware
|
||||
param.hdr.size = sizeof(param);
|
||||
status = mmal_port_parameter_get(camera_info->control, ¶m.hdr);
|
||||
if (status == MMAL_SUCCESS && param.num_cameras > 0)
|
||||
if (status == MMAL_SUCCESS && param.num_cameras > state->cameraNum)
|
||||
{
|
||||
// Take the parameters from the first camera listed.
|
||||
state->width = param.cameras[0].max_width;
|
||||
state->height = param.cameras[0].max_height;
|
||||
strncpy(state->camera_name, param.cameras[0].camera_name, MMAL_PARAMETER_CAMERA_INFO_MAX_STR_LEN);
|
||||
if (state->width == 0)
|
||||
state->width = param.cameras[state->cameraNum].max_width;
|
||||
if (state->height == 0)
|
||||
state->height = param.cameras[state->cameraNum].max_height;
|
||||
strncpy(state->camera_name, param.cameras[state->cameraNum].camera_name, MMAL_PARAMETER_CAMERA_INFO_MAX_STR_LEN);
|
||||
state->camera_name[MMAL_PARAMETER_CAMERA_INFO_MAX_STR_LEN-1] = 0;
|
||||
}
|
||||
else
|
||||
@@ -312,6 +312,12 @@ static void set_sensor_defaults(RASPISTILL_STATE *state)
|
||||
{
|
||||
vcos_log_error("Failed to create camera_info component");
|
||||
}
|
||||
//Command line hasn't specified a resolution, and we failed to
|
||||
//get a default resolution from camera_info. Assume OV5647 full res
|
||||
if (state->width == 0)
|
||||
state->width = 2592;
|
||||
if (state->height == 0)
|
||||
state->height = 1944;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -361,9 +367,6 @@ static void default_status(RASPISTILL_STATE *state)
|
||||
state->timestamp = 0;
|
||||
state->restart_interval = 0;
|
||||
|
||||
// Setup for sensor specific parameters
|
||||
set_sensor_defaults(state);
|
||||
|
||||
// Setup preview window defaults
|
||||
raspipreview_set_defaults(&state->preview_parameters);
|
||||
|
||||
@@ -1808,6 +1811,9 @@ int main(int argc, const char **argv)
|
||||
exit(EX_USAGE);
|
||||
}
|
||||
|
||||
// Setup for sensor specific parameters
|
||||
set_sensor_defaults(&state);
|
||||
|
||||
if (state.verbose)
|
||||
{
|
||||
fprintf(stderr, "\n%s Camera App %s\n\n", basename(argv[0]), VERSION_STRING);
|
||||
|
||||
Reference in New Issue
Block a user