CN117709380A - Bar code scanning method and device, storage medium and electronic equipment - Google Patents

Bar code scanning method and device, storage medium and electronic equipment Download PDF

Info

Publication number
CN117709380A
CN117709380A CN202311725113.3A CN202311725113A CN117709380A CN 117709380 A CN117709380 A CN 117709380A CN 202311725113 A CN202311725113 A CN 202311725113A CN 117709380 A CN117709380 A CN 117709380A
Authority
CN
China
Prior art keywords
square
target
block
blocks
bar code
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311725113.3A
Other languages
Chinese (zh)
Inventor
张芸枭
安平
张雪利
李勇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Industrial and Commercial Bank of China Ltd ICBC
Original Assignee
Industrial and Commercial Bank of China Ltd ICBC
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Industrial and Commercial Bank of China Ltd ICBC filed Critical Industrial and Commercial Bank of China Ltd ICBC
Priority to CN202311725113.3A priority Critical patent/CN117709380A/en
Publication of CN117709380A publication Critical patent/CN117709380A/en
Pending legal-status Critical Current

Links

Abstract

The application discloses a bar code scanning method, a bar code scanning device, a storage medium and electronic equipment. Relates to the field of financial science and technology, and the method comprises the following steps: acquiring a target image containing a bar code to be scanned, performing binarization processing on the target image, and equally dividing the target image after the binarization processing into square sets; extracting skeleton features from each square of the square set to obtain a group of skeleton feature sets; screening the square blocks in the square block set through skeleton characteristics to obtain a screened first square block and an unselected undeveloped square block; screening all the blocks to be determined based on the central moment of the blocks to be determined to obtain a second block which meets the preset central moment condition, and combining the first block with the second block to obtain a target block set; and determining a target scanning area containing the bar code to be scanned through the target square set, and scanning the target scanning area to obtain the target bar code. By the method and the device, the problem of inaccurate bar code scanning results in the related technology is solved.

Description

