docs: 添加项目 README,说明愿景与目标
大石头 authored at 2026-12-02 00:23:01
18.68 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-CN.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` with a single async entry point 與 cancellation support | | 內建範本辨識 | 純受控範本比對,隨套件分發,無模型檔案 | | OCR 管線 | Score filtering, region sorting 與 line-aware text merging on top of any engine | | 區域模型 | Text, confidence, bounding box 與 tilt angle for every detected line | | 優雅降級 | 辨識不到時回傳空結果與分數,不拋例外 | </details> <details> <summary><b>條碼</b> (4 項)</summary> | 能力 | 提供的價值 | | --- | --- | | 引擎契約 | `IBarcodeReader` returns text, format 與 bounding box per result | | 內建解碼 | 純受控支援 QR、Code128、Code39、Code93、EAN-13、EAN-8 與 UPC-A,無需第三方套件 | | 條碼 pipeline | Duplicate removal by content 與 format, plus `MaxResults` truncation | | 碼制選擇 | Restrict decoding to the codes you expect to cut latency on busy images | </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` wraps any buffer with offset, stride 與 five packed pixel formats | | 影像互轉 | `ImageFrame` 與 `VisionImage` 在核心套件內雙向互轉 | | 零複製檢視 | Row 與 pixel spans expose the underlying buffer without copies | </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、API、服務、資料與物聯網。 | [![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) | 建構於 NewLife 資料堆疊之上的 MySql 驅動與輔助層。 | [![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) | 物聯網標準庫,定義通訊協定契約與裝置抽象。 | [![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) | 建構於 NewLife.IoT 之上的 Modbus TCP/RTU/ASCII 實作。 | [![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) | 建構於 NewLife.IoT 之上的西門子 PLC 協定。 | [![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) | 建構於 NewLife.IoT 之上的歐姆龍 PLC 協定。 | [![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) | 建構於 NewLife.IoT 之上的三菱 Melsec PLC 協定。 | [![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) | 開源輕量級物聯網平台,含閘道與裝置管理。 | — | | **車聯網** | | | | [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) | Vision, goals, module scope 與 non-goals | | [功能清單](/NewLife/NewLife.Vision/Blob/master/Doc/功能清单.md) | Feature status across implementation, testing 與 comments | | [架構設計](/NewLife/NewLife.Vision/Blob/master/Doc/架构设计.md) | Layers, contracts, pipelines 與 adapter boundaries | | [競品分析](/NewLife/NewLife.Vision/Blob/master/Doc/竞品分析.md) | Engine comparison 與 positioning | | [效能測試](/NewLife/NewLife.Vision/Blob/master/Doc/性能测试.md) | 核心鏈路的實測耗時與記憶體配置 | | [更新記錄](/NewLife/NewLife.Vision/Blob/master/Doc/ChangeLog.md) | 正式發佈時產生的版本記錄 | ## 參與貢獻 ```bash dotnet build -c Release dotnet test -c Release ``` Issues 與 pull requests are welcome. Please keep public API free of third-party engine types 與 add a focused test for every new behavior. ## 授權條款 MIT License ## 團隊 <img src="https://newlifex.com/logo.png" width="48" align="right" alt="NewLife" /> Founded in 2002, the NewLife team has spent more than two decades on the .NET 與 IoT ecosystem 與 maintains nearly 100 open-source projects. Open-source components have been downloaded <!--nuget-total:start-->6.48M<!--nuget-total:end--> times from NuGet (ecosystem-wide, as of 2026-10). 官方網站:https://newlifex.com · 開源組織:https://github.com/NewLifeX