資源簡介
本項(xiàng)目是我用基于Opencv和C++實(shí)現(xiàn)的一整套車牌識別系統(tǒng)從定位、分割到字符識別的源代碼,可直接運(yùn)行使用,效果還不錯。

代碼片段和文件信息
#include?“StdAfx.h“
#include?“charseg_preprocess.h“
#include?
extern?bool?Plate_flag;
namespace?plate
{
/**
?*??make_border_zeros?------?mask?the?top?two?rows?bottom?two?rows?left?two?columns
?*???????????????????????????right?two?columns?with?zeros
?*
?*??Parameters:
?*??@img?-------------------?the?input?image?which?will?be?modified
?*/
static?void?make_border_zeros(cv::Mat&?img)
{
????????CV_Assert(?img.depth()?==?CV_8UC1?);
????????CV_Assert(?img.rows?>=?2?);
????????CV_Assert(?img.cols?>=?2?);
????????img.rowRange(?0?2?)?=?cv::Mat::zeros(2?img.cols?CV_8UC1);
????????img.rowRange(?img.rows?-?2?img.rows?)?=?
????????????????cv::Mat::zeros(2?img.cols?CV_8UC1);
????????img.colRange(?0?2?)?=?cv::Mat::zeros(img.rows?2?CV_8UC1);
????????img.colRange(?img.cols?-?2?img.cols?)?=?
????????????????cv::Mat::zeros(img.rows?2?CV_8UC1);
????????return;
}
/**
?*??object_enhancement?--------?enhance?the?seven?characters?in?the?plate
?*
?*??Parameters:
?*??@img?----------------------?the?input?gray?image?characters?in?which?will?be?enhanced
?*/
static?void?object_enhancement(cv::Mat&?img)
{
????????CV_Assert(?img.channels()?==?1?);
????????//?transfer?pixel?value?range?from?[0?255]?to?[0?100]
????????cv::Mat?weaken_img;
????????img.convertTo(?weaken_img?CV_8UC1?0.40?0.0?);
????????//?find?the?first?top?40%?pixel?values
????????std::vector?pixel_values;
????????for?(?int?r?=?0;?r?????????????????const?unsigned?char*?prow?=?weaken_img.ptr(r);
????????????????for?(?int?c?=?0;?c?????????????????????????pixel_values.push_back(?prow[c]?);
????????????????}
????????}
????????std::sort(?pixel_values.begin()?pixel_values.end()?);
????????std::size_t?sentinel_index?=?cvRound(?pixel_values.size()?*?0.60?);
????????unsigned?char?sentinel_value?=?pixel_values[sentinel_index];
????????//?only?the?pixels?whose?value?are?in?the?top?40%?are?enhanced
????????for?(?int?r?=?0;?r?????????????????const?unsigned?char*?pweaken_img_row?=?
????????????????????????weaken_img.ptr(r);
????????????????unsigned?char*?pimg_row?=?img.ptr(r);
????????????????for?(?int?c?=?0;?c?????????????????????????if?(?pweaken_img_row[c]?>=?sentinel_value?)?{
????????????????????????????????pimg_row[c]?=?cv::saturate_cast(
????????????????????????????????????????pweaken_img_row[c]?*?2.55?);
????????????????????????}
????????????????????????else?{
????????????????????????????????pimg_row[c]?=?pweaken_img_row[c];
????????????????????????}
????????????????}
????????}
????????return;
}
/**
?*??img_threshold?----------?Apply?a?fixed-level?threshold?to?each?pixel?of?the?image
?*
?*??Parameters:
?*??@img?-------------------?the?input?gray?image
?*/
static?void?img_threshold(cv::Mat&?img)
{
????????CV_Assert(?img
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????10625??2013-04-10?13:55??plate_recognition_20130410_beifen\charseg_preprocess.cpp
?????文件?????????645??2013-04-01?10:35??plate_recognition_20130410_beifen\charseg_preprocess.h
?????文件???????24169??2013-04-10?13:42??plate_recognition_20130410_beifen\charseg_segment.cpp
?????文件?????????892??2013-04-01?10:33??plate_recognition_20130410_beifen\charseg_segment.h
?????文件?????????752??2013-04-10?11:38??plate_recognition_20130410_beifen\main.cpp
?????文件???????36339??2013-07-05?12:01??plate_recognition_20130410_beifen\plate_recognition_20130410.cpp
?????目錄???????????0??2013-09-01?09:37??plate_recognition_20130410_beifen\
- 上一篇:哈夫曼壓縮解壓算法-C語言
- 下一篇:C語言控制臺窗口界面編程(修正版)
評論
共有 條評論