[aravis] camera: more trigger related functions.



commit f34410937395be0f5885cc242bd6d7c1ca9c1b74
Author: Emmanuel Pacaud <emmanuel gnome org>
Date:   Tue Apr 13 13:28:35 2010 +0200

    camera: more trigger related functions.

 src/arvcamera.c     |   51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 src/arvcamera.h     |    5 +++++
 src/arvcameratest.c |   26 +++++++++++++++++++++++---
 3 files changed, 79 insertions(+), 3 deletions(-)
---
diff --git a/src/arvcamera.c b/src/arvcamera.c
index fe2b4b6..087e9c5 100644
--- a/src/arvcamera.c
+++ b/src/arvcamera.c
@@ -26,6 +26,7 @@
 #include <arvgccommand.h>
 #include <arvgcinteger.h>
 #include <arvgcfloat.h>
+#include <arvgcenumeration.h>
 #include <arvgcstring.h>
 #include <arvgc.h>
 #include <arvdevice.h>
@@ -70,6 +71,16 @@ arv_camera_get_device_id (ArvCamera *camera)
 }
 
 void
+arv_camera_set_acquisition_mode (ArvCamera *camera, const char *value)
+{
+	g_return_if_fail (ARV_IS_CAMERA (camera));
+
+	arv_gc_enumeration_set_string_value (ARV_GC_ENUMERATION (arv_gc_get_node (camera->priv->genicam,
+										  "AcquisitionMode")),
+					     value);
+}
+
+void
 arv_camera_start_acquisition (ArvCamera *camera)
 {
 	g_return_if_fail (ARV_IS_CAMERA (camera));
@@ -85,6 +96,46 @@ arv_camera_stop_acquisition (ArvCamera *camera)
 	arv_gc_command_execute (ARV_GC_COMMAND (arv_gc_get_node (camera->priv->genicam, "AcquisitionStop")));
 }
 
