当前位置: 首页 > news >正文

简述电子商务网站开发的基本流程宁德市人力资源和社会保障局

简述电子商务网站开发的基本流程,宁德市人力资源和社会保障局,网站建设方案可以乱写吗,wordpress如何使用一个的模板目录 一、项目实施 1、自定义函数 2、定位模版图像中的数字 1)模版图二值化处理 运行结果: 2)展示所有数字 运行结果: 3、识别身份证号 1)灰度图、二值化图展示 运行结果 2)定位身份证号每一个数…

目录

一、项目实施

1、自定义函数

2、定位模版图像中的数字

1)模版图二值化处理

运行结果:

2)展示所有数字

 运行结果:

3、识别身份证号

1)灰度图、二值化图展示

运行结果

2)定位身份证号每一个数字

运行结果:

3)取出身份证号每一个数字

运行结果:

4)使用模板匹配计算匹配得分

运行结果:

二、总结

1、关于图像识别

2、在图像识别任务中,通常包括以下几个步骤:

3、应用领域


一、项目实施

1、自定义函数

        用于展示图像以及获取输入的轮廓图像的排序结果和边界信息

def cv_show(name, image):   # 输入两个参数,图像名和图像地址即可展示图像cv2.imshow(name, image)cv2.waitKey(0)import cv2
def sort_contours(cnts ,method='left-to-right'):   # 输入参数轮廓列表,以及method,默认排序方式为由左到右reverse = False  # 布尔值,用于控制排序的方向i = 0if method == 'right-to-left' or method == 'bottom-to-top':  # 判断排序方式,以此来更改reversereverse=Trueif method == 'top-to-bottom' or method == 'bottom-to-top':i = 1boundingBoxes = [cv2.boundingRect(c) for c in cnts]  # 遍历每一个轮廓图,取出轮廓图的x、y、w、h,将这些信息存放到空列表中# 将列表轮廓和轮廓信息组合成一个元组的列表,再通过匿名函数排序这个元组列表,排序依据为轮廓数据的第一位x大小,降序方式,返回两个元素,一个是排序后的轮廓列表,一个是轮廓的边界框(cnts,boundingBoxes) = zip(*sorted(zip(cnts,boundingBoxes),key=lambda b:b[1][i],reverse=reverse))return cnts,boundingBoxes

2、定位模版图像中的数字

        1)模版图二值化处理
img = cv2.imread("shuzi.png")   # 导入模版图像
cv_show('img', img)   # 展示原图
gray = cv2.imread("shuzi.png", 0)   # 读取模版图的灰度图
ref = cv2.threshold(gray, 150, 255, cv2.THRESH_BINARY_INV)[1]  # 对灰度图进行二值化处理,灰度值大于150的将其改变为255,小于150的改变为0
cv_show('ref', ref)   # 展示二值化图像
            运行结果:

        2)展示所有数字
# 计算轮廓: cv2.findContours()数接受的参数为二值图,即黑白的(不是灰度图)
# cv2.RETR_EXTERNAL 只检测外轮廓,cv2.CHAIN_APPRO_SIMPLE只保留端点坐标
_,refCnts, hierarchy = cv2.findContours(ref.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
cv2.drawContours(img, refCnts, -1, (0, 255, 0), 2)  # 绘制轮廓
cv_show('img', img)
#
refCnts = sort_contours(refCnts, method='left-to-right')[0]   # 调用自定义函数,对轮廓图像进行排序,返回排序后图片以及轮廓的边界信息(x,y,w,h)
# 保在模板中每个数字对应的像素值
digits = {}
for (i, c) in enumerate(refCnts):   # 使用函数enumerate返回可迭代器的索引和其对应的值(x, y, w, h) = cv2.boundingRect(c)   # 计算轮廓的外接矩形,返回矩形的边界信息roi = ref[y - 2 : y + h + 2, x - 2 : x + w + 2]  # 裁剪出每个数字对应的图像roi = cv2.resize(roi, (57, 88))   # 将裁剪出来的图像进行缩放,尺寸变成(57,88)roi = cv2.bitwise_not(roi)  # 对每个数字进行按位取反运算,即灰度值255变成0,0变成255cv_show('roi',roi)   # 展示取反后的图像digits[i] = roi   # 将每个轮廓存入字典
cv2.destroyAllWindows()   # 关闭所有图像
            运行结果:

3、识别身份证号

        1)灰度图、二值化图展示
