-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathHTML_UI_REDESIGN
More file actions
1854 lines (1636 loc) · 66.6 KB
/
HTML_UI_REDESIGN
File metadata and controls
1854 lines (1636 loc) · 66.6 KB
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
from flask import Flask, Response, request, send_file, jsonify
import cv2
import json
import time
import os
import threading
import logging
import subprocess
import re
import lgpio
import sys
app = Flask(__name__)
# 配置日志
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
logger = logging.getLogger(__name__)
# 全局摄像头对象
camera = None
camera_lock = threading.Lock()
# 全局GPIO对象
GPIO_PIN = 18 # GPIO18/Pin12
h = None
gpio_lock = threading.Lock()
motor_state = {'running': False, 'pulse_width': 1500} # 默认中性脉宽1500µs
# PWM设置
PWM_FREQUENCY = 50 # 50Hz for ESC
PWM_NEUTRAL = 1500 # 中性脉宽(停止)
PWM_FULL_FORWARD = 2000 # 最大正向脉宽
PWM_FULL_REVERSE = 1000 # 最大反向脉宽
# 当前摄像头设置
current_settings = {
'resolution': '1280x480',
'fps': 30,
'brightness': 50,
'contrast': 50,
'saturation': 50,
'flip_h': True,
'flip_v': True,
'recording': False,
'format': 'mp4'
}
# 录像变量
recording = False
output_file = None
frame_count = 0
recording_start_time = 0
recordings_folder = os.path.abspath('recordings')
# 创建录像文件夹
if not os.path.exists(recordings_folder):
try:
os.makedirs(recordings_folder)
logger.info("录像文件夹创建成功")
except PermissionError as e:
logger.error(f"无法创建录像文件夹:权限不足 - {e}")
sys.exit(1)
# 初始化GPIO
def initialize_gpio():
global h
try:
h = lgpio.gpiochip_open(0)
lgpio.gpio_claim_output(h, GPIO_PIN)
lgpio.tx_pwm(h, GPIO_PIN, PWM_FREQUENCY, 0) # 初始化PWM,占空比0
logger.info("GPIO初始化成功")
except Exception as e:
logger.error(f"GPIO初始化失败:{e}")
sys.exit(1)
def set_motor_pwm(pulse_width):
"""设置电机PWM脉宽(单位:微秒)"""
try:
with gpio_lock:
duty_cycle = (pulse_width / 20000.0) * 100 # 50Hz周期为20ms,转换为占空比
lgpio.tx_pwm(h, GPIO_PIN, PWM_FREQUENCY, duty_cycle)
motor_state['pulse_width'] = pulse_width
motor_state['running'] = pulse_width != PWM_NEUTRAL
logger.info(f"电机PWM设置:脉宽 {pulse_width}µs,运行状态:{motor_state['running']}")
except Exception as e:
logger.error(f"设置电机PWM失败:{e}")
raise Exception(f"设置电机PWM失败:{e}")
def motor_ramp(start_pwm, target_pwm, step=10, delay=0.05):
"""逐步调整电机PWM脉宽,实现从慢到快或快到慢过渡"""
global motor_state
current_pwm = start_pwm
while abs(current_pwm - target_pwm) > step:
if target_pwm > current_pwm:
current_pwm = min(current_pwm + step, target_pwm)
else:
current_pwm = max(current_pwm - step, target_pwm)
try:
with gpio_lock:
duty_cycle = (current_pwm / 20000.0) * 100 # 50Hz周期为20ms
lgpio.tx_pwm(h, GPIO_PIN, PWM_FREQUENCY, duty_cycle)
motor_state['pulse_width'] = current_pwm
motor_state['running'] = current_pwm != PWM_NEUTRAL
logger.info(f"电机PWM调整:{current_pwm}µs,运行状态:{motor_state['running']}")
except Exception as e:
logger.error(f"电机PWM调整失败:{e}")
break
time.sleep(delay)
# 确保最终达到目标值
try:
with gpio_lock:
duty_cycle = (target_pwm / 20000.0) * 100
lgpio.tx_pwm(h, GPIO_PIN, PWM_FREQUENCY, duty_cycle)
motor_state['pulse_width'] = target_pwm
motor_state['running'] = target_pwm != PWM_NEUTRAL
logger.info(f"电机PWM完成调整:{target_pwm}µs,运行状态:{motor_state['running']}")
except Exception as e:
logger.error(f"电机PWM最终调整失败:{e}")
def initialize_camera():
"""初始化或重新初始化摄像头"""
global camera
with camera_lock:
if camera is not None:
camera.release()
time.sleep(0.1)
camera = cv2.VideoCapture(0, cv2.CAP_V4L2)
if not camera.isOpened():
logger.error("无法打开摄像头")
raise Exception("无法打开摄像头")
width, height = parse_resolution(current_settings['resolution'])
camera.set(cv2.CAP_PROP_FRAME_WIDTH, width)
camera.set(cv2.CAP_PROP_FRAME_HEIGHT, height)
camera.set(cv2.CAP_PROP_FPS, current_settings['fps'])
camera.set(cv2.CAP_PROP_BRIGHTNESS, current_settings['brightness'] / 100)
camera.set(cv2.CAP_PROP_CONTRAST, current_settings['contrast'] / 100)
camera.set(cv2.CAP_PROP_SATURATION, current_settings['saturation'] / 100)
actual_width = int(camera.get(cv2.CAP_PROP_FRAME_WIDTH))
actual_height = int(camera.get(cv2.CAP_PROP_FRAME_HEIGHT))
if abs(actual_width - width) > 1 or abs(actual_height - height) > 1:
logger.warning(f"分辨率 {width}x{height} 设置失败,实际为 {actual_width}x{actual_height}")
return False
logger.info(f"摄像头初始化成功,分辨率:{actual_width}x{actual_height}")
return True
def parse_resolution(resolution_str):
"""解析分辨率字符串为宽度和高度"""
try:
width, height = map(int, resolution_str.split('x'))
return width, height
except ValueError:
logger.warning(f"无效的分辨率格式:{resolution_str},使用默认值640x480")
return 640, 480
def get_supported_resolutions(device_index=0):
"""获取USB摄像头支持的分辨率"""
try:
result = subprocess.run(['v4l2-ctl', '--device', f'/dev/video{device_index}', '--list-formats-ext'],
capture_output=True, text=True, timeout=5)
output = result.stdout
resolutions = []
pattern = r'Size: Discrete (\d+x\d+)'
for match in re.finditer(pattern, output):
resolutions.append(match.group(1))
return list(set(resolutions))
except Exception as e:
logger.warning(f"获取分辨率失败,尝试OpenCV测试: {e}")
camera = cv2.VideoCapture(device_index, cv2.CAP_V4L2)
if not camera.isOpened():
logger.error("无法打开摄像头进行分辨率测试")
return ['640x480']
test_resolutions = [(320, 240), (640, 480), (1280, 720), (1920, 1080)]
supported = []
for width, height in test_resolutions:
camera.set(cv2.CAP_PROP_FRAME_WIDTH, width)
camera.set(cv2.CAP_PROP_FRAME_HEIGHT, height)
actual_width = int(camera.get(cv2.CAP_PROP_FRAME_WIDTH))
actual_height = int(camera.get(cv2.CAP_PROP_FRAME_HEIGHT))
if actual_width == width and actual_height == height:
supported.append(f"{width}x{height}")
camera.release()
return supported or ['640x480']
def generate_frames():
"""生成视频帧并应用设置"""
global camera, recording, output_file, frame_count, recording_start_time
while True:
with camera_lock:
if camera is None or not camera.isOpened():
try:
initialize_camera()
except Exception as e:
logger.error(f"摄像头初始化失败: {e}")
time.sleep(1)
continue
success, frame = camera.read()
if not success:
logger.warning("无法读取帧,尝试重新初始化摄像头")
try:
initialize_camera()
except:
time.sleep(1)
continue
if current_settings['flip_h']:
frame = cv2.flip(frame, 1)
if current_settings['flip_v']:
frame = cv2.flip(frame, 0)
if recording and output_file is not None:
output_file.write(frame)
frame_count += 1
elapsed_time = time.time() - recording_start_time
minutes = int(elapsed_time // 60)
seconds = int(elapsed_time % 60)
cv2.putText(frame, f"REC {minutes:02d}:{seconds:02d}", (10, 30),
cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255), 2, cv2.LINE_AA)
cv2.circle(frame, (25, 55), 10, (0, 0, 255), -1)
ret, buffer = cv2.imencode('.jpg', frame, [int(cv2.IMWRITE_JPEG_QUALITY), 90])
if not ret:
continue
frame_bytes = buffer.tobytes()
yield (b'--frame\r\n'
b'Content-Type: image/jpeg\r\n\r\n' + frame_bytes + b'\r\n')
time.sleep(1.0 / current_settings['fps'])
@app.route('/video_feed')
def video_feed():
"""提供视频流"""
return Response(generate_frames(), mimetype='multipart/x-mixed-replace; boundary=frame')
@app.route('/update_settings', methods=['POST'])
def update_settings():
"""更新摄像头设置"""
global current_settings, camera, recording, output_file
data = request.get_json()
supported_resolutions = get_supported_resolutions()
if 'resolution' in data and data['resolution'] in supported_resolutions:
if current_settings['resolution'] != data['resolution']:
if recording:
recording = False
if output_file is not None:
output_file.release()
output_file = None
current_settings['resolution'] = data['resolution']
try:
success = initialize_camera()
if not success:
current_settings['resolution'] = '640x480'
initialize_camera()
return jsonify({'status': 'error', 'message': '分辨率不支持,回退到640x480'})
except Exception as e:
logger.error(f"分辨率切换失败: {e}")
current_settings['resolution'] = '640x480'
initialize_camera()
return jsonify({'status': 'error', 'message': f'分辨率切换失败: {e}'})
if 'fps' in data and int(data['fps']) in [15, 30, 60]:
current_settings['fps'] = int(data['fps'])
with camera_lock:
if camera is not None:
camera.set(cv2.CAP_PROP_FPS, current_settings['fps'])
if 'brightness' in data:
current_settings['brightness'] = max(0, min(100, int(data['brightness'])))
with camera_lock:
if camera is not None:
camera.set(cv2.CAP_PROP_BRIGHTNESS, current_settings['brightness'] / 100)
if 'contrast' in data:
current_settings['contrast'] = max(0, min(100, int(data['contrast'])))
with camera_lock:
if camera is not None:
camera.set(cv2.CAP_PROP_CONTRAST, current_settings['contrast'] / 100)
if 'saturation' in data:
current_settings['saturation'] = max(100, min(100, int(data['saturation'])))
with camera_lock:
if camera is not None:
camera.set(cv2.CAP_PROP_SATURATION, current_settings['saturation'] / 0.1)
if 'flip_h' in data:
current_settings['flip_h'] = data['flip_h']
if 'flip_v' in data:
current_settings['flip_v'] = data['flip_v']
if 'format' in data and data['format'] in ['avi', 'mp4']:
current_settings['format'] = data['format']
return jsonify({'status': 'success', 'settings': current_settings})
@app.route('/toggle_recording', methods=['POST'])
def toggle_recording():
"""开始或停止录像"""
global recording, output_file, frame_count, recording_start_time, current_settings
data = request.get_json()
action = data.get('action')
if action == 'start' and not recording:
width, height = parse_resolution(current_settings['resolution'])
timestamp = time.strftime("%Y%m%d-%H%M%S")
file_ext = current_settings['format']
file_path = os.path.join(recordings_folder, f'recording_{timestamp}.{file_ext}')
fourcc = cv2.VideoWriter_fourcc(*'H264') if file_ext == 'mp4' else cv2.VideoWriter_fourcc(*'XVID')
try:
output_file = cv2.VideoWriter(file_path, fourcc, current_settings['fps'], (width, height))
if not output_file.isOpened():
logger.error("无法创建录像文件")
return jsonify({'status': 'error', 'message': '无法创建录像文件'})
recording = True
frame_count = 0
recording_start_time = time.time()
logger.info(f"开始录像,保存至:{file_path}")
return jsonify({'status': 'success', 'message': '录像开始', 'recording': True})
except Exception as e:
logger.error(f"开始录像失败: {e}")
return jsonify({'status': 'error', 'message': f'开始录像失败: {e}'})
elif action == 'stop' and recording:
recording = False
if output_file is not None:
output_file.release()
output_file = None
duration = time.time() - recording_start_time
logger.info(f"录像停止,捕获 {frame_count} 帧,持续 {duration:.2f} 秒")
return jsonify({
'status': 'success',
'message': f'录像停止,捕获 {frame_count} 帧,持续 {duration:.2f} 秒',
'recording': False
})
return jsonify({'status': 'error', 'message': '无效请求'})
@app.route('/control_motor', methods=['POST'])
def control_motor():
"""控制电机启停,实现渐进加速和减速"""
data = request.get_json()
action = data.get('action')
if action not in ['start', 'stop']:
return jsonify({'status': 'error', 'message': '无效动作'})
try:
if action == 'start':
# 从当前脉宽逐步加速到最大正向
current_pwm = motor_state['pulse_width']
threading.Thread(target=motor_ramp, args=(current_pwm, PWM_FULL_FORWARD)).start()
return jsonify({'status': 'success', 'message': '电机加速启动'})
else:
# 从当前脉宽逐步减速到中性
current_pwm = motor_state['pulse_width']
threading.Thread(target=motor_ramp, args=(current_pwm, PWM_NEUTRAL)).start()
return jsonify({'status': 'success', 'message': '电机减速停止'})
except Exception as e:
return jsonify({'status': 'error', 'message': f'电机控制失败: {e}'})
@app.route('/get_motor_status', methods=['GET'])
def get_motor_status():
"""返回当前电机状态"""
return jsonify({
'running': motor_state['running'],
'pulse_width': motor_state['pulse_width']
})
@app.route('/get_recordings', methods=['GET'])
def get_recordings():
"""获取录像文件列表"""
recordings = []
try:
for file in os.listdir(recordings_folder):
if file.endswith(('.avi', '.mp4')):
file_path = os.path.join(recordings_folder, file)
file_stats = os.stat(file_path)
recordings.append({
'name': file,
'size': file_stats.st_size,
'date': time.ctime(file_stats.st_ctime)
})
return jsonify({'recordings': recordings})
except Exception as e:
logger.error(f"获取录像列表失败: {e}")
return jsonify({'status': 'error', 'message': f'获取录像列表失败: {e}'})
@app.route('/download_recording/<filename>', methods=['GET'])
def download_recording(filename):
"""下载录像文件"""
file_path = os.path.join(recordings_folder, filename)
if os.path.exists(file_path) and (filename.endswith('.avi') or filename.endswith('.mp4')):
return send_file(file_path, as_attachment=True)
logger.warning(f"尝试下载不存在或不支持的文件:{filename}")
return jsonify({'status': 'error', 'message': '文件不存在或格式不支持'}), 404
@app.route('/delete_recording/<filename>', methods=['POST'])
def delete_recording(filename):
"""删除录像文件"""
file_path = os.path.join(recordings_folder, filename)
if os.path.exists(file_path) and (filename.endswith('.avi') or filename.endswith('.mp4')):
try:
os.remove(file_path)
logger.info(f"文件删除成功:{filename}")
return jsonify({'status': 'success', 'message': '文件已删除'})
except Exception as e:
logger.error(f"删除文件失败: {e}")
return jsonify({'status': 'error', 'message': f'删除文件失败: {e}'})
logger.warning(f"尝试删除不存在或不支持的文件:{filename}")
return jsonify({'status': 'error', 'message': '文件不存在或格式不支持'}), 404
@app.route('/get_supported_resolutions', methods=['GET'])
def get_supported_resolutions_route():
"""返回摄像头支持的分辨率"""
resolutions = get_supported_resolutions()
return jsonify({'resolutions': resolutions})
@app.route('/get_current_settings', methods=['GET'])
def get_current_settings():
"""返回当前摄像头设置"""
return jsonify(current_settings)
@app.route('/')
def index():
"""提供主页面"""
return """
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>智能视频监控系统</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
:root {
--primary: #3a86ff;
--primary-dark: #2667cc;
--secondary: #ff006e;
--success: #38b000;
--warning: #ffbe0b;
--danger: #ff5252;
--dark: #1a1a2e;
--light: #ffffff;
--gray: #8d99ae;
--gray-light: #edf2f4;
--gray-dark: #2b2d42;
--shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
--radius: 8px;
--transition: all 0.3s ease;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Segoe UI', 'Roboto', 'Helvetica Neue', sans-serif;
}
body {
background-color: #f8f9fa;
color: var(--gray-dark);
line-height: 1.6;
}
.app-container {
display: flex;
flex-direction: column;
min-height: 100vh;
}
.header {
background-color: var(--light);
padding: 1rem 2rem;
box-shadow: var(--shadow);
display: flex;
justify-content: space-between;
align-items: center;
position: sticky;
top: 0;
z-index: 100;
}
.logo {
display: flex;
align-items: center;
gap: 0.75rem;
font-weight: 600;
font-size: 1.25rem;
color: var(--dark);
}
.logo i {
color: var(--primary);
font-size: 1.5rem;
}
.nav-toggle {
display: none;
background: none;
border: none;
font-size: 1.5rem;
color: var(--dark);
cursor: pointer;
}
.main-content {
display: flex;
flex: 1;
}
.sidebar {
width: 320px;
background-color: var(--light);
border-right: 1px solid var(--gray-light);
padding: 1.5rem;
overflow-y: auto;
transition: var(--transition);
}
.panel {
margin-bottom: 1.5rem;
background-color: var(--light);
border-radius: var(--radius);
overflow: hidden;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
border: 1px solid var(--gray-light);
}
.panel-header {
padding: 1rem 1.25rem;
display: flex;
align-items: center;
background-color: var(--gray-light);
font-weight: 600;
font-size: 0.9rem;
color: var(--gray-dark);
text-transform: uppercase;
letter-spacing: 0.5px;
}
.panel-header i {
margin-right: 0.75rem;
color: var(--primary);
}
.panel-body {
padding: 1.25rem;
}
.form-group {
margin-bottom: 1.25rem;
}
.form-group:last-child {
margin-bottom: 0;
}
.form-label {
display: block;
margin-bottom: 0.5rem;
font-weight: 500;
font-size: 0.9rem;
color: var(--gray-dark);
}
.form-control {
width: 100%;
padding: 0.75rem 1rem;
border: 1px solid var(--gray-light);
border-radius: var(--radius);
font-size: 0.9rem;
transition: var(--transition);
background-color: var(--light);
color: var(--dark);
}
.form-control:focus {
outline: none;
border-color: var(--primary);
box-shadow: 0 0 0 3px rgba(58, 134, 255, 0.1);
}
.form-select {
appearance: none;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%232b2d42' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
background-repeat: no-repeat;
background-position: right 1rem center;
padding-right: 2.5rem;
}
.slider-container {
position: relative;
padding-top: 1.5rem;
}
.form-range {
-webkit-appearance: none;
width: 100%;
height: 6px;
border-radius: 3px;
background: var(--gray-light);
outline: none;
}
.form-range::-webkit-slider-thumb {
-webkit-appearance: none;
width: 18px;
height: 18px;
border-radius: 50%;
background: var(--primary);
cursor: pointer;
border: none;
box-shadow: 0 0 5px rgba(0,0,0,0.1);
}
.form-range::-moz-range-thumb {
width: 18px;
height: 18px;
border-radius: 50%;
background: var(--primary);
cursor: pointer;
border: none;
box-shadow: 0 0 5px rgba(0,0,0,0.1);
}
.range-value {
position: absolute;
top: 0;
right: 0;
font-size: 0.8rem;
font-weight: 600;
color: var(--primary);
}
.switch-container {
display: flex;
justify-content: space-between;
align-items: center;
}
.switch {
position: relative;
display: inline-block;
width: 44px;
height: 24px;
}
.switch input {
opacity: 0;
width: 0;
height: 0;
}
.switch-slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: var(--gray-light);
transition: var(--transition);
border-radius: 24px;
}
.switch-slider:before {
position: absolute;
content: "";
height: 18px;
width: 18px;
left: 3px;
bottom: 3px;
background-color: white;
transition: var(--transition);
border-radius: 50%;
}
input:checked + .switch-slider {
background-color: var(--primary);
}
input:focus + .switch-slider {
box-shadow: 0 0 0 3px rgba(58, 134, 255, 0.1);
}
input:checked + .switch-slider:before {
transform: translateX(20px);
}
.status-indicator {
display: inline-flex;
align-items: center;
padding: 0.3rem 0.75rem;
border-radius: 12px;
font-size: 0.8rem;
font-weight: 600;
background-color: var(--gray-light);
color: var(--gray-dark);
}
.status-indicator.active {
background-color: var(--success);
color: white;
}
.status-indicator.stopped {
background-color: var(--gray);
color: white;
}
.btn-group {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 0.75rem;
margin-top: 1rem;
}
.btn {
display: inline-flex;
align-items: center;
justify-content: center;
padding: 0.75rem 1.25rem;
border-radius: var(--radius);
font-weight: 500;
font-size: 0.9rem;
cursor: pointer;
transition: var(--transition);
border: none;
box-shadow: var(--shadow);
gap: 0.5rem;
}
.btn-primary {
background-color: var(--primary);
color: white;
}
.btn-primary:hover {
background-color: var(--primary-dark);
}
.btn-success {
background-color: var(--success);
color: white;
}
.btn-success:hover {
background-color: #2b9000;
}
.btn-danger {
background-color: var(--danger);
color: white;
}
.btn-danger:hover {
background-color: #e03e3e;
}
.btn-secondary {
background-color: var(--gray-light);
color: var(--gray-dark);
}
.btn-secondary:hover {
background-color: #dce1e4;
}
.btn-full {
grid-column: span 2;
}
.content {
flex: 1;
padding: 1.5rem;
display: flex;
flex-direction: column;
overflow-y: auto;
}
.video-wrapper {
position: relative;
width: 100%;
background-color: var(--dark);
border-radius: var(--radius);
overflow: hidden;
margin-bottom: 1.5rem;
box-shadow: var(--shadow);
}
.video-inner {
position: relative;
width: 100%;
padding-top: 56.25%; /* 16:9 Aspect Ratio */
}
.video-feed {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
object-fit: contain;
}
.video-overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
justify-content: space-between;
pointer-events: none;
}
.video-indicators {
padding: 1rem;
display: flex;
gap: 0.75rem;
}
.video-indicator {
background-color: rgba(0, 0, 0, 0.6);
color: white;
padding: 0.5rem 0.75rem;
border-radius: var(--radius);
font-size: 0.8rem;
font-weight: 500;
display: flex;
align-items: center;
gap: 0.5rem;
pointer-events: auto;
}
.indicator-dot {
width: 10px;
height: 10px;
border-radius: 50%;
background-color: var(--success);
}
.indicator-dot.pulse {
animation: pulse 1.5s infinite;
}
.indicator-dot.recording {
background-color: var(--danger);
}
.video-controls {
padding: 1rem;
display: flex;
justify-content: center;
gap: 1rem;
background: linear-gradient(to top, rgba(0,0,0,0.7), transparent);
opacity: 0;
transition: opacity 0.3s ease;
pointer-events: auto;
}
.video-wrapper:hover .video-controls {
opacity: 1;
}
.control-btn {
width: 40px;
height: 40px;
border-radius: 50%;
background-color: rgba(255, 255, 255, 0.2);
border: none;
color: white;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
transition: var(--transition);
}
.control-btn:hover {
background-color: rgba(255, 255, 255, 0.3);
}
.control-btn.active {
background-color: var(--primary);
}
.recordings-container {
background-color: var(--light);
border-radius: var(--radius);
overflow: hidden;
box-shadow: var(--shadow);
display: none;
}
.recordings-header {
padding: 1rem 1.5rem;
background-color: var(--gray-light);
display: flex;
justify-content: space-between;
align-items: center;
}
.recordings-title {
font-weight: 600;
font-size: 1rem;
color: var(--gray-dark);
display: flex;
align-items: center;
gap: 0.5rem;
}
.recordings-body {
max-height: 400px;
overflow-y: auto;
}
.recording-item {
padding: 1rem 1.5rem;
border-bottom: 1px solid var(--gray-light);
display: flex;
justify-content: space-between;
align-items: center;
transition: var(--transition);
}
.recording-item:hover {
background-color: var(--gray-light);
}
.recording-info {
flex: 1;
}
.recording-name {
font-weight: 500;
margin-bottom: 0.25rem;
}
.recording-meta {
display: flex;
gap: 1rem;
font-size: 0.8rem;
color: var(--gray);
}
.recording-actions {
display: flex;
gap: 0.5rem;
}
.recording-btn {
background: none;
border: none;
color: var(--gray);
font-size: 1rem;
cursor: pointer;
transition: var(--transition);
padding: 0.25rem;
}
.recording-btn:hover {
color: var(--primary);
}
.recording-btn.delete:hover {
color: var(--danger);
}
.toast {
position: fixed;
bottom: 2rem;
right: 2rem;
padding: 1rem 1.5rem;
border-radius: var(--radius);
background-color: var(--dark);
color: white;
box-shadow: var(--shadow);
z-index: 1000;
max-width: 300px;
display: flex;
align-items: center;
gap: 0.75rem;
transform: translateY(100px);
opacity: 0;
transition: transform 0.3s ease, opacity 0.3s ease;
}