Bar code scanning method and device, storage medium and electronic equipment
Technical Field
The application relates to the field of financial science and technology, in particular to a bar code scanning method, a bar code scanning device, a storage medium and electronic equipment.
Background
The bar code technology is a key information identification and information acquisition technology and is widely applied to the fields of commercial trade, logistics, product tracing, electronic commerce and the like. Financial institutions also use bar code technology on a large scale, wherein POS (Point of Sale terminal device, a payment device) terminal devices used by the financial institutions are provided with device bar codes for device maintenance personnel to manage the POS devices.
In the related art, the scanning scene of the one-dimensional bar code is realized by special laser scanning equipment. And the special equipment has high cost and poor convenience. If in the inspection scene, the inspector needs to hold a code scanning gun with a Bluetooth function, which is equipped by a company, to complete bar code scanning, so that the company cost is increased, and the workload of the inspector is also increased.
With the increasing popularity of mobile phone application scenes, the bar code scanning can be completed by selecting a bar code scanning mode through a mobile phone camera, the bar code scanning mode of the mobile phone has low requirements on equipment, and the application scenes are wide. Some mobile phone application providers in the related art use a front-end recognition method, and some mobile phone application providers use a back-end recognition method. The front-end identification method is to use a JS (JavaScript, a programming language) method to perform bar code identification offline in the front-end application. Such as quagga. Js, barcode. Js, etc. The front-end recognition method can be realized off-line, has quick response, is influenced by factors such as the accuracy of the traditional algorithm, large pixel difference of multiple cameras of the mobile phone, the illumination of the environment and the like, and can reduce the stability and the accuracy of a code scanning result. The back-end recognition method is to shoot a bar code picture through a mobile phone camera, and upload the bar code picture to a background server for bar code recognition. Such as the components of xing. Jar and spiral. Bar. The back end identification needs to have certain communication cost, and the communicated pictures are usually compressed, so that the accuracy of bar code identification can be influenced due to low picture quality.
Aiming at the problem of inaccurate bar code scanning result in the related technology, no effective solution is proposed at present.
Disclosure of Invention
The main purpose of the application is to provide a bar code scanning method, a device, a storage medium and an electronic device, so as to solve the problem of inaccurate bar code scanning result in the related technology.
In order to achieve the above object, according to one aspect of the present application, there is provided a barcode scanning method. The method comprises the following steps: acquiring a target image containing a bar code to be scanned, performing binarization processing on the target image, and equally dividing the target image after the binarization processing into square sets; extracting skeleton features from each square of the square set to obtain a group of skeleton feature sets; screening the square blocks in the square block set through skeleton characteristics to obtain a screened first square block and an unselected undeveloped square block; screening all the blocks to be determined based on the central moment of the blocks to be determined to obtain a second block which meets the preset central moment condition, and combining the first block with the second block to obtain a target block set; and determining a target scanning area containing the bar code to be scanned through the target square set, and scanning the target scanning area to obtain the target bar code.
Optionally, screening the blocks in the block set through the skeleton feature, and obtaining the screened first block and the unselected pending block includes: for each square in the square set, judging whether the number of elements contained in the skeleton characteristics of the square to be screened is larger than or equal to a first number threshold; determining a block to be screened as a block to be determined under the condition that the element number is smaller than a first number threshold value; judging whether the square to be screened contains parallel lines or not under the condition that the number of elements is larger than or equal to a first number threshold value; determining the square to be screened as a square to be determined under the condition that the square to be screened does not contain parallel lines; in the case where the squares to be screened include parallel lines, the first square and the squares to be determined are screened by the features of the parallel lines.
Optionally, screening the first square and the pending square by the features of the parallel lines includes: determining the proportion of the number of straight lines contained in parallel lines to all the straight lines in the square to be screened to obtain a target proportion; under the condition that the target proportion is smaller than the proportion threshold value, determining the square to be screened as a square to be determined; determining the target length of the longest straight line in parallel lines under the condition that the target proportion is greater than or equal to a proportion threshold value; determining the square to be screened as a square to be determined under the condition that the target length is smaller than the length threshold value; and determining the square to be screened as a first square under the condition that the target length is greater than or equal to a length threshold value.
Optionally, screening all the to-be-determined squares based on the central moment of the to-be-determined squares, and obtaining the second square meeting the preset central moment condition includes: acquiring the current scanning times corresponding to the target image, and judging whether the current scanning times are greater than or equal to a scanning times threshold value; under the condition that the current scanning times is greater than or equal to a scanning times threshold value, acquiring a first center moment of each first square block to obtain a group of first center moments; for each block to be determined, determining a second central moment of the block to be determined, and calculating the similarity between the second central moment and each first central moment in a group of first central moments to obtain a group of first similarity; and determining the block to be determined as a second block under the condition that at least one first similarity in the group of first similarities is larger than or equal to a first similarity threshold value.
Optionally, before determining the target scan area containing the barcode to be scanned by the set of target tiles, the method further comprises: for each square in the target square set, determining a first angle of parallel lines in the current square, wherein the first angle is an included angle between the bottom edge of the current square and the parallel lines; judging whether a second angle of parallel lines in other blocks is the same as the first angle, wherein the other blocks are blocks except the current block in the target block set, and the second angle is an included angle between the bottom edges of the other blocks and the parallel lines of the other blocks; marking the current square with the same color as the other squares in the case that the second angle of the parallel lines in the at least one other square is the same as the first angle; and under the condition that the second angle and the first angle of parallel lines in all other blocks are different, marking the current block with a new color, wherein the color of the new color is different from that of each other block mark.
Optionally, before determining the target scan area containing the barcode to be scanned by the set of target tiles, the method further comprises: determining the color of each square in the target square set, and judging whether the colors of all squares in the target square set are the same; determining the blocks marked with the target colors under the condition that the blocks with different colors exist in the target block set, and removing all the blocks marked with other colors except the target colors from the target block set, wherein the target colors are the colors marked by the blocks with the largest number in the blocks with the same colors; and under the condition that the colors of all the squares in the target square set are the same, executing the step of determining a target scanning area containing the bar code to be scanned through the target square set.
Optionally, determining, by the set of target squares, a target scan area containing a barcode to be scanned includes: determining all connected blocks in the target block set to obtain at least one connected region; judging whether the number of the square blocks contained in the area is larger than or equal to a second number threshold value; determining the region as a first region when the number of blocks is greater than or equal to a second number threshold; under the condition that the number of the square blocks is smaller than a second number threshold, calculating the similarity of the direction vector of the parallel lines of the square blocks in the area and the direction vector of the parallel lines of the square blocks in other areas to obtain a second similarity; combining the region and other regions into one region under the condition that the second similarity is larger than or equal to a second similarity threshold value to obtain a second region; and dividing a rectangular area based on the outlines of the outer square blocks of the first area and the second area to obtain a target scanning area.
Optionally, the target image is acquired by: controlling a camera of the mobile equipment to shoot an object containing a bar code to be scanned to obtain a pending image; controlling a camera to re-shoot an object containing the bar code to be scanned under the condition that the bar code to be scanned is not recognized from the image to be determined until the bar code to be scanned is recognized from the image to be determined, wherein under the condition that the shooting frequency of re-shooting is greater than or equal to the threshold value of the shooting frequency, controlling a flashlight of the mobile equipment to be started, and adjusting the distance between the camera and the object containing the bar code to be scanned; and in the case that the bar code to be scanned is identified from the pending images, determining the pending images as target images.
Optionally, in the case that the mobile device includes a plurality of cameras, determining the camera corresponding to the highest resolution as the target camera, and shooting the object including the barcode to be scanned through the target camera.
In order to achieve the above object, according to another aspect of the present application, there is provided a barcode scanning device. The device comprises: the acquisition unit is used for acquiring a target image containing a bar code to be scanned, carrying out binarization processing on the target image, and equally dividing the target image subjected to the binarization processing into square sets; the extraction unit is used for extracting skeleton features from each square of the square set to obtain a group of skeleton feature sets; the first screening unit is used for screening the square blocks in the square block set through skeleton characteristics to obtain a screened first square block and an unselected square block to be determined; the second screening unit is used for screening all the to-be-determined squares based on the center moment of the to-be-determined squares to obtain a second square which meets the preset center moment condition, and combining the first square with the second square to obtain a target square set; and the determining unit is used for determining a target scanning area containing the bar code to be scanned through the target square set, and scanning the target scanning area to obtain the target bar code.
Through the application, the following steps are adopted: acquiring a target image containing a bar code to be scanned, performing binarization processing on the target image, and equally dividing the target image after the binarization processing into square sets; extracting skeleton features from each square of the square set to obtain a group of skeleton feature sets; screening the square blocks in the square block set through skeleton characteristics to obtain a screened first square block and an unselected undeveloped square block; screening all the blocks to be determined based on the central moment of the blocks to be determined to obtain a second block which meets the preset central moment condition, and combining the first block with the second block to obtain a target block set; and determining a target scanning area containing the bar code to be scanned through the target square set, and scanning the target scanning area to obtain the target bar code, thereby solving the problem of inaccurate bar code scanning result in the related technology. Dividing a target image into square sets, performing primary screening on the square sets according to skeleton characteristics of the square to obtain a first square, performing secondary screening on the square to be determined according to a central moment to obtain a second square, and determining a target scanning area through the first square and the second square group and the obtained target square set, so that a target bar code is obtained by scanning the target scanning area, and the effect of improving the accuracy of a bar code scanning result is achieved.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application, illustrate and explain the application and are not to be construed as limiting the application. In the drawings:
FIG. 1 is a flow chart of a bar code scanning method provided in accordance with an embodiment of the present application;
FIG. 2 is a schematic diagram of a target image after binarization processing according to an embodiment of the present application;
FIG. 3 is a schematic diagram of a target image equally divided into sets of squares according to an embodiment of the present application;
FIG. 4 is a schematic diagram of a target image after extraction of skeletal features provided in accordance with an embodiment of the present application;
FIG. 5 is a schematic diagram of a method for determining a barcode scanning region provided in accordance with an embodiment of the present application;
FIG. 6 is a schematic diagram of a bar code scanning device provided according to an embodiment of the present application;
fig. 7 is a schematic diagram of an electronic device provided according to an embodiment of the present application.
Detailed Description
It should be noted that, in the case of no conflict, the embodiments and features in the embodiments may be combined with each other. The present application will be described in detail below with reference to the accompanying drawings in conjunction with embodiments.
In order to make the present application solution better understood by those skilled in the art, the following description will be made in detail and with reference to the accompanying drawings in the embodiments of the present application, it is apparent that the described embodiments are only some embodiments of the present application, not all embodiments. All other embodiments, which can be made by one of ordinary skill in the art based on the embodiments herein without making any inventive effort, shall fall within the scope of the present application.
It should be noted that the terms "first," "second," and the like in the description and claims of the present application and the above figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate in order to describe the embodiments of the present application described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
It should be noted that, the user information (including, but not limited to, user equipment information, user personal information, etc.) and the data (including, but not limited to, data for presentation, analyzed data, etc.) related to the present disclosure are information and data authorized by the user or sufficiently authorized by each party.
The invention will be described with reference to preferred embodiments, and FIG. 1 is a flowchart of a bar code scanning method according to an embodiment of the present application, as shown in FIG. 1, comprising the steps of:
Step S101, obtaining a target image containing a bar code to be scanned, performing binarization processing on the target image, and equally dividing the target image after the binarization processing into square sets.
Specifically, the target image may be a picture of a device barcode including a POS machine acquired by a mobile phone camera. The bar code is first required to be positioned from the target image to the position where the bar code is located when scanning the bar code. The decoder is then used to decode the bar code at the target location. The target image is subjected to binarization processing through a binarizeImage function, the binarizeImage function obtains an optimal binarization segmentation threshold value of the image through an otsu (maximum inter-class difference) algorithm, instead of simply setting the global threshold value to 127, so that the image can be more accurately divided into a foreground and a background, and the influence of illumination brightness in different images is eliminated. The square blocks in the square block set may be square or rectangular, fig. 2 is a schematic diagram of a target image after binarization processing according to an embodiment of the present application, and fig. 3 is a schematic diagram of a target image after equal division into square block sets according to an embodiment of the present application, where the target image is divided into equal square block sets, so that a target scan area is conveniently and quickly located from the square block sets.
Step S102, extracting skeleton features from each square in the square set to obtain a group of skeleton feature sets.
Specifically, the skeleton feature may be extracted from each block by using a skeletonize function, and fig. 4 is a schematic diagram of a target image after extracting the skeleton feature according to an embodiment of the present application, and as shown in fig. 4, elements included in the skeleton feature extracted from each block are different.
Step S103, the blocks in the square block set are screened through skeleton characteristics, and the screened first blocks and the undeveloped blocks are obtained.
Specifically, the square block is screened based on the skeleton characteristics, whether parallel lines exist in the square block is judged through the skeleton characteristics, if the parallel lines exist, the square block is likely to be a first square block containing the bar code, if the parallel lines do not exist, the square block is likely to contain the bar code or not, the square block is determined to be pending for further screening.
Step S104, screening all the blocks to be determined based on the central moment of the blocks to be determined to obtain a second block which meets the preset central moment condition, and combining the first block with the second block to obtain a target block set.
Specifically, for the block to be determined, the Orientation (direction, posture, rotation, and rotation angle of the element in the block to be determined may be represented by a rotation matrix, euler angle, and four elements) of the block to be determined is obtained by calculating the center moment of the image (the center moment is calculated from the original moment and the centroid), the Orientation calculated in this embodiment is used to represent the average angle of the element in the block, that is, the angle between the straight line included in the block and the bottom edge of the block, and the block to be determined is further screened by determining whether the block having the same average angle as the block to be determined exists in the first block, and if the average angle of the first block has the same average angle as the block to be determined (that is, the preset center moment condition is met), it is indicated that the straight line included in the block to be determined may belong to a portion of the parallel line of the bar code, and therefore the block to be determined as the second block. The first square and the second square thus selected can cover substantially all squares containing bar codes, i.e. the target square set.
It should be noted that, in the related art, the barcode scanning algorithm is difficult to obtain the barcode scanning result under a few conditions, because the scanning area is broken into two or more blocks in the middle of the barcode due to the problems of light/image blurring and the like, and the problem that the square block at the barcode position is missed during positioning is solved, so that when the screening of the proper square block is performed, the old screening condition is removed, a correction function is added to the screened square block, and if the average angle in the current square block has a great similarity with the average angle in a certain square block which has passed the screening, the current square block is also regarded as passing the screening. However, occasionally, the pattern at the edges of the bar code is divided into another square, where it is difficult to pass the box because the tangible image occupies a too small percentage of the whole of the box. If the average angle of the squares which have passed the screening is recorded, when the average angle in a new square which has not been screened is very similar to a certain angle in the record array, the problem that the bar code edge is not covered can be solved by considering that the bar code edge passes the screening.
Step S105, determining a target scanning area containing the bar code to be scanned through the target square set, and scanning the target scanning area to obtain the target bar code.
Specifically, parallel lines with the same average angle are determined according to elements contained in the target square block set, the connected square blocks are divided into target scanning areas containing bar codes to be scanned based on the connected square blocks, and then the target scanning areas are scanned, so that the target bar codes are obtained.
According to the bar code scanning method, the target image containing the bar code to be scanned is obtained, binarization processing is carried out on the target image, and the target image after the binarization processing is equally divided into square sets; extracting skeleton features from each square of the square set to obtain a group of skeleton feature sets; screening the square blocks in the square block set through skeleton characteristics to obtain a screened first square block and an unselected undeveloped square block; screening all the blocks to be determined based on the central moment of the blocks to be determined to obtain a second block which meets the preset central moment condition, and combining the first block with the second block to obtain a target block set; and determining a target scanning area containing the bar code to be scanned through the target square set, and scanning the target scanning area to obtain the target bar code, thereby solving the problem of inaccurate bar code scanning result in the related technology. Dividing a target image into square sets, performing primary screening on the square sets according to skeleton characteristics of the square to obtain a first square, performing secondary screening on the square to be determined according to a central moment to obtain a second square, and determining a target scanning area through the first square and the second square group and the obtained target square set, so that a target bar code is obtained by scanning the target scanning area, and the effect of improving the accuracy of a bar code scanning result is achieved.
In the method for scanning bar codes provided by the embodiment of the application, optionally, the method for screening the square blocks in the square block set through the skeleton feature to obtain the screened first square block and the undeveloped square block includes: for each square in the square set, judging whether the number of elements contained in the skeleton characteristics of the square to be screened is larger than or equal to a first number threshold; determining a block to be screened as a block to be determined under the condition that the element number is smaller than a first number threshold value; judging whether the square to be screened contains parallel lines or not under the condition that the number of elements is larger than or equal to a first number threshold value; determining the square to be screened as a square to be determined under the condition that the square to be screened does not contain parallel lines; in the case where the squares to be screened include parallel lines, the first square and the squares to be determined are screened by the features of the parallel lines.
Specifically, the first number threshold may be set to 2, if there is no element in a block, or there is only one element, or there are no more than two elements, all elements are screened out, and the next analysis is no longer performed, that is, the number of elements is less than the first number threshold, which indicates that the block cannot contain barcode elements, so that the block with the number of elements less than the first number threshold is directly determined as the pending block. Since the bar code is composed of a plurality of parallel lines, the first square can be screened by judging whether the square to be screened contains parallel lines. And if the square to be screened comprises parallel lines, screening the first square and the square to be determined according to the characteristics of the parallel lines. The present embodiment determines the block containing the barcode by screening the first block and the pending block.
Optionally, in the barcode scanning method provided in the embodiment of the present application, screening the first square and the to-be-determined square by the features of the parallel lines includes: determining the proportion of the number of straight lines contained in parallel lines to all the straight lines in the square to be screened to obtain a target proportion; under the condition that the target proportion is smaller than the proportion threshold value, determining the square to be screened as a square to be determined; determining the target length of the longest straight line in parallel lines under the condition that the target proportion is greater than or equal to a proportion threshold value; determining the square to be screened as a square to be determined under the condition that the target length is smaller than the length threshold value; and determining the square to be screened as a first square under the condition that the target length is greater than or equal to a length threshold value.
Specifically, to ensure that the first block that is screened contains a barcode, the parallel lines contained in the square must satisfy the barcode characteristics, for example, if and only if the number of elements within the matrix movement array (i.e., the number of lines contained in the parallel lines) is greater than or equal to 3/4 (i.e., the target proportion) of the length of the eignomic array (i.e., the number of all lines in the square to be screened), and the target length of the longest line of the parallel lines is greater than 1/4 (i.e., the length threshold) of the length of the entire square, the parallel lines in this square will be considered part of the barcode, as determined by screening as the first square. The present embodiment is used to determine the scan area of the barcode by screening the first block.
Optionally, in the barcode scanning method provided in the embodiment of the present application, screening all the blocks to be determined based on the central moment of the block to be determined, obtaining the second block meeting the preset central moment condition includes: acquiring the current scanning times corresponding to the target image, and judging whether the current scanning times are greater than or equal to a scanning times threshold value; under the condition that the current scanning times is greater than or equal to a scanning times threshold value, acquiring a first center moment of each first square block to obtain a group of first center moments; for each block to be determined, determining a second central moment of the block to be determined, and calculating the similarity between the second central moment and each first central moment in a group of first central moments to obtain a group of first similarity; and determining the block to be determined as a second block under the condition that at least one first similarity in the group of first similarities is larger than or equal to a first similarity threshold value.
Specifically, since adding the correction function is equivalent to relaxing the condition of the block passing screening, the probability of the redundant block passing screening is also increased. The probability of the square passing through the screening is not increased, and the screening condition is relaxed for the bar code images which are difficult to obtain the result, such as curved surfaces and bar code images with too small bar codes in the images, so that the correction function is started after the scanning times exceed 100 times (namely the threshold value of the scanning times), the second square is screened from the squares to be determined, namely the second square is screened according to the similarity between the second center distance in the squares to be determined and the first center distance of the screened first square, and if at least one first similarity in a group of first similarities is greater than or equal to the threshold value of the first similarity, the slope of parallel lines in the squares to be determined is identical with the slope of the parallel lines of a certain first square, namely the parallel lines contained in the squares to be determined possibly belong to a part of the bar codes. And determining the undetermined square block with the first similarity being greater than or equal to the first similarity threshold as a second square block. In this embodiment, the second square is selected to avoid that the bar code cannot be scanned successfully due to missing part of the square containing the bar code.
Optionally, in the barcode scanning method provided in the embodiment of the present application, before determining, by the target square set, the target scanning area including the barcode to be scanned, the method further includes: for each square in the target square set, determining a first angle of parallel lines in the current square, wherein the first angle is an included angle between the bottom edge of the current square and the parallel lines; judging whether a second angle of parallel lines in other blocks is the same as the first angle, wherein the other blocks are blocks except the current block in the target block set, and the second angle is an included angle between the bottom edges of the other blocks and the parallel lines of the other blocks; marking the current square with the same color as the other squares in the case that the second angle of the parallel lines in the at least one other square is the same as the first angle; and under the condition that the second angle and the first angle of parallel lines in all other blocks are different, marking the current block with a new color, wherein the color of the new color is different from that of each other block mark.
Specifically, in order to conveniently divide the target scanning area where the bar code is located, after determining the parallel lines included in the square, marking the color of the current square according to the first angle of the parallel lines in the current square, if the first angle of the current square is the same as the second angle of the parallel lines included in other squares, it is indicated that the current square and other squares may belong to the same area, therefore, the current square is marked with the same color as other squares, if the second angle of the parallel lines without other squares is the same as the first angle of the current square, it is indicated that the current square and other squares do not belong to the same area, and the current square is marked with a new color. The embodiment improves the identification efficiency of the target scanning area by marking the color on the square block.
Optionally, in the barcode scanning method provided in the embodiment of the present application, before determining, by the target square set, a target scanning area including a barcode to be scanned, the method further includes: determining the color of each square in the target square set, and judging whether the colors of all squares in the target square set are the same; determining the blocks marked with the target colors under the condition that the blocks with different colors exist in the target block set, and removing all the blocks marked with other colors except the target colors from the target block set, wherein the target colors are the colors marked by the blocks with the largest number in the blocks with the same colors; and under the condition that the colors of all the squares in the target square set are the same, executing the step of determining a target scanning area containing the bar code to be scanned through the target square set.
Specifically, since a portion of the squares included in the target square set may not belong to the barcode scanning region, the color of the mark of the portion of the squares is different from the main color (i.e., the target color) of the squares in the target square set, that is, none of the squares marked with other colors except the square of the target color belong to the target scanning region. All squares marked with other colors than the target color are therefore removed from the target set of squares based on the color of the square mark before the target scan area is determined by the target set of squares. The embodiment improves the dividing efficiency of the target scanning area by eliminating the square marked with other colors.
Optionally, in the barcode scanning method provided in the embodiment of the present application, determining, by the target square set, a target scanning area including a barcode to be scanned includes: determining all connected blocks in the target block set to obtain at least one connected region; judging whether the number of the square blocks contained in the area is larger than or equal to a second number threshold value; determining the region as a first region when the number of blocks is greater than or equal to a second number threshold; under the condition that the number of the square blocks is smaller than a second number threshold, calculating the similarity of the direction vector of the parallel lines of the square blocks in the area and the direction vector of the parallel lines of the square blocks in other areas to obtain a second similarity; combining the region and other regions into one region under the condition that the second similarity is larger than or equal to a second similarity threshold value to obtain a second region; and dividing a rectangular area based on the outlines of the outer square blocks of the first area and the second area to obtain a target scanning area.
Specifically, the second number threshold may be set to 6, and the area with the number of blocks equal to or greater than the second number threshold is filtered by the findbiggestConnectedAreas function, and since there may be a plurality of barcodes in one image, the return value of the findbiggestConnectedAreas function is an array, and the elements in the array are arranged according to the number of blocks in the area. A region containing the bar code as small as possible is mapped out by calculation of the first region screened by the boxfrom Patches function. First, the average angle of the squares in the first region is calculated. Then, the range of the scan area box is calculated by the square of the outermost layer inside the first area. Finally, the box is rotated according to the calculated average angle and positioned to the bar code area, namely the target scanning area.
For areas where the number of squares is less than the second number threshold, the areas may be disconnected due to a barrier in the middle of the barcode. Since the regions are a set of squares having similar average angles and connected coordinates, the pattern similarity (i.e., the second similarity) between the two regions can be obtained by comparing the average angles of the squares between the respective regions. If the angles of the two independent areas passing through the screening are similar (i.e. the second similarity is greater than or equal to the second similarity threshold), and the coordinates are different by only one or two squares, the two areas are regarded as a connected area. The second similarity of the squares of the individual regions is calculated by the check function checkPatchesSimilary. If the calculated second similarity of the current block is greater than 0.95 (second similarity threshold), the checkPatchess similarity accepts a parameter vec1 representing the direction vector in the current block, calculates the similarity between vec and vec1 of blocks in the screened area (area 1), and if the similarity is greater than 0.95, assigns the latest label value to the area1 current block, in such a way that blocks with the same label are regarded as the same area. The present embodiment identifies the barcode by determining the target scan region.
Optionally, in the barcode scanning method provided in the embodiment of the present application, the target image is acquired by: controlling a camera of the mobile equipment to shoot an object containing a bar code to be scanned to obtain a pending image; controlling a camera to re-shoot an object containing the bar code to be scanned under the condition that the bar code to be scanned is not recognized from the image to be determined until the bar code to be scanned is recognized from the image to be determined, wherein under the condition that the shooting frequency of re-shooting is greater than or equal to the threshold value of the shooting frequency, controlling a flashlight of the mobile equipment to be started, and adjusting the distance between the camera and the object containing the bar code to be scanned; and in the case that the bar code to be scanned is identified from the pending images, determining the pending images as target images.
Specifically, when the live stream is selected to perform code scanning, the inside of the barcode scanning algorithm is a process of circularly performing image positioning, determining a barcode region and decoding the determined barcode region, and in order to optimize the barcode scanning process, two functions of lighting a flashlight and approaching a camera are added in a frame function. Both functions are implemented by the applyconstate method provided by the browser navigator object. Wherein, the lighting flashlight corresponds to the torch attribute, and the zooming-in camera corresponds to the zoom attribute. The optimization thinking of zooming in the camera is to judge with three conditions that the scanning times exceed 60 (shooting times threshold) times and decoding is not successful yet, and that the zoom (zooming in function of the browser) is available, and that the bar code is once positioned in the previous 60 times of scanning or the area with the number of the target scanning areas exceeding 3 is obtained, and if the conditions are met, the camera is zoomed in.
In the code scanning process, a condition exists that the definition of the bar code is enough, but the size is too small, the bar code area occupies only four or five blocks, in order to improve the code scanning efficiency in the condition, a judging condition is newly added in a findGestConnectedAreas function, after the area with the number of the blocks being more than or equal to 5 is screened, if the area with the number of the blocks being more than or equal to 3 is not obtained, the area with the number of the blocks being more than or equal to 3 is continuously screened, and if the area exists, the variable value getSmallAreas is assigned as true. The getSmallAreas play a role in marking a bar code with a small size in a current image of a bar code scanning algorithm, and when the getSmallAreas is true, the bar code scanning algorithm draws a camera close to scan the bar code under the condition that the scanning times reach 60 and a zoom function is available. By pulling the camera closer, the number of blocks covered by the bar code will be increased, thereby improving the possibility of obtaining the code scanning result.
The optimal idea for lighting the flashlight is to light the flashlight if the image illumination intensity of the current video stream is continuously too low and the torch attribute is available in the current browser environment. The bar code scanning algorithm binarizes the image by means of an otsu (a binarization processing algorithm), and threshold value calculated by the otsu can reflect illumination intensity of the current image, so that brightness of the current image is mastered by threshold value calculated by the otsu, and then a flashlight is further operated. By calculating the threshold average value obtained from the last forty scans, if the average value is less than 60 and the in-interface torch attribute returned by the current browser is available, the camera flashlight is turned on.
Optionally, in the barcode scanning method provided in the embodiment of the present application, in a case that the mobile device includes a plurality of cameras, the camera corresponding to the highest resolution is determined as the target camera, and the object including the barcode to be scanned is shot by the target camera.
Specifically, the bar code scanning algorithm plug-in internally encapsulates a function for acquiring a camera list, acquires a camera through a browser enumeration camera device method (navigator, media devices), and sets a first item of a method return array as a camera for default use of the plug-in. Since some devices will acquire a blurred wide angle camera, in this case the barcode scanning algorithm will have difficulty locating the barcode and further decoding due to the too blurred image. Therefore, a pull-down list of the switching camera is added on the front-end page, a camera list is obtained by using an enumereateVideodevice method packaged in a bar code scanning algorithm and rendered at the front end, a camera corresponding to the highest resolution is determined to be a target camera, and an object containing a bar code to be scanned is shot through the target camera. According to the embodiment, the camera corresponding to the highest resolution is automatically called to shoot the bar code, so that the success rate of bar code scanning is improved.
According to another embodiment of the present application, there is further provided a method for determining a barcode scanning region, and fig. 5 is a schematic diagram of the method for determining a barcode scanning region according to the embodiment of the present application. As shown in fig. 5, the method includes: the mobile phone code scanning component starts to work, converts a picture into a two-dimensional black-and-white image, converts the binary black-and-white picture into equal squares, extracts framework features in each square, screens the squares based on the framework features, judges whether all the squares are screened, judges whether parallel lines are contained in the squares if the squares are not screened, discards the squares if the parallel lines are not contained, does not mark the squares if the parallel lines are not contained, judges whether other squares have the same parallel line angle or not if the parallel lines are contained, uses color marks of the squares with the same angle if the parallel lines are contained, and uses new color marks if the parallel lines are not contained. The marked square is determined to be the screened square.
After all the squares are screened, the central moment of each square is calculated in sequence, whether all the squares are subjected to secondary screening is judged, if not, the square is judged whether to pass the condition screening of the central moment, if so, the square is recorded as the square in the target square set passing the screening, if not, whether the scanning times of the bar codes exceeds 100 times is judged, if not, the square is discarded, if the similarity of the square and the central moment of the square passing the screening is more than or equal to a similarity threshold value, if the similarity is more than or equal to the similarity threshold value, the square is determined as the square passing the screening, and if the similarity is less than the similarity threshold value, the square is discarded.
Judging whether the screened square blocks are connected and whether the number of the connected square blocks is more than six after the secondary screening is carried out on all the square blocks, if the number of the square blocks is not more than six, recording the areas where the connected square blocks exist, judging whether the similarity between the direction vectors in different areas is more than 0.95, if the similarity between the direction vectors in different areas is more than 0.95, communicating the two areas into one area, if the number of the connected square blocks in the area is more than six, calculating a rectangular scanning area through the square blocks on the outermost layer of the area, and rotating the scanning area according to the angle to be adjusted by the scanning area to obtain a target scanning area.
According to the method for determining the barcode scanning area, the accuracy of barcode positioning is improved, and the scanning speed is improved.
It should be noted that the steps illustrated in the flowcharts of the figures may be performed in a computer system such as a set of computer executable instructions, and that although a logical order is illustrated in the flowcharts, in some cases the steps illustrated or described may be performed in an order other than that illustrated herein.
The embodiment of the application also provides a bar code scanning device, and the bar code scanning device can be used for executing the bar code scanning method. The following describes a barcode scanning device provided in an embodiment of the present application.
Fig. 6 is a schematic diagram of a barcode scanning device provided according to an embodiment of the present application. As shown in fig. 6, the apparatus includes:
an acquiring unit 10, configured to acquire a target image including a barcode to be scanned, perform binarization processing on the target image, and equally divide the binarized target image into a set of squares;
an extracting unit 20, configured to extract skeleton features from each block of the set of blocks, to obtain a set of skeleton feature sets;
a first screening unit 30, configured to screen the blocks in the block set according to the skeleton feature, so as to obtain a screened first block and an unselected block to be determined;
a second screening unit 40, configured to screen all the to-be-determined squares based on the center moment of the to-be-determined squares to obtain a second square meeting the preset center moment condition, and combine the first square and the second square to obtain a target square set;
the determining unit 50 is configured to determine a target scanning area including a barcode to be scanned through the target square set, and scan the target scanning area to obtain the target barcode.
According to the bar code scanning device provided by the embodiment of the application, the target image containing the bar code to be scanned is acquired through the acquisition unit 10, the target image is subjected to binarization processing, and the target image subjected to the binarization processing is equally divided into square sets; an extraction unit 20 that extracts skeleton features from each block of the set of blocks, to obtain a set of skeleton feature sets; a first screening unit 30 for screening the square blocks in the square block set by using the skeleton characteristics to obtain a screened first square block and an unselected square block to be determined; a second screening unit 40 for screening all the blocks to be determined based on the central moment of the blocks to be determined to obtain a second block which meets the preset central moment condition, and combining the first block and the second block to obtain a target block set; the determining unit 50 determines a target scanning area containing a barcode to be scanned through the target square set, scans the target scanning area to obtain a target barcode, solves the problem of inaccurate barcode scanning result in the related art, divides a target image into square sets, performs primary screening on the square sets according to skeleton characteristics of the squares to obtain a first square, performs secondary screening on the square to be determined according to a center moment to obtain a second square, and determines the target scanning area through the first square and the second square set and the obtained target square set, thereby scanning the target scanning area to obtain the target barcode, and further achieving the effect of improving the accuracy of the barcode scanning result.
Optionally, in the barcode scanning device provided in the embodiment of the present application, the first screening unit 30 includes: the first judging module is used for judging whether the number of elements contained in the skeleton characteristics of the square to be screened is larger than or equal to a first number threshold value for each square in the square set; the first determining module is used for determining the square to be screened as a square to be determined under the condition that the number of elements is smaller than a first number threshold value; the second judging module is used for judging whether the square to be screened contains parallel lines or not under the condition that the number of the elements is larger than or equal to a first number threshold value; the second determining module is used for determining the square to be screened as a square to be determined under the condition that the square to be screened does not contain parallel lines; and the first screening module is used for screening the first square and the square to be determined through the characteristics of the parallel lines in the case that the square to be screened contains the parallel lines.
Optionally, in the barcode scanning device provided in the embodiment of the present application, the first screening module includes: the first determining submodule is used for determining the proportion of the number of straight lines contained in parallel lines to all the straight lines in the square to be screened to obtain a target proportion; the second determining submodule is used for determining the square to be screened as the square to be determined under the condition that the target proportion is smaller than the proportion threshold value; a third determining submodule, configured to determine a target length of a longest straight line among parallel lines when the target proportion is greater than or equal to the proportion threshold; a fourth determining submodule, configured to determine a block to be screened as a block to be determined if the target length is less than the length threshold; and a fifth determining submodule, configured to determine a block to be screened as a first block when the target length is greater than or equal to the length threshold.
Optionally, in the barcode scanning device provided in the embodiment of the present application, the second screening unit 40 includes: the first acquisition module is used for acquiring the current scanning times corresponding to the target image and judging whether the current scanning times are greater than or equal to a scanning times threshold value; the second acquisition module is used for acquiring the first central moment of each first square block to obtain a group of first central moments under the condition that the current scanning times are larger than or equal to a scanning times threshold value; the third determining module is used for determining a second center moment of each block to be determined, calculating the similarity between the second center moment and each first center moment in the group of first center moments, and obtaining a group of first similarity; and the fourth determining module is used for determining the block to be determined as the second block under the condition that at least one first similarity is larger than or equal to a first similarity threshold value in a group of first similarities.
Optionally, in the barcode scanning device provided in the embodiment of the present application, the device further includes: an angle determining unit, configured to determine, for each square in the target square set, a first angle of a parallel line in the current square, where the first angle is an angle between a bottom edge of the current square and the parallel line; the first judging unit is used for judging whether the second angle and the first angle of parallel lines in other blocks are the same, wherein the other blocks are blocks except the current block in the target block set, and the second angle is an included angle between the bottom edges of the other blocks and the parallel lines of the other blocks; a first marking unit for marking the current square with the same color as the other squares in the case that there is at least one other square in which the second angle of the parallel lines is the same as the first angle; and the second marking unit is used for marking the current square block with a new color under the condition that the second angles and the first angles of the parallel lines in all other square blocks are different, wherein the color of the new color is different from that of each other square block.
Optionally, in the barcode scanning device provided in the embodiment of the present application, the device further includes: the second judging unit is used for determining the color of each square in the target square set and judging whether the colors of all squares in the target square set are the same or not; the rejecting unit is used for determining the square marked with the target color under the condition that the square with different colors exists in the target square set, and rejecting all the square marked with other colors except the target color from the target square set, wherein the target color is the color marked by the square with the largest number in the square with the same color; and the execution unit is used for executing the step of determining the target scanning area containing the bar code to be scanned through the target square block set under the condition that the colors of all the square blocks in the target square block set are the same.
Optionally, in the barcode scanning device provided in the embodiment of the present application, the determining unit 50 includes: a fifth determining module, configured to determine all connected blocks in the target block set, to obtain at least one connected area; the third judging module is used for judging whether the number of the square blocks contained in the area is larger than or equal to a second number threshold value; a sixth determining module, configured to determine the area as the first area when the number of blocks is greater than or equal to the second number threshold; the calculating module is used for calculating the similarity of the direction vector of the parallel lines of the square blocks in the area and the direction vector of the parallel lines of the square blocks in other areas under the condition that the number of the square blocks is smaller than a second number threshold value, so as to obtain a second similarity; the merging module is used for merging the region and other regions into one region to obtain a second region under the condition that the second similarity is larger than or equal to a second similarity threshold value; the dividing module is used for dividing the rectangular area based on the outlines of the outer square blocks of the first area and the second area to obtain a target scanning area.
Optionally, in the barcode scanning device provided in the embodiment of the present application, the target image is acquired by: controlling a camera of the mobile equipment to shoot an object containing a bar code to be scanned to obtain a pending image; controlling a camera to re-shoot an object containing the bar code to be scanned under the condition that the bar code to be scanned is not recognized from the image to be determined until the bar code to be scanned is recognized from the image to be determined, wherein under the condition that the shooting frequency of re-shooting is greater than or equal to the threshold value of the shooting frequency, controlling a flashlight of the mobile equipment to be started, and adjusting the distance between the camera and the object containing the bar code to be scanned; and in the case that the bar code to be scanned is identified from the pending images, determining the pending images as target images.
Optionally, in the barcode scanning device provided in the embodiment of the present application, in a case that the mobile device includes a plurality of cameras, the camera corresponding to the highest resolution is determined as the target camera, and the object including the barcode to be scanned is shot by the target camera.
The barcode scanning device includes a processor and a memory, the above-mentioned acquisition unit 10, extraction unit 20, first screening unit 30, second screening unit 40, determination unit 50, and the like are stored in the memory as program units, and the processor executes the above-mentioned program units stored in the memory to realize the corresponding functions.
The processor includes a kernel, and the kernel fetches the corresponding program unit from the memory. The kernel can be provided with one or more than one, and the accuracy of the bar code scanning result is improved by adjusting the kernel parameters.
The memory may include volatile memory, random Access Memory (RAM), and/or nonvolatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM), among other forms in computer readable media, the memory including at least one memory chip.
The embodiment of the invention provides a computer readable storage medium, on which a program is stored, which when executed by a processor, implements a bar code scanning method.
The embodiment of the invention provides a processor, which is used for running a program, wherein the program runs to execute a bar code scanning method.
Fig. 7 is a schematic diagram of an electronic device provided according to an embodiment of the present application. As shown in fig. 7, the electronic device 701 includes a processor, a memory, and a program stored on the memory and executable on the processor, and the processor implements the following steps when executing the program: acquiring a target image containing a bar code to be scanned, performing binarization processing on the target image, and equally dividing the target image after the binarization processing into square sets; extracting skeleton features from each square of the square set to obtain a group of skeleton feature sets; screening the square blocks in the square block set through skeleton characteristics to obtain a screened first square block and an unselected undeveloped square block; screening all the blocks to be determined based on the central moment of the blocks to be determined to obtain a second block which meets the preset central moment condition, and combining the first block with the second block to obtain a target block set; and determining a target scanning area containing the bar code to be scanned through the target square set, and scanning the target scanning area to obtain the target bar code. The device herein may be a server, PC, PAD, cell phone, etc.
The present application also provides a computer program product adapted to perform, when executed on a data processing device, a program initialized with the method steps of: acquiring a target image containing a bar code to be scanned, performing binarization processing on the target image, and equally dividing the target image after the binarization processing into square sets; extracting skeleton features from each square of the square set to obtain a group of skeleton feature sets; screening the square blocks in the square block set through skeleton characteristics to obtain a screened first square block and an unselected undeveloped square block; screening all the blocks to be determined based on the central moment of the blocks to be determined to obtain a second block which meets the preset central moment condition, and combining the first block with the second block to obtain a target block set; and determining a target scanning area containing the bar code to be scanned through the target square set, and scanning the target scanning area to obtain the target bar code.
It will be appreciated by those skilled in the art that embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In one typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include volatile memory in a computer-readable medium, random Access Memory (RAM) and/or nonvolatile memory, etc., such as Read Only Memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.
Computer readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of storage media for a computer include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by a computing device. Computer-readable media, as defined herein, does not include transitory computer-readable media (transmission media), such as modulated data signals and carrier waves.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article or apparatus that comprises an element.
It will be appreciated by those skilled in the art that embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The foregoing is merely exemplary of the present application and is not intended to limit the present application. Various modifications and changes may be made to the present application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc. which are within the spirit and principles of the present application are intended to be included within the scope of the claims of the present application.