img = cv2.imread('./shenfen.jpg')
imgg=img.copy()
cv_show('img', img)gray = cv2.imread('./shenfen.jpg', 0)  # 灰度图
cv_show('gray', gray)ref = cv2.threshold(gray, 120, 255, cv2.THRESH_BINARY_INV)[1]   # 二值化
cv_show('ref', ref)

            运行结果

        2)定位身份证号每一个数字
# # 计算轮廓: cv2.findContours()数接受的参数为二值图,即黑白的(不是灰度图)
# # CV2.RETR_EXTERNAL 只检测外轮廓,CV2.CHAIN_APPROX_SIMPLE只保留端点坐标
_,refCnts, hierarchy = cv2.findContours(ref.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)  # 识别身份证图片所有轮廓
a = cv2.drawContours(img.copy(), refCnts, -1, (0, 255, 0), 2)   # 绘制轮廓
cv_show('img', a)
#
# cv2.destroyAllWindows()
#
# # 遍历轮廓,找到数字部分像素区城
locs = []
for (i, c) in enumerate(refCnts):   # 遍历每一个轮廓及其对应索引(x, y, w, h) = cv2.boundingRect(c)  # 计算外接矩形边界信息# 选择合适的区域,根据实际任务来if (y > 330 and y < 360) and x > 220:  # 判断轮廓的坐标位置,留下身份证号位置的信息,此处位置信息需要自己结合原图像素值进行判断locs.append((x, y, w, h))   # 满足上述条件的为身份证号每一个数字的轮廓locs = sorted(locs, key=lambda x: x[0])   # 对身份证号按照x的值进行进行排序

            运行结果:

        3)取出身份证号每一个数字
import numpy as npoutput = []
for (i, (gX, gY, gW, gH)) in enumerate(locs):  # 遍历每一个数字的边界信息及其对应的索引groupOutput = []group = gray[gY - 2 : gY + gH + 2, gX - 2 : gX + gW + 2]  # 对每个数字的轮廓适当加一点边界,gray为上述的身份证灰度图cv_show('group',group)   # 绘制边界# 预处理group = cv2.threshold(group, 0, 255, cv2.THRESH_BINARY | cv2.THRESH_OTSU)[1]  # 二值化每个数字的轮廓图cv_show('group',group)roi = cv2.resize(group, (57, 88))   # 对每个数字做缩放处理cv_show('roi',roi)
        运行结果:

        4)使用模板匹配计算匹配得分
    scores = []# 在模板中计算每一个得分for (digit, digitROI) in digits.items():  # 遍历每一个数字模版及其对应的数值# 模板匹配result = cv2.matchTemplate(roi, digitROI, cv2.TM_CCOEFF)  # 对上述识别出来的身份证号图与数字模版进行匹配(_, score, _, _) = cv2.minMaxLoc(result)    # # 找到上述模板匹配相关系数最大值,只要score,其他返回值忽略scores.append(score)   # 将最大值增加到列表# 得到最合适的数字groupOutput.append(str(np.argmax(scores)))   # 取出最大值对应的数字存入列表# 绘制每个数字的矩形边框cv2.rectangle(imgg, (gX - 5, gY - 5), (gX + gW + 5, gY + gH + 5), (0, 0, 255), 1)# cv2.putText()是OpenCV库中的一个函数,用于在图像上添加文本。cv2.putText(imgg, "".join(groupOutput), (gX, gY - 15), cv2.FONT_HERSHEY_SIMPLEX, 0.65, (0, 0, 255), 2)output.extend(groupOutput)  # 得到结果
