
不需要头文件或者静态连接库。
如果没有加密狗,程序在运行时不会报告。但是会随机修改内存,修改量取决于使用的加密狗和正版加密狗的差距。所以强烈建议使用正版加密狗。
调用Windows API LoadLibrary来加载动态链接库 ggilpr.dll。参考代码如下:
lpr_library=::LoadLibrary(_T("gilpr.dll"));
如果gilpr.dll和可执行文件在同一个目录下,而且这个目录还有FT_ET99_API.dll的话,LoadLibrary一般会成功返回。
接下来需要得到gilpr.dll唯一的入口,也是整个车牌识别模块唯一的接口。参考代码如下:
typedef int (*FVehicleLicencePlateRecognize)(char * result/*10*/,int * color,int
width,int height,unsigned char * image,int paint_to_desktop/* 0: do not paint, 1
paint */);
VehicleLicencePlateRecognize=(FVehicleLicencePlateRecognize)::GetProcAddress(lpr_library,"VehicleLicencePlateRecognize");
一般说来只要是能够成功加载动态库,接口函数也可以成功找到。
函数VehicleLicencePlateRecognize需要一个数组存放位图数据,它的数据结构用c语言描述如下:
unsigned char image[height][width][3/* red green blue*/]
因为宽度和长度是可变的,所以在声明的时候,他的形式是unsigned char * image。
其他参数比较简单。请看下面的内容。
调用VehicleLicencePlateRecognize识别车牌。
VehicleLicencePlateRecognize一共有六个参数:
返回值:如果成功定位车牌,函数返回1;车牌定位失败返回0。
参考代码如下:
if(VehicleLicencePlateRecognize(result,&color,bitmap_reader.GetWidth(),bitmap_reader.GetHeight(),image,1))
{
if(color==0)
m_result=_T("蓝色");
else
m_result=_T("黄色");
m_result+=_T(" ");
m_result+=result;
}
else
{
m_result=_T("没有定位");
}
如果需要识别多个车牌可以重复调用 VehicleLicencePlateRecognize,而不必重新加载动态库。
调用FreeLibrary清楚垃圾,参考代码如下:
::FreeLibrary(lpr_library);
注意调用完FreeLibrary之后VehicleLicencePlateRecognize将失效。最好将VehicleLicencePlateRecognize置空。
(完)