Claims (12)

1. A method of bar code scanning comprising:
acquiring a target image containing a bar code to be scanned, performing binarization processing on the target image, and equally dividing the target image subjected to the binarization processing into square sets;
extracting skeleton features from each square of the square set to obtain a group of skeleton feature sets;
screening the blocks in the block set through the skeleton characteristics to obtain a screened first block and an unselected block to be determined;
screening all the blocks to be determined based on the central moment of the blocks to be determined to obtain a second block which meets the preset central moment condition, and combining the first block with the second block to obtain a target block set;
and determining a target scanning area containing the bar code to be scanned through the target square set, and scanning the target scanning area to obtain a target bar code.
2. The method of claim 1, wherein screening the blocks in the set of blocks by the skeletal feature to obtain a screened first block and an unselected pending block comprises:
for each square in the square set, judging whether the number of elements contained in the skeleton characteristics of the square to be screened is larger than or equal to a first number threshold;
Determining the block to be screened as the block to be determined under the condition that the element number is smaller than the first number threshold;
judging whether the square to be screened contains parallel lines or not under the condition that the element number is larger than or equal to the first number threshold value;
determining the square to be screened as the square to be determined under the condition that the square to be screened does not contain parallel lines;
in the case that the square to be screened comprises parallel lines, screening the first square and the square to be determined through the characteristics of the parallel lines.
3. The method of claim 2, wherein screening the first square and the pending square by features of parallel lines comprises:
determining the proportion of the number of straight lines contained in the parallel lines to all the straight lines in the square to be screened to obtain a target proportion;
determining the square to be screened as the square to be determined under the condition that the target proportion is smaller than a proportion threshold value;
determining the target length of the longest straight line in the parallel lines under the condition that the target proportion is greater than or equal to the proportion threshold value;
determining the square to be screened as the square to be determined under the condition that the target length is smaller than a length threshold value;
And determining the square to be screened as the first square under the condition that the target length is greater than or equal to a length threshold value.
4. The method of claim 1, wherein screening all of the pending blocks based on the central moment of the pending blocks to obtain a second block that meets a preset central moment condition comprises:
acquiring the current scanning times corresponding to the target image, and judging whether the current scanning times are greater than or equal to a scanning times threshold value;
under the condition that the current scanning times is larger than or equal to the scanning times threshold value, acquiring a first center moment of each first square block to obtain a group of first center moments;
for each block to be determined, determining a second central moment of the block to be determined, and calculating the similarity between the second central moment and each first central moment in the group of first central moments to obtain a group of first similarity;
and determining the block to be determined as the second block under the condition that at least one first similarity in the group of first similarities is larger than or equal to a first similarity threshold value.
5. The method of claim 1, wherein prior to determining a target scan area containing the barcode to be scanned by the set of target tiles, the method further comprises:
For each square in the target square set, determining a first angle of parallel lines in a current square, wherein the first angle is an included angle between the bottom edge of the current square and the parallel lines;
judging whether a second angle of parallel lines in other blocks is the same as the first angle, wherein the other blocks are blocks except the current block in the target block set, and the second angle is an included angle between the bottom edges of the other blocks and the parallel lines of the other blocks;
marking the current square with the same color as the other squares if there is a second angle of parallel lines in at least one other square that is the same as the first angle;
and marking the current square block with a new color under the condition that the second angle of the parallel lines in all other square blocks is different from the first angle, wherein the color of the new color is different from that of each other square block.
6. The method of claim 5, wherein prior to determining a target scan area containing the barcode to be scanned by the set of target tiles, the method further comprises:
Determining the color of each square in the target square set, and judging whether the colors of all squares in the target square set are the same;
determining blocks marked with target colors under the condition that blocks with different colors exist in the target block set, and eliminating all blocks marked with other colors except the target colors from the target block set, wherein the target colors are the colors of the most square marks in the blocks with the same colors;
and under the condition that the colors of all the squares in the target square set are the same, executing the step of determining a target scanning area containing the bar code to be scanned through the target square set.
7. The method of claim 1, wherein determining, by the set of target tiles, a target scan area containing the barcode to be scanned comprises:
determining all connected blocks in the target block set to obtain at least one connected region;
judging whether the number of the square blocks contained in the area is larger than or equal to a second number threshold value;
determining the area as a first area when the number of the squares is greater than or equal to the second number threshold;
Calculating the similarity of the direction vector of the parallel lines of the square blocks in the area and the direction vector of the parallel lines of the square blocks in other areas under the condition that the number of the square blocks is smaller than the second number threshold value, so as to obtain a second similarity;
combining the region and other regions into one region to obtain a second region under the condition that the second similarity is larger than or equal to a second similarity threshold;
and dividing a rectangular area based on the outlines of the outer square blocks of the first area and the second area to obtain the target scanning area.
8. The method of claim 1, wherein the target image is acquired by:
controlling a camera of the mobile equipment to shoot an object containing the bar code to be scanned to obtain a pending image;
controlling the camera to re-shoot an object containing the bar code to be scanned under the condition that the bar code to be scanned is not recognized from the image to be determined, until the bar code to be scanned is recognized from the image to be determined, wherein under the condition that the shooting frequency of re-shooting is greater than or equal to a shooting frequency threshold value, controlling a flashlight of the mobile equipment to be started, and adjusting the distance between the camera and the object containing the bar code to be scanned;
And determining the pending image as the target image under the condition that the bar code to be scanned is identified from the pending image.
9. The method according to claim 8, wherein in case the mobile device comprises a plurality of cameras, determining the camera corresponding to the highest resolution as a target camera, and photographing the object comprising the barcode to be scanned by the target camera.
10. A bar code scanning device, comprising:
the acquisition unit is used for acquiring a target image containing a bar code to be scanned, carrying out binarization processing on the target image, and equally dividing the target image subjected to the binarization processing into square sets;
the extraction unit is used for extracting skeleton features from each square of the square set to obtain a group of skeleton feature sets;
the first screening unit is used for screening the blocks in the block set through the skeleton characteristics to obtain a screened first block and an unselected pending block;
the second screening unit is used for screening all the to-be-determined squares based on the center moment of the to-be-determined squares to obtain a second square which meets the preset center moment condition, and combining the first square with the second square to obtain a target square set;
And the determining unit is used for determining a target scanning area containing the bar code to be scanned through the target square set, and scanning the target scanning area to obtain a target bar code.
11. A non-volatile storage medium, characterized in that the non-volatile storage medium comprises a stored program, wherein the program, when run, controls a device in which the non-volatile storage medium is located to perform the barcode scanning method of any one of claims 1 to 9.
12. An electronic device comprising one or more processors and a memory for storing one or more programs, wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the barcode scanning method of any of claims 1-9.
CN202311725113.3A 2023-12-14 2023-12-14 Bar code scanning method and device, storage medium and electronic equipment Pending CN117709380A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311725113.3A CN117709380A (en) 2023-12-14 2023-12-14 Bar code scanning method and device, storage medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311725113.3A CN117709380A (en) 2023-12-14 2023-12-14 Bar code scanning method and device, storage medium and electronic equipment

