问题已经解决,谢谢各位参与讨论!谢谢俺们的肖老师:欢迎程序爱好者参考。<br>最终正确版:<br>unit test;<br>interface<br>uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs, StdCtrls,mmsystem;<br>type<br> TForm1 = class(TForm)<br> Button1: TButton;<br> Button2: TButton;<br> Edit1: TEdit;<br> procedure Button1Click(Sender: TObject);<br> procedure Button2Click(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br>var<br> Form1: TForm1;<br>implementation<br>{$R *.dfm}<br>procedure TForm1.Button1Click(Sender: TObject);<br>type<br> //图象导入<br> TCISLoadImageFun = function(PImgName: PChar): Boolean; stdcall;<br> TCISGetImageFun = procedure(PImageData: PChar; Pwidth, Pheight, Pdepth, Pchannels: PInteger);stdcall;<br> TCISImageDllReleaseFun = procedure; stdcall;<br>//车牌处理<br>CISDllInitFun = function(): Boolean; stdcall;<br> CISDllReleaseFun = procedure; stdcall;<br>CISProcessFrameFun = function(PimageData: PChar; width, height,<br>depth, channels: Integer; pPlateChars
char ): Boolean;stdcall;<br>var<br>CISImageHandle: THandle;<br> CubicPlateHandle: THandle;<br><br> //图片导入<br> CISGetImage: TCISGetImageFun;<br> CISLoadImage: TCISLoadImageFun;<br> CISImageRelease: TCISImageDllReleaseFun;<br> //车牌识别<br> CISDllInit:CISDllInitFun;<br> CISDllRelease:CISDllReleaseFun;<br> CISProcessFrame:CISProcessFrameFun;<br> loadpic: Boolean;<br> // 图像数据指针 存放车牌识别字符<br> PimageData, pPlateChars : PChar;<br> //,pPlateChars<br> //pPlateChars:array[0..8] of pchar ;<br> //图像宽度 图像高度 图像深度 图像通道数<br> Pwidth, pheight, Pdepth, Pchannels: PInteger;<br> width, height, depth, channels: Integer;<br> //计时<br> //计时频率<br> c1:int64;<br> // 起始时间 结束时间<br> t1,t2:int64;<br> //用去时间<br> r1:double;<br> xxs : Boolean;<br> Tp,Tp2:TFarProc;<br>begin<br> new(PimageData);<br> New(Pwidth);<br> New(pheight);<br> New(Pdepth);<br> New(Pchannels);<br> New(pPlateChars);<br> //申请内存保存车拍<br> getmem(pPlateChars, 8);<br> //计时 开始<br> QueryPerformanceFrequency(c1);//WINDOWS API 返回计数频率(Intel86:1193180)(获得系统的高性能频率计数器在一毫秒内的震动次数)<br> QueryPerformanceCounter(t1);//WINDOWS API 获取开始计数值<br> //图片导入、<br> CISImageHandle := LoadLibrary('CISImage.dll');<br> if CISImageHandle > 0 then<br> try<br> Tp := GetProcAddress(CISImageHandle, PChar('CISLoadImage'));<br> CISLoadImage := TCISLoadImageFun(Tp);<br> @CISGetImage := GetProcAddress(CISImageHandle, PChar('CISGetImage'));<br> @CISImageRelease := GetProcAddress(CISImageHandle,PChar('CISImageDllRelease'));<br> if Tp <> nil then // or (CISLoadImage = nil)<br> begin<br> loadpic := CISLoadImage('1024.jpg');<br> if loadpic then<br> CISGetImage(@PimageData, Pwidth, Pheight,Pdepth, Pchannels);<br> ShowMessage(IntToStr(Pwidth^) + ':' + IntToStr(pheight^) + ':' + IntToStr(Pdepth^) + ':' + IntToStr(Pchannels^));<br> <br> //车牌识别<br> CubicPlateHandle := LoadLibrary('CubicPlate.dll');<br> if CubicPlateHandle <=0 then exit;<br> Tp2 := GetProcAddress(CubicPlateHandle, PChar('CISDllInit'));<br> CISDllInit := CISDllInitFun(Tp2);<br> @CISProcessFrame := GetProcAddress(CubicPlateHandle, PChar('CISProcessFrame'));<br> @CISDllRelease := GetProcAddress(CubicPlateHandle, PChar('CISDllRelease'));<br> if Tp2 <> nil then<br> xxs :=CISDllInit()<br> else exit;<br> xxs :=CISProcessFrame(PimageData,Pwidth^, Pheight^, Pdepth^, Pchannels^,pPlateChars);<br> if xxs then<br> Edit1.Text := pPlateChars<br> else<br> Edit1.Text := '无法识别';<br> // 计时结束<br> QueryPerformanceCounter(t2);//获取结束计数值<br><br>// r1:=(t2-t1)/c1*1000;//取得计时时间,单位毫秒(ms)<br> r1:=(t2-t1)/c1*1000000;//取得计时时间,单位微秒<br> // showmessage(floattostr(r1); IntToStr(width) + ':' + IntToStr(height) + ':' + IntToStr(depth) + ':' + IntToStr(channels)+':'+<br> ShowMessage( pPlateChars +' 共用去时间'+floattostr(r1)+ '微秒');<br> end<br> else<br> ShowMessage( 'CISGetImage函数没有找到');<br><br> finally<br> if CubicPlateHandle >0 then<br> begin<br> CISDllRelease;<br> FreeLibrary(CubicPlateHandle);<br> end;<br> CISImageRelease;<br> FreeLibrary(CISImageHandle);<br> // Dispose(PimageData);<br>// Dispose(Pwidth);<br>// Dispose(pheight);<br>// Dispose(Pdepth);<br>// Dispose(Pchannels);<br> freemem (pPlateChars);<br> end;<br>end;<br>procedure TForm1.Button2Click(Sender: TObject);<br>begin<br>close;<br>end;<br>end.