summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--test/CMakeLists.txt10
-rw-r--r--test/grab-async.c44
2 files changed, 42 insertions, 12 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index ee5b407..e4e60dc 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -10,10 +10,7 @@ pkg_check_modules(GTHREAD2 gthread-2.0)
pkg_check_modules(GLIB2 glib-2.0>=2.24 REQUIRED)
pkg_check_modules(GOBJECT2 gobject-2.0>=2.24 REQUIRED)
-#include_directories(${CMAKE_SOURCE_DIR}/src)
-
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/control.glade ${CMAKE_CURRENT_BINARY_DIR})
-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/run.py ${CMAKE_CURRENT_BINARY_DIR})
# --- Build targets -----------------------------------------------------------
include_directories(
@@ -37,16 +34,13 @@ if (HAVE_PYLON_CAMERA)
endif()
add_executable(grab grab.c)
-#add_executable(grab-async grab-async.c)
+add_executable(grab-async grab-async.c)
add_executable(benchmark benchmark.c)
target_link_libraries(benchmark uca ${GLIB2_LIBRARIES} ${GOBJECT2_LIBRARIES})
target_link_libraries(grab uca ${GLIB2_LIBRARIES} ${GOBJECT2_LIBRARIES})
-#target_link_libraries(grab-async uca ${GLIB2_LIBRARIES} ${GOBJECT2_LIBRARIES})
+target_link_libraries(grab-async uca ${GLIB2_LIBRARIES} ${GOBJECT2_LIBRARIES})
-#add_executable(grab_pylon grab_pylon.c)
-#target_link_libraries(grab_pylon uca ${GLIB2_LIBRARIES} ${GOBJECT2_LIBRARIES})
-#
if (GTK2_FOUND)
include_directories(${GTK2_INCLUDE_DIRS})
diff --git a/test/grab-async.c b/test/grab-async.c
index e1ec114..6132829 100644
--- a/test/grab-async.c
+++ b/test/grab-async.c
@@ -19,6 +19,7 @@
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
+#include "uca-plugin-manager.h"
#include "uca-camera.h"
static UcaCamera *camera = NULL;
@@ -29,7 +30,8 @@ typedef struct {
guint counter;
} CallbackData;
-static void sigint_handler(int signal)
+static void
+sigint_handler(int signal)
{
printf("Closing down libuca\n");
uca_camera_stop_recording(camera, NULL);
@@ -37,7 +39,8 @@ static void sigint_handler(int signal)
exit(signal);
}
-static void grab_callback(gpointer data, gpointer user_data)
+static void
+grab_callback(gpointer data, gpointer user_data)
{
CallbackData *cbd = (CallbackData *) user_data;
gchar *filename = g_strdup_printf("frame-%04i.raw", cbd->counter++);
@@ -49,16 +52,49 @@ static void grab_callback(gpointer data, gpointer user_data)
g_free(filename);
}
-int main(int argc, char *argv[])
+static void
+print_usage (void)
+{
+ GList *types;
+ UcaPluginManager *manager;
+
+ manager = uca_plugin_manager_new ();
+ g_print ("Usage: benchmark [ ");
+ types = uca_plugin_manager_get_available_cameras (manager);
+
+ if (types == NULL) {
+ g_print ("] -- no camera plugin found\n");
+ return;
+ }
+
+ for (GList *it = g_list_first (types); it != NULL; it = g_list_next (it)) {
+ gchar *name = (gchar *) it->data;
+ if (g_list_next (it) == NULL)
+ g_print ("%s ]\n", name);
+ else
+ g_print ("%s, ", name);
+ }
+}
+
+int
+main(int argc, char *argv[])
{
CallbackData cbd;
guint sensor_width, sensor_height;
gchar *name;
+ UcaPluginManager *manager;
GError *error = NULL;
(void) signal(SIGINT, sigint_handler);
g_type_init();
- camera = uca_camera_new("pco", &error);
+
+ if (argc < 2) {
+ print_usage();
+ return 1;
+ }
+
+ manager = uca_plugin_manager_new ();
+ camera = uca_plugin_manager_new_camera (manager, argv[1], &error);
if (camera == NULL) {
g_print("Error during initialization: %s\n", error->message);