登录 注册
当前位置:主页 > 资源下载 > 9 > 解析Delphi OCR图像中的文字

解析Delphi OCR图像中的文字

  • 更新:2024-11-22 22:35:50
  • 大小:211KB
  • 推荐:★★★★★
  • 来源:网友上传分享
  • 类别:Delphi - 后端
  • 格式:RAR

资源介绍

function identity(libName:pchar;mRound,bone,maxNoise,limit,spn,spx0,spy0,spuw,spuh,sppw,rlL,rlH,ruW,imgW,imgH:Integer;var imgAry:TBArray):string; var ary: TAAIArray; unitAry: TBArray; n,n1,x1,y1,x2,y2,unitW,unitH: Integer; rt: string; begin if spx0 < 0 then spx0 := 0; if spy0 < 0 then spy0 := 0; if spn = 0 then begin if (spx0<>0) or (spy0<>0) or (spuw<>0) or (spuh<>0) then cutArea(imgW,imgH,spx0,spy0,spuw,spuh,imgAry); ary := clearNoise(maxNoise,rlL,rlH,ruW,imgW,imgH,true,imgAry); end else begin n := (imgW-spx0-sppw) div (spuw+sppw) + 1; if (spn = -1) or (spn > n) then spn := n; //针对单元单独去除杂点 SetLength(unitAry,spuw*spuh); for n:=0 to spn-1 do begin for y1:=0 to spuh-1 do for x1:=0 to spuw-1 do unitAry[x1+y1*spuw] := imgAry[(y1+spy0)*imgW+x1+n*(spuw+sppw)+spx0]; clearNoise(maxNoise,1,1,spuw,spuw,spuh,false,unitAry); for y1:=0 to spuh-1 do for x1:=0 to spuw-1 do imgAry[(y1+spy0)*imgW+x1+n*(spuw+sppw)+spx0] := unitAry[x1+y1*spuw]; end; ary := splitArea(spn,spx0,spy0,spuw,spuh,sppw,imgW,imgAry); end; if Length(ary) = 0 then rt := '?' else rt := ''; for n:=0 to Length(ary)-1 do begin if Length(ary[n]) = 0 then continue; x1 := ary[n][0][0]; y1 := ary[n][0][1]; x2 := x1; y2 := y1; for n1:=1 to Length(ary[n])-1 do begin if ary[n][n1][0] < x1 then x1 := ary[n][n1][0]; if ary[n][n1][0] > x2 then x2 := ary[n][n1][0]; if ary[n][n1][1] < y1 then y1 := ary[n][n1][1]; if ary[n][n1][1] > y2 then y2 := ary[n][n1][1]; end; unitW := x2 - x1 + 1; unitH := y2 - y1 + 1; SetLength(unitAry,unitW*unitH); for n1:=0 to Length(unitAry)-1 do unitAry[n1] := 0; for n1:=0 to Length(ary[n])-1 do unitAry[(ary[n][n1][1]-y1)*unitW+ary[n][n1][0]-x1] := 1; rt := rt + unitIdentity(libName,mRound,bone,limit,unitW,unitH,unitAry); end; result := rt; end;