[aravis/aravis-0-2] camera: handle enumerated framerate of The Imaging Source cameras.
- From: Emmanuel Pacaud <emmanuel src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [aravis/aravis-0-2] camera: handle enumerated framerate of The Imaging Source cameras.
- Date: Tue, 30 Apr 2013 20:03:12 +0000 (UTC)
commit fdd15cc071bfbe428f3519d9d8c328bf16b12398
Author: Edgar Thier <edgarthier gmail com>
Date: Tue Apr 30 21:59:25 2013 +0200
camera: handle enumerated framerate of The Imaging Source cameras.
docs/reference/aravis/aravis-sections.txt | 1 +
src/arvcamera.c | 109 ++++++++++++++++++++++++++++-
src/arvcamera.h | 1 +
3 files changed, 109 insertions(+), 2 deletions(-)
---
diff --git a/docs/reference/aravis/aravis-sections.txt b/docs/reference/aravis/aravis-sections.txt
index b2da96f..3f14b25 100644
--- a/docs/reference/aravis/aravis-sections.txt
+++ b/docs/reference/aravis/aravis-sections.txt
@@ -32,6 +32,7 @@ arv_camera_get_acquisition_mode
arv_camera_is_frame_rate_available
arv_camera_set_frame_rate
arv_camera_get_frame_rate
+arv_camera_get_frame_rate_bounds
arv_camera_set_trigger
arv_camera_set_trigger_source
arv_camera_get_trigger_source
diff --git a/src/arvcamera.c b/src/arvcamera.c
index 3f625fe..99bbb80 100644
--- a/src/arvcamera.c
+++ b/src/arvcamera.c
@@ -603,11 +603,22 @@ arv_camera_get_acquisition_mode (ArvCamera *camera)
void
arv_camera_set_frame_rate (ArvCamera *camera, double frame_rate)
{
+ ArvGcNode *feature;
+ double minimum;
+ double maximum;
+
g_return_if_fail (ARV_IS_CAMERA (camera));
if (frame_rate <= 0.0)
return;
+ arv_camera_get_frame_rate_bounds(camera, &minimum, &maximum);
+
+ if (frame_rate < minimum)
+ frame_rate = minimum;
+ if (frame_rate > maximum)
+ frame_rate = maximum;
+
switch (camera->priv->vendor) {
case ARV_CAMERA_VENDOR_BASLER:
arv_device_set_string_feature_value (camera->priv->device, "TriggerSelector",
@@ -632,7 +643,28 @@ arv_camera_set_frame_rate (ArvCamera *camera, double frame_rate)
arv_device_set_string_feature_value (camera->priv->device, "TriggerSelector",
"FrameStart");
arv_device_set_string_feature_value (camera->priv->device, "TriggerMode", "Off");
- arv_device_set_float_feature_value (camera->priv->device, "FPS", frame_rate);
+ feature = arv_device_get_feature (camera->priv->device, "FPS");
+ if (ARV_IS_GC_FEATURE_NODE (feature) &&
+ g_strcmp0 (arv_dom_node_get_node_name (ARV_DOM_NODE (feature)), "Enumeration") ==
0) {
+ gint64 *values;
+ guint n_values;
+ guint i;
+
+ values = arv_gc_enumeration_get_available_int_values (ARV_GC_ENUMERATION
(feature), &n_values, NULL);
+ for (i = 0; i < n_values; i++) {
+ if (values[i] > 0) {
+ double e;
+
+ e = (int)((10000000/(double) values[i]) * 100 + 0.5) / 100.0;
+ if (e == frame_rate) {
+ arv_gc_enumeration_set_int_value (ARV_GC_ENUMERATION
(feature), values[i], NULL);
+ break;
+ }
+ }
+ }
+ g_free (values);
+ } else
+ arv_device_set_float_feature_value (camera->priv->device, "FPS", frame_rate);
break;
case ARV_CAMERA_VENDOR_UNKNOWN:
arv_device_set_string_feature_value (camera->priv->device, "TriggerSelector",
@@ -655,6 +687,8 @@ arv_camera_set_frame_rate (ArvCamera *camera, double frame_rate)
double
arv_camera_get_frame_rate (ArvCamera *camera)
{
+ ArvGcNode *feature;
+
g_return_val_if_fail (ARV_IS_CAMERA (camera), -1);
switch (camera->priv->vendor) {
@@ -662,7 +696,18 @@ arv_camera_get_frame_rate (ArvCamera *camera)
case ARV_CAMERA_VENDOR_PROSILICA:
return arv_device_get_float_feature_value (camera->priv->device,
"AcquisitionFrameRateAbs");
case ARV_CAMERA_VENDOR_TIS:
- return arv_device_get_float_feature_value (camera->priv->device, "FPS");
+ feature = arv_device_get_feature (camera->priv->device, "FPS");
+ if (ARV_IS_GC_FEATURE_NODE (feature) &&
+ g_strcmp0 (arv_dom_node_get_node_name (ARV_DOM_NODE (feature)), "Enumeration") ==
0) {
+ gint64 i;
+
+ i = arv_gc_enumeration_get_int_value (ARV_GC_ENUMERATION (feature), NULL);
+ if (i > 0)
+ return (int)((10000000/(double) i) * 100 + 0.5) / 100.0;
+ else
+ return 0;
+ } else
+ return arv_device_get_float_feature_value (camera->priv->device, "FPS");
case ARV_CAMERA_VENDOR_UNKNOWN:
default:
return arv_device_get_float_feature_value (camera->priv->device,
"AcquisitionFrameRate");
@@ -670,6 +715,66 @@ arv_camera_get_frame_rate (ArvCamera *camera)
}
/**
+ * arv_camera_get_frame_rate_bounds:
+ * @camera: a #ArvCamera
+ * @min: (out): minimal possible framerate
+ * @max: (out): maximum possible framerate
+ *
+ * Retrieves allowed range for framerate.
+ *
+ * Since 0.2.2
+ */
+
+void
+arv_camera_get_frame_rate_bounds (ArvCamera *camera, double *min, double *max)
+{
+ ArvGcNode *feature;
+
+ g_return_if_fail (ARV_IS_CAMERA (camera));
+
+ switch (camera->priv->vendor) {
+ case ARV_CAMERA_VENDOR_TIS:
+ feature = arv_device_get_feature (camera->priv->device, "FPS");
+ if (ARV_IS_GC_FEATURE_NODE (feature) &&
+ g_strcmp0 (arv_dom_node_get_node_name (ARV_DOM_NODE (feature)), "Enumeration") ==
0) {
+ gint64 *values;
+ guint n_values;
+ guint i;
+
+ if (min != NULL)
+ *min = 0;
+ if (max != NULL)
+ *max = 0;
+
+ values = arv_gc_enumeration_get_available_int_values (ARV_GC_ENUMERATION
(feature), &n_values, NULL);
+ for (i = 0; i < n_values; i++) {
+ if (values[i] > 0) {
+ double s;
+
+ s = (int)((10000000/(double) values[i]) * 100 + 0.5) / 100.0;
+
+ if (s > *max && max != NULL)
+ *max = s;
+ if ((*min == 0 || *min > s) && min != NULL)
+ *min = s;
+ }
+ }
+ g_free (values);
+ } else
+ arv_device_get_float_feature_bounds (camera->priv->device, "FPS", min, max);
+ break;
+ case ARV_CAMERA_VENDOR_BASLER:
+ case ARV_CAMERA_VENDOR_PROSILICA:
+ arv_device_get_float_feature_bounds (camera->priv->device, "AcquisitionFrameRateAbs",
min, max);
+ break;
+ case ARV_CAMERA_VENDOR_UNKNOWN:
+ default:
+ arv_device_get_float_feature_bounds (camera->priv->device, "AcquisitionFrameRate",
min, max);
+ break;
+ }
+}
+
+/**
* arv_camera_set_trigger:
* @camera: a #ArvCamera
* @source: trigger source as string
diff --git a/src/arvcamera.h b/src/arvcamera.h
index 9cf0d76..f918217 100644
--- a/src/arvcamera.h
+++ b/src/arvcamera.h
@@ -91,6 +91,7 @@ gboolean arv_camera_is_frame_rate_available (ArvCamera *camera);
void arv_camera_set_frame_rate (ArvCamera *camera, double frame_rate);
double arv_camera_get_frame_rate (ArvCamera *camera);
+void arv_camera_get_frame_rate_bounds (ArvCamera * camera, double *min, double *max);
void arv_camera_set_trigger (ArvCamera *camera, const char *source);
void arv_camera_set_trigger_source (ArvCamera *camera, const char *source);
const char * arv_camera_get_trigger_source (ArvCamera *camera);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]