Publications (1)

Publication Number Publication Date
CN117709380A true CN117709380A (en) 2024-03-15

Family

ID=90154819

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311725113.3A Pending CN117709380A (en) 2023-12-14 2023-12-14 Bar code scanning method and device, storage medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN117709380A (en)

Similar Documents

Publication Publication Date Title
CN110378165B (en) Two-dimensional code identification method, two-dimensional code positioning identification model establishment method and device
CN101416219B (en) Foreground/background segmentation in digital images
CN106897648B (en) Method and system for identifying position of two-dimensional code
CN107633526B (en) Image tracking point acquisition method and device and storage medium
CN102722881B (en) Operationally process the method and system of monochromatic image data
GB2549554A (en) Method and system for detecting an object in an image
CN104217202B (en) Information identifying method, equipment and system
US11908160B2 (en) Method and apparatus for context-embedding and region-based object detection
US11699283B2 (en) System and method for finding and classifying lines in an image with a vision system
US11003963B2 (en) Method and system for identifying targets in scenes shot by a camera
CN111339887B (en) Commodity identification method and intelligent container system
RU2729399C1 (en) Method for detection and recognition of visual markers of long range and high density
Burghardt et al. Automated visual recognition of individual African penguins
Wang et al. CSA-CDGAN: channel self-attention-based generative adversarial network for change detection of remote sensing images
CN108040244B (en) Snapshot method and device based on light field video stream and storage medium
JP6511950B2 (en) Image processing apparatus, image processing method and program
Liu et al. Deep learning-based automatic player identification and logging in american football videos
CN117709380A (en) Bar code scanning method and device, storage medium and electronic equipment
CN114926508B (en) Visual field boundary determining method, device, equipment and storage medium
CN103544465B (en) A kind of decoding two-dimensional bar code recognition methods and device
JP4550768B2 (en) Image detection method and image detection apparatus
CN109409387A (en) The acquisition direction of image capture device determines method, apparatus and electronic equipment
US11734531B2 (en) Methods and systems of harvesting data for training machine learning (ML) model
Apostolidis et al. Fast object re-detection and localization in video for spatio-temporal fragment creation
Uskenbayeva et al. Contour analysis of external images

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination