[go: up one dir, main page]

CN107368829B - Method and apparatus for determining a rectangular target area in an input image - Google Patents

Method and apparatus for determining a rectangular target area in an input image Download PDF

Info

Publication number
CN107368829B
CN107368829B CN201610307727.3A CN201610307727A CN107368829B CN 107368829 B CN107368829 B CN 107368829B CN 201610307727 A CN201610307727 A CN 201610307727A CN 107368829 B CN107368829 B CN 107368829B
Authority
CN
China
Prior art keywords
line segment
candidate
aspect ratio
line segments
segment combination
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Fee Related
Application number
CN201610307727.3A
Other languages
Chinese (zh)
Other versions
CN107368829A (en
Inventor
李鑫
刘伟
范伟
孙俊
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Fujitsu Ltd
Original Assignee
Fujitsu Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Fujitsu Ltd filed Critical Fujitsu Ltd
Priority to CN201610307727.3A priority Critical patent/CN107368829B/en
Publication of CN107368829A publication Critical patent/CN107368829A/en
Application granted granted Critical
Publication of CN107368829B publication Critical patent/CN107368829B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/20Image preprocessing
    • G06V10/25Determination of region of interest [ROI] or a volume of interest [VOI]

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Multimedia (AREA)
  • Theoretical Computer Science (AREA)
  • Image Processing (AREA)
  • Image Analysis (AREA)

Abstract

The invention discloses a method and equipment for determining a rectangular target area in an input image. The method comprises the following steps: acquiring a horizontal line segment and a vertical line segment in an input image; generating candidate line segment combinations, wherein each candidate line segment combination comprises two horizontal line segments and two vertical line segments, and the line segments or the extension lines of the line segments in each candidate line segment combination are intersected to obtain four intersection points; calculating the aspect ratio of the perspective corrected rectangular area corresponding to each candidate line segment combination according to the four intersection points corresponding to each candidate line segment combination, the preset reference aspect ratio and the camera internal parameters of the input image; selecting a candidate line segment combination based on the comparison of the aspect ratio corresponding to each candidate line segment combination with a predetermined reference aspect ratio; and determining an area surrounded by four line segments or extensions thereof in the selected candidate line segment combination as a rectangular target area.

Description

确定输入图像中的矩形目标区域的方法和设备Method and apparatus for determining a rectangular target area in an input image

技术领域technical field

本发明一般地涉及图像处理领域。具体而言,本发明涉及一种能够在复杂背景下确定输入图像中的矩形目标区域以进行透视校正的方法和设备。The present invention generally relates to the field of image processing. In particular, the present invention relates to a method and apparatus capable of determining a rectangular target area in an input image for perspective correction in a complex background.

背景技术Background technique

在现代社会中,存在有各种各样的证件、卡片、文档等,例如身份证,名片,银行卡,户口本,驾驶证,护照、派出所的户籍管理文档等。某些单位或者个人需要频繁的收集或存档这些信息,需要将这些证件、卡片、文档等留存电子件。除了一些特殊的读取工具以外,通常的电子化方法就是拍照,然后存储图像或者对图像进行识别后存储所识别的信息。In modern society, there are various certificates, cards, documents, etc., such as ID cards, business cards, bank cards, household registration books, driver's licenses, passports, and household registration management documents of police stations. Some units or individuals need to collect or archive this information frequently, and need to keep these certificates, cards, documents, etc. electronically. Except for some special reading tools, the usual electronic method is to take pictures, and then store the image or identify the image and store the identified information.

在拍照留存的过程中,往往需要解决透视变换的问题。这是因为:由于环境或设备的限制,对这些证件、卡片、文档等(矩形目标)进行拍摄时,有可能不是正对着拍摄对象的表面拍摄,而是与拍摄对象的表面的法线方向之间存在一定的角度,造成拍照结果受到倾斜的影响,这种倾斜通常被称为透视变换。为了下一步的识别和存储,必须对图像进行透视校正,然后才能进行版面分析、识别等后续处理。In the process of photographing and retaining, it is often necessary to solve the problem of perspective transformation. This is because: due to the limitations of the environment or equipment, when shooting these documents, cards, documents, etc. (rectangular targets), it may not be directly facing the surface of the subject, but the normal direction of the surface of the subject. There is a certain angle between them, which causes the result of taking pictures to be affected by tilt, which is usually called perspective transformation. For further identification and storage, perspective correction must be performed on the image, and then subsequent processing such as layout analysis and identification can be performed.

传统的方法是分析拍摄的图像,找出其边缘和角点,结合矩形目标的宽度和高度信息,建立透视变换公式,进行透视校正。The traditional method is to analyze the captured image, find its edges and corners, combine the width and height information of the rectangular target, establish a perspective transformation formula, and perform perspective correction.

但是,传统的方法要求准确的边缘和角点位置。在输入图像中矩形目标的背景复杂的情况下,难以准确定位边缘和角点位置,传统的方法就不再适用。However, traditional methods require accurate edge and corner locations. When the background of the rectangular target in the input image is complex, it is difficult to accurately locate the edge and corner positions, and the traditional method is no longer applicable.

本发明致力于解决上述问题,在输入图像中背景复杂的情况下仍能准确确定矩形目标区域,以用于透视校正。The present invention aims to solve the above problems, and can accurately determine a rectangular target area for perspective correction under the condition of complex background in the input image.

发明内容SUMMARY OF THE INVENTION

在下文中给出了关于本发明的简要概述,以便提供关于本发明的某些方面的基本理解。应当理解,这个概述并不是关于本发明的穷举性概述。它并不是意图确定本发明的关键或重要部分,也不是意图限定本发明的范围。其目的仅仅是以简化的形式给出某些概念,以此作为稍后论述的更详细描述的前序。The following presents a brief summary of the present invention in order to provide a basic understanding of certain aspects of the invention. It should be understood that this summary is not an exhaustive overview of the invention. It is not intended to identify key or essential parts of the invention nor to limit the scope of the invention. Its sole purpose is to present some concepts in a simplified form as a prelude to the more detailed description that is discussed later.

本发明的目的是提出一种确定输入图像中的矩形目标区域的方法和设备。The purpose of the present invention is to propose a method and apparatus for determining a rectangular target area in an input image.

为了实现上述目的,根据本发明的一个方面,提供了一种确定输入图像中的矩形目标区域的方法,该方法包括:获得输入图像中的水平类线段和竖直类线段;生成候选线段组合,每个候选线段组合中包括两个水平类线段和两个竖直类线段,每个候选线段组合中的线段或其延长线相交得到四个交点;根据每个候选线段组合对应的四个交点、预定参考宽高比、输入图像的相机内参数,计算每个候选线段组合对应的透视校正后矩形区域的宽高比;基于每个候选线段组合对应的宽高比与预定参考宽高比的比较,选择一个候选线段组合;以及将所选择的候选线段组合中的四个线段或其延长线包围的区域确定为矩形目标区域。In order to achieve the above object, according to an aspect of the present invention, a method for determining a rectangular target area in an input image is provided, the method comprising: obtaining horizontal line segments and vertical line segments in the input image; generating a candidate line segment combination, Each candidate line segment combination includes two horizontal line segments and two vertical line segments, and the line segments or their extension lines in each candidate line segment combination intersect to obtain four intersection points; according to each candidate line segment combination, the corresponding four intersection points, Predetermining the reference aspect ratio and the in-camera parameters of the input image, calculating the aspect ratio of the perspective-corrected rectangular area corresponding to each candidate line segment combination; based on the comparison between the aspect ratio corresponding to each candidate line segment combination and the predetermined reference aspect ratio , select a candidate line segment combination; and determine the area surrounded by four line segments or their extension lines in the selected candidate line segment combination as a rectangular target area.

根据本发明的另一个方面,提供了一种确定输入图像中的矩形目标区域的设备,该设备包括:线段获得装置,被配置为:获得输入图像中的水平类线段和竖直类线段;候选线段组合生成装置,被配置为:生成候选线段组合,每个候选线段组合中包括两个水平类线段和两个竖直类线段,每个候选线段组合中的线段或其延长线相交得到四个交点;宽高比计算装置,被配置为:根据每个候选线段组合对应的四个交点、预定参考宽高比、输入图像的相机内参数,计算每个候选线段组合对应的透视校正后矩形区域的宽高比;选择装置,被配置为:基于每个候选线段组合对应的宽高比与预定参考宽高比的比较,选择一个候选线段组合;以及矩形区域确定装置,被配置为:将所选择的候选线段组合中的四个线段或其延长线包围的区域确定为矩形目标区域。According to another aspect of the present invention, there is provided a device for determining a rectangular target area in an input image, the device comprising: a line segment obtaining device configured to: obtain horizontal line segments and vertical line segments in the input image; candidate A line segment combination generating device is configured to: generate candidate line segment combinations, each candidate line segment combination includes two horizontal line segments and two vertical line segments, and the line segments or their extension lines in each candidate line segment combination intersect to obtain four line segments intersection; an aspect ratio calculating device, configured to: calculate the perspective-corrected rectangular area corresponding to each candidate line segment combination according to the four intersection points corresponding to each candidate line segment combination, the predetermined reference aspect ratio, and the in-camera parameters of the input image the aspect ratio; the selection device is configured to: select a candidate line segment combination based on the comparison of the aspect ratio corresponding to each candidate line segment combination with the predetermined reference aspect ratio; and the rectangular area determination device is configured to: The area enclosed by the four line segments or their extension lines in the selected candidate line segment combination is determined as the rectangular target area.

根据本发明的又一方面,提供了一种信息处理设备。所述信息处理设备包括:控制器,被配置为:获得输入图像中的水平类线段和竖直类线段;生成候选线段组合,每个候选线段组合中包括两个水平类线段和两个竖直类线段,每个候选线段组合中的线段或其延长线相交得到四个交点;根据每个候选线段组合对应的四个交点、预定参考宽高比、输入图像的相机内参数,计算每个候选线段组合对应的透视校正后矩形区域的宽高比;基于每个候选线段组合对应的宽高比与预定参考宽高比的比较,选择一个候选线段组合;以及将所选择的候选线段组合中的四个线段或其延长线包围的区域确定为矩形目标区域。According to yet another aspect of the present invention, an information processing apparatus is provided. The information processing device includes: a controller configured to: obtain horizontal line segments and vertical line segments in an input image; and generate candidate line segment combinations, each candidate line segment combination including two horizontal line segments and two vertical line segments Class line segment, the line segments or their extension lines in each candidate line segment combination intersect to obtain four intersection points; according to the four intersection points corresponding to each candidate line segment combination, the predetermined reference aspect ratio, and the in-camera parameters of the input image, calculate each candidate line segment. The aspect ratio of the perspective-corrected rectangular area corresponding to the line segment combination; selecting a candidate line segment combination based on the comparison between the aspect ratio corresponding to each candidate line segment combination and the predetermined reference aspect ratio; and combining the selected candidate line segment combinations. The area enclosed by the four line segments or their extension lines is determined as the rectangular target area.

另外,根据本发明的另一方面,还提供了一种存储介质。所述存储介质包括机器可读的程序代码,当在信息处理设备上执行所述程序代码时,所述程序代码使得所述信息处理设备执行根据本发明的上述方法。In addition, according to another aspect of the present invention, a storage medium is also provided. The storage medium includes machine-readable program code which, when executed on an information processing apparatus, causes the information processing apparatus to perform the above-described method according to the present invention.

此外,根据本发明的再一方面,还提供了一种程序产品。所述程序产品包括机器可执行的指令,当在信息处理设备上执行所述指令时,所述指令使得所述信息处理设备执行根据本发明的上述方法。Furthermore, according to yet another aspect of the present invention, a program product is also provided. The program product comprises machine-executable instructions which, when executed on an information processing apparatus, cause the information processing apparatus to perform the above-described method according to the invention.

应注意:本发明能够解决传统方法不能处理复杂背景的图像的技术问题,并且本发明也能够处理简单背景的图像。It should be noted that the present invention can solve the technical problem that traditional methods cannot handle images with complex backgrounds, and the present invention can also handle images with simple backgrounds.

附图说明Description of drawings

参照下面结合附图对本发明的实施例的说明,会更加容易地理解本发明的以上和其它目的、特点和优点。附图中的部件只是为了示出本发明的原理。在附图中,相同的或类似的技术特征或部件将采用相同或类似的附图标记来表示。附图中:The above and other objects, features and advantages of the present invention will be more easily understood with reference to the following description of the embodiments of the present invention in conjunction with the accompanying drawings. The components in the drawings are merely intended to illustrate the principles of the invention. In the drawings, the same or similar technical features or components will be denoted by the same or similar reference numerals. In the attached picture:

图1示出了根据本发明的实施例的确定输入图像中的矩形目标区域的方法的流程图。FIG. 1 shows a flowchart of a method of determining a rectangular target area in an input image according to an embodiment of the present invention.

图2示出了步骤S1的一种实施方式。FIG. 2 shows an embodiment of step S1.

图3示出了步骤S3的一种实施方式。FIG. 3 shows an embodiment of step S3.

图4示出了输入图像的示例。FIG. 4 shows an example of an input image.

图5示出了检测出的所有边缘线段。Figure 5 shows all edge segments detected.

图6示出了根据本发明的方法找到的矩形目标区域。Figure 6 shows a rectangular target area found according to the method of the present invention.

图7示出了在本发明的基础上进行透视校正后的结果。FIG. 7 shows the result of perspective correction based on the present invention.

图8示出了根据本发明的实施例的设备的结构方框图。FIG. 8 shows a block diagram of the structure of a device according to an embodiment of the present invention.

图9示出了根据本发明的信息处理设备的结构方框图。FIG. 9 is a block diagram showing the structure of an information processing apparatus according to the present invention.

图10示出了可用于实施根据本发明的实施例的方法和设备的计算机的示意性框图。Figure 10 shows a schematic block diagram of a computer that may be used to implement methods and apparatus according to embodiments of the present invention.

具体实施方式Detailed ways

在下文中将结合附图对本发明的示范性实施例进行详细描述。为了清楚和简明起见,在说明书中并未描述实际实施方式的所有特征。然而,应该了解,在开发任何这种实际实施方式的过程中必须做出很多特定于实施方式的决定,以便实现开发人员的具体目标,例如,符合与系统及业务相关的那些限制条件,并且这些限制条件可能会随着实施方式的不同而有所改变。此外,还应该了解,虽然开发工作有可能是非常复杂和费时的,但对得益于本公开内容的本领域技术人员来说,这种开发工作仅仅是例行的任务。Hereinafter, exemplary embodiments of the present invention will be described in detail with reference to the accompanying drawings. In the interest of clarity and conciseness, not all features of an actual implementation are described in the specification. It should be appreciated, however, that many implementation-specific decisions must be made in the development of any such actual implementation in order to achieve the developer's specific goals, such as compliance with those constraints related to the system and the business, and these Restrictions may vary from implementation to implementation. Furthermore, it should also be appreciated that while development work can be very complex and time consuming, such development work would be a routine undertaking for those skilled in the art having the benefit of this disclosure.

在此,还需要说明的一点是,为了避免因不必要的细节而模糊了本发明,在附图中仅仅示出了与根据本发明的方案密切相关的装置结构和/或处理步骤,而省略了与本发明关系不大的其他细节。另外,还需要指出的是,在本发明的一个附图或一种实施方式中描述的元素和特征可以与一个或更多个其它附图或实施方式中示出的元素和特征相结合。Here, it should also be noted that, in order to avoid obscuring the present invention due to unnecessary details, only device structures and/or processing steps closely related to the solution according to the present invention are shown in the drawings, and are omitted. other details not relevant to the present invention. Additionally, it is noted that elements and features described in one figure or embodiment of the present invention may be combined with elements and features shown in one or more other figures or embodiments.

下面将参照图1描述根据本发明的实施例的确定输入图像中的矩形目标区域的方法的流程。The flow of a method for determining a rectangular target area in an input image according to an embodiment of the present invention will be described below with reference to FIG. 1 .

图1示出了根据本发明的实施例的确定输入图像中的矩形目标区域的方法的流程图。如图1所示,根据本发明的实施例的方法包括如下步骤:获得输入图像中的水平类线段和竖直类线段(步骤S1);生成候选线段组合,每个候选线段组合中包括两个水平类线段和两个竖直类线段,每个候选线段组合中的线段或其延长线相交得到四个交点(步骤S2);根据每个候选线段组合对应的四个交点、预定参考宽高比、输入图像的相机内参数,计算每个候选线段组合对应的透视校正后矩形区域的宽高比(步骤S3);基于每个候选线段组合对应的宽高比与预定参考宽高比的比较,选择一个候选线段组合(步骤S4);以及将所选择的候选线段组合中的四个线段或其延长线包围的区域确定为矩形目标区域(步骤S5)。FIG. 1 shows a flowchart of a method of determining a rectangular target area in an input image according to an embodiment of the present invention. As shown in FIG. 1 , the method according to an embodiment of the present invention includes the following steps: obtaining horizontal line segments and vertical line segments in an input image (step S1 ); generating candidate line segment combinations, each candidate line segment combination including two The horizontal line segment and the two vertical line segments, the line segments or their extension lines in each candidate line segment combination intersect to obtain four intersection points (step S2); according to the four intersection points corresponding to each candidate line segment combination, the predetermined reference aspect ratio , input the in-camera parameters of the image, and calculate the aspect ratio of the perspective-corrected rectangular area corresponding to each candidate line segment combination (step S3); based on the comparison between the aspect ratio corresponding to each candidate line segment combination and the predetermined reference aspect ratio, One candidate line segment combination is selected (step S4 ); and the area surrounded by four line segments or their extension lines in the selected candidate line segment combination is determined as a rectangular target area (step S5 ).

在步骤S1中,获得输入图像中的水平类线段和竖直类线段。In step S1, horizontal line segments and vertical line segments in the input image are obtained.

输入图像例如是包含证件、卡片、文档等矩形目标的图像。The input image is, for example, an image containing a rectangular object such as a certificate, card, document, or the like.

图4示出了输入图像的示例,其中包括矩形目标区域(下方的卡片)和复杂的背景干扰(上方的N次贴,其具有两个类似于矩形的结构),在用传统的方法进行透视校正时,很容易将背景认定为矩形目标区域,进而错误地进行透视校正。Figure 4 shows an example of an input image, which includes a rectangular target area (card below) and a complex background distraction (N-time sticker above, which has two rectangle-like structures), before using conventional methods for perspective When correcting, it is easy to identify the background as a rectangular target area and incorrectly perform perspective correction.

首先,例如,可以对输入图像进行预处理,预处理包括但不限于去除噪声、缩放大小、图像增强等。First, for example, the input image can be preprocessed, including but not limited to noise removal, resizing, image enhancement, and the like.

然后,如图2所示,在步骤S21中,获取输入图像中的线段。Then, as shown in FIG. 2, in step S21, line segments in the input image are acquired.

具体地,检测输入图像中的边缘;以及从边缘中检测线段。Specifically, detecting edges in the input image; and detecting line segments from the edges.

检测图像中的边缘的方法和从边缘中检测直线段的方法为本领域技术人员所熟知,例如,可以基于CANNY算子或者基于梯度检测边缘。从边缘中检测线段例如可以利用霍夫线检测算法等。本发明不限于此。Methods for detecting edges in images and methods for detecting straight line segments from edges are well known to those skilled in the art, for example, edges can be detected based on CANNY operator or based on gradients. To detect line segments from edges, for example, a Hough line detection algorithm or the like can be used. The present invention is not limited to this.

在步骤S22中,将所获取的线段分类为水平类线段和竖直类线段。In step S22, the acquired line segments are classified into horizontal line segments and vertical line segments.

首先,对所有获取的线段进行合并,将距离接近、斜率一致或接近(如相差5度以内)的线段进行合并,合并为一条线段。其中,斜率不一致且不接近的线段之间的距离定义为最大值。合并的方法例如是拟合多个线段、选取中间位置的线段、以平均斜率代表、聚类等。应注意,合并步骤为可选步骤。First, merge all the obtained line segments, and merge the line segments with close distances, the same slope or close (eg, within 5 degrees), and merge them into one line segment. Among them, the distance between line segments whose slopes are inconsistent and not close is defined as the maximum value. The methods of combining are, for example, fitting multiple line segments, selecting line segments in the middle, representing by average slope, clustering, and so on. It should be noted that the merge step is optional.

然后,对所有合并后的线段进行分类,根据其斜率,分为水平类线段和竖直类线段。Then, all the merged line segments are classified into horizontal line segments and vertical line segments according to their slopes.

水平类线段为大体水平的线段,例如与水平方向的斜率之差在预定范围内的线段。竖直类线段为大体竖直的线段,例如与竖直方向的斜率之差在预定范围内的线段。The horizontal line segment is a substantially horizontal line segment, for example, a line segment whose slope difference from the horizontal direction is within a predetermined range. The vertical line segment is a substantially vertical line segment, for example, a line segment whose slope difference from the vertical direction is within a predetermined range.

当然,上述合并线段的步骤和将线段分类为水平类线段和竖直类线段的步骤的顺序可以互换。Of course, the order of the steps of merging the line segments and the step of classifying the line segments into horizontal line segments and vertical line segments can be interchanged.

图5示出了检测出的所有边缘线段,包括卡片的四个边、N次贴的7个边。Figure 5 shows all detected edge line segments, including the four sides of the card and the seven sides of the N-time stickers.

在步骤S2中,生成候选线段组合,每个候选线段组合中包括两个水平类线段和两个竖直类线段,每个候选线段组合中的线段或其延长线相交得到四个交点。应注意,这里的候选线段组合例如是穷举得到的。In step S2, a candidate line segment combination is generated, each candidate line segment combination includes two horizontal line segments and two vertical line segments, and the line segments or their extension lines in each candidate line segment combination intersect to obtain four intersection points. It should be noted that the candidate line segment combinations here are, for example, obtained exhaustively.

因为目标区域是矩形的,矩形包括彼此垂直的两条水平边和两条竖直边,所以候选线段组合应包括两个水平类线段和两个竖直类线段。Since the target area is rectangular, and the rectangle includes two horizontal sides and two vertical sides that are perpendicular to each other, the candidate line segment combination should include two horizontal-like line segments and two vertical-like line segments.

所生成的每个候选线段组合中的线段或其延长线相交可以得到四个交点。应注意,如果得到的四个交点中至少有一个交点不在输入图像的范围内,则舍弃这样的候选线段组合。Four intersection points can be obtained by intersecting the line segments or their extended lines in each candidate line segment combination generated. It should be noted that if at least one of the four obtained intersections is not within the range of the input image, such a candidate line segment combination is discarded.

在步骤S3中,根据每个候选线段组合对应的四个交点、预定参考宽高比、输入图像的相机内参数,计算每个候选线段组合对应的透视校正后矩形区域的宽高比。In step S3, the aspect ratio of the perspective-corrected rectangular area corresponding to each candidate line segment combination is calculated according to the four intersection points corresponding to each candidate line segment combination, the predetermined reference aspect ratio, and the in-camera parameters of the input image.

具体地,如图3所示,在步骤S31中,根据每个候选线段组合对应的四个交点和预定参考宽高比,得到对应的用于透视校正的单应性矩阵。Specifically, as shown in FIG. 3 , in step S31 , a corresponding homography matrix for perspective correction is obtained according to the four intersection points corresponding to each candidate line segment combination and a predetermined reference aspect ratio.

假设最终得到的水平类线段为sh1、sh2等。竖直类线段为sv1,sv2等。候选线段组合(sh1、sh2、sv1,sv2)对应四个交点为(sh1,sv1),(sh1,sv2),(sh2,sv1),(sh2,sv2)的交点,命名为p1、p2、p3、p4It is assumed that the final obtained horizontal class line segments are sh1, s h2 , and so on. The vertical line segments are s v1 , s v2 and so on. The candidate line segment combination (s h1 , s h2 , s v1 , s v2 ) corresponds to four intersection points (s h1 , s v1 ), (s h1 , s v2 ), (s h2 , s v1 ), (s h2 , s v2 ), named p 1 , p 2 , p 3 , p 4 .

本发明基于如下假设:已知目标的宽高比,称为预定参考宽高比R。The present invention is based on the assumption that the aspect ratio of the target is known, referred to as the predetermined reference aspect ratio R.

基于预定参考宽高比R,可以构建单位目标矩形,其四个顶点坐标为pm1(0,0)、pm2(1,0)、pm3(0,R)、pm4(1,R)。Based on a predetermined reference aspect ratio R, a unit target rectangle can be constructed whose four vertex coordinates are p m1 (0,0), p m2 (1,0), p m3 (0, R), p m4 (1, R ).

针对每个候选线段组合,都有四个交点p1、p2、p3、p4。本领域技术人员已知透视校正用的单应性矩阵H为:For each candidate line segment combination, there are four intersection points p 1 , p 2 , p 3 , p 4 . Those skilled in the art know that the homography matrix H used for perspective correction is:

Figure BDA0000986839180000071
Figure BDA0000986839180000071

其中,h33=1。where h 33 =1.

相应地,透视变换公式为:Correspondingly, the perspective transformation formula is:

h21xix+h22xiy+h23=(h31xix+h32xiy+h33)miy h 21 x ix +h 22 x iy +h 23 =(h 31 x ix +h 32 x iy +h 33 )m iy

h11xix+h12xiy+h13=(h31xix+h32xiy+h33)mix h 11 x ix +h 12 x iy +h 13 =(h 31 x ix +h 32 x iy +h 33 )m ix

其中,xix、xiy为p1、p2、p3、p4的横坐标和纵坐标,mix、miy为pm1(0,0)、pm2(1,0)、pm3(0,R)、pm4(1,R)的横坐标和纵坐标。因此,共得到8个方程,由于R已知,共8个未知数,即h11、h12、h13、h21、h22、h23、h31、h32。即可求解出单应性矩阵H。应注意,此单应性矩阵对应的是射影空间中的(即经透视变换后的)基于预定参考宽高比R的单位目标矩形,并不是最终用于进行透视校正的单应性矩阵。并且,此单应性矩阵对应于一个候选线段组合。因此,每个候选线段组合对应于一个单应性矩阵H。Among them, x ix , x iy are the abscissa and ordinate of p 1 , p 2 , p 3 , and p 4 , and mix and m iy are p m1 (0,0), p m2 (1,0), p m3 (0,R), the abscissa and ordinate of p m4 (1,R). Therefore, a total of 8 equations are obtained. Since R is known, there are 8 unknowns in total, namely h 11 , h 12 , h 13 , h 21 , h 22 , h 23 , h 31 , and h 32 . The homography matrix H can be solved. It should be noted that this homography matrix corresponds to the unit target rectangle in the projective space (that is, after perspective transformation) based on a predetermined reference aspect ratio R, and is not the final homography matrix used for perspective correction. And, this homography matrix corresponds to a candidate line segment combination. Therefore, each candidate line segment combination corresponds to a homography matrix H.

此外,当射影空间中的(即经透视变换后的)宽高比r未知时,同样经过上述的推导步骤,可以得到包含h11、h12、h13、h21、h22、h23、h31、h32共8个未知数的8个方程,可用于解方程组的有对应于每个候选线段组合的4个交点P和基于未知宽高比r的单位目标矩形。这样,共有9个未知数。In addition, when the aspect ratio r in the projective space (that is, after perspective transformation) is unknown, through the above derivation steps, it can be obtained including h 11 , h 12 , h 13 , h 21 , h 22 , h 23 , h 31 , h 32 have a total of 8 equations with 8 unknowns, and there are 4 intersection points P corresponding to each candidate line segment combination and a unit target rectangle based on an unknown aspect ratio r that can be used to solve the equation system. Thus, there are 9 unknowns in total.

另外,基于透视校正前四个点的世界坐标与透视校正后四个点在射影空间的射影坐标的对应关系(即上述透视变换公式)、相机的外参矩阵的公知特性,可知透视变换矩阵和相机内参数之间的约束关系:In addition, based on the correspondence between the world coordinates of the four points before the perspective correction and the projective coordinates of the four points after the perspective correction in the projective space (that is, the above-mentioned perspective transformation formula), and the known characteristics of the camera's external parameter matrix, it can be known that the perspective transformation matrix and The constraint relationship between the parameters in the camera:

Figure BDA0000986839180000081
Figure BDA0000986839180000081

其中,相机内参数矩阵A为:

Figure BDA0000986839180000082
f为相机的焦距,w、h为相机的分辨率,a、b为相机的传感器尺寸。Among them, the camera internal parameter matrix A is:
Figure BDA0000986839180000082
f is the focal length of the camera, w and h are the resolution of the camera, and a and b are the sensor size of the camera.

这样,共9个方程和9个未知数。Thus, there are 9 equations and 9 unknowns in total.

可以求解出:can be solved:

Figure BDA0000986839180000083
Figure BDA0000986839180000083

其中,每个候选线段组合可以求解出一个r。上述公式是预定关系的示例。Among them, each candidate line segment combination can solve an r. The above formula is an example of a predetermined relationship.

因此,在步骤S32中,根据每个候选线段组合对应的单应性矩阵和输入图像的相机内参数,基于预定关系,计算每个候选线段组合对应的透视校正后矩形区域的宽高比。Therefore, in step S32, according to the homography matrix corresponding to each candidate line segment combination and the in-camera parameters of the input image, and based on a predetermined relationship, the aspect ratio of the perspective corrected rectangular region corresponding to each candidate line segment combination is calculated.

在步骤S4中,基于每个候选线段组合对应的宽高比r与预定参考宽高比R的比较,选择一个候选线段组合。In step S4, a candidate line segment combination is selected based on the comparison between the aspect ratio r corresponding to each candidate line segment combination and the predetermined reference aspect ratio R.

具体地,选择其宽高比与预定参考宽高比之差最小的候选线段组合。由于输入图像中只有一个矩形目标区域,因此,只有一个候选线段组合对应的r是正确的,即最接近预定参考宽高比R。Specifically, the candidate line segment combination whose aspect ratio is the smallest difference from the predetermined reference aspect ratio is selected. Since there is only one rectangular target area in the input image, only one candidate line segment combination corresponds to the correct r, that is, the closest to the predetermined reference aspect ratio R.

在步骤S5中,将所选择的候选线段组合中的四个线段或其延长线包围的区域确定为矩形目标区域。In step S5, the area surrounded by the four line segments or their extension lines in the selected candidate line segment combination is determined as a rectangular target area.

图6示出了根据本发明的方法找到的矩形目标区域,其四个角点以圆点标识。FIG. 6 shows a rectangular target area found according to the method of the present invention, the four corners of which are marked with dots.

另外,根据最终选择的宽高比r对应的单应性矩阵,可对步骤S5中确定的矩形目标区域进行透视校正,以得到校正后的图像。In addition, according to the homography matrix corresponding to the finally selected aspect ratio r, perspective correction may be performed on the rectangular target area determined in step S5 to obtain a corrected image.

图7示出了在本发明的基础上,进行透视校正后的结果。下方的卡片已经校正为标准的卡片形状,不再具有透视变换的效果,同时,上方的N次贴被校正为畸形,这是因为本发明的透视校正所基于的单应性矩阵是基于正确的目标即卡片生成的。在传统的方法中,由于难以判断卡片与N次贴哪个是目标区域,所以很可能将N次贴校正得较好,而将卡片校正为畸形。FIG. 7 shows the result of perspective correction based on the present invention. The lower card has been corrected to the standard card shape, and no longer has the effect of perspective transformation. At the same time, the upper N times stickers have been corrected to be deformed. This is because the homography matrix on which the perspective correction of the present invention is based is based on the correct one. Targets are generated from cards. In the traditional method, since it is difficult to judge which of the card and the N-time sticker is the target area, it is likely that the N-time sticker is better corrected, and the card is corrected to be deformed.

下面,将参照图8描述根据本发明的实施例的确定输入图像中的矩形目标区域的设备。Hereinafter, an apparatus for determining a rectangular target area in an input image according to an embodiment of the present invention will be described with reference to FIG. 8 .

图8示出了根据本发明的实施例的设备的结构方框图。如图8所示,根据本发明的确定输入图像中的矩形目标区域的设备800包括:线段获得装置81,被配置为:获得输入图像中的水平类线段和竖直类线段;候选线段组合生成装置82,被配置为:生成候选线段组合,每个候选线段组合中包括两个水平类线段和两个竖直类线段,每个候选线段组合中的线段或其延长线相交得到四个交点;宽高比计算装置83,被配置为:根据每个候选线段组合对应的四个交点、预定参考宽高比、输入图像的相机内参数,计算每个候选线段组合对应的透视校正后矩形区域的宽高比;选择装置84,被配置为:基于每个候选线段组合对应的宽高比与预定参考宽高比的比较,选择一个候选线段组合;以及矩形区域确定装置85,被配置为:将所选择的候选线段组合中的四个线段或其延长线包围的区域确定为矩形目标区域。FIG. 8 shows a block diagram of the structure of a device according to an embodiment of the present invention. As shown in FIG. 8 , the device 800 for determining a rectangular target area in an input image according to the present invention includes: a line segment obtaining device 81, configured to: obtain horizontal line segments and vertical line segments in the input image; The device 82 is configured to: generate a candidate line segment combination, each candidate line segment combination includes two horizontal class line segments and two vertical class line segments, and the line segments or their extension lines in each candidate line segment combination intersect to obtain four intersection points; The aspect ratio calculation device 83 is configured to: calculate the perspective correction rectangular area corresponding to each candidate line segment combination according to the four intersection points corresponding to each candidate line segment combination, the predetermined reference aspect ratio, and the in-camera parameters of the input image. aspect ratio; selecting means 84, configured to: select a candidate line segment combination based on the comparison of the aspect ratio corresponding to each candidate line segment combination with a predetermined reference aspect ratio; and a rectangular area determining means 85, configured to: The area enclosed by the four line segments or their extension lines in the selected candidate line segment combination is determined as a rectangular target area.

在一个实施例中,宽高比计算装置83包括:单应性矩阵获得单元,被配置为:根据每个候选线段组合对应的四个交点和预定参考宽高比,得到对应的用于透视校正的单应性矩阵;宽高比计算单元,被配置为:根据每个候选线段组合对应的单应性矩阵和输入图像的相机内参数,基于预定关系,计算每个候选线段组合对应的透视校正后矩形区域的宽高比。In one embodiment, the aspect ratio calculating device 83 includes: a homography matrix obtaining unit, configured to: combine the corresponding four intersection points of each candidate line segment and a predetermined reference aspect ratio to obtain a corresponding one for perspective correction The homography matrix of the The aspect ratio of the back rectangular area.

在一个实施例中,预定关系基于透视校正前四个点的世界坐标与透视校正后四个点在射影空间的射影坐标的对应关系、相机的外参矩阵的特性来构建。In one embodiment, the predetermined relationship is constructed based on the correspondence between the world coordinates of the four points before the perspective correction and the projective coordinates of the four points after the perspective correction in the projective space, and the characteristics of the camera's extrinsic parameter matrix.

在一个实施例中,线段获得装置81包括:获取单元,被配置为:获取输入图像中的线段;以及分类单元,被配置为:将所获取的线段分类为水平类线段和竖直类线段。In one embodiment, the line segment obtaining device 81 includes: an obtaining unit configured to obtain line segments in the input image; and a classification unit configured to classify the obtained line segments into horizontal line segments and vertical line segments.

在一个实施例中,线段获得装置81还包括:合并单元,被配置为:根据预定规则,分别合并水平类线段和/或竖直类线段中的至少部分线段。In one embodiment, the line segment obtaining apparatus 81 further includes: a merging unit, configured to merge at least some of the horizontal line segments and/or the vertical line segments respectively according to a predetermined rule.

在一个实施例中,获取单元被进一步配置为:检测输入图像中的边缘;以及从边缘中检测线段。In one embodiment, the acquisition unit is further configured to: detect edges in the input image; and detect line segments from the edges.

在一个实施例中,获取单元被进一步配置为:基于梯度,检测输入图像中的边缘;以及利用霍夫变换,从边缘中检测线段。In one embodiment, the acquisition unit is further configured to: detect edges in the input image based on the gradients; and detect line segments from the edges using the Hough transform.

在一个实施例中,选择装置84被进一步配置为:选择其宽高比与预定参考宽高比之差最小的候选线段组合。In one embodiment, the selecting means 84 is further configured to select the candidate line segment combination whose aspect ratio is the smallest in difference from the predetermined reference aspect ratio.

由于在根据本发明的设备800中所包括的各个装置和单元中的处理分别与上面描述的方法中所包括的各个步骤中的处理类似,因此为了简洁起见,在此省略这些装置和单元的详细描述。Since the processing in each device and unit included in the apparatus 800 according to the present invention is respectively similar to the process in each step included in the method described above, the details of these devices and units are omitted here for the sake of brevity. describe.

另外,根据本发明的再一方面,如图9所示,提供了一种信息处理设备。该信息处理设备100包括控制器1001。该控制器1001被配置为:获得输入图像中的水平类线段和竖直类线段;生成候选线段组合,每个候选线段组合中包括两个水平类线段和两个竖直类线段,每个候选线段组合中的线段或其延长线相交得到四个交点;根据每个候选线段组合对应的四个交点、预定参考宽高比、输入图像的相机内参数,计算每个候选线段组合对应的透视校正后矩形区域的宽高比;基于每个候选线段组合对应的宽高比与预定参考宽高比的比较,选择一个候选线段组合;以及将所选择的候选线段组合中的四个线段或其延长线包围的区域确定为矩形目标区域。In addition, according to still another aspect of the present invention, as shown in FIG. 9, an information processing apparatus is provided. The information processing apparatus 100 includes a controller 1001 . The controller 1001 is configured to: obtain horizontal line segments and vertical line segments in the input image; generate candidate line segment combinations, each candidate line segment combination includes two horizontal line segments and two vertical line segments, each candidate line segment Four intersection points are obtained by intersecting the line segments or their extension lines in the line segment combination; according to the four intersection points corresponding to each candidate line segment combination, the predetermined reference aspect ratio, and the in-camera parameters of the input image, the perspective correction corresponding to each candidate line segment combination is calculated. The aspect ratio of the rear rectangular area; based on the comparison of the aspect ratio corresponding to each candidate line segment combination with the predetermined reference aspect ratio, select one candidate line segment combination; and select four line segments or their extensions in the selected candidate line segment combination The area enclosed by the line is determined as the rectangular target area.

此外,这里尚需指出的是,上述设备中各个组成装置、单元可以通过软件、固件、硬件或其组合的方式进行配置。配置可使用的具体手段或方式为本领域技术人员所熟知,在此不再赘述。在通过软件或固件实现的情况下,从存储介质或网络向具有专用硬件结构的计算机(例如图10所示的通用计算机900)安装构成该软件的程序,该计算机在安装有各种程序时,能够执行各种功能等。In addition, it should be pointed out here that each component device and unit in the above-mentioned apparatus may be configured by means of software, firmware, hardware or a combination thereof. The specific means or manners that can be used for the configuration are well known to those skilled in the art, and are not repeated here. When implemented by software or firmware, the program constituting the software is installed from a storage medium or a network to a computer having a dedicated hardware configuration (for example, a general-purpose computer 900 shown in FIG. 10 ). When the computer is installed with various programs, Can perform various functions and the like.

图10示出了可用于实施根据本发明的实施例的方法和设备的计算机的示意性框图。Figure 10 shows a schematic block diagram of a computer that may be used to implement methods and apparatus according to embodiments of the present invention.

在图10中,中央处理单元(CPU)901根据只读存储器(ROM)902中存储的程序或从存储部分908加载到随机存取存储器(RAM)903的程序执行各种处理。在RAM 903中,还根据需要存储当CPU 901执行各种处理等等时所需的数据。CPU 901、ROM 902和RAM 903经由总线904彼此连接。输入/输出接口905也连接到总线904。In FIG. 10 , a central processing unit (CPU) 901 executes various processes according to a program stored in a read only memory (ROM) 902 or a program loaded from a storage section 908 to a random access memory (RAM) 903 . In the RAM 903, data required when the CPU 901 executes various processes and the like is also stored as necessary. The CPU 901 , the ROM 902 and the RAM 903 are connected to each other via a bus 904 . An input/output interface 905 is also connected to the bus 904 .

下述部件连接到输入/输出接口905:输入部分906(包括键盘、鼠标等等)、输出部分907(包括显示器,比如阴极射线管(CRT)、液晶显示器(LCD)等,和扬声器等)、存储部分908(包括硬盘等)、通信部分909(包括网络接口卡比如LAN卡、调制解调器等)。通信部分909经由网络比如因特网执行通信处理。根据需要,驱动器910也可连接到输入/输出接口905。可拆卸介质911比如磁盘、光盘、磁光盘、半导体存储器等等可以根据需要被安装在驱动器910上,使得从中读出的计算机程序根据需要被安装到存储部分908中。The following components are connected to the input/output interface 905: an input section 906 (including a keyboard, mouse, etc.), an output section 907 (including a display such as a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.), A storage part 908 (including a hard disk, etc.), a communication part 909 (including a network interface card such as a LAN card, a modem, etc.). The communication section 909 performs communication processing via a network such as the Internet. A driver 910 may also be connected to the input/output interface 905 as desired. A removable medium 911 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc. can be mounted on the drive 910 as needed, so that a computer program read therefrom is installed into the storage section 908 as needed.

在通过软件实现上述系列处理的情况下,从网络比如因特网或存储介质比如可拆卸介质911安装构成软件的程序。In the case where the above-described series of processing is realized by software, a program constituting the software is installed from a network such as the Internet or a storage medium such as the removable medium 911 .

本领域的技术人员应当理解,这种存储介质不局限于图10所示的其中存储有程序、与设备相分离地分发以向用户提供程序的可拆卸介质911。可拆卸介质911的例子包含磁盘(包含软盘(注册商标))、光盘(包含光盘只读存储器(CD-ROM)和数字通用盘(DVD))、磁光盘(包含迷你盘(MD)(注册商标))和半导体存储器。或者,存储介质可以是ROM 902、存储部分908中包含的硬盘等等,其中存有程序,并且与包含它们的设备一起被分发给用户。It should be understood by those skilled in the art that such a storage medium is not limited to the removable medium 911 shown in FIG. 10 in which the program is stored and distributed separately from the device to provide the user with the program. Examples of the removable medium 911 include magnetic disks (including floppy disks (registered trademark)), optical disks (including compact disk read only memory (CD-ROM) and digital versatile disks (DVD)), magneto-optical disks (including minidiscs (MD) (registered trademark) )) and semiconductor memory. Alternatively, the storage medium may be the ROM 902, a hard disk included in the storage section 908, or the like, in which programs are stored and distributed to users together with the apparatuses including them.

