毕业设计 python opencv实现车牌识别 颜色判断
主要代码参考https://blog.csdn.net/wzh191920/article/details/79589506
GitHub:https://github.com/yinghualuowu
答辩通过了,补完~
该部分代码还包括缩小边界
def img_color(card_imgs):
colors = []
for card_index, card_img in enumerate(card_imgs): green = yello = blue = black = white = 0
card_img_hsv = cv2.cvtColor(card_img, cv2.COLOR_BGR2HSV)
# 有转换失败的可能,原因来自于上面矫正矩形出错
if card_img_hsv is None:
continue
row_num, col_num = card_img_hsv.shape[:2]
card_img_count = row_num * col_num for i in range(row_num):
for j in range(col_num):
H = card_img_hsv.item(i, j, 0)
S = card_img_hsv.item(i, j, 1)
V = card_img_hsv.item(i, j, 2)
if 11 < H <= 34 and S > 34:
yello += 1
elif 35 < H <= 99 and S > 34:
green += 1
elif 99 < H <= 124 and S > 34:
blue += 1 if 0 < H < 180 and 0 < S < 255 and 0 < V < 46:
black += 1
elif 0 < H < 180 and 0 < S < 43 and 221 < V < 225:
white += 1
color = "no" limit1 = limit2 = 0
if yello * 2 >= card_img_count:
color = "yello"
limit1 = 11
limit2 = 34 # 有的图片有色偏偏绿
elif green * 2 >= card_img_count:
color = "green"
limit1 = 35
limit2 = 99
elif blue * 2 >= card_img_count:
color = "blue"
limit1 = 100
limit2 = 124 # 有的图片有色偏偏紫
elif black + white >= card_img_count * 0.7:
color = "bw"
colors.append(color)
card_imgs[card_index] = card_img if limit1 == 0:
continue
xl, xr, yh, yl = accurate_place(card_img_hsv, limit1, limit2, color)
if yl == yh and xl == xr:
continue
need_accurate = False
if yl >= yh:
yl = 0
yh = row_num
need_accurate = True
if xl >= xr:
xl = 0
xr = col_num
need_accurate = True if color =="green":
card_imgs[card_index] = card_img
else:
card_imgs[card_index] = card_img[yl:yh, xl:xr] if color != "green" or yl < (yh - yl) // 4 else card_img[
yl - (
yh - yl) // 4:yh,
xl:xr] if need_accurate:
card_img = card_imgs[card_index]
card_img_hsv = cv2.cvtColor(card_img, cv2.COLOR_BGR2HSV)
xl, xr, yh, yl = accurate_place(card_img_hsv, limit1, limit2, color)
if yl == yh and xl == xr:
continue
if yl >= yh:
yl = 0
yh = row_num
if xl >= xr:
xl = 0
xr = col_num
if color =="green":
card_imgs[card_index] = card_img
else:
card_imgs[card_index] = card_img[yl:yh, xl:xr] if color != "green" or yl < (yh - yl) // 4 else card_img[
yl - (
yh - yl) // 4:yh,
xl:xr] return colors,card_imgs
accrate_place部分
def accurate_place(card_img_hsv, limit1, limit2, color):
row_num, col_num = card_img_hsv.shape[:2]
xl = col_num
xr = 0
yh = 0
yl = row_num
row_num_limit = 21
col_num_limit = col_num * 0.8 if color != "green" else col_num * 0.5 # 绿色有渐变
for i in range(row_num):
count = 0
for j in range(col_num):
H = card_img_hsv.item(i, j, 0)
S = card_img_hsv.item(i, j, 1)
V = card_img_hsv.item(i, j, 2)
if limit1 < H <= limit2 and 34 < S and 46 < V:
count += 1
if count > col_num_limit:
if yl > i:
yl = i
if yh < i:
yh = i
for j in range(col_num):
count = 0
for i in range(row_num):
H = card_img_hsv.item(i, j, 0)
S = card_img_hsv.item(i, j, 1)
V = card_img_hsv.item(i, j, 2)
if limit1 < H <= limit2 and 34 < S and 46 < V:
count += 1
if count > row_num - row_num_limit:
if xl > j:
xl = j
if xr < j:
xr = j
return xl, xr, yh, yl
毕业设计 python opencv实现车牌识别 颜色判断的更多相关文章
- 毕业设计 python opencv实现车牌识别 颜色定位
主要代码参考https://blog.csdn.net/wzh191920/article/details/79589506 GitHub:https://github.com/yinghualuow ...
- 毕业设计 python opencv实现车牌识别 界面
主要代码参考https://blog.csdn.net/wzh191920/article/details/79589506 GitHub:https://github.com/yinghualuow ...
- 毕业设计 python opencv实现车牌识别 形状定位
主要代码参考https://blog.csdn.net/wzh191920/article/details/79589506 GitHub:https://github.com/yinghualuow ...
- 毕业设计 python opencv实现车牌识别 预处理
主要代码参考https://blog.csdn.net/wzh191920/article/details/79589506 GitHub:https://github.com/yinghualuow ...
- 毕业设计 python opencv实现车牌识别 码云地址
码云地址:https://gitee.com/yinghualuowu/Python_VLPR 删除了冗余代码,可以更加便于运行.其实是为了那些进不去github准备的~
- 毕业设计 python opencv实现车牌识别 矩形矫正
主要代码参考https://blog.csdn.net/wzh191920/article/details/79589506 GitHub:https://github.com/yinghualuow ...
- 探索 Python + HyperLPR 进行车牌识别
概要 HyperLRP是一个开源的.基于深度学习高性能中文车牌识别库,由北京智云视图科技有限公司开发,支持PHP.C/C++.Python语言,Windows/Mac/Linux/Android/IO ...
- 基于opencv的车牌识别系统
前言 学习了很长一段时间了,需要沉淀下,而最好的办法就是做一个东西来应用学习的东西,同时也是一个学习的过程. 概述 OpenCV的全称是:Open Source Computer Vision ...
- python+opencv实现车牌定位
写在前面 HIT大三上学期视听觉信号处理课程中视觉部分的实验三,经过和学长们实验的对比发现每一级实验要求都不一样,因此这里标明了是2019年秋季学期的视觉实验三. 由于时间紧张,代码没有进行任何优化, ...
随机推荐
- 运行程序显示:Could not find version 8.3 of the MCR.
- 每天一道算法题(24)——自定义幂函数pow
double myPower(double base, int exponent){ if(exponent==0) return 1; if(exponent==1) return base; if ...
- 在PHP中PDO解决中文乱码问题的一些补充
我的环境是appsver包, 在网上最常出现的解决中文乱码显示的代码是: 第一种:PDO::__construct($dsn, $user, $pass, array (PDO::MYSQL_ATTR ...
- maven安装第三方jar包到本地仓库
添加项目依赖的时候,有些jar下载不下来,只有手动下载或安装到本地仓库了 首先下载所需要的jar,放到指定的文件夹 然后执行如下命令: mvn install:install-file -Dfile= ...
- [转]AJAX工作原理及其优缺点
1.什么是AJAX?AJAX全称为“Asynchronous JavaScript and XML”(异步JavaScript和XML),是一种创建交互式网页应用的网页开发技术.它使用:使用XHTML ...
- php学习笔记-include
这个和C语言中的include是同样的用法,如果一个php文件中有一句include a.php,那么执行的时候就会把a.php的内容插入到这个php文件中. 举个例子,我现在有一个名为hellowo ...
- jquery ajax 分页2
/* * 分页 $("#divPager").flexipager * 2015.03.17 */ //初始化列表默认属性 (function($) { $.addFlex = f ...
- javax.servlet.ServletConfig接口(五)
主要作用是保存web.xml文件里面的配置信息 一个servlet对应一个ServletConfig,100个servlet对应100个ServletConfig. 代码如下(单个获取和获取所有) ...
- iOS symbolicatecrash工具crash日志分析
若一个App没有加入Crashlytics或者Buggly这些崩溃日志监控,那么我们在App崩溃的时候如何获取崩溃信息呢? 此时我们可以通过symbolicatecrash工具对手机日志来进行分析定位 ...
- 动态绑数据(GridView控件Header和ItemTemplate)
想了解此篇文章,建议先预习一下<动态变更GridView控件列名>http://www.cnblogs.com/insus/p/3232057.html,因为多少有些关联.不管怎样,它能够 ...