mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 11:45:25 +00:00
examples: facedetect: add silent option
By default the example floods the screen with the detected face values. Add an option to avoid this for frail terminals.
This commit is contained in:
parent
9e99102b48
commit
64513a60e9
1 changed files with 17 additions and 11 deletions
|
@ -30,6 +30,7 @@ GstElement *playbin, *pipeline;
|
||||||
GstElement *v4l2src, *videoscale, *videoconvert_in, *facedetect,
|
GstElement *v4l2src, *videoscale, *videoconvert_in, *facedetect,
|
||||||
*videoconvert_out, *autovideosink;
|
*videoconvert_out, *autovideosink;
|
||||||
static gboolean ctrlvol = FALSE;
|
static gboolean ctrlvol = FALSE;
|
||||||
|
static gboolean silent = FALSE;
|
||||||
|
|
||||||
static GstBusSyncReply
|
static GstBusSyncReply
|
||||||
bus_sync_handler (GstBus * bus, GstMessage * message, GstPipeline * pipeline)
|
bus_sync_handler (GstBus * bus, GstMessage * message, GstPipeline * pipeline)
|
||||||
|
@ -52,23 +53,26 @@ bus_sync_handler (GstBus * bus, GstMessage * message, GstPipeline * pipeline)
|
||||||
/* if facedetect is into buffer */
|
/* if facedetect is into buffer */
|
||||||
if (structure &&
|
if (structure &&
|
||||||
strcmp (gst_structure_get_name (structure), "facedetect") == 0) {
|
strcmp (gst_structure_get_name (structure), "facedetect") == 0) {
|
||||||
/* print message type and structure name */
|
if (!silent) {
|
||||||
g_print ("Type message, name message: %s{{%s}}\n",
|
/* print message type and structure name */
|
||||||
gst_message_type_get_name (message->type),
|
g_print ("Type message, name message: %s{{%s}}\n",
|
||||||
gst_structure_get_name (structure));
|
gst_message_type_get_name (message->type),
|
||||||
/* print msg structure names&type */
|
gst_structure_get_name (structure));
|
||||||
for (i = 0; i < gst_structure_n_fields (structure); i++) {
|
|
||||||
const gchar *name = gst_structure_nth_field_name (structure, i);
|
/* print msg structure names and type */
|
||||||
GType type = gst_structure_get_field_type (structure, name);
|
for (i = 0; i < gst_structure_n_fields (structure); i++) {
|
||||||
g_print ("-Name field, type: %s[%s]\n", name, g_type_name (type));
|
const gchar *name = gst_structure_nth_field_name (structure, i);
|
||||||
|
GType type = gst_structure_get_field_type (structure, name);
|
||||||
|
g_print ("-Name field, type: %s[%s]\n", name, g_type_name (type));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
g_print ("\n");
|
|
||||||
|
|
||||||
/* get structure of faces */
|
/* get structure of faces */
|
||||||
value = gst_structure_get_value (structure, "faces");
|
value = gst_structure_get_value (structure, "faces");
|
||||||
/* obtain the contents into the structure */
|
/* obtain the contents into the structure */
|
||||||
contents = g_strdup_value_contents (value);
|
contents = g_strdup_value_contents (value);
|
||||||
g_print ("Detected objects: %s\n", *(&contents));
|
if (!silent)
|
||||||
|
g_print ("Detected objects: %s\n\n", *(&contents));
|
||||||
|
|
||||||
/* list size */
|
/* list size */
|
||||||
size = gst_value_list_get_size (value);
|
size = gst_value_list_get_size (value);
|
||||||
|
@ -138,6 +142,8 @@ main (gint argc, gchar ** argv)
|
||||||
GOptionEntry options[] = {
|
GOptionEntry options[] = {
|
||||||
{"control-volume", 'c', 0, G_OPTION_ARG_NONE, &ctrlvol,
|
{"control-volume", 'c', 0, G_OPTION_ARG_NONE, &ctrlvol,
|
||||||
"Control the volume by hiding the nose or mouth", NULL},
|
"Control the volume by hiding the nose or mouth", NULL},
|
||||||
|
{"silent", 's', 0, G_OPTION_ARG_NONE, &silent,
|
||||||
|
"Don't output the messages and detected faces structure", NULL},
|
||||||
{NULL}
|
{NULL}
|
||||||
};
|
};
|
||||||
GOptionContext *ctx;
|
GOptionContext *ctx;
|
||||||
|
|
Loading…
Reference in a new issue