opencv案例实战——银行卡模式匹配识别

系列文章目录

1.图像读取及其通道与灰度
2.图像填充与图像融合
3.图像滤波
4.图像阈值
5.腐蚀与膨胀
6.图像梯度
7.边缘检测
8.轮廓与轮廓特征



前言

在之前的几篇文章中我们已经介绍了opencv的一些基础知识,本篇文章我们将结合一个案例运用之前的知识并且学习opencv中模式匹配的应用。
演示视频如下:

基于opencv图像处理的卡号检测效果演示(附源码)

用到的知识点如果有不清楚的可以查看上面列出来的系列文章。具体代码会放在最后。

案例介绍

我们有若干个如下图的银行卡图片
在这里插入图片描述
我们的目的是通过一些图像处理操作检测出银行卡中的卡号,除了银行卡图片外我们还有一个模板图片

opencv基于模板匹配的银行卡卡号识别项目实战 最近在恶补opencv,在前期不太那么认真的学习状态下,着手搞了一下这个小项目实战,基于模板匹配下的银行卡卡号识别。 整体思路: 首先对于该项目而言,我们所需要考虑的是,该如何让计算机成功识别到银行卡的卡号,并正确识别出每个卡号数字所对应的数字。那么我们在这里提供一种思路,首先通过对银行卡图像进行轮廓识别,然后拿到我们需要的对应的卡号的轮廓部分,然后再在轮廓中进行进一步轮廓识别,拿到每个数字的轮廓,最后通过画出每个数字的外接矩形,然后根据事先识别好的模板的外接矩形轮廓进行模板匹配,对应就能成功识别出正确的数 阅读详情

相关推荐

opencv之银行卡号识别

1.项目背景 1.1 项目介绍 这个一个opencv的经典应用,所以用它来熟悉之前的一些操作。 1.2 项目目的 通过此程序可以识别出银行卡图片中包括的银行卡卡号。 2.项目介绍 此项目主要分为两部分:模板图片处理,银行卡图片处理。 模板图片: 银行卡图片示例: 2.1 模板图片处理 由于模板图片如上图所示,是把十个数字放在一个图片里面,因此需要利用轮廓检测方法把它们分开成为10个模板。如下图: 步骤: 读入图片 化为 灰度图,再化为二值图 对二值图轮廓检测,得到轮廓数据 对所有轮廓按照x

aaaaaaaa1a1的博客 3007

OpenCV实践-银行卡号识别

