c# 视觉识别图片文字 二维码
1.二维码识别 插件 ZXing.Net
using System;
using System.Drawing; // 如果你使用的是System.Drawing.Common
using ZXing;class Program
{static void Main(){string imagePath = "path_to_your_qr_code_image.png";var barcodeBitmap = (Bitmap)Image.FromFile(imagePath);var barcodeReader = new BarcodeReader();var result = barcodeReader.Decode(barcodeBitmap);if (result != null){Console.WriteLine("二维码内容: " + result.Text);}else{Console.WriteLine("未能识别二维码内容");}}
}2.识别字符 插件:Tesseract
using System;
using System.Drawing;
using Tesseract;class Program
{static void Main(){string imagePath = "path_to_your_image.png";// 确保已下载并引用了 Tesseract 的语言数据文件(.traineddata)string tessdataPath = "path_to_tessdata"; // 通常包含 "eng.traineddata" 等文件using (var engine = new TesseractEngine(tessdataPath, "eng", EngineMode.Default)){using (var img = Pix.LoadFromFile(imagePath)){using (var page = engine.Process(img)){Console.WriteLine("识别结果: " + page.GetText());Console.WriteLine("置信度: " + page.GetMeanConfidence());}}}}
}
裁剪图片:
public static void caijian(string inputPath, string outputPath,int x,int y,int width,int height){// 加载原始图片using (Bitmap originalBitmap = new Bitmap(inputPath)){// 定义裁剪区域(x, y, width, height)Rectangle cropArea = new Rectangle(x, y, width, height); // 修改这些值以适应你的需求// 创建裁剪后的图片using (Bitmap croppedBitmap = CropImage(originalBitmap, cropArea)){// 保存裁剪后的图片croppedBitmap.Save(outputPath);}}}static Bitmap CropImage(Bitmap source, Rectangle cropArea){// 确保裁剪区域在源图像范围内if (cropArea.X < 0 || cropArea.Y < 0 || cropArea.Right > source.Width || cropArea.Bottom > source.Height){throw new ArgumentException("裁剪区域超出了图像边界");}Bitmap croppedImage = new Bitmap(cropArea.Width, cropArea.Height);using (Graphics g = Graphics.FromImage(croppedImage)){g.DrawImage(source, new Rectangle(0, 0, cropArea.Width, cropArea.Height),cropArea, GraphicsUnit.Pixel);}return croppedImage;}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Net.Mime.MediaTypeNames;
using System.Drawing; // 如果你使用的是System.Drawing.Common
using ZXing;
using Tesseract;namespace ConsoleApp1
{class Program{static void Main(string[] args){string outimagePath1 = Environment.CurrentDirectory + "\\outLab.jpg";string outimagePath2 = Environment.CurrentDirectory + "\\outStart.jpg";string imagePath3 = Environment.CurrentDirectory + "\\333330.jpg";caijian(imagePath3, outimagePath1, 1600, 1250, 1500, 350);Getlab(outimagePath1);caijian(imagePath3, outimagePath2,475,873,738,673);GetChistring(outimagePath2);Console.Read();}public static void caijian(string inputPath, string outputPath,int x,int y,int width,int height){// 加载原始图片using (Bitmap originalBitmap = new Bitmap(inputPath)){// 定义裁剪区域(x, y, width, height)Rectangle cropArea = new Rectangle(x, y, width, height); // 修改这些值以适应你的需求// 创建裁剪后的图片using (Bitmap croppedBitmap = CropImage(originalBitmap, cropArea)){// 保存裁剪后的图片croppedBitmap.Save(outputPath);}}}static Bitmap CropImage(Bitmap source, Rectangle cropArea){// 确保裁剪区域在源图像范围内if (cropArea.X < 0 || cropArea.Y < 0 || cropArea.Right > source.Width || cropArea.Bottom > source.Height){throw new ArgumentException("裁剪区域超出了图像边界");}Bitmap croppedImage = new Bitmap(cropArea.Width, cropArea.Height);using (Graphics g = Graphics.FromImage(croppedImage)){g.DrawImage(source, new Rectangle(0, 0, cropArea.Width, cropArea.Height),cropArea, GraphicsUnit.Pixel);}return croppedImage;}public static void GetChistring(string imagePath){try{// 确保已下载并引用了 Tesseract 的语言数据文件(.traineddata)//var engine = new TesseractEngine(tessdataPath, "chi_sim", EngineMode.LstmOnly)string tessdataPath = Environment.CurrentDirectory+ "\\tessdata"; // 通常包含 "eng.traineddata" 等文件var engine = new TesseractEngine(tessdataPath, "chi_sim", EngineMode.Default | EngineMode.LstmOnly);var img = Pix.LoadFromFile(imagePath);var page = engine.Process(img);Console.WriteLine("识别结果: " + page.GetText());Console.WriteLine("置信度: " + page.GetMeanConfidence());}catch (Exception e){Console.WriteLine(e);}}public static void GetENstring(string imagePath){try{// 确保已下载并引用了 Tesseract 的语言数据文件(.traineddata)//var engine = new TesseractEngine(tessdataPath, "chi_sim", EngineMode.LstmOnly)string tessdataPath = Environment.CurrentDirectory + "\\tessdata"; // 通常包含 "eng.traineddata" 等文件var engine = new TesseractEngine(tessdataPath, "eng", EngineMode.Default | EngineMode.LstmOnly);var img = Pix.LoadFromFile(imagePath);var page = engine.Process(img);Console.WriteLine("识别结果: " + page.GetText());Console.WriteLine("置信度: " + page.GetMeanConfidence());}catch (Exception e){Console.WriteLine(e);}}public static void Getlab(string imagePath){var barcodeBitmap = (Bitmap)System.Drawing.Image.FromFile(imagePath);var barcodeReader = new BarcodeReader{Options = new ZXing.Common.DecodingOptions{// 支持多种条形码格式,包括二维码PossibleFormats = new List<BarcodeFormat>{BarcodeFormat.CODE_128, BarcodeFormat.CODE_39, BarcodeFormat.EAN_13,BarcodeFormat.EAN_8, BarcodeFormat.UPC_A, BarcodeFormat.UPC_E,BarcodeFormat.QR_CODE, BarcodeFormat.DATA_MATRIX}}};var result = barcodeReader.Decode(barcodeBitmap);if (result != null){Console.WriteLine("识别内容: " + result.Text);}else{Console.WriteLine("未能识别内容");}}}
}
将图片用Windows画图打开确认像素点 和大小进行裁剪后交给算法识别;

GitCode - 全球开发者的开源社区,开源代码托管平台
下载训练模型:chi_sim.traineddata 中文
下载训练模型:eng.traineddata 英文
相关文章:
c# 视觉识别图片文字 二维码
1.二维码识别 插件 ZXing.Net using System; using System.Drawing; // 如果你使用的是System.Drawing.Common using ZXing;class Program {static void Main(){string imagePath "path_to_your_qr_code_image.png";var barcodeBitmap (Bitmap)Image.FromFile(im…...
UEFI——访问PCI/PCIE设备(二)
一、支持访问PCI/PCIE设备的Protocol UEFI中提供了两个主要的模块来支持PCI总线,一是PCI Host Bridge(PCI主桥)控制器驱动,另一个是PCI总线驱动。这两个模块是和特定的平台硬件绑定的,在这种机制下,屏蔽了…...
决策树算法的介绍与应用
目录 引言 决策树算法的基本原理 表格总结:决策树的构建步骤 决策树算法的 MATLAB 实现 示例:使用决策树进行分类预测 决策树的应用场景 表格总结:决策树的主要应用领域 决策树的优势与局限 结论 引言 决策树是一种广泛应用于数据挖掘…...
杰发科技Bootloader(3)—— 基于7801的APP切到Boot
为了方便在APP中跳转到Boot重新进行升级,有两种办法,7840同样可以使用。 1. 调用reset接口进行复位,复位后会先进Boot,再自动跳转到App。 NVIC_SystemReset(); 2. 直接使用跳转指令,参考Boot跳转到App代码࿰…...
Leetcode面试经典150题-138.随机链表的复制
题目比较简单,重点是理解思想,random不管,copy一定要放在next 而且里面的遍历过程不能省略 解法都在代码里,不懂就留言或者私信 /* // Definition for a Node. class Node {int val;Node next;Node random;public Node(int val…...
freemarker模板学习笔记
文章目录 freemarker常用指令if-elseif-else指令switch, case, default, break指令list, else, items, sep, break 指令<#list>指令语法<#else> 指令<#items> 指令<#sep> 指令<#break> 指令 include 指令<#include> 基础知识<#include&…...
高亚科技与广东海悟携手,打造全流程电子竞标管理平台!
近日,中国企业管理软件资深服务商高亚科技与广东海悟科技有限公司(以下简称“海悟”)正式签署合作协议,双方将基于高亚科技的8Manage SRM系统,推进海悟采购管理的数字化升级,实现全流程在线电子竞标管理&am…...
240908-结合DBGPT与Ollama实现RAG本地知识检索增强
A. 最终效果 B. 背景说明 DBGPT在0.5.6版本中开始支持Ollama:v0.5.6 版本更新 网友对其Web端及界面端的设置进行了分享: feat(model): support ollama as an optional llm & embedding proxy by GITHUBear Pull Request #1475 eosphoros-ai/DB-G…...
AMD ThinkSystem服务器上的 Linux 和 C 状态设置 - Lenovo ThinkSystem
受影响的配置 该系统可以是以下任何Lenovo服务器: ThinkSystem 、SR645( ThinkSystem )ThinkSystem ,SR645 V3( ThinkSystem )ThinkSystem ,SR635 V3( ThinkSystem )Th…...
Redis过期删除和缓存淘汰
1. 过期删除 在 Redis 中,键的过期删除机制主要包括惰性删除(Lazy Deletion)和定期删除(Periodic Deletion)。这两种策略有各自的优缺点,Redis 最终会结合这两种方法来管理过期键。 1.1 惰性删除…...
Golang | Leetcode Golang题解之第401题二进制手表
题目: 题解: func readBinaryWatch(turnedOn int) (ans []string) {for i : 0; i < 1024; i {h, m : i>>6, i&63 // 用位运算取出高 4 位和低 6 位if h < 12 && m < 60 && bits.OnesCount(uint(i)) turnedOn {ans …...
TON智能合约stdlib_ext库:扩展功能一览
TON(TheOpenNetwork)作为一个去中心化的区块链平台,其智能合约功能强大而灵活。在TON智能合约的开发过程中,stdlib.fc库提供了基础的功能支持。然而,对于一些高级或特定的需求,stdlib.fc可能无法满足。为此…...
LabVIEW开发FPGA方法与FIFO数据丢失处理
开发基于NI 7975R FPGA的系统涉及一系列流程,包括驱动安装、LabVIEW项目设置、开发调试、编译和与Windows系统的通信。重点在于FIFO的正确配置,避免数据丢失是关键环节之一,尤其是在使用高速数据流传输时。以下将详细介绍这些过程,…...
Python中的内存池机制
在Python中,内存管理是一个复杂但至关重要的主题,它直接关系到程序的性能和稳定性。Python的内存管理机制包括对象的分配、追踪以及回收,其中内存池(Memory Pool)是这一机制中的一个重要组成部分。内存池机制通过预先分…...
智能家居系统(基于STM32F103C8T6标准库+FreeRTOS+Qt串口开发实现)
视频演示:基于STM32F103C8T6标准库FreeRTOSQt串口开发实现的智能家居项目_哔哩哔哩_bilibili 基于STM32F103C8T6标准库FreeRTOSQt串口开发实现的智能家居项目: https://pan.baidu.com/s/1f41gAfOOnlcQoKoMx3o84A?pwd6j2g 提取码: 6j2g 注:本项目为学习完…...
[数据集][目标检测]脊椎检测数据集VOC+YOLO格式1137张1类别
数据集格式:Pascal VOC格式YOLO格式(不包含分割路径的txt文件,仅仅包含jpg图片以及对应的VOC格式xml文件和yolo格式txt文件) 图片数量(jpg文件个数):1137 标注数量(xml文件个数):1137 标注数量(txt文件个数):1137 标注…...
大受欢迎的游戏却又意外被作者下架的《Flappy Bird》将重返iPhone
据"Flappy Bird 基金会"官网称,标志性的侧卷轴滚动游戏《Flappy Bird》将很快回归 iPhone。《Flappy Bird》于 2013 年发布,很快就获得了数千万次下载。然而,这款游戏在2014 年突然从 App Store 下架,原因是其越南开发者…...
Flutter类
Dart中的对象都继承自 Object 类,单继承(extend关键字)。Dart与Java、kotlin不同的是其无public、private、protected修饰符,默认public ,通过在属性名、方法名前加 _下划线 来定义是否私有。 实现一个简单的类 class…...
深入解析全连接层:PyTorch 中的 nn.Linear、nn.Parameter 及矩阵运算
文章目录 数学概念(全连接层,线性层)nn.Linear()nn.Parameter()Q1. 为什么 self.weight 的权重矩阵 shape 使用 ( out_features , in_features ) (\text{out\_features}, \text{in\_features}) (out_features,in_features)而不是 ( in_featur…...
缓存对象反序列化失败
未定义serialVersionUID,会自动生成序列化号 新增了属性,序列号就变了,导致缓存对象反序列化失败。 所有缓存对象必须指定序列化id! 那我如何找到未添加字段前 对象的序列化号呢?默认的序列化号是如何生成的呢&#…...
Golang 面试经典题:map 的 key 可以是什么类型?哪些不可以?
Golang 面试经典题:map 的 key 可以是什么类型?哪些不可以? 在 Golang 的面试中,map 类型的使用是一个常见的考点,其中对 key 类型的合法性 是一道常被提及的基础却很容易被忽视的问题。本文将带你深入理解 Golang 中…...
Appium+python自动化(十六)- ADB命令
简介 Android 调试桥(adb)是多种用途的工具,该工具可以帮助你你管理设备或模拟器 的状态。 adb ( Android Debug Bridge)是一个通用命令行工具,其允许您与模拟器实例或连接的 Android 设备进行通信。它可为各种设备操作提供便利,如安装和调试…...
UE5 学习系列(三)创建和移动物体
这篇博客是该系列的第三篇,是在之前两篇博客的基础上展开,主要介绍如何在操作界面中创建和拖动物体,这篇博客跟随的视频链接如下: B 站视频:s03-创建和移动物体 如果你不打算开之前的博客并且对UE5 比较熟的话按照以…...
【大模型RAG】Docker 一键部署 Milvus 完整攻略
本文概要 Milvus 2.5 Stand-alone 版可通过 Docker 在几分钟内完成安装;只需暴露 19530(gRPC)与 9091(HTTP/WebUI)两个端口,即可让本地电脑通过 PyMilvus 或浏览器访问远程 Linux 服务器上的 Milvus。下面…...
【CSS position 属性】static、relative、fixed、absolute 、sticky详细介绍,多层嵌套定位示例
文章目录 ★ position 的五种类型及基本用法 ★ 一、position 属性概述 二、position 的五种类型详解(初学者版) 1. static(默认值) 2. relative(相对定位) 3. absolute(绝对定位) 4. fixed(固定定位) 5. sticky(粘性定位) 三、定位元素的层级关系(z-i…...
[ICLR 2022]How Much Can CLIP Benefit Vision-and-Language Tasks?
论文网址:pdf 英文是纯手打的!论文原文的summarizing and paraphrasing。可能会出现难以避免的拼写错误和语法错误,若有发现欢迎评论指正!文章偏向于笔记,谨慎食用 目录 1. 心得 2. 论文逐段精读 2.1. Abstract 2…...
linux 错误码总结
1,错误码的概念与作用 在Linux系统中,错误码是系统调用或库函数在执行失败时返回的特定数值,用于指示具体的错误类型。这些错误码通过全局变量errno来存储和传递,errno由操作系统维护,保存最近一次发生的错误信息。值得注意的是,errno的值在每次系统调用或函数调用失败时…...
uniapp微信小程序视频实时流+pc端预览方案
方案类型技术实现是否免费优点缺点适用场景延迟范围开发复杂度WebSocket图片帧定时拍照Base64传输✅ 完全免费无需服务器 纯前端实现高延迟高流量 帧率极低个人demo测试 超低频监控500ms-2s⭐⭐RTMP推流TRTC/即构SDK推流❌ 付费方案 (部分有免费额度&#x…...
鱼香ros docker配置镜像报错:https://registry-1.docker.io/v2/
使用鱼香ros一件安装docker时的https://registry-1.docker.io/v2/问题 一键安装指令 wget http://fishros.com/install -O fishros && . fishros出现问题:docker pull 失败 网络不同,需要使用镜像源 按照如下步骤操作 sudo vi /etc/docker/dae…...
SAP学习笔记 - 开发26 - 前端Fiori开发 OData V2 和 V4 的差异 (Deepseek整理)
上一章用到了V2 的概念,其实 Fiori当中还有 V4,咱们这一章来总结一下 V2 和 V4。 SAP学习笔记 - 开发25 - 前端Fiori开发 Remote OData Service(使用远端Odata服务),代理中间件(ui5-middleware-simpleproxy)-CSDN博客…...
