-
Notifications
You must be signed in to change notification settings - Fork 1
/
video1394.pyx
1149 lines (830 loc) · 43.5 KB
/
video1394.pyx
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
#
#
#
#
#
#
#
#
import threading
import sys
from dc1394 cimport *
import codebench.events as events
import numpy as np
cimport numpy as np
import select
cdef dict color_coding = {
DC1394_COLOR_CODING_MONO8 : "MONO8",
DC1394_COLOR_CODING_YUV411 : "YUV411",
DC1394_COLOR_CODING_YUV422 : "YUV422",
DC1394_COLOR_CODING_YUV444 : "YUV444",
DC1394_COLOR_CODING_RGB8 : "RGB8",
DC1394_COLOR_CODING_MONO16 : "MONO16",
DC1394_COLOR_CODING_RGB16 : "RGB16",
DC1394_COLOR_CODING_MONO16S : "MONO16S",
DC1394_COLOR_CODING_RGB16S : "RGB16S",
DC1394_COLOR_CODING_RAW8 : "RAW8",
DC1394_COLOR_CODING_RAW16 : "RAW16" }
VIDEO_MODE_1600x1200_RGB8 = DC1394_VIDEO_MODE_1600x1200_RGB8
VIDEO_MODE_1280x960_RGB8 = DC1394_VIDEO_MODE_1280x960_RGB8
VIDEO_MODE_1024x768_RGB8 = DC1394_VIDEO_MODE_1024x768_RGB8
VIDEO_MODE_800x600_RGB8 = DC1394_VIDEO_MODE_800x600_RGB8
VIDEO_MODE_640x480_RGB8 = DC1394_VIDEO_MODE_640x480_RGB8
VIDEO_MODE_1600x1200_YUV422 = DC1394_VIDEO_MODE_1600x1200_YUV422
VIDEO_MODE_1280x960_YUV422 = DC1394_VIDEO_MODE_1280x960_YUV422
VIDEO_MODE_1024x768_YUV422 = DC1394_VIDEO_MODE_1024x768_YUV422
VIDEO_MODE_800x600_YUV422 = DC1394_VIDEO_MODE_800x600_YUV422
VIDEO_MODE_640x480_YUV422 = DC1394_VIDEO_MODE_640x480_YUV422
VIDEO_MODE_640x480_YUV411 = DC1394_VIDEO_MODE_640x480_YUV411
VIDEO_MODE_1280x960_MONO8 = DC1394_VIDEO_MODE_1280x960_MONO8
VIDEO_MODE_1024x768_MONO8 = DC1394_VIDEO_MODE_1024x768_MONO8
VIDEO_MODE_800x600_MONO8 = DC1394_VIDEO_MODE_800x600_MONO8
VIDEO_MODE_640x480_MONO8 = DC1394_VIDEO_MODE_640x480_MONO8
VIDEO_MODE_1600x1200_MONO16 = DC1394_VIDEO_MODE_1600x1200_MONO16
VIDEO_MODE_1280x960_MONO16 = DC1394_VIDEO_MODE_1280x960_MONO16
VIDEO_MODE_1600x1200_MONO8 = DC1394_VIDEO_MODE_1600x1200_MONO8
VIDEO_MODE_1024x768_MONO16 = DC1394_VIDEO_MODE_1024x768_MONO16
VIDEO_MODE_800x600_MONO16 = DC1394_VIDEO_MODE_800x600_MONO16
VIDEO_MODE_640x480_MONO16 = DC1394_VIDEO_MODE_640x480_MONO16
FRAMERATE_1_875 = DC1394_FRAMERATE_1_875
FRAMERATE_3_75 = DC1394_FRAMERATE_3_75
FRAMERATE_7_5 = DC1394_FRAMERATE_7_5
FRAMERATE_15 = DC1394_FRAMERATE_15
FRAMERATE_30 = DC1394_FRAMERATE_30
FRAMERATE_60 = DC1394_FRAMERATE_60
FRAMERATE_120 = DC1394_FRAMERATE_120
FRAMERATE_240 = DC1394_FRAMERATE_240
cdef list DC1394ISOSpeedTable = [
DC1394_ISO_SPEED_100,
DC1394_ISO_SPEED_200,
DC1394_ISO_SPEED_400,
DC1394_ISO_SPEED_800,
DC1394_ISO_SPEED_1600,
DC1394_ISO_SPEED_3200 ]
cdef dict DC1394NumpyColorCoding = {
DC1394_COLOR_CODING_MONO8 : np.uint8(),
DC1394_COLOR_CODING_YUV411 : np.uint8(),
DC1394_COLOR_CODING_YUV422 : np.uint8(),
DC1394_COLOR_CODING_YUV444 : np.uint8(),
DC1394_COLOR_CODING_RGB8 : np.dtype([("R", np.uint8), ("G", np.uint8), ("B", np.uint8)]),
DC1394_COLOR_CODING_MONO16 : np.uint16(),
DC1394_COLOR_CODING_RGB16 : np.dtype([("R", np.uint16), ("G", np.uint16), ("B", np.uint16)]),
DC1394_COLOR_CODING_MONO16S : np.int16(),
DC1394_COLOR_CODING_RGB16S : np.int16(),
DC1394_COLOR_CODING_RAW8 : np.uint8(),
DC1394_COLOR_CODING_RAW16 : np.uint16(),
}
cdef dict DC1394NumpyColorCoding2 = {
DC1394_COLOR_CODING_MONO8 : ("u8", 1),
DC1394_COLOR_CODING_YUV411 : ("u8", 1),
DC1394_COLOR_CODING_YUV422 : ("u8", 1),
DC1394_COLOR_CODING_YUV444 : ("u8", 1),
DC1394_COLOR_CODING_RGB8 : ("u8", 3),
DC1394_COLOR_CODING_MONO16 : ("u16", 1),
DC1394_COLOR_CODING_RGB16 : ("u16", 3),
DC1394_COLOR_CODING_MONO16S : ("i16", 1),
DC1394_COLOR_CODING_RGB16S : ("i16", 3),
DC1394_COLOR_CODING_RAW8 : ("u8", 1),
DC1394_COLOR_CODING_RAW16 : ("u16", 1),
}
class DC1394Error(Exception): pass
cdef inline int DC1394SafeCall(dc1394error_t error) except -1:
cdef const_char_ptr errstr
cdef int return_value = 0
if DC1394_SUCCESS != error:
errstr = dc1394_error_get_string(error)
raise DC1394Error(errstr)
return_value = -1
return return_value
cdef inline dict __dc1394_array_interface__(dc1394video_frame_t *frame):
cdef str dtype
cdef uint8_t nbytes
(dtype, nbytes) = DC1394NumpyColorCoding2[frame.color_coding]
cdef str endianess = ">%s" % dtype
if (frame.little_endian == DC1394_TRUE):
endianess = "%s%s" % ("<", dtype)
return dict(data = <np.intp_t>frame.image,
shape = (frame.size[1], frame.size[0], nbytes),
strides = (frame.stride, nbytes, 1),
version = 3,
typestr = endianess)
cdef class FrameObject(object):
def __init__(self,interface):
self.__array_interface__ = interface
cdef class DC1394Context(object):
"""
This object represent a DC1394 context which is needed for further calling
of dc1394 function
"""
cdef dc1394_t *dc1394
def __cinit__(self):
self.dc1394 = dc1394_new()
def __dealloc__(self):
dc1394_free(self.dc1394)
def __get_number_of_devices__(self):
cdef dc1394camera_list_t *camera_list
DC1394SafeCall(dc1394_camera_enumerate(self.dc1394, &camera_list))
return camera_list.num
numberOfDevices = property(__get_number_of_devices__)
cpdef list enumerateCameras(self):
cdef dc1394camera_list_t *camera_lst
cdef list return_value
DC1394SafeCall(dc1394_camera_enumerate(self.dc1394, &camera_lst))
return_value = [camera_lst.ids[i] for i in xrange(camera_lst.num)]
dc1394_camera_free_list(camera_lst)
return return_value
cpdef createCamera(self, unsigned int cid):
cdef dict camdesc = self.enumerateCameras()[cid]
return DC1394Camera(self, camdesc['guid'], unit = camdesc['unit'])
cdef class DC1394Camera(object):
cdef dc1394camera_t *cam
cdef DC1394Context ctx
cdef dict available_modes
cdef bint stop_event
cdef bint running
cdef object __grab_event__
cdef object __init_event__
cdef object __stop_event__
cdef object capture_loop
cdef dict available_features
cdef dict unavailable_features
def __dealloc__(self):
dc1394_camera_free(self.cam)
def __cinit__(self, DC1394Context ctx, uint64_t guid, int unit = -1):
self.ctx = ctx
if unit != -1:
self.cam = dc1394_camera_new_unit(ctx.dc1394, guid, unit)
else:
self.cam = dc1394_camera_new(ctx.dc1394, guid);
self.populate_capabilities()
try:
self.operationMode = DC1394_OPERATION_MODE_1394B
self.isoSpeed = DC1394_ISO_SPEED_800
except DC1394Error, e:
self.operationMode = DC1394_OPERATION_MODE_LEGACY
self.isoSpeed = DC1394_ISO_SPEED_400
self.populate_capabilities()
self.running = False
self.stop_event = False
self.__grab_event__ = events.Event()
self.__init_event__ = events.Event()
self.__stop_event__ = events.Event()
def start(self):
if (self.running):
raise RuntimeError("Camera Already Running")
self.power = True
self.stop_event = False
self.capture_loop = threading.Thread(target = self.run, name = "DC1394 capture loop")
self.capture_loop.start()
def run(self):
self.__init_event__()
DC1394SafeCall(dc1394_capture_setup(self.cam, 10, DC1394_CAPTURE_FLAGS_DEFAULT))
self.transmission = DC1394_ON
self.running = True
cdef dc1394video_frame_t *frame
cdef dc1394error_t err
selectlist = [self.fileno]
dc1394_capture_dequeue(self.cam, DC1394_CAPTURE_POLICY_WAIT, &frame)
dtype = DC1394NumpyColorCoding[frame.color_coding]
cdef np.ndarray[np.uint8_t, ndim=3, mode="c"] arr = np.ndarray(shape=(frame.size[1], frame.size[0], dtype.itemsize) , dtype=np.uint8 )
cdef object nparr = arr
cdef char *orig_ptr = arr.data
cdef np.dtype orig_dtype = arr.dtype
arr.dtype = dtype
nparr.shape = (frame.size[1], frame.size[0])
selectlist = [self.fileno]
while not self.stop_event:
rlist, wlist, xlist = select.select(selectlist, [], [], 1)
if len(rlist) == 0:
continue
err = dc1394_capture_dequeue(self.cam, DC1394_CAPTURE_POLICY_POLL, &frame)
if err != DC1394_SUCCESS:
continue
arr.data = <char *>frame.image
self.__grab_event__(arr, frame.timestamp)
dc1394_capture_enqueue(self.cam, frame)
arr.data = orig_ptr
arr.dtype = orig_dtype
self.transmission = DC1394_OFF
DC1394SafeCall(dc1394_capture_stop(self.cam))
self.running = False
self.__stop_event__()
def stop(self, join = True):
self.stop_event = True
if join:
self.capture_loop.join()
self.power = False
cdef void populate_capabilities(self):
cdef dc1394video_modes_t modes
cdef dc1394framerates_t framerates
cdef float framerate
self.available_features = {}
self.unavailable_features = {}
self.available_modes = {}
DC1394SafeCall(dc1394_video_get_supported_modes(self.cam, &modes))
for m in [modes.modes[i] for i in xrange(modes.num)]:
DC1394SafeCall(dc1394_video_get_supported_framerates (self.cam, m, &framerates))
fmlist = []
for j from 0 <= j < framerates.num:
fmlist.append(framerates.framerates[j])
self.available_modes[m] = fmlist
cdef dc1394featureset_t featureset
DC1394SafeCall(dc1394_feature_get_all(self.cam, &featureset))
cdef dc1394feature_info_t featureinfo
for i from 0 < i < DC1394_FEATURE_NUM:
featureinfo = featureset.feature[i]
if (featureinfo.available == DC1394_TRUE):
self.available_features[featureinfo.id] = featureinfo
property initEvent:
def __get__(self):
return self.__init_event__
property stopEvent:
def __get__(self):
return self.__stop_event__
property fileno:
def __get__(self):
return dc1394_capture_get_fileno(self.cam)
# -------------------------------------------------------------------------
def __repr__(self):
return '<DC1394Camera vendor="%s" model="%s"/>' % (self.cam.vendor, self.cam.model)
# -------------------------------------------------------------------------
property grabEvent:
def __get__(self):
return self.__grab_event__
# -------------------------------------------------------------------------
property bandwitdh:
def __get__(self):
cdef uint32_t bandwidth
DC1394SafeCall(dc1394_video_get_bandwidth_usage(self.cam, &bandwidth))
return bandwidth
# -------------------------------------------------------------------------
property multishot:
def __get__(self):
cdef dc1394bool_t pwr
cdef uint32_t frames
DC1394SafeCall(dc1394_video_get_multi_shot(self.cam, &pwr, &frames))
return frames if (pwr == DC1394_TRUE) else 0
def __set__(self, uint32_t frames):
cdef dc1394bool_t pwr = DC1394_TRUE if (frames > 0) else DC1394_FALSE
DC1394SafeCall(dc1394_video_set_multi_shot(self.cam, frames, pwr))
# -------------------------------------------------------------------------
property brightness:
def __get__(self):
if DC1394_FEATURE_BRIGHTNESS not in self.available_features:
raise DC1394Error("[brightness] not available")
feature = self.available_features[DC1394_FEATURE_BRIGHTNESS]
cdef uint32_t value
dc1394_feature_get_value(self.cam, DC1394_FEATURE_BRIGHTNESS, &value)
return value
def __set__(self, uint32_t value):
if DC1394_FEATURE_BRIGHTNESS not in self.available_features:
raise DC1394Error("[brightness not available")
feature = self.available_features[DC1394_FEATURE_BRIGHTNESS]
if feature['current_mode'] == DC1394_FEATURE_MODE_AUTO:
raise DC1394Error("[brightness] Currently In Auto Mode")
if value < feature['min'] or value > feature['max']:
raise DC1394Error("[brightness] value out of range")
DC1394SafeCall(dc1394_feature_set_value(self.cam, DC1394_FEATURE_BRIGHTNESS, value))
# -------------------------------------------------------------------------
property exposure:
def __get__(self):
if DC1394_FEATURE_EXPOSURE not in self.available_features:
raise DC1394Error("[exposure] not available")
feature = self.available_features[DC1394_FEATURE_EXPOSURE]
cdef uint32_t value
dc1394_feature_get_value(self.cam, DC1394_FEATURE_EXPOSURE, &value)
return value
def __set__(self, uint32_t value):
if DC1394_FEATURE_EXPOSURE not in self.available_features:
raise DC1394Error("[exposure not available")
feature = self.available_features[DC1394_FEATURE_EXPOSURE]
if feature['current_mode'] == DC1394_FEATURE_MODE_AUTO:
raise DC1394Error("[exposure] Currently In Auto Mode")
if value < feature['min'] or value > feature['max']:
raise DC1394Error("[exposure] value out of range")
DC1394SafeCall(dc1394_feature_set_value(self.cam, DC1394_FEATURE_EXPOSURE, value))
# -------------------------------------------------------------------------
property sharpness:
def __get__(self):
if DC1394_FEATURE_SHARPNESS not in self.available_features:
raise DC1394Error("[sharpness] not available")
feature = self.available_features[DC1394_FEATURE_SHARPNESS]
cdef uint32_t value
dc1394_feature_get_value(self.cam, DC1394_FEATURE_SHARPNESS, &value)
return value
def __set__(self, uint32_t value):
if DC1394_FEATURE_SHARPNESS not in self.available_features:
raise DC1394Error("[sharpness not available")
feature = self.available_features[DC1394_FEATURE_SHARPNESS]
if feature['current_mode'] == DC1394_FEATURE_MODE_AUTO:
raise DC1394Error("[sharpness] Currently In Auto Mode")
if value < feature['min'] or value > feature['max']:
raise DC1394Error("[sharpness] value out of range")
DC1394SafeCall(dc1394_feature_set_value(self.cam, DC1394_FEATURE_SHARPNESS, value))
# -------------------------------------------------------------------------
property whiteBalance:
def __get__(self):
if DC1394_FEATURE_WHITE_BALANCE not in self.available_features:
raise DC1394Error("[whiteBalance] not available")
feature = self.available_features[DC1394_FEATURE_WHITE_BALANCE]
cdef uint32_t value
dc1394_feature_get_value(self.cam, DC1394_FEATURE_WHITE_BALANCE, &value)
return value
def __set__(self, uint32_t value):
if DC1394_FEATURE_WHITE_BALANCE not in self.available_features:
raise DC1394Error("[whiteBalance not available")
feature = self.available_features[DC1394_FEATURE_WHITE_BALANCE]
if feature['current_mode'] == DC1394_FEATURE_MODE_AUTO:
raise DC1394Error("[whiteBalance] Currently In Auto Mode")
if value < feature['min'] or value > feature['max']:
raise DC1394Error("[whiteBalance] value out of range")
DC1394SafeCall(dc1394_feature_set_value(self.cam, DC1394_FEATURE_WHITE_BALANCE, value))
# -------------------------------------------------------------------------
property hue:
def __get__(self):
if DC1394_FEATURE_HUE not in self.available_features:
raise DC1394Error("[hue] not available")
feature = self.available_features[DC1394_FEATURE_HUE]
cdef uint32_t value
dc1394_feature_get_value(self.cam, DC1394_FEATURE_HUE, &value)
return value
def __set__(self, uint32_t value):
if DC1394_FEATURE_HUE not in self.available_features:
raise DC1394Error("[hue not available")
feature = self.available_features[DC1394_FEATURE_HUE]
if feature['current_mode'] == DC1394_FEATURE_MODE_AUTO:
raise DC1394Error("[hue] Currently In Auto Mode")
if value < feature['min'] or value > feature['max']:
raise DC1394Error("[hue] value out of range")
DC1394SafeCall(dc1394_feature_set_value(self.cam, DC1394_FEATURE_HUE, value))
# -------------------------------------------------------------------------
property saturation:
def __get__(self):
if DC1394_FEATURE_SATURATION not in self.available_features:
raise DC1394Error("[saturation] not available")
feature = self.available_features[DC1394_FEATURE_SATURATION]
cdef uint32_t value
dc1394_feature_get_value(self.cam, DC1394_FEATURE_SATURATION, &value)
return value
def __set__(self, uint32_t value):
if DC1394_FEATURE_SATURATION not in self.available_features:
raise DC1394Error("[saturation not available")
feature = self.available_features[DC1394_FEATURE_SATURATION]
if feature['current_mode'] == DC1394_FEATURE_MODE_AUTO:
raise DC1394Error("[saturation] Currently In Auto Mode")
if value < feature['min'] or value > feature['max']:
raise DC1394Error("[saturation] value out of range")
DC1394SafeCall(dc1394_feature_set_value(self.cam, DC1394_FEATURE_SATURATION, value))
# -------------------------------------------------------------------------
property gamma:
def __get__(self):
if DC1394_FEATURE_GAMMA not in self.available_features:
raise DC1394Error("[gamma] not available")
feature = self.available_features[DC1394_FEATURE_GAMMA]
cdef uint32_t value
dc1394_feature_get_value(self.cam, DC1394_FEATURE_GAMMA, &value)
return value
def __set__(self, uint32_t value):
if DC1394_FEATURE_GAMMA not in self.available_features:
raise DC1394Error("[gamma not available")
feature = self.available_features[DC1394_FEATURE_GAMMA]
if feature['current_mode'] == DC1394_FEATURE_MODE_AUTO:
raise DC1394Error("[gamma] Currently In Auto Mode")
if value < feature['min'] or value > feature['max']:
raise DC1394Error("[gamma] value out of range")
DC1394SafeCall(dc1394_feature_set_value(self.cam, DC1394_FEATURE_GAMMA, value))
# -------------------------------------------------------------------------
property shutter:
def __get__(self):
if DC1394_FEATURE_SHUTTER not in self.available_features:
raise DC1394Error("[shutter] not available")
feature = self.available_features[DC1394_FEATURE_SHUTTER]
cdef uint32_t value
dc1394_feature_get_value(self.cam, DC1394_FEATURE_SHUTTER, &value)
return value
def __set__(self, uint32_t value):
if DC1394_FEATURE_SHUTTER not in self.available_features:
raise DC1394Error("[shutter not available")
feature = self.available_features[DC1394_FEATURE_SHUTTER]
if feature['current_mode'] == DC1394_FEATURE_MODE_AUTO:
raise DC1394Error("[shutter] Currently In Auto Mode")
if value < feature['min'] or value > feature['max']:
raise DC1394Error("[shutter] value out of range")
DC1394SafeCall(dc1394_feature_set_value(self.cam, DC1394_FEATURE_SHUTTER, value))
# -------------------------------------------------------------------------
property gain:
def __get__(self):
if DC1394_FEATURE_GAIN not in self.available_features:
raise DC1394Error("[gain] not available")
feature = self.available_features[DC1394_FEATURE_GAIN]
cdef uint32_t value
dc1394_feature_get_value(self.cam, DC1394_FEATURE_GAIN, &value)
return value
def __set__(self, uint32_t value):
if DC1394_FEATURE_GAIN not in self.available_features:
raise DC1394Error("[gain not available")
feature = self.available_features[DC1394_FEATURE_GAIN]
if feature['current_mode'] == DC1394_FEATURE_MODE_AUTO:
raise DC1394Error("[gain] Currently In Auto Mode")
if value < feature['min'] or value > feature['max']:
raise DC1394Error("[gain] value out of range")
DC1394SafeCall(dc1394_feature_set_value(self.cam, DC1394_FEATURE_GAIN, value))
# -------------------------------------------------------------------------
property iris:
def __get__(self):
if DC1394_FEATURE_IRIS not in self.available_features:
raise DC1394Error("[iris] not available")
feature = self.available_features[DC1394_FEATURE_IRIS]
cdef uint32_t value
dc1394_feature_get_value(self.cam, DC1394_FEATURE_IRIS, &value)
return value
def __set__(self, uint32_t value):
if DC1394_FEATURE_IRIS not in self.available_features:
raise DC1394Error("[iris not available")
feature = self.available_features[DC1394_FEATURE_IRIS]
if feature['current_mode'] == DC1394_FEATURE_MODE_AUTO:
raise DC1394Error("[iris] Currently In Auto Mode")
if value < feature['min'] or value > feature['max']:
raise DC1394Error("[iris] value out of range")
DC1394SafeCall(dc1394_feature_set_value(self.cam, DC1394_FEATURE_IRIS, value))
# -------------------------------------------------------------------------
property focus:
def __get__(self):
if DC1394_FEATURE_FOCUS not in self.available_features:
raise DC1394Error("[focus] not available")
feature = self.available_features[DC1394_FEATURE_FOCUS]
cdef uint32_t value
dc1394_feature_get_value(self.cam, DC1394_FEATURE_FOCUS, &value)
return value
def __set__(self, uint32_t value):
if DC1394_FEATURE_FOCUS not in self.available_features:
raise DC1394Error("[focus not available")
feature = self.available_features[DC1394_FEATURE_FOCUS]
if feature['current_mode'] == DC1394_FEATURE_MODE_AUTO:
raise DC1394Error("[focus] Currently In Auto Mode")
if value < feature['min'] or value > feature['max']:
raise DC1394Error("[focus] value out of range")
DC1394SafeCall(dc1394_feature_set_value(self.cam, DC1394_FEATURE_FOCUS, value))
# -------------------------------------------------------------------------
property temperature:
def __get__(self):
if DC1394_FEATURE_TEMPERATURE not in self.available_features:
raise DC1394Error("[temperature] not available")
feature = self.available_features[DC1394_FEATURE_TEMPERATURE]
cdef uint32_t value
dc1394_feature_get_value(self.cam, DC1394_FEATURE_TEMPERATURE, &value)
return value
def __set__(self, uint32_t value):
if DC1394_FEATURE_TEMPERATURE not in self.available_features:
raise DC1394Error("[temperature not available")
feature = self.available_features[DC1394_FEATURE_TEMPERATURE]
if feature['current_mode'] == DC1394_FEATURE_MODE_AUTO:
raise DC1394Error("[temperature] Currently In Auto Mode")
if value < feature['min'] or value > feature['max']:
raise DC1394Error("[temperature] value out of range")
DC1394SafeCall(dc1394_feature_set_value(self.cam, DC1394_FEATURE_TEMPERATURE, value))
# -------------------------------------------------------------------------
property trigger:
def __get__(self):
if DC1394_FEATURE_TRIGGER not in self.available_features:
raise DC1394Error("[trigger] not available")
feature = self.available_features[DC1394_FEATURE_TRIGGER]
cdef uint32_t value
dc1394_feature_get_value(self.cam, DC1394_FEATURE_TRIGGER, &value)
return value
def __set__(self, uint32_t value):
if DC1394_FEATURE_TRIGGER not in self.available_features:
raise DC1394Error("[trigger not available")
feature = self.available_features[DC1394_FEATURE_TRIGGER]
if feature['current_mode'] == DC1394_FEATURE_MODE_AUTO:
raise DC1394Error("[trigger] Currently In Auto Mode")
if value < feature['min'] or value > feature['max']:
raise DC1394Error("[trigger] value out of range")
DC1394SafeCall(dc1394_feature_set_value(self.cam, DC1394_FEATURE_TRIGGER, value))
# -------------------------------------------------------------------------
property triggerDelay:
def __get__(self):
if DC1394_FEATURE_TRIGGER_DELAY not in self.available_features:
raise DC1394Error("[triggerDelay] not available")
feature = self.available_features[DC1394_FEATURE_TRIGGER_DELAY]
cdef uint32_t value
dc1394_feature_get_value(self.cam, DC1394_FEATURE_TRIGGER_DELAY, &value)
return value
def __set__(self, uint32_t value):
if DC1394_FEATURE_TRIGGER_DELAY not in self.available_features:
raise DC1394Error("[triggerDelay not available")
feature = self.available_features[DC1394_FEATURE_TRIGGER_DELAY]
if feature['current_mode'] == DC1394_FEATURE_MODE_AUTO:
raise DC1394Error("[triggerDelay] Currently In Auto Mode")
if value < feature['min'] or value > feature['max']:
raise DC1394Error("[triggerDelay] value out of range")
DC1394SafeCall(dc1394_feature_set_value(self.cam, DC1394_FEATURE_TRIGGER_DELAY, value))
# -------------------------------------------------------------------------
property whiteShading:
def __get__(self):
if DC1394_FEATURE_WHITE_SHADING not in self.available_features:
raise DC1394Error("[whiteShading] not available")
feature = self.available_features[DC1394_FEATURE_WHITE_SHADING]
cdef uint32_t value
dc1394_feature_get_value(self.cam, DC1394_FEATURE_WHITE_SHADING, &value)
return value
def __set__(self, uint32_t value):
if DC1394_FEATURE_WHITE_SHADING not in self.available_features:
raise DC1394Error("[whiteShading not available")
feature = self.available_features[DC1394_FEATURE_WHITE_SHADING]
if feature['current_mode'] == DC1394_FEATURE_MODE_AUTO:
raise DC1394Error("[whiteShading] Currently In Auto Mode")
if value < feature['min'] or value > feature['max']:
raise DC1394Error("[whiteShading] value out of range")
DC1394SafeCall(dc1394_feature_set_value(self.cam, DC1394_FEATURE_WHITE_SHADING, value))
# -------------------------------------------------------------------------
property frameRate:
def __get__(self):
if DC1394_FEATURE_FRAME_RATE not in self.available_features:
raise DC1394Error("[frameRate] not available")
feature = self.available_features[DC1394_FEATURE_FRAME_RATE]
cdef uint32_t value
dc1394_feature_get_value(self.cam, DC1394_FEATURE_FRAME_RATE, &value)
return value
def __set__(self, uint32_t value):
if DC1394_FEATURE_FRAME_RATE not in self.available_features:
raise DC1394Error("[frameRate not available")
feature = self.available_features[DC1394_FEATURE_FRAME_RATE]
if feature['current_mode'] == DC1394_FEATURE_MODE_AUTO:
raise DC1394Error("[frameRate] Currently In Auto Mode")
if value < feature['min'] or value > feature['max']:
raise DC1394Error("[frameRate] value out of range")
DC1394SafeCall(dc1394_feature_set_value(self.cam, DC1394_FEATURE_FRAME_RATE, value))
# -------------------------------------------------------------------------
property zoom:
def __get__(self):
if DC1394_FEATURE_ZOOM not in self.available_features:
raise DC1394Error("[zoom] not available")
feature = self.available_features[DC1394_FEATURE_ZOOM]
cdef uint32_t value
dc1394_feature_get_value(self.cam, DC1394_FEATURE_ZOOM, &value)
return value
def __set__(self, uint32_t value):
if DC1394_FEATURE_ZOOM not in self.available_features:
raise DC1394Error("[zoom not available")
feature = self.available_features[DC1394_FEATURE_ZOOM]
if feature['current_mode'] == DC1394_FEATURE_MODE_AUTO:
raise DC1394Error("[zoom] Currently In Auto Mode")
if value < feature['min'] or value > feature['max']:
raise DC1394Error("[zoom] value out of range")
DC1394SafeCall(dc1394_feature_set_value(self.cam, DC1394_FEATURE_ZOOM, value))
# -------------------------------------------------------------------------
property pan:
def __get__(self):
if DC1394_FEATURE_PAN not in self.available_features:
raise DC1394Error("[pan] not available")
feature = self.available_features[DC1394_FEATURE_PAN]
cdef uint32_t value
dc1394_feature_get_value(self.cam, DC1394_FEATURE_PAN, &value)
return value
def __set__(self, uint32_t value):
if DC1394_FEATURE_PAN not in self.available_features:
raise DC1394Error("[pan not available")
feature = self.available_features[DC1394_FEATURE_PAN]
if feature['current_mode'] == DC1394_FEATURE_MODE_AUTO:
raise DC1394Error("[pan] Currently In Auto Mode")
if value < feature['min'] or value > feature['max']:
raise DC1394Error("[pan] value out of range")
DC1394SafeCall(dc1394_feature_set_value(self.cam, DC1394_FEATURE_PAN, value))
# -------------------------------------------------------------------------
property tilt:
def __get__(self):
if DC1394_FEATURE_TILT not in self.available_features:
raise DC1394Error("[tilt] not available")
feature = self.available_features[DC1394_FEATURE_TILT]
cdef uint32_t value
dc1394_feature_get_value(self.cam, DC1394_FEATURE_TILT, &value)
return value
def __set__(self, uint32_t value):
if DC1394_FEATURE_TILT not in self.available_features:
raise DC1394Error("[tilt not available")
feature = self.available_features[DC1394_FEATURE_TILT]
if feature['current_mode'] == DC1394_FEATURE_MODE_AUTO:
raise DC1394Error("[tilt] Currently In Auto Mode")
if value < feature['min'] or value > feature['max']:
raise DC1394Error("[tilt] value out of range")
DC1394SafeCall(dc1394_feature_set_value(self.cam, DC1394_FEATURE_TILT, value))
# -------------------------------------------------------------------------
property opticalFilter:
def __get__(self):
if DC1394_FEATURE_OPTICAL_FILTER not in self.available_features:
raise DC1394Error("[opticalFilter] not available")
feature = self.available_features[DC1394_FEATURE_OPTICAL_FILTER]
cdef uint32_t value
dc1394_feature_get_value(self.cam, DC1394_FEATURE_OPTICAL_FILTER, &value)
return value
def __set__(self, uint32_t value):
if DC1394_FEATURE_OPTICAL_FILTER not in self.available_features:
raise DC1394Error("[opticalFilter not available")
feature = self.available_features[DC1394_FEATURE_OPTICAL_FILTER]
if feature['current_mode'] == DC1394_FEATURE_MODE_AUTO:
raise DC1394Error("[opticalFilter] Currently In Auto Mode")
if value < feature['min'] or value > feature['max']:
raise DC1394Error("[opticalFilter] value out of range")
DC1394SafeCall(dc1394_feature_set_value(self.cam, DC1394_FEATURE_OPTICAL_FILTER, value))
# -------------------------------------------------------------------------
property captureSize:
def __get__(self):
if DC1394_FEATURE_CAPTURE_SIZE not in self.available_features:
raise DC1394Error("[captureSize] not available")
feature = self.available_features[DC1394_FEATURE_CAPTURE_SIZE]
cdef uint32_t value
dc1394_feature_get_value(self.cam, DC1394_FEATURE_CAPTURE_SIZE, &value)
return value
def __set__(self, uint32_t value):
if DC1394_FEATURE_CAPTURE_SIZE not in self.available_features:
raise DC1394Error("[captureSize not available")
feature = self.available_features[DC1394_FEATURE_CAPTURE_SIZE]
if feature['current_mode'] == DC1394_FEATURE_MODE_AUTO:
raise DC1394Error("[captureSize] Currently In Auto Mode")
if value < feature['min'] or value > feature['max']:
raise DC1394Error("[captureSize] value out of range")
DC1394SafeCall(dc1394_feature_set_value(self.cam, DC1394_FEATURE_CAPTURE_SIZE, value))
# -------------------------------------------------------------------------
property captureQuality:
def __get__(self):
if DC1394_FEATURE_CAPTURE_QUALITY not in self.available_features:
raise DC1394Error("[captureQuality] not available")
feature = self.available_features[DC1394_FEATURE_CAPTURE_QUALITY]
cdef uint32_t value
dc1394_feature_get_value(self.cam, DC1394_FEATURE_CAPTURE_QUALITY, &value)
return value
def __set__(self, uint32_t value):
if DC1394_FEATURE_CAPTURE_QUALITY not in self.available_features:
raise DC1394Error("[captureQuality not available")
feature = self.available_features[DC1394_FEATURE_CAPTURE_QUALITY]
if feature['current_mode'] == DC1394_FEATURE_MODE_AUTO:
raise DC1394Error("[captureQuality] Currently In Auto Mode")
if value < feature['min'] or value > feature['max']:
raise DC1394Error("[captureQuality] value out of range")
DC1394SafeCall(dc1394_feature_set_value(self.cam, DC1394_FEATURE_CAPTURE_QUALITY, value))
# -------------------------------------------------------------------------
property oneshot:
def __get__(self):
cdef dc1394bool_t pwr
DC1394SafeCall(dc1394_video_get_one_shot(self.cam, &pwr))
return (pwr == DC1394_TRUE)
def __set__(self, bint flag):
cdef dc1394bool_t pwr = DC1394_TRUE if flag else DC1394_TRUE
DC1394SafeCall(dc1394_video_set_one_shot(self.cam, pwr))
# -------------------------------------------------------------------------
property availableFramerates:
def __get__(self):
cdef float framerate
cdef dict framerates = {}
for f in self.available_modes[self.mode]:
dc1394_framerate_as_float(f, &framerate)
framerates[f] = framerate
return framerates
# -------------------------------------------------------------------------
property availableModes:
def __get__(self):
return self.available_modes
# -------------------------------------------------------------------------
property mode:
def __get__(self):
cdef dc1394video_mode_t mode
DC1394SafeCall(dc1394_video_get_mode(self.cam, &mode))
return mode
def __set__(self, dc1394video_mode_t mode):
DC1394SafeCall(dc1394_video_set_mode(self.cam, mode))
# -------------------------------------------------------------------------
property framerate:
def __get__(self):
cdef dc1394framerate_t framerate
DC1394SafeCall(dc1394_video_get_framerate(self.cam, &framerate))
return framerate
def __set__(self, dc1394framerate_t framerate):
DC1394SafeCall(dc1394_video_set_framerate(self.cam, framerate))
# -------------------------------------------------------------------------
property isoSpeed:
def __get__(self):
cdef dc1394speed_t speed
DC1394SafeCall(dc1394_video_get_iso_speed(self.cam, &speed))
return speed
def __set__(self, dc1394speed_t speed):
DC1394SafeCall(dc1394_video_set_iso_speed(self.cam, speed))
# -------------------------------------------------------------------------
property operationMode:
def __get__(self):
cdef dc1394operation_mode_t mode
DC1394SafeCall(dc1394_video_get_operation_mode(self.cam, &mode))
return mode
def __set__(self, dc1394operation_mode_t mode):
DC1394SafeCall(dc1394_video_set_operation_mode(self.cam, mode))
# -------------------------------------------------------------------------
property transmission:
def __set__(self, dc1394switch_t trans):