sz3/libcimbar

GitHub: sz3/libcimbar

libcimbar 是一种基于彩色图标矩阵的高密度 2D 条形码编解码库,专为物理隔离环境下通过屏幕-摄像头链路实现高速单向数据传输而设计。

Stars: 6268 | Forks: 457

### [简介](https://github.com/sz3/cimbar) | [关于](https://github.com/sz3/cimbar/blob/master/ABOUT.md) | [CFC](https://github.com/sz3/cfc) | LIBCIMBAR ### [详情](DETAILS.md) | [性能](PERFORMANCE.md) | [待办事项](TODO.md) ## libcimbar:彩色图标矩阵条形码 请看:一种用于物理隔离(air-gapped)数据传输的实验性条形码格式。 只需一台电脑显示器和一个智能手机摄像头,它就能维持 850 kilobits/s(~106 KB/s)的传输速度!

## 解释一下? 编码器会将动态条形码输出到电脑或智能手机屏幕上: * 编码器 Web 应用:https://cimbar.org 而解码器是一个手机应用,利用手机摄像头来读取动态条形码: * 解码器 Android 应用:https://github.com/sz3/cfc 不需要使用 internet/bluetooth/NFC 等。所有数据都通过摄像头镜头传输。你可以亲自尝试一下,或者相信我说它真的有效。 :) ## 它是如何工作的? `cimbar` 是一种高密度的 2D 条形码格式。数据存储在由彩色图块组成的网格中——位(bit)是根据选择的图块以及用于绘制该图块的颜色来进行编码的。为了应对视频 -> 数字解码过程中的有损特性,数据应用了 Reed Solomon 纠错机制。低于 1% 的错误率是预期之内且可被纠正的。 `libcimbar` 这个经过优化的实现包含了一个简单的文件编码协议,该协议基于喷泉码(`wirehair`)和 zstd 压缩构建。最大 33MB(压缩后!)的文件会被编码为一系列 cimbar 码,并可以作为图像或实时视频流输出。只要成功解码出足够多的不同图像帧,文件就能被成功重建并解压。即使接收到的图像顺序打乱,或者有些图像已损坏或丢失,也是如此。 ## 平台 代码使用 C++ 编写,并在 amd64+linux、arm64+android(仅限解码器)和 emscripten+WASM(仅限编码器)上进行了开发/测试。它可能也可以在其他平台上运行,或者稍作修改即可运行。 最关键的是,由于编码器可以编译为 asmjs 和 wasm,因此它可以在任何拥有现代 Web 浏览器的设备上运行。对于离线使用,你可以将 cimbar.org 安装为渐进式 Web 应用(PWA),或者[下载最新版本](https://github.com/sz3/libcimbar/releases/latest)的 `cimbar_js.html`,将其保存在本地,并在你的 Web 浏览器中打开。 ## 库依赖 在构建之前必须安装 [OpenCV](https://opencv.org/) 和 [GLFW](https://github.com/glfw/glfw)(+ OpenGL ES 头文件)。所有其他依赖项均已包含在源码树中。 * opencv - https://opencv.org/ (`libopencv-dev`) * GLFW - https://github.com/glfw/glfw (`libglfw3-dev`) * GLES3/gl3.h - `libgles2-mesa-dev` * base - https://github.com/r-lyeh-archived/base * catch2 - https://github.com/catchorg/Catch2 * concurrentqueue - https://github.com/cameron314/concurrentqueue * cxxopts - https://github.com/jarro2783/cxxopts (用于命令行工具) * fmt - https://github.com/fmtlib/fmt * intx - https://github.com/chfast/intx * libcorrect - https://github.com/quiet/libcorrect * libpopcnt - https://github.com/kimwalisch/libpopcnt * PicoSHA2 - https://github.com/okdshin/PicoSHA2 (用于测试) * stb_image - https://github.com/nothings/stb (用于加载内嵌的 png 文件) * wirehair - https://github.com/catid/wirehair * zstd - https://github.com/facebook/zstd ## 构建 1. 安装 opencv 和 GLFW。在 ubuntu/debian 上,操作如下: ``` sudo apt install libopencv-dev libglfw3-dev libgles2-mesa-dev ``` 2. 运行 cmake + make 咒语 ``` cmake . make -j7 make install ``` 默认情况下,libcimbar 会尝试将构建产物安装在 `./dist/bin/` 目录下。 要构建 cimbar.js(cimbar.org 所使用的库),请参阅 [WASM](WASM.md)。 ## 用法 编码: * 较大的输入文件可能会用大量 png 图片塞满你的磁盘! ``` ./cimbar --encode -i inputfile.txt -o outputprefix ``` 解码(将文件提取到输出目录): ``` ./cimbar outputprefix*.png -o /tmp ``` 从 stdin 解码一系列已编码的图像: ``` echo outputprefix*.png | ./cimbar -o /tmp ``` 编码并以窗口动画形式显示: ``` ./cimbar_send inputfile.pdf ``` 你也可以使用 [cimbar.org](https://cimbar.org) 或最新的 [发布版本](https://github.com/sz3/libcimbar/releases/latest) 来编码文件。 ## 性能数据 [性能](PERFORMANCE.md) ## 实现细节 [详情](DETAILS.md) ## 改进空间/后续步骤 [待办事项](TODO.md) ## 灵感来源 * https://github.com/JohannesBuchner/imagehash/ * https://github.com/divan/txqr * https://en.wikipedia.org/wiki/High_Capacity_Color_Barcode ## 你想了解更多吗? ### [简介](https://github.com/sz3/cimbar) | [关于](https://github.com/sz3/cimbar/blob/master/ABOUT.md)
标签:Android, Bash脚本, C++, DSL, 数据擦除, 数据编码, 条形码/二维码, 物理隔离数据传输, 计算机视觉