Irregular code scanning and recognition method, device, equipment and storage medium
By determining the size of the target frame data stream and obtaining the punctuation coordinates of the characteristic code area to generate a mask diagram, the problem of difficulty in identifying the characteristic code in the prior art is solved, and the accurate identification of the characteristic code on the product label is achieved, and the recognition efficiency is improved.
Patent Information
- Application Number
- CN202411230495.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-04
- Publication Date
- 2024-12-31
- Estimated Expiration
- 2044-09-04
AI Technical Summary
The prior art is difficult to identify the distinctive code on the product label, making it difficult to obtain product information by scanning the code.
By determining the target frame data stream size based on the screen parameters of the code scanning device and the frame data stream parameters, obtaining the punctuation coordinates of the profile code area, generating a mask diagram, and processing the camera frame data stream through the mask diagram to identify the profile code.
It realizes accurate identification of the distinctive code on the product label, and improves the scanning and identification efficiency and accuracy of the distinctive code.
Smart Images

Figure CN118839710B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of code scanning technology, and in particular to a method, device, equipment and storage medium for scanning and identifying special-shaped codes. Background Art
[0002] In order to increase the anti-counterfeiting performance of product labels and give product labels certain specific design elements, manufacturers currently often set product identification codes in special graphics on product labels, so that the shape of the product identification code is consistent with the shape of the special graphics. Product identification codes of this shape are also called special-shaped codes; users can scan the special-shaped codes with their mobile phones to obtain product information.
[0003] However, the use of special-shaped codes on product labels is relatively new, resulting in a lack of technology for scanning and identifying special-shaped codes, making it difficult to identify special-shaped codes on product labels. Summary of the invention
[0004] In order to facilitate the recognition of special-shaped codes, embodiments of the present application provide a method, device, equipment and storage medium for scanning and recognizing special-shaped codes.
[0005] In a first aspect, an embodiment of the present application provides a method for scanning and identifying a special-shaped code, comprising:
[0006] Determine the target frame data stream size based on the screen parameters of the code scanning device and the frame data stream parameters;
[0007] Acquire punctuation coordinates of the heteromorphic code area based on the target frame data stream size;
[0008] Generate a mask image based on the target frame data stream size and the punctuation coordinates of the heteromorphic code area;
[0009] The camera frame data stream is processed based on the mask image to obtain a special-shaped code, and the special-shaped code is recognized to obtain a recognition result.
[0010] In a second aspect, an embodiment of the present application provides a device for scanning and identifying a special-shaped code, comprising:
[0011] A size determination module, used to determine the target frame data stream size based on the screen parameters of the code scanning device and the frame data stream parameters;
[0012] An area acquisition module, used for acquiring punctuation coordinates of the heterogeneous code area based on the target frame data stream size;
[0013] A mask generation module, used for generating a mask image based on the target frame data stream size and the punctuation coordinates of the heteromorphic code area;
[0014] The code image recognition module is used to process the camera frame data stream based on the mask image to obtain a special-shaped code, and recognize the special-shaped code to obtain a recognition result.
[0015] In a third aspect, an embodiment of the present application provides a computer device, the computer device comprising a memory and a processor, the memory storing a computer program, and the processor implementing the steps in the above method when executing the computer program.
[0016] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, which implements the steps in the above-mentioned method when executed by a processor.
[0017] In a fifth aspect, the embodiments of the present application further provide a computer program product, wherein the computer program product includes a computer program, and when the computer program is executed by a processor, the steps in any of the above method embodiments are implemented.
[0018] The above-mentioned special-shaped code scanning and recognition method, device, equipment and storage medium determine the target frame data stream size based on the screen parameters of the scanning device and the frame data stream parameters; obtain the punctuation coordinates of the special-shaped code area based on the target frame data stream size; generate a mask image based on the target frame data stream size and the punctuation coordinates of the special-shaped code area; process the camera frame data stream based on the mask image to obtain the special-shaped code, and recognize the special-shaped code to obtain the recognition result; through the implementation of the above-mentioned method, by calculating the target frame data stream size and the punctuation coordinates of the special-shaped code area, it is convenient to further calculate the mask image used to indicate the area where the special-shaped code is located on the target frame data stream, and then re-confirm the special-shaped code from the target frame data stream through the mask image, so as to facilitate the subsequent further recognition of the special-shaped code; this facilitates the recognition of the special-shaped code on the product label (corresponding to the camera frame data stream).
[0019] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present application, nor is it intended to limit the scope of the present application. Other features of the present application will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.
[0021] Figure 1 This is an application environment diagram of the method for scanning and identifying special-shaped codes in one embodiment of the present application;
[0022] Figure 2 This is a flow chart of a method for scanning and identifying a special-shaped code provided in Example 1 of the present application;
[0023] Figure 3 This is a schematic diagram for reflecting frame data stream parameters provided in Embodiment 1 of the present application;
[0024] Figure 4 This is a flow chart of a method for scanning and identifying a special-shaped code provided in Embodiment 2 of the present application;
[0025] Figure 5 This is a flow chart of a method for scanning and identifying a special-shaped code provided in Example 3 of the present application;
[0026] Figure 6 A flowchart of a method for scanning and identifying a special-shaped code provided in the fourth embodiment of the present application;
[0027] Figure 7 A schematic diagram of a process for generating contour coordinates of a special-shaped code provided in the fourth embodiment of the present application;
[0028] Figure 8 This is a flow chart of a method for scanning and identifying a special-shaped code provided in Embodiment 5 of the present application;
[0029] Fig. 9 This is a flow chart of a method for scanning and identifying a special-shaped code provided in Example 6 of the present application;
[0030] Fig.10 This is a schematic diagram of the structure of a device for scanning and identifying special-shaped codes provided in one embodiment of the present application;
[0031] Fig.11 A schematic diagram of the structure of a computer device provided in one embodiment of the present application;
[0032] Fig.12 An internal structure diagram of a computer-readable storage medium provided in one embodiment of the present application. DETAILED DESCRIPTION
[0033] In order to make the purpose, technical solution and advantages of the present disclosure more clear, the present disclosure 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 disclosure and are not used to limit the present disclosure.
[0034] It should be noted that the terms "first", "second", etc. in the specification and claims of this article and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of this article described here can be implemented in an order other than those illustrated or described here. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, device, product or equipment that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or equipment.
[0035] In this article, the term "and / or" is only a description of the association relationship between related objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the related objects before and after are in an "or" relationship.
[0036] To solve the above problems, the present disclosure provides a method for scanning and recognizing special-shaped codes, which can be applied to Figure 1 In the application environment shown. Among them, the terminal 102 communicates with the server 104 through the network. The data storage system can store the data that the server 104 needs to process. The data storage system can be integrated on the server 104, or it can be placed on the cloud or other network servers. Among them, the terminal 102 can be but is not limited to various personal computers, laptops, smart phones, tablets, Internet of Things devices and portable wearable devices. The Internet of Things devices can be smart speakers, smart TVs, smart air conditioners, smart car-mounted devices, etc. Portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. The server 104 can be implemented with an independent server or a server cluster consisting of multiple servers.
[0037] Embodiment 1
[0038] Figure 2 This is a flowchart of a method for scanning and identifying a special-shaped code provided in Example 1 of the present application, refer to Figure 2 The method may be performed by a device for performing the method, and the device may be implemented by software and / or hardware. The method includes:
[0039] S110. Determine a target frame data stream size based on screen parameters of the code scanning device and frame data stream parameters.
[0040] The code scanning device includes but is not limited to smart devices with camera functions, such as smart phones and smart tablets; the screen parameters of the code scanning device include but are not limited to the screen size, which includes the screen width screenwith and the screen height screenheight. The frame data stream parameters are multiple frame data stream sizes preset by the code scanning device, such as Figure 3 The multiple "camera frame data stream sizes" shown in the figure; the program built into the code scanning device can select one of the frame data stream sizes, so that the size of the frame data stream generated by the code scanning device when shooting is the selected frame data stream size. For example, assuming that the frame data stream size selected by the user on the code scanning device is , then the size of the frame data stream generated by the subsequent user shooting with a code scanning device is ; When the barcode scanning device is shooting, it will generate multiple continuous image frames, and the frame data stream is also the multiple continuous image frames; for example, when the barcode scanning device shoots a product label with a five-pointed star shape, it will generate a frame data stream related to the product label. The target frame data stream size is the frame data stream size that can make the size of the frame data stream generated by shooting fill the screen of the barcode scanning device; the target frame data stream size can be obtained by processing the barcode scanning device screen parameters and frame data stream parameters.
[0041] Specifically, the code scanning device obtains the code scanning device screen parameters and frame data stream parameters, and processes the code scanning device screen parameters and frame data stream parameters to obtain a target frame data stream size.
[0042] S120: Acquire punctuation coordinates of the heteromorphic code area based on the target frame data stream size.
[0043] Among them, the camera frame data stream is a frame data stream generated when the barcode scanning device shoots the target where the special-shaped code is located. It should be noted that the image format of the camera frame data stream initially obtained by the barcode scanning device is NV21 format. After the barcode scanning device obtains the camera frame data stream in NV21 format, the camera frame data stream in NV21 format is converted into a camera frame data stream in RGB format, thereby realizing the image format conversion of the camera frame data stream, so as to facilitate the subsequent determination of the special-shaped code therein according to the camera frame data stream in RGB format; in this embodiment, the target where the special-shaped code is located is specifically a product label with a special-shaped code, such as a product label with a five-pointed star-shaped special-shaped code; the punctuation coordinates of the special-shaped code area are the coordinates of the area where the special-shaped code is located in the camera frame data stream; the punctuation coordinates of the special-shaped code area can be obtained by processing the camera frame data stream obtained by scanning the barcode scanning device according to the target frame data stream size.
[0044] Specifically, the punctuation coordinates of the heteromorphic code area are obtained by processing the acquired camera frame data stream according to the target frame data stream size.
[0045] S130: Generate a mask image based on the target frame data stream size and the punctuation coordinates of the heteromorphic code area.
[0046] Among them, the mask image is an image with a size consistent with the size of the target frame data stream, in which a black area is generated by the target frame data stream size and the punctuation coordinates of the shaped code area, and the shape, size and position of the black area are completely consistent with the punctuation coordinates of the shaped code area determined in the camera frame data stream; the mask image can be generated by processing the target frame data stream size and the punctuation coordinates of the shaped code area.
[0047] Specifically, the target frame data stream size and the punctuation coordinates of the heteromorphic code area are processed to generate a mask image.
[0048] S140, processing the camera frame data stream based on the mask image to obtain a special-shaped code, and recognizing the special-shaped code to obtain a recognition result.
[0049] Among them, the special-shaped code is an image of the special-shaped code set on the target photographed by the scanning device. The special-shaped code can be obtained by processing the camera frame data stream through the mask image; the scanning device can recognize the generated special-shaped code to obtain a corresponding result, that is, a recognition result.
[0050] Specifically, the code scanning device processes the camera frame data stream through the mask to obtain the special-shaped code. Further, the code scanning device recognizes the special-shaped code to obtain the corresponding recognition result.
[0051] It should be noted that, in this embodiment, the target frame data stream size is determined based on the screen parameters of the code scanning device and the frame data stream parameters; the punctuation coordinates of the shaped code area are obtained based on the target frame data stream size; a mask image is generated based on the target frame data stream size and the punctuation coordinates of the shaped code area; the camera frame data stream is processed based on the mask image to obtain the shaped code, and the shaped code is recognized to obtain a recognition result; through the implementation of the above method, by calculating the target frame data stream size and the punctuation coordinates of the shaped code area, it is convenient to further calculate the mask image for indicating the area where the shaped code is located on the target frame data stream, and then the shaped code is reconfirmed from the target frame data stream through the mask image, so as to facilitate the subsequent further recognition of the shaped code; this facilitates the recognition of the shaped code on the camera frame data stream.
[0052] Embodiment 2
[0053] Figure 4 This is a flowchart of a method for scanning and identifying a special-shaped code provided in Example 2 of this application, refer to Figure 4 The method optimizes the "determining the target frame data stream size based on the screen parameters of the code scanning device and the frame data stream parameters" in the first embodiment; it should be noted that for the parts not described in detail in this embodiment, reference can be made to the descriptions of other embodiments. The method includes:
[0054] S211. Calculate the screen ratio and the ratio deviation value based on the acquired screen parameters of the code scanning device and a preset deviation coefficient.
[0055] Among them, in this embodiment, the screen parameters of the code scanning device specifically include the screen width screenwith and the screen height screenheight, the screen ratio is the ratio of the screen width screenwith to the screen height screenheight, and the screen ratio is recorded as screenratio; the deviation coefficient is a preset value obtained based on historical experience data. In this embodiment, the deviation coefficient is preset to 5%; the ratio deviation value is the product of the screen ratio and the deviation coefficient , and the proportional deviation value is recorded as deviation.
[0056] It should be noted that the camera frame data stream size captured by the code scanning device may not be completely equal to the screen size of the code scanning device, and the aspect ratio of the frame data stream size of most frame data stream parameters ( Figure 3 The frame data stream size aspect ratio (shown in the figure) is also not equal to the screen aspect ratio (screen ratio screenratio) of the code scanning device. Therefore, a proportional deviation value needs to be set to allow the frame data stream size to exceed the screen size of the code scanning device. If the camera frame data stream with a size exceeding the screen aspect ratio needs to be used for code scanning and recognition in the future, the image data that exceeds the screen size range needs to be cut off from the camera frame data stream. According to historical experience, the proportional deviation value is best at 5%, that is, when the camera frame data stream size exceeds the screen size by 5%, cutting the image data that exceeds the screen size by 5% will not have an adverse effect on code scanning and recognition.
[0057] Specifically, the ratio of the screen width screenwith to the screen height screenheight in the screen parameters of the code scanning device is calculated to obtain the screen ratio screenratio; further, the product of the screen ratio screenratio and a preset deviation coefficient is calculated to obtain the ratio deviation value.
[0058] S212: Determine a target frame data stream size based on the screen ratio, the ratio deviation value, and the frame data stream parameters.
[0059] The frame data stream parameters include a plurality of preset frame data stream sizes (such as Figure 3 ), each frame data stream size has a corresponding frame data stream width and frame data stream height, for example, Figure 3 shown Take this frame data stream size as an example, its frame data stream width is 3072, and its frame data stream height is 4090; the frame data stream width and frame data stream height corresponding to the frame data stream size can be further calculated to obtain the frame data stream aspect ratio corresponding to the frame data stream size (such as Figure 3 Frame data stream size aspect ratio as shown) Figure 3 As shown, The frame data stream aspect ratio corresponding to this frame data stream size is frame data stream width / frame data stream height = =0.75; it can be seen that the frame data stream aspect ratio corresponding to each frame data stream size in the frame data stream parameters can be calculated through the frame data stream parameters; further, by comparing the frame data stream aspect ratio, the screen ratio and the ratio deviation value, the target frame data stream size can be determined, and the target frame data stream size is the frame data stream size in the frame data stream parameters that is closer to the screen size.
[0060] Specifically, the frame data stream aspect ratio corresponding to each frame data stream size in the frame data stream parameters is calculated, and then each frame data stream aspect ratio is compared with the screen ratio and the ratio deviation value, so as to determine the target frame data stream size from the frame data stream parameters.
[0061] It should be noted that the size and aspect ratio of the camera frame data stream of different targets scanned by the scanning device are different; the camera frame data stream corresponding to the target frame data stream size can fill the screen of the scanning device, can adapt to camera frame data streams of different sizes and aspect ratios to the maximum extent, and can also better fit the optimal visual experience of users when using it, that is, the content seen by the user is the content processed by the scanning recognition.
[0062] S220: Acquire punctuation coordinates of the heteromorphic code area based on the target frame data stream size.
[0063] S230: Generate a mask image based on the target frame data stream size and the punctuation coordinates of the heteromorphic code area.
[0064] S240: Process the camera frame data stream based on the mask image to obtain a special-shaped code, and recognize the special-shaped code to obtain a recognition result.
[0065] Embodiment 3
[0066] Figure 5 This is a flowchart of a method for scanning and identifying a special-shaped code provided in Example 3 of this application, refer to Figure 5 The method optimizes the "determining the target frame data stream size based on the screen ratio, the ratio deviation value and the frame data stream parameter" in the second embodiment; it should be noted that, for the part not described in detail in this embodiment, reference can be made to the description of other embodiments, and the method includes:
[0067] S311. Calculate the screen ratio and the ratio deviation value based on the acquired screen parameters of the code scanning device and the preset deviation coefficient.
[0068] S3121. Calculate the frame data stream size ratio corresponding to each frame data stream size in the frame data stream parameters.
[0069] It should be noted that the frame data stream parameters include multiple frame data stream sizes.
[0070] Among them, exemplary, multiple frame data stream sizes are as follows Figure 3 The camera frame data stream sizes shown include each frame data stream size having a corresponding frame data stream width and frame data stream height. Figure 3 shown Take this frame data stream size as an example, its frame data stream width is 3072, and its frame data stream height is 4090; the frame data stream width and frame data stream height corresponding to the frame data stream size can be further calculated to obtain the frame data stream aspect ratio corresponding to the frame data stream size (such as Figure 3 The frame data stream size aspect ratio shown in FIG. 1 ) is also the frame data stream size ratio; Figure 3 As shown, The frame data stream size ratio corresponding to this frame data stream size is frame data stream width / frame data stream height= =0.75.
[0071] Specifically, the frame data stream width and the frame data stream height of each frame data stream size in the frame data stream parameters are obtained, and then the ratio of the frame data stream width to the frame data stream height is calculated to obtain a frame data stream size ratio imageratio corresponding to each frame data stream size.
[0072] S3122: Determine whether the difference between the frame data stream size ratio and the screen ratio is not greater than the ratio deviation value.
[0073] Specifically, taking one of the frame data stream size ratios as an example, the difference between the frame data stream size ratio imageratio and the screen ratio screenratio is calculated, and then it is determined whether the difference is not greater than the ratio deviation value deviation.
[0074] S3123: If yes, determine the frame data stream size corresponding to the frame data stream size ratio as the target frame data stream size.
[0075] Among them, if the difference between the frame data stream size ratio imageratio and the screen ratio screenratio is not greater than the ratio deviation value deviation, it means that the camera frame data stream corresponding to the frame data stream size corresponding to the frame data stream size ratio imageratio can fill the screen of the scanning device, and the frame data stream size corresponding to this frame data stream size ratio imageratio is used as the target frame data stream size; the subsequent scanning device will capture the camera frame data stream of the same size as the target frame data stream size.
[0076] Specifically, if it is determined that the difference between the frame data stream size ratio imageratio and the screen ratio screenratio is not greater than the ratio deviation value deviation, the frame data stream size corresponding to the frame data stream size ratio imageratio is used as the target frame data stream size.
[0077] It should be noted that the camera frame data stream corresponding to the target frame data stream size can fill the screen of the scanning device, can adapt to camera frame data streams of different sizes and aspect ratios to the maximum extent, and can also better fit the optimal visual experience of users when using it, that is, the content seen by the user is the content of the scanning code recognition and processing.
[0078] S320: Acquire punctuation coordinates of the heteromorphic code area based on the target frame data stream size.
[0079] S330: Generate a mask image based on the target frame data stream size and the punctuation coordinates of the heteromorphic code area.
[0080] S340: Process the camera frame data stream based on the mask image to obtain a special-shaped code, and recognize the special-shaped code to obtain a recognition result.
[0081] Embodiment 4
[0082] Figure 6 A flowchart of a method for scanning and identifying a special-shaped code provided in the fourth embodiment of the present application, refer to Figure 6 The method optimizes the "obtaining punctuation coordinates of the heteromorphic code area based on the target frame data stream size" in the first embodiment; it should be noted that, for the part not described in detail in this embodiment, reference can be made to the description of other embodiments, and the method includes:
[0083] S410: Determine a target frame data stream size based on the screen parameters of the code scanning device and the frame data stream parameters.
[0084] S421, sending the target frame data stream size to a preset web page end, so that the web page end calculates the contour coordinates of the special-shaped code based on the target frame data stream size.
[0085] In which, the web page end is a functional web page Web preset in the code scanning device, and the functional web page Web is used to receive the target frame data stream size sent by the code scanning device to calculate the contour coordinates of the special-shaped code; the contour coordinates of the special-shaped code are the contour coordinates of the special-shaped code on the camera frame data stream; specifically, refer to Figure 7 The functional web page Web generates a native camera component of the same size as the target frame data stream size. The functional web page Web is preset with a WebView component with a hollow area for carrying a Web page. The shape of the hollow area is consistent with the shape of the special-shaped code. The functional web page Web also makes the WebView component the same size as the native camera component. The functional web page Web obtains the coordinates of the image mapped on the native camera component through the hollow area of the WebView component to obtain the contour coordinates of the special-shaped code.
[0086] Specifically, the code scanning device sends the acquired target frame data stream size to a preset web page, and the web calculates the contour coordinates of the special-shaped code according to the target frame data stream size.
[0087] S422, obtaining the contour coordinates of the special-shaped code and the camera frame data stream.
[0088] The camera frame data stream is a continuous multi-frame image obtained when the barcode scanning device scans and photographs a target with a special-shaped code; illustratively, the target with the special-shaped code may be a product label with a five-pointed star-shaped special-shaped code.
[0089] Specifically, after the functional web page Web calculates the contour coordinates of the special-shaped code, it sends the contour coordinates of the special-shaped code to the scanning device through the Jsbridge interface, so that the scanning device obtains the contour coordinates of the special-shaped code; in addition, in the process of obtaining the contour coordinates of the special-shaped code, the user also scans the target with the special-shaped code through the scanning device to obtain the camera frame data stream.
[0090] S423: Determine the area on the camera frame data stream corresponding to the contour coordinates of the special-shaped code to obtain the punctuation coordinates of the special-shaped code area.
[0091] The camera frame data stream and the coordinates of the contour of the shaped code are in the same size dimension; the coordinates of the contour area corresponding to the coordinates of the contour of the shaped code on the camera frame data stream are also the punctuation coordinates of the shaped code area.
[0092] Specifically, the corresponding contour is determined on the real data stream of the heterogeneous code through the contour coordinates of the heterogeneous code, and the area within the contour is used as the punctuation coordinates of the heterogeneous code area.
[0093] It should be noted that by determining the punctuation coordinates in the heteromorphic code area, it is convenient to further obtain the heteromorphic code from the camera frame data stream according to the punctuation coordinates in the heteromorphic code area.
[0094] S430: Generate a mask image based on the target frame data stream size and the punctuation coordinates of the heteromorphic code area.
[0095] S440: Process the camera frame data stream based on the mask image to obtain a special-shaped code, and recognize the special-shaped code to obtain a recognition result.
[0096] Embodiment 5
[0097] Figure 8 A flowchart of a method for scanning and identifying a special-shaped code provided in Example 5 of this application, refer to Figure 8 The method optimizes the "generating a mask map based on the target frame data stream size and the punctuation coordinates of the heteromorphic code area" in the first embodiment; it should be noted that, for the part not described in detail in this embodiment, reference can be made to the description of other embodiments, and the method includes:
[0098] S510: Determine a target frame data stream size based on the screen parameters of the code scanning device and the frame data stream parameters.
[0099] S520: Acquire punctuation coordinates of the heteromorphic code area based on the target frame data stream size.
[0100] S531. Create a grayscale image with the same size as the target frame data stream.
[0101] Among them, the RGB value of each pixel in the grayscale image is , that is, the grayscale image is a pure white image.
[0102] Specifically, the barcode scanning device creates a grayscale image with the same size as the target frame data stream, and the RGB value of each pixel in the grayscale image is .
[0103] S532: Determine an image on the grayscale image corresponding to the punctuation coordinates of the heteromorphic code region to obtain a mask image.
[0104] Among them, since the size of the camera frame data stream scanned and photographed by the code scanning device is the size of the target frame data stream, and the size of the grayscale image is the same as the size of the target frame data stream, the grayscale image is the same size as the camera frame data stream. In this way, the code scanning device can determine the image corresponding to the punctuation coordinates of the special-shaped code area on the camera frame data stream on the grayscale image, and further, the RGB values of all pixels in the image can be set to , so that a pure black area corresponding to the punctuation coordinates of the heteromorphic code area can be generated on the original pure white image, thereby obtaining a mask image.
[0105] Specifically, the barcode scanning device determines the image corresponding to the punctuation coordinates of the shaped code area on the camera frame data stream on the grayscale image, and sets the RGB values of all pixels in the image to , so that the image is converted into a pure black image, thereby obtaining a mask map.
[0106] It should be noted that the position and size of the pure black area corresponding to the mask image are consistent with the position and size of the special-shaped code on the camera frame data stream; by generating the mask image, it is convenient to determine the special-shaped code on the camera frame data stream later.
[0107] S540: Process the camera frame data stream based on the mask image to obtain a special-shaped code, and recognize the special-shaped code to obtain a recognition result.
[0108] Embodiment 6
[0109] Fig. 9 A flowchart of a method for scanning and identifying a special-shaped code provided in Example 6 of this application, refer to Fig. 9 The method optimizes the "obtaining punctuation coordinates of the heteromorphic code area based on the target frame data stream size" in the first embodiment; it should be noted that, for the part not described in detail in this embodiment, reference can be made to the description of other embodiments, and the method includes:
[0110] S610: Determine a target frame data stream size based on screen parameters of the code scanning device and frame data stream parameters.
[0111] S620: Acquire punctuation coordinates of the heteromorphic code area based on the target frame data stream size.
[0112] S630: Generate a mask image based on the target frame data stream size and the punctuation coordinates of the heteromorphic code area.
[0113] S641. Copy an image that overlaps with the mask image in position from the camera frame data stream to obtain a special-shaped code.
[0114] The camera frame data stream has the same size as the grayscale image where the mask image is located, and the mask image in the grayscale image has the same position as the shaped code in the camera frame data stream. Therefore, the image in the camera frame data stream that overlaps with the mask image is also the shaped code.
[0115] Specifically, an image that overlaps with the mask image in position is copied from the camera frame data stream to obtain the special-shaped code.
[0116] S642: Identify the special-shaped code to obtain a recognition result.
[0117] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0118] Embodiment 7
[0119] Based on the same inventive concept, the disclosed embodiment also provides a device for scanning and recognizing a shaped code for implementing the above-mentioned method for scanning and recognizing a shaped code. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above-mentioned method, so the specific limitations in the embodiments of one or more devices for scanning and recognizing a shaped code provided below can refer to the limitations of the method for scanning and recognizing a shaped code above, and will not be repeated here.
[0120] In this embodiment, Fig.10 As shown, a device for scanning and identifying a special-shaped code is provided, comprising:
[0121] A size determination module, used to determine the target frame data stream size based on the screen parameters of the code scanning device and the frame data stream parameters;
[0122] An area acquisition module, used for acquiring punctuation coordinates of the heterogeneous code area based on the target frame data stream size;
[0123] A mask generation module, used for generating a mask image based on the target frame data stream size and the punctuation coordinates of the heteromorphic code area;
[0124] The code image recognition module is used to process the camera frame data stream based on the mask image to obtain a special-shaped code, and recognize the special-shaped code to obtain a recognition result.
[0125] Each module in the above-mentioned special-shaped code scanning and recognition device can be implemented in whole or in part by software, hardware and their combination. Each of the above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the corresponding operations of each of the above modules.
[0126] It should be noted that, in this embodiment, the target frame data stream size is determined based on the screen parameters of the code scanning device and the frame data stream parameters; the punctuation coordinates of the shaped code area are obtained based on the target frame data stream size; a mask image is generated based on the target frame data stream size and the punctuation coordinates of the shaped code area; the camera frame data stream is processed based on the mask image to obtain the shaped code, and the shaped code is recognized to obtain a recognition result; through the implementation of the above method, by calculating the target frame data stream size and the punctuation coordinates of the shaped code area, it is convenient to further calculate the mask image for indicating the area where the shaped code is located on the target frame data stream, and then the shaped code is reconfirmed from the target frame data stream through the mask image, so as to facilitate the subsequent further recognition of the shaped code; this facilitates the recognition of the shaped code on the camera frame data stream.
[0127] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Fig.11 As shown. The computer device includes a processor, a memory and a network interface connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a method for scanning and recognizing a special-shaped code is implemented.
[0128] Those skilled in the art will understand that Fig.11 The structure shown in the figure is only a block diagram of a part of the structure related to the scheme of the present disclosure, and does not constitute a limitation on the computer device to which the scheme of the present disclosure is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0129] In one embodiment, a computer readable storage medium is provided. Fig.12 As shown, a computer program is stored thereon, and when the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.
[0130] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.
[0131] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this disclosure are all information and data authorized by the user or fully authorized by all parties.
[0132] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided by the present disclosure can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided by the present disclosure may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided by the present disclosure may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic unit, a data processing logic unit based on quantum computing, etc., but are not limited to this.
[0133] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0134] The above-described embodiments only express several implementation methods of the present disclosure, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present invention. It should be pointed out that, for a person of ordinary skill in the art, several modifications and improvements can be made without departing from the concept of the present disclosure, and these all belong to the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure shall be subject to the attached claims.
Claims
1. A method for scanning and identifying a special-shaped code, characterized in that: include: Determine the target frame data stream size based on the screen parameters of the code scanning device and the frame data stream parameters; Acquire punctuation coordinates of the heteromorphic code area based on the target frame data stream size; Generate a mask image based on the target frame data stream size and the punctuation coordinates of the heteromorphic code area; Processing the camera frame data stream based on the mask image to obtain a special-shaped code, and recognizing the special-shaped code to obtain a recognition result; Among them, determining the target frame data stream size based on the screen parameters of the code scanning device and the frame data stream parameters includes: calculating the screen ratio and the ratio deviation value based on the acquired screen parameters of the code scanning device and the preset deviation coefficient; determining the target frame data stream size based on the screen ratio, the ratio deviation value and the frame data stream parameters.
2. The method according to claim 1, characterized in that The frame data stream parameters include a plurality of frame data stream sizes; and determining a target frame data stream size based on the screen ratio, the ratio deviation value, and the frame data stream parameters includes: Calculating a frame data stream size ratio corresponding to each frame data stream size in the frame data stream parameters; Determine whether the difference between the frame data stream size ratio and the screen ratio is not greater than the ratio deviation value; If so, the frame data stream size corresponding to the frame data stream size ratio is determined as the target frame data stream size.
3. The method according to claim 1, characterized in that The step of obtaining punctuation coordinates of the heteromorphic code area based on the target frame data stream size includes: Sending the target frame data stream size to a preset web page end, so that the web page end calculates the contour coordinates of the special-shaped code based on the target frame data stream size; Obtaining the contour coordinates of the special-shaped code and the camera frame data stream; The area corresponding to the contour coordinates of the special-shaped code on the camera frame data stream is determined to obtain the punctuation coordinates of the special-shaped code area.
4. The method according to claim 1, characterized in that The step of generating a mask image based on the target frame data stream size and the punctuation coordinates of the heteromorphic code area includes: Creating a grayscale image with the same size as the target frame data stream; The image corresponding to the punctuation coordinates of the heteromorphic code area on the grayscale image is determined to obtain a mask image.
5. The method according to claim 1, characterized in that The step of processing the camera frame data stream based on the mask image to obtain the special-shaped code comprises: An image that overlaps with the mask image in position is copied from the camera frame data stream to obtain a special-shaped code.
6. A device for scanning and identifying special-shaped codes, characterized in that: The device comprises: A size determination module, used to determine the target frame data stream size based on the screen parameters of the code scanning device and the frame data stream parameters; An area acquisition module, used for acquiring punctuation coordinates of the heterogeneous code area based on the target frame data stream size; A mask generation module, used for generating a mask image based on the target frame data stream size and the punctuation coordinates of the heteromorphic code area; The code image recognition module is used to process the camera frame data stream based on the mask image to obtain a special-shaped code, and recognize the special-shaped code to obtain a recognition result.
7. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 5 are implemented.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.
9. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.