循环读取车牌图片文件并识别显示

// 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;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值