本发明还提出一种存储有机器可读取的指令代码的程序产品。所述指令代码由机器读取并执行时,可执行上述根据本发明的实施例的方法。The present invention also provides a program product storing machine-readable instruction codes. When the instruction code is read and executed by a machine, the above-described method according to the embodiment of the present invention can be executed.

相应地,用于承载上述存储有机器可读取的指令代码的程序产品的存储介质也包括在本发明的公开中。所述存储介质包括但不限于软盘、光盘、磁光盘、存储卡、存储棒等等。Correspondingly, a storage medium for carrying the above-mentioned program product storing the machine-readable instruction code is also included in the disclosure of the present invention. The storage medium includes, but is not limited to, a floppy disk, an optical disk, a magneto-optical disk, a memory card, a memory stick, and the like.

在上面对本发明具体实施例的描述中,针对一种实施方式描述和/或示出的特征可以以相同或类似的方式在一个或更多个其它实施方式中使用,与其它实施方式中的特征相组合,或替代其它实施方式中的特征。In the above description of specific embodiments of the invention, features described and/or illustrated for one embodiment may be used in the same or similar manner in one or more other embodiments as the features of the other embodiments. In combination with, or in place of, features in other embodiments.

应该强调,术语“包括/包含”在本文使用时指特征、要素、步骤或组件的存在,但并不排除一个或更多个其它特征、要素、步骤或组件的存在或附加。It should be emphasized that the term "comprising/comprising" when used herein refers to the presence of a feature, element, step or component, but does not exclude the presence or addition of one or more other features, elements, steps or components.