OpenCV实践-银行卡号识别 利用opencv实现对图片上的银行卡上的卡号识别,并把识别出的数字标注在图片上。解决思路: 对数字模板进行轮廓识别,并将每个数字放到数组里 对银行卡上所有轮廓处理,根据长度选取每组卡号的轮廓(一组为4个数字) 将卡号轮廓外接矩形坐标保存,提取里面的每个数字并将它与数组的数字进行模板匹配 选取得分最高的数字,并将它们画在图片上 模板处理 根据这样的一个数字模板: 因为轮廓提取函数只接受二值图像,所以先灰度化,二值化: ref = cv2.cvtCOLOR(img,cv2.

qq_33643943的博客 1111

OpenCV C++案例实战二十《银行卡号识别》

OpenCV C++案例实战二十《银行卡号识别》前言一、获取模板图像1.1 功能效果1.2 功能源码二、银行卡号定位2.1 将银行卡号切割成四块2.1.1 功能效果2.1.2 功能源码2.2 字符切割2.2.1 功能效果2.2.2 功能源码三、字符识别3.1.读取文件3.2.字符匹配3.3.功能源码四、效果显示4.1 功能源码4.2 效果显示五、源码5.1 hpp文件5.2 cpp文件5.3 main文件总结 前言 本文将使用OpenCV C++ 进行银行卡号识别。主要步骤可以细分为: 1、 获取模板图像

Zero___Chen的博客 1万+

[Multisim][模电实验]简易函数信号发生器的设计与实现_北京邮电大学2019级信通院电子电路实验下

本文记述了笔者设计并实现以±12V供电电压输出1KHZ~10KHZ频率连续可调的方波、三角波和正弦波的过程。其中,方波输出电压峰峰值为12V(误差<20%),占空比可调、三角波输出电压峰峰值为8V(±20%),正弦波输出电压峰峰值≥1V。

lgc0208的博客 4万+

【踩坑记录】Latex引文bib报错

VScode+Texlive+Zotero本地论文写作环境踩坑。解决Zotero导出bib文件后tex中通过cite引用时所产生的问题。

weixin_43319948的博客 2828

知识图谱与人工智能本体论:构建机器认知的语义基石

本文探讨了知识图谱与人工智能本体论如何作为机器认知的语义基石,让AI从‘知道数据’迈向‘理解知识’。文章详细拆解了本体论的核心构件与构建方法,并阐述了从本体到知识图谱的实践路径,包括知识获取、融合、存储及推理应用,最终分析了其在智能搜索与专家系统等场景中带来的根本性重塑。

nginx7reverse的博客 913

HTB_Bike靶机之模板注入

船到桥头自然直 文章目录信息收集模板引擎SSIT 模板注入后放答案 信息收集 日常 A 扫描,两个端口 22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.4 (Ubuntu Linux; protocol 2.0) | ssh-hostkey: | 3072 48:ad:d5:b8:3a:9f:bc:be:f7:e8:20:1e:f6:bf:de:ae (RSA) | 256 b7:89:6c:0b:20:ed:49:b2:c1:86:7c:.

网络安全学习 802

ScanNetV2 数据集讲解和选择性下载

写在前面的话: 不可转载!!!!!!!!!!!! ScanNetV2一共1.2T,数据太大本文会简单讲解如何下载自己想要的文件,并附上修改后的下载程序 ScanNetV2:http://www.scan-net.org/ 简介 ScanNetV2的作者是斯坦福大学的博士,其团队通过收集RGB-D的视频序列,通过ipad应用加深传感器而收集的,然后视频会被上传到服务器,并被自动重建。然后,视频会被给到亚马逊 Mechanical Turk,将标注工作众包出去。ScanNetV2是RGB-D数据集,.

qq_35781447的博客 2万+

Origin教程004:Origin图形导出

需要编辑的话,双击图形,会自动用origin软件打开图形,这种方式是最开始导出图形的功能,方式一和二都是后面增加的。如果导出的图片边距较大的时候,会影响图片的美观,可以通过。也可以设置在PPT中直接编辑,找到。解决方法是,选择一条线,

WwLK123的博客 6346

基于综合阻抗特征的配电架空线路单相断线故障区段定位研究

本文提出了一种基于综合阻抗特征的配电架空线路单相断线故障区段定位方法。通过分析故障后正序、负序阻抗变化,构造综合阻抗判据实现精准定位。仿真结果表明:该方法能有效识别故障区段,差异度判据显著(故障区段达0.508,非故障区段<0.016);对过渡电阻(1-200Ω)和负荷变化具有强鲁棒性,定位准确率不受影响。相比传统方法,综合阻抗法放大了断线故障特征,解决了弱故障信号检测难题,为配电网安全运行提供了可靠的技术手段。

AI的内部世界的博客 84

【8】mctp & pldm

异步会check seq,保证不丢包,虽然发一条req,不用等,但是不能发下一条req,等上条response回来后才能发下一条。TO(tag owner)=1是request,TO=0是response,但是异步通信response由0改为1。如下还有kcs,i3c,serial等。

持续更新ing... 1086

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

上一篇: opencv-python常用函数解析及参数介绍(八)——轮廓与轮廓特征
下一篇: pytorch深度学习基础(八)——线性回归
艾醒(AiXing-w)
艾醒(AiXing-w) 2021年度博客之星AI领域top5 2021年度博客之星AI领域top5
博客等级 码龄7年 1万+粉丝 320原创
评论 5
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

艾醒(AiXing-w)

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址