如何识别图像中的钞票?

时间:2010-07-03 16:12:10

标签: c opencv

我有一些欧元钞票的图像。账单完全在图像内 并且大部分是扁平的(例如很小的变形),并且透视歪斜很小(例如图像非常取自钞票上方)。

现在我不是图像识别方面的专家。我想实现以下目标:

  • 找到钱币的边界框(这样我就可以从图像其余部分的噪音中“删除”账单
  • 弄清楚方向。

我认为这两个步骤是预处理,但如果没有上述两个步骤,可能会执行以下步骤。所以,我想阅读:

  • 账单序号。
  • 票据面临价值。

我认为这应该与OpenCV完全相同。我只是不确定如何正确处理它。我会在边缘检测器上选择类似方法或霍夫或轮廓检测器的FaceDetector吗?

我还要感谢任何有关阅读材料的进一步提示。

3 个答案:

答案 0 :(得分:1)

霍夫很棒,但可能有点贵

这可能有效:

- 使用Threshold或Canny查找图像的边缘。

- 然后cvFindContours识别轮廓,然后尝试检测矩形。 检查opencv发行版中的squares.c示例。它基本上检查轮廓的多边形近似是否有4个点,并且这些点之间的平均角度接近90度。 以下是squares.py示例中的代码段 (在python中是相同的:P)。

  ..some pre-processing
  cvThreshold( tgray, gray, (l+1)*255/N, 255, CV_THRESH_BINARY );

        # find contours and store them all as a list
        count, contours = cvFindContours(gray, storage)

        if not contours:
            continue

        # test each contour
        for contour in contours.hrange():
            # approximate contour with accuracy proportional
            # to the contour perimeter
            result = cvApproxPoly( contour, sizeof(CvContour), storage,
                CV_POLY_APPROX_DP, cvContourPerimeter(contour)*0.02, 0 );
            res_arr = result.asarray(CvPoint)
            # square contours should have 4 vertices after approximation
            # relatively large area (to filter out noisy contours)
            # and be convex.
            # Note: absolute value of an area is used because
            # area may be positive or negative - in accordance with the
            # contour orientation
            if( result.total == 4 and 
                abs(cvContourArea(result)) > 1000 and 
                cvCheckContourConvexity(result) ):
                s = 0;
                for i in range(4):
                    # find minimum angle between joint
                    # edges (maximum of cosine)
                    t = abs(angle( res_arr[i], res_arr[i-2], res_arr[i-1]))
                    if s<t:
                        s=t
                # if cosines of all angles are small
                # (all angles are ~90 degree) then write quandrange
                # vertices to resultant sequence
                if( s < 0.3 ):
                    for i in range(4):
                        squares.append( res_arr[i] )

- 使用MinAreaRect2(查找给定2D点集的最小区域的外接矩形),获取矩形的边界框。使用边界框指向您可以轻松计算角度。

您还可以在opencv目录中的samples / c /下找到C版square.c。

答案 1 :(得分:0)

openCV上有一个很好的book

使用霍夫变换找到矩形条形状(和角度),然后在其中找到矩形/圆形应该快速而简单

对于更复杂的搜索,比如Haar分类器 - 如果你需要在图像中找到钞票的奇数角落?

答案 2 :(得分:0)

您还可以查看OpenCV中的模板匹配方法;另一种选择是使用SURF功能。他们让你搜索符号&amp;数字的大小,角度等不变。

相关问题