summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@suren.me>2017-08-24 16:00:47 +0200
committerSuren A. Chilingaryan <csa@suren.me>2017-08-24 16:00:47 +0200
commitfda61833ea8a8e6f1b10b66e0bb27614ef0eb750 (patch)
tree0ac1aa37bb60e885cb275257f4805ba85fde0172
parent71e1f2db8b87763c06211d85119a921b11095a9d (diff)
parent0cc0ea331abc3f906606389b194166180d5ba548 (diff)
downloaduca-ufo-master.tar.gz
uca-ufo-master.tar.bz2
uca-ufo-master.tar.xz
uca-ufo-master.zip
Merge branch 'master' of https://github.com/ufo-kit/uca-ufoHEADmaster
-rw-r--r--CMakeLists.txt3
-rw-r--r--tests/test.c129
-rw-r--r--uca-ufo-camera.c11
3 files changed, 136 insertions, 7 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 42f2131..ba10a9b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -63,3 +63,6 @@ target_link_libraries(ucaufo
install(TARGETS ucaufo
LIBRARY DESTINATION ${LIBUCA_PLUGINDIR})
+
+add_executable(test tests/test.c)
+target_link_libraries(test ucaufo)
diff --git a/tests/test.c b/tests/test.c
new file mode 100644
index 0000000..c8e89af
--- /dev/null
+++ b/tests/test.c
@@ -0,0 +1,129 @@
+#include <stdlib.h>
+#include <string.h>
+#include <uca/uca-camera.h>
+#include <uca/uca-plugin-manager.h>
+
+UcaPluginManager *manager;
+UcaCamera *camera;
+
+static void
+dispose (void)
+{
+ g_object_unref (camera);
+ g_object_unref (manager);
+}
+
+static void
+pass_or_die (GError *error)
+{
+ if (error == NULL)
+ return;
+
+ g_print ("Error: %s\n", error->message);
+ dispose ();
+ exit (1);
+}
+
+static void
+print_header (const gchar *header)
+{
+ guint remaining;
+
+ remaining = 79 - strlen (header);
+ g_print ("%s ", header);
+
+ for (guint i = 0; i < remaining; i++)
+ g_print ("-");
+
+ g_print ("\n");
+}
+
+static void
+check_roi_size (UcaCamera *camera, guint x, guint y, guint width, guint height, GError **error)
+{
+ guint roi_height;
+ guint16 *frame;
+
+ g_object_set (camera, "roi-height", height, NULL);
+ g_object_get (camera, "roi-height", &roi_height, NULL);
+
+ if (height != roi_height) {
+ g_print (" Error: ROI is %u x %u pixels\n", width, roi_height);
+ return;
+ }
+
+ frame = g_malloc0 (2 * width * height);
+
+ uca_camera_start_recording (camera, error);
+
+ if (*error != NULL)
+ goto exit_check_roi_size;
+
+ for (guint i = 0; i < 30; i++) {
+ uca_camera_grab (camera, frame, error);
+
+ if (*error != NULL) {
+ uca_camera_stop_recording (camera, NULL);
+ goto exit_check_roi_size;
+ }
+ }
+
+ uca_camera_stop_recording (camera, error);
+
+ if (*error != NULL)
+ goto exit_check_roi_size;
+
+exit_check_roi_size:
+ g_free (frame);
+}
+
+static void
+test_roi_change (UcaCamera *camera)
+{
+ guint sensor_width;
+ guint sensor_height;
+ guint roi_width;
+ guint roi_height;
+
+ print_header ("Check different region-of-interest sizes");
+
+ g_object_get (camera,
+ "sensor-width", &sensor_width,
+ "sensor-height", &sensor_height,
+ "roi-width", &roi_width,
+ "roi-height", &roi_height,
+ NULL);
+
+ g_print (" Sensor size: %u x %u pixels\n", sensor_width, sensor_height);
+
+ for (roi_height = sensor_height; roi_height > 8; roi_height /= 2) {
+ GError *error = NULL;
+
+ g_print (" Test ROI %u x %u pixels: ", sensor_width, roi_height);
+
+ check_roi_size (camera, 0, 0, sensor_width, sensor_height, &error);
+
+ if (error == NULL) {
+ g_print ("PASS\n");
+ }
+ else {
+ g_print ("FAIL (%s)\n", error->message);
+ g_error_free (error);
+ }
+ }
+}
+
+int
+main (int argc, char **argv)
+{
+ GError *error = NULL;
+
+ manager = uca_plugin_manager_new ();
+ camera = uca_plugin_manager_get_camera (manager, "ufo", &error, NULL);
+
+ pass_or_die (error);
+
+ test_roi_change (camera);
+
+ dispose ();
+}
diff --git a/uca-ufo-camera.c b/uca-ufo-camera.c
index 7470418..94d1d3c 100644
--- a/uca-ufo-camera.c
+++ b/uca-ufo-camera.c
@@ -206,9 +206,6 @@ update_properties (UcaUfoCameraPrivate *priv)
case PCILIB_REGISTER_RW1I:
flags = G_PARAM_READWRITE;
break;
- case PCILIB_REGISTER_INCONSISTENT:
- g_warning ("%s is an inconsistent register, don't know how to handle that", reg->name);
- break;
}
value = read_register_value (priv->handle, reg->name);
@@ -369,9 +366,9 @@ uca_ufo_camera_stop_recording (UcaCamera *camera, GError **error)
set_control_bit (priv, 11, FALSE); /* disable streaming */
if (priv->async_thread) {
- err = pcilib_stop(priv->handle, PCILIB_EVENT_FLAG_STOP_ONLY);
- PCILIB_SET_ERROR(err, UCA_UFO_CAMERA_ERROR_STOP_RECORDING);
- g_thread_join(priv->async_thread);
+ err = pcilib_stop (priv->handle, PCILIB_EVENT_FLAG_STOP_ONLY);
+ PCILIB_SET_ERROR (err, UCA_UFO_CAMERA_ERROR_STOP_RECORDING);
+ g_thread_join (priv->async_thread);
priv->async_thread = NULL;
}
@@ -380,7 +377,7 @@ uca_ufo_camera_stop_recording (UcaCamera *camera, GError **error)
;
err = pcilib_stop (priv->handle, PCILIB_EVENT_FLAGS_DEFAULT);
- PCILIB_SET_ERROR(err, UCA_UFO_CAMERA_ERROR_STOP_RECORDING);
+ PCILIB_SET_ERROR (err, UCA_UFO_CAMERA_ERROR_STOP_RECORDING);
}
static void