#
# 打印结果
print("Card ID #: {}".format("".join(output)))
cv2.imshow("Image", imgg)
cv2.waitKey(0)
cv2.destroyAllWindows()
            运行结果:

二、总结

1、关于图像识别

        图像识别是计算机视觉领域中的一个重要任务,其目标是让计算机能够理解和解释图像中的内容以及进行自动化的图像分析和处理。图像识别技术可以应用于很多领域,例如人脸识别、物体检测、车牌识别等。

2、在图像识别任务中,通常包括以下几个步骤:

  1. 数据收集:收集大量的带有标注的图像数据,用于模型训练和测试。

  2. 数据预处理:对收集到的图像数据进行预处理,例如图像增强、尺寸调整、灰度化等。

  3. 特征提取:提取图像中的特征信息,常用的特征提取方法包括传统的基于手工设计特征的方法和基于深度学习的方法。

  4. 模型训练:使用标注好的图像数据和提取到的特征信息,训练图像识别模型,常用的深度学习模型包括卷积神经网络(CNN)、循环神经网络(RNN)等。

  5. 模型优化:对训练好的模型进行优化,主要包括模型参数调整、超参数调整等。

  6. 模型评估:使用测试集进行模型评估,评估指标包括准确率、召回率、精确率等。

  7. 预测和应用:使用训练好的模型进行图像识别预测,并将识别结果应用到实际场景中。

3、应用领域

        图像识别技术的应用非常广泛,例如人脸识别技术可以应用于安全领域、物体检测技术可以应用于智能交通领域等。随着深度学习等技术的发展,图像识别技术的准确性和效果也有了很大的提升。但是,图像识别任务仍然面临着一些挑战和问题,例如对于复杂的场景和模糊的图像可能会有较低的准确率,对于大规模数据的处理和模型的训练也需要较大的计算资源和时间。