此外,本发明的方法不限于按照说明书中描述的时间顺序来执行,也可以按照其他的时间顺序地、并行地或独立地执行。因此,本说明书中描述的方法的执行顺序不对本发明的技术范围构成限制。In addition, the method of the present invention is not limited to be executed according to the chronological sequence described in the specification, and can also be executed according to other chronological sequence, in parallel or independently. Therefore, the execution order of the methods described in this specification does not limit the technical scope of the present invention.

尽管上面已经通过对本发明的具体实施例的描述对本发明进行了披露,但是,应该理解,上述的所有实施例和示例均是示例性的,而非限制性的。本领域的技术人员可在所附权利要求的精神和范围内设计对本发明的各种修改、改进或者等同物。这些修改、改进或者等同物也应当被认为包括在本发明的保护范围内。While the present invention has been disclosed above by way of descriptions of specific embodiments thereof, it should be understood that all of the above-described embodiments and examples are illustrative and not restrictive. Various modifications, improvements or equivalents of the present invention may be devised by those skilled in the art within the spirit and scope of the appended claims. These modifications, improvements or equivalents should also be considered to be included within the protection scope of the present invention.

附记Postscript

1.一种确定输入图像中的矩形目标区域的方法,包括:1. A method of determining a rectangular target area in an input image, comprising:

