信用卡大小卡的检测算法 [英] Algorithm to detect credit card sized card

查看:123
本文介绍了信用卡大小卡的检测算法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在图像中检测出信用卡大小的卡.该卡可以是任何卡,例如身份证,会员卡.目前,我正在考虑使用Canny Edge,Hough Line和Hough Circle来检测卡.但是,当我想结合霍夫线和霍夫圆的所有信息来定位卡时,该过程将很繁琐.有人建议使用threshold和findContour,但是卡片的颜色可能与背景相似,这使得该方法难以获得所需的结果.有什么内核和方法可以帮助我检测卡吗?

解决方案

我认为,您的问题类似于文档扫描仪.您可以参考此链接

  1. 使用Canny边缘检测器查找图像中的边缘(可以将较低和较高的阈值设置为0.66 * meanIntensity和1.33 * meanIntensity)并进行形态学封闭操作.

    执行关闭后的边缘图像

  2. 使用findContours查找图像中的轮廓

  3. 滤除不想要的轮廓(我使用廓线来过滤轮廓)

  4. 使用近似多边形将轮廓逼近7点或更多点. (我在这里使用0.005 *周长作为参数)

  5. 如果要查找准确的边缘,请在点之间拟合线并获得最大的4条线.找到它们的交点(因为卡可能包含弯曲边缘,也可能不包含弯曲边缘)

  6. 您最终将获得可用于单应性或确定区域的卡端点.

    卡的顶点

修改 编辑答案以包括获取卡顶点的步骤,并更新结果.

I want to detect a credit card sized card in image. The card can be any card eg identity card, member card. Currently, I am thinking to use Canny Edge, Hough Line and Hough Circle to detect the card. But the process will be tedious when I want to combine all the information of Hough Line and Hough Circle to locate the card. Some people suggest threshold and findContour but the color of card can be similar to the background which make this method difficult to achieve the desired result. Is there any kernel and method which can help me to detect the card?

解决方案

I think, your problem is similar to document scanner. You can refer to this link

  1. Find edges in the image using Canny edge detector (lower and higher thresholds can be set as 0.66*meanIntensity and 1.33*meanIntensity) and do a morphological close operation.

    Edge image after performing close

  2. Find the contours in the image using findContours

  3. filterout unwanted contours (I used contourArea to filter contours)

  4. using approxPolyDP approximate the contours to 7 or more points. (I used 0.005 * perimeter as the parameter here)

  5. If you want to find accurate edges, fit lines between the points and get the 4 biggest lines.Find their intersection (since the card may or may not contain curved edges)

  6. You'll end up with the card endpoints which can be used further for homography or to determine the region.

    vertices of the card

Edit Edited the answer to include the steps to obtain the vertices of the card and results are updated.

这篇关于信用卡大小卡的检测算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