summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2017-10-11 09:53:52 +0200
committerMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2017-10-11 09:53:52 +0200
commite2c150f53b6d6dc35e520212f1e710a39f75eca1 (patch)
treed109dfba5d98fe4d9051f80aa8c72aae62b7c13b
parent34d31e7974665f6f78bfd4af476f7d053c53f750 (diff)
downloaduca-e2c150f53b6d6dc35e520212f1e710a39f75eca1.tar.gz
uca-e2c150f53b6d6dc35e520212f1e710a39f75eca1.tar.bz2
uca-e2c150f53b6d6dc35e520212f1e710a39f75eca1.tar.xz
uca-e2c150f53b6d6dc35e520212f1e710a39f75eca1.zip
grab: show progress during acquisition
-rw-r--r--bin/tools/CMakeLists.txt5
-rw-r--r--bin/tools/grab.c28
-rw-r--r--bin/tools/meson.build5
3 files changed, 21 insertions, 17 deletions
diff --git a/bin/tools/CMakeLists.txt b/bin/tools/CMakeLists.txt
index 6eb99eb..3f0044b 100644
--- a/bin/tools/CMakeLists.txt
+++ b/bin/tools/CMakeLists.txt
@@ -19,13 +19,16 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
include_directories(${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR})
-set(BINARIES "benchmark" "gen-doc" "grab" "info")
+set(BINARIES "benchmark" "gen-doc" "info")
foreach (BINARY ${BINARIES})
add_executable(uca-${BINARY} ${BINARY}.c common.c)
target_link_libraries(uca-${BINARY} ${libs})
endforeach ()
+add_executable(uca-grab grab.c common.c)
+target_link_libraries(uca-grab ${libs} m)
+
install(TARGETS uca-benchmark uca-grab uca-gen-doc uca-info
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT executables)
diff --git a/bin/tools/grab.c b/bin/tools/grab.c
index 009dc16..8e2e834 100644
--- a/bin/tools/grab.c
+++ b/bin/tools/grab.c
@@ -20,6 +20,7 @@
#include <glib-object.h>
#include <stdio.h>
#include <stdlib.h>
+#include <math.h>
#include "uca-plugin-manager.h"
#include "uca-camera.h"
#include "uca-ring-buffer.h"
@@ -136,10 +137,12 @@ record_frames (UcaCamera *camera, Options *opts)
gsize size;
gint n_frames;
guint n_allocated;
+ guint n_digits;
+ gchar *fmt_string;
GTimer *timer;
+ gdouble elapsed;
UcaRingBuffer *buffer;
GError *error = NULL;
- gdouble last_printed;
g_object_get (G_OBJECT (camera),
"roi-width", &roi_width,
@@ -153,7 +156,8 @@ record_frames (UcaCamera *camera, Options *opts)
buffer = uca_ring_buffer_new (size, n_allocated);
timer = g_timer_new();
- g_print ("Start recording: %ix%i at %i bits/pixel\n", roi_width, roi_height, bits);
+ g_print ("Acquiring %i images at %ix%i with %i bits per pixel\n",
+ opts->n_frames, roi_width, roi_height, bits);
uca_camera_start_recording(camera, &error);
@@ -161,33 +165,27 @@ record_frames (UcaCamera *camera, Options *opts)
return error;
n_frames = 0;
+ n_digits = floor (log10 (abs (opts->n_frames))) + 1;
+ fmt_string = g_strdup_printf ("\33[2K\r%%%ii/%%i images acquired ...", n_digits);
g_timer_start(timer);
- last_printed = 0.0;
while (1) {
- gdouble elapsed;
-
uca_camera_grab (camera, uca_ring_buffer_get_write_pointer (buffer), &error);
uca_ring_buffer_write_advance (buffer);
if (error != NULL)
return error;
- n_frames++;
- elapsed = g_timer_elapsed (timer, NULL);
+ g_print (fmt_string, ++n_frames, opts->n_frames);
if (n_frames == opts->n_frames)
break;
-
- if (elapsed - last_printed >= 1.0) {
- g_print ("Recorded %i frames at %.2f frames/s\n",
- n_frames, n_frames / elapsed);
- last_printed = elapsed;
- }
}
- g_print ("Stop recording: %3.2f frames/s\n",
- n_frames / g_timer_elapsed (timer, NULL));
+ elapsed = g_timer_elapsed (timer, NULL);
+ g_print ("\nAcquired %3.2f images/s = %3.2f ms/image = %.4f MB/s\n",
+ n_frames / elapsed, elapsed / n_frames * 1000.,
+ n_frames * size / 1024. / 1024. / elapsed);
uca_camera_stop_recording (camera, &error);
diff --git a/bin/tools/meson.build b/bin/tools/meson.build
index 3ae20d6..6901939 100644
--- a/bin/tools/meson.build
+++ b/bin/tools/meson.build
@@ -1,3 +1,6 @@
+cc = meson.get_compiler('c')
+libm = cc.find_library('m')
+
executable('uca-info',
sources: ['info.c'],
include_directories: include_dir,
@@ -9,7 +12,7 @@ executable('uca-info',
executable('uca-grab',
sources: ['grab.c', 'common.c'],
include_directories: include_dir,
- dependencies: deps,
+ dependencies: deps + [libm],
link_with: lib,
install: true
)