Identification pattern detection method and device, electronic equipment and readable storage medium
The mask image is extracted by segmenting the model and contour detection is performed. Combined with homography transformation and decoding technology, the missed detection problem of identification pattern detection in complex scenarios is solved, and the scene universality of detection is improved.
Patent Information
- Application Number
- CN202411510081.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-28
- Publication Date
- 2025-02-18
AI Technical Summary
In the prior art, the scenes of identification pattern detection are poor, especially when the image background is complex or the lighting conditions are extreme, the missed detection problem is prone to occur.
By inputting the image to be detected into the segmentation model, the mask image is obtained, and the mask image is contoured, the contour position of the region of interest is determined, the image area is determined in the image to be detected and homographic transformation is performed to obtain the image to be decoded , finally decode the decoded image to be decoded to obtain the identification recognition result.
In the case of complex image background or extreme lighting conditions, the identification pattern can be effectively extracted and detected, which improves the scene universality of identification pattern detection.
Smart Images

Figure CN119478350A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of image processing technology, and in particular, relates to a method, device, electronic device and readable storage medium for detecting a marking pattern. Background Art
[0002] Identification patterns refer to patterns that carry identification content and can be used in scenarios such as augmented reality, robot positioning, and camera calibration. In the traditional method, when detecting identification patterns, adaptive threshold segmentation is used for edge extraction, and connected domain analysis is performed to achieve detection. However, this method has high requirements for image quality and is prone to missed detection when the image background or lighting conditions are complex and extreme, and the scene universality is poor. Summary of the invention
[0003] The embodiments of the present application provide a method, device, electronic device and readable storage medium for detecting an identification pattern, which can solve the problem of poor scene universality of identification pattern detection in related technologies.
[0004] A first aspect of an embodiment of the present application provides a method for detecting an identification pattern, comprising: acquiring an image to be detected; inputting the image to be detected into a segmentation model to obtain a mask image output by the segmentation model, wherein the mask image is used to indicate an area of a target identification pattern in the image to be detected; performing contour detection on the mask image to determine a contour position of an area of interest corresponding to the target identification pattern; determining an image area at the contour position in the image to be detected, and determining an image to be decoded corresponding to the image area; decoding the image to be decoded to obtain a identification recognition result corresponding to the target identification pattern.
[0005] In some embodiments of the first aspect, the performing contour detection on the mask image to determine the contour position of the region of interest corresponding to the target identification pattern includes: performing contour detection on the mask image to obtain a contour detection result; performing quadrilateral fitting on the contour detection result to obtain the region of interest and the contour position; and determining the image to be decoded corresponding to the image area includes: performing a homography transformation on the image area to obtain the image to be decoded.
[0006] In some embodiments of the first aspect, before decoding the image to be decoded, it also includes: for each pixel point in the image to be decoded, on each color channel, calculating the product between the initial channel value and the contrast enhancement coefficient; for each pixel point in the image to be decoded, on each color channel, taking the minimum value between the product and the maximum channel value as the enhanced channel value of the corresponding color channel; and obtaining the image to be decoded with contrast enhanced according to the enhanced channel value.
[0007] In some embodiments of the first aspect, the contrast enhancement coefficient is negatively correlated with the exposure of the image to be decoded.
[0008] In some embodiments of the first aspect, the segmentation model is obtained by training a model to be trained according to a training data set, and the sample images in the training data set are obtained by performing data enhancement on the original data set.
[0009] In some embodiments of the first aspect, the process of acquiring the training data set includes: acquiring the original data set, wherein the original data set includes a background image without a logo pattern and an image of a sample logo pattern; performing image processing on the image of the sample logo pattern according to randomly generated image processing parameters to obtain an enhanced image; overlaying the enhanced image at a random position of the background image to obtain a newly added image; and combining the newly added image with the original data set to obtain the training data set.
[0010] In some embodiments of the first aspect, if there are multiple target identification patterns in the image to be detected, the contour detection is performed on the mask image to determine the contour position of the area of interest corresponding to the target identification pattern, the image area at the contour position is determined in the image to be detected, and the image to be decoded corresponding to the image area is determined, including: performing contour detection on the mask image to determine the contour positions of multiple areas of interest, and the multiple areas of interest correspond one-to-one to multiple target identification patterns; determining the image area at each contour position in the image to be detected to obtain multiple image areas; determining multiple images to be decoded that correspond one-to-one to the multiple image areas; decoding the images to be decoded to obtain the identification recognition result corresponding to the target identification pattern, including: respectively decoding the multiple images to be decoded to obtain the identification recognition result.
[0011] A second aspect of an embodiment of the present application provides a detection device for an identification pattern, comprising: an image acquisition unit, used to acquire an image to be detected; a mask acquisition unit, used to input the image to be detected into a segmentation model to obtain a mask image output by the segmentation model, wherein the mask image is used to indicate an area of a target identification pattern in the image to be detected; a contour extraction unit, used to perform contour detection on the mask image, and determine a contour position of an area of interest corresponding to the target identification pattern; an image determination unit, used to determine an image area at the contour position in the image to be detected, and determine an image to be decoded corresponding to the image area; and a decoding unit, used to decode the image to be decoded, and obtain a identification recognition result corresponding to the target identification pattern.
[0012] A third aspect of an embodiment of the present application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above-mentioned identification pattern detection method when executing the computer program.
[0013] A fourth aspect of an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above-mentioned identification pattern detection method are implemented.
[0014] A fifth aspect of the embodiments of the present application provides a computer program product. When the computer program product is run on an electronic device, the electronic device executes the steps of the above-mentioned identification pattern detection method.
[0015] In an embodiment of the present application, by inputting an image to be detected into a segmentation model to obtain a mask image output by the segmentation model, contour detection is performed on the mask image to determine the contour position of the area of interest corresponding to the target identification pattern, the image area at the contour position is determined in the image to be detected, and the image to be decoded corresponding to the image area is determined, so that the image to be decoded is decoded to obtain a logo recognition result corresponding to the target identification pattern. This method uses the segmentation model to extract the mask image, and uses the mask image instead of threshold segmentation to extract the image area where the target identification pattern is located. Even when the image background or lighting conditions are complex and extreme, the identification pattern can be extracted more effectively, thereby improving the scene universality of identification pattern detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0017] Figure 1 It is a schematic diagram of the implementation process of a detection method of a marking pattern provided in an embodiment of the present application;
[0018] Figure 2 is a schematic diagram of obtaining a mask image provided by an embodiment of the present application;
[0019] Figure 3 is a schematic diagram of obtaining a sample image provided by an embodiment of the present application;
[0020] Figure 4 is a schematic diagram of a specific implementation process of contrast enhancement provided in an embodiment of the present application;
[0021] Figure 5 is a schematic diagram of an image to be decoded after contrast enhancement provided by an embodiment of the present application;
[0022] Figure 6 It is a structural schematic diagram of a detection device for a marking pattern provided in an embodiment of the present application;
[0023] Figure 7 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0024] In order to make the purpose, technical solutions and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work are protected by the present application.
[0025] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.
[0026] In the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0027] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0028] In order to illustrate the technical solution of the present application, a specific embodiment is provided below for illustration.
[0029] Figure 1 The present invention provides a schematic diagram of the implementation process of a detection method for a marking pattern provided in an embodiment of the present invention, which can be applied to an electronic device, which can be a computer, a mobile phone, a robot or other intelligent device.
[0030] Specifically, the above identification pattern detection method may include the following steps S101 to S105.
[0031] Step S101, obtaining an image to be detected.
[0032] In the implementation manner of the present application, the image to be detected is an image that needs to be detected by a logo pattern. The above logo pattern may refer to a QR code, a barcode, an AprilTag code, etc., which is not limited in the present application.
[0033] In some embodiments of the present application, the image to be detected can be acquired by a camera built into the electronic device. For example, when the robot needs to be positioned, the image of the operating environment of the robot can be captured by a built-in camera to obtain the image to be detected. In other embodiments of the present application, the image to be detected can also be input by a user or downloaded via the Internet. This application does not limit the method for acquiring the image to be detected.
[0034] Step S102: input the image to be detected into the segmentation model to obtain a mask image output by the segmentation model.
[0035] The segmentation model is a pre-trained model for generating a mask image of the image to be detected. The mask image can be used to indicate the area of the target identification pattern in the image to be detected, so as to extract the image area where the target identification pattern in the image to be detected is located. The target identification pattern is also the identification pattern that appears in the image to be detected.
[0036] Specifically, the mask image can be a binary image or a Boolean image of the same size as the image to be detected. In the mask image, the region of interest corresponding to the target identification pattern and the region of no interest (the region of no interest corresponds to the region outside the target identification pattern) can be distinguished by different pixel values. For example, the region of interest corresponding to the target identification pattern is marked as 1 (or True), and the region of no interest is marked as 0 (or False), so that the position of the region of interest in the mask image can represent the position of the image region where the target identification pattern is located in the image to be detected.
[0037] For example, please refer to Figure 2 The segmentation model detects the identification pattern code on the image to be detected, and when the identification pattern code is detected, the mask image of the identification pattern code is returned. Figure 2 In the figure, the white area is the region of interest corresponding to the target identification pattern, and the black area is the region of no interest.
[0038] Step S103: Perform contour detection on the mask image to determine the contour position of the region of interest corresponding to the target identification pattern.
[0039] Since the region of interest and the region of non-interest corresponding to the target identification pattern in the mask image can be distinguished by different pixel values, contour detection is performed on the mask image to detect the contour of the region of interest in the mask image, and obtain the contour position of the region of interest corresponding to the target identification pattern. The contour position can be expressed as the position coordinates of each contour point on the contour, or as the position coordinates of the contour center and contour corner points, etc., and this application does not limit this. This application does not limit the method of contour detection, for example, the edge area can be determined by methods such as Sobel operator, Prewitt operator and Canny operator.
[0040] Step S104: determine an image region at a contour position in the image to be detected, and determine an image to be decoded corresponding to the image region.
[0041] In the implementation manner of the present application, the image to be decoded refers to an image used to decode and obtain identification content. Since the contour position of the region of interest in the mask image is the same as the contour position of the target identification pattern in the image to be detected, the image area at the contour position can be determined in the image to be detected, and the image area is also the image area of the target identification pattern. Then, the image area of the target identification pattern in the image to be detected, or the image obtained by further processing the image area of the target identification pattern, can be used as the image to be decoded.
[0042] Step S105 , decoding the image to be decoded to obtain a logo recognition result corresponding to the target logo pattern.
[0043] The decoding method can be selected according to the type of identification pattern, and the decoding algorithm used can be implemented according to the existing decoding algorithm. For example, when the target identification pattern is an AprilTag code, since the AprilTag code expresses different codes through a black and white pixel matrix, based on the pixel value of each pixel in the pixel matrix within the target identification pattern, the identification content carried by the target identification pattern can be decoded to obtain the identification recognition result.
[0044] In an embodiment of the present application, by inputting an image to be detected into a segmentation model to obtain a mask image output by the segmentation model, contour detection is performed on the mask image to determine the contour position of the area of interest corresponding to the target identification pattern, the image area at the contour position is determined in the image to be detected, and the image to be decoded corresponding to the image area is determined, so that the image to be decoded is decoded to obtain a logo recognition result corresponding to the target identification pattern. This method uses the segmentation model to extract the mask image, and uses the mask image instead of threshold segmentation to extract the image area where the target identification pattern is located. Even when the image background or lighting conditions are complex and extreme, the identification pattern can be extracted more effectively, thereby improving the scene universality of identification pattern detection.
[0045] In some embodiments of the present application, the segmentation model is obtained by training a model to be trained according to a training data set, and the sample images in the training data set are obtained by performing data enhancement on the original data set.
[0046] Specifically, the sample images in the training data set may include images of the original data set and images obtained by performing data enhancement on the images of the original data set. Through data enhancement, the training data set can be expanded to make the training data set more balanced, thereby improving the generalization ability of the segmentation model.
[0047] In some embodiments of the present application, the process of acquiring a training data set may include: acquiring an original data set, the original data set including a background image without a logo pattern and an image of a sample logo pattern; overlaying the image of the sample logo pattern at a random position of the background image to obtain a newly added image; and combining the newly added image with the original data set to obtain a training data set.
[0048] Furthermore, in some embodiments of the present application, the process of acquiring a training data set may include: acquiring the original data set, wherein the original data set includes a background image without a logo pattern and an image of a sample logo pattern; performing image processing on the image of the sample logo pattern according to randomly generated image processing parameters to obtain an enhanced image; overlaying the enhanced image at a random position of the background image to obtain a newly added image; and combining the newly added image with the original data set to obtain a training data set.
[0049] The image of the sample identification pattern can be obtained by segmenting the image containing the identification pattern, or can be directly generated according to the coding format of the sample identification pattern, which is not limited in this application. Both the background image without the identification pattern and the image containing the identification pattern can be collected in real application scenarios to meet application requirements.
[0050] Image processing parameters may include, but are not limited to: scaling parameters, brightness adjustment parameters, and blur operation parameters. Among them, the scaling parameters can be used to randomly scale the image in the horizontal and vertical directions according to the scaling ratio to increase the adaptability of the model to scale changes. The brightness adjustment parameters can be used to adjust the brightness of the image to increase the robustness of the model to color changes. The blur operation is used to reduce the details and edges in the image to make the image look more blurred, and the blur operation parameters are used to control the blur degree of the image during the blur operation.
[0051] For example, Figure 3As shown, first, a sufficient number of images containing identification pattern codes are collected in real application scenarios as data sets for model training, and the identification pattern code part is cropped from the acquired real scene image (for example, the area where the identification pattern code is located is cropped using the mask annotation result) to obtain an image of the identification pattern. Secondly, a large number of background images without identification pattern codes are collected. For a background image, one is randomly selected from all the images of the identification pattern, and it is pasted on a random position of the background image to obtain a newly added image. Before pasting, random data enhancement operations can also be performed on the image of the identification pattern, including but not limited to random scaling, random brightness adjustment, and random blur operations. Repeat the above process for all background images until the identification pattern code is pasted on each background image, and then add the images of the original data set to form a training data set.
[0052] Based on the training data set, the existing model training methods such as gradient descent method can be used to train the training model to obtain a segmentation model. Then, the image to be detected is input into the segmentation model to obtain a mask image output by the segmentation model.
[0053] In some embodiments of the present application, contour detection is performed on the mask image to determine the contour position of the region of interest corresponding to the target identification pattern, which may include: performing contour detection on the mask image to obtain a contour detection result, and performing quadrilateral fitting on the contour detection result to obtain the region of interest and the contour position.
[0054] Correspondingly, determining the image to be decoded corresponding to the image region may include: performing a homography transformation on the image region to obtain the image to be decoded.
[0055] Specifically, the contour detection result can characterize the contour of the area in the mask image corresponding to the target identification pattern. Since the target identification pattern is a quadrilateral pattern, it can be known from the principle of perspective transformation that the quadrilateral target identification pattern is still a quadrilateral after the perspective transformation, but the contour detection result is sometimes not a strict quadrilateral area. Therefore, the contour detection result can be quadrilateral fitting, and the obtained quadrilateral area is used as the area of interest, and its contour position is obtained. The contour position of the quadrilateral area can characterize the original posture of the target identification pattern in the image to be detected. Through homography transformation, the image area of the target identification pattern in the image to be detected is adjusted to the standard posture of a regular quadrilateral to obtain the image to be decoded.
[0056] Compared with the traditional method of finding the fitted quadrilateral by straight line detection, the mask-based contour extraction is more advantageous for processing complex environments. Therefore, the implementation of the present application can further improve the universality of the scene. Moreover, decoding the image to be decoded based on the standard posture of the regular quadrilateral is also conducive to improving the decoding accuracy.
[0057] In some embodiments of the present application, before decoding the image to be decoded, the process may further include: performing contrast enhancement on the image to be decoded. The purpose of contrast enhancement is to increase the difference between black and white pixels in the image, thereby enhancing the decodability of the logo pattern and avoiding decoding failure caused by too bright or too dark light.
[0058] The contrast enhancement method can be selected according to actual conditions.
[0059] In some embodiments of the present application, Figure 4 As shown, the above-mentioned contrast enhancement of the image to be decoded may include: step S401 to step S403.
[0060] Step S401: For each pixel in the image to be decoded, on each color channel, the product between the initial channel value and the contrast enhancement coefficient is calculated.
[0061] Step S402: For each pixel in the image to be decoded, on each color channel, the minimum value between the product and the maximum channel value is used as the enhanced channel value of the corresponding color channel.
[0062] Step S403: obtaining a contrast-enhanced image to be decoded according to the enhanced channel values.
[0063] The initial channel value is the channel value of each pixel in the image to be decoded.
[0064] The contrast enhancement coefficient can be set according to actual conditions, and the value range can be between 0.5 and 3. The contrast enhancement coefficients of different color channels can be the same or different.
[0065] Specifically, step S401 and step S402 can be expressed by the following formula:
[0066] R'(x,y)=min(α*R(x,y),255);
[0067] G'(x,y)=min(α*G(x,y),255);
[0068] B'(x,y)=min(α*B(x,y),255);
[0069] Where R, G, B represent the red, green and blue channels respectively, α represents the contrast enhancement coefficient, R(x,y), G(x,y), B(x,y) represent the initial channel values, 255 represents the maximum channel value, min represents the minimum value, and R'(x,y), G'(x,y), B'(x,y) represent the enhanced channel values.
[0070] In some embodiments of the present application, the contrast enhancement coefficient is negatively correlated with the exposure of the image to be decoded. For a dark image to be decoded, the contrast enhancement coefficient may be greater than 1, and for an overexposed image to be decoded, the contrast enhancement coefficient may be less than 1.
[0071] The effect of contrast enhancement is as follows Figure 5 As shown, it can be seen Figure 5 The upper edge of the identification pattern code of the image to be decoded in the image is gray under the influence of the shadow, while in the image to be decoded after the contrast is enhanced, the influence of the shadow is greatly weakened.
[0072] Correspondingly, a logo recognition result can be obtained for the image to be decoded after contrast enhancement.
[0073] In some embodiments of the present application, the number of target identification patterns in the image to be detected may be one or more. If the number of target identification patterns in the image to be detected is multiple, contour detection is performed on the mask image to determine the contour position of the region of interest corresponding to the target identification pattern, an image region at the contour position is determined in the image to be detected, and an image to be decoded corresponding to the image region is determined, which may include: contour detection is performed on the mask image to determine the contour positions of multiple regions of interest, the multiple regions of interest correspond one-to-one to multiple target identification patterns; the image region at each contour position is determined in the image to be detected to obtain multiple image regions; and multiple images to be decoded corresponding one-to-one to the multiple image regions are determined.
[0074] Correspondingly, decoding the image to be decoded to obtain the identification result corresponding to the target identification pattern may include: decoding a plurality of images to be decoded respectively to obtain the identification result.
[0075] Specifically, if there are multiple target identification patterns in the image to be detected, one mask image can be used to extract image areas of multiple target identification patterns, and each image area of the target identification pattern will be processed independently to obtain an image to be decoded, and then enhanced and decoded independently. In this way, the solution provided by the present application can be used to detect images with a single identification pattern, and can also be used to detect images with multiple identification patterns, with higher universality.
[0076] It should be noted that, for the sake of simplicity of description, the aforementioned method embodiments are all expressed as a series of action combinations, but those skilled in the art should know that the present application is not limited to the described order of actions, because according to the present application, certain steps can be performed in other orders.
[0077] like Figure 6FIG. 6 is a schematic structural diagram of a detection device 600 for a marking pattern provided in an embodiment of the present application. The detection device 600 for a marking pattern is configured on an electronic device.
[0078] Specifically, the detection device 600 for the identification pattern may include:
[0079] An image acquisition unit 601 is used to acquire an image to be detected;
[0080] A mask acquisition unit 602 is used to input the image to be detected into a segmentation model to obtain a mask image output by the segmentation model, wherein the mask image is used to indicate an area of the target identification pattern in the image to be detected;
[0081] The contour extraction unit 603 is used to perform contour detection on the mask image to determine the contour position of the region of interest corresponding to the target identification pattern;
[0082] An image determination unit 604 is used to determine an image region at the contour position in the image to be detected, and determine an image to be decoded corresponding to the image region;
[0083] The decoding unit 605 is used to decode the image to be decoded to obtain a logo recognition result corresponding to the target logo pattern.
[0084] In some embodiments of the present application, the contour extraction unit 603 may be specifically used to: perform contour detection on the mask image to obtain a contour detection result; perform quadrilateral fitting on the contour detection result to obtain the region of interest and the contour position. The image determination unit 604 may be specifically used to: perform homography transformation on the image region to obtain the image to be decoded.
[0085] In some embodiments of the present application, the detection device 600 for the identification pattern may further include an enhancement unit, which is used to: for each pixel point in the image to be decoded, on each color channel, calculate the product between the initial channel value and the contrast enhancement coefficient; for each pixel point in the image to be decoded, on each color channel, take the minimum value between the product and the maximum channel value as the enhanced channel value of the corresponding color channel; and obtain the image to be decoded with contrast enhanced according to the enhanced channel value.
[0086] In some embodiments of the present application, the contrast enhancement coefficient is negatively correlated with the exposure of the image to be decoded.
[0087] In some embodiments of the present application, the segmentation model is obtained by training a model to be trained according to a training data set, and the sample images in the training data set are obtained by performing data enhancement on the original data set.
[0088] In some embodiments of the present application, the detection device 600 for the identification pattern may further include a training unit, which is used to: obtain the original data set, wherein the original data set includes a background image without the identification pattern and an image of the sample identification pattern; perform image processing on the image of the sample identification pattern according to randomly generated image processing parameters to obtain an enhanced image; overlay the enhanced image at a random position of the background image to obtain a newly added image; and combine the newly added image with the original data set to obtain the training data set.
[0089] In some embodiments of the present application, if there are multiple target identification patterns in the image to be detected, the above-mentioned contour extraction unit 603 can be specifically used to: perform contour detection on the mask image, determine the contour positions of multiple regions of interest, and the multiple regions of interest correspond one-to-one to the multiple target identification patterns; the image determination unit 604 can be specifically used to: determine the image area at each contour position in the image to be detected to obtain multiple image areas; determine multiple images to be decoded that correspond one-to-one to the multiple image areas; the decoding unit 605 can be specifically used to: respectively decode the multiple images to be decoded to obtain the identification recognition result.
[0090] It should be noted that, for the convenience and simplicity of description, the specific working process of the above-mentioned detection device 600 for the identification pattern can be referred to Figures 1 to 5 The corresponding process of the method will not be repeated here.
[0091] like Figure 7 , which is a schematic diagram of an electronic device provided in an embodiment of the present application. Specifically, the electronic device 7 may include: a processor 70, a memory 71, and a computer program 72 stored in the memory 71 and executable on the processor 70, such as a detection program for a logo pattern. When the processor 70 executes the computer program 72, the steps in the above-mentioned detection method for a logo pattern are implemented, such as Figure 1 Alternatively, when the processor 70 executes the computer program 72, the functions of each module / unit in the above-mentioned device embodiments are realized, for example Figure 6 The functions of the image acquisition unit 601, the mask acquisition unit 602, the contour extraction unit 603, the image determination unit 604 and the decoding unit 605 are shown.
[0092] The computer program may be divided into one or more modules / units, which are stored in the memory 71 and executed by the processor 70 to complete the present application. The one or more modules / units may be a series of computer program instruction segments capable of completing specific functions, which are used to describe the execution process of the computer program in the electronic device.
[0093] For example, the computer program can be divided into: an image acquisition unit, a mask acquisition unit, a contour extraction unit, an image determination unit and a decoding unit. The specific functions of each unit are as follows: an image acquisition unit, used to acquire an image to be detected; a mask acquisition unit, used to input the image to be detected into a segmentation model to obtain a mask image output by the segmentation model, wherein the mask image is used to indicate the area of the target identification pattern in the image to be detected; a contour extraction unit, used to perform contour detection on the mask image to determine the contour position of the area of interest corresponding to the target identification pattern; an image determination unit, used to determine the image area at the contour position in the image to be detected, and determine the image to be decoded corresponding to the image area; a decoding unit, used to decode the image to be decoded to obtain the identification result corresponding to the target identification pattern.
[0094] The electronic device may include, but is not limited to, a processor 70 and a memory 71. Those skilled in the art will appreciate that Figure 7 These are merely examples of electronic devices and do not constitute a limitation of the electronic device. The electronic device may include more or fewer components than those shown in the figure, or a combination of certain components, or different components. For example, the electronic device may also include input and output devices, network access devices, buses, etc.
[0095] The processor 70 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), off-the-shelf programmable gate arrays or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0096] The memory 71 may be an internal storage unit of the electronic device, such as a hard disk or memory of the electronic device. The memory 71 may also be an external storage device of the electronic device, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the electronic device. Furthermore, the memory 71 may also include both an internal storage unit of the electronic device and an external storage device. The memory 71 is used to store the computer program and other programs and data required by the electronic device. The memory 71 may also be used to temporarily store data that has been output or is to be output.
[0097] It should be noted that, for the convenience and brevity of description, the structure of the above electronic device can also refer to the specific description of the structure in the method embodiment, which will not be repeated here.
[0098] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0099] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0100] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0101] In the embodiments provided in the present application, it should be understood that the disclosed devices / electronic devices and methods can be implemented in other ways. For example, the device / electronic device embodiments described above are merely schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0102] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0103] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0104] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0105] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A method for detecting a marking pattern, characterized in that: include: Acquire the image to be detected; Inputting the image to be detected into a segmentation model to obtain a mask image output by the segmentation model, wherein the mask image is used to indicate an area of a target identification pattern in the image to be detected; Performing contour detection on the mask image to determine the contour position of the region of interest corresponding to the target identification pattern; Determine an image area at the contour position in the image to be detected, and determine an image to be decoded corresponding to the image area; The image to be decoded is decoded to obtain a logo recognition result corresponding to the target logo pattern.
2. The method for detecting a marking pattern according to claim 1, wherein: The performing contour detection on the mask image to determine the contour position of the region of interest corresponding to the target identification pattern includes: Performing contour detection on the mask image to obtain a contour detection result; Performing quadrilateral fitting on the contour detection result to obtain the region of interest and the contour position; The determining the image to be decoded corresponding to the image area comprises: Performing homography transformation on the image region to obtain the image to be decoded.
3. The method for detecting a marking pattern according to claim 1, wherein: Before decoding the image to be decoded, the method further includes: For each pixel in the image to be decoded, on each color channel, calculating the product between the initial channel value and the contrast enhancement coefficient; For each pixel in the image to be decoded, on each color channel, taking the minimum value between the product and the maximum channel value as the enhanced channel value of the corresponding color channel; According to the enhanced channel value, the to-be-decoded image with enhanced contrast is obtained.
4. The method for detecting a marking pattern according to claim 3, wherein: The contrast enhancement coefficient is negatively correlated with the exposure of the image to be decoded.
5. The method for detecting a marking pattern according to any one of claims 1 to 4, characterized in that: The segmentation model is obtained by training a model to be trained according to a training data set, and the sample images in the training data set are obtained by performing data enhancement on the original data set.
6. The method for detecting a marking pattern according to claim 5, characterized in that: The process of obtaining the training data set includes: Acquire the original data set, wherein the original data set includes a background image without a logo pattern and an image of a sample logo pattern; Performing image processing on the image of the sample identification pattern according to randomly generated image processing parameters to obtain an enhanced image; Overlaying the enhanced image at a random position of the background image to obtain a newly added image; The newly added image is combined with the original data set to obtain the training data set.
7. The method for detecting a marking pattern according to any one of claims 1 to 4, characterized in that: If there are multiple target identification patterns in the image to be detected, the contour detection is performed on the mask image to determine the contour position of the region of interest corresponding to the target identification pattern, an image area at the contour position is determined in the image to be detected, and an image to be decoded corresponding to the image area is determined, including: Performing contour detection on the mask image to determine contour positions of a plurality of regions of interest, wherein the plurality of regions of interest correspond one-to-one to a plurality of target identification patterns; Determine the image region at each contour position in the image to be detected to obtain a plurality of image regions; Determine a plurality of the to-be-decoded images corresponding one to one to the plurality of image regions; The decoding of the to-be-decoded image to obtain a logo recognition result corresponding to the target logo pattern includes: The plurality of images to be decoded are decoded respectively to obtain the identification result.
8. A detection device for a logo pattern, characterized in that: include: An image acquisition unit, used for acquiring an image to be detected; A mask acquisition unit, used for inputting the image to be detected into a segmentation model to obtain a mask image output by the segmentation model, wherein the mask image is used to indicate an area of a target identification pattern in the image to be detected; A contour extraction unit, used to perform contour detection on the mask image to determine the contour position of the region of interest corresponding to the target identification pattern; An image determination unit, configured to determine an image region at the contour position in the image to be detected, and determine an image to be decoded corresponding to the image region; The decoding unit is used to decode the image to be decoded to obtain a logo recognition result corresponding to the target logo pattern.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the identification pattern detection method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the identification pattern detection method according to any one of claims 1 to 7 are implemented.