examples: camerabin: add timing printing for preview image
Measure and print the time taken to generate preview image. And fix a typo
This commit is contained in:
parent
25062fc384
commit
97789fa5bc
@ -183,6 +183,8 @@ static gchar *preview_caps_name = NULL;
|
|||||||
static Display *display = NULL;
|
static Display *display = NULL;
|
||||||
static Window window = 0;
|
static Window window = 0;
|
||||||
|
|
||||||
|
GTimer *timer = NULL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Prototypes
|
* Prototypes
|
||||||
*/
|
*/
|
||||||
@ -266,14 +268,14 @@ sync_bus_callback (GstBus * bus, GstMessage * message, gpointer data)
|
|||||||
size = GST_BUFFER_SIZE (buf);
|
size = GST_BUFFER_SIZE (buf);
|
||||||
preview_filename = g_strdup_printf ("test_vga.rgb");
|
preview_filename = g_strdup_printf ("test_vga.rgb");
|
||||||
caps_string = gst_caps_to_string (GST_BUFFER_CAPS (buf));
|
caps_string = gst_caps_to_string (GST_BUFFER_CAPS (buf));
|
||||||
g_print ("writing buffer to %s, buffer caps: %s\n",
|
g_print ("writing buffer to %s, elapsed: %.2fs, buffer caps: %s\n",
|
||||||
preview_filename, caps_string);
|
preview_filename, g_timer_elapsed (timer, NULL), caps_string);
|
||||||
g_free (caps_string);
|
g_free (caps_string);
|
||||||
f = g_fopen (preview_filename, "w");
|
f = g_fopen (preview_filename, "w");
|
||||||
if (f) {
|
if (f) {
|
||||||
written = fwrite (data_buf, size, 1, f);
|
written = fwrite (data_buf, size, 1, f);
|
||||||
if (!written) {
|
if (!written) {
|
||||||
g_print ("errro writing file\n");
|
g_print ("error writing file\n");
|
||||||
}
|
}
|
||||||
fclose (f);
|
fclose (f);
|
||||||
} else {
|
} else {
|
||||||
@ -668,6 +670,7 @@ run_pipeline (gpointer user_data)
|
|||||||
g_object_set (camera_bin, "zoom", zoom / 100.0f, NULL);
|
g_object_set (camera_bin, "zoom", zoom / 100.0f, NULL);
|
||||||
|
|
||||||
capture_count++;
|
capture_count++;
|
||||||
|
g_timer_start (timer);
|
||||||
g_signal_emit_by_name (camera_bin, "capture-start", 0);
|
g_signal_emit_by_name (camera_bin, "capture-start", 0);
|
||||||
|
|
||||||
|
|
||||||
@ -808,6 +811,8 @@ main (int argc, char *argv[])
|
|||||||
if (filename->len == 0)
|
if (filename->len == 0)
|
||||||
filename = g_string_append (filename, ".");
|
filename = g_string_append (filename, ".");
|
||||||
|
|
||||||
|
timer = g_timer_new ();
|
||||||
|
|
||||||
/* init */
|
/* init */
|
||||||
if (setup_pipeline ()) {
|
if (setup_pipeline ()) {
|
||||||
loop = g_main_loop_new (NULL, FALSE);
|
loop = g_main_loop_new (NULL, FALSE);
|
||||||
@ -830,6 +835,7 @@ main (int argc, char *argv[])
|
|||||||
g_free (src_csp);
|
g_free (src_csp);
|
||||||
g_free (src_format);
|
g_free (src_format);
|
||||||
g_free (target_times);
|
g_free (target_times);
|
||||||
|
g_timer_destroy (timer);
|
||||||
|
|
||||||
if (window)
|
if (window)
|
||||||
XDestroyWindow (display, window);
|
XDestroyWindow (display, window);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user