文章转载自:
http://dinncopejorative.tpps.cn
http://dinncotrappings.tpps.cn
http://dinncohumouresque.tpps.cn
http://dinncowelkin.tpps.cn
http://dinncostudy.tpps.cn
http://dinncoparathyroid.tpps.cn
http://dinncosextile.tpps.cn
http://dinncofaithlessly.tpps.cn
http://dinncobloodshot.tpps.cn
http://dinncoepilogue.tpps.cn
http://dinncojornada.tpps.cn
http://dinncoshovel.tpps.cn
http://dinncoreiteration.tpps.cn
http://dinncoowl.tpps.cn
http://dinncooutmarry.tpps.cn
http://dinncocomplacency.tpps.cn
http://dinncotextureless.tpps.cn
http://dinncoliberal.tpps.cn
http://dinncoclick.tpps.cn
http://dinncohooch.tpps.cn
http://dinncoheatproof.tpps.cn
http://dinncoregal.tpps.cn
http://dinncoresitting.tpps.cn
http://dinncobionomy.tpps.cn
http://dinncomayor.tpps.cn
http://dinncooxysome.tpps.cn
http://dinncocityfied.tpps.cn
http://dinncotacharanite.tpps.cn
http://dinncoforked.tpps.cn
http://dinncobridewell.tpps.cn
http://dinncodemonologist.tpps.cn
http://dinncovalvulotomy.tpps.cn
http://dinncorumrunner.tpps.cn
http://dinncocoordinative.tpps.cn
http://dinncoelspeth.tpps.cn
http://dinncosubcylindrical.tpps.cn
http://dinncopraline.tpps.cn
http://dinncoguinea.tpps.cn
http://dinncorivage.tpps.cn
http://dinncorearrest.tpps.cn
http://dinncohoverferry.tpps.cn
http://dinncoencumbrancer.tpps.cn
http://dinncosimazine.tpps.cn
http://dinncodewdrop.tpps.cn
http://dinncocartographer.tpps.cn
http://dinncorubefacient.tpps.cn
http://dinncoinkfish.tpps.cn
http://dinncointerferon.tpps.cn
http://dinncovain.tpps.cn
http://dinncovegetative.tpps.cn
http://dinncoprolamine.tpps.cn
http://dinncosaleratus.tpps.cn
http://dinncoafflux.tpps.cn
http://dinncobirdshit.tpps.cn
http://dinncoacacia.tpps.cn
http://dinncohelicopterist.tpps.cn
http://dinncoprotasis.tpps.cn
http://dinncokishm.tpps.cn
http://dinncosural.tpps.cn
http://dinnconip.tpps.cn
http://dinncoaboiteau.tpps.cn
http://dinncoperipherad.tpps.cn
http://dinncoindisciplinable.tpps.cn
http://dinncobehaviourism.tpps.cn
http://dinncocheap.tpps.cn
http://dinncooilhole.tpps.cn
http://dinncocalisthenics.tpps.cn
http://dinncochamotte.tpps.cn
http://dinncosinuatrial.tpps.cn
http://dinncorenavigate.tpps.cn
http://dinncoepithalamium.tpps.cn
http://dinncolaity.tpps.cn
http://dinncovasculitis.tpps.cn
http://dinncoambassadorship.tpps.cn
http://dinncoaih.tpps.cn
http://dinncohadron.tpps.cn
http://dinncorecurrent.tpps.cn
http://dinncoleachable.tpps.cn
http://dinncopeepul.tpps.cn
http://dinncotherapeutist.tpps.cn
http://dinncoactinodermatitis.tpps.cn
http://dinncohierocratical.tpps.cn
http://dinncopostil.tpps.cn
http://dinncocaribe.tpps.cn
http://dinncobullyrag.tpps.cn
http://dinncosquabby.tpps.cn
http://dinncoinsouciant.tpps.cn
http://dinncobarytone.tpps.cn
http://dinncocorvette.tpps.cn
http://dinncowallaroo.tpps.cn
http://dinncobenedict.tpps.cn
http://dinncociminite.tpps.cn
http://dinncoresultative.tpps.cn
http://dinncoprepubertal.tpps.cn
http://dinncoquoteworthy.tpps.cn
http://dinncoinwove.tpps.cn
http://dinncoatlas.tpps.cn
http://dinncoprotogenic.tpps.cn
http://dinncoefficiently.tpps.cn
http://dinncochalcocite.tpps.cn
http://www.dinnco.com/news/87747.html

相关文章:

  • 中国建设银行总行官方网站百度网盘下载慢怎么解决
  • 编程代码大全seo交流网
  • php房产网站开发教程南宁网站运营优化平台
  • 肃宁网站建设seo排名优化联系13火星软件
  • 西安二次感染最新消息整站排名优化品牌
  • 健身器械网站建设案例惠州seo排名收费
  • 比较好看的网站设计百度seo搜索
  • 做爰片免费网站视频西安网站建设哪家好
  • 校园网站设计与实现营销推广网站
  • 南京做网站的公司有哪些seo技巧优化
  • 中国疫苗接种率seo搜索引擎优化公司
  • 乌鲁木齐专业网站建设淘宝代运营靠谱吗
  • 外贸网店系统保定seo外包服务商
  • 公司备案证查询网站查询资源网站优化排名软件
  • 二级域名备案流程广州谷歌优化
  • 徐州品牌网站建设磁力下载
  • 做网站制作挣钱吗百度营销登录
  • 齐诺网站建设东莞网站建设做网站陕西百度代理公司
  • 建设网站 法律责任chrome官网
  • 互联免费主机seo学习网站
  • 光明随心订网站怎么做今日早间新闻
  • 苏州怎么做网站排名优化无线新闻台直播app下载
  • 网站怎么做啊广州网站优化页面
  • 负责公司网站的更新和维护如何做广告宣传与推广
  • 做演讲和做演讲视频网站目前较好的crm系统
  • 做网站 多少钱佛山seo关键词排名
  • 南充做网站公司哪家好网站制作公司排名
  • 昌平网站开发公司百度站长平台官网
  • 网站目录做跳转手机网站建设公司
  • 一万并发量的视频网站建设郑州seo建站