// TestLPR.cpp : Defines the entry point for the console application.
//
#include "StdAfx.h"
#include <stdlib.h>
#include "THPlateID.h"
#include <linux/stat.h>
#include <dirent.h>
#include <string.h>
#include <fcntl.h>
int nWidth=720;
int nHeight=288;
/* test YUV
HS_PlateIDConfig idConfig =
{80, 400, false, true, true, false, 25, 30, -1, 30, true, 1};
unsigned char YUVBuffer[1024*1024];
int main(int argc, char* argv[])
{
int nRet;
bool bHavePlate;
HS_PlateIDResult result;
printf("Hello World!/n");
// Read YUV Image
FILE *fp=fopen("dead2.yuv","rb");
if (!fp) {
printf("can't open file dead2.yuv!/n");
exit(0);
}
fread(YUVBuffer,nWidth*nHeight*2,1,fp);
fclose(fp);
nRet = HS_InitPlateIDSDK(&idConfig);
nRet =HS_RecogYUV422LPImage(YUVBuffer, nWidth, nHeight, &result,
&bHavePlate, NULL, 0);
if (bHavePlate)
{
printf("plate: %s, color: %s/nleft: %d, top: %d, right: %d, bottom: %d/n",
result.license, result.color, result.rcLocation.left, result.rcLocation.top,
result.rcLocation.right, result.rcLocation.bottom);
}
else
printf("no plate detected!/n");
HS_UninitPlateIDSDK();
return 0;
}
*/
HS_PlateIDConfig idConfig =
{80, 400, false, false, true, false, 25, 30, -1, 30, true, 1};
int ReadBmp(char * FileName, unsigned char * &pImg, int &width, int &height);
int main(int argc, char* argv[])
{
int nRet;
DIR *dirp ;
struct dirent *direntp;
bool bHavePlate;
HS_PlateIDResult result;
unsigned char *pImg;
char filename[100];
char *strDirPath = argv[1];
// printf("%s", strDirPath);
//printf("Hello World!/n");
if((dirp = opendir(strDirPath)) == NULL)
{
printf("open dir failed /n");
return 0;
}
while((direntp = readdir(dirp)) != NULL)
{
if( !strcmp(direntp->d_name, ".") || !strcmp(direntp->d_name, "..") )
continue;
memset(filename, '/0', 100);
strcpy(filename, strDirPath);
// strcat(filename, "/");
strcat(filename, direntp->d_name);
//printf("%s", filename);
nRet=ReadBmp("/home/wintone/LinuxTest/Rockey2/test/TestLPR/testBmp/0.bmp",pImg,nWidth,nHeight);
if (nRet == false) {
printf("can't read image %s!/n",filename);
exit(0);
}
nRet = HS_InitPlateIDSDK(&idConfig);
nRet =HS_RecogStillLPImage(pImg, nWidth, nHeight, &result, &bHavePlate,false,0,0);
if (bHavePlate)
{
printf("FileName: %s/n,plate: %s, color: %s/nleft: %d, top: %d, right: %d, bottom: %d/n",filename,
result.license, result.color, result.rcLocation.left, result.rcLocation.top,
result.rcLocation.right, result.rcLocation.bottom);
}
else
printf("no plate detected!/n");
}
HS_UninitPlateIDSDK();
return 0;
}
循环读取车牌图片文件并识别显示
最新推荐文章于 2021-04-01 11:28:53 发布