+void
+arv_camera_set_trigger_selector	(ArvCamera *camera, const char *value)
+{
+	g_return_if_fail (ARV_IS_CAMERA (camera));
+
+	arv_gc_enumeration_set_string_value (ARV_GC_ENUMERATION (arv_gc_get_node (camera->priv->genicam,
+										  "TriggerSelector")),
+					     value);
+}
+
+void
+arv_camera_set_trigger_mode (ArvCamera *camera, const char *value)
+{
+	g_return_if_fail (ARV_IS_CAMERA (camera));
+
+	arv_gc_enumeration_set_string_value (ARV_GC_ENUMERATION (arv_gc_get_node (camera->priv->genicam,
+										  "TriggerMode")),
+					     value);
+}
+
+void
+arv_camera_set_trigger_source (ArvCamera *camera, const char *value)
+{
+	g_return_if_fail (ARV_IS_CAMERA (camera));
+
+	arv_gc_enumeration_set_string_value (ARV_GC_ENUMERATION (arv_gc_get_node (camera->priv->genicam,
+										  "TriggerSource")),
+					     value);
+}
+
+void
+arv_camera_set_trigger_activation (ArvCamera *camera, const char *value)
+{
+	g_return_if_fail (ARV_IS_CAMERA (camera));
+
+	arv_gc_enumeration_set_string_value (ARV_GC_ENUMERATION (arv_gc_get_node (camera->priv->genicam,
+										  "TriggerActivation")),
+					     value);
+}
+
 guint
 arv_camera_get_payload (ArvCamera *camera)
 {
diff --git a/src/arvcamera.h b/src/arvcamera.h
index 4c8650e..487a7fa 100644
--- a/src/arvcamera.h
+++ b/src/arvcamera.h
@@ -55,8 +55,13 @@ ArvStream *	arv_camera_new_stream		(ArvCamera *camera, ArvStreamCallback callbac
 const char *	arv_camera_get_vendor_name	(ArvCamera *camera);
 const char *	arv_camera_get_model_name	(ArvCamera *camera);
 const char *	arv_camera_get_device_id	(ArvCamera *camera);
+void		arv_camera_set_acquisition_mode (ArvCamera *camera, const char *value);
 void		arv_camera_start_acquisition	(ArvCamera *camera);
 void		arv_camera_stop_acquisition	(ArvCamera *camera);
+void		arv_camera_set_trigger_selector		(ArvCamera *camera, const char *value);
+void		arv_camera_set_trigger_mode		(ArvCamera *camera, const char *value);
+void		arv_camera_set_trigger_source		(ArvCamera *camera, const char *value);
+void		arv_camera_set_trigger_activation	(ArvCamera *camera, const char *value);
 guint		arv_camera_get_payload		(ArvCamera *camera);
 void		arv_camera_set_region		(ArvCamera *camera, gint x, gint y, gint width, gint height);
 void		arv_camera_get_region		(ArvCamera *camera, gint *x, gint *y, gint *width, gint *height);
diff --git a/src/arvcameratest.c b/src/arvcameratest.c
index 343c101..c50c0bb 100644
--- a/src/arvcameratest.c
+++ b/src/arvcameratest.c
@@ -13,6 +13,7 @@ static char *arv_option_camera_name = NULL;
 static char *arv_option_debug_domains = NULL;
 static gboolean arv_option_snaphot = FALSE;
 static gboolean arv_option_auto_buffer = FALSE;
+static gboolean arv_option_external_trigger = FALSE;
 static int arv_option_width = -1;
 static int arv_option_height = -1;
 static int arv_option_horizontal_binning = -1;
@@ -25,7 +26,9 @@ static const GOptionEntry arv_option_entries[] =
 	{ "snapshot",		's', 0, G_OPTION_ARG_NONE,
 		&arv_option_snaphot,	"Snapshot", NULL},
 	{ "auto",		'a', 0, G_OPTION_ARG_NONE,
-		&arv_option_auto_buffer,	"AutoBufferSize", NULL},
+		&arv_option_auto_buffer,	"Auto buffer size", NULL},
+	{ "external",		'e', 0, G_OPTION_ARG_NONE,
+		&arv_option_external_trigger,	"External trigger", NULL},
 	{ "width", 		'w', 0, G_OPTION_ARG_INT,
 		&arv_option_width,		"Width", NULL },
 	{ "height", 		'h', 0, G_OPTION_ARG_INT,
@@ -104,23 +107,40 @@ main (int argc, char **argv)
 						  ARV_GV_STREAM_OPTION_SOCKET_BUFFER_AUTO,
 						  0);
 
-		for (i = 0; i < 30; i++)
+		for (i = 0; i < 200; i++)
 			arv_stream_push_buffer (stream, arv_buffer_new (payload, NULL));
 
+		arv_camera_set_acquisition_mode (camera, "Continuous");
+
+		if (arv_option_external_trigger) {
+			arv_camera_set_trigger_selector (camera, "FrameRate");
+			arv_camera_set_trigger_mode (camera, "On");
+			arv_camera_set_trigger_activation (camera, "RisingEdge");
+			arv_camera_set_trigger_source (camera, "Line1");
+		}
+
 		arv_camera_start_acquisition (camera);
 
 		signal (SIGINT, set_cancel);
 
 		do {
-			g_usleep (100000);
+			int buffer_count;
+
+			g_usleep (1000000);
 
+			buffer_count = 0;
 			do  {
 				buffer = arv_stream_pop_buffer (stream);
 				if (buffer != NULL) {
+					if (buffer->status == ARV_BUFFER_STATUS_SUCCESS)
+						buffer_count++;
 					/* Image processing here */
 					arv_stream_push_buffer (stream, buffer);
 				}
 			} while (buffer != NULL);
+
+			g_print ("Frame rate = %d\n", buffer_count);
+
 		} while (!cancel);
 
 		arv_stream_get_statistics (stream, &n_processed_buffers, &n_failures, &n_underruns);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]