mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-11 09:55:36 +00:00
rpicamsrc: Merge changes from userland repo
Current to b69f807ce59189457662c2144a8e7e12dc776988 No integration of stereoscopic support as yet
This commit is contained in:
parent
edf4927704
commit
4d70e1d8ee
3 changed files with 152 additions and 23 deletions
|
@ -128,6 +128,15 @@ static XREF_T drc_mode_map[] =
|
|||
|
||||
static const int drc_mode_map_size = sizeof(drc_mode_map)/sizeof(drc_mode_map[0]);
|
||||
|
||||
static XREF_T stereo_mode_map[] =
|
||||
{
|
||||
{"off", MMAL_STEREOSCOPIC_MODE_NONE},
|
||||
{"sbs", MMAL_STEREOSCOPIC_MODE_SIDE_BY_SIDE},
|
||||
{"tb", MMAL_STEREOSCOPIC_MODE_TOP_BOTTOM},
|
||||
};
|
||||
|
||||
static const int stereo_mode_map_size = sizeof(stereo_mode_map)/sizeof(stereo_mode_map[0]);
|
||||
|
||||
|
||||
#define CommandSharpness 0
|
||||
#define CommandContrast 1
|
||||
|
@ -150,6 +159,10 @@ static const int drc_mode_map_size = sizeof(drc_mode_map)/sizeof(drc_mode_map[0]
|
|||
#define CommandDRCLevel 18
|
||||
#define CommandStatsPass 19
|
||||
#define CommandAnnotate 20
|
||||
#define CommandStereoMode 21
|
||||
#define CommandStereoDecimate 22
|
||||
#define CommandStereoSwap 23
|
||||
#define CommandAnnotateExtras 24
|
||||
|
||||
static COMMAND_LIST cmdline_commands[] =
|
||||
{
|
||||
|
@ -174,6 +187,10 @@ static COMMAND_LIST cmdline_commands[] =
|
|||
{CommandDRCLevel, "-drc", "drc", "Set DRC Level", 1},
|
||||
{CommandStatsPass, "-stats", "st", "Force recomputation of statistics on stills capture pass"},
|
||||
{CommandAnnotate, "-annotate", "a", "Enable/Set annotate flags or text", 1},
|
||||
{CommandStereoMode, "-stereo", "3d", "Select stereoscopic mode", 1},
|
||||
{CommandStereoDecimate,"-decimate","dec", "Half width/height of stereo image"},
|
||||
{CommandStereoSwap, "-3dswap", "3dswap", "Swap camera order for stereoscopic"},
|
||||
{CommandAnnotateExtras,"-annotateex","ae", "Set extra annotation parameters (text size, text colour(hex YUV), bg colour(hex YUV))", 2},
|
||||
};
|
||||
|
||||
static int cmdline_commands_size = sizeof(cmdline_commands) / sizeof(cmdline_commands[0]);
|
||||
|
@ -591,13 +608,69 @@ int raspicamcontrol_parse_cmdline(RASPICAM_CAMERA_PARAMETERS *params, const char
|
|||
else
|
||||
{
|
||||
params->enable_annotate = ANNOTATE_USER_TEXT;
|
||||
strncpy(params->annotate_string, arg2, MMAL_CAMERA_ANNOTATE_MAX_TEXT_LEN_V2);
|
||||
params->annotate_string[MMAL_CAMERA_ANNOTATE_MAX_TEXT_LEN_V2-1] = '\0';
|
||||
//copy string char by char and replace "\n" with newline character
|
||||
unsigned char c;
|
||||
char const *s = arg2;
|
||||
char *t = ¶ms->annotate_string[0];
|
||||
int n=0;
|
||||
while ((c = *s++) && n < MMAL_CAMERA_ANNOTATE_MAX_TEXT_LEN_V3-1)
|
||||
{
|
||||
if (c == '\\' && *s)
|
||||
{
|
||||
switch (c = *s++)
|
||||
{
|
||||
case 'n':
|
||||
c = '\n';
|
||||
break;
|
||||
|
||||
default:
|
||||
c = '\\';
|
||||
s--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
*(t++) = c;
|
||||
n++;
|
||||
}
|
||||
*t='\0';
|
||||
|
||||
//params->annotate_string[MMAL_CAMERA_ANNOTATE_MAX_TEXT_LEN_V3-1] = '\0';
|
||||
}
|
||||
used=2;
|
||||
break;
|
||||
}
|
||||
|
||||
case CommandAnnotateExtras:
|
||||
{
|
||||
// 3 parameters - text size (6-80), text colour (Hex VVUUYY) and background colour (Hex VVUUYY)
|
||||
sscanf(arg2, "%u,%X,%X", ¶ms->annotate_text_size,
|
||||
¶ms->annotate_text_colour,
|
||||
¶ms->annotate_bg_colour);
|
||||
used=2;
|
||||
break;
|
||||
}
|
||||
|
||||
case CommandStereoMode:
|
||||
{
|
||||
params->stereo_mode.mode = stereo_mode_from_string(arg2);
|
||||
used = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
case CommandStereoDecimate:
|
||||
{
|
||||
params->stereo_mode.decimate = MMAL_TRUE;
|
||||
used = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
case CommandStereoSwap:
|
||||
{
|
||||
params->stereo_mode.swap_eyes = MMAL_TRUE;
|
||||
used = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return used;
|
||||
|
@ -744,6 +817,12 @@ void raspicamcontrol_set_defaults(RASPICAM_CAMERA_PARAMETERS *params)
|
|||
params->stats_pass = MMAL_FALSE;
|
||||
params->enable_annotate = 0;
|
||||
params->annotate_string[0] = '\0';
|
||||
params->annotate_text_size = 0; //Use firmware default
|
||||
params->annotate_text_colour = -1; //Use firmware default
|
||||
params->annotate_bg_colour = -1; //Use firmware default
|
||||
params->stereo_mode.mode = MMAL_STEREOSCOPIC_MODE_NONE;
|
||||
params->stereo_mode.decimate = MMAL_FALSE;
|
||||
params->stereo_mode.swap_eyes = MMAL_FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -807,7 +886,10 @@ int raspicamcontrol_set_all_parameters(MMAL_COMPONENT_T *camera, const RASPICAM_
|
|||
result += raspicamcontrol_set_shutter_speed(camera, params->shutter_speed);
|
||||
result += raspicamcontrol_set_DRC(camera, params->drc_level);
|
||||
result += raspicamcontrol_set_stats_pass(camera, params->stats_pass);
|
||||
result += raspicamcontrol_set_annotate(camera, params->enable_annotate, params->annotate_string);
|
||||
result += raspicamcontrol_set_annotate(camera, params->enable_annotate, params->annotate_string,
|
||||
params->annotate_text_size,
|
||||
params->annotate_text_colour,
|
||||
params->annotate_bg_colour);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -1238,57 +1320,80 @@ int raspicamcontrol_set_stats_pass(MMAL_COMPONENT_T *camera, int stats_pass)
|
|||
*
|
||||
* @return 0 if successful, non-zero if any parameters out of range
|
||||
*/
|
||||
int raspicamcontrol_set_annotate(MMAL_COMPONENT_T *camera, const int settings, const char *string)
|
||||
int raspicamcontrol_set_annotate(MMAL_COMPONENT_T *camera, const int settings, const char *string,
|
||||
const int text_size, const int text_colour, const int bg_colour)
|
||||
{
|
||||
MMAL_PARAMETER_CAMERA_ANNOTATE_V2_T annotate =
|
||||
{{MMAL_PARAMETER_ANNOTATE, sizeof(MMAL_PARAMETER_CAMERA_ANNOTATE_V2_T)}};
|
||||
MMAL_PARAMETER_CAMERA_ANNOTATE_V3_T annotate =
|
||||
{{MMAL_PARAMETER_ANNOTATE, sizeof(MMAL_PARAMETER_CAMERA_ANNOTATE_V3_T)}};
|
||||
|
||||
if (settings)
|
||||
{
|
||||
time_t t = time(NULL);
|
||||
struct tm tm = *localtime(&t);
|
||||
char tmp[MMAL_CAMERA_ANNOTATE_MAX_TEXT_LEN_V2];
|
||||
char tmp[MMAL_CAMERA_ANNOTATE_MAX_TEXT_LEN_V3];
|
||||
|
||||
annotate.enable = 1;
|
||||
annotate.enable = 1;
|
||||
|
||||
if (settings & (ANNOTATE_APP_TEXT | ANNOTATE_USER_TEXT))
|
||||
{
|
||||
strncpy(annotate.text, string, MMAL_CAMERA_ANNOTATE_MAX_TEXT_LEN_V2);
|
||||
annotate.text[MMAL_CAMERA_ANNOTATE_MAX_TEXT_LEN_V2-1] = '\0';
|
||||
strncpy(annotate.text, string, MMAL_CAMERA_ANNOTATE_MAX_TEXT_LEN_V3);
|
||||
annotate.text[MMAL_CAMERA_ANNOTATE_MAX_TEXT_LEN_V3-1] = '\0';
|
||||
}
|
||||
|
||||
if (settings & ANNOTATE_TIME_TEXT)
|
||||
{
|
||||
strftime(tmp, 32, "%X ", &tm );
|
||||
strncat(annotate.text, tmp, MMAL_CAMERA_ANNOTATE_MAX_TEXT_LEN_V2 - strlen(annotate.text) - 1);
|
||||
strncat(annotate.text, tmp, MMAL_CAMERA_ANNOTATE_MAX_TEXT_LEN_V3 - strlen(annotate.text) - 1);
|
||||
}
|
||||
|
||||
if (settings & ANNOTATE_DATE_TEXT)
|
||||
{
|
||||
strftime(tmp, 32, "%x", &tm );
|
||||
strncat(annotate.text, tmp, MMAL_CAMERA_ANNOTATE_MAX_TEXT_LEN_V2 - strlen(annotate.text) - 1);
|
||||
strncat(annotate.text, tmp, MMAL_CAMERA_ANNOTATE_MAX_TEXT_LEN_V3 - strlen(annotate.text) - 1);
|
||||
}
|
||||
|
||||
if (settings & ANNOTATE_SHUTTER_SETTINGS)
|
||||
annotate.show_shutter = 1;
|
||||
annotate.show_shutter = MMAL_TRUE;
|
||||
|
||||
if (settings & ANNOTATE_GAIN_SETTINGS)
|
||||
annotate.show_analog_gain = 1;
|
||||
annotate.show_analog_gain = MMAL_TRUE;
|
||||
|
||||
if (settings & ANNOTATE_LENS_SETTINGS)
|
||||
annotate.show_lens = 1;
|
||||
annotate.show_lens = MMAL_TRUE;
|
||||
|
||||
if (settings & ANNOTATE_CAF_SETTINGS)
|
||||
annotate.show_caf = 1;
|
||||
annotate.show_caf = MMAL_TRUE;
|
||||
|
||||
if (settings & ANNOTATE_MOTION_SETTINGS)
|
||||
annotate.show_motion = 1;
|
||||
annotate.show_motion = MMAL_TRUE;
|
||||
|
||||
if (settings & ANNOTATE_FRAME_NUMBER)
|
||||
annotate.show_frame_num = 1;
|
||||
annotate.show_frame_num = MMAL_TRUE;
|
||||
|
||||
if (settings & ANNOTATE_BLACK_BACKGROUND)
|
||||
annotate.black_text_background = 1;
|
||||
annotate.enable_text_background = MMAL_TRUE;
|
||||
|
||||
annotate.text_size = text_size;
|
||||
|
||||
if (text_colour != -1)
|
||||
{
|
||||
annotate.custom_text_colour = MMAL_TRUE;
|
||||
annotate.custom_text_Y = text_colour&0xff;
|
||||
annotate.custom_text_U = (text_colour>>8)&0xff;
|
||||
annotate.custom_text_V = (text_colour>>16)&0xff;
|
||||
}
|
||||
else
|
||||
annotate.custom_text_colour = MMAL_FALSE;
|
||||
|
||||
if (bg_colour != -1)
|
||||
{
|
||||
annotate.custom_background_colour = MMAL_TRUE;
|
||||
annotate.custom_background_Y = bg_colour&0xff;
|
||||
annotate.custom_background_U = (bg_colour>>8)&0xff;
|
||||
annotate.custom_background_V = (bg_colour>>16)&0xff;
|
||||
}
|
||||
else
|
||||
annotate.custom_background_colour = MMAL_FALSE;
|
||||
}
|
||||
else
|
||||
annotate.enable = 0;
|
||||
|
@ -1296,6 +1401,18 @@ int raspicamcontrol_set_annotate(MMAL_COMPONENT_T *camera, const int settings, c
|
|||
return mmal_status_to_int(mmal_port_parameter_set(camera->control, &annotate.hdr));
|
||||
}
|
||||
|
||||
int raspicamcontrol_set_stereo_mode(MMAL_PORT_T *port, MMAL_PARAMETER_STEREOSCOPIC_MODE_T *stereo_mode)
|
||||
{
|
||||
MMAL_PARAMETER_STEREOSCOPIC_MODE_T stereo = { {MMAL_PARAMETER_STEREOSCOPIC_MODE, sizeof(stereo)},
|
||||
MMAL_STEREOSCOPIC_MODE_NONE, MMAL_FALSE, MMAL_FALSE };
|
||||
if (stereo_mode->mode != MMAL_STEREOSCOPIC_MODE_NONE)
|
||||
{
|
||||
stereo.mode = stereo_mode->mode;
|
||||
stereo.decimate = stereo_mode->decimate;
|
||||
stereo.swap_eyes = stereo_mode->swap_eyes;
|
||||
}
|
||||
return mmal_status_to_int(mmal_port_parameter_set(port, &stereo.hdr));
|
||||
}
|
||||
|
||||
/**
|
||||
* Asked GPU how much memory it has allocated
|
||||
|
|
|
@ -155,7 +155,10 @@ typedef struct
|
|||
MMAL_BOOL_T stats_pass; /// Stills capture statistics pass on/off
|
||||
int enable_annotate; /// Flag to enable the annotate, 0 = disabled, otherwise a bitmask of what needs to be displayed
|
||||
char annotate_string[MMAL_CAMERA_ANNOTATE_MAX_TEXT_LEN_V2]; /// String to use for annotate - overrides certain bitmask settings
|
||||
|
||||
int annotate_text_size; // Text size for annotation
|
||||
int annotate_text_colour; // Text colour for annotation
|
||||
int annotate_bg_colour; // Background colour for annotation
|
||||
MMAL_PARAMETER_STEREOSCOPIC_MODE_T stereo_mode;
|
||||
} RASPICAM_CAMERA_PARAMETERS;
|
||||
|
||||
|
||||
|
@ -194,7 +197,9 @@ int raspicamcontrol_set_ROI(MMAL_COMPONENT_T *camera, PARAM_FLOAT_RECT_T rect);
|
|||
int raspicamcontrol_set_shutter_speed(MMAL_COMPONENT_T *camera, int speed_ms);
|
||||
int raspicamcontrol_set_DRC(MMAL_COMPONENT_T *camera, MMAL_PARAMETER_DRC_STRENGTH_T strength);
|
||||
int raspicamcontrol_set_stats_pass(MMAL_COMPONENT_T *camera, int stats_pass);
|
||||
int raspicamcontrol_set_annotate(MMAL_COMPONENT_T *camera, const int bitmask, const char *string);
|
||||
int raspicamcontrol_set_annotate(MMAL_COMPONENT_T *camera, const int bitmask, const char *string,
|
||||
const int text_size, const int text_colour, const int bg_colour);
|
||||
int raspicamcontrol_set_stereo_mode(MMAL_PORT_T *port, MMAL_PARAMETER_STEREOSCOPIC_MODE_T *stereo_mode);
|
||||
|
||||
//Individual getting functions
|
||||
int raspicamcontrol_get_saturation(MMAL_COMPONENT_T *camera);
|
||||
|
|
|
@ -857,13 +857,20 @@ static void update_annotation_data(RASPIVID_STATE *state)
|
|||
config->intraperiod,
|
||||
raspicli_unmap_xref(config->profile, profile_map, profile_map_size));
|
||||
|
||||
raspicamcontrol_set_annotate(state->camera_component, config->camera_parameters.enable_annotate, text);
|
||||
raspicamcontrol_set_annotate(state->camera_component, config->camera_parameters.enable_annotate, text,
|
||||
config->camera_parameters.annotate_text_size,
|
||||
config->camera_parameters.annotate_text_colour,
|
||||
config->camera_parameters.annotate_bg_colour);
|
||||
|
||||
free(text);
|
||||
}
|
||||
else
|
||||
{
|
||||
raspicamcontrol_set_annotate(state->camera_component, config->camera_parameters.enable_annotate, config->camera_parameters.annotate_string);
|
||||
raspicamcontrol_set_annotate(state->camera_component, config->camera_parameters.enable_annotate,
|
||||
config->camera_parameters.annotate_string,
|
||||
config->camera_parameters.annotate_text_size,
|
||||
config->camera_parameters.annotate_text_colour,
|
||||
config->camera_parameters.annotate_bg_colour);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue