forked from AravisProject/aravis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharvcamera.c
4287 lines (3641 loc) · 117 KB
/
arvcamera.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* Aravis - Digital camera library
*
* Copyright © 2009-2022 Emmanuel Pacaud
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
* Author: Emmanuel Pacaud <[email protected]>
*/
/**
* SECTION:arvcamera
* @short_description: Class for generic camera control
*
* [[email protected]] is a class for the generic control of cameras. It hides the complexity of the genicam interface
* by providing a simple API, with the drawback of not exposing all the available features. See [[email protected]]
* and [[email protected]] for a more advanced use of the Aravis library.
*/
#include <arvfeatures.h>
#include <arvdebug.h>
#include <arvcamera.h>
#include <arvsystem.h>
#include <arvgvinterface.h>
#include <arvgcboolean.h>
#include <arvgccommand.h>
#include <arvgcinteger.h>
#include <arvgcfloat.h>
#include <arvgcenumeration.h>
#include <arvgcenumentry.h>
#include <arvgcstring.h>
#include <arvbuffer.h>
#include <arvgc.h>
#include <arvgvdevice.h>
#if ARAVIS_HAS_USB
#include <arvuvdevice.h>
#endif
#include <arvenums.h>
#include <arvstr.h>
static void arv_camera_get_integer_bounds_as_gint (ArvCamera *camera, const char *feature, gint *min, gint *max, GError **error);
static void arv_camera_get_integer_bounds_as_guint (ArvCamera *camera, const char *feature, guint *min, guint *max, GError **error);
static void arv_camera_get_integer_bounds_as_double (ArvCamera *camera, const char *feature, double *min, double *max, GError **error);
/**
* ArvCameraVendor:
* @ARV_CAMERA_VENDOR_UNKNOWN: unknown camera vendor
* @ARV_CAMERA_VENDOR_BASLER: Basler
* @ARV_CAMERA_VENDOR_PROSILICA: Prosilica
* @ARV_CAMERA_VENDOR_TIS: The Imaging Source
* @ARV_CAMERA_VENDOR_POINT_GREY_FLIR: PointGrey / FLIR
* @ARV_CAMERA_VENDOR_XIMEA: XIMEA GmbH
* @ARV_CAMERA_VENDOR_MATRIX_VISION: Matrix Vision GmbH
* @ARV_CAMERA_VENDOR_IMPERX: Imperx, Inc
*/
typedef enum {
ARV_CAMERA_VENDOR_UNKNOWN,
ARV_CAMERA_VENDOR_BASLER,
ARV_CAMERA_VENDOR_DALSA,
ARV_CAMERA_VENDOR_PROSILICA,
ARV_CAMERA_VENDOR_TIS,
ARV_CAMERA_VENDOR_POINT_GREY_FLIR,
ARV_CAMERA_VENDOR_RICOH,
ARV_CAMERA_VENDOR_XIMEA,
ARV_CAMERA_VENDOR_MATRIX_VISION,
ARV_CAMERA_VENDOR_IMPERX
} ArvCameraVendor;
typedef enum {
ARV_CAMERA_SERIES_UNKNOWN,
ARV_CAMERA_SERIES_BASLER_ACE,
ARV_CAMERA_SERIES_BASLER_SCOUT,
ARV_CAMERA_SERIES_BASLER_OTHER,
ARV_CAMERA_SERIES_DALSA,
ARV_CAMERA_SERIES_PROSILICA,
ARV_CAMERA_SERIES_TIS,
ARV_CAMERA_SERIES_POINT_GREY_FLIR,
ARV_CAMERA_SERIES_RICOH,
ARV_CAMERA_SERIES_XIMEA,
ARV_CAMERA_SERIES_MATRIX_VISION,
ARV_CAMERA_SERIES_IMPERX_CHEETAH,
ARV_CAMERA_SERIES_IMPERX_OTHER
} ArvCameraSeries;
typedef struct {
char *name;
ArvDevice *device;
ArvGc *genicam;
ArvCameraVendor vendor;
ArvCameraSeries series;
gboolean has_serial_number;
gboolean has_gain;
gboolean gain_raw_as_float;
gboolean gain_abs_as_float;
gboolean has_brightness;
gboolean has_black_level_raw;
gboolean has_black_level;
gboolean has_exposure_time;
gboolean has_acquisition_frame_rate;
gboolean has_acquisition_frame_rate_auto;
gboolean has_acquisition_frame_rate_enabled;
gboolean has_region_offset;
GError *init_error;
} ArvCameraPrivate;
static void arv_camera_initable_iface_init (GInitableIface *iface);
G_DEFINE_TYPE_WITH_CODE (ArvCamera, arv_camera, G_TYPE_OBJECT,
G_ADD_PRIVATE (ArvCamera)
G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE, arv_camera_initable_iface_init))
enum
{
PROP_0,
PROP_CAMERA_NAME,
PROP_CAMERA_DEVICE
};
/**
* arv_camera_create_stream: (skip)
* @camera: a #ArvCamera
* @callback: (scope call) (allow-none): a frame processing callback
* @user_data: (closure) (allow-none): user data for @callback
* @error: a #GError placeholder, %NULL to ignore
*
* Creates a new [class@ArvStream] for video stream reception. See
* [callback@ArvStreamCallback] for details regarding the callback function.
*
* Returns: (transfer full): a new [class@ArvStream], to be freed after use with [[email protected]].
*
* Since: 0.2.0
*/
ArvStream *
arv_camera_create_stream (ArvCamera *camera, ArvStreamCallback callback, gpointer user_data, GError **error)
{
return arv_camera_create_stream_full(camera, callback, user_data, NULL, error);
}
/**
* arv_camera_create_stream_full: (rename-to arv_camera_create_stream)
* @camera: a #ArvCamera
* @callback: (scope notified) (allow-none): a frame processing callback
* @user_data: (closure) (allow-none): user data for @callback
* @destroy: a #GDestroyNotify placeholder, %NULL to ignore
* @error: a #GError placeholder, %NULL to ignore
*
* Creates a new [class@ArvStream] for video stream reception. See
* [callback@ArvStreamCallback] for details regarding the callback function.
*
* Returns: (transfer full): a new [class@ArvStream], to be freed after use with [[email protected]].
*
* Since: 0.8.23
*/
ArvStream *
arv_camera_create_stream_full (ArvCamera *camera, ArvStreamCallback callback, gpointer user_data, GDestroyNotify destroy, GError **error)
{
ArvCameraPrivate *priv = arv_camera_get_instance_private (camera);
g_return_val_if_fail (ARV_IS_CAMERA (camera), NULL);
return arv_device_create_stream_full (priv->device, callback, user_data, destroy, error);
}
/* Device control */
/**
* arv_camera_get_vendor_name:
* @camera: a #ArvCamera
* @error: a #GError placeholder, %NULL to ignore
*
* Returns: the camera vendor name.
*
* Since: 0.8.0
*/
const char *
arv_camera_get_vendor_name (ArvCamera *camera, GError **error)
{
return arv_camera_get_string (camera, "DeviceVendorName", error);
}
/**
* arv_camera_get_model_name:
* @camera: a #ArvCamera
* @error: a #GError placeholder, %NULL to ignore
*
* Returns: the camera model name.
*
* Since: 0.8.0
*/
const char *
arv_camera_get_model_name (ArvCamera *camera, GError **error)
{
return arv_camera_get_string (camera, "DeviceModelName", error);
}
/**
* arv_camera_get_device_serial_number:
* @camera: a #ArvCamera
* @error: a #GError placeholder, %NULL to ignore
*
* Returns: the camera device serial number.
*
* Since: 0.8.8
*/
const char *
arv_camera_get_device_serial_number (ArvCamera *camera, GError **error)
{
ArvCameraPrivate *priv = arv_camera_get_instance_private (camera);
g_return_val_if_fail (ARV_IS_CAMERA (camera), NULL);
if (priv->has_serial_number)
return arv_camera_get_string (camera, "DeviceSerialNumber", error);
return arv_camera_get_device_id (camera, error);
}
/**
* arv_camera_get_device_id:
* @camera: a #ArvCamera
* @error: a #GError placeholder, %NULL to ignore
*
* Returns: the camera device ID.
*
* Since: 0.8.0
*/
const char *
arv_camera_get_device_id (ArvCamera *camera, GError **error)
{
return arv_camera_get_string (camera, "DeviceID", error);
}
/* Image format control */
/**
* arv_camera_get_sensor_size:
* @camera: a #ArvCamera
* @width: (out): camera sensor width
* @height: (out): camera sensor height
* @error: a #GError placeholder, %NULL to ignore
*
* Since: 0.8.0
*/
void
arv_camera_get_sensor_size (ArvCamera *camera, gint *width, gint *height, GError **error)
{
GError *local_error = NULL;
g_return_if_fail (ARV_IS_CAMERA (camera));
if (width != NULL)
*width = arv_camera_get_integer (camera, "SensorWidth", &local_error);
if (height != NULL && local_error == NULL)
*height = arv_camera_get_integer (camera, "SensorHeight", &local_error);
if (local_error != NULL)
g_propagate_error (error, local_error);
}
/**
* arv_camera_is_region_offset_available:
* @camera: a #ArvCamera
* @error: a #GError placeholder, %NULL to ignore
*
* Returns: %TRUE if OffsetX and OffsetY features are available.
*
* Since: 0.8.22
*/
gboolean
arv_camera_is_region_offset_available (ArvCamera *camera, GError **error)
{
ArvCameraPrivate *priv = arv_camera_get_instance_private (camera);
GError *local_error = NULL;
gboolean has_offset_x, has_offset_y;
g_return_val_if_fail (ARV_IS_CAMERA (camera), FALSE);
if (!priv->has_region_offset)
return FALSE;
has_offset_x = arv_camera_is_feature_available (camera, "OffsetX", &local_error);
if (local_error == NULL)
has_offset_y = arv_camera_is_feature_available (camera, "OffsetY", &local_error);
if (local_error != NULL) {
g_propagate_error (error, local_error);
return FALSE;
}
return has_offset_x && has_offset_y;
}
/**
* arv_camera_set_region:
* @camera: a #ArvCamera
* @x: x offset
* @y: y_offset
* @width: region width
* @height: region height
* @error: a #GError placeholder, %NULL to ignore
*
* Defines the region of interest which will be transmitted in the video
* stream. Negative @x or @y values, or not strictly positive @width or @height values are ignored.
*
* Since: 0.8.0
*/
void
arv_camera_set_region (ArvCamera *camera, gint x, gint y, gint width, gint height, GError **error)
{
ArvCameraPrivate *priv = arv_camera_get_instance_private (camera);
GError *local_error = NULL;
g_return_if_fail (ARV_IS_CAMERA (camera));
if (priv->has_region_offset) {
if (x >= 0)
arv_camera_set_integer (camera, "OffsetX", 0, &local_error);
if (y >= 0 && local_error == NULL)
arv_camera_set_integer (camera, "OffsetY", 0, &local_error);
}
if (width > 0 && local_error == NULL)
arv_camera_set_integer (camera, "Width", width, &local_error);
if (height > 0 && local_error == NULL)
arv_camera_set_integer (camera, "Height", height, &local_error);
if (priv->has_region_offset) {
if (x >= 0 && local_error == NULL)
arv_camera_set_integer (camera, "OffsetX", x, &local_error);
if (y >= 0 && local_error == NULL)
arv_camera_set_integer (camera, "OffsetY", y, &local_error);
}
if (local_error != NULL)
g_propagate_error (error, local_error);
}
/**
* arv_camera_get_region:
* @camera: a #ArvCamera
* @x: (out): x offset
* @y: (out): y_offset
* @width: (out): region width
* @height: (out): region height
* @error: a #GError placeholder, %NULL to ignore
*
* Retrieves the current region of interest.
*
* Since: 0.8.0
*/
void
arv_camera_get_region (ArvCamera *camera, gint *x, gint *y, gint *width, gint *height, GError **error)
{
ArvCameraPrivate *priv = arv_camera_get_instance_private (camera);
GError *local_error = NULL;
g_return_if_fail (ARV_IS_CAMERA (camera));
if (x != NULL)
*x = priv->has_region_offset ? arv_camera_get_integer (camera, "OffsetX", &local_error) : 0;
if (y != NULL && local_error == NULL)
*y = priv->has_region_offset ? arv_camera_get_integer (camera, "OffsetY", &local_error) : 0;
if (width != NULL && local_error == NULL)
*width = arv_camera_get_integer (camera, "Width", &local_error);
if (height != NULL && local_error == NULL)
*height = arv_camera_get_integer (camera, "Height", &local_error);
if (local_error != NULL)
g_propagate_error (error, local_error);
}
/**
* arv_camera_get_x_offset_bounds:
* @camera: a #ArvCamera
* @min: (out): minimum offset
* @max: (out): maximum offset
* @error: a #GError placeholder, %NULL to ignore
*
* Retrieves the valid range for image horizontal offset.
*
* Since: 0.8.0
*/
void
arv_camera_get_x_offset_bounds (ArvCamera *camera, gint *min, gint *max, GError **error)
{
arv_camera_get_integer_bounds_as_gint (camera, "OffsetX", min, max, error);
}
/**
* arv_camera_get_x_offset_increment:
* @camera: a #ArvCamera
* @error: a #GError placeholder, %NULL to ignore
*
* Returns: horizontal offset value increment.
*
* Since: 0.8.0
*/
gint
arv_camera_get_x_offset_increment (ArvCamera *camera, GError **error)
{
return arv_camera_get_integer_increment (camera, "OffsetX", error);
}
/**
* arv_camera_get_y_offset_bounds:
* @camera: a #ArvCamera
* @min: (out): minimum offset
* @max: (out): maximum offset
* @error: a #GError placeholder, %NULL to ignore
*
* Retrieves the valid range for image vertical offset.
*
* Since: 0.8.0
*/
void
arv_camera_get_y_offset_bounds (ArvCamera *camera, gint *min, gint *max, GError **error)
{
arv_camera_get_integer_bounds_as_gint (camera, "OffsetY", min, max, error);
}
/**
* arv_camera_get_y_offset_increment:
* @camera: a #ArvCamera
* @error: a #GError placeholder, %NULL to ignore
*
* Returns: vertical offset value increment.
*
* Since: 0.8.0
*/
gint
arv_camera_get_y_offset_increment (ArvCamera *camera, GError **error)
{
return arv_camera_get_integer_increment (camera, "OffsetY", error);
}
/**
* arv_camera_get_width_bounds:
* @camera: a #ArvCamera
* @min: (out): minimum width
* @max: (out): maximum width
* @error: a #GError placeholder, %NULL to ignore
*
* Retrieves the valid range for image width.
*
* Since: 0.8.0
*/
void
arv_camera_get_width_bounds (ArvCamera *camera, gint *min, gint *max, GError **error)
{
arv_camera_get_integer_bounds_as_gint (camera, "Width", min, max, error);
}
/**
* arv_camera_get_width_increment:
* @camera: a #ArvCamera
* @error: a #GError placeholder, %NULL to ignore
*
* Returns: width value increment.
*
* Since: 0.8.0
*/
gint
arv_camera_get_width_increment (ArvCamera *camera, GError **error)
{
return arv_camera_get_integer_increment (camera, "Width", error);
}
/**
* arv_camera_get_height_bounds:
* @camera: a #ArvCamera
* @min: (out): minimum height
* @max: (out): maximum height
* @error: a #GError placeholder, %NULL to ignore
*
* Retrieves the valid range for image height.
*
* Since: 0.8.0
*/
void
arv_camera_get_height_bounds (ArvCamera *camera, gint *min, gint *max, GError **error)
{
arv_camera_get_integer_bounds_as_gint (camera, "Height", min, max, error);
}
/**
* arv_camera_get_height_increment:
* @camera: a #ArvCamera
* @error: a #GError placeholder, %NULL to ignore
*
* Returns: height value increment.
*
* Since: 0.8.0
*/
gint
arv_camera_get_height_increment (ArvCamera *camera, GError **error)
{
return arv_camera_get_integer_increment (camera, "Height", error);
}
/**
* arv_camera_set_binning:
* @camera: a #ArvCamera
* @dx: horizontal binning
* @dy: vertical binning
* @error: a #GError placeholder, %NULL to ignore
*
* Defines binning in both directions. Not all cameras support this
* feature. Negative @dx or @dy values are ignored.
*
* Since: 0.8.0
*/
void
arv_camera_set_binning (ArvCamera *camera, gint dx, gint dy, GError **error)
{
GError *local_error = NULL;
g_return_if_fail (ARV_IS_CAMERA (camera));
if (dx > 0)
arv_camera_set_integer (camera, "BinningHorizontal", dx, &local_error);
if (dy > 0 && local_error == NULL)
arv_camera_set_integer (camera, "BinningVertical", dy, &local_error);
if (local_error != NULL)
g_propagate_error (error, local_error);
}
/**
* arv_camera_get_binning:
* @camera: a #ArvCamera
* @dx: (out): horizontal binning placeholder
* @dy: (out): vertical binning placeholder
* @error: a #GError placeholder, %NULL to ignore
*
* Retrieves binning in both directions.
*
* Since: 0.8.0
*/
void
arv_camera_get_binning (ArvCamera *camera, gint *dx, gint *dy, GError **error)
{
GError *local_error = NULL;
g_return_if_fail (ARV_IS_CAMERA (camera));
if (dx != NULL)
*dx = arv_camera_get_integer (camera, "BinningHorizontal", &local_error);
if (dy != NULL && local_error == NULL)
*dy = arv_camera_get_integer (camera, "BinningVertical", &local_error);
if (local_error != NULL)
g_propagate_error (error, local_error);
}
/**
* arv_camera_get_x_binning_bounds:
* @camera: a #ArvCamera
* @min: (out): minimum binning
* @max: (out): maximum binning
* @error: a #GError placeholder, %NULL to ignore
*
* Retrieves the valid range for image horizontal binning.
*
* Since: 0.8.0
*/
void
arv_camera_get_x_binning_bounds (ArvCamera *camera, gint *min, gint *max, GError **error)
{
arv_camera_get_integer_bounds_as_gint (camera, "BinningHorizontal", min, max, error);
}
/**
* arv_camera_get_x_binning_increment:
* @camera: a #ArvCamera
* @error: a #GError placeholder, %NULL to ignore
*
* Returns: horizontal binning value increment.
*
* Since: 0.8.0
*/
gint
arv_camera_get_x_binning_increment (ArvCamera *camera, GError **error)
{
return arv_camera_get_integer_increment (camera, "BinningHorizontal", error);
}
/**
* arv_camera_get_y_binning_bounds:
* @camera: a #ArvCamera
* @min: (out): minimum binning
* @max: (out): maximum binning
* @error: a #GError placeholder, %NULL to ignore
*
* Retrieves the valid range for image vertical binning.
*
* Since: 0.8.0
*/
void
arv_camera_get_y_binning_bounds (ArvCamera *camera, gint *min, gint *max, GError **error)
{
arv_camera_get_integer_bounds_as_gint (camera, "BinningVertical", min, max, error);
}
/**
* arv_camera_get_y_binning_increment:
* @camera: a #ArvCamera
* @error: a #GError placeholder, %NULL to ignore
*
* Returns: vertical binning value increment.
*
* Since: 0.8.0
*/
gint
arv_camera_get_y_binning_increment (ArvCamera *camera, GError **error)
{
return arv_camera_get_integer_increment (camera, "BinningVertical", error);
}
/**
* arv_camera_set_pixel_format:
* @camera: a #ArvCamera
* @format: pixel format
* @error: a #GError placeholder, %NULL to ignore
*
* Defines pixel format.
*
* Since: 0.8.0
*/
void
arv_camera_set_pixel_format (ArvCamera *camera, ArvPixelFormat format, GError **error)
{
arv_camera_set_integer (camera, "PixelFormat", format, error);
}
/**
* arv_camera_set_pixel_format_from_string:
* @camera: a #ArvCamera
* @format: pixel format
* @error: a #GError placeholder, %NULL to ignore
*
* Defines pixel format described by a string.
*
* Since: 0.8.0
*/
void
arv_camera_set_pixel_format_from_string (ArvCamera *camera, const char * format, GError **error)
{
arv_camera_set_string (camera, "PixelFormat", format, error);
}
/**
* arv_camera_get_pixel_format:
* @camera: a #ArvCamera
* @error: a #GError placeholder, %NULL to ignore
*
* Returns: pixel format.
*
* Since: 0.8.0
*/
ArvPixelFormat
arv_camera_get_pixel_format (ArvCamera *camera, GError **error)
{
return arv_camera_get_integer (camera, "PixelFormat", error);
}
/**
* arv_camera_get_pixel_format_as_string:
* @camera: a #ArvCamera
* @error: a #GError placeholder, %NULL to ignore
*
* Retuns: pixel format as string, NULL on error.
*
* Since: 0.8.0
*/
const char *
arv_camera_get_pixel_format_as_string (ArvCamera *camera, GError **error)
{
return arv_camera_get_string (camera, "PixelFormat", error);
}
/**
* arv_camera_dup_available_pixel_formats:
* @camera: a #ArvCamera
* @n_pixel_formats: (out): number of different pixel formats
* @error: a #GError placeholder, %NULL to ignore
*
* Retrieves the list of all available pixel formats.
*
* Returns: (array length=n_pixel_formats) (transfer container): a newly allocated array of #ArvPixelFormat, to be freed after use with
* g_free().
*
* Since: 0.8.0
*/
gint64 *
arv_camera_dup_available_pixel_formats (ArvCamera *camera, guint *n_pixel_formats, GError **error)
{
return arv_camera_dup_available_enumerations (camera, "PixelFormat", n_pixel_formats, error);
}
/**
* arv_camera_dup_available_pixel_formats_as_strings:
* @camera: a #ArvCamera
* @n_pixel_formats: (out): number of different pixel formats
* @error: a #GError placeholder, %NULL to ignore
*
* Retrieves the list of all available pixel formats as strings.
*
* Returns: (array length=n_pixel_formats) (transfer container): a newly allocated array of strings, to be freed after use with
* g_free().
*
* Since: 0.8.0
*/
const char **
arv_camera_dup_available_pixel_formats_as_strings (ArvCamera *camera, guint *n_pixel_formats, GError **error)
{
g_return_val_if_fail (ARV_IS_CAMERA (camera), NULL);
return arv_camera_dup_available_enumerations_as_strings (camera, "PixelFormat", n_pixel_formats, error);
}
/**
* arv_camera_dup_available_pixel_formats_as_display_names:
* @camera: a #ArvCamera
* @n_pixel_formats: (out): number of different pixel formats
* @error: a #GError placeholder, %NULL to ignore
*
* Retrieves the list of all available pixel formats as display names.
* In general, these human-readable strings cannot be used as settings.
*
* Returns: (array length=n_pixel_formats) (transfer container): a newly allocated array of string constants, to be freed after use with
* g_free().
*
* Since: 0.8.0
*/
const char **
arv_camera_dup_available_pixel_formats_as_display_names (ArvCamera *camera, guint *n_pixel_formats, GError **error)
{
return arv_camera_dup_available_enumerations_as_display_names (camera, "PixelFormat", n_pixel_formats, error);
}
/* Acquisition control */
/**
* arv_camera_start_acquisition:
* @camera: a #ArvCamera
* @error: a #GError placeholder, %NULL to ignore
*
* Starts video stream acquisition.
*
* Since: 0.8.0
*/
void
arv_camera_start_acquisition (ArvCamera *camera, GError **error)
{
arv_camera_execute_command (camera, "AcquisitionStart", error);
}
/**
* arv_camera_stop_acquisition:
* @camera: a #ArvCamera
* @error: a #GError placeholder, %NULL to ignore
*
* Stops video stream acquisition.
*
* Since: 0.8.0
*/
void
arv_camera_stop_acquisition (ArvCamera *camera, GError **error)
{
arv_camera_execute_command (camera, "AcquisitionStop", error);
}
/**
* arv_camera_abort_acquisition:
* @camera: a #ArvCamera
* @error: a #GError placeholder, %NULL to ignore
*
* Aborts video stream acquisition.
*
* Since: 0.8.0
*/
void
arv_camera_abort_acquisition (ArvCamera *camera, GError **error)
{
arv_camera_execute_command (camera, "AcquisitionAbort", error);
}
/**
* arv_camera_acquisition:
* @camera: a #ArvCamera
* @timeout: acquisition timeout in µs. Zero means no timeout.
* @error: a #GError placeholder, %NULL to ignore
*
* Acquire one image buffer.
*
* <warning>
* <para>arv_camera_acquisition() sets the camera in SingleFrame acquisition mode. You may have to put back the camera in
* Continuous acquisition mode for later operations, using arv_camera_set_acquisition_mode().</para>
* </warning>
*
* Returns: (transfer full): A new #ArvBuffer, NULL on error. The returned buffer must be freed using g_object_unref().
*
* Since: 0.8.0
*/
ArvBuffer *
arv_camera_acquisition (ArvCamera *camera, guint64 timeout, GError **error)
{
GError *local_error = NULL;
ArvStream *stream;
ArvBuffer *buffer = NULL;
gint payload;
g_return_val_if_fail (ARV_IS_CAMERA (camera), NULL);
stream = arv_camera_create_stream (camera, NULL, NULL, &local_error);
if (ARV_IS_STREAM(stream)) {
payload = arv_camera_get_payload (camera, &local_error);
if (local_error == NULL) {
arv_stream_push_buffer (stream, arv_buffer_new (payload, NULL));
arv_camera_set_acquisition_mode (camera, ARV_ACQUISITION_MODE_SINGLE_FRAME, &local_error);
if (local_error != NULL &&
local_error->code == ARV_GC_ERROR_ENUM_ENTRY_NOT_FOUND) {
g_clear_error (&local_error);
/* Some cameras don't support SingleFrame, fall back to Continuous */
arv_camera_set_acquisition_mode (camera, ARV_ACQUISITION_MODE_CONTINUOUS, &local_error);
}
}
if (local_error == NULL)
arv_camera_start_acquisition (camera, &local_error);
if (local_error == NULL) {
if (timeout > 0)
buffer = arv_stream_timeout_pop_buffer (stream, timeout);
else
buffer = arv_stream_pop_buffer (stream);
arv_camera_stop_acquisition (camera, &local_error);
}
g_object_unref (stream);
}
if (local_error != NULL)
g_propagate_error (error, local_error);
return buffer;
}
/*
* arv_camera_set_acquisition_mode:
* @camera: a #ArvCamera
* @acquisition_mode: acquisition mode
* @error: a #GError placeholder, %NULL to ignore
*
* Defines acquisition mode.
*
* Since: 0.8.0
*/
void
arv_camera_set_acquisition_mode (ArvCamera *camera, ArvAcquisitionMode acquisition_mode, GError **error)
{
arv_camera_set_string (camera, "AcquisitionMode", arv_acquisition_mode_to_string (acquisition_mode), error);
}
/**
* arv_camera_get_acquisition_mode:
* @camera: a #ArvCamera
* @error: a #GError placeholder, %NULL to ignore
*
* Returns: acquisition mode.
*
* Since: 0.8.0
*/
ArvAcquisitionMode
arv_camera_get_acquisition_mode (ArvCamera *camera, GError **error)
{
const char *string;
g_return_val_if_fail (ARV_IS_CAMERA (camera), 0);
string = arv_camera_get_string (camera, "AcquisitionMode", error);
return arv_acquisition_mode_from_string (string);
}
/**
* arv_camera_set_frame_count:
* @camera: a #ArvCamera
* @frame_count: number of frames to capture in MultiFrame mode
* @error: a #GError placeholder, %NULL to ignore
*
* Sets the number of frames to capture in MultiFrame mode.
*
* Since: 0.8.0
*/
void
arv_camera_set_frame_count (ArvCamera *camera, gint64 frame_count, GError **error)
{
GError *local_error = NULL;
gint64 minimum;
gint64 maximum;
g_return_if_fail (ARV_IS_CAMERA (camera));
if (frame_count <= 0)
return;
arv_camera_get_frame_count_bounds (camera, &minimum, &maximum, &local_error);
if (local_error != NULL) {
g_propagate_error (error, local_error);
return;
}
if (frame_count < minimum)
frame_count = minimum;
if (frame_count > maximum)
frame_count = maximum;
arv_camera_set_integer (camera, "AcquisitionFrameCount", frame_count, error);
}
/**
* arv_camera_get_frame_count:
* @camera: a #ArvCamera
* @error: a #GError placeholder, %NULL to ignore
*
* Returns: number of frames to capture in MultiFrame mode.
*
* Since: 0.8.0
*/
gint64
arv_camera_get_frame_count (ArvCamera *camera, GError **error)
{
return arv_camera_get_integer (camera, "AcquisitionFrameCount", error);
}
/**
* arv_camera_get_frame_count_bounds:
* @camera: a #ArvCamera
* @min: (out): minimal possible frame count
* @max: (out): maximum possible frame count
* @error: a #GError placeholder, %NULL to ignore
*