获得输入图像中的水平类线段和竖直类线段;Obtain the horizontal and vertical line segments in the input image;

生成候选线段组合,每个候选线段组合中包括两个水平类线段和两个竖直类线段,每个候选线段组合中的线段或其延长线相交得到四个交点;Generate candidate line segment combinations, each candidate line segment combination includes two horizontal class line segments and two vertical class line segments, and the line segments or their extension lines in each candidate line segment combination intersect to obtain four intersection points;

根据每个候选线段组合对应的四个交点、预定参考宽高比、输入图像的相机内参数,计算每个候选线段组合对应的透视校正后矩形区域的宽高比;Calculate the aspect ratio of the perspective-corrected rectangular area corresponding to each candidate line segment combination according to the four intersection points corresponding to each candidate line segment combination, the predetermined reference aspect ratio, and the in-camera parameters of the input image;

基于每个候选线段组合对应的宽高比与预定参考宽高比的比较,选择一个候选线段组合;以及selecting a candidate line segment combination based on a comparison of the aspect ratio corresponding to each candidate line segment combination with a predetermined reference aspect ratio; and

将所选择的候选线段组合中的四个线段或其延长线包围的区域确定为矩形目标区域。The area enclosed by the four line segments or their extension lines in the selected candidate line segment combination is determined as a rectangular target area.

