From 64513a60e9797a1c307d08d12559e6888bae7314 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Mon, 17 Aug 2015 23:44:42 +0100 Subject: [PATCH] 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. --- tests/examples/opencv/gstfacedetect_test.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/tests/examples/opencv/gstfacedetect_test.c b/tests/examples/opencv/gstfacedetect_test.c index 138faf2..8ccbda0 100644 --- a/tests/examples/opencv/gstfacedetect_test.c +++ b/tests/examples/opencv/gstfacedetect_test.c @@ -30,6 +30,7 @@ GstElement *playbin, *pipeline; GstElement *v4l2src, *videoscale, *videoconvert_in, *facedetect, *videoconvert_out, *autovideosink; static gboolean ctrlvol = FALSE; +static gboolean silent = FALSE; static GstBusSyncReply 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 (structure && strcmp (gst_structure_get_name (structure), "facedetect") == 0) { - /* print message type and structure name */ - g_print ("Type message, name message: %s{{%s}}\n", - gst_message_type_get_name (message->type), - gst_structure_get_name (structure)); - /* print msg structure names&type */ - for (i = 0; i < gst_structure_n_fields (structure); i++) { - 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)); + if (!silent) { + /* print message type and structure name */ + g_print ("Type message, name message: %s{{%s}}\n", + gst_message_type_get_name (message->type), + gst_structure_get_name (structure)); + + /* print msg structure names and type */ + for (i = 0; i < gst_structure_n_fields (structure); i++) { + 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 */ value = gst_structure_get_value (structure, "faces"); /* obtain the contents into the structure */ 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 */ size = gst_value_list_get_size (value); @@ -138,6 +142,8 @@ main (gint argc, gchar ** argv) GOptionEntry options[] = { {"control-volume", 'c', 0, G_OPTION_ARG_NONE, &ctrlvol, "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} }; GOptionContext *ctx; -- 2.7.4