车牌识别opencv+tesseract-ocr


车牌识别代码,利用opencv实现对车牌的定位,tesseract-ocr进行车牌的识别。
资源截图
代码片段和文件信息
#include 
#include 
#include “tesseractaseapi.h“
#include “tesseractstrngs.h“
//#include
#pragma  comment(lib“libtesseract302.lib“)
#pragma  comment(lib “liblept168.lib“) 
#include 

#include
#include
#include“qmessagebox.h“
#include  
//
using namespace cv;
using namespace std;
#include “chepaishibie.h“
#include “cv.h“
#include “highgui.h“
#include “cxcore.h“
#include
#include
#include
#include 
#include“qlineedit.h“
void swap1(float *a float *b);

void swap2(int *a int *b);
bool isEligible(const RotatedRect &candidate);
void OstuBeresenThreshold(const Mat &in Mat &out); 
Mat getRplane(const Mat &in);
chepaishibie::chepaishibie(QWidget *parent)
: QMainWindow(parent)
{
ui.setupUi(this);
}

chepaishibie::~chepaishibie()
{

}
Mat image;//定义读入图像
QImage img;//
string name;//定义图片地址字符串
void chepaishibie::on_pushButton_clicked()//打开图片
{
QString filename = QFileDialog::getOpenFileName(this tr(“Open Image“) ““ tr(“Image File(*.bmp *.jpg *.jpeg *.png)“));
QTextCodec *code = QTextCodec::codecForName(“gb18030“);//转码
name = code->fromUnicode(filename).data();//获取图片地址
image = imread(name);//读取图片
//将图片长缩放为480
if (image.cols < 480)
{
float n = (float)480 / image.cols;
cv::resize(image image Size((float)image.cols*n (float)image.rows*n) 0 0 CV_INTER_LINEAR);
}
else
{
float n = (float)image.cols / 480;
cv::resize(image image Size((float)image.cols / n (float)image.rows / n) 0 0 CV_INTER_LINEAR);
}
//提示是否找到图片
if (!image.data)
{
QMessageBox msgBox;
msgBox.setText(tr(“image data is null“));
msgBox.exec();
return;
}
else
{
cv::cvtColor(image image CV_BGR2RGB);
img = QImage((const unsigned char*)(image.data) image.cols image.rows image.cols*image.channels() QImage::Format_RGB888);
ui.label->clear();

ui.label->setPixmap(QPixmap::fromImage(img));

ui.label->resize(ui.label->pixmap()->size());

}
}
int myOtsu(const IplImage *frame) //大津法求阈值   
{
#define GrayScale 256   //frame灰度级   
int width = frame->width;
int height = frame->height;
int pixelCount[GrayScale] = { 0 };
float pixelPro[GrayScale] = { 0 };
int i j pixelSum = width * height threshold = 0;
uchar* data = (uchar*)frame->imageData;

//统计每个灰度级中像素的个数   
for (i = 0; i < height; i++)
{
for (j = 0; j < width; j++)
{
pixelCount[(int)data[i * width + j]]++;
}
}

//计算每个灰度级的像素数目占整幅图像的比例   
for (i = 0; i < GrayScale; i++)
{
pixelPro[i] = (float)pixelCount[i] / pixelSum;
}

//遍历灰度级[0255]寻找合适的threshold   
float w0 w1 u0tmp u1tmp u0 u1 deltaTmp deltaMax = 0;
for (i = 0; i < GrayScale; i++)
{
w0 = w1 = u0tmp = u1tmp = u0 = u1 = deltaTmp = 0;
for (j = 0; j < GrayScale; j++)
{
if (j <= i)   //背景部分   
{

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2017-11-09 00:15  chepaishibie
     目录           0  2017-06-09 11:42  chepaishibie.vs
     目录           0  2017-06-09 11:42  chepaishibie.vschepaishibie
     目录           0  2017-06-09 11:42  chepaishibie.vschepaishibiev14
     文件       30208  2017-06-09 11:43  chepaishibie.vschepaishibiev14.suo
     目录           0  2017-06-09 11:44  chepaishibiechepaishibie
     文件    69271552  2017-11-09 00:15  chepaishibiechepaishibie.sdf
     文件         982  2017-04-20 12:35  chepaishibiechepaishibie.sln
     文件       32768  2017-11-09 00:15  chepaishibiechepaishibie.v12.suo
     文件     1601536  2017-06-09 11:43  chepaishibiechepaishibie.VC.db
     文件       25234  2017-05-04 18:04  chepaishibiechepaishibie1221.jpg
     文件       17994  2017-05-04 18:03  chepaishibiechepaishibiechepaishibie.cpp
     文件         584  2017-05-02 15:49  chepaishibiechepaishibiechepaishibie.h
     文件          72  2017-04-20 12:35  chepaishibiechepaishibiechepaishibie.qrc
     文件        3762  2017-05-02 20:41  chepaishibiechepaishibiechepaishibie.ui
     文件       16079  2017-11-08 21:37  chepaishibiechepaishibiechepaishibie.vcxproj
     文件        2715  2017-04-20 12:35  chepaishibiechepaishibiechepaishibie.vcxproj.filters
     文件         663  2017-06-09 11:44  chepaishibiechepaishibiechepaishibie.vcxproj.user
     文件       24801  2017-05-04 18:04  chepaishibiechepaishibiecpy.jpg
     文件        7372  2017-05-04 18:04  chepaishibiechepaishibiecpz.jpg
     文件        3607  2017-05-04 18:04  chepaishibiechepaishibiecpzj.jpg
     目录           0  2017-05-02 18:55  chepaishibiechepaishibieDebug
     文件        2203  2017-05-02 16:09  chepaishibiechepaishibieDebugchepaishibie.Build.CppClean.log
     文件        4413  2017-05-02 18:55  chepaishibiechepaishibieDebugchepaishibie.log
     文件     1043373  2017-05-02 18:55  chepaishibiechepaishibieDebugchepaishibie.obj
     目录           0  2017-05-02 18:55  chepaishibiechepaishibieDebugchepaishibie.tlog
     文件         196  2017-05-02 18:55  chepaishibiechepaishibieDebugchepaishibie.tlogchepaishibie.lastbuildstate
     文件        6802  2017-05-02 18:55  chepaishibiechepaishibieDebugchepaishibie.tlogcl.command.1.tlog
     文件       97772  2017-05-02 18:55  chepaishibiechepaishibieDebugchepaishibie.tlogCL.read.1.tlog
     文件        3360  2017-05-02 18:55  chepaishibiechepaishibieDebugchepaishibie.tlogCL.write.1.tlog
     文件        2764  2017-05-02 16:44  chepaishibiechepaishibieDebugchepaishibie.tlogcustombuild.command.1.tlog
............此处省略110个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)