2.如附记1所述的方法,其中根据每个候选线段组合对应的四个交点、预定参考宽高比、输入图像的相机内参数,计算每个候选线段组合对应的透视校正后矩形区域的宽高比包括:2. The method as described in appendix 1, wherein the perspective-corrected rectangular area corresponding to each candidate line segment combination is calculated according to the four intersection points corresponding to each candidate line segment combination, the predetermined reference aspect ratio, and the in-camera parameters of the input image. The aspect ratios include:

根据每个候选线段组合对应的四个交点和预定参考宽高比,得到对应的用于透视校正的单应性矩阵;According to the four intersection points corresponding to each candidate line segment combination and a predetermined reference aspect ratio, a corresponding homography matrix for perspective correction is obtained;

根据每个候选线段组合对应的单应性矩阵和输入图像的相机内参数,基于预定关系,计算每个候选线段组合对应的透视校正后矩形区域的宽高比。According to the homography matrix corresponding to each candidate line segment combination and the in-camera parameters of the input image, and based on a predetermined relationship, the aspect ratio of the perspective-corrected rectangular region corresponding to each candidate line segment combination is calculated.

3.如附记2所述的方法,其中,预定关系基于透视校正前四个点的世界坐标与透视校正后四个点在射影空间的射影坐标的对应关系、相机的外参矩阵的特性来构建。3. The method as described in appendix 2, wherein the predetermined relationship is based on the correspondence between the world coordinates of the four points before the perspective correction and the projective coordinates of the four points after the perspective correction in the projective space, and the characteristics of the camera's external parameter matrix. Construct.

