Qt 车牌识别 (HyperLPR)

8 篇文章 0 订阅
2 篇文章 0 订阅

开发环境:win10 + Qt5.12.1 + vs2015_x64

下载

HyperLPR-Qt 源码:https://github.com/yuace/HyperLPR-QT

直接把源码加到.pri文件中

在这里插入图片描述

在这里插入图片描述

安装/直接解压 opencv-4.2.0-vc14_vc15.exe

下载:https://sourceforge.net/projects/opencvlibrary/files/4.2.0/opencv-4.2.0-vc14_vc15.exe/download
在这里插入图片描述

使用

在这里插入图片描述

void EasyPRThread::run()
{
    setResult(0);
    switch (threadType()) {
    case 0://init
        init();
        break;
    case 1:
    {
        QImage image;
        QString tag;
        extractFacialFeatures(getFilePath(),image,tag);
        setImage(image);
        setTag(tag);
    }
        break;
    case 2:
    {

    }
        break;
    case 3:
    {

    }
        break;
    case 4:
    {
        int sameCount = 0;
        int errorCount = 0;
        for(int i=0; i<_filePaths.size(); ++i){
            QImage image;
            QString tag;
            extractFacialFeatures(_filePaths.at(i),image,tag);
            setImage(image);
            setTag(tag);
            QFileInfo fileInfo(_filePaths.at(i));
            if(fileInfo.completeBaseName() == tag){
                ++sameCount;
            }else{
                ++errorCount;
            }
        }
        QString str = QString("%1:%2  %3:%4   %5:%6  %7:%8")
                .arg(QStringLiteral("共"))
                .arg(_filePaths.size())
                .arg(QStringLiteral("正确"))
                .arg(sameCount)
                .arg(QStringLiteral("错误"))
                .arg(errorCount)
                .arg(QStringLiteral("识别率"))
                .arg(sameCount*1.0/_filePaths.size());
        SCDebug<<str;
        emit sigTextEdit(str);

    }
        break;
    default:
        break;
    }
}
bool EasyPRThread::extractFacialFeatures(const QString &filePath,QImage &image,QString &tag)
{
    cv::Mat frame = cv::imread(filePath.toLocal8Bit().toStdString());
    std::vector<pr::PlateInfo> res = _pipelinePR->RunPiplineAsImage(frame,pr::SEGMENTATION_FREE_METHOD);
    int count = 0;
    for(auto st:res) {
        if(st.confidence > _threshold) {
            ++count;
            cv::Rect region = st.getPlateRect();
            cv::rectangle(frame,cv::Point(region.x,region.y),cv::Point(region.x+region.width,region.y+region.height),cv::Scalar(255,255,0),2);
            tag = QString::fromLocal8Bit(st.getPlateName().data());
            //            int type = st.getPlateType();
            //            SCDebug<<"type:"<<type;
//            QString tempStr = QString("%1:%2").arg(getLicensePlateType(st.getPlateType())).arg(tag);
            emit sigTextEdit(tag);
        }
        SCDebug<<"st.confidence:"<<st.confidence;
    }
    //    SCDebug<<"count:"<<count;
    image = QImage((const unsigned char*)(frame.data), frame.cols, frame.rows, frame.step, QImage::Format_RGB888).rgbSwapped();
    return true;
}

最终效果

测试EasyPR 源码中自带的 general_test 文件夹中的车牌图片识别率有:0.718(71.8%)

在这里插入图片描述

Qt 车牌识别 (EasyPR )

https://blog.csdn.net/u012020854/article/details/111049724

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值