使用DELPHI对图片中的文字进行识别的过程(最简单实现)

该博客介绍了如何使用DELPHI进行图像中的数字识别,采用模式识别方法,适用于标准无反光的电表数字识别。程序不处理小数位,能识别4位整数。文章详细讲解了关键代码,包括图片转换、模板匹配和对比过程。
摘要由CSDN通过智能技术生成
unit bmp2number;
{将传递进来的图像进行对比,识别出图片中的数字。
本程序使用的是模式识别的方式,需要照片标准,数字无反光。
电表只有4位数字+1位小数,小数因为在拍照中不能保证停止,所以本程序也不作小数位的识别
因此。如果当前的数字 已经识别到了4位,程序就返回,
我们预设一个记录,用来记录这被识别的出4位数字的具体位置,再通过对TOP及LEFT位置的进行排序组合后返回
对于本模板的重要方法说明:
Function GetNumber:string
功能:返回识别出的数字字符串
按照对TBmp2Number对象的下列属性:
  SoruceBitmap:需要被识别的图像
  Temp_Index:模板编号
  Temp_path:模板文件目录
  discern_rate:识别率

}

interface
uses windows,math,classes,controls,graphics,jpeg,sysutils,dialogs,extctrls,forms,
stdctrls,ComCtrls;

Type
  pRGBTripleArray = ^TRGBTripleArray;
  TRGBTripleArray = array [0 .. 65535] of TRGBTriple;
  Ptemplate=^Ttemplate;  //被识别的数字当用记录保存起来
  Ttemplate=record
    number:integer;
    top:Integer;
    Left:Integer;
  end;
  
  TBmp2Number=class(Tobject)
    private
     FSourceBitMap:Tbitmap;
     FTempl_index:integer;
     Ftempl_Path:String;
     Fdiscern_rate:Double;
     FNumber:string;
     FNumberList:TList;
     tmeplate:Ptemplate;
     fStop:Boolean;
     FShowDemo:Boolean;
    protected
      procedure SetTempl_index(value:Integer);
      procedure SetTempl_path(Value:String);
      procedure InitTemplate;
      Function GetNumber:String;
     
    public
      memo1:TRichedit;
      image1,image2:Timage;
      pb_Count,pb_deta:TProgressbar;
      constructor Create;
   
    published
      property SourceBitMap:Tbitmap read FSourceBitMap write FSourceBitmap;
      property Templ_index:integer read Ftempl_index write SetTempl_index;
      Property Templ_Path:String read Ftempl_Path write SetTempl_path;
      property discern_rate:Double read Fdiscern_rate write Fdiscern_ra
  • 2
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值