Barcode recognition method, device, equipment, storage medium and product
By constructing a rough stitching image and performing translation adjustments, the problem of barcodes with large inclination angles on the test tube cannot be recognized, and effective acquisition of test tube information is achieved.
Patent Information
- Application Number
- CN202411804388.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-10
- Publication Date
- 2025-04-08
- Estimated Expiration
- 2044-12-10
AI Technical Summary
The prior art cannot identify barcodes with a large inclination angle on the test tube, resulting in the inability to obtain test tube information.
By setting the effective number of rows in the window of the plane array camera, obtain the multi-frame scanned image of the test tube during rotation, construct a rough stitching image, select candidate areas, determine the barcode positioning points and lines, adjust the image translation, generate the stitching barcode image, and finally identify it.
The normal identification of barcodes with a large inclination angle on the test tube is achieved, ensuring the acquisition of test tube information.
Smart Images

Figure CN119272787B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of intelligent identification technology, and in particular to barcode identification methods, devices, equipment, storage media and products. Background Art
[0002] Test tubes are frequently used in fields such as chemistry and medicine. In order to enable intelligent processing and ensure that the purpose, function, results and other information of each test tube can be distinguished, corresponding barcodes are set on the walls of the test tubes (such as by attaching barcodes with stickers). Then, by acquiring images and identifying the barcodes in the test tube images, the corresponding information of the test tubes can be obtained.
[0003] However, due to the particularity of the test tube, if the barcode sticker is tilted at a large angle, it is impossible to guarantee that the test tube image contains the completed barcode when the image is captured from any angle, resulting in the inability to recognize the barcode on the test tube. Summary of the invention
[0004] The main purpose of the present application is to provide a barcode recognition method, device, equipment, storage medium and product, aiming to solve the technical problem that the related technology cannot recognize the barcode with a large inclination angle attached to the test tube.
[0005] To achieve the above objectives, the present application proposes a barcode recognition method, the method comprising:
[0006] The number of effective rows of the area array camera window is set according to the diameter of the test tube to be identified;
[0007] Acquire multiple frames of scanned images of the test tube to be identified during the rotation process based on the set area array camera, wherein a barcode is set on the wall of the test tube to be identified, and the scanned image is an image when the wall of the test tube to be identified is scanned;
[0008] Constructing a rough spliced image according to the plurality of frames of scanned images, and selecting at least one candidate region from the rough spliced image;
[0009] Determine a barcode positioning point according to the gradient direction corresponding to each candidate area, and determine a barcode line corresponding to each image in the roughly spliced image according to the barcode positioning point;
[0010] Determine the relative number of misaligned pixels between each group of adjacent images in the roughly spliced image based on the barcode line;
[0011] Based on the relative number of misaligned pixels, translation adjustment is performed on each currently processed image in the roughly spliced image to generate a spliced barcode image;
[0012] The spliced barcode image is identified to obtain barcode information.
[0013] In a possible implementation of the present application, constructing a rough spliced image according to multiple frames of scanned images includes:
[0014] Detect whether there is a previously constructed fine mosaic;
[0015] If it exists, the last stitched image in the fine stitched image is used as the stitching reference image;
[0016] If it does not exist, the image with the earliest corresponding image acquisition time among the multiple frames of the scanned images is used as the stitching reference image;
[0017] Based on the stitching reference image, the scanned images are stitched in sequence in the order of the corresponding image acquisition moments to generate a rough stitching image.
[0018] In a possible implementation of the present application, selecting at least one candidate region from the roughly stitched image includes:
[0019] Performing gradient calculation on the roughly stitched image to obtain gradient response distribution information corresponding to the roughly stitched image;
[0020] At least one candidate region is selected from the roughly spliced image based on the gradient response distribution information and a preset response threshold.
[0021] In a possible implementation of the present application, determining the barcode positioning point according to the gradient direction corresponding to each candidate area includes:
[0022] Count the number of gradient directions corresponding to each candidate region to obtain the statistical count corresponding to each gradient direction;
[0023] Selecting a barcode direction from each gradient direction based on the statistical count;
[0024] A barcode positioning point that conforms to the barcode direction is selected from the candidate area.
[0025] In a possible implementation of the present application, determining the relative number of misaligned pixels between each group of adjacent images in the roughly stitched image based on the barcode line includes:
[0026] Traversing each group of adjacent images in the roughly spliced image, and taking the traversed group of adjacent images as a target processing image;
[0027] According to each preset number of misaligned pixels, the target processed image is respectively misaligned to obtain an edge line set corresponding to each preset number of misaligned pixels, wherein the edge line set includes continuous edge lines in the target processed image after the misalignment adjustment, and the continuous edge line is a line constructed when barcode lines in two adjacent current processed images are continuous;
[0028] Calculate the sum of the lengths of the continuous edge lines in each edge line set respectively, and obtain the continuous edge lengths corresponding to each preset number of misaligned pixels;
[0029] Selecting a relative number of misaligned pixels corresponding to the target processed image from each preset number of misaligned pixels according to the continuous edge length;
[0030] At the end of the traversal, the relative number of misaligned pixels between each group of adjacent images in the roughly stitched image is obtained.
[0031] In a possible implementation of the present application, constructing a rough spliced image according to multiple frames of scanned images includes:
[0032] Comparing the scanned images that are adjacent in time sequence to determine the extent of content change between the scanned images that are adjacent in time sequence;
[0033] If the content change amplitude is less than a preset amplitude threshold, removing the scanned image with an earlier time sequence from the scanned images adjacent in time sequence;
[0034] After the removal is completed, a rough stitched image is constructed based on the processed scanned images.
[0035] In addition, to achieve the above purpose, the present application also proposes a barcode recognition device, the device comprising:
[0036] A setting module, used to set the number of effective rows of the window of the area array camera according to the test tube diameter of the test tube to be identified;
[0037] An acquisition module, used for acquiring multiple frames of scanned images of the test tube to be identified in the process of rotation based on the set area array camera, wherein a barcode is set on the wall of the test tube to be identified, and the scanned image is an image when the wall of the test tube to be identified is scanned;
[0038] A stitching module, used for constructing a rough stitching image according to the plurality of scanned images, and selecting at least one candidate region from the rough stitching image;
[0039] A positioning module, used to determine a barcode positioning point according to a gradient direction corresponding to each candidate area, and determine a barcode line corresponding to each image in the roughly spliced image according to the barcode positioning point;
[0040] A determination module, used for determining the relative number of misaligned pixels between each group of adjacent images in the roughly spliced image based on the barcode line;
[0041] An adjustment module, configured to perform translation adjustment on each currently processed image in the roughly spliced image based on the relative number of misaligned pixels to generate a spliced barcode image;
[0042] The recognition module is used to recognize the spliced barcode image to obtain barcode information.
[0043] In addition, to achieve the above objectives, the present application also proposes a barcode recognition device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the barcode recognition method described above.
[0044] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the barcode recognition method as described above are implemented.
[0045] In addition, to achieve the above-mentioned purpose, the present application also proposes a computer program product, which includes a computer program, and when the computer program is executed by a processor, the steps of the barcode recognition method described above are implemented.
[0046] One or more technical solutions proposed in this application have at least the following technical effects:
[0047] The effective number of rows of the area array camera window is set according to the test tube diameter of the test tube to be identified, and based on the set area array camera, multiple frames of scanned images of the test tube to be identified in the rotation process are obtained to construct a rough stitching image, and a candidate area is selected from the rough stitching image; the barcode positioning point is determined according to the gradient direction corresponding to the candidate area, and the barcode line in the rough stitching image is determined according to the barcode positioning point; the relative number of misaligned pixels between each group of adjacent images in the rough stitching image is determined based on the barcode line; the image in the rough stitching image is translated and adjusted based on the relative number of misaligned pixels to generate a stitching barcode image, and a stitching barcode image with a complete barcode is generated, and then the stitching barcode image is identified to ensure that even if the barcode is attached to the test tube wall at a large inclination angle, barcode recognition can still be performed normally. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0049] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0050] Figure 1 A schematic diagram of the process flow provided for the first embodiment of the barcode recognition method of the present application;
[0051] Figure 2 A schematic diagram of the process flow provided for the second embodiment of the barcode recognition method of the present application;
[0052] Figure 3 A flowchart of the third embodiment of the barcode recognition method of the present application is provided;
[0053] Figure 4 A schematic diagram of the effective number of rows of an area array camera window according to an embodiment of the present application;
[0054] Figure 5 A schematic diagram of image stitching according to an embodiment of the present application;
[0055] Figure 6 A schematic diagram of a continuous edge line according to an embodiment of the present application;
[0056] Figure 7 This is a schematic diagram of the module structure of the barcode recognition device according to an embodiment of the present application;
[0057] Figure 8 Schematic diagram of the device structure of the hardware operating environment involved in the barcode recognition method in the embodiment of the present application.
[0058] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0059] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.
[0060] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.
[0061] Based on this, the present application embodiment provides a barcode recognition method, referring to Figure 1 , Figure 1 This is a flowchart of the first embodiment of the barcode recognition method of the present application.
[0062] In this embodiment, the barcode recognition method includes steps S10 to S70:
[0063] Step S10: setting the number of effective rows of the area array camera window according to the test tube diameter of the test tube to be identified.
[0064] It should be noted that the executor of this embodiment can be the barcode recognition device, and the barcode recognition device can be an electronic device such as a personal computer or a server, or other devices that can achieve the same or similar functions. This embodiment does not limit this. In this embodiment and the following embodiments, the barcode recognition method of the present invention is described by taking the barcode recognition device as an example.
[0065] It should be noted that the effective number of rows of the area array camera window can be used to characterize the size of the image captured when the area array camera captures a single image. In order to ensure the efficiency of acquisition, the effective number of rows of the area array camera window during acquisition can be determined according to the diameter of the test tube.
[0066] In actual use, the scanning line number corresponding to the test tube diameter can be found in the diameter-line-number mapping table, wherein the correspondence between the test tube diameter and the scanning line number can be stored in the diameter-line-number mapping table, and the correspondence can be pre-set by the manager of the barcode recognition equipment.
[0067] Of course, the number of scanning lines can also be calculated according to the test tube diameter through a set formula, such as calculating the overall area of the test tube wall according to the test tube diameter, dividing the overall area by the area of the single-line scanning region, and taking the divided product as the number of scanning lines.
[0068] It is understandable that the larger the test tube diameter is, the larger the overall area of the test tube wall to be collected is. In order to ensure the efficiency of barcode recognition, the time for barcode recognition on a single test tube is generally similar or fixed. Based on this, the larger the test tube diameter is, the larger the corresponding number of scanning lines is; conversely, the smaller the test tube diameter is, the smaller the corresponding number of scanning lines is.
[0069] Step S20: acquiring multiple frames of scanning images of the test tube to be identified during its rotation process based on the configured area array camera.
[0070] It should be noted that the test tube to be identified may be a test tube that needs to be barcode identified and has a barcode on its wall, and the scanned image may be an image acquired when scanning the wall of the test tube to be identified.
[0071] In actual use, when obtaining multiple-frame scanning images of the test tube to be identified, in order to ensure the efficiency of acquisition and the continuity of the acquired images, the test tube to be identified can be rotated at a preset uniform speed (or approximately uniform speed), and the set area array camera can continuously perform image acquisition during the rotation of the test tube to be identified (the frequency of image acquisition can be determined according to the rotation speed of the test tube to be identified, and the faster the rotation speed, the higher the acquisition frequency), thereby obtaining multiple-frame scanning images.
[0072] In actual application, in order to ensure that a complete barcode can be constructed based on the collected multi-frame scanned images, it is necessary to ensure that images are collected at all angles of the wall of the test tube to be identified. Therefore, when controlling the rotation of the test tube to be identified, the test tube to be identified can be rotated at least one circle. If necessary, a certain rotation redundancy can be set, such as rotating the test tube to be identified one and a half circles.
[0073] Among them, the corresponding machine or equipment can be used to control the rotation of the test tube to be identified, for example, a roller is used to drive the test tube to be identified to rotate at a constant speed (or approximately constant speed). The image acquisition device used can be a line scan camera (with a speed encoder). In order to avoid the influence of some irrelevant factors, irrelevant areas can be pre-set in the scanned image, wherein the barcode recognition device will ignore the image content in the irrelevant area when performing image processing.
[0074] Step S30: constructing a rough spliced image according to the multiple frames of the scanned images, and selecting at least one candidate region from the rough spliced image.
[0075] In actual use, when constructing a roughly stitched image based on multiple frames of scanned images, the scanned images may be stitched together in sequence according to the order of acquisition time, and the stitched image is used as the roughly stitched image.
[0076] Among them, when stitching the scanned images, they can also be stitched according to the rotation direction of the test tube to be identified. For example, if the rotation direction of the test tube to be identified is from top to bottom (in terms of the direction of the roller, it can be expressed as counterclockwise), then the scanned image that was acquired earlier is at the top when stitching, and the scanned images are stitched in sequence from top to bottom.
[0077] It should be noted that the candidate area may be an image area in the roughly spliced image where a barcode line may exist, wherein the barcode line may be a line constituting a barcode.
[0078] In actual use, the barcode lines in the roughly spliced image can be identified through a pre-trained model, and at least one candidate area can be selected from the roughly spliced image based on the identification result.
[0079] In a possible implementation of this embodiment, the candidate region may be selected by using a gradient change. The step of selecting at least one candidate region from the roughly spliced image in this embodiment may include:
[0080] Performing gradient calculation on the roughly stitched image to obtain gradient response distribution information corresponding to the roughly stitched image;
[0081] At least one candidate region is selected from the roughly spliced image based on the gradient response distribution information and a preset response threshold.
[0082] It should be noted that since a barcode generally includes multiple barcode lines, and the intervals between the barcode lines may be small, it may be difficult to guarantee the recognition effect by directly using the model for recognition. In actual application, the color difference between the barcode line color (such as black, red, blue, etc.) and the background color (the background color is generally white or other lighter colors) is generally large. Therefore, the color change can be used to determine the candidate area. Therefore, the gradient calculation can be performed on the roughly spliced image to obtain the gradient response distribution information corresponding to the roughly spliced image. Among them, the gradient distribution information may include the gradient response corresponding to each point or area in the roughly spliced image. The gradient response is used to characterize the color difference between a point and other points. The larger the gradient response, the greater the color difference.
[0083] In actual use, after obtaining the gradient response distribution information, the gradient response corresponding to each point or region in the rough spliced image can be determined according to the gradient response distribution information, and the points or regions in the rough spliced image whose corresponding gradient response is greater than or equal to the preset response threshold are taken as candidate regions. The preset response threshold can be pre-set by the administrator of the barcode recognition method.
[0084] Step S40: determining a barcode positioning point according to the gradient direction corresponding to each candidate region, and determining a barcode line corresponding to each image in the roughly spliced image according to the barcode positioning point.
[0085] It should be noted that, in some cases, there may be some influencing factors in the recognition environment (such as equipment knots, dirt, etc.), which may cause some areas to be mistakenly recognized as candidate areas. On this basis, such misidentified areas need to be excluded. Since a barcode generally contains multiple barcode lines, the directions of the barcode lines are actually the same. On this basis, the gradient directions of the candidate areas corresponding to the true barcode lines should actually be consistent. Therefore, the barcode direction of the true barcode line can be determined in combination with the gradient directions corresponding to the candidate areas, and the barcode positioning points can be located. After that, the barcode lines corresponding to the current processed images in the roughly stitched image are determined according to the barcode positioning points.
[0086] In a possible implementation of this embodiment, the true barcode direction may be determined by the statistical quantity of the gradient direction. In this case, the step of determining the barcode positioning point according to the gradient direction corresponding to each candidate area in this embodiment may include:
[0087] Count the number of gradient directions corresponding to each candidate region to obtain the statistical count corresponding to each gradient direction;
[0088] Selecting a barcode direction from each gradient direction based on the statistical count;
[0089] A barcode positioning point that conforms to the barcode direction is selected from the candidate area.
[0090] In actual use, a barcode generally contains multiple barcode lines, and the directions of the barcode lines are actually the same. Based on this, the gradient directions corresponding to the candidate regions can be counted to obtain the statistical counts corresponding to the gradient directions, where the statistical counts corresponding to the gradient directions can represent the number of candidate regions corresponding to the gradient directions.
[0091] It is understandable that even if influencing factors appear, their number is generally small, while the number of barcode lines is generally large. Therefore, it can be considered that the gradient direction with the most occurrences is actually the true barcode direction. Therefore, the gradient direction with the largest corresponding statistical count can be selected as the barcode direction. After that, the points in each candidate area that meet the gradient direction can be used as barcode positioning points.
[0092] Step S50: determining the relative number of misaligned pixels between each group of adjacent images in the roughly spliced image based on the barcode line.
[0093] In actual use, the number of relative misaligned pixels between adjacent currently processed images can be determined by translating adjacent currently processed images to determine the number and / or length of continuous barcode lines.
[0094] Step S60: performing translation adjustment on each image in the roughly spliced image based on the relative number of misaligned pixels to generate a spliced barcode image.
[0095] It should be noted that, since the wall of the test tube is actually a special curved shape, and the images collected in multiple frames are directly stitched together, there may be slight misalignment between the barcode lines. Such stitching may cause the barcode in the final image to appear "intermittent", and even if the barcode is too compact, it may cause confusion among the barcode lines in each barcode. In order to avoid this situation, the barcode lines in each group of images in the roughly stitched image can be compared and analyzed to determine the relative number of misaligned pixels between each group of adjacent images in each roughly stitched image.
[0096] In actual use, after determining the relative number of misaligned pixels, each image in the roughly stitched image can be translated and adjusted according to the relative number of misaligned pixels, so that a certain pixel misalignment is maintained between adjacent images in the roughly stitched image, thereby ensuring that each barcode line can remain continuous, thereby generating a stitched barcode image.
[0097] Step S70: Identify the spliced barcode image to obtain barcode information.
[0098] In actual use, since the multi-frame scanned images are obtained by continuously acquiring images while controlling the rotation of the test tube to be identified, and the test tube to be identified rotates at least one circle, the multi-frame scanned images actually contain images of the test tube wall at various angles. The multi-frame scanned images obtained are spliced in chronological order of acquisition time, and the obtained image must contain a complete barcode. Therefore, at this time, the spliced barcode image can be identified to determine the information contained in the barcode, thereby obtaining the barcode information.
[0099] It is understandable that after obtaining the barcode information, the relevant information corresponding to the test tube to be identified can be found according to the barcode information. Of course, if necessary, the barcode information can also be directly stored or sent to other devices for their use.
[0100] It should be noted that, depending on the frequency of acquisition, the acquired scanned image may contain many frames. For example, for the test tube to be identified, the acquired scanned image contains 100 frames after one rotation. If too many frames of images are processed at the same time, too much image data will need to be read into the memory, and it will take time to process each frame of the image. The overall time consumption is relatively long, and once a processing abnormality occurs in the middle, the overall processing flow will fail. In order to avoid this situation, the number of image frames processed each time can be reduced. Therefore, a part (at least one frame) can be selected from the multiple frames of scanned images as the current processing image. After that, the acquired current processing image is used as the scanned image to be processed, and the processing flow of steps S30-S60 is executed, and the image generated after translation adjustment is used as a fine mosaic.
[0101] In actual use, the current processing image may be a scanned image currently undergoing splicing processing. When selecting the current processing image, a preset number of scanned images may be selected from multiple frames of scanned images as the current processing image.
[0102] The preset number can be set in advance by the administrator of the barcode recognition device, such as setting the preset number to 2, 5 or other values. In order to ensure the normal stitching of the image, when selecting the current processing image, the collection time corresponding to the selected current processing image needs to be adjacent.
[0103] For example: assuming that there are 100 multi-frame scanned images in total, they can be sorted in chronological order and numbered 1-100. If the preset number is 5, when the current processing image is selected for the first time, the scanned images numbered 1-5 can be selected as the current processing image. When selecting again, the scanned images numbered 6-10 can be selected as the current processing image, and so on.
[0104] In actual use, when translating, a frame can be selected from the coarsely stitched image as the translation reference frame. For example, if the coarsely stitched image is constructed based on the previously constructed fine stitched image and the current processed image, the last stitched frame in the previously constructed fine stitched image can be used as the translation reference frame; and if the coarsely stitched image is constructed directly based on the current processed image, a frame (such as the earliest frame in time sequence, or the latest frame in time sequence) can be directly selected from the current processed image as the stitching reference frame.
[0105] After generating the fine stitching image, it is also possible to detect whether the processing of all scanned images has been completed. If there is no scanned image that has not been selected as the current processing image, it means that each scanned image has been stitched and translated. At this time, it can be determined that the processing is completed. Therefore, the generated fine stitching image can be used as a stitching barcode image.
[0106] The stitching completion signal can be sent by the management personnel, or it can be a signal or label that has been set in the multi-frame scan to indicate the completion of image acquisition during scanning (for example, when the roller drives the test tube to rotate, it rotates a preset number of times, and then a signal can be sent to the image acquisition device, and the image acquisition device sets the corresponding stitching completion signal in the currently acquired scanned image or after the image). If the stitching completion signal is detected during the processing, it can also be determined that the processing is completed. Therefore, the generated fine stitching image can be used as a stitching barcode image.
[0107] If there are scanned images that have not been selected and no stitching completion signal is detected, it means that there are scanned images that have not been processed accordingly. At this time, the current processed image can be selected to continue processing.
[0108] In a possible implementation of this embodiment, since the currently processed images may be selected in batches for processing in multiple batches, and in order to ensure that the finally obtained image contains a complete barcode, it is necessary to ensure that the finally obtained mosaic is composed of multiple frames of scanned images as a whole. Therefore, when constructing a rough mosaic, it is also possible to detect whether there is a previously constructed fine mosaic, so as to determine how to construct the rough mosaic. At this time, the step of constructing a rough mosaic according to the multiple frames of scanned images in this embodiment may include:
[0109] Detect whether there is a previously constructed fine mosaic;
[0110] If it exists, the last stitched image in the fine stitched image is used as the stitching reference image;
[0111] If it does not exist, the image with the earliest corresponding image acquisition time among the multiple frames of the scanned images is used as the stitching reference image;
[0112] Based on the stitching reference image, the scanned images are stitched in sequence in the order of the corresponding image acquisition moments to generate a rough stitching image.
[0113] It should be noted that if there is a previously constructed fine stitching image, it means that this is not the first time that the current processing image is selected. The current processing image has been selected at least once before, and the current processing image has been stitched, translated, and other processes have been performed to construct a fine stitching image. At this time, the selected current processing image can be stitched on the previously constructed fine stitching image. Therefore, the last stitched frame of the fine stitching image can be used as the stitching reference image;
[0114] If there is no previously constructed fine stitching image, it means that this is the first time the current processing image is selected, or the acquired scanned images are not processed in batches. At this time, in order to ensure correct stitching, the image with the earliest corresponding acquisition time in the multiple frames of scanned images can be used as the stitching reference image.
[0115] In actual use, after determining the stitching reference image, the scanned images can be stitched together in sequence according to the corresponding image acquisition time sequence, and the stitched image is used as a rough stitching image.
[0116] The present embodiment provides a barcode recognition method, which sets the number of effective rows of the window of the area array camera according to the test tube diameter of the test tube to be recognized, obtains multiple frames of scanned images of the test tube to be recognized in the rotation process based on the set area array camera to construct a rough stitched image, and selects a candidate area from the rough stitched image; determines the barcode positioning point according to the gradient direction corresponding to the candidate area, and determines the barcode line in the rough stitched image according to the barcode positioning point; determines the relative number of misaligned pixels between each group of adjacent images in the rough stitched image based on the barcode line; performs translation adjustment on the image in the rough stitched image based on the relative number of misaligned pixels to generate a stitched barcode image, generates a stitched barcode image with a complete barcode, and then recognizes the stitched barcode image to ensure that even if the barcode is attached to the test tube wall at a large tilt angle, barcode recognition can still be performed normally.
[0117] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar contents as those in the above-mentioned embodiment 1 can refer to the above introduction, and will not be repeated later. Figure 2 , the step S30 may include steps S301 to S303:
[0118] Step S301: comparing the scanned images that are adjacent in time sequence to determine the content change range between the scanned images that are adjacent in time sequence;
[0119] Step S302: if the content change amplitude is less than a preset amplitude threshold, removing the scanned image with an earlier time sequence from the scanned images that are adjacent in time sequence;
[0120] Step S303: after the removal is completed, a rough spliced image is constructed according to the processed scanned image, and at least one candidate region is selected from the rough spliced image.
[0121] It should be noted that the barcode actually set on the test tube wall may only occupy a part of the test tube wall area. In this case, the partial scanned image collected may not actually contain the relevant content of the barcode. Subsequent processing of such images actually wastes equipment resources and consumes unnecessary time. In order to avoid this phenomenon, it is necessary to remove the scanned images that are not related to the barcode.
[0122] In actual use, if the scanned image contains content related to the barcode, the content of two frames of scanned images adjacent in time sequence will change significantly. Based on this, the content change amplitude between the two frames of scanned images can be used to determine whether there is content unrelated to the barcode. Therefore, the scanned images adjacent in time sequence can be compared to determine the content change amplitude between the scanned images adjacent in time sequence. If the content change amplitude is less than the preset amplitude threshold, it means that the content difference between the two consecutive frames of scanned images is extremely small. Therefore, the scanned image with an earlier time sequence in the scanned images adjacent in time sequence can be removed, thereby minimizing the processing of such scanned images unrelated to the barcode.
[0123] In actual application, the scanned images of two frames that are adjacent in time sequence in the selected scanned images can be compared and processed in sequence (for example: assuming that the scanned images are numbered 1-5 in time sequence, 1 and 2, 2 and 3, 3 and 4, 4 and 5 can be compared and processed in sequence). When the processing is completed, the remaining scanned images will contain at most very little content that is not related to the barcode. Therefore, a roughly spliced image can be constructed based on the processed scanned images, thereby minimizing the processing of scanned images that are not related to the barcode.
[0124] This embodiment provides a barcode recognition method. Because some images irrelevant to the barcode are deleted according to the image difference before stitching, it is ensured that the processing of irrelevant images can be reduced, thereby reducing unnecessary performance loss.
[0125] Based on the first embodiment of the present application, in the third embodiment of the present application, the same or similar contents as those in the first embodiment can be referred to the above description, and will not be described in detail later. Figure 3 , the step S50 may include steps S501 to S505:
[0126] Step S501: traversing each group of adjacent images in the roughly stitched image, and taking the traversed group of adjacent images as a target processing image;
[0127] Step S502: performing offset adjustment on the target processed image according to each preset offset pixel number, and obtaining edge line sets corresponding to each preset offset pixel number;
[0128] Step S503: Calculate the sum of the lengths of the continuous edge lines in each edge line set to obtain the continuous edge lengths corresponding to each preset number of misaligned pixels;
[0129] Step S504: selecting a relative number of misaligned pixels corresponding to the target processed image from each preset number of misaligned pixels according to the continuous edge length;
[0130] Step S505: at the end of the traversal, the relative number of misaligned pixels between each group of adjacent currently processed images in the roughly spliced image is obtained.
[0131] It should be noted that there will be a certain degree of misalignment in the barcodes in each scanned image. This misalignment is caused by the time interval between acquisitions and the special shape of the test tube wall. The magnitude of the misalignment is generally not large, and is only a small number of pixels (such as about 1 pixel). Based on this misalignment magnitude, the manager of the barcode recognition equipment can pre-set at least one preset number of misaligned pixels, and then perform misalignment adjustments on the target processed image according to each preset number of misaligned pixels to obtain a set of edge lines corresponding to each preset number of misaligned pixels.
[0132] Among them, the edge line set includes continuous edge lines in the target processing image after misalignment adjustment, and the continuous edge line is a line constructed when the barcode lines in two adjacent current processing images are continuous. For example, when the barcode lines in two adjacent current processing images are continuous, the completed line composed of two barcode lines is a continuous edge line, or, when the barcode lines in two current processing images are continuous, the vertical section of the continuous barcode lines is used as a continuous edge line.
[0133] In actual use, the manager of the barcode recognition device can also set a corresponding preset misalignment interval (such as 0-2 pixels), and the barcode recognition device can determine at least one preset number of misaligned pixels based on the preset misalignment interval and the interval value step.
[0134] The interval value step length is used to represent the difference between each preset number of misaligned pixels. The interval value step length can be a preset fixed value, or can be set by the administrator of the barcode recognition device when setting the preset misaligned interval.
[0135] In actual use, the continuous edge length can be used to characterize the barcode line fitting effect after translation. The better the fitting effect is, the more continuous barcode lines there are, and the corresponding continuous edge length, that is, the sum of the lengths of the continuous edge lines, is larger. Therefore, when selecting the relative number of misaligned pixels corresponding to the target processing image, the preset number of misaligned pixels with the largest corresponding continuous edge length can be selected as the relative number of misaligned pixels corresponding to the target processing image.
[0136] For ease of understanding, now combined Figure 4 , 5 and 6 for illustration, but not for limitation. Figure 4 This is a schematic diagram of the effective number of rows of the area array camera window of this embodiment. Figure 5 is a schematic diagram of image stitching in this embodiment, Figure 6 Schematic diagram of the continuous edge line of this embodiment.
[0137] like Figure 4 As shown in the figure, when scanning the barcode of the test tube, the size of the image can be adjusted by setting the number of effective lines in the window. The acquisition area is Figure 4 In the area between the two red lines, the larger the number of valid rows in the window, the larger the acquisition area.
[0138] like Figure 5 As shown, the white line area is used to indicate the interval between the current processed images (a total of three frames of current processed images) that make up the roughly stitched image (the white line area is only for schematic illustration and may not exist during actual stitching). The three frames of current processed images are stitched sequentially according to the order of acquisition time.
[0139] A set of adjacent scanned images 1 and 2 are selected as target processing images. After the target processing images are adjusted according to a preset number of offset pixels, the images are as follows: Figure 6 As shown, some barcode lines are completely continuous. In this case, the entirety of the completely continuous barcode lines (i.e., the total length of two completely continuous barcode lines combined) can be used as a continuous edge line (e.g. Figure 6 The vertical section of the completely continuous barcode line (i.e., the width of the completely continuous barcode line) can also be used as a continuous edge line (such as Figure 6 (as shown in the dashed box in B). Among them, Figure 6 This is only a schematic illustration and does not limit the number and specific length of the barcode lines.
[0140] This embodiment provides a barcode recognition method, which accurately locates the barcode line based on the gradient direction, and then performs multiple translation processes and reasonably selects the optimal number of relative misaligned pixels according to the continuity of the barcode line after the translation.
[0141] This application also provides a barcode recognition device, please refer to Figure 7 , the barcode recognition device comprises:
[0142] A setting module 10, used to set the number of effective rows of the window of the area array camera according to the diameter of the test tube to be identified;
[0143] An acquisition module 20 is used to acquire multiple frames of scanned images of the test tube to be identified during the rotation process based on the set area array camera, wherein a barcode is set on the wall of the test tube to be identified, and the scanned image is an image when the wall of the test tube to be identified is scanned;
[0144] A stitching module 30, configured to construct a rough stitching image according to the plurality of scanned images, and select at least one candidate region from the rough stitching image;
[0145] A positioning module 40, configured to determine a barcode positioning point according to a gradient direction corresponding to each candidate region, and determine a barcode line corresponding to each image in the roughly spliced image according to the barcode positioning point;
[0146] A determination module 50, configured to determine the relative number of misaligned pixels between each group of adjacent images in the roughly spliced image based on the barcode line;
[0147] An adjustment module 60, configured to perform translation adjustment on each currently processed image in the roughly spliced image based on the relative number of misaligned pixels to generate a spliced barcode image;
[0148] The recognition module 70 is used to recognize the spliced barcode image to obtain barcode information.
[0149] The barcode recognition device provided by the present application adopts the barcode recognition method in the above embodiment, which can solve the technical problem that the related technology cannot recognize the barcode with a large tilt angle attached to the test tube. Compared with the prior art, the beneficial effects of the barcode recognition device provided by the present application are the same as the beneficial effects of the barcode recognition method provided by the above embodiment, and the other technical features in the barcode recognition device are the same as the features disclosed in the above embodiment method, which will not be repeated here.
[0150] The present application provides a barcode recognition device, which includes: at least one processor; and a memory that is communicatively connected to the at least one processor; wherein the memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the barcode recognition method in the above-mentioned embodiment 1.
[0151] Reference below Figure 8, which shows a schematic diagram of the structure of a barcode recognition device suitable for implementing the embodiment of the present application. The barcode recognition device in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 8 The barcode recognition device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0152] like Figure 8 As shown, the barcode recognition device may include a processing device 1001 (such as a central processing unit, a graphics processor, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the barcode recognition device are also stored. The processing device 1001, ROM1002 and RAM1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touch pad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the barcode recognition device to communicate with other devices wirelessly or by wire to exchange data. Although the barcode recognition device with various systems is shown in the figure, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or have alternatively.
[0153] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.
[0154] The barcode recognition device provided by the present application adopts the barcode recognition method in the above embodiment, which can solve the technical problem that the related technology cannot recognize the barcode with a large tilt angle attached to the test tube. Compared with the prior art, the beneficial effects of the barcode recognition device provided by the present application are the same as the beneficial effects of the barcode recognition method provided by the above embodiment, and the other technical features in the barcode recognition device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.
[0155] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0156] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0157] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer program) stored thereon, and the computer-readable program instructions are used to execute the barcode recognition method in the above-mentioned embodiment.
[0158] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, or infrared systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM: Random Access Memory), a read-only memory (ROM: Read Only Memory), an erasable programmable read-only memory (EPROM: Erasable Programmable Read Only Memory or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM: CD-Read Only Memory), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency: Radio Frequency), etc., or any suitable combination of the above.
[0159] The computer-readable storage medium may be included in the barcode recognition device; or may exist independently without being assembled into the barcode recognition device.
[0160] The computer-readable storage medium carries one or more programs. When the one or more programs are executed by a barcode recognition device, the barcode recognition device: sets the number of effective rows of the area array camera window according to the test tube diameter of the test tube to be recognized; obtains multiple frames of scanned images of the test tube to be recognized during the rotation process based on the set area array camera, wherein a barcode is set on the wall of the test tube to be recognized, and the scanned image is an image of the test tube wall to be recognized when it is scanned; constructs a rough spliced image based on the multiple frames of the scanned images, and selects at least one candidate area from the rough spliced image; determines a barcode positioning point according to the gradient direction corresponding to each candidate area, and determines a barcode line corresponding to each image in the rough spliced image according to the barcode positioning point; determines the relative number of misaligned pixels between each group of adjacent images in the rough spliced image based on the barcode line; performs translation adjustment on each image in the rough spliced image based on the relative number of misaligned pixels to generate a spliced barcode image; recognizes the spliced barcode image to obtain barcode information.
[0161] Computer program code for performing the operations of the present application may be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0162] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0163] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.
[0164] The readable storage medium provided by the present application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned barcode recognition method, and can solve the technical problem that the related art cannot recognize the barcode with a large tilt angle attached to the test tube. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided by the present application are the same as the beneficial effects of the barcode recognition method provided by the above-mentioned embodiment, and will not be repeated here.
[0165] The present application also provides a computer program product, including a computer program, which implements the steps of the above-mentioned barcode recognition method when executed by a processor.
[0166] The computer program product provided by the present application can solve the technical problem that the related art cannot recognize the barcode with a large tilt angle attached to the test tube. Compared with the prior art, the beneficial effects of the computer program product provided by the present application are the same as the beneficial effects of the barcode recognition method provided by the above embodiment, which will not be repeated here.
[0167] The above descriptions are only some embodiments of the present application, and are not intended to limit the patent scope of the present application. All equivalent structural changes made using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect applications in other related technical fields are included in the patent protection scope of the present application.
Claims
1. A barcode recognition method, characterized in that: The method comprises: The number of effective rows of the area array camera window is set according to the diameter of the test tube to be identified; Acquire multiple frames of scanned images of the test tube to be identified during the rotation process based on the set area array camera, wherein a barcode is set on the wall of the test tube to be identified, and the scanned image is an image when the wall of the test tube to be identified is scanned; Constructing a rough spliced image according to the plurality of frames of scanned images, and selecting at least one candidate region from the rough spliced image; Determine a barcode positioning point according to the gradient direction corresponding to each candidate area, and determine a barcode line corresponding to each image in the roughly spliced image according to the barcode positioning point; Determine the relative number of misaligned pixels between each group of adjacent images in the roughly spliced image based on the barcode lines, the relative number of misaligned pixels being the preset number of misaligned pixels for which the sum of lengths of continuous edge lines corresponding to the misalignment adjustment is the maximum, the continuous edge line being a line constructed when the barcode lines in two adjacent images are continuous; Based on the relative number of misaligned pixels, translation adjustment is performed on each image in the roughly spliced image to generate a spliced barcode image; The spliced barcode image is identified to obtain barcode information.
2. The barcode recognition method according to claim 1, characterized in that: The step of constructing a rough spliced image based on the multiple frames of scanned images includes: Detect whether there is a previously constructed fine mosaic; If it exists, the last stitched image in the fine stitched image is used as the stitching reference image; If it does not exist, the image with the earliest corresponding image acquisition time among the multiple frames of the scanned images is used as the stitching reference image; Based on the stitching reference image, the scanned images are stitched in sequence in the order of the corresponding image acquisition moments to generate a rough stitching image.
3. The barcode recognition method according to claim 1, characterized in that: The selecting at least one candidate region from the roughly stitched image comprises: Performing gradient calculation on the roughly stitched image to obtain gradient response distribution information corresponding to the roughly stitched image; At least one candidate region is selected from the roughly spliced image based on the gradient response distribution information and a preset response threshold.
4. The barcode recognition method according to claim 1, characterized in that: The step of determining the barcode positioning point according to the gradient direction corresponding to each candidate area includes: Count the number of gradient directions corresponding to each candidate region to obtain the statistical count corresponding to each gradient direction; Selecting a barcode direction from each gradient direction based on the statistical count; A barcode positioning point that conforms to the barcode direction is selected from the candidate area.
5. The barcode recognition method according to claim 1, characterized in that: The determining, based on the barcode line, the relative number of misaligned pixels between each group of adjacent images in the roughly spliced image comprises: Traversing each group of adjacent images in the roughly spliced image, and taking the traversed group of adjacent images as a target processing image; Performing offset adjustment on the target processed image according to each preset number of offset pixels, respectively, to obtain edge line sets corresponding to each preset number of offset pixels, wherein the edge line sets include continuous edge lines in the target processed image after the offset adjustment; Calculate the sum of the lengths of the continuous edge lines in each edge line set respectively, and obtain the continuous edge lengths corresponding to each preset number of misaligned pixels; Selecting a relative number of misaligned pixels corresponding to the target processed image from each preset number of misaligned pixels according to the continuous edge length; At the end of the traversal, the relative number of misaligned pixels between each group of adjacent images in the roughly stitched image is obtained.
6. The barcode recognition method according to any one of claims 1 to 5, characterized in that: The step of constructing a rough spliced image based on the multiple frames of scanned images includes: Comparing the scanned images that are adjacent in time sequence to determine the extent of content change between the scanned images that are adjacent in time sequence; If the content change amplitude is less than a preset amplitude threshold, removing the scanned image with an earlier time sequence from the scanned images adjacent in time sequence; After the removal is completed, a rough stitched image is constructed based on the processed scanned images.
7. A barcode recognition device, characterized in that: The device comprises: A setting module, used to set the number of effective rows of the window of the area array camera according to the test tube diameter of the test tube to be identified; An acquisition module, used for acquiring multiple frames of scanned images of the test tube to be identified in the process of rotation based on the set area array camera, wherein a barcode is set on the wall of the test tube to be identified, and the scanned image is an image when the wall of the test tube to be identified is scanned; A stitching module, used for constructing a rough stitching image according to the plurality of scanned images, and selecting at least one candidate region from the rough stitching image; A positioning module, used to determine a barcode positioning point according to a gradient direction corresponding to each candidate area, and determine a barcode line corresponding to each image in the roughly spliced image according to the barcode positioning point; A determination module, configured to determine the relative number of misaligned pixels between each group of adjacent images in the roughly spliced image based on the barcode lines, wherein the relative number of misaligned pixels is a preset number of misaligned pixels at which the sum of lengths of continuous edge lines corresponding to the misaligned adjustment is the largest, and the continuous edge line is a line constructed when the barcode lines in two adjacent images are continuous; An adjustment module, configured to perform translation adjustment on each currently processed image in the roughly spliced image based on the relative number of misaligned pixels to generate a spliced barcode image; The recognition module is used to recognize the spliced barcode image to obtain barcode information.
8. A barcode recognition device, characterized in that: The device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the barcode recognition method according to any one of claims 1 to 6.
9. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the barcode recognition method according to any one of claims 1 to 6 are implemented.
10. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the steps of the barcode recognition method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Barcode identification method, device and equipment and readable storage medium
CN117540762A
Sample tube bar code identification method and system and medium
CN118313402A