#include
#include
#include
#include
using
namespace
std;
using
namespace cv;
void getbluemask(iplimage*src, iplimage*dst);
int main()
}}//若每一行的畫素累加和除以上一行的畫素累加和小於乙個閾值,則將其畫素累加和置0
for (int j = height - 1; j >= 1; j--)
}for (int j = height - 1; j >= 0; j--)
int y_min = 0;
int y_max = 0;
int m_max_value = 0;
m_max_value = level_shadow[0];
for (int j = 0; j < height; j++)
}if (m_max_value < 10)
cout
<< "提取車牌高度失敗!"
<< endl;
cvrect roi_plate_height;
roi_plate_height.x = 0;
roi_plate_height.y = y_min;
roi_plate_height.width = psrc_image->width;
roi_plate_height.height = m_max_value;
cvsetimageroi(image, roi_plate_height);
//裁剪車牌區域
iplimage*proi_height_image = cvcreateimage(cvsize(roi_plate_height.width, roi_plate_height.height),8, 1);
cvcopy(image, proi_height_image);
int copy_m_max_value = m_max_value;
while ((copy_m_max_value % 3) != 0)
int close_width = int(copy_m_max_value*0.6);
int close_height = copy_m_max_value;
//閉運算
iplconvkernel*pkernel_close = cvcreatestructuringelementex(close_width, close_height, close_width / 2, close_width / 2, cv_shape_rect, null);
cvmorphologyex(proi_height_image, proi_height_image, null, pkernel_close, cv_mop_close, 1);
cvnamedwindow("proi_height_image");
cvshowimage("proi_height_image", proi_height_image);
int x_min = 0;
int x_max = 0;
int m_row_max_value = 0;
int count_row[2048];
memset(count_row, 0, sizeof(count_row));
//統計車牌的寬度
int mid_height = m_max_value / 2;
uchar*ptr_mid = (uchar*)(proi_height_image->imagedata + mid_height*proi_height_image->widthstep);
for (int i = width - 1; i >= 0; i--)
int max_value_count_row = count_row[0];
for (int i = 0; i < width; i++)
}if (float(max_value_count_row) / float(m_max_value)<3 || float(max_value_count_row) / float(m_max_value)>6)
cout
<< "提取車牌高度失敗!"
<< endl;
cvrect roi_plate;
roi_plate.x = x_min;
roi_plate.y = y_min;
roi_plate.width = max_value_count_row;
roi_plate.height = m_max_value;
if (roi_plate.x<0 || roi_plate.x>width)
cout
<< "提取車牌高度失敗!"
<< endl;
if (roi_plate.y<0 || roi_plate.y>height)
cout
<< "提取車牌高度失敗!"
<< endl;
if ((roi_plate.x + roi_plate.width)>width)
cout
<< "提取車牌高度失敗!"
<< endl;
if ((roi_plate.y + roi_plate.height)>height)
cout
<< "提取車牌高度失敗!"
<< endl;
cvsetimageroi(bin, roi_plate);
iplimage*plate_image = cvcreateimage(cvsize(roi_plate.width, roi_plate.height), 8, 1);
cvcopy(bin, plate_image);
cvnot(plate_image, plate_image);
cvnamedwindow("plate_image");
cvshowimage("plate_image", plate_image);
cvwaitkey();
}void getbluemask(iplimage*src, iplimage*dst)}}
}
OpenCV實現車牌定位 C
最近開始接觸 c 了,就拿乙個 opencv 小專案來練練手。在車牌自動識別系統中,從汽車影象的獲取到車牌字元處理是乙個複雜的過程,本文就以乙個簡單的方法來處理車牌定位。我國的汽車牌照一般由七個字元和乙個點組成,車牌字元的高度和寬度是固定的,分別為90mm和45mm,七個字元之間的距離也是固定的12...
opencv實現車牌識別之車牌號定位 1
按照在 跌倒就在 爬起來的精神,本章繼續做車牌號的檢測識別。所有步驟分為3步完成 車牌號定位,車牌號字元分割 字元識別。本章為第一部分 車牌號定位。正式開始講解之前,先看下車牌號定位出來的效果演示。注 本文所有均 於網路。如圖所示,定位到車牌號之後,將車牌號用黃色框選起來,同時將該車牌複製為新顯示出...
opencv 車牌切割
usr bin env python3 coding utf 8 created on thu mar 21 12 42 15 2019 author lg import cv2 import numpy as np 形態學處理 def process img 高斯平滑 gaussian cv2.g...