4.如附记1所述的方法,其中,获得输入图像中的水平类线段和竖直类线段包括:4. The method according to appendix 1, wherein obtaining the horizontal line segment and the vertical line segment in the input image comprises:

获取输入图像中的线段;以及get the line segments in the input image; and

将所获取的线段分类为水平类线段和竖直类线段。The acquired line segments are classified into horizontal line segments and vertical line segments.

5.如附记4所述的方法,获得输入图像中的水平类线段和竖直类线段还包括:5. The method described in Supplementary Note 4, obtaining the horizontal line segment and the vertical line segment in the input image further comprises:

根据预定规则,分别合并水平类线段和/或竖直类线段中的至少部分线段。According to a predetermined rule, at least some of the horizontal line segments and/or the vertical line segments are merged respectively.

6.如附记4所述的方法,获取输入图像中的线段包括:6. The method described in Supplementary Note 4, obtaining the line segment in the input image comprises:

检测输入图像中的边缘;以及detect edges in the input image; and

从边缘中检测线段。Detect line segments from edges.

7.如附记6所述的方法,其中,7. The method of appendix 6, wherein,

基于梯度,检测输入图像中的边缘;以及based on gradients, detect edges in the input image; and

利用霍夫变换,从边缘中检测线段。Line segments are detected from edges using the Hough transform.

8.如附记1所述的方法,其中,基于每个候选线段组合对应的宽高比与预定参考宽高比的比较,选择一个候选线段组合包括:8. The method of appendix 1, wherein, based on the comparison of the aspect ratio corresponding to each candidate line segment combination with a predetermined reference aspect ratio, selecting a candidate line segment combination comprises:

选择其宽高比与预定参考宽高比之差最小的候选线段组合。The candidate line segment combination whose aspect ratio is the smallest difference from the predetermined reference aspect ratio is selected.

9.一种确定输入图像中的矩形目标区域的设备,包括:9. A device for determining a rectangular target area in an input image, comprising:

线段获得装置,被配置为:获得输入图像中的水平类线段和竖直类线段;a line segment obtaining device, configured to: obtain horizontal line segments and vertical line segments in the input image;

候选线段组合生成装置,被配置为:生成候选线段组合,每个候选线段组合中包括两个水平类线段和两个竖直类线段,每个候选线段组合中的线段或其延长线相交得到四个交点;The device for generating a candidate line segment combination is configured to: generate a candidate line segment combination, each candidate line segment combination includes two horizontal class line segments and two vertical class line segments, and the line segments or their extension lines in each candidate line segment combination intersect to obtain four line segments. a point of intersection;

宽高比计算装置,被配置为:根据每个候选线段组合对应的四个交点、预定参考宽高比、输入图像的相机内参数,计算每个候选线段组合对应的透视校正后矩形区域的宽高比;The aspect ratio calculation device is configured to: calculate the width of the perspective-corrected rectangular region corresponding to each candidate line segment combination according to the four intersection points corresponding to each candidate line segment combination, the predetermined reference aspect ratio, and the in-camera parameters of the input image high ratio;

选择装置,被配置为:基于每个候选线段组合对应的宽高比与预定参考宽高比的比较,选择一个候选线段组合;以及selecting means configured to: select a candidate line segment combination based on a comparison of the aspect ratio corresponding to each candidate line segment combination with a predetermined reference aspect ratio; and

矩形区域确定装置,被配置为:将所选择的候选线段组合中的四个线段或其延长线包围的区域确定为矩形目标区域。The rectangular area determination device is configured to determine the area surrounded by four line segments or their extension lines in the selected candidate line segment combination as a rectangular target area.

10.如附记9所述的设备,所述宽高比计算装置包括:10. The device according to appendix 9, wherein the aspect ratio calculating means comprises:

单应性矩阵获得单元,被配置为:根据每个候选线段组合对应的四个交点和预定参考宽高比,得到对应的用于透视校正的单应性矩阵;a homography matrix obtaining unit, configured to: obtain a corresponding homography matrix for perspective correction according to the four intersection points corresponding to each candidate line segment combination and a predetermined reference aspect ratio;

