-
Notifications
You must be signed in to change notification settings - Fork 901
/
streameyectl.py
1221 lines (1008 loc) · 32.1 KB
/
streameyectl.py
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
# Copyright (c) 2015 Calin Crisan
# This file is part of motionEyeOS.
#
# motionEyeOS is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import config
import hashlib
import logging
import os.path
import re
from tornado.ioloop import IOLoop
import settings
from config import additional_config
MOTIONEYE_CONF = '/data/etc/motioneye.conf'
RASPIMJPEG_CONF = '/data/etc/raspimjpeg.conf'
STREAMEYE_CONF = '/data/etc/streameye.conf'
EXPOSURE_CHOICES = [
('off', 'Off'),
('auto', 'Auto'),
('night', 'Night'),
('nightpreview', 'Night Preview'),
('backlight', 'Backlight'),
('spotlight', 'Spotlight'),
('sports', 'Sports'),
('snow', 'Snow'),
('beach', 'Beach'),
('verylong', 'Very Long'),
('fixedfps', 'Fixed FPS'),
('antishake', 'Antishake'),
('fireworks', 'Fireworks')
]
AWB_CHOICES = [
('off', 'Off'),
('auto', 'Auto'),
('sunlight', 'Sunlight'),
('cloudy', 'Cloudy'),
('shade', 'Shade'),
('tungsten', 'Tungsten'),
('fluorescent', 'Fluorescent'),
('incandescent', 'Incandescent'),
('flash', 'Flash'),
('horizon', 'Horizon'),
('greyworld', 'Greyworld')
]
METERING_CHOICES = [
('average', 'Average'),
('spot', 'Spot'),
('backlit', 'Backlit'),
('matrix', 'Matrix')
]
DRC_CHOICES = [
('off', 'Off'),
('low', 'Low'),
('medium', 'Medium'),
('high', 'High')
]
IMXFX_CHOICES = [
('none', 'None'),
('negative', 'Negative'),
('solarize', 'Solarize'),
('sketch', 'Sketch'),
('denoise', 'Denoise'),
('emboss', 'Emboss'),
('oilpaint', 'Oilpaint'),
('hatch', 'Hatch'),
('gpen', 'G Pen'),
('pastel', 'Pastel'),
('watercolor', 'Water Color'),
('film', 'Film'),
('blur', 'Blur'),
('saturation', 'Saturation'),
('colorswap', 'Color Swap'),
('washedout', 'Washed Out'),
('posterise', 'Posterize'),
('colorpoint', 'Color Point'),
('colorbalance', 'Color Balance'),
('cartoon', 'Cartoon'),
('deinterlace1', 'Deinterlace 1'),
('deinterlace2', 'Deinterlace 2')
]
RESOLUTION_CHOICES = [
('320x200', '320x200'),
('320x240', '320x240'),
('640x480', '640x480'),
('800x480', '800x480'),
('800x600', '800x600'),
('1024x576', '1024x576'),
('1024x768', '1024x768'),
('1280x720', '1280x720'),
('1280x800', '1280x800'),
('1280x960', '1280x960'),
('1280x1024', '1280x1024'),
('1296x972', '1296x972'),
('1440x960', '1440x960'),
('1440x1024', '1440x1024'),
('1600x1200', '1600x1200'),
('1640x922', '1640x922'),
('1640x1232', '1640x1232'),
('1920x1080', '1920x1080'),
('2592x1944', '2592x1944'),
('3280x2464', '3280x2464')
]
ROTATION_CHOICES = [
('0', '0°'),
('90', '90°'),
('180', '180°'),
('270', '270°')
]
PROTO_CHOICES = [
('mjpeg', 'MJPEG'),
('rtsp', 'RTSP'),
]
AUTH_CHOICES = [
('disabled', 'Disabled'),
('basic', 'Basic'),
]
_streameye_enabled = None
def _get_streameye_enabled():
global _streameye_enabled
if _streameye_enabled is not None:
return _streameye_enabled
camera_ids = config.get_camera_ids(filter_valid=False) # filter_valid prevents infinte recursion
if len(camera_ids) != 1:
_streameye_enabled = False
return False
camera_config = config.get_camera(camera_ids[0], as_lines=True) # as_lines prevents infinte recursion
camera_config = config._conf_to_dict(camera_config)
if camera_config.get('@proto') != 'mjpeg':
_streameye_enabled = False
return False
if '127.0.0.1:' not in camera_config.get('@url', ''):
_streameye_enabled = False
return False
_streameye_enabled = True
return True
def _set_streameye_enabled_deferred(enabled):
was_enabled = _get_streameye_enabled()
if enabled and not was_enabled:
io_loop = IOLoop.instance()
io_loop.add_callback(_set_streameye_enabled, True)
elif not enabled and was_enabled:
io_loop = IOLoop.instance()
io_loop.add_callback(_set_streameye_enabled, False)
if enabled:
# this will force updating streameye settings whenever the surveillance credentials are changed
streameye_settings = _get_streameye_settings(1)
_set_streameye_settings(1, streameye_settings)
def _set_streameye_enabled(enabled):
global _streameye_enabled
if enabled:
logging.debug('removing all cameras from cache')
config._camera_config_cache = {}
config._camera_ids_cache = []
logging.debug('disabling all cameras in motion.conf')
cmd = 'sed -r -i "s/^camera (.*)/#camera \\1/" /data/etc/motion.conf &>/dev/null'
if os.system(cmd):
logging.error('failed to disable cameras in motion.conf')
logging.debug('renaming camera files')
for name in os.listdir(settings.CONF_PATH):
if re.match('^camera-\d+.conf$', name):
os.rename(os.path.join(settings.CONF_PATH, name), os.path.join(settings.CONF_PATH, name + '.bak'))
logging.debug('adding simple mjpeg camera')
streameye_settings = _get_streameye_settings(1)
main_config = config.get_main()
device_details = {
'proto': 'mjpeg',
'host': '127.0.0.1',
'port': streameye_settings['sePort'],
'username': '',
'password': '',
'scheme': 'http',
'path': '/'
}
if streameye_settings['seAuthMode'] == 'basic':
device_details['username'] = main_config['@normal_username']
device_details['password'] = main_config['@normal_password']
_streameye_enabled = True
config._additional_structure_cache = {}
camera_config = config.add_camera(device_details)
# call set_camera again so that the streamEye-related defaults are saved
config.set_camera(camera_config['@id'], camera_config)
_set_motioneye_add_remove_cameras(False)
else: # disabled
logging.debug('removing simple mjpeg camera')
for camera_id in config.get_camera_ids():
camera_config = config.get_camera(camera_id)
if camera_config.get('@proto') == 'mjpeg':
config.rem_camera(camera_id)
logging.debug('renaming camera files')
for name in os.listdir(settings.CONF_PATH):
if re.match('^camera-\d+.conf.bak$', name):
os.rename(os.path.join(settings.CONF_PATH, name), os.path.join(settings.CONF_PATH, name[:-4]))
_streameye_enabled = False
config.invalidate()
logging.debug('enabling all cameras')
for camera_id in config.get_camera_ids():
camera_config = config.get_camera(camera_id)
camera_config['@enabled'] = True
config.set_camera(camera_id, camera_config)
_set_motioneye_add_remove_cameras(True)
def _set_motioneye_add_remove_cameras(enabled):
logging.debug('%s motionEye add/remove cameras' % ['disabling', 'enabling'][enabled])
lines = []
found = False
if os.path.exists(MOTIONEYE_CONF):
with open(MOTIONEYE_CONF) as f:
lines = f.readlines()
for i, line in enumerate(lines):
line = line.strip()
if not line:
continue
try:
name, _ = line.split(' ', 2)
except:
continue
name = name.replace('_', '-')
if name == 'add-remove-cameras':
lines[i] = 'add-remove-cameras %s' % str(enabled).lower()
found = True
if not found:
lines.append('add-remove-cameras %s' % str(enabled).lower())
with open(MOTIONEYE_CONF, 'w') as f:
for line in lines:
if not line.strip():
continue
if not line.endswith('\n'):
line += '\n'
f.write(line)
def _get_raspimjpeg_settings(camera_id):
s = {
'preview': False,
'brightness': 50,
'contrast': 0,
'saturation': 0,
'sharpness': 0,
'iso': 400,
'ev': 0,
'shutter': 0,
'exposure': 'auto',
'awb': 'auto',
'metering': 'average',
'drc': 'off',
'vstab': False,
'denoise': False,
'imxfx': 'none',
'width': 640,
'height': 480,
'rotation': 0,
'vflip': False,
'hflip': False,
'framerate': 15,
'quality': 25,
'bitrate': 1000000,
'zoomx': 0,
'zoomy': 0,
'zoomw': 100,
'zoomh': 100
}
if os.path.exists(RASPIMJPEG_CONF):
logging.debug('reading raspimjpeg settings from %s' % RASPIMJPEG_CONF)
with open(RASPIMJPEG_CONF) as f:
for line in f:
line = line.strip()
if not line:
continue
try:
name, value = line.split(' ', 1)
except:
continue
name = name.replace('_', '-')
try:
value = int(value)
except:
pass
if value == 'false':
value = False
elif value == 'true':
value = True
if name == 'zoom':
try:
parts = value.split(',')
s['zoomx'] = int(float(parts[0]) * 100)
s['zoomy'] = int(float(parts[1]) * 100)
s['zoomw'] = int(float(parts[2]) * 100)
s['zoomh'] = int(float(parts[3]) * 100)
except:
logging.error('failed to parse zoom setting "%s"' % value)
continue
s[name] = value
s['contrast'] = (s['contrast'] + 100) / 2
s['saturation'] = (s['saturation'] + 100) / 2
s['sharpness'] = (s['sharpness'] + 100) / 2
s['resolution'] = '%sx%s' % (s.pop('width'), s.pop('height'))
s = dict(('se' + n[0].upper() + n[1:], v) for (n, v) in s.items())
return s
def _set_raspimjpeg_settings(camera_id, s):
s = dict((n[2].lower() + n[3:], v) for (n, v) in s.items())
s['width'] = int(s['resolution'].split('x')[0])
s['height'] = int(s.pop('resolution').split('x')[1])
s['zoom'] = '%.2f,%.2f,%.2f,%.2f' % (
s.pop('zoomx') / 100.0, s.pop('zoomy') / 100.0,
s.pop('zoomw') / 100.0, s.pop('zoomh') / 100.0)
s['contrast'] = s['contrast'] * 2 - 100
s['saturation'] = s['saturation'] * 2 - 100
s['sharpness'] = s['sharpness'] * 2 - 100
logging.debug('writing raspimjpeg settings to %s' % RASPIMJPEG_CONF)
lines = []
for name, value in sorted(s.items(), key=lambda i: i[0]):
if isinstance(value, bool):
value = str(value).lower()
line = '%s %s\n' % (name, value)
lines.append(line)
with open(RASPIMJPEG_CONF, 'w') as f:
for line in lines:
f.write(line)
def _get_streameye_settings(camera_id):
s = {
'seProto': 'mjpeg',
'seAuthMode': 'disabled',
'sePort': 8081,
'seRTSPPort': 554
}
if os.path.exists(STREAMEYE_CONF):
logging.debug('reading streameye settings from %s' % STREAMEYE_CONF)
with open(STREAMEYE_CONF) as f:
for line in f:
line = line.strip()
if not line:
continue
m = re.findall('^PORT="?(\d+)"?', line)
if m:
s['sePort'] = int(m[0])
continue
m = re.findall('^RTSP_PORT="?(\d+)"?', line)
if m:
s['seRTSPPort'] = int(m[0])
continue
m = re.findall('^AUTH="?(\w+)"?', line)
if m:
s['seAuthMode'] = m[0]
m = re.findall('^PROTO="?(\w+)"?', line)
if m:
s['seProto'] = m[0]
return s
def _set_streameye_settings(camera_id, s):
s = dict(s)
s.setdefault('sePort', 8081)
s.setdefault('seRTSPPort', 554)
s.setdefault('seAuthMode', 'disabled')
main_config = config.get_main()
username = main_config['@normal_username']
password = main_config['@normal_password']
realm = 'motionEyeOS'
logging.debug('writing streameye settings to %s' % STREAMEYE_CONF)
lines = [
'PROTO="%s"' % s['seProto'],
'PORT="%s"' % s['sePort'],
'RTSP_PORT="%s"' % s['seRTSPPort'],
'AUTH="%s"' % s['seAuthMode'],
'CREDENTIALS="%s:%s:%s"' % (username, password, realm)
]
with open(STREAMEYE_CONF, 'w') as f:
for line in lines:
f.write(line + '\n')
if 1 in config.get_camera_ids():
# a workaround to update the camera username and password
# since we cannot call set_camera() from here
if s['seAuthMode'] == 'basic':
url = 'http://%s:%s@127.0.0.1:%s/' % (username, password, s['sePort'])
else:
url = 'http://127.0.0.1:%s/' % s['sePort']
if 1 in config._camera_config_cache:
logging.debug('updating streaming authentication in config cache')
config._camera_config_cache[1]['@url'] = url
lines = config.get_camera(1, as_lines=True)
for i, line in enumerate(lines):
if line.startswith('# @url'):
lines[i] = '# @url %s' % url
config_file = os.path.join(settings.CONF_PATH, config._CAMERA_CONFIG_FILE_NAME % {'id': 1})
logging.debug('updating streaming authentication in camera config file %s' % config_file)
with open(config_file, 'w') as f:
for line in lines:
f.write(line + '\n')
logging.debug('restarting streameye')
if os.system('streameye.sh restart'):
logging.error('streameye restart failed')
# make streameye-related log files downloadable
if _get_streameye_enabled():
def _add_log_handlers():
import handlers
handlers.LogHandler.LOGS['streameye'] = (os.path.join(settings.LOG_PATH, 'streameye.log'), 'streameye.log')
handlers.LogHandler.LOGS['raspimjpeg'] = (os.path.join(settings.LOG_PATH, 'raspimjpeg.log'), 'raspimjpeg.log')
# handlers.LogHandler is not yet available
# at the time streameyectl is imported
io_loop = IOLoop.instance()
io_loop.add_callback(_add_log_handlers)
@additional_config
def streamEyeLog():
return {
'type': 'html',
'section': 'expertSettings',
'get': lambda: '<a href="javascript:downloadFile(\'log/streameye/\');">streameye.log</a>',
}
@additional_config
def raspiMjpegLog():
return {
'type': 'html',
'section': 'expertSettings',
'get': lambda: '<a href="javascript:downloadFile(\'log/raspimjpeg/\');">raspimjpeg.log</a>',
}
@additional_config
def streamEyeMainSeparator():
return {
'type': 'separator',
'section': 'expertSettings'
}
@additional_config
def streamEye():
return {
'label': 'Fast Network Camera',
'description': 'Enabling this option will turn your Raspberry PI into a simple and fast MJPEG network camera, ' +
'disabling motion detection, media files and all other advanced features (works only with the CSI camera)',
'type': 'bool',
'section': 'expertSettings',
'reboot': True,
'get': _get_streameye_enabled,
'set': _set_streameye_enabled_deferred,
}
@additional_config
def streamEyeCameraSeparator1():
return {
'type': 'separator',
'section': 'device',
'camera': True
}
@additional_config
def seBrightness():
if not _get_streameye_enabled():
return None
return {
'label': 'Brightness',
'description': 'sets a desired brightness level for this camera',
'type': 'range',
'min': 0,
'max': 100,
'snap': 2,
'ticksnum': 5,
'decimals': 0,
'unit': '%',
'section': 'device',
'camera': True,
'required': True,
'get': _get_raspimjpeg_settings,
'set': _set_raspimjpeg_settings,
'get_set_dict': True
}
@additional_config
def seContrast():
if not _get_streameye_enabled():
return None
return {
'label': 'Contrast',
'description': 'sets a desired contrast level for this camera',
'type': 'range',
'min': 0,
'max': 100,
'snap': 2,
'ticksnum': 5,
'decimals': 0,
'unit': '%',
'section': 'device',
'camera': True,
'required': True,
'get': _get_raspimjpeg_settings,
'set': _set_raspimjpeg_settings,
'get_set_dict': True
}
@additional_config
def seSaturation():
if not _get_streameye_enabled():
return None
return {
'label': 'Saturation',
'description': 'sets a desired saturation level for this camera',
'type': 'range',
'min': 0,
'max': 100,
'snap': 2,
'ticksnum': 5,
'decimals': 0,
'unit': '%',
'section': 'device',
'camera': True,
'required': True,
'get': _get_raspimjpeg_settings,
'set': _set_raspimjpeg_settings,
'get_set_dict': True
}
@additional_config
def seSharpness():
if not _get_streameye_enabled():
return None
return {
'label': 'Sharpness',
'description': 'sets a desired sharpness level for this camera',
'type': 'range',
'min': 0,
'max': 100,
'snap': 2,
'ticksnum': 5,
'decimals': 0,
'unit': '%',
'section': 'device',
'camera': True,
'required': True,
'get': _get_raspimjpeg_settings,
'set': _set_raspimjpeg_settings,
'get_set_dict': True
}
@additional_config
def streamEyeCameraSeparator2():
return {
'type': 'separator',
'section': 'device',
'camera': True
}
@additional_config
def seResolution():
if not _get_streameye_enabled():
return None
return {
'label': 'Video Resolution',
'description': 'the video resolution (larger values produce better quality but require more CPU power, larger storage space and bandwidth)',
'type': 'choices',
'choices': RESOLUTION_CHOICES,
'section': 'device',
'camera': True,
'required': True,
'get': _get_raspimjpeg_settings,
'set': _set_raspimjpeg_settings,
'get_set_dict': True
}
@additional_config
def seRotation():
if not _get_streameye_enabled():
return None
return {
'label': 'Video Rotation',
'description': 'use this to rotate the captured image, if your camera is not positioned correctly',
'type': 'choices',
'choices': ROTATION_CHOICES,
'section': 'device',
'camera': True,
'required': True,
'get': _get_raspimjpeg_settings,
'set': _set_raspimjpeg_settings,
'get_set_dict': True
}
@additional_config
def seVflip():
if not _get_streameye_enabled():
return None
return {
'label': 'Flip Vertically',
'description': 'enable this to flip the captured image vertically',
'type': 'bool',
'section': 'device',
'camera': True,
'required': True,
'get': _get_raspimjpeg_settings,
'set': _set_raspimjpeg_settings,
'get_set_dict': True
}
@additional_config
def seHflip():
if not _get_streameye_enabled():
return None
return {
'label': 'Flip Horizontally',
'description': 'enable this to flip the captured image horizontally',
'type': 'bool',
'section': 'device',
'camera': True,
'required': True,
'get': _get_raspimjpeg_settings,
'set': _set_raspimjpeg_settings,
'get_set_dict': True
}
@additional_config
def seFramerate():
if not _get_streameye_enabled():
return None
return {
'label': 'Frame Rate',
'description': 'sets the number of frames captured by the camera every second (higher values produce smoother videos but require more CPU power, larger storage space and bandwidth)',
'type': 'range',
'min': 1,
'max': 30,
'snap': 0,
'ticks': "1|5|10|15|20|25|30",
'decimals': 0,
'section': 'device',
'camera': True,
'required': True,
'get': _get_raspimjpeg_settings,
'set': _set_raspimjpeg_settings,
'get_set_dict': True
}
@additional_config
def seQuality():
if not _get_streameye_enabled():
return None
return {
'label': 'Image Quality',
'description': 'sets the JPEG image quality (higher values produce a better image quality but require more storage space and bandwidth)',
'type': 'range',
'min': 1,
'max': 100,
'snap': 2,
'ticks': '1|25|50|75|100',
'decimals': 0,
'unit': '%',
'section': 'device',
'camera': True,
'required': True,
'get': _get_raspimjpeg_settings,
'set': _set_raspimjpeg_settings,
'get_set_dict': True
}
@additional_config
def seBitrate():
if not _get_streameye_enabled():
return None
return {
'label': 'Bitrate',
'description': 'sets the RTSP stream bitrate (higher values produce a better stream quality but require more storage space and bandwidth)',
'type': 'number',
'min': 0,
'max': 100000000,
'unit': 'bps',
'section': 'device',
'camera': True,
'required': True,
'get': _get_raspimjpeg_settings,
'set': _set_raspimjpeg_settings,
'get_set_dict': True
}
@additional_config
def seZoomx():
if not _get_streameye_enabled():
return None
return {
'label': 'Zoom X',
'description': 'sets the horizontal zoom offset',
'type': 'range',
'min': 0,
'max': 80,
'snap': 2,
'ticksnum': 5,
'decimals': 0,
'unit': '%',
'section': 'device',
'camera': True,
'required': True,
'get': _get_raspimjpeg_settings,
'set': _set_raspimjpeg_settings,
'get_set_dict': True
}
@additional_config
def seZoomy():
if not _get_streameye_enabled():
return None
return {
'label': 'Zoom Y',
'description': 'sets the vertical zoom offset',
'type': 'range',
'min': 0,
'max': 80,
'snap': 2,
'ticksnum': 5,
'decimals': 0,
'unit': '%',
'section': 'device',
'camera': True,
'required': True,
'get': _get_raspimjpeg_settings,
'set': _set_raspimjpeg_settings,
'get_set_dict': True
}
@additional_config
def seZoomw():
if not _get_streameye_enabled():
return None
return {
'label': 'Zoom Width',
'description': 'sets the zoom width',
'type': 'range',
'min': 20,
'max': 100,
'snap': 2,
'ticksnum': 5,
'decimals': 0,
'unit': '%',
'section': 'device',
'camera': True,
'required': True,
'get': _get_raspimjpeg_settings,
'set': _set_raspimjpeg_settings,
'get_set_dict': True
}
@additional_config
def seZoomh():
if not _get_streameye_enabled():
return None
return {
'label': 'Zoom Height',
'description': 'sets the zoom height',
'type': 'range',
'min': 20,
'max': 100,
'snap': 2,
'ticksnum': 5,
'decimals': 0,
'unit': '%',
'section': 'device',
'camera': True,
'required': True,
'get': _get_raspimjpeg_settings,
'set': _set_raspimjpeg_settings,
'get_set_dict': True
}
@additional_config
def sePreview():
if not _get_streameye_enabled():
return None
return {
'label': 'HDMI Preview',
'description': 'enable this if you want to see the preview on an HDMI-connected monitor',
'type': 'bool',
'section': 'device',
'camera': True,
'get': _get_raspimjpeg_settings,
'set': _set_raspimjpeg_settings,
'get_set_dict': True
}
@additional_config
def streamEyeCameraSeparator3():
return {
'type': 'separator',
'section': 'device',
'camera': True
}
@additional_config
def seIso():
if not _get_streameye_enabled():
return None
return {
'label': 'ISO',
'description': 'sets a desired ISO level for this camera',
'type': 'range',
'min': 100,
'max': 800,
'snap': 1,
'ticksnum': 8,
'decimals': 0,
'unit': '',
'section': 'device',
'camera': True,
'required': True,
'get': _get_raspimjpeg_settings,
'set': _set_raspimjpeg_settings,
'get_set_dict': True
}
@additional_config
def seShutter():
if not _get_streameye_enabled():
return None
return {
'label': 'Shutter Speed',
'description': 'sets a desired shutter speed for this camera',
'type': 'number',
'min': 0,
'max': 6000000,
'unit': 'microseconds',
'section': 'device',
'camera': True,
'required': True,
'get': _get_raspimjpeg_settings,
'set': _set_raspimjpeg_settings,
'get_set_dict': True
}
@additional_config
def streamEyeCameraSeparator4():
return {
'type': 'separator',
'section': 'device',
'camera': True
}
@additional_config
def seExposure():
if not _get_streameye_enabled():
return None
return {
'label': 'Exposure Mode',
'description': 'sets a desired exposure mode for this camera',
'type': 'choices',
'choices': EXPOSURE_CHOICES,
'section': 'device',
'camera': True,
'required': True,
'get': _get_raspimjpeg_settings,