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
| """ Beamr ML-Safe 压缩技术分析
核心:直接压缩摄像头传感器原始Bayer数据 而非经过ISP处理后的RGB/YUV数据
Bayer RAW的优势: 1. 保留全部传感器信息(ISP处理会丢失信息) 2. 12-bit动态范围(vs 8-bit处理后) 3. 无ISP延迟 4. ML模型可在RAW域训练(更多信息=更好精度) """
import numpy as np
class BayerRAWCompression: """ 12-bit Bayer RAW 数据压缩分析 Bayer模式:传感器输出的马赛克数据 每个像素只有R/G/B中的一个颜色 12-bit Bayer RAW vs 8-bit RGB: - Bayer: 12 bit/pixel (RAW) - RGB: 8×3 = 24 bit/pixel (ISP处理后) - Bayer本身已是RGB的1/2大小 - 再加47%无损压缩 = Bayer的53% - 总计: 12 × 0.53 = 6.36 bit/pixel - vs RGB 24 bit/pixel = 73.5% 总压缩率 """ BAYER_PATTERNS = { 'RGGB': [[0, 1], [1, 2]], 'BGGR': [[2, 1], [1, 0]], 'GRBG': [[1, 0], [2, 1]], 'GBRG': [[1, 2], [0, 1]], } def __init__(self, bayer_pattern: str = 'RGGB', bit_depth: int = 12): self.pattern = self.BAYER_PATTERNS[bayer_pattern] self.bit_depth = bit_depth def estimate_savings(self, resolution: tuple, fps: int = 30, duration_hours: float = 8.0) -> dict: """ 估算存储节省 Args: resolution: (width, height) fps: 帧率 duration_hours: 录制时长(小时) Returns: 节省统计 """ w, h = resolution pixels_per_frame = w * h frames = fps * 3600 * duration_hours raw_bits = pixels_per_frame * self.bit_depth * frames raw_gb = raw_bits / 8 / 1e9 compressed_gb = raw_gb * 0.53 rgb_bits = pixels_per_frame * 8 * 3 * frames rgb_gb = rgb_bits / 8 / 1e9 h265_gb = raw_gb * 0.1 return { 'format': f'{self.bit_depth}-bit Bayer RAW', 'resolution': f'{w}x{h}', 'fps': fps, 'duration_hours': duration_hours, 'raw_size_gb': raw_gb, 'compressed_size_gb': compressed_gb, 'savings_gb': raw_gb - compressed_gb, 'savings_percent': 47.0, 'vs_rgb_gb': rgb_gb, 'vs_h265_gb': h265_gb, 'total_vs_rgb_savings': (1 - compressed_gb / rgb_gb) * 100, }
def ims_data_savings(): """ IMS座舱场景的数据节省估算 典型配置: - DMS摄像头: 2MP, 30fps, 12-bit - OMS摄像头: 2MP, 15fps, 12-bit - 后排摄像头: 1MP, 15fps, 12-bit - 每日测试8小时 """ bayer = BayerRAWCompression('RGGB', 12) dms = bayer.estimate_savings((1920, 1080), 30, 8) print("DMS摄像头 (2MP@30fps):") print(f" 原始: {dms['raw_size_gb']:.1f} GB/天") print(f" 压缩后: {dms['compressed_size_gb']:.1f} GB/天") print(f" 节省: {dms['savings_gb']:.1f} GB ({dms['savings_percent']}%)") print() oms = bayer.estimate_savings((1920, 1080), 15, 8) print("OMS摄像头 (2MP@15fps):") print(f" 原始: {oms['raw_size_gb']:.1f} GB/天") print(f" 压缩后: {oms['compressed_size_gb']:.1f} GB/天") print(f" 节省: {oms['savings_gb']:.1f} GB") print() total_raw = dms['raw_size_gb'] + oms['raw_size_gb'] total_comp = dms['compressed_size_gb'] + oms['compressed_size_gb'] print(f"总计 (DMS+OMS):") print(f" 原始: {total_raw:.1f} GB/天") print(f" 压缩后: {total_comp:.1f} GB/天") print(f" 每日节省: {total_raw - total_comp:.1f} GB") return dms, oms
if __name__ == "__main__": ims_data_savings()
|