docs: 添加项目 README,说明愿景与目标
大石头 authored at 2026-12-02 00:23:01
18.39 KiB
NewLife.Vision
# NewLife.Vision - .NET 视觉理解库 ![GitHub top language](https://img.shields.io/github/languages/top/newlifex/NewLife.Vision?logo=github) ![GitHub License](https://img.shields.io/github/license/NewLifeX/NewLife.Vision?logo=github) ![NuGet Downloads](https://img.shields.io/nuget/dt/NewLife.Vision?logo=nuget) ![NuGet](https://img.shields.io/nuget/v/NewLife.Vision?logo=nuget) ![NuGet prerelease](https://img.shields.io/nuget/vpre/NewLife.Vision?label=dev%20nuget&logo=nuget) [![test](https://github.com/NewLifeX/NewLife.Vision/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/NewLifeX/NewLife.Vision/actions/workflows/test.yml) ![locales](https://img.shields.io/badge/locales-11-2ea44f?logo=dotnet) ![platform](https://img.shields.io/badge/platform-Windows%20%7C%20Linux%20%7C%20macOS-blue) ![arch](https://img.shields.io/badge/arch-x64%20%7C%20arm64-orange) [![contributors](https://img.shields.io/github/contributors/NewLifeX/NewLife.Vision?logo=github)](https://github.com/NewLifeX/NewLife.Vision/graphs/contributors) <!-- lang:start --> 🌐 [English](/NewLife/NewLife.Vision/Blob/master/README.md) | [繁體中文](/NewLife/NewLife.Vision/Blob/master/README.zh-TW.md) | [Español](/NewLife/NewLife.Vision/Blob/master/README.es.md) | [Deutsch](/NewLife/NewLife.Vision/Blob/master/README.de.md) | [日本語](/NewLife/NewLife.Vision/Blob/master/README.ja.md) | [Français](/NewLife/NewLife.Vision/Blob/master/README.fr.md) | [Português](/NewLife/NewLife.Vision/Blob/master/README.pt.md) | [Русский](/NewLife/NewLife.Vision/Blob/master/README.ru.md) | [한국어](/NewLife/NewLife.Vision/Blob/master/README.ko.md) | [العربية](/NewLife/NewLife.Vision/Blob/master/README.ar.md) <!-- lang:end --> 把像素变成可检索、可决策的结构化结果:文字、条码、目标与人脸,引擎可替换。 源码:https://github.com/NewLifeX/NewLife.Vision NuGet:`NewLife.Vision` ## 快速开始 用内置纯托管解码器识别条码: ```bash dotnet add package NewLife.Vision ``` ```csharp using NewLife.Imaging.Codecs; using NewLife.Vision; using NewLife.Vision.Barcode; var image = ImageCodecs.Decode(File.ReadAllBytes("qr.png")).ToVisionImage(); var results = new BarcodePipeline(new ManagedBarcodeReader()).Read(image); Console.WriteLine(results[0].Text); ``` 用内置纯托管模板识别器识别文字: ```bash dotnet add package NewLife.Vision ``` ```csharp using NewLife.Imaging.Codecs; using NewLife.Vision; using NewLife.Vision.Ocr; var recognizer = new TemplateOcrRecognizer(); var pipeline = new OcrPipeline(recognizer); var image = ImageCodecs.Decode(File.ReadAllBytes("label.png")).ToVisionImage(); var result = await pipeline.RecognizeAsync(image); Console.WriteLine(result.Text); ``` 支持 `netstandard2.0`、`netstandard2.1`、`net461`、`net8.0`、`net10.0` 与 `net11.0`。 ## 主要功能 <details> <summary><b>预处理与几何矫正</b> (6 项)</summary> | Capability | What it gives you | | --- | --- | | 步骤契约 | `IImagePreprocessor` 顺序组合无状态步骤,可并发调用 | | 基础步骤 | 灰度、Otsu 二值、对比度拉伸、缩放与 ROI 裁剪,算子复用 NewLife.Imaging | | 倾斜矫正 | 投影轮廓估角并旋转,返回估计角度 | | 透视矫正 | 四点单应变换加双线性采样,输出尺寸可选 | | 识别预设 | `PreprocessPipeline.CreateOcr()` 与 `CreateBarcode()` 开箱即用 | | 相机标定 | `CameraCalibrator` 由平面标靶解内参与径向畸变,`ImageUndistorter` 把图摆正 | </details> <details> <summary><b>文字识别</b>(5 项)</summary> | 能力 | 带来的价值 | | --- | --- | | 引擎契约 | `ITextRecognizer` 提供唯一的异步入口并支持取消 | | 内置模板识别 | 纯托管模板匹配,随包分发,无模型文件 | | OCR 管线 | 在任意引擎之上做置信度过滤、区域排序与按行合并 | | 区域模型 | 每行文字都带文本、置信度、包围盒与倾斜角度 | | 优雅降级 | 识别不到时返回空结果与分数,不抛异常 | </details> <details> <summary><b>条码</b>(4 项)</summary> | 能力 | 带来的价值 | | --- | --- | | 引擎契约 | `IBarcodeReader` 按结果返回文本、码制与包围盒 | | 内置解码 | 纯托管支持 QR、Code128、Code39、Code93、EAN-13、EAN-8 与 UPC-A,无需第三方包 | | 条码管线 | 按内容与码制去重,并按 `MaxResults` 截断 | | 码制选择 | 只解期望的码制,降低复杂图像上的耗时 | </details> <details> <summary><b>检测与人脸</b> (4 项)</summary> | 能力 | 带来的价值 | | --- | --- | | 检测契约 | `IObjectDetector` 输出包围盒、类别与分数;`DetectionPipeline` 做分数/类别过滤与按类别 NMS | | 会话驱动模型 | `IModelSession` 承载任意推理后端,内置纯托管 ONNX 子集推理,YOLO 与人脸解码、分割与姿态后处理、1:1 人脸比对与模型缺失降级开箱可用 | | 云端识别 | `ChatVisionRecognizer` 调用任意 OpenAI 兼容端点,不引入额外客户端依赖 | </details> <details> <summary><b>帧与像素模型</b>(3 项)</summary> | 能力 | 带来的价值 | | --- | --- | | 视觉图像 | `VisionImage` 以偏移、行跨度和五种紧凑像素格式包裹任意缓冲区 | | 图像互转 | `ImageFrame` 与 `VisionImage` 在核心包内双向互转 | | 零拷贝视图 | 行视图与整图视图直接暴露底层缓冲区 | </details> ## 生态版图 NewLife 生态按依赖分层,各项目独立版本、独立发版。下面的版图在所有 NewLife 仓库中逐字一致;每个项目链接到代码仓库与主 NuGet 包。 | 项目 | 一句话定位 | 下载量 | | --- | --- | --- | | **基础底座** | | | | [NewLife.Core](https://github.com/NewLifeX/X) | 日志、配置、缓存、网络、序列化、定时调度与 APM 追踪。 | [![NuGet](https://img.shields.io/nuget/dt/NewLife.Core?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.Core) | | [NewLife.XCode](https://github.com/NewLifeX/NewLife.XCode) | 数据中间件:单表百亿级、自动分表、读写分离,支持 10 多种数据库。 | [![NuGet](https://img.shields.io/nuget/dt/NewLife.XCode?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.XCode) | | [NewLife.Net](https://github.com/NewLifeX/NewLife.Net) | 高性能网络库:单机 177 万 pps、14.5 Gbps(TCP 1KB,2026-10 实测),400 万 Tcp 长连接。 | [![NuGet](https://img.shields.io/nuget/dt/NewLife.Net?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.Net) | | [NewLife.Remoting](https://github.com/NewLifeX/NewLife.Remoting) | 协议通信与 RPC 框架,面向 CS 应用与物联网设备。 | [![NuGet](https://img.shields.io/nuget/dt/NewLife.Remoting?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.Remoting) | | [NewLife.Agent](https://github.com/NewLifeX/NewLife.Agent) | 把 .NET 应用安装为操作系统守护进程:Windows 服务与 Linux systemd。 | [![NuGet](https://img.shields.io/nuget/dt/NewLife.Agent?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.Agent) | | [NewLife.Templates](https://github.com/NewLifeX/NewLife.Zero) | `dotnet new` 项目模板:控制台、Web、WebApi、服务、数据与物联网。 | [![NuGet](https://img.shields.io/nuget/dt/NewLife.Templates?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.Templates) | | **数据存储与消息** | | | | [NewLife.Redis](https://github.com/NewLifeX/NewLife.Redis) | Redis 客户端:微秒级延迟、百万级吞吐,内置消息队列。 | [![NuGet](https://img.shields.io/nuget/dt/NewLife.Redis?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.Redis) | | [NewLife.RocketMQ](https://github.com/NewLifeX/NewLife.RocketMQ) | 纯托管 RocketMQ 客户端,支持 Apache RocketMQ 与阿里云消息队列。 | [![NuGet](https://img.shields.io/nuget/dt/NewLife.RocketMQ?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.RocketMQ) | | [NewLife.MQTT](https://github.com/NewLifeX/NewLife.MQTT) | MQTT 客户端与服务端,客户端支持阿里云物联网。 | [![NuGet](https://img.shields.io/nuget/dt/NewLife.MQTT?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.MQTT) | | [NewLife.NovaDb](https://github.com/NewLifeX/NewLife.NovaDb) | C# 混合数据库:嵌入/网络双模,关系型、时序、消息队列与 KV 于一体。 | [![NuGet](https://img.shields.io/nuget/dt/NewLife.NovaDb?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.NovaDb) | | [NewLife.MySql](https://github.com/NewLifeX/NewLife.MySql) | MySql 驱动与数据访问辅助层,基于 NewLife 数据栈实现。 | [![NuGet](https://img.shields.io/nuget/dt/NewLife.MySql?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.MySql) | | [NewLife.TDengine](https://github.com/NewLifeX/NewLife.TDengine) | 纯托管 TDengine ADO.NET 驱动:REST、WebSocket 与原生 RPC 三种连接方式,零本机依赖。 | [![NuGet](https://img.shields.io/nuget/dt/NewLife.TDengine?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.TDengine) | | [NewLife.Presto](https://github.com/NewLifeX/NewLife.Presto) | 纯 C# Presto/Trino ADO.NET 驱动,零第三方依赖,支持 XCode ORM 集成。 | [![NuGet](https://img.shields.io/nuget/dt/NewLife.Presto?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.Presto) | | **Web 与分布式** | | | | [NewLife.Cube](https://github.com/NewLifeX/NewLife.Cube) | 魔方快速开发平台:用户权限、SSO、OAuth 服务端与 CRUD 脚手架。 | [![NuGet](https://img.shields.io/nuget/dt/NewLife.Cube?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.Cube) | | [NewLife.Cube.React](https://github.com/NewLifeX/NewLife.Cube.React) | 魔方前后端分离示例:WebAPI 后端 + Swagger + React/Vue/Blazor 前端。 | [![NuGet](https://img.shields.io/nuget/dt/NewLife.Cube.React?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.Cube.React) | | [Stardust](https://github.com/NewLifeX/Stardust) | 星尘分布式服务平台:节点管理、APM、配置中心、注册中心与发布中心。 | [![NuGet](https://img.shields.io/nuget/dt/NewLife.Stardust?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.Stardust) | | [AntJob](https://github.com/NewLifeX/AntJob) | 蚂蚁调度:分布式任务与实时数据平台,支持分片、重试与回溯补算。 | [![NuGet](https://img.shields.io/nuget/dt/NewLife.AntJob?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.AntJob) | | **AI 与视觉** | | | | [NewLife.AI](https://github.com/NewLifeX/NewLife.AI) | 统一接入 46 家大模型服务商,附带开箱即用的 ChatAI Web 对话应用。 | [![NuGet](https://img.shields.io/nuget/dt/NewLife.AI?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.AI) | | [NewLife.Imaging](https://github.com/NewLifeX/NewLife.Imaging) | 纯托管图像基础库:像素模型、编解码契约、绘制与元数据,零原生依赖。 | — | | [NewLife.Vision](https://github.com/NewLifeX/NewLife.Vision) | 视觉算法库:OCR、条码、目标检测与人脸识别,构建在 NewLife.Imaging 之上。 | — | | [NewLife.ML](https://github.com/NewLifeX/NewLife.ML) | 面向 .NET 的表格机器学习:把数据库表与 Excel 变成可部署的预测与分类模型。 | — | | **工业与物联网** | | | | [NewLife.IoT](https://github.com/NewLifeX/NewLife.IoT) | IoT 标准库,定义物联网通信协议契约与设备抽象。 | [![NuGet](https://img.shields.io/nuget/dt/NewLife.IoT?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.IoT) | | [NewLife.Modbus](https://github.com/NewLifeX/NewLife.Modbus) | Modbus TCP/RTU/ASCII,基于 NewLife.IoT 实现。 | [![NuGet](https://img.shields.io/nuget/dt/NewLife.Modbus?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.Modbus) | | [NewLife.Siemens](https://github.com/NewLifeX/NewLife.Siemens) | 西门子 PLC 协议,基于 NewLife.IoT 实现。 | [![NuGet](https://img.shields.io/nuget/dt/NewLife.Siemens?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.Siemens) | | [NewLife.Omron](https://github.com/NewLifeX/NewLife.Omron) | 欧姆龙 PLC 协议,基于 NewLife.IoT 实现。 | [![NuGet](https://img.shields.io/nuget/dt/NewLife.Omron?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.Omron) | | [NewLife.Melsec](https://github.com/NewLifeX/NewLife.Melsec) | 三菱 Melsec PLC 协议,基于 NewLife.IoT 实现。 | [![NuGet](https://img.shields.io/nuget/dt/NewLife.Melsec?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.Melsec) | | [NewLife.Schneider](https://github.com/NewLifeX/NewLife.Schneider) | 施耐德 PLC 通信驱动,基于 Modbus TCP。 | [![NuGet](https://img.shields.io/nuget/dt/NewLife.Schneider?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.Schneider) | | [NewLife.OPC](https://github.com/NewLifeX/NewLife.OPC) | OPC 客户端,用于工业数据采集。 | — | | [NewLife.BACnet](https://github.com/NewLifeX/NewLife.BACnet) | BACnet 楼宇自控协议栈。 | [![NuGet](https://img.shields.io/nuget/dt/NewLife.BACnet?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.BACnet) | | [NewLife.LoRa](https://github.com/NewLifeX/NewLife.LoRa) | 超低功耗物联网远程通信协议 LoRaWAN。 | [![NuGet](https://img.shields.io/nuget/dt/NewLife.LoRa?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.LoRa) | | [ZeroIoT](https://github.com/NewLifeX/ZeroIoT) | 开源轻量级 IoT 平台,含网关与设备管理。 | — | | **车联网** | | | | [NewLife.JT808](https://github.com/NewLifeX/NewLife.JT808) | JT/T 808 车辆定位协议:70+ 消息体,覆盖 2011/2013/2019 三个版本。 | [![NuGet](https://img.shields.io/nuget/dt/NewLife.JT808?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.JT808) | | [NewLife.JT809](https://github.com/NewLifeX/NewLife.JT809) | JT/T 809 部标平台互联协议,面向运输管理部门。 | [![NuGet](https://img.shields.io/nuget/dt/NewLife.JT809?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.JT809) | | [NewLife.JT1078](https://github.com/NewLifeX/NewLife.JT1078) | JT/T 1078 车载视频:RTP 解析、FLV/fMP4 转封装与直播推送。 | [![NuGet](https://img.shields.io/nuget/dt/NewLife.JT1078?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.JT1078) | | **领域组件** | | | | [NewLife.Office](https://github.com/NewLifeX/NewLife.Office) | 一个包覆盖 Excel、Word、PPT、PDF 等 15+ 文档格式。 | [![NuGet](https://img.shields.io/nuget/dt/NewLife.Office?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.Office) | | [NewLife.Audio](https://github.com/NewLifeX/NewLife.Audio) | 跨平台音频:编解码、设备 IO、DSP、容器与流式处理。 | [![NuGet](https://img.shields.io/nuget/dt/NewLife.Audio?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.Audio) | | [NewLife.Video](https://github.com/NewLifeX/NewLife.Video) | 视频编解码、封装格式、帧处理与流媒体。 | [![NuGet](https://img.shields.io/nuget/dt/NewLife.Video?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.Video) | | [NewLife.Map](https://github.com/NewLifeX/NewLife.Map) | 百度/高德/腾讯/天地图统一接口,支持地理编码与坐标转换。 | [![NuGet](https://img.shields.io/nuget/dt/NewLife.Map?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.Map) | | [NewLife.IP](https://github.com/NewLifeX/NewLife.IP) | IPv4 归属地:离线内存映射库 + 在线 API 双源。 | [![NuGet](https://img.shields.io/nuget/dt/NewLife.IP?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.IP) | | [NewLife.Holiday](https://github.com/NewLifeX/NewLife.Holiday) | 中国假期识别库:内置每年假期与调休数据,支持农历节日,完全离线。 | [![NuGet](https://img.shields.io/nuget/dt/NewLife.Holiday?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.Holiday) | | **工具与产品** | | | | [CrazyCoder](https://github.com/NewLifeX/XCoder) | 码神工具:网络、串口、加解密、正则、Modbus 与 MQTT。 | [![NuGet](https://img.shields.io/nuget/dt/NewLife.XCoder?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.XCoder) | | [NewLife.UnitTest](https://github.com/NewLifeX/NewLife.UnitTest) | 单元测试扩展库:测试基类、数据驱动与依赖注入辅助。 | [![NuGet](https://img.shields.io/nuget/dt/NewLife.UnitTest?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.UnitTest) | | [GitCandy](https://github.com/NewLifeX/GitCandy) | 自托管 Git 源代码管理系统。 | — | | [LuckyClover](https://github.com/NewLifeX/LuckyClover) | 从低版本宿主启动时,自动安装匹配的 .NET 运行时。 | — | > 徽章取各项目主包;主题包、扩展包与卫星包见对应 NuGet 页面。未在表中列出的 30 多个包(FTP、Office 扩展、各类协议驱动等)见 [NewLifeX 组织](https://github.com/NewLifeX) 与 [newlifex.com](https://newlifex.com)。 ## 文档与示例 | 文档 | 说明 | | --- | --- | | [需求文档](/NewLife/NewLife.Vision/Blob/master/Doc/需求文档.md) | 愿景、目标、模块范围与不做什么 | | [功能清单](/NewLife/NewLife.Vision/Blob/master/Doc/功能清单.md) | 实现、测试、注释三维状态 | | [架构设计](/NewLife/NewLife.Vision/Blob/master/Doc/架构设计.md) | 分层、契约、管线与适配边界 | | [竞品分析](/NewLife/NewLife.Vision/Blob/master/Doc/竞品分析.md) | 引擎对比与差异化定位 | | [性能测试](/NewLife/NewLife.Vision/Blob/master/Doc/性能测试.md) | 核心链路的实测耗时与内存分配 | | [更新记录](/NewLife/NewLife.Vision/Blob/master/Doc/ChangeLog.md) | 正式发版时生成的版本记录 | ## 参与贡献 ```bash dotnet build -c Release dotnet test -c Release ``` 欢迎提交 Issue 与 Pull Request。公共 API 不得出现第三方引擎类型,每个新行为请补充聚焦的测试。 ## 许可证 MIT License ## 团队 <img src="https://newlifex.com/logo.png" width="48" align="right" alt="NewLife" /> 新生命团队成立于 2002 年,二十余年深耕 .NET 与物联网生态,维护近百个开源项目。开源组件在 NuGet 上累计下载 <!--nuget-total:start-->6.48M<!--nuget-total:end--> 次(生态整体,截至 2026-10)。 官网:https://newlifex.com · 开源组织:https://github.com/NewLifeX