Commit Graph

7 Commits

Author SHA1 Message Date
Serendipity bd4ca718ac feat: 解码器全面增强 — 多遍二值化 + 4点透视 + ECI/FNC1
Phase 1 — 二值化+检测增强:
- decoder/image.rs 重写: 中位数→Otsu→Sauvola 三遍自适应阈值
- 新增 load_gray() 公共 API 供调用方自定义预处理
- 反色QR码自动检测(5点采样法)
- 静区验证 + 包围盒(BoundingBox) + 解码置信度评分
- 定位图案比例偏差计算

Phase 2 — 4点透视变换+多QR码:
- decoder/perspective.rs 重写: DLT求解3x3单应矩阵
- 用3个定位图案+推算第4点构建4点对应
- 双线性插值替换最近邻采样
- 多角度旋转回退(7个预设角度)
- decode_all() 返回图像中所有QR码(按置信度降序)

Phase 3 — ISO合规:
- decoder/bch.rs: decode_format_info/version_info 返回汉明距离
- decoder/format.rs: 副本冲突时选汉明距离更小者
- decoder/mode_decode.rs: ECI指派号识别, FNC1/GS1检测(0101/1001)
- 结构化追加(0011)头部提取: position/total/parity
- DecodeResult 扩展: is_gs1, eci_designator, structured_append

验证: cargo check+clippy通过, 81+24测试全部通过
2026-06-21 16:00:11 +08:00
Serendipity cd75141037 refactor: P0-P5 全面架构重构
P1 thiserror 类型化错误:
新增 core/src/error.rs QrError 枚举, 全链 String -> QrError,
包括 EmptyInput/InvalidVersion/DataTooLong/DecodeFail 等 8 种变体

P2 text_builder Tauri 统一:
新增 build_qr_text Tauri command, 删除前端 qrText.ts,
所有 mode 组件改为 invoke 调用 Rust 端构建文本

P3 QrConfig 颜色字段移除:
从 QrConfig/QrCode 移除 fg_color/bg_color,
改为 to_svg/to_image_bytes 参数传递

P4 前端 4 项合并:
Context 拆分为 StateContext+DispatchContext (H10),
新建 useModeForm 通用 hook (M11),
VCardMode grid-cols-2 网格布局 (M13),
persistHistory/loadHistory 迁至 utils/storage.ts (L9)

P5 算法优化:
MaskedView 懒计算替代 8 次 Matrix 克隆 (H9),
encoding_rs 精确 Kanji Shift JIS 映射 (H12)

验证: cargo check+clippy 通过, 81+24+7 全部测试通过
2026-06-21 15:09:10 +08:00
Serendipity b41f6ee7df feat: 格式扩展 — 支持 BMP/JPEG/WebP 输出
- png.rs 重命名为 image.rs,新增 OutputFormat 枚举
- QrCode::to_image_bytes 支持 PNG/BMP/JPEG/WebP
- CLI 新增 -f/--format 参数(png/bmp/jpeg/webp)
- Web API fmt 参数扩展至全部 4 种图像格式
- core/Cargo.toml: image crate 新增 bmp feature
2026-06-19 21:34:21 +08:00
Serendipity effc88c6d7 feat: QR 码解码器 — 从零手写的完整解码流水线
新增 core/src/decoder/ 模块(9 文件,~1500 行):
- bch.rs: BCH(15,5)+BCH(18,6) 查表解码(32+64 有效码字,t≤3)
- format.rs: 从矩阵读取格式信息(EC+掩码)+版本信息(2 副本容错)
- extract.rs: 逆向蛇形排列提取数据码字
- deinterleave.rs: 逆向 RS 数据交错
- rs_decode.rs: RS 纠错流水线(伴随式→BM→Chien→Forney)
- mode_decode.rs: 逆向 4 种编码模式(数字/字母/字节/汉字 Shift JIS)
- detect.rs: 定位图案检测(1:1:3:1:1 比例+交叉验证+聚类)
- image.rs: 图像加载+灰度二值化(PNG/JPEG/WebP)
- mod.rs: 顶层 API(decode_image + decode_matrix)

修改已有文件:
- core: galois.rs 表 pub(crate), 新增 poly_eval(); reed_solomon 公开内部函数
- cli: 新增 --decode <file> 解码模式
- web: 新增 POST /api/decode(multipart file upload)

测试: 72 passed (58 原有 + 14 新增 decoder 测试)
2026-06-19 20:36:12 +08:00
Serendipity ce8063431e docs: 开源规范化 — doc comments + 社区文件 + 示例代码 + crates.io 就绪
- 为 core 公开 API 添加完整 doc comments(rustdoc 可用)
- 新增 .editorconfig / CONTRIBUTING / CODE_OF_CONDUCT / SECURITY
- 新增 Issue 模板(bug + feature)+ PR 模板
- 新增 3 个代码示例(examples/)
- 更新 Cargo.toml 元数据(description/repository/keywords/categories/MSRV)
- 更新 README + CHANGELOG
2026-06-19 18:56:28 +08:00
Serendipity 95e3cc91ff chore: workspace 加 gui 成员,qr-core 加 serde 2026-06-17 00:10:18 +08:00
Serendipity ad77b3ac1b feat: workspace 骨架 — core + cli 模块结构 2026-06-16 23:27:58 +08:00