关于读出图片中数字的代码,现在已有但只能读出四个数字来,无论你图片上有多少数字有没有高手愿意帮忙看看,修改一下了,愿意的留下邮箱我把程序发过去.  希望懂的大哥帮帮忙.

解决方案 »

  1.   

    我搞过图片识别,发一个给我吧:[email protected]
      

  2.   

    帮你研究研究 [email protected]
      

  3.   

    兄弟,你给我们发的是什么呀,最主要的kind1.pas都不发,我们怎么帮你。
    怕我们偷你的技术吗?
    50%的识别率
      

  4.   

    图片已经在image1里了,直接bmp.Assign(image1.Picture );不就得了,非得绕一圈,从文件读入,还得考虑不同的图片格式。
    一句话:无语
      

  5.   

    由于有三个文件comm.pas\func.pas\kind1.pas好像我删掉了照样可以运行也没有出错所以没有发给你们.
      

  6.   

    发过来研究一下,谢谢!!
    [email protected]
      

  7.   

    发过来研究一下,谢谢!! 
    [email protected]
      

  8.   

    发过来研究一下,[email protected]
      

  9.   


    发过来研究一下,[email protected]
      

  10.   

    你发过来吧,我接触过 [email protected]
      

  11.   

    邮件都已经发送了,之前小发了一个KIND望各位帮助的高手原谅.
    18楼你没有留下邮箱我发不过去啊.
      

  12.   

       
    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_rate ;    
           property Number:String read GetNumber;    
           property Stop:Boolean read Fstop write FStop;    
           property ShowDemo:Boolean read FShowDemo write FShowDemo;    
         end;    
       
    //SourceBitmap:电表图片,template_index:调用的模板号    template_path;模板存放的目录    
       
           
    Function Pic2Bmp(PicFileName:String):TBitmap;    
       
       
    implementation   
       
    //将图片转换成BMP格式,以便比较,主要是因为数码相机采集的图片基本上是JPEG 格式的。    
    //所以在装入时需要将其转换成BMP图片,便于比较    
    Function Pic2Bmp(PicFileName:String):TBitmap;    
    var   
       Str:String;    
       Icon: TIcon;    
       Jpeg1:TJPEGIMAGE;    
       MetaFile:TMetafile;    
    begin   
    result:=TBitMap.create;    
    result.PixelFormat:=pf24bit;    
    Str := ExtractFileExt(PicFileName);    
    Str :=Uppercase(Copy(Str,2,3));    
       if (Str='BMP')    then   
           result.LoadFromFile(PicFileName)    
       else   //Jpeg转换成BMP    
       if (Str='JPG') or (Str='JPEG') then   
       begin   
         Jpeg1 := TJPEGIMAGE.Create;    
         Jpeg1.LoadFromFile(PicFileName);    
         result.Assign(Jpeg1);    
         Jpeg1.free;    
       end   
       else        //ICO 转换成BMP    
       if (Str='ICO') or (Str='ico') then   
       begin   
          Icon := TIcon.Create;    
          Icon.LoadFromFile(PicFileName);    
          result := TBitmap.Create;    
          result.Width := Icon.Width;    
          result.Height := Icon.Height;    
          result.Canvas.Draw(0, 0, Icon);    
          Icon.Free;    
       
       end   
       else   //WMF转换成BMP    
       if Str='WMF' then   
       begin   
           Metafile:=TMetaFile.create;    
            
           MetaFile.LoadFromFile(PicFileName);    
          with result do   
          begin   
             Height:=Metafile.Height;    
             Width:=Metafile.Width;    
             Canvas.Draw(0,0,MetaFile);    
       
          end;    
          MetaFile.Free;    
       end;    
       
    end;    
       
    constructor TBmp2Number.Create;    
    begin   
       inherited Create;    
       Ftempl_index:=1;    
       Ftempl_Path:='template';    
       Fdiscern_rate:=100;    
    end;    
       
      

  13.   

    //设置模板索引    
    procedure TBmp2Number.SetTempl_index(value:integer);    
    begin   
       FtempL_index:=Value;    
       initTemplate;    
    end;    
       
    procedure TBmp2Number.SetTempl_path(value:String);    
    begin   
       FTempl_path:=value;    
       initTemplate;    
    end;    
       
    //初始化运行模板库    
    procedure TBmp2Number.InitTemplate;    
    begin   
       if tempL_Index=0 then exit;    
       if Not DirectoryExists(Templ_Path) then exit;    
          
    end;    
       
    //逐行扫描的方式识别图片中的数字    
    function TBmp2Number.GetNumber:string;    
       
    var   
       tmpleBmp,midbmp:TBitMap;    
       row,Col,mRow,mCol,numberNo:integer;    
       NewRow,NewCol:integer;    
       PSource, Ptemple: pRGBTripleArray;    
       mR, mG, mB, tR, tG, tB: Integer;    
       mP, tP: pRGBTripleArray;    
       succ:Boolean;//对比是否成功    
    begin   
       //数据的初步检查    
       if sourcebitmap=nil then   
       begin   
         showmessage('请装入目标图片!');    
         exit;    
       end;    
       FNumberList:=Tlist.Create;    
       try   
       if assigned(pb_Count) then   
          pb_Count.Max:= SourceBitMap.width;    
         if assigned(pb_deta) then   
           pb_deta.Max:= SourceBitMap.Height;       
             
       for Col:=0 to   SourceBitMap.width-1 do   
       begin   
        if stop then exit;    
         if   ShowDemo then   
         memo1.Lines.Add('本列是:'+inttostr(col));    
         if assigned(pb_Count) then   
         begin   
          pb_Count.Position:=col;    
          Application.ProcessMessages;    
         end;    
         for Row:=0 to SourceBitMap.Height-1    do   
         begin   
            if assigned(pb_deta) then   
             begin   
               pb_deta.Max:= SourceBitMap.Height;    
               pb_deta.Position:=Row;    
               Application.ProcessMessages;    
             end;    
           if stop then exit;    
           for numberNo:=0 to 9 do    //0至9的数字分别装入模板    
           begin   
             if     not fileexists(Templ_Path+inttostr(numberNo)+'_'+inttostr(Templ_index)+'.bmp') then continue;    
       
               if stop then exit;    
              tmpleBmp:=TBitMap.create;    
              tmpleBmp:=Pic2Bmp(Templ_Path+inttostr(numberNo)+'_'+inttostr(Templ_index)+'.bmp');    
    //          tmpleBmp.LoadFromFile(Templ_Path+inttostr(numberNo)+'_'+inttostr(Templ_index)+'.bmp');    
               if   ShowDemo then   
              image1.Picture.bitmap:=tmplebmp;    
                
              //从原图像中驳离出来与模板文件同样大小的文件来    
              midbmp:=Tbitmap.Create;    
              midbmp.PixelFormat:= tmpleBmp.PixelFormat;    
              midbmp.Width:=tmplebmp.Width;    
              midbmp.height:=tmplebmp.Height;    
       
              application.ProcessMessages;    
            //    
       
              midbmp.Canvas.CopyRect(Rect(0,0,midbmp.width,midbmp.height),    
                     sourcebitmap.canvas,    
                     Rect(Col,row,Col+tmpleBmp.width,row+tmpleBmp.height));    
              if   ShowDemo then   
                    image2.picture.bitmap:=midbmp;    
               Assert(midbmp.PixelFormat = tmpleBmp.PixelFormat);    
              //然后逐行取值比较    
              for mRow:=0 to MidBmp.Height-1 do   
              begin   
                mp:= midBmp.ScanLine[mRow];    
                tp:= tmplebmp.ScanLine[mRow];    
                   if stop then exit;    
                for mcol:=0 to MidBmp.Width -1 do   
                begin   
                 if stop then exit;    
                  mR := mp[mcol].rgbtRed;    
                  mG := mP[mcol].rgbtGreen;    
                  mB := mP[mcol].rgbtBlue;    
                  tR := tP[mcol].rgbtRed;    
                  tG:= tP[mcol].rgbtGreen;    
                  tB:=tP[mcol].rgbtBlue;    
                 if   ShowDemo then   
                  memo1.Lines.Add('Mrow:'+Inttostr(mrow)+'MCol:'+inttostr(Mcol)+'mr:'   
                  +inttostr(mr)+'mg:'+inttostr(mg)+'mb:'+    
                    inttostr(mb)+'tr:'+inttostr(tr)+'tg:'+inttostr(tg)+'tb:'+    
                    inttostr(tb));    
                  if (mR <> tR) or (mG <> tG) or (mB <> tB) then//如果像素不等    
                  begin   
                    succ:=false;    
                    break;    
       
                  end   
                  else   
                  succ:=true;    
       
                end; // end mcol:=0 to midbmp.width -1 do    
       
       
            end;    //end mrow:=0 to midbmp.height-1 do    
            freeandnil(midbmp);    
             if succ then   
              begin//对比成功    
               new(tmeplate);    
               tmeplate.number:= numberNo;    
               tmePlate.top := Row;    
               tmePlate.left:=col;    
               FNumberList.Add(tmeplate);    
              end   ;    
             // else    
             //   break;    
             freeandnil(tmpleBmp);    
          end;               //end for number    
       
       
        end;     //end for row    
        end; // end for col    
        except   
          showmessage('对比失败!');    
        end;    
       
    for    row:=0 to   FNumberList.Count -1 do   
        Result:=result+inttostr(Ptemplate(FNumberlist.Items[row]).number);    
    for row:=FNumberList.count-1 downto 0 do   
    begin   
       Dispose(Ptemplate(FNumberList[Row]));    
       FNumberlist.Delete(row);    
    end;    
    FNumberlist.free;    
    end;    
       
       
       
    end.  
     
    这个大家帮忙看看能不能让其读出八位的数字.
      

  14.   

    //逐行扫描的方式识别图片中的数字    
    function TBmp2Number.GetNumber:string;    
       
    var   
       tmpleBmp,midbmp:TBitMap;    
       row,Col,mRow,mCol,numberNo:integer;    
       NewRow,NewCol:integer;    
       PSource, Ptemple: pRGBTripleArray;    
       mR, mG, mB, tR, tG, tB: Integer;    
       mP, tP: pRGBTripleArray;    
       succ:Boolean;//对比是否成功    
    begin   
       //数据的初步检查    
       if sourcebitmap=nil then   
       begin   
         showmessage('请装入目标图片!');    
         exit;    
       end;    
       FNumberList:=Tlist.Create;    
       try   
       if assigned(pb_Count) then   
          pb_Count.Max:= SourceBitMap.width;    
         if assigned(pb_deta) then   
           pb_deta.Max:= SourceBitMap.Height;       
             
       for Col:=0 to   SourceBitMap.width-1 do   
       begin   
        if stop then exit;    
         if   ShowDemo then   
         memo1.Lines.Add('本列是:'+inttostr(col));    
         if assigned(pb_Count) then   
         begin   
          pb_Count.Position:=col;    
          Application.ProcessMessages;    
         end;    
         for Row:=0 to SourceBitMap.Height-1    do   
         begin   
            if assigned(pb_deta) then   
             begin   
               pb_deta.Max:= SourceBitMap.Height;    
               pb_deta.Position:=Row;    
               Application.ProcessMessages;    
             end;    
           if stop then exit;    
           for numberNo:=0 to 9 do    //0至9的数字分别装入模板    
           begin   
             if     not fileexists(Templ_Path+inttostr(numberNo)+'_'+inttostr(Templ_index)+'.bmp') then continue;    
       
               if stop then exit;    
              tmpleBmp:=TBitMap.create;    
              tmpleBmp:=Pic2Bmp(Templ_Path+inttostr(numberNo)+'_'+inttostr(Templ_index)+'.bmp');    
    //          tmpleBmp.LoadFromFile(Templ_Path+inttostr(numberNo)+'_'+inttostr(Templ_index)+'.bmp');    
               if   ShowDemo then   
              image1.Picture.bitmap:=tmplebmp;    
                
              //从原图像中驳离出来与模板文件同样大小的文件来    
              midbmp:=Tbitmap.Create;    
              midbmp.PixelFormat:= tmpleBmp.PixelFormat;    
              midbmp.Width:=tmplebmp.Width;    
              midbmp.height:=tmplebmp.Height;    
       
              application.ProcessMessages;    
            //    
       
              midbmp.Canvas.CopyRect(Rect(0,0,midbmp.width,midbmp.height),    
                     sourcebitmap.canvas,    
                     Rect(Col,row,Col+tmpleBmp.width,row+tmpleBmp.height));    
              if   ShowDemo then   
                    image2.picture.bitmap:=midbmp;    
               Assert(midbmp.PixelFormat = tmpleBmp.PixelFormat);    
              //然后逐行取值比较    
              for mRow:=0 to MidBmp.Height-1 do   
              begin   
                mp:= midBmp.ScanLine[mRow];    
                tp:= tmplebmp.ScanLine[mRow];    
                   if stop then exit;    
                for mcol:=0 to MidBmp.Width -1 do   
                begin   
                 if stop then exit;    
                  mR := mp[mcol].rgbtRed;    
                  mG := mP[mcol].rgbtGreen;    
                  mB := mP[mcol].rgbtBlue;    
                  tR := tP[mcol].rgbtRed;    
                  tG:= tP[mcol].rgbtGreen;    
                  tB:=tP[mcol].rgbtBlue;    
                 if   ShowDemo then   
                  memo1.Lines.Add('Mrow:'+Inttostr(mrow)+'MCol:'+inttostr(Mcol)+'mr:'   
                  +inttostr(mr)+'mg:'+inttostr(mg)+'mb:'+    
                    inttostr(mb)+'tr:'+inttostr(tr)+'tg:'+inttostr(tg)+'tb:'+    
                    inttostr(tb));    
                  if (mR <> tR) or (mG <> tG) or (mB <> tB) then//如果像素不等    
                  begin   
                    succ:=false;    
                    break;    
       
                  end   
                  else   
                  succ:=true;    
       
                end; // end mcol:=0 to midbmp.width -1 do    
       
       
            end;    //end mrow:=0 to midbmp.height-1 do    
            freeandnil(midbmp);    
             if succ then   
              begin//对比成功    
               new(tmeplate);    
               tmeplate.number:= numberNo;    
               tmePlate.top := Row;    
               tmePlate.left:=col;    
               FNumberList.Add(tmeplate);    
              end   ;    
             // else    
             //   break;    
             freeandnil(tmpleBmp);    
          end;               //end for number    
       
       
        end;     //end for row    
        end; // end for col    
        except   
          showmessage('对比失败!');    
        end;    
       
    for    row:=0 to   FNumberList.Count -1 do   
        Result:=result+inttostr(Ptemplate(FNumberlist.Items[row]).number);    
    for row:=FNumberList.count-1 downto 0 do   
    begin   
       Dispose(Ptemplate(FNumberList[Row]));    
       FNumberlist.Delete(row);    
    end;    
    FNumberlist.free;    
    end;    
       
       
       
    end.  
    有人指点一下这个吗?
      

  15.   

    这样不方便看,太多,发吧。
    [email protected]
      

  16.   

    以前搞过论坛验证码识别。
    改起来应该不复杂,[email protected]
      

  17.   

    [email protected]
    看看也学习下。
      

  18.   

    谢了!发给我一个吧。[email protected]
    了解下
      

  19.   

    发过来,我帮你看一下 [email protected]
      

  20.   

    发来,我看看
    [email protected]
      

  21.   

    你好,发来一份研究一下,谢谢,[email protected]