宽高比计算单元,被配置为:根据每个候选线段组合对应的单应性矩阵和输入图像的相机内参数,基于预定关系,计算每个候选线段组合对应的透视校正后矩形区域的宽高比。The aspect ratio calculation unit is configured to: according to the homography matrix corresponding to each candidate line segment combination and the in-camera parameters of the input image, and based on a predetermined relationship, calculate the width and height of the perspective-corrected rectangular region corresponding to each candidate line segment combination Compare.

11.如附记10所述的设备,其中,预定关系基于透视校正前四个点的世界坐标与透视校正后四个点在射影空间的射影坐标的对应关系、相机的外参矩阵的特性来构建。11. The device as described in appendix 10, wherein the predetermined relationship is based on the correspondence between the world coordinates of the four points before the perspective correction and the projective coordinates of the four points after the perspective correction in the projective space, and the characteristics of the camera's external parameter matrix. Construct.

12.如附记9所述的设备,其中,所述线段获得装置包括:12. The apparatus according to appendix 9, wherein the line segment obtaining means comprises:

获取单元,被配置为:获取输入图像中的线段;以及an acquisition unit configured to: acquire line segments in the input image; and

分类单元,被配置为:将所获取的线段分类为水平类线段和竖直类线段。The classification unit is configured to: classify the acquired line segments into horizontal line segments and vertical line segments.

13.如附记12所述的设备,其中,所述线段获得装置还包括:13. The apparatus according to appendix 12, wherein the line segment obtaining device further comprises:

合并单元,被配置为:根据预定规则,分别合并水平类线段和/或竖直类线段中的至少部分线段。The merging unit is configured to merge at least some of the horizontal line segments and/or the vertical line segments respectively according to a predetermined rule.

14.如附记12所述的设备,其中,所述获取单元被进一步配置为:14. The device according to supplementary note 12, wherein the acquiring unit is further configured to:

检测输入图像中的边缘;以及detect edges in the input image; and

从边缘中检测线段。Detect line segments from edges.

15.如附记14所述的设备,其中,所述获取单元被进一步配置为:15. The device according to supplementary note 14, wherein the acquiring unit is further configured to:

基于梯度,检测输入图像中的边缘;以及based on gradients, detect edges in the input image; and

利用霍夫变换,从边缘中检测线段。Line segments are detected from edges using the Hough transform.

16.如附记9所述的设备,其中,所述选择装置被进一步配置为:16. The apparatus of appendix 9, wherein the selection means is further configured to:

选择其宽高比与预定参考宽高比之差最小的候选线段组合。The candidate line segment combination whose aspect ratio is the smallest difference from the predetermined reference aspect ratio is selected.

17.一种信息处理设备,包括:17. An information processing device, comprising:

控制器,被配置为:Controller, configured as:

获得输入图像中的水平类线段和竖直类线段;Obtain the horizontal and vertical line segments in the input image;

生成候选线段组合,每个候选线段组合中包括两个水平类线段和两个竖直类线段,每个候选线段组合中的线段或其延长线相交得到四个交点;Generate candidate line segment combinations, each candidate line segment combination includes two horizontal class line segments and two vertical class line segments, and the line segments or their extension lines in each candidate line segment combination intersect to obtain four intersection points;

根据每个候选线段组合对应的四个交点、预定参考宽高比、输入图像的相机内参数,计算每个候选线段组合对应的透视校正后矩形区域的宽高比;Calculate the aspect ratio of the perspective-corrected rectangular area corresponding to each candidate line segment combination according to the four intersection points corresponding to each candidate line segment combination, the predetermined reference aspect ratio, and the in-camera parameters of the input image;

基于每个候选线段组合对应的宽高比与预定参考宽高比的比较,选择一个候选线段组合;以及selecting a candidate line segment combination based on a comparison of the aspect ratio corresponding to each candidate line segment combination with a predetermined reference aspect ratio; and

将所选择的候选线段组合中的四个线段或其延长线包围的区域确定为矩形目标区域。The area enclosed by the four line segments or their extension lines in the selected candidate line segment combination is determined as a rectangular target area.

Claims (8)

