QT使用OCR识别车牌核心算法

百度OCR后返回的数值处理.
返回值的内容如下:
QJsonObject({“log_id”:2.6976919022152786e+18,“words_result”:{“color”:“blue”,“number”:“京PKR676”,“probability”:[0.90123444795608521,0.90137338638305664,0.90100210905075073,0.90103435516357422,0.90110069513320923,0.90008586645126343,0.90102887153625488],“vertexes_location”:[{“x”:224,“y”:126},{“x”:337,“y”:134},{“x”:334,“y”:168},{“x”:221,“y”:161}]}})

根据返回值可以看出来,返回值的类型是QJsonObject,随意定义一个QJsonObject类型的变量接收数据,然后我们发现数据中的number在words_result这个集合中,所以我们还需要将words_result从接收数据中先提取出来,他的返回格式还是QJsonObject.
读取结果如下:
QJsonObject({“color”:“blue”,“number”:“京PKR676”,“probability”:[0.90123444795608521,0.90137338638305664,0.90100210905075073,0.90103435516357422,0.90110069513320923,0.90008586645126343,0.90102887153625488],“vertexes_location”:[{“x”:224,“y”:126},{“x”:337,“y”:134},{“x”:334,“y”:168},{“x”:221,“y”:161}]})
然后我们发现现在这个数据就是一个可以正常读取的集合了,我们使用value方法读取
结果如下:“京PKR676” 直接显示即可
具体程序代码如下:

QJsonObject obj = parse_doucment.object(); qDebug()<<"QJsonObject              "<<obj;
QString res;
QJsonObject jsonArr = obj.value("words_result").toObject();
qDebug()<<"QJsonArray                          "<<jsonArr;
res = jsonArr.value("number").toString();
qDebug()<<"QJsonArray                          "<<res;
ui->textEdit_2->setText(res);

如有疑问,可以留言讨论.

你可能感兴趣的:(QT编程总结)