summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuis de Bethencourt <luis@debethencourt.com>2015-08-17 23:44:42 +0100
committerLuis de Bethencourt <luis@debethencourt.com>2015-08-17 23:44:47 +0100
commit64513a60e9797a1c307d08d12559e6888bae7314 (patch)
tree0a98ed4932ccd96abaaad22c4c723b55e53674ab
parent9e99102b48201abba60e6fee0c00518bcb2a3dba (diff)
downloadgstreamer-plugins-bad-64513a60e9797a1c307d08d12559e6888bae7314.tar.gz
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.
-rw-r--r--tests/examples/opencv/gstfacedetect_test.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/tests/examples/opencv/gstfacedetect_test.c b/tests/examples/opencv/gstfacedetect_test.c
index 138faf213..8ccbda0bf 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;