1.一种确定输入图像中的矩形目标区域的方法,包括:1. A method of determining a rectangular target area in an input image, comprising: 获得输入图像中的水平类线段和竖直类线段,其中,所述水平类线段是与水平方向的斜率之差在第一预定范围内的线段,并且所述竖直类线段是与竖直方向的斜率之差在第二预定范围内的线段;Obtaining a horizontal-like line segment and a vertical-like line segment in the input image, wherein the horizontal-like line segment is a line segment with a slope difference from the horizontal direction within a first predetermined range, and the vertical-like line segment is a line segment related to the vertical direction The difference between the slopes of the line segment within the second predetermined range; 生成候选线段组合,每个候选线段组合中包括两个水平类线段和两个竖直类线段,每个候选线段组合中的线段或其延长线相交得到四个交点;Generate candidate line segment combinations, each candidate line segment combination includes two horizontal class line segments and two vertical class line segments, and the line segments or their extension lines in each candidate line segment combination intersect to obtain four intersection points; 根据每个候选线段组合对应的四个交点和预定参考宽高比,得到对应的用于透视校正的单应性矩阵;According to the four intersection points corresponding to each candidate line segment combination and a predetermined reference aspect ratio, a corresponding homography matrix for perspective correction is obtained; 根据每个候选线段组合对应的单应性矩阵和输入图像的相机内参数,基于预定关系,计算每个候选线段组合对应的透视校正后矩形区域的宽高比,其中,所述预定关系基于透视校正前四个点的世界坐标与透视校正后四个点在射影空间的射影坐标的对应关系、相机的外参矩阵的特性来构建;According to the homography matrix corresponding to each candidate line segment combination and the in-camera parameters of the input image, based on a predetermined relationship, the aspect ratio of the perspective-corrected rectangular region corresponding to each candidate line segment combination is calculated, wherein the predetermined relationship is based on the perspective It is constructed by the correspondence between the world coordinates of the first four points and the projective coordinates of the four points in the projective space after perspective correction, and the characteristics of the camera's external parameter matrix; 基于每个候选线段组合对应的宽高比与预定参考宽高比的比较,选择一个候选线段组合;以及selecting a candidate line segment combination based on a comparison of the aspect ratio corresponding to each candidate line segment combination with a predetermined reference aspect ratio; and 将所选择的候选线段组合中的四个线段或其延长线包围的区域确定为矩形目标区域。The area enclosed by the four line segments or their extension lines in the selected candidate line segment combination is determined as a rectangular target area. 2.如权利要求1所述的方法,其中,获得输入图像中的水平类线段和竖直类线段包括:2. The method of claim 1, wherein obtaining horizontal line segments and vertical line segments in the input image comprises: 获取输入图像中的线段;以及get the line segments in the input image; and 将所获取的线段分类为水平类线段和竖直类线段。The acquired line segments are classified into horizontal line segments and vertical line segments. 3.如权利要求2所述的方法,获得输入图像中的水平类线段和竖直类线段还包括:3. The method of claim 2 , obtaining horizontal line segments and vertical line segments in the input image further comprising: 根据预定规则,分别合并水平类线段和/或竖直类线段中的至少部分线段。According to a predetermined rule, at least some of the horizontal line segments and/or the vertical line segments are merged respectively. 4.如权利要求2所述的方法,获取输入图像中的线段包括:4. The method of claim 2, obtaining line segments in the input image comprising: 检测输入图像中的边缘;以及detect edges in the input image; and 从边缘中检测线段。Detect line segments from edges. 5.如权利要求4所述的方法,其中,5. The method of claim 4, wherein, 基于梯度,检测输入图像中的边缘;以及based on gradients, detect edges in the input image; and 利用霍夫变换,从边缘中检测线段。Line segments are detected from edges using the Hough transform. 6.如权利要求1所述的方法,其中,基于每个候选线段组合对应的宽高比与预定参考宽高比的比较,选择一个候选线段组合包括:6. The method of claim 1, wherein, based on the comparison of the aspect ratio corresponding to each candidate line segment combination with a predetermined reference aspect ratio, selecting a candidate line segment combination comprises: 选择其宽高比与预定参考宽高比之差最小的候选线段组合。The candidate line segment combination whose aspect ratio is the smallest difference from the predetermined reference aspect ratio is selected. 7.一种确定输入图像中的矩形目标区域的设备,包括:7. A device for determining a rectangular target area in an input image, comprising: 线段获得装置,被配置为:获得输入图像中的水平类线段和竖直类线段,其中,所述水平类线段是与水平方向的斜率之差在第一预定范围内的线段,并且所述竖直类线段是与竖直方向的斜率之差在第二预定范围内的线段;A line segment obtaining device is configured to obtain a horizontal line segment and a vertical line segment in the input image, wherein the horizontal line segment is a line segment with a slope difference from the horizontal direction within a first predetermined range, and the vertical line segment The straight line segment is a line segment whose difference from the slope of the vertical direction is within a second predetermined range; 候选线段组合生成装置,被配置为:生成候选线段组合,每个候选线段组合中包括两个水平类线段和两个竖直类线段,每个候选线段组合中的线段或其延长线相交得到四个交点;The device for generating a candidate line segment combination is configured to: generate a candidate line segment combination, each candidate line segment combination includes two horizontal class line segments and two vertical class line segments, and the line segments or their extension lines in each candidate line segment combination intersect to obtain four line segments. a point of intersection; 宽高比计算装置,被配置为:根据每个候选线段组合对应的四个交点和预定参考宽高比,得到对应的用于透视校正的单应性矩阵,并且根据每个候选线段组合对应的单应性矩阵和输入图像的相机内参数,基于预定关系,计算每个候选线段组合对应的透视校正后矩形区域的宽高比,其中,所述预定关系基于透视校正前四个点的世界坐标与透视校正后四个点在射影空间的射影坐标的对应关系、相机的外参矩阵的特性来构建;The aspect ratio calculation device is configured to: obtain a corresponding homography matrix for perspective correction according to the four intersection points corresponding to each candidate line segment combination and a predetermined reference aspect ratio, and according to each candidate line segment combination corresponding The homography matrix and the in-camera parameters of the input image, based on a predetermined relationship, calculate the aspect ratio of the perspective corrected rectangular area corresponding to each candidate line segment combination, wherein the predetermined relationship is based on the world coordinates of the first four points before perspective correction It is constructed by the corresponding relationship with the projective coordinates of the four points in the projective space after perspective correction and the characteristics of the camera's external parameter matrix; 选择装置,被配置为:基于每个候选线段组合对应的宽高比与预定参考宽高比的比较,选择一个候选线段组合;以及selecting means configured to: select a candidate line segment combination based on a comparison of the aspect ratio corresponding to each candidate line segment combination with a predetermined reference aspect ratio; and 矩形区域确定装置,被配置为:将所选择的候选线段组合中的四个线段或其延长线包围的区域确定为矩形目标区域。The rectangular area determination device is configured to determine the area surrounded by four line segments or their extension lines in the selected candidate line segment combination as a rectangular target area. 8.一种信息处理设备,包括:8. An information processing device, comprising: 控制器,被配置为:Controller, configured as: 获得输入图像中的水平类线段和竖直类线段,其中,所述水平类线段是与水平方向的斜率之差在第一预定范围内的线段,并且所述竖直类线段是与竖直方向的斜率之差在第二预定范围内的线段;Obtaining a horizontal-like line segment and a vertical-like line segment in the input image, wherein the horizontal-like line segment is a line segment with a slope difference from the horizontal direction within a first predetermined range, and the vertical-like line segment is a line segment related to the vertical direction The difference between the slopes of the line segment within the second predetermined range; 生成候选线段组合,每个候选线段组合中包括两个水平类线段和两个竖直类线段,每个候选线段组合中的线段或其延长线相交得到四个交点;Generate candidate line segment combinations, each candidate line segment combination includes two horizontal class line segments and two vertical class line segments, and the line segments or their extension lines in each candidate line segment combination intersect to obtain four intersection points; 根据每个候选线段组合对应的四个交点和预定参考宽高比,得到对应的用于透视校正的单应性矩阵;According to the four intersection points corresponding to each candidate line segment combination and a predetermined reference aspect ratio, a corresponding homography matrix for perspective correction is obtained; 根据每个候选线段组合对应的单应性矩阵和输入图像的相机内参数,基于预定关系,计算每个候选线段组合对应的透视校正后矩形区域的宽高比,其中,所述预定关系基于透视校正前四个点的世界坐标与透视校正后四个点在射影空间的射影坐标的对应关系、相机的外参矩阵的特性来构建;According to the homography matrix corresponding to each candidate line segment combination and the in-camera parameters of the input image, based on a predetermined relationship, the aspect ratio of the perspective-corrected rectangular region corresponding to each candidate line segment combination is calculated, wherein the predetermined relationship is based on the perspective It is constructed by the correspondence between the world coordinates of the first four points and the projective coordinates of the four points in the projective space after perspective correction, and the characteristics of the camera's external parameter matrix; 基于每个候选线段组合对应的宽高比与预定参考宽高比的比较,选择一个候选线段组合;以及selecting a candidate line segment combination based on a comparison of the aspect ratio corresponding to each candidate line segment combination with a predetermined reference aspect ratio; and 将所选择的候选线段组合中的四个线段或其延长线包围的区域确定为矩形目标区域。The area enclosed by the four line segments or their extension lines in the selected candidate line segment combination is determined as a rectangular target area.
CN201610307727.3A 2016-05-11 2016-05-11 Method and apparatus for determining a rectangular target area in an input image Expired - Fee Related CN107368829B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610307727.3A CN107368829B (en) 2016-05-11 2016-05-11 Method and apparatus for determining a rectangular target area in an input image

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610307727.3A CN107368829B (en) 2016-05-11 2016-05-11 Method and apparatus for determining a rectangular target area in an input image

Publications (2)

Publication Number Publication Date
CN107368829A CN107368829A (en) 2017-11-21
CN107368829B true CN107368829B (en) 2020-08-14

Family

ID=60304464

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610307727.3A Expired - Fee Related CN107368829B (en) 2016-05-11 2016-05-11 Method and apparatus for determining a rectangular target area in an input image

Country Status (1)

Country Link
CN (1) CN107368829B (en)

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108805823B (en) * 2018-04-12 2021-03-12 上海扩博智能技术有限公司 Commodity image correction method, system, equipment and storage medium
CN108734162B (en) * 2018-04-12 2021-02-09 上海扩博智能技术有限公司 Method, system, equipment and storage medium for identifying target in commodity image
CN108564557B (en) * 2018-05-31 2020-08-25 京东方科技集团股份有限公司 Image correction method and device
CN109409366B (en) * 2018-10-30 2022-04-05 四川长虹电器股份有限公司 Distorted image correction method and device based on angular point detection
TWI731484B (en) * 2019-11-26 2021-06-21 台灣基督長老教會馬偕醫療財團法人馬偕紀念醫院 Method and system for building medication library and managing medication via the image of its blister package
CN110930300B (en) * 2019-12-09 2023-09-29 上海扩博智能技术有限公司 Image correction method, system, device and storage medium
CN115460456B (en) * 2021-06-08 2025-02-11 微软技术许可有限责任公司 Target area extraction for digital content addition
CN115760620B (en) * 2022-11-18 2023-10-20 荣耀终端有限公司 Document correction method and device and electronic equipment

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP4067957B2 (en) * 2002-12-20 2008-03-26 富士通株式会社 Boundary detection method, program, and image processing apparatus
JP4006601B2 (en) * 2004-03-29 2007-11-14 セイコーエプソン株式会社 Image processing system, projector, program, information storage medium, and image processing method
JP2008059081A (en) * 2006-08-29 2008-03-13 Sony Corp Image processing apparatus, image processing method and computer program
US8897538B1 (en) * 2013-08-26 2014-11-25 Vertifi Software, LLC Document image capturing and processing

Also Published As

Publication number Publication date
CN107368829A (en) 2017-11-21

Similar Documents

Publication Publication Date Title
CN107368829B (en) Method and apparatus for determining a rectangular target area in an input image
JP6934026B2 (en) Systems and methods for detecting lines in a vision system
US10187546B2 (en) Method and device for correcting document image captured by image pick-up device
US8811751B1 (en) Method and system for correcting projective distortions with elimination steps on multiple levels
US8897600B1 (en) Method and system for determining vanishing point candidates for projective correction
TWI485650B (en) Method and arrangement for multi-camera calibration
US8897539B2 (en) Using images to create measurements of structures through the videogrammetric process
KR102649038B1 (en) System and method for finding lines in an image with a vision system
US20150262346A1 (en) Image processing apparatus, image processing method, and image processing program
US11657644B2 (en) Automatic ruler detection
US8913836B1 (en) Method and system for correcting projective distortions using eigenpoints
JP2016162420A (en) Attention area detection device, attention area detection method and program
EP3093822A1 (en) Displaying a target object imaged in a moving picture
CN103366165B (en) Image processing apparatus, image processing method and equipment
JP5656768B2 (en) Image feature extraction device and program thereof
JP2022009474A (en) Systems and methods for detecting lines in a vision system
US10586099B2 (en) Information processing apparatus for tracking processing
CN102831578B (en) Image processing method and image processing device
JP6542230B2 (en) Method and system for correcting projected distortion
GB2532537A (en) Aligning multi-view scans
WO2018152710A1 (en) Image correction method and device
JP5636966B2 (en) Error detection apparatus and error detection program
US20250022169A1 (en) Image processing apparatus, image processing method, and storage medium
WO2023239717A1 (en) Apparatus and method for whiteboard rectification
Eum et al. Planar content selection in images and videos using frontalness

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20200814

CF01 Termination of patent right due to non-payment of annual fee