www.pudn.com > PlateDSP.rar > main.pas


unit main; 
 
interface 
 
uses 
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 
  Dialogs, OleCtrls, PlateDSP_TLB, ExtCtrls, StdCtrls; 
 
type 
  TForm1 = class(TForm) 
    PlateDSPX1: TPlateDSPX; 
    ImageCar: TImage; 
    ImagePlate: TImage; 
    LabelNumber: TLabel; 
    LabelType: TLabel; 
    LabelColor: TLabel; 
    LabelPercent: TLabel; 
    procedure FormShow(Sender: TObject); 
    procedure PlateDSPX1Recoged(Sender: TObject; PlateNum: Integer); 
  private 
    { Private declarations } 
  public 
    { Public declarations } 
  end; 
 
var 
  Form1: TForm1; 
 
implementation 
 
{$R *.dfm} 
 
procedure TForm1.FormShow(Sender: TObject); 
begin 
    LabelNumber.Caption := ''; 
    LabelType.Caption := ''; 
    LabelColor.Caption := ''; 
    LabelPercent.Caption := ''; 
 
    { connect #1 video capture card } 
    PlateDSPX1.VideoConnect(0); 
 
end; 
 
procedure TForm1.PlateDSPX1Recoged(Sender: TObject; PlateNum: Integer); 
var 
    i, Per : integer; 
    TmpFile : string; 
    PerStr : string; 
begin 
    try 
        { save and display captured bmp } 
        TmpFile := ExtractFilePath(Application.ExeName) + 'CaptureTmp1.bmp'; 
        PlateDSPX1.SaveCapturePicture( TmpFile ); 
        ImageCar.Picture.LoadFromFile( TmpFile ); 
        { check recog result } 
        if( PlateNum > 0 ) then 
        begin 
            { get recognition result } 
            LabelNumber.Caption := PlateDSPX1.GetPlateNumber(0); 
            LabelType.Caption := '种类:' + PlateDSPX1.GetPlateClassName(0); 
            LabelColor.Caption := '颜色:' + IntToStr(PlateDSPX1.GetPlateColor(0)); 
            PerStr := '置信度:' + IntToStr(PlateDSPX1.GetPlateReliability(0,-1)) + ' ('; 
            for i := 0 to 20 do 
            begin 
                Per := PlateDSPX1.GetPlateReliability(0,i); 
                if (Per >= 0) then 
                    PerStr := PerStr + ' ' + IntToStr(Per); 
            end; 
            LabelPercent.Caption := PerStr + ' )'; 
            TmpFile := ExtractFilePath(Application.ExeName) + 'PlateTmp1.bmp'; 
            PlateDSPX1.SavePlatePicture( 0, TmpFile ); 
            ImagePlate.Picture.LoadFromFile( TmpFile ); 
            ImagePlate.Visible := true; 
        end 
        else 
        begin 
            LabelNumber.Caption := ''; 
            LabelType.Caption := ''; 
            LabelColor.Caption := ''; 
            LabelPercent.Caption := ''; 
            ImagePlate.Visible := False; 
        end; 
    except 
        ; 
    end; 
end; 
 
end.