CN110502948B - Restoration method and device for folding two-dimensional code image and code scanning equipment - Google Patents
Restoration method and device for folding two-dimensional code image and code scanning equipment Download PDFInfo
- Publication number
- CN110502948B CN110502948B CN201910603979.4A CN201910603979A CN110502948B CN 110502948 B CN110502948 B CN 110502948B CN 201910603979 A CN201910603979 A CN 201910603979A CN 110502948 B CN110502948 B CN 110502948B
- Authority
- CN
- China
- Prior art keywords
- image
- dimensional code
- code image
- folded
- restoring
- 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.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 49
- 238000001514 detection method Methods 0.000 claims abstract description 57
- 238000012937 correction Methods 0.000 claims abstract description 28
- 238000007781 pre-processing Methods 0.000 claims abstract description 22
- 238000012545 processing Methods 0.000 claims description 59
- 230000000877 morphologic effect Effects 0.000 claims description 24
- 238000003708 edge detection Methods 0.000 claims description 16
- 238000006243 chemical reaction Methods 0.000 claims description 14
- 238000005520 cutting process Methods 0.000 claims description 10
- 230000008569 process Effects 0.000 claims description 8
- 238000010586 diagram Methods 0.000 description 19
- 230000009466 transformation Effects 0.000 description 8
- 238000004806 packaging method and process Methods 0.000 description 7
- 239000011159 matrix material Substances 0.000 description 4
- 230000009467 reduction Effects 0.000 description 2
- 238000000844 transformation Methods 0.000 description 2
- 230000003044 adaptive effect Effects 0.000 description 1
- 230000008859 change Effects 0.000 description 1
- 238000005260 corrosion Methods 0.000 description 1
- 230000007797 corrosion Effects 0.000 description 1
- 230000010339 dilation Effects 0.000 description 1
- 238000000605 extraction Methods 0.000 description 1
- 230000001788 irregular Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000000717 retained effect Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06K—GRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
- G06K7/00—Methods or arrangements for sensing record carriers, e.g. for reading patterns
- G06K7/10—Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation
- G06K7/14—Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation using light without selection of wavelength, e.g. sensing reflected white light
- G06K7/1404—Methods for optical code recognition
- G06K7/146—Methods for optical code recognition the method including quality enhancement steps
Landscapes
- Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- Toxicology (AREA)
- Health & Medical Sciences (AREA)
- Electromagnetism (AREA)
- General Health & Medical Sciences (AREA)
- Quality & Reliability (AREA)
- Artificial Intelligence (AREA)
- Computer Vision & Pattern Recognition (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Image Processing (AREA)
- Image Analysis (AREA)
Abstract
本发明揭露一种折叠二维码图像的还原方法、还原装置与扫码设备。还原方法包括:图像预处理步骤,对一折叠二维码图像进行预处理,以获取包含有二维码图像信息的预处理后图像;角点检测步骤,对该预处理后图像进行角点检测,以获取该折叠二维码图像的多个校正点,其中所述多个校正点至少包含该折叠二维码图像的顶部角点及位于该折叠二维码图像的折叠线上的折叠角点;图像还原步骤,利用所述角点及所述顶部角点,对该折叠二维码图像进行透视还原,以获取该折叠二维码图像在两个交汇平面中的第一部分图像和第二部分图像;图像拼接步骤,对该第一部分图像和该第二部分图像进行拼接,以获取一平面二维码图像。本发明可实现从折叠二维码图像中提取信息。
The invention discloses a method for restoring a folded two-dimensional code image, a restoring device and a code scanning device. The restoration method includes: an image preprocessing step, preprocessing a folded two-dimensional code image to obtain a preprocessed image containing two-dimensional code image information; a corner detection step, performing corner detection on the preprocessed image , to obtain a plurality of correction points of the folded two-dimensional code image, wherein the plurality of correction points at least include the top corner point of the folded two-dimensional code image and the folding corner point located on the folding line of the folded two-dimensional code image ; Image restoration step, using the corner point and the top corner point to perform perspective restoration on the folded two-dimensional code image, so as to obtain the first part image and the second part of the folded two-dimensional code image in two intersection planes Image; an image splicing step, splicing the first part of the image and the second part of the image to obtain a plane two-dimensional code image. The invention can realize extracting information from folded two-dimensional code images.
Description
技术领域technical field
本发明是与二维码图像应用有关,特别是关于折叠二维码图像的还原方法、还原装置与具有相关还原装置的扫码设备。The present invention is related to the application of two-dimensional code images, in particular to a method for restoring a folded two-dimensional code image, a restoring device and a code scanning device with the related restoring device.
背景技术Background technique
图像二维码应用,比如QR Code,已经在各个领域被广泛使用。其中用于承载信息的二维码的图像通常为正方形且常在平面上显示(例如黏贴在商品包装盒上的标签)。二维码图像在被相机摄取后,由于相机的镜头和传感器通常不会与平面二维码平行,且摄取角度在可以还原并提取二维码图像承载信息的前提下可以为任意角度,对摄取的二维码图像通常会造成不同程度的透视畸变。Image QR code applications, such as QR Code, have been widely used in various fields. The image of the two-dimensional code used to carry information is usually square and often displayed on a plane (such as a label pasted on a commodity packaging box). After the two-dimensional code image is captured by the camera, the lens and sensor of the camera are usually not parallel to the plane two-dimensional code, and the capturing angle can be any angle under the premise that the information carried by the two-dimensional code image can be restored and extracted. QR code images usually cause different degrees of perspective distortion.
透视畸变会使摄取的二维码图像与原始的二维码图像在形状、大小、位置上有所不同,而在对其进行透视还原前,摄取的二维码图像所承载的信息则无法被提取,因此透视还原是图像二维码应用中必要的一部,其实现的方法也被大量学习。其中最常用的为利用在二维码图像的四个角点添加寻像图像作为位置校正点,在通过其他图像处理技术提取到摄取到的四个角点后,可以利用其中摄取到的角点的坐标与相对应的原始的坐标来计算摄取的图像经历的透视畸变从而进行还原,比如被广泛使用的ZXing开源条形码软件库使用的校正点便是二维码本身的寻像图像。除了利用寻像图像作为校正点,也可以利用二维码图像本身的结构来矫正透视畸变的工作,比如在中国专利申请CN101908144A中,通过提取所摄取到的二维码图像中模块的位置来获取多个可用来计算透视畸变参数的校正点。Perspective distortion will cause the ingested QR code image to be different from the original QR code image in shape, size, and position, and the information carried by the ingested QR code image cannot be captured before perspective restoration. Extraction, so perspective restoration is a necessary part in the application of image QR codes, and the method of its realization has also been studied a lot. The most commonly used method is to use the four corner points of the two-dimensional code image to add the finder image as the position correction point. After the four corner points are extracted by other image processing techniques, the captured corner points can be used The coordinates and the corresponding original coordinates are used to calculate the perspective distortion experienced by the captured image and restore it. For example, the correction point used by the widely used ZXing open source barcode software library is the image-finding image of the QR code itself. In addition to using the image-finding image as a correction point, the structure of the two-dimensional code image itself can also be used to correct perspective distortion. For example, in the Chinese patent application CN101908144A, the position of the module in the captured two-dimensional code image can be obtained Multiple correction points that can be used to calculate perspective distortion parameters.
在对平面二维码图像进行透视还原的基础上,目前也有在透视畸变基础上增强其在一定的非平面的情况下被摄取后的透视还原的工作,来处理当平面二维码被黏贴的表面有轻微的弯曲,或者二维码图片标签本身表面有除了透视畸变外其他不规则的形状变化的情况。比如中国专利申请CN201510432188即是使用匹配模板来利用多个寻像图像矫正透视畸变以及曲面矫正。Based on the perspective restoration of the plane QR code image, there is also a work on the perspective distortion to enhance the perspective restoration after it is ingested in a certain non-planar situation, to deal with when the plane QR code is pasted The surface of the label has a slight curvature, or the surface of the QR code image label itself has irregular shape changes other than perspective distortion. For example, Chinese patent application CN201510432188 uses a matching template to correct perspective distortion and surface correction by using multiple image-finding images.
然而,目前这些相关的二维码透视还原方法一般仅针对显示在平面上,以及存在一定弯曲和其他畸变的二维码图像进行还原,而未考虑二维码图像的折叠形变,例如在中间位置被折叠并且被黏贴在由两个存在一定角度的平面组成的商品包装上时造成的形变。此种折叠形变造成了原本的平面二维码图像变为在两个平面交汇处折叠的立体二维码(比如立方体的两个相邻的面)的情况,因此传统的二维码图像透视还原方法无法用于被从中间处折叠黏贴的二维码图像。所以此种类型的包装目前并无法将二维码图像安放在两个平面的交汇处。然而,此种类型的商品包装却较为常见,涵盖了从立方体形状的包装到所有存在两个交汇平面的包装。However, at present, these related two-dimensional code perspective restoration methods generally only restore the two-dimensional code image displayed on the plane, and have certain curvature and other distortions, without considering the folding deformation of the two-dimensional code image, such as in the middle position The deformation caused by being folded and glued to a product package consisting of two flat surfaces at an angle. This kind of folding deformation causes the original plane two-dimensional code image to become a three-dimensional two-dimensional code folded at the intersection of two planes (such as two adjacent faces of a cube), so the traditional two-dimensional code image perspective restoration The method cannot be used for QR code images that are folded and pasted from the middle. Therefore, this type of packaging currently cannot place the QR code image at the intersection of the two planes. However, this type of commodity packaging is more common, ranging from cube-shaped packaging to all packaging where two intersecting planes exist.
因此,迫切需要一种折叠二维码图像的还原方法,可以实现从折叠的二维码图像中提取信息。Therefore, there is an urgent need for a method for restoring a folded two-dimensional code image, which can extract information from the folded two-dimensional code image.
发明内容Contents of the invention
有鉴于此,本发明的一目的在于提供一种折叠二维码图像的还原方法及其装置与扫码设备,使从位于商品包装的平面交汇处黏贴的图像二维码并从中提取信息成为可能。In view of this, an object of the present invention is to provide a method for restoring a folded two-dimensional code image, its device, and a code scanning device, so that information can be extracted from the image two-dimensional code pasted at the plane intersection of the product package. possible.
为了实现上述目的,本发明提供一种折叠二维码图像的还原方法,其特点在于,包括:In order to achieve the above object, the present invention provides a method for restoring a folded two-dimensional code image, which is characterized in that it includes:
图像预处理步骤,对一折叠二维码图像进行预处理,以获取包含有二维码图像信息的预处理后图像;The image preprocessing step is to preprocess a folded two-dimensional code image to obtain a preprocessed image containing two-dimensional code image information;
角点检测步骤,对该预处理后图像进行角点检测,以获取该折叠二维码图像的多个校正点,其中所述多个校正点至少包含该折叠二维码图像的顶部角点及位于该折叠二维码图像的折叠线上的折叠角点;The corner point detection step is to perform corner point detection on the preprocessed image to obtain a plurality of correction points of the folded two-dimensional code image, wherein the plurality of correction points at least include the top corner point of the folded two-dimensional code image and A folding corner located on a folding line of the folding two-dimensional code image;
图像还原步骤,利用所述折叠角点及所述顶部角点,对该折叠二维码图像进行透视还原,以获取该折叠二维码图像在两个交汇平面中的第一部分图像和第二部分图像;The image restoration step is to use the folded corners and the top corners to perform perspective restoration on the folded two-dimensional code image, so as to obtain the first part image and the second part of the folded two-dimensional code image in two intersection planes image;
图像拼接步骤,对该第一部分图像和该第二部分图像进行拼接,以获取一平面二维码图像。The image splicing step is to splice the first part of the image and the second part of the image to obtain a plane two-dimensional code image.
在本发明的一实施方式中,该图像预处理步骤包括:In one embodiment of the present invention, the image preprocessing step includes:
对该折叠二维码图像进行形态处理,通过对该折叠二维码图像中的不同物体进行区分,提取其中的二维码图像信息,其中该二维码图像信息包含二维码图像的位置信息。Performing morphological processing on the folded two-dimensional code image, by distinguishing different objects in the folded two-dimensional code image, extracting the two-dimensional code image information, wherein the two-dimensional code image information includes the position information of the two-dimensional code image .
在本发明的一实施方式中,在对该折叠二维码图像进行形态处理之前,还包括:In one embodiment of the present invention, before performing morphological processing on the folded two-dimensional code image, it also includes:
对该折叠二维码图像进行灰度值转换处理,以得到一灰度值图像;performing grayscale conversion processing on the folded two-dimensional code image to obtain a grayscale image;
对该灰度值图像进行二值化处理,以得到一黑白二值图像。Binarize the gray value image to obtain a black and white binary image.
在本发明的一实施方式中,在对该折叠二维码图像进行形态处理时,包含:In one embodiment of the present invention, when performing morphological processing on the folded two-dimensional code image, it includes:
使用结构元素对该黑白二值图像进行闭运算,使该黑白二值图像中的二维码图像的边界变得连续;performing a closing operation on the black-and-white binary image by using structural elements, so that the boundaries of the two-dimensional code images in the black-and-white binary image become continuous;
对该黑白二值图像进行填充,以区分二维码图像与其他物体,并获取二维码图像在该黑白二值图像中的位置信息。The black and white binary image is filled to distinguish the two-dimensional code image from other objects, and the position information of the two-dimensional code image in the black and white binary image is obtained.
在本发明的一实施方式中,该角点检测步骤包括:In one embodiment of the present invention, the corner detection step includes:
使用填充后的该黑白二值图像作为标签图像,并对其进行边缘检测,以获取二维码图像的多个边缘,并得到一边缘标签图像;Use the filled black and white binary image as a label image, and perform edge detection on it to obtain multiple edges of the two-dimensional code image, and obtain an edge label image;
对该边缘标签图像进行线检测,以提取出该二维码图像的所述多个边缘的边缘信息;performing line detection on the edge label image to extract edge information of the multiple edges of the two-dimensional code image;
利用所述多个边缘的所述边缘信息进行角点检测,以获取该二维码图像的多个顶部角点和位于折叠线上的折叠角点。Corner detection is performed by using the edge information of the plurality of edges to obtain a plurality of top corners and folding corners on the folding line of the two-dimensional code image.
在本发明的一实施方式中,在该图像还原步骤中,所获取的还原后的该第一部分图像和该第二部分图像均为校正后长宽比设定为1的正方形图像。In an embodiment of the present invention, in the image restoration step, the obtained restored first partial image and the second partial image are square images with an aspect ratio set to 1 after correction.
在本发明的一实施方式中,该图像拼接步骤包括:In one embodiment of the present invention, the image stitching step includes:
通过模块数量估计方法,分别计算出该二维码图像在水平方向和垂直方向上的模块数量;Calculate the number of modules of the two-dimensional code image in the horizontal direction and the vertical direction respectively by the module number estimation method;
根据还原后的该二维码图像的该第一部分图像和该第二部分图像的宽度、以及所计算出的水平方向和垂直方向上的模块数量,将还原后的该二维码图像的该第一部分图像和该第二部分图像由正方形图像调整为其原始的长宽比,以得到修正后的第一部分图像和修正后的第二部分图像;According to the width of the first part image and the second part image of the restored two-dimensional code image, and the calculated number of modules in the horizontal direction and the vertical direction, the second part of the restored two-dimensional code image is The part of the image and the second part of the image are adjusted from the square image to their original aspect ratio to obtain the corrected first part of the image and the corrected second part of the image;
将该修正后的第一部分图像和该修正后的第二部分图像进行拼接,以得到该平面二维码图像。splicing the corrected first part image and the corrected second part image to obtain the planar two-dimensional code image.
在本发明的一实施方式中,该模块数量估计方法包括:In an embodiment of the present invention, the method for estimating the number of modules includes:
在该黑白二值图像中,通过在水平方向上所获取到的两个顶部角点来确定水平定位图形的扫描位置,并根据该水平定位图形的扫描结果来确定该二维码图像在水平方向上的模块数量;In the black-and-white binary image, the scanning position of the horizontal positioning figure is determined by the two top corner points obtained in the horizontal direction, and the horizontal position of the two-dimensional code image is determined according to the scanning result of the horizontal positioning figure. number of modules on
在该黑白二值图像中,通过在垂直方向上所获取到的顶部角点和折叠角点来确定垂直定位图形的扫描位置,并根据该垂直定位图形的扫描结果来确定该二维码图像在垂直方向上的模块数量。In the black-and-white binary image, the scanning position of the vertical positioning figure is determined by the top corner and folding corner obtained in the vertical direction, and the two-dimensional code image is determined according to the scanning result of the vertical positioning figure. The number of modules in the vertical direction.
在本发明的一实施方式中,当角点检测步骤检测失败或图像还原步骤失败时,还包括:In one embodiment of the present invention, when the detection of the corner point detection step fails or the image restoration step fails, it also includes:
通过增加结构元素的尺寸,重新进行闭运算步骤。The closing operation step is repeated by increasing the size of the structuring element.
在本发明的一实施方式中,在对该折叠二维码图像进行灰度值转换处理之前还包括:In one embodiment of the present invention, before performing gray value conversion processing on the folded two-dimensional code image, it also includes:
通过一图像摄取装置获得一摄取图像,并对该摄取图像进行切割处理,以获取具有一预定尺寸的该折叠二维码图像。A captured image is obtained by an image capturing device, and the captured image is cut to obtain the folded two-dimensional code image with a predetermined size.
为了实现上述目的,本发明另提供一种折叠二维码图像的还原装置,其特点在于,包括:In order to achieve the above object, the present invention further provides a device for restoring a folded two-dimensional code image, which is characterized in that it includes:
图像预处理单元,用于对一折叠二维码图像进行预处理,以获取包含有二维码图像信息的预处理后图像;An image preprocessing unit, configured to preprocess a folded two-dimensional code image to obtain a preprocessed image containing two-dimensional code image information;
角点检测单元,用于对该预处理后图像进行角点检测,以获取该折叠二维码图像的多个校正点,其中所述多个校正点至少包含该折叠二维码图像的顶部角点及位于该折叠二维码图像的折叠线上的折叠角点;A corner detection unit, configured to perform corner detection on the preprocessed image to obtain a plurality of correction points of the folded two-dimensional code image, wherein the plurality of correction points include at least the top corner of the folded two-dimensional code image point and the folded corners on the folded line of the folded two-dimensional code image;
图像还原单元,用于利用所述折叠角点及所述顶部角点,对该折叠二维码图像进行透视还原,以获取该折叠二维码图像在两个交汇平面中的第一部分图像和第二部分图像;An image restoring unit, configured to use the folded corners and the top corners to perform perspective restoration on the folded two-dimensional code image, so as to obtain the first part image and the second part of the folded two-dimensional code image in the two intersection planes two-part image;
图像拼接单元,用于对该第一部分图像和该第二部分图像进行拼接,以获取一平面二维码图像。The image splicing unit is used to splice the first partial image and the second partial image to obtain a plane two-dimensional code image.
在本发明的另一实施方式中,该图像预处理单元包括:In another embodiment of the present invention, the image preprocessing unit includes:
形态处理模块,用于对该折叠二维码图像进行形态处理,通过对该折叠二维码图像中的不同物体进行区分,提取其中的二维码图像信息,其中该二维码图像信息包含二维码图像的位置信息。The morphological processing module is used to perform morphological processing on the folded two-dimensional code image, and extract the two-dimensional code image information by distinguishing different objects in the folded two-dimensional code image, wherein the two-dimensional code image information contains two The location information of the QR code image.
在本发明的另一实施方式中,该图像预处理单元还包括:In another embodiment of the present invention, the image preprocessing unit also includes:
灰度值转换处理模块,用于对该折叠二维码图像进行灰度值转换处理,以得到一灰度值图像;以及A grayscale value conversion processing module, configured to perform grayscale value conversion processing on the folded two-dimensional code image to obtain a grayscale value image; and
二值化处理模块,用于对该灰度值图像进行二值化处理,以得到一黑白二值图像。The binarization processing module is used to perform binarization processing on the gray value image to obtain a black and white binary image.
在本发明的另一实施方式中,该形态处理模块在对该折叠二维码图像进行形态处理时,是使用结构元素对该黑白二值图像进行闭运算,使该黑白二值图像中的二维码图像的边界变得连续;以及是对该黑白二值图像进行填充,以区分二维码图像与其他物体,并获取二维码图像在该黑白二值图像中的位置信息。In another embodiment of the present invention, when the morphological processing module performs morphological processing on the folded two-dimensional code image, it uses structural elements to perform a closed operation on the black and white binary image, so that the binary in the black and white binary image The boundary of the two-dimensional code image becomes continuous; and the black and white binary image is filled to distinguish the two-dimensional code image from other objects, and the position information of the two-dimensional code image in the black and white binary image is obtained.
在本发明的另一实施方式中,该角点检测单元包括:In another embodiment of the present invention, the corner detection unit includes:
边缘检测模块,用于使用填充后的该黑白二值图像作为标签图像,并对其进行边缘检测,以获取二维码图像的多个边缘,并得到一边缘标签图像;An edge detection module, configured to use the filled black and white binary image as a label image, and perform edge detection on it to obtain multiple edges of the two-dimensional code image, and obtain an edge label image;
线检测模块,用于对该边缘标签图像进行线检测,以提取出该二维码图像的所述多个边缘的边缘信息;A line detection module, configured to perform line detection on the edge label image, to extract edge information of the plurality of edges of the two-dimensional code image;
角点检测模块,用于利用所述多个边缘的所述边缘信息进行角点检测,以获取该二维码图像的多个顶部角点和位于折叠线上的折叠角点。The corner detection module is configured to use the edge information of the plurality of edges to perform corner detection, so as to obtain a plurality of top corners of the two-dimensional code image and folding corners located on the folding line.
在本发明的另一实施方式中,该图像还原单元所获取的还原后的该第一部分图像和该第二部分图像均为校正后长宽比设定为1的正方形图像。In another embodiment of the present invention, the restored first partial image and the second partial image obtained by the image restoration unit are square images with an aspect ratio set to 1 after correction.
在本发明的另一实施方式中,该图像拼接单元包括:In another embodiment of the present invention, the image stitching unit includes:
模块数量估计模块,用于通过模块数量估计方法,分别计算出该二维码图像在水平方向和垂直方向上的模块数量;The module quantity estimation module is used to calculate the module quantity of the two-dimensional code image in the horizontal direction and the vertical direction respectively by the module quantity estimation method;
图像大小调整模块,用于根据还原后的该二维码图像的该第一部分图像和该第二部分图像的宽度、以及所计算出的水平方向和垂直方向上的模块数量,将还原后的该二维码图像的该第一部分图像和该第二部分图像由正方形图像调整为其原始的长宽比,以得到修正后的第一部分图像和修正后的第二部分图像;The image size adjustment module is used to adjust the restored two-dimensional code image according to the width of the first part of the image and the width of the second part of the image, and the calculated number of modules in the horizontal and vertical directions. The first part image and the second part image of the two-dimensional code image are adjusted to their original aspect ratio by the square image, so as to obtain the corrected first part image and the corrected second part image;
图像拼接模块,用于将该修正后的第一部分图像和该修正后的第二部分图像进行拼接,以得到该平面二维码图像。The image splicing module is used to splice the corrected first part of the image and the corrected second part of the image to obtain the planar two-dimensional code image.
在本发明的另一实施方式中,该模块数量估计模块是:In another embodiment of the present invention, the module number estimation module is:
在该黑白二值图像中,通过在水平方向上所获取到的两个顶部角点来确定水平定位图形的扫描位置,并根据该水平定位图形的扫描结果来确定该二维码图像在水平方向上的模块数量;In the black-and-white binary image, the scanning position of the horizontal positioning figure is determined by the two top corner points obtained in the horizontal direction, and the horizontal position of the two-dimensional code image is determined according to the scanning result of the horizontal positioning figure. number of modules on
在该黑白二值图像中,通过在垂直方向上所获取到的顶部角点和折叠角点来确定垂直定位图形的扫描位置,并根据该垂直定位图形的扫描结果来确定该二维码图像在垂直方向上的模块数量。In the black-and-white binary image, the scanning position of the vertical positioning figure is determined by the top corner and folding corner obtained in the vertical direction, and the two-dimensional code image is determined according to the scanning result of the vertical positioning figure. The number of modules in the vertical direction.
在本发明的另一实施方式中,当角点检测步骤检测失败或图像还原步骤失败时,该形态处理模块还通过增加结构元素的尺寸,重新进行闭运算步骤。In another embodiment of the present invention, when the corner detection step fails or the image restoration step fails, the morphological processing module further performs the closing operation step by increasing the size of the structural elements.
在本发明的另一实施方式中,该图像预处理单元还包括:In another embodiment of the present invention, the image preprocessing unit also includes:
切割模块,用于通过一图像摄取装置获得一摄取图像,并对该摄取图像进行切割处理,以获取具有一预定尺寸的该折叠二维码图像。The cutting module is used to obtain a captured image through an image capturing device, and perform cutting processing on the captured image to obtain the folded two-dimensional code image with a predetermined size.
为了实现上述目的,本发明又提供一种折叠二维码图像的扫码设备,其特点在于,包括:In order to achieve the above purpose, the present invention further provides a code scanning device for folding two-dimensional code images, which is characterized in that it includes:
一相机单元,用于摄取一折叠二维码图像;A camera unit for capturing a folded two-dimensional code image;
一如上所述的折叠二维码图像的还原装置,用于对该折叠二维码图像进行还原,以获取一平面二维码图像;A device for restoring the folded two-dimensional code image as described above, used to restore the folded two-dimensional code image to obtain a plane two-dimensional code image;
一二维码解码器,用于对经还原后所得到的该平面二维码图像进行解码。A two-dimensional code decoder is used to decode the restored flat two-dimensional code image.
本发明针对折叠形变这一类型的透视畸变,在不改变图像二维码本身结构的情况下,设计了相关的还原方法及其装置与相关的扫码设备,从而使从位于商品包装的平面交汇处黏贴的图像二维码并从中提取信息成为可能。Aiming at the perspective distortion of folding deformation, the present invention designs a related restoration method and its device and related code scanning equipment without changing the structure of the two-dimensional code of the image itself, so that the planes located on the commodity packaging meet It is possible to extract information from image QR codes pasted everywhere.
以下将以实施方式对上述的说明作详细的描述,并对本发明的技术方案提供更进一步的解释。The above-mentioned description will be described in detail in the following embodiments, and a further explanation will be provided for the technical solution of the present invention.
附图说明Description of drawings
为让本发明的上述和其他目的、特征、优点与实施例能更明显易懂,所附附图的说明如下:In order to make the above and other objects, features, advantages and embodiments of the present invention more comprehensible, the accompanying drawings are described as follows:
图1为本发明的一实施例中折叠二维码图像的还原方法的流程图;Fig. 1 is a flowchart of a method for restoring a folded two-dimensional code image in an embodiment of the present invention;
图2为本发明的一实施例中使用相机摄取的折叠二维码图像的示意图;Fig. 2 is a schematic diagram of a folded two-dimensional code image captured by a camera in an embodiment of the present invention;
图3为本发明的一实施例中经过切割处理和灰度值转换处理后的折叠二维码图像的示意图;Fig. 3 is a schematic diagram of a folded two-dimensional code image after cutting and gray value conversion in an embodiment of the present invention;
图4A为本发明的一实施例中在进行二值化处理过程中图像块与摄取的图像的关系的展示示意图;FIG. 4A is a schematic diagram showing the relationship between image blocks and captured images during binarization processing according to an embodiment of the present invention;
图4B为本发明的一实施例中经过二值化处理后得到的黑白二值图像;Fig. 4B is a black and white binary image obtained after binarization processing in an embodiment of the present invention;
图5为本发明的一实施例中在进行形态处理过程中使用的结构元素Ec的示意图;5 is a schematic diagram of a structural element E c used in the process of morphological processing in an embodiment of the present invention;
图6为本发明的一实施例中在进行形态处理过程中进行闭运算之后得到的闭运算结果图像Ic的示意图;Fig. 6 is a schematic diagram of the closed operation result image Ic obtained after the closed operation is performed during the morphological processing in an embodiment of the present invention;
图7为本发明的一实施例中在进行形态处理过程中经填充后得到的填充结果图像If的示意图;Fig. 7 is a schematic diagram of the filling result image If obtained after filling during the morphological processing in an embodiment of the present invention;
图8为本发明的一实施例中经边缘检测后得到的边缘标签图像Ie的示意图;8 is a schematic diagram of an edge label image I e obtained after edge detection in an embodiment of the present invention;
图9为本发明的一实施例中在进行线检测时霍夫域坐标(θ,ρ)与像素坐标(x,y)的关系示意图;9 is a schematic diagram of the relationship between Hough domain coordinates (θ, ρ) and pixel coordinates (x, y) during line detection in an embodiment of the present invention;
图10A、图10B为本发明的一实施例中的霍夫变换结果示意图,其中图10A显示了折叠二维码图像的上下4个顶部角点在霍夫域的表示,图10B显示了折叠二维码图像的中间折叠线上的2个折叠角点在霍夫域的表示;Figure 10A and Figure 10B are schematic diagrams of the Hough transform results in an embodiment of the present invention, wherein Figure 10A shows the representation of the upper and lower four top corners of the folded two-dimensional code image in the Hough domain, and Figure 10B shows the representation of the folded two-dimensional code image The representation of the two folding corners on the middle folding line of the two-dimensional code image in the Hough domain;
图11为本发明的一实施例中经线检测后的结果示意图;Fig. 11 is a schematic diagram of the results after the line detection in an embodiment of the present invention;
图12为本发明的一实施例中经角点检测后的结果示意图;Fig. 12 is a schematic diagram of the results after corner detection in an embodiment of the present invention;
图13A、图13B为本发明的一实施例中经图像还原步骤后得到的透视还原结果示意图,其中图13A显示了还原后的该折叠二维码图像的第一部分图像(即上部图像),图13B显示了还原后的该折叠二维码图像的第二部分图像(即下部图像);Fig. 13A and Fig. 13B are schematic diagrams of perspective restoration results obtained after the image restoration step in an embodiment of the present invention, wherein Fig. 13A shows the first part of the image (ie, the upper image) of the folded two-dimensional code image after restoration, and Fig. 13B shows the second part of the image (i.e. the lower image) of the folded two-dimensional code image after reduction;
图14为本发明的一实施例中通过模块数量估计方法计算在水平方向上的模块数量时的示意图,其中显示了在黑白二值图像中,从提取到的下端的两个校对点确定的水平定位图形的扫描位置;Fig. 14 is a schematic diagram of calculating the number of modules in the horizontal direction by the method of estimating the number of modules in an embodiment of the present invention, which shows the levels determined from the extracted two calibration points at the lower end in the black-and-white binary image Locate the scanning position of the graphic;
图15为图14中水平定位图形的扫描结果示意图;Fig. 15 is a schematic diagram of the scanning result of the horizontal positioning pattern in Fig. 14;
图16A、图16B分别为本发明的一实施例中经图像大小调整后得到的修正后的第一部分图像、修正后的第二部分图像的示意图;FIG. 16A and FIG. 16B are respectively schematic diagrams of the corrected first part of the image and the corrected second part of the image obtained after image size adjustment in an embodiment of the present invention;
图17为本发明的一实施例中经图像拼接步骤后得到的平面二维码图像的示意图;Fig. 17 is a schematic diagram of a plane two-dimensional code image obtained after the image stitching step in an embodiment of the present invention;
图18为本发明的一种折叠二维码图像的还原装置的结构示意图;Fig. 18 is a schematic structural diagram of a device for restoring a folded two-dimensional code image according to the present invention;
图19为本发明的一种折叠二维码图像的扫码设备的结构示意图。FIG. 19 is a schematic structural diagram of a code scanning device for folding two-dimensional code images according to the present invention.
具体实施方式Detailed ways
为了使本发明的叙述更佳详尽与完备,可参照所附的附图及以下所述各种实施例,附图中相同的号码代表相同或相似的组件。另一方面,众所周知的组件与步骤并未描述于实施例中,以避免对本发明造成不必要的限制。此外,为简化附图起见,一些已知惯用的结构与元件在附图中将以简单示意的方式绘示。In order to make the description of the present invention more detailed and complete, reference may be made to the attached drawings and various embodiments described below, and the same numbers in the drawings represent the same or similar components. On the other hand, well-known components and steps have not been described in the embodiments in order not to limit the invention unnecessarily. In addition, for the sake of simplifying the drawings, some known and conventional structures and elements will be shown in a simple and schematic manner in the drawings.
下面将结合图1~图17,将以一较佳实施例详细说明本发明的折叠二维码图像的还原方法。The method for restoring a folded two-dimensional code image according to the present invention will be described in detail in a preferred embodiment below with reference to FIGS. 1 to 17 .
需要事先说明的是,本较佳实施例中所揭露的还原方法是假设原始的二维码图像为四边形(非正方形)且折叠处与上下两边平行,其中每一个承载的比特信息都是由一个正方形模块组成,并且在其中经过平面交汇处的边以及上下两边其中的一个边中有交替的黑色模块与白色模块作为定位图形,定位图形中的黑白模块大小与数据模块相同,用来定位其中每一模块行和模块列在整个数据模块部分的位置。但是,可以理解的是,上述仅是本较佳实施例对二维码的假设,但本发明所涉及到的方法、装置及其应用没有限制二维码的种类等。It needs to be explained in advance that the restoration method disclosed in this preferred embodiment assumes that the original two-dimensional code image is quadrilateral (not square) and the folds are parallel to the upper and lower sides, and the bit information carried by each of them is composed of a It is composed of square modules, and there are alternating black and white modules as positioning graphics on the side passing through the intersection of the planes and one of the upper and lower sides. The size of the black and white modules in the positioning graphics is the same as that of the data module. A module row and module column are positioned throughout the module section of the data. However, it can be understood that the above is only the assumption of the two-dimensional code in this preferred embodiment, but the methods, devices and applications involved in the present invention do not limit the types of two-dimensional codes and the like.
并且,经过角度未知折叠后,原本的平面二维码图像由两个不同交汇平面构成,本实施例是将从中间折叠后的二维码图像的两个平面分别做透视还原,然后对两个还原后的平面进行拼接从而还原原本的二维码图像。本发明没有假设特定的折叠角度,但假设其足够大可以区分上下两个平面,同时不至于使两个平面中的任意一个被另一个遮挡或者失去对焦。Moreover, after folding with an unknown angle, the original planar two-dimensional code image is composed of two different intersecting planes. The restored planes are spliced to restore the original two-dimensional code image. The invention does not assume a particular folding angle, but assumes that it is large enough to distinguish between the upper and lower planes without causing either of the two planes to be obscured by the other or out of focus.
如图1所示,其示出了本发明的一较佳实施例的折叠二维码图像的还原方法的流程。As shown in FIG. 1 , it shows the flow of a method for restoring a folded two-dimensional code image in a preferred embodiment of the present invention.
该还原方法分为四个主要步骤:图像预处理步骤、角点检测步骤、图像还原步骤、和图像拼接步骤。The restoration method is divided into four main steps: an image preprocessing step, a corner point detection step, an image restoration step, and an image stitching step.
图像预处理步骤Image preprocessing steps
图像预处理步骤,其主要是对一折叠二维码图像进行预处理,以获取包含有二维码图像信息的预处理后图像。在本较佳实施例中,该图像预处理步骤可包括切割处理、灰度值转换处理、二值化处理、以及形态处理等多个处理步骤。但是,可以理解的是,在其它实施例中,也可以仅包含这些处理步骤中的一个或多个,这些并不作为对本发明的限制。The image preprocessing step is mainly to preprocess a folded two-dimensional code image to obtain a preprocessed image containing two-dimensional code image information. In this preferred embodiment, the image preprocessing step may include multiple processing steps such as cutting processing, gray value conversion processing, binarization processing, and morphological processing. However, it can be understood that, in other embodiments, only one or more of these processing steps may be included, and these are not intended to limit the present invention.
对摄取的图像进行切割处理、灰度值转换处理和二值化处理Carry out cutting processing, gray value conversion processing and binarization processing on the captured image
在本较佳实施例中,假设一图像摄取装置,例如一扫码设备的相机单元,所摄取到的折叠二维码图像是经过一次折叠角度未知的折叠,且折叠线与二维码图像的四边中平行的两边平行,其中,该相机单元所摄取到的折叠二维码图像如图2所示。In this preferred embodiment, it is assumed that an image capture device, such as a camera unit of a code scanning device, captures the folded two-dimensional code image after a fold with an unknown folding angle, and the folding line and the two-dimensional code image Two parallel sides among the four sides are parallel, and the image of the folded two-dimensional code captured by the camera unit is shown in FIG. 2 .
首先,在取得摄取到的折叠二维码图像时,为了减轻后续图像处理的计算量,可对摄取到的图像进行切割处理,从而减少处理的像素数量和其他无关的图像部分,以获取具有一预定尺寸的折叠二维码图像,例如可通过切割处理获得一675×675像素的折叠二维码图像。在实际操作过程中,可以通过设计扫码设备,并借助用户的协助,使得该扫码设备的相机单元在摄取图像时可使二维码大致位于中央,从而可获得一预定尺寸(例如675×675像素)的折叠二维码图像,以此来减少后续需要处理的图像范围,增加整体的计算速度。该预定尺寸的折叠二维码图像可作为后续步骤的输入。First of all, when obtaining the captured folded two-dimensional code image, in order to reduce the calculation load of the subsequent image processing, the captured image can be cut to reduce the number of processed pixels and other irrelevant image parts, so as to obtain a The folded two-dimensional code image of a predetermined size, for example, can be cut to obtain a folded two-dimensional code image of 675×675 pixels. In the actual operation process, by designing the code scanning device and with the assistance of the user, the camera unit of the code scanning device can make the two-dimensional code roughly in the center when capturing the image, so that a predetermined size (such as 675× 675 pixels) of the folded QR code image, so as to reduce the range of images that need to be processed later and increase the overall calculation speed. The folded two-dimensional code image of the predetermined size can be used as an input for subsequent steps.
由于没有涉及到颜色信息,可用已知的转换公式将所获取的该折叠二维码图像进行灰度值转换处理,即转换为灰度值图像Ig。Since no color information is involved, the acquired folded two-dimensional code image can be converted into a gray value image I g using a known conversion formula.
Ig=0.299×R+0.587×G+0.114×BI g =0.299×R+0.587×G+0.114×B
其中(R,G,B)为摄取到的折叠二维码图像的红绿蓝三个颜色值。在经过切割处理和灰度值转换处理后,后续需要处理的灰度值图像Ig如图3所示。Where (R, G, B) are the three color values of red, green and blue of the captured folded QR code image. After the cutting process and the gray value conversion process, the gray value image I g to be processed subsequently is shown in FIG. 3 .
在得到灰度值图像Ig后,需要将其中的二维码图像部分与其他无关的图像部分进行区分。在此步骤中,灰度值图像Ig进一步被变换为二进制图像,也就是黑白二值图像Ib。After the gray value image I g is obtained, it is necessary to distinguish the two-dimensional code image part from other irrelevant image parts. In this step, the gray value image I g is further transformed into a binary image, that is, a black and white binary image I b .
考虑到不均匀的反射光线和二维码图像内容中的像素值不同的对比度,参考自ZXing软件库,一个简单的自适应阈值设定方式如下:首先,将摄取的图像分解为数个8×8像素的图像块。如果其尺寸并非8的倍数,边界的图像块尺寸可以小于8×8像素。用blk(i,j)来表示第(i,j)个图像块,在每一个图像块中,计算:Considering the uneven reflected light and the different contrast of the pixel values in the two-dimensional code image content, a simple adaptive threshold setting method is as follows from the ZXing software library: First, decompose the captured image into several 8×8 pixel image blocks. If its size is not a multiple of 8, the image block size of the boundary can be smaller than 8×8 pixels. Use blk(i,j) to represent the (i,j)th image block, in each image block, calculate:
其中图像块与摄取的图像的关系如图4A所示,其中,假设摄取的图像大小为24×24像素,则其可以分为9个图像块,例如包括图像块blk(1,1)、blk(1,2)、blk(1,3)、blk(2,1)、……、blk(3,3)等,每个图像块的大小为8×8像素。The relationship between the image block and the captured image is shown in Figure 4A, wherein, assuming that the captured image has a size of 24×24 pixels, it can be divided into 9 image blocks, for example, including image blocks blk(1,1), blk (1,2), blk(1,3), blk(2,1), ..., blk(3,3), etc., the size of each image block is 8×8 pixels.
然后,再以(i,j)为中心,周围的5×5个图像块中取p(i,j)的平均值作为阈值。Then, take (i, j) as the center, and take the average value of p(i, j) in the surrounding 5×5 image blocks as the threshold.
如果周围的图像块超出了图像的边界,则将范围调整为离(i,j)最近的5×5个图像块。最后,在第(i,j)个图像块中,将灰度值图像和相对应的阈值进行比较,得到黑白二值图像Ib:If the surrounding image blocks exceed the boundary of the image, the range is adjusted to the nearest 5×5 image blocks to (i, j). Finally, in the (i,j)th image block, compare the gray value image with the corresponding threshold to obtain the black and white binary image I b :
(k,l)位于图像块blk(i,j)中 (k,l) is located in the image block blk(i,j)
得到的黑白二值图像Ib如图4B所示。The obtained black and white binary image I b is shown in Fig. 4B.
形态处理Morphological processing
此步骤是对该折叠二维码图像进行形态处理,通过对该折叠二维码图像中的不同物体进行区分,提取其中的二维码图像信息,其中该二维码图像信息包含二维码图像的位置信息。This step is to perform morphological processing on the folded two-dimensional code image, by distinguishing different objects in the folded two-dimensional code image, and extract the two-dimensional code image information therein, wherein the two-dimensional code image information includes the two-dimensional code image location information.
在此步骤中,是使用得到的黑白二值图像Ib来对摄取的图像中不同的物体进行区分,提取其中的二维码图像信息,并且去掉其他不必要的图像部分。在此,是假设二维码图像为摄取的图像中最主要的物体。In this step, the obtained black-and-white binary image I b is used to distinguish different objects in the captured image, extract the two-dimensional code image information therein, and remove other unnecessary image parts. Here, it is assumed that the two-dimensional code image is the most important object in the captured image.
首先,对该黑白二值图像Ib进行闭运算。这一步是使用以结构元素为Ec的标准闭运算,使该黑白二值图像中的二维码图像的边界变得连续。其中,此闭运算步骤是对黑白二值图像中的物体(包括二维码图像和其他可能的物体)外围和边界中断裂处进行弥合,同时保持了物体在黑白二值图像中的总体位置和形状:First, perform a closing operation on the black and white binary image I b . This step is to use the standard closing operation with the structural element as E c to make the boundary of the two-dimensional code image in the black and white binary image continuous. Wherein, this closing operation step is to bridge the breaks in the periphery and boundary of objects (including two-dimensional code images and other possible objects) in the black and white binary image, while maintaining the overall position and position of the object in the black and white binary image. shape:
这里,由于事先无法预知相机摄取二维码图像时的摄取环境、周边干扰二维码图像检测的物体数量、以及二维码本身在整个图像中所占的比例,可首先将结构元素Ec设置为半径为7的圆形滑动窗口,如图5所示。Here, since it is impossible to predict in advance the capturing environment when the camera captures the two-dimensional code image, the number of surrounding objects that interfere with the detection of the two-dimensional code image, and the proportion of the two-dimensional code itself in the entire image, the structural element E c can be set first is a circular sliding window with a radius of 7, as shown in Figure 5.
另外,表示图像形态的膨胀操作:in addition, Represents a dilation operation for image morphology:
其会使物体的边界根据结构元素Ec的结构向外扩张,∪可以当作“或(or)”操作。It will cause the boundary of the object to expand outward according to the structure of the structural element E c , and ∪ can be used as an "or (or)" operation.
代表图像形态的腐蚀操作: Corrosion operations representing image morphologies:
其会使物体的边界根据结构元素Ec向内收缩,也就是只有当图像的边界处形状与Ec重合的部分会被保留,∩可以当作“且(and)”操作。It will cause the boundary of the object to shrink inward according to the structural element Ec , that is, only when the part of the shape at the boundary of the image coincides with Ec will be retained, ∩ can be used as an "and" operation.
在进行闭运算后,黑白二值图像中二维码图像的部分的边界会变得连续,如图6所示,其示出了进行闭运算之后得到的闭运算结果图像Ic。与图4B比较,可以看出图4B中位于中间的二维码图像的边界已经被连为一体。After the closing operation, the boundary of the part of the two-dimensional code image in the black and white binary image will become continuous, as shown in FIG. 6 , which shows the result image I c of the closing operation obtained after the closing operation. Compared with FIG. 4B , it can be seen that the boundary of the two-dimensional code image in the middle in FIG. 4B has been connected as a whole.
在本发明中,当后续的步骤失败时,例如当角点检测步骤检测失败或图像还原步骤失败时,可通过增加结构元素的尺寸,重新进行闭运算步骤,并重新尝试后续步骤。例如,可通过提高窗口的半径重新进行闭运算步骤,对图像上不同的物体进行更大范围的填充。如此,本发明可通过角点检测步骤和图像还原步骤的结果调整闭运算中的结构元素来控制整个流程。In the present invention, when the subsequent steps fail, for example, when the corner detection step fails or the image restoration step fails, the closing operation step can be re-performed by increasing the size of the structural element, and the subsequent steps can be tried again. For example, the closing operation step can be performed again by increasing the radius of the window to fill in a larger range of different objects on the image. In this way, the present invention can adjust the structural elements in the closing operation through the results of the corner detection step and the image restoration step to control the entire process.
下一步,是对图像进行填充操作来区分二维码图像与其他物体,并获取二维码图像在摄取图像中的位置。由于在闭运算后,闭运算结果图像Ic中相同的物体的边界已经连为一体,且不同物体并不相连,则可在不同的物体上分别进行填充,并且获取其中面积最大(白色像素点最多)的物体作为二维码图像的位置。经填充后的填充结果图像If如图7所示。The next step is to fill the image to distinguish the QR code image from other objects, and obtain the position of the QR code image in the captured image. Since after the closing operation, the boundaries of the same objects in the closing operation result image I c have been connected as a whole, and different objects are not connected, then different objects can be filled separately, and the largest area (white pixel points) can be obtained most) objects as the position of the QR code image. The filled result image If after filling is shown in FIG. 7 .
角点检测步骤Corner detection step
角点检测步骤,其主要是对预处理后图像进行角点检测,以获取折叠二维码图像的多个校正点,其中所述多个校正点至少包含该折叠二维码图像的顶部角点及位于该折叠二维码图像的折叠线上的折叠角点。在本较佳实施例中,该角点检测步骤可包括边缘检测、线检测和角点检测等多个检测步骤。A corner point detection step, which mainly performs corner point detection on the preprocessed image to obtain a plurality of correction points of the folded two-dimensional code image, wherein the plurality of correction points include at least the top corner point of the folded two-dimensional code image and the folded corners located on the folded line of the folded two-dimensional code image. In this preferred embodiment, the corner detection step may include multiple detection steps such as edge detection, line detection and corner detection.
边缘检测edge detection
从摄取到的折叠二维码图像可以看到,经过折叠后的二维码存在6个角点以及6条边。因此,通过对摄取的图像进行边缘检测和线检测,可以确定其中的6条边,并根据它们的相交点可以确定6个角点,例如包括该折叠二维码图像的4个顶部角点及位于该折叠二维码图像的折叠线上的2个折叠角点。It can be seen from the captured image of the folded QR code that there are 6 corners and 6 sides in the folded QR code. Therefore, by performing edge detection and line detection on the captured image, 6 sides can be determined, and 6 corner points can be determined according to their intersection points, for example, including the 4 top corner points of the folded two-dimensional code image and Two folding corners located on the folding line of the folded QR code image.
在这一步骤中,可使用填充后的黑白二值图像,例如填充结果图像If作为标签图像,对其进行边缘检测。由于图7中白色部分的边缘十分明显,且需要提取的边缘也十分具体,这里需要的边缘检测并非难点,故可使用不同的边缘检测方法,如Prewitt或者Sobel等。比如本较佳实施例可使用Sobel Operator来提取黑白二值图像中的边缘,其在水平方向和垂直方向的滑动窗口分别为:In this step, the filled black-and-white binary image can be used, for example, the filled result image If as the label image for edge detection. Since the edge of the white part in Figure 7 is very obvious, and the edge to be extracted is also very specific, the edge detection required here is not difficult, so different edge detection methods can be used, such as Prewitt or Sobel. For example, this preferred embodiment can use the Sobel Operator to extract the edges in the black and white binary image, and its sliding windows in the horizontal and vertical directions are respectively:
然后,可将其中量值较大的边缘提取出来作为二维码图像的边缘。最终的得到的边缘标签图像Ie为:Then, the edge with a larger magnitude can be extracted as the edge of the two-dimensional code image. The final edge label image I e obtained is:
其中*表示卷积,得到的边缘标签图像Ie如图8所示。where * represents convolution, and the resulting edge label image I e is shown in Figure 8.
线检测line detection
得到边缘标签图像Ie后,需要提取出边缘信息以进行下一步的处理。这里可使用常用的霍夫变换来进行线检测。对于每一个在二维码边缘标签图像的白色像素点(x,y),经过霍夫变换后经过如下的关系变为(θ,ρ):After the edge label image I e is obtained, the edge information needs to be extracted for the next step of processing. Here, the commonly used Hough transform can be used for line detection. For each white pixel point (x, y) of the label image on the edge of the QR code, after the Hough transform, it becomes (θ, ρ) through the following relationship:
x cosθ+y sinθ=ρx cosθ+y sinθ=ρ
并在霍夫域中的(θ,ρ)中加1。在对边缘标签图像Ie进行霍夫变换后,得到如图10A、10B所示的霍夫变换结果。这里的坐标(x,y)为摄取到的二维码图像中的坐标,其原点为图像的左上角,如图9所示,其示出了霍夫域坐标(θ,ρ)与像素坐标(x,y)的关系。其中直线L上的每一个像素都会在同一处(θ,ρ)中加1,最终再累计为霍夫域的局部最大值。And add 1 to (θ,ρ) in the Hough domain. After the Hough transform is performed on the edge label image Ie , the Hough transform results shown in Figs. 10A and 10B are obtained. The coordinates (x, y) here are the coordinates in the captured two-dimensional code image, and its origin is the upper left corner of the image, as shown in Figure 9, which shows the relationship between the Hough domain coordinates (θ, ρ) and the pixel coordinates (x,y) relationship. Each pixel on the straight line L will add 1 to the same (θ, ρ), and finally accumulate to the local maximum value of the Hough domain.
图10A、图10B分别示出了霍夫变换结果,图10A显示了折叠二维码图像的上下4个顶部角点在霍夫域的表示,图10B显示了折叠二维码图像中间折叠线上的2个折叠角点在霍夫域的表示。在图10A和图10B中,在垂直方向取得了4条直线,在水平方向则取得了2条直线,分别用白色方格标记为霍夫域中的局部最大值。Figure 10A and Figure 10B show the results of the Hough transform respectively, Figure 10A shows the representation of the upper and lower four top corners of the folded two-dimensional code image in the Hough domain, Figure 10B shows the fold line in the middle of the folded two-dimensional code image A representation of the 2 folded corners in the Hough domain. In FIG. 10A and FIG. 10B , 4 straight lines are obtained in the vertical direction, and 2 straight lines are obtained in the horizontal direction, which are respectively marked by white squares as local maxima in the Hough domain.
虽然边缘检测步骤中取得的边缘为线段,但在此利用的是检测到的这6条线段所在的直线,可使用齐次坐标来表示。如此一来,即可在霍夫域中得到边缘直线的信息,包括其起点s=(xs,ys,1)和终点e=(xe,ye,1)。齐次坐标系中,可用l=[a,b,c]来表示直线,则在直线上的点满足:Although the edges obtained in the edge detection step are line segments, the straight lines where the six detected line segments are located are used here, which can be represented by homogeneous coordinates. In this way, the information of the edge straight line can be obtained in the Hough domain, including its starting point s=(x s ,y s ,1) and ending point e=(x e ,y e ,1). In the homogeneous coordinate system, l=[a,b,c] can be used to represent the straight line, then the points on the straight line satisfy:
ax+by+c=0ax+by+c=0
其中,直线l可以用直线上的两点的交叉乘积得到:Among them, the straight line l can be obtained by the cross product of two points on the straight line:
这里s=(xs,ys,1)与e=(xe,ye,1)都可以由直线在霍夫域中的点(θ,ρ)计算得到。取得的4条垂直方向的直线可用li,i=1,…,4表示,如图11中的直线li,水平方向的2条直线可用lj,j=1,2表示,如图11中的直线lj。Here s=(x s ,y s ,1) and e=(x e ,y e ,1) can be calculated from the point (θ,ρ) of the straight line in the Hough domain. The obtained 4 straight lines in the vertical direction can be represented by l i , i=1,...,4, as shown in the straight line li in Figure 11, and the 2 straight lines in the horizontal direction can be represented by l j , j =1, 2, as shown in Figure 11 The straight line l j in .
角点检测Corner detection
在进行图像还原前,需要取得摄取的折叠二维码图像的四个顶部角点和折叠处的两个折叠角点,作为校正点和图像还原的输入。在得到二维码图像边界的直线li和lj后,可以再次用交叉乘积来得到直线交点的齐次坐标:Before performing image restoration, it is necessary to obtain the four top corners of the captured folded QR code image and the two fold corners at the fold as input for correction points and image restoration. After obtaining the straight lines l i and l j of the two-dimensional code image boundary, the homogeneous coordinates of the intersection points of the straight lines can be obtained by cross product again:
其中,二维码图像的4个顶部角点为水平方向上的直线lj和垂直方向上的直线li的交点。Wherein, the four top corners of the two-dimensional code image are the intersection points of the straight line l j in the horizontal direction and the straight line l i in the vertical direction.
二维码图像的折叠处的2个折叠角点为不同的垂直方向上的直线li之间的交点。Two folding corner points at the folding place of the two-dimensional code image are intersection points between straight lines l i in different vertical directions.
其中,为两条不同的垂直线。并且,在这些交点中,只需取在摄取到的图像范围中的交点,作为需要的校正点。另外,校正点的坐标需要转换为二维平面坐标c。in, for two different vertical lines. And, among these intersection points, only the intersection points in the captured image range are taken as required correction points. In addition, the coordinates of the calibration points need to be transformed into two-dimensional plane coordinates c.
如图12所示,从二维码图像的边界的直线中提取了6个校正点。其中P1~P4为二维码图像的4个顶部角点,P5~P6为折叠处的2个折叠角点。As shown in FIG. 12, 6 correction points are extracted from the straight line of the boundary of the two-dimensional code image. Among them, P1-P4 are the four top corners of the two-dimensional code image, and P5-P6 are the two folding corners of the folding place.
图像还原步骤Image Restoration Steps
图像还原步骤,其主要是利用所述折叠角点及所述顶部角点,对该折叠二维码图像进行透视还原,以获取该折叠二维码图像在两个交汇平面中的第一部分图像和第二部分图像。The image restoration step mainly uses the folded corners and the top corners to perform perspective restoration on the folded two-dimensional code image, so as to obtain the first part of the folded two-dimensional code image in the two intersection planes and The second part of the image.
透视变换的数学表达Mathematical Expression of Perspective Transformation
在本发明中,假设相机模型为针孔相机模型。尽管其他的更为准确的相机光学模型可以表达更多类型的空间失真,由于它们较为复杂且与透视还原没有直接关系,因而针孔相机模型更普遍用于平面透视变换。In the present invention, it is assumed that the camera model is a pinhole camera model. Although other, more accurate camera optics models can express more types of spatial distortions, pinhole camera models are more commonly used for planar perspective transformations because they are more complex and not directly related to perspective restoration.
平面透视变换描述的是一个在三维空间中的二维平面上的点投射到另一个二维平面的过程。也就是说,相机所摄取的图像为二维图像。这也是目前二维码应用中的透视还原所假设的,二维码图像为平面。Plane perspective transformation describes the process of projecting a point on a two-dimensional plane in three-dimensional space to another two-dimensional plane. That is to say, the image captured by the camera is a two-dimensional image. This is also assumed by perspective reduction in current QR code applications, where the QR code image is flat.
如果把在平面二维码中二维空间上的一点的二维坐标以齐次坐标表示:x″=[x″y″z″]T,也就是说,其二维的直角坐标为:If the two-dimensional coordinates of a point on the two-dimensional space in the plane two-dimensional code are represented by homogeneous coordinates: x″=[x″y″z″] T , that is to say, its two-dimensional Cartesian coordinates are:
对于平面透视变换,其变换后的齐次坐标为x′=Ax″:For plane perspective transformation, the homogeneous coordinates after transformation are x′=Ax″:
相应的,x'在摄取到的二维图像中的直角坐标为:Correspondingly, the Cartesian coordinates of x' in the captured two-dimensional image are:
其中,A为3×3的非其奇异矩阵。透视变换中,A为齐次矩阵,其自由度为8,因为在对其乘以一个标量常数后,不会改变。Among them, A is a 3×3 non-singular matrix. In perspective transformation, A is a homogeneous matrix with 8 degrees of freedom, because after multiplying it by a scalar constant, will not change.
透视还原步骤Perspective restoration steps
得到6个校正点后,可将其分为上下两部分进行处理。由于透视变换的自由度为8,而每一个参考点的坐标为二维坐标,故需要4个参考点来估计一个完整的齐次矩阵A。After getting 6 calibration points, it can be divided into upper and lower parts for processing. Since the degree of freedom of perspective transformation is 8, and the coordinates of each reference point are two-dimensional coordinates, four reference points are needed to estimate a complete homogeneous matrix A.
在上一步骤中得到了6个校正点,所以对于上半部分的二维码图像,可将上半部分的2个校正点(例如顶部角点)和中间折叠部分的2个校正点(例如折叠角点)作为参考点。对于下半部分,可将下半部分的2个校正点(例如顶部角点)和中间折叠部分的2个校正点(例如折叠角点)作为参考点。这样,中间折叠部分的折叠角点一共被用到2次来估计两个不同的透视变换。In the previous step, 6 calibration points were obtained, so for the upper half of the QR code image, the 2 calibration points of the upper half (such as top corner points) and the 2 calibration points of the middle folded part (such as Fold corners) as reference points. For the bottom half, the 2 correction points of the bottom half (eg top corners) and the 2 correction points of the middle folded part (eg fold corners) can be used as reference points. In this way, the folded corners of the middle folded part are used twice in total to estimate two different perspective transformations.
首先,假设上下两部分的二维码图像均从一个单位长度的正方形所投影过来(会进行后续处理使上下两部分二维码的长度吻合),也就是:First, assume that the upper and lower parts of the two-dimensional code image are projected from a square of unit length (subsequent processing will be performed to make the lengths of the upper and lower parts of the two-dimensional code match), that is:
(0,0)→(x0,y0),(0,0)→(x 0 ,y 0 ),
(1,0)→(x1,y1),(1,0)→(x 1 ,y 1 ),
(0,1)→(x2,y2),(0,1)→(x 2 ,y 2 ),
(1,1)→(x3,y3)(1,1)→(x 3 ,y 3 )
其中,(xi,yi)为角点坐标ci,可用如下的关系式来得到齐次矩阵A:Among them, (x i , y i ) are the corner coordinates c i , and the homogeneous matrix A can be obtained by the following relation:
a11=x1-x0+a13x1 a 11 =x 1 -x 0 +a 13 x 1
a21=x3-x0+a23x3 a 21 =x 3 -x 0 +a 23 x 3
a31=x0 a 31 =x 0
a12=y1-y0+a13y1 a 12 =y 1 -y 0 +a 13 y 1
a22=y3-y0+a23y3 a 22 =y 3 -y 0 +a 23 y 3
a32=y0 a 32 =y 0
定义:definition:
Δx1=x1-x2,Δx2=x3-x3,Δx3=x0-x1+x2-x3 Δx 1 =x 1 -x 2 , Δx 2 =x 3 -x 3 , Δx 3 =x 0 -x 1 +x 2 -x 3
Δy1=y1-y2,Δy2=y3-y2,Δy3=y0-y1+y2-y3 Δy 1 =y 1 -y 2 , Δy 2 =y 3 -y 2 , Δy 3 =y 0 -y 1 +y 2 -y 3
则可以计算then it can be calculated
由于上下两部分经过的不同的透视畸变,所以其对应的齐次矩阵也不同,可分别用A1和A2来表示,通过两组不同的参考点得到二维码图像。而后可以通过和来将上下两部分分别还原为正方形图像,如图13A和图13B所示,其示出了得到的透视还原结果。其中,图13A显示了还原后的该折叠二维码图像的第一部分图像(即上部图像),图13B显示了还原后的该折叠二维码图像的第二部分图像(即下部图像)。Due to the different perspective distortions experienced by the upper and lower parts, the corresponding homogeneous matrices are also different, which can be represented by A 1 and A 2 respectively, and the two-dimensional code image is obtained through two sets of different reference points. Then you can pass and To restore the upper and lower parts to a square image respectively, as shown in FIG. 13A and FIG. 13B , which show the obtained perspective restoration results. Wherein, FIG. 13A shows the first partial image (ie, the upper image) of the folded two-dimensional code image after restoration, and FIG. 13B shows the second partial image (ie, the lower image) of the folded two-dimensional code image after restoration.
图像拼接步骤Image Stitching Steps
图像拼接步骤,其主要是对该第一部分图像和该第二部分图像进行拼接,以获取一平面二维码图像。The image splicing step mainly involves splicing the first part of the image and the second part of the image to obtain a plane two-dimensional code image.
其中,得到折叠二维码图像上下两部分(即第一部分图像和第二部分图像)的正方形透视还原结果后,在还原后的二维码图像宽度不变的情况下,需要将它们的长度调整到它们原先的长度,从而在最后一步中,对还原后的上下两部分的二维码图像进行融合,还原得到原始的平面二维码图像。Among them, after obtaining the square perspective restoration results of the upper and lower parts of the folded two-dimensional code image (ie, the first part of the image and the second part of the image), when the width of the restored two-dimensional code image remains unchanged, their lengths need to be adjusted to their original lengths, so that in the last step, the restored two-dimensional code images of the upper and lower parts are fused to obtain the original plane two-dimensional code image.
模块数量估计Module Quantity Estimation
首先,通过上下两部分的二维码图像中位于上下两端其中一端的定位图形,也就是其中交替的黑色与白色模块,计算摄取到的二维码图像在水平方向的模块数量,如图14和图15所示。而确认上下哪一端包含了定位图形则非常容易,因为不包含定位图形的一端不会有黑白交替的模块出现。同时,假设模块为正方形,其长宽相同。First, calculate the number of modules in the horizontal direction of the captured QR code image through the positioning graphics located at one of the upper and lower ends of the upper and lower parts of the QR code image, that is, the alternating black and white modules, as shown in Figure 14 and shown in Figure 15. It is very easy to confirm which end contains the positioning graphic, because the side that does not contain the positioning graphic will not have alternating black and white modules. At the same time, it is assumed that the modules are square with the same length and width.
如图14所示,其是在黑白二值图像中,从提取到的下端的两个校对点(即顶部角点)确定水平定位图形的扫描位置,用线段“Lh”标记。As shown in Figure 14, in the black-and-white binary image, the scanning position of the horizontal positioning pattern is determined from the extracted two calibration points at the lower end (that is, the top corner point), which is marked with a line segment "L h ".
如图15所示,其示出了图14中线段“Lh”的扫描结果,可以从中估计在水平方向上的模块数量。在图15中,每一次从0→1→0的过程代表了一个模块,同样,每一次1→0→1的过程也代表了一个模块,因此可以从中得到水平方向的模块数量nh。这里,nh应为整数,因为在水平方向上的二维码图像并未被分割,其所包含的应为整数个模块。As shown in FIG. 15 , it shows the scanning result of the line segment “L h ” in FIG. 14 , from which the number of modules in the horizontal direction can be estimated. In Figure 15, each process from 0→1→0 represents a module, and similarly, each process from 1→0→1 also represents a module, so the number n h of modules in the horizontal direction can be obtained from it. Here, n h should be an integer, because the two-dimensional code image in the horizontal direction is not divided, and it should contain an integer number of modules.
用同样的方法,在还原后的上、下两部分的二维码图像的右侧,可以确定上、下两部分的二维码图像在垂直方向上的模块数量nv,upper、nv,lower。区别于水平方向的一点是nv,upper、nv,lower可以不是整数,因为在折叠过的二维码图像上下两部分的交汇处可以在垂直方向上的一个模块中间,导致上、下两部分各有此模块的一部分。在此,可利用二维码图像的上部分中最下端的模块所占的像素长度dupper,bottom与下部分最上端的模块所占的像素长度dlower,top得到:In the same way, on the right side of the restored upper and lower two-dimensional code images, the number of modules in the vertical direction nv,upper , nv , of the upper and lower two-dimensional code images can be determined. lower . One difference from the horizontal direction is that n v,upper and n v,lower may not be integers, because the intersection of the upper and lower parts of the folded two-dimensional code image can be in the middle of a module in the vertical direction, resulting in the upper and lower two Sections each have a portion of this module. Here, the pixel length d upper,bottom occupied by the lowermost module in the upper part of the two-dimensional code image and the pixel length d lower,top occupied by the uppermost module in the lower part can be used to obtain:
其中#upper和#lower分别为上、下两部分垂直定位图形中黑白交替的数量,也就是nv,upper和nv,lower的整数部分。Among them, #upper and #lower are the numbers of alternating black and white in the vertical positioning graphics of the upper and lower parts respectively, that is, the integer parts of n v,upper and n v,lower .
图像大小调整和拼接Image resizing and stitching
在这一步中,原先还原的二维码图像的上、下两部分将由正方形图像调整为其原始的长宽比。通过透视还原后二维码图像的上下两部分的宽度w和上一步估计出来的水平方向的模块数量nh,可以计算出模块在透视还原后的大小m:In this step, the upper and lower parts of the originally restored QR code image will be adjusted to their original aspect ratio by the square image. Through the width w of the upper and lower parts of the two-dimensional code image after perspective restoration and the number of modules n h in the horizontal direction estimated in the previous step, the size m of the module after perspective restoration can be calculated:
m=w/nh m=w/n h
从而可以计算透视还原后上部分的二维码图像的长度(高度)hupper:Thus, the length (height) h upper of the upper part of the two-dimensional code image after perspective restoration can be calculated:
hupper=nv,upper×mh upper = n v, upper × m
和下部分的二维码图像的长度(高度)hlower:and the length (height) h lower of the QR code image in the lower part:
hlower=nv,lower×mh lower = n v, lower × m
从而将上下两部分原本同宽度一样的长度(高度)调整为hupper和hlower,经调整后的结果如图16A和图16B所示,其中图16A示出了经图像大小调整后得到的修正后的第一部分图像(即上部图像),图16B示出了经图像大小调整后得到的修正后的第二部分图像的示意图(即下部图像)。Therefore, the length (height) of the upper and lower parts, which are originally the same as the width, is adjusted to h upper and h lower . The adjusted results are shown in Figure 16A and Figure 16B, where Figure 16A shows the correction obtained after image size adjustment Fig. 16B shows a schematic diagram of the corrected second partial image (ie, the lower image) obtained after image size adjustment.
最后,将上下两部分的二维码图像进行拼接,即可得到还原后的平面二维码图像,如图17所示。还原后的平面二维码图像可以被二维码解码器识别,从而可取得相关信息。Finally, splicing the upper and lower parts of the two-dimensional code image to obtain the restored flat two-dimensional code image, as shown in Figure 17. The restored planar two-dimensional code image can be recognized by the two-dimensional code decoder, so that relevant information can be obtained.
如图18所示,本发明相应提供一种折叠二维码图像的还原装置180,其可包括:As shown in Fig. 18, the present invention accordingly provides a
图像预处理单元181,用于对一折叠二维码图像进行预处理,以获取包含有二维码图像信息的预处理后图像;
角点检测单元182,用于对该预处理后图像进行角点检测,以获取该折叠二维码图像的多个校正点,其中所述多个校正点至少包含该折叠二维码图像的顶部角点及位于该折叠二维码图像的折叠线上的角点;A
图像还原单元183,用于利用所述角点及所述顶部角点,对该折叠二维码图像进行透视还原,以获取该折叠二维码图像在两个交汇平面中的第一部分图像和第二部分图像;以及The
图像拼接单元184,用于对该第一部分图像和该第二部分图像进行拼接,以获取一平面二维码图像。The
较佳的,该图像预处理单元包括形态处理模块,用于对该折叠二维码图像进行形态处理,通过对该折叠二维码图像中的不同物体进行区分,提取其中的二维码图像信息,其中该二维码图像信息包含二维码图像的位置信息。Preferably, the image preprocessing unit includes a morphological processing module for performing morphological processing on the folded two-dimensional code image, and extracting the two-dimensional code image information in the folded two-dimensional code image by distinguishing different objects , wherein the two-dimensional code image information includes the location information of the two-dimensional code image.
更佳的,该图像预处理单元还可包括:Preferably, the image preprocessing unit may also include:
灰度值转换处理模块,用于对该折叠二维码图像进行灰度值转换处理,以得到一灰度值图像;以及A grayscale value conversion processing module, configured to perform grayscale value conversion processing on the folded two-dimensional code image to obtain a grayscale value image; and
二值化处理模块,用于对该折叠二维码图像进行二值化处理,以得到一黑白二值图像。The binarization processing module is used to perform binarization processing on the folded two-dimensional code image to obtain a black and white binary image.
在本发明,该形态处理模块在对该折叠二维码图像进行形态处理时,是使用结构元素对该黑白二值图像进行闭运算,使该黑白二值图像中的二维码图像的边界变得连续;以及是对该黑白二值图像进行填充,以区分二维码图像与其他物体,并获取二维码图像在该黑白二值图像中的位置信息。In the present invention, when the morphological processing module performs morphological processing on the folded two-dimensional code image, it uses structural elements to perform a closing operation on the black and white binary image, so that the boundary of the two-dimensional code image in the black and white binary image becomes and to fill the black and white binary image to distinguish the two-dimensional code image from other objects, and obtain the position information of the two-dimensional code image in the black and white binary image.
较佳的,该角点检测单元可包括:Preferably, the corner detection unit may include:
边缘检测模块,用于使用填充后的该黑白二值图像作为标签图像,并对其进行边缘检测,以获取二维码图像的多个边缘,并得到一边缘标签图像;An edge detection module, configured to use the filled black and white binary image as a label image, and perform edge detection on it to obtain multiple edges of the two-dimensional code image, and obtain an edge label image;
线检测模块,用于对该边缘标签图像进行线检测,以提取出该二维码图像的所述多个边缘的边缘信息;以及A line detection module, configured to perform line detection on the edge label image to extract edge information of the plurality of edges of the two-dimensional code image; and
角点检测模块,用于利用所述多个边缘的所述边缘信息进行角点检测,以获取该二维码图像的多个顶部角点和位于折叠线上的折叠角点。The corner detection module is configured to use the edge information of the plurality of edges to perform corner detection, so as to obtain a plurality of top corners of the two-dimensional code image and folding corners located on the folding line.
在本发明中,该图像还原单元是假设该折叠二维码图像的该第一部分图像和该第二部分图像均从一个单位长度的正方形所投影过来,且所获取的还原后的该第一部分图像和该第二部分图像均为正方形图像。In the present invention, the image restoration unit assumes that the first partial image and the second partial image of the folded two-dimensional code image are both projected from a square of unit length, and the obtained restored first partial image and the second part of the image are both square images.
较佳的,该图像拼接单元可包括:Preferably, the image splicing unit may include:
模块数量估计模块,用于通过模块数量估计方法,分别计算出该二维码图像在水平方向和垂直方向上的模块数量;The module quantity estimation module is used to calculate the module quantity of the two-dimensional code image in the horizontal direction and the vertical direction respectively by the module quantity estimation method;
图像大小调整模块,用于根据还原后的该二维码图像的该第一部分图像和该第二部分图像的宽度、以及所计算出的水平方向和垂直方向上的模块数量,将还原后的该二维码图像的该第一部分图像和该第二部分图像由正方形调整为其原始的长宽比,以得到修正后的第一部分图像和修正后的第二部分图像;以及The image size adjustment module is used to adjust the restored two-dimensional code image according to the width of the first part of the image and the width of the second part of the image, and the calculated number of modules in the horizontal and vertical directions. The first partial image and the second partial image of the two-dimensional code image are square-scaled to their original aspect ratios to obtain a corrected first partial image and a corrected second partial image; and
图像拼接模块,用于将该修正后的第一部分图像和该修正后的第二部分图像进行拼接,以得到该平面二维码图像。The image splicing module is used to splice the corrected first part of the image and the corrected second part of the image to obtain the planar two-dimensional code image.
在本发明中,该模块数量估计模块是:In the present invention, the module quantity estimation module is:
在该黑白二值图像中,通过在水平方向上所获取到的两个顶部角点来确定水平定位图形的扫描位置,并根据该水平定位图形的扫描结果来确定该二维码图像在水平方向上的模块数量;In the black-and-white binary image, the scanning position of the horizontal positioning figure is determined by the two top corner points obtained in the horizontal direction, and the horizontal position of the two-dimensional code image is determined according to the scanning result of the horizontal positioning figure. number of modules on
在该黑白二值图像中,通过在垂直方向上所获取到的顶部角点和折叠角点来确定垂直定位图形的扫描位置,并根据该垂直定位图形的扫描结果来确定该二维码图像在垂直方向上的模块数量。In the black-and-white binary image, the scanning position of the vertical positioning figure is determined by the top corner and folding corner obtained in the vertical direction, and the two-dimensional code image is determined according to the scanning result of the vertical positioning figure. The number of modules in the vertical direction.
在本发明中,当角点检测步骤检测失败或图像还原步骤还原失败时,该形态处理模块还通过增加结构元素的尺寸,重新进行闭运算步骤。In the present invention, when the corner point detection step fails to detect or the image restoration step fails to restore, the morphological processing module also increases the size of the structural elements to re-perform the closing operation step.
在本发明中,该图像预处理单元还可进一步包括:In the present invention, the image preprocessing unit may further include:
切割模块,用于通过一图像摄取装置获得一摄取图像,并对该摄取图像进行切割处理,以获取具有一预定尺寸的该折叠二维码图像。The cutting module is used to obtain a captured image through an image capturing device, and perform cutting processing on the captured image to obtain the folded two-dimensional code image with a predetermined size.
如图19所示,本发明还提供一种折叠二维码图像的扫码设备190,其可包括:As shown in Figure 19, the present invention also provides a
一相机单元191,用于摄取一折叠二维码图像;A
一如上所述的折叠二维码图像的还原装置180,用于对该折叠二维码图像进行还原,以获取一平面二维码图像;以及A
一二维码解码器192,用于对经还原后所得到的该平面二维码图像进行解码。A two-
本发明针对折叠形变这一类型的透视畸变,在不改变图像二维码本身结构的情况下,设计了相关的还原方法及其装置与相关的扫码设备,从而使从位于商品包装的平面交汇处黏贴的图像二维码并从中提取信息成为可能。Aiming at the perspective distortion of folding deformation, the present invention designs a related restoration method and its device and related code scanning equipment without changing the structure of the two-dimensional code of the image itself, so that the planes located on the commodity packaging meet It is possible to extract information from image QR codes pasted everywhere.
虽然本发明已以实施方式揭露如上,然其并非用以限定本发明,任何熟悉此技艺者,在不脱离本发明的精神和范围内,当可作各种的更动与润饰,因此本发明的保护范围当视所附的权利要求书所界定的范围为准。Although the present invention has been disclosed above in terms of implementation, it is not intended to limit the present invention. Any skilled person can make various changes and modifications without departing from the spirit and scope of the present invention. Therefore, the present invention The scope of protection should be based on the scope defined by the appended claims.
Claims (21)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910603979.4A CN110502948B (en) | 2019-07-05 | 2019-07-05 | Restoration method and device for folding two-dimensional code image and code scanning equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910603979.4A CN110502948B (en) | 2019-07-05 | 2019-07-05 | Restoration method and device for folding two-dimensional code image and code scanning equipment |
Publications (2)
Publication Number | Publication Date |
---|---|
CN110502948A CN110502948A (en) | 2019-11-26 |
CN110502948B true CN110502948B (en) | 2023-01-20 |
Family
ID=68585900
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910603979.4A Active CN110502948B (en) | 2019-07-05 | 2019-07-05 | Restoration method and device for folding two-dimensional code image and code scanning equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110502948B (en) |
Families Citing this family (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111681160B (en) * | 2020-05-28 | 2021-07-06 | 深圳市无虚科技有限公司 | Curved image restoration method, device and equipment and readable storage medium |
CN111681161B (en) * | 2020-05-28 | 2021-05-07 | 深圳市无虚科技有限公司 | Restoration method and device for folded two-dimensional code image and computer readable storage medium |
CN112749576B (en) * | 2021-03-09 | 2022-02-01 | 腾讯科技(深圳)有限公司 | Image recognition method and device, computing equipment and computer storage medium |
Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107679436A (en) * | 2017-09-04 | 2018-02-09 | 华南理工大学 | A kind of image correcting method suitable for Bending Deformation Quick Response Code |
Family Cites Families (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2005316755A (en) * | 2004-04-28 | 2005-11-10 | Nec Electronics Corp | Two-dimensional rectangular code symbol reader and two-dimensional rectangular code symbol reading method |
US8322621B2 (en) * | 2008-12-26 | 2012-12-04 | Datalogic ADC, Inc. | Image-based code reader for acquisition of multiple views of an object and methods for employing same |
EP3104306B2 (en) * | 2015-06-11 | 2023-11-01 | Scantrust SA | Two dimensional barcode |
-
2019
- 2019-07-05 CN CN201910603979.4A patent/CN110502948B/en active Active
Patent Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107679436A (en) * | 2017-09-04 | 2018-02-09 | 华南理工大学 | A kind of image correcting method suitable for Bending Deformation Quick Response Code |
Non-Patent Citations (1)
Title |
---|
基于图像拼接技术的缺损二维条码恢复算法研究;王佳婧等;《计算机与数字工程》;20130720(第07期);全文 * |
Also Published As
Publication number | Publication date |
---|---|
CN110502948A (en) | 2019-11-26 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109409366B (en) | Distorted image correction method and device based on angular point detection | |
JP4630936B1 (en) | Image processing apparatus, image processing method, image processing program, and recording medium recording image processing program | |
US6671399B1 (en) | Fast epipolar line adjustment of stereo pairs | |
CN105279787B (en) | The method that three-dimensional house type is generated based on the floor plan identification taken pictures | |
JP6688277B2 (en) | Program, learning processing method, learning model, data structure, learning device, and object recognition device | |
CN101460937B (en) | Model- based dewarping method and apparatus | |
EP2536122B1 (en) | Image processing method, image processing device and scanner | |
US5974199A (en) | Method for scanning and detecting multiple photographs and removing edge artifacts | |
CN112348815A (en) | Image processing method, image processing apparatus, and non-transitory storage medium | |
CN110502948B (en) | Restoration method and device for folding two-dimensional code image and code scanning equipment | |
CN105488492B (en) | A color image preprocessing method, road recognition method and related device | |
CN105809667A (en) | Shading effect optimization method based on depth camera in augmented reality | |
RU2631765C1 (en) | Method and system of correcting perspective distortions in images occupying double-page spread | |
JP4738469B2 (en) | Image processing apparatus, image processing program, and image processing method | |
JP2012243307A (en) | Method for detecting strain in input image, device for detecting strain in input image and computer readable medium | |
CN110136069B (en) | Text image correction method and device and electronic equipment | |
CN106407983A (en) | Image body identification, correction and registration method | |
Kanter | Color Crack: Identifying Cracks in Glass | |
CN107545223B (en) | Image recognition method and electronic equipment | |
CN108335266B (en) | Method for correcting document image distortion | |
JP6797046B2 (en) | Image processing equipment and image processing program | |
JP4456304B2 (en) | Distortion correction method | |
CN110070490A (en) | Image split-joint method and device | |
WO2022056875A1 (en) | Method and apparatus for segmenting nameplate image, and computer-readable storage medium | |
Abbas | Recovering homography from camera captured documents using convolutional neural networks |
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 | ||
TR01 | Transfer of patent right |
Effective date of registration: 20230202 Address after: 308, Building 10, Shenzhen-Hong Kong Youth Dream Workshop, No. 35, Qianwan 1st Road, Nanshan Street, Qianhai Shenzhen-Hong Kong Cooperation Zone, Shenzhen, Guangdong Province Patentee after: Tufang image technology (Shenzhen) Co.,Ltd. Address before: China Hung Hom Kowloon Hongkong Patentee before: Guo Weiqiang |
|
TR01 | Transfer of patent right |