Battery tab detection method, device and equipment and storage medium
By encoding the segmented images of the battery ears, the skeleton information is quickly extracted, and the problem of low skeleton image extraction efficiency in the prior art is solved, and more efficient detection efficiency is achieved.
Patent Information
- Application Number
- CN202311466054.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-06
- Publication Date
- 2025-05-06
AI Technical Summary
In the prior art, the skeleton image extraction efficiency of the battery pole ear is low, resulting in a lower detection efficiency.
By encoding the segmented image of the battery ear, the encoding value of the first structure in the row to be encoded is determined to quickly extract the skeleton information and reduce the image traversal time.
The skeleton image extraction efficiency of the battery pole ear is improved, the extraction time complexity is reduced, and the detection efficiency is improved.
Smart Images

Figure CN119941607A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of battery detection, and is related to but not limited to a method, device, equipment and storage medium for detecting a battery tab. Background Art
[0002] Lithium battery tab folding detection is an important part of the battery production process. Its main purpose is to detect the position of the battery tab to determine whether the battery tab is folded or deformed. Tab folding detection can improve the quality and stability of battery assembly and ensure the reliability and safety of the battery during use.
[0003] At present, the detection of tab folding is done by using visual detection technology or sensor detection technology. Among them, the visual detection technology uses a camera or other image sensor to capture the image of the battery tab, and then uses an image processing algorithm to analyze the position and shape of the tab in the image to determine whether it is folded or deformed. In this process, it is necessary to extract the tab skeleton in the tab cross-section segmentation image. This process requires multiple image traversals. Therefore, it takes a lot of time to extract the skeleton image of the battery tab, resulting in low extraction efficiency of the skeleton image, which in turn leads to low detection efficiency of the battery tab. Summary of the invention
[0004] The battery tab detection method, device, equipment and storage medium provided in the present application can improve the efficiency of extracting the skeleton image of the battery tab, thereby reducing the time complexity of extracting the skeleton image, and further improving the detection efficiency of the battery tab.
[0005] The technical solution of this application is implemented as follows:
[0006] In a first aspect, an embodiment of the present application provides a method for detecting a battery tab, comprising:
[0007] Obtain a segmented image of the battery tab;
[0008] Encoding the segmented image to determine the encoding value of the first structure of each to-be-encoded row in the segmented image; wherein the first structure represents the relevant information of the continuous segment contained in the to-be-encoded row; and the continuous segment represents the foreground information of the segmented image;
[0009] Determine a skeleton image of the battery tab based on the encoding values of the first structure of each to-be-encoded row of the segmented image;
[0010] The detection result of the battery lug is determined based on the skeleton image of the battery lug.
[0011] According to the above technical means, the skeleton information in the segmented image of the battery tab is the foreground information of the image. By traversing and encoding the continuous segments in each row to be encoded in the segmented image, the encoding value of the first structure of each row to be encoded is obtained, and the foreground information in the row to be encoded can be quickly extracted. In this way, since the encoding process is only performed on the foreground information of the segmented image, the traversal time of the segmented image can be reduced, thereby improving the extraction efficiency of the skeleton image, reducing the time complexity of extracting the skeleton image, and thus improving the detection efficiency of the battery tab.
[0012] Further, encoding the segmented image to determine the encoding value of the first structure of each to-be-encoded row in the segmented image includes:
[0013] Encode the current row to be encoded in the segmented image to determine the encoding value of the second structure of the current row to be encoded; wherein the second structure represents the position information of the continuous segment;
[0014] Determine the encoding value of the first structure of the current row to be encoded according to the encoding value of each second structure in the current row to be encoded and the number of second structures;
[0015] Continue to determine the encoding value of the second structure of the next row to be encoded until all the rows to be encoded in the segmented image are traversed, and obtain the encoding value of the first structure of each row to be encoded in the segmented image.
[0016] According to the above technical means, on the one hand, by encoding the position information of continuous segments in the image, the image data can be effectively compressed, reducing the demand for data storage and transmission; on the other hand, by extracting useful information about the continuous segments of the image, when it is necessary to transmit the image or image-related data, a smaller coding value will improve data transmission efficiency and reduce transmission time and cost.
[0017] Further, encoding the current row to be encoded in the segmented image to determine the encoding value of the second structure of the current row to be encoded includes:
[0018] For the current first segment to be encoded in the current row to be encoded, determine the first flag of the current segment to be encoded according to the pixel value of each pixel of the current segment to be encoded; the first flag is used to indicate whether the pixel in the current segment to be encoded is a foreground pixel;
[0019] Encode the first flag bit of the current first segment to be encoded to determine the encoding value of the second structure of the current first segment to be encoded;
[0020] Continue to determine the first flag bit of the next first segment to be encoded according to the pixel values of each pixel point of the next first segment to be encoded, thereby determining the encoding value of the second structure of the next first segment to be encoded, until the end position of the next first segment to be encoded is less than the width of the segmented image, and obtain the encoding value of the second structure of the current row to be encoded.
[0021] According to the above technical means, on the one hand, by encoding the first flag bit of the current first segment to be encoded, the foreground information of the segmented image can be represented in a more compact manner, reducing the cost of data storage and data transmission. On the other hand, encoding each first segment to be encoded in the encoding line can help manage and process large images, improve encoding efficiency, and meet real-time requirements.
[0022] Further, determining the first flag of the current first segment to be encoded according to the pixel value of each pixel point of the current first segment to be encoded includes:
[0023] Loading the current first segment to be encoded into the operation register; the number of pixels in the current first segment to be encoded is related to the number of bits in the operation register;
[0024] According to the pixel value of each pixel point in the operation register, whether each pixel point is a foreground pixel point is determined at the same time, and the determination result of each pixel point is obtained;
[0025] According to the judgment result of each pixel point, the first flag bit of the current first segment to be encoded is determined.
[0026] According to the above technical means, on the one hand, loading the current first segment to be encoded into the operation register can reduce the number of data reads, thereby improving memory access efficiency. On the one hand, by simultaneously determining whether multiple pixels are foreground pixels, the image processing speed can be improved. On the one hand, according to the judgment results of each pixel, the first flag bit of the current first segment to be encoded is determined, which can effectively encode the foreground information in the image, thereby saving encoding storage space.
[0027] Further, according to the judgment result of each pixel point, the first flag bit of the current first segment to be encoded is determined, including:
[0028] If the judgment result of the pixel point indicates that the pixel point is a foreground pixel point, the bit corresponding to the pixel point in the first flag bit of the current first segment to be encoded is set to the first value;
[0029] If the judgment result of the pixel point indicates that the pixel point is not a foreground pixel point, the bit corresponding to the pixel point in the first flag bit of the current first segment to be encoded is set to the second value.
[0030] According to the above technical means, by configuring different flags for foreground pixels and non-foreground pixels, foreground pixels and non-foreground pixels can be effectively represented, which helps to improve the efficiency and accuracy of image processing.
[0031] Further, encoding the first flag bit of the current first segment to be encoded to determine the encoding value of the second structure of the current first segment to be encoded includes:
[0032] In the case where the first flag bit of the current first segment to be encoded indicates that at least one pixel in the current first segment to be encoded is a foreground pixel, respectively determining the lowest foreground bit and the highest foreground bit of the first flag bit; the lowest foreground bit represents the position of the lowest effective bit in the flag bit; the highest foreground bit represents the position of the highest effective bit in the flag bit;
[0033] When the lowest foreground bit of the first flag bit is not equal to the highest flag bit of the current first segment to be encoded, the encoding value of the second structure of the current first segment to be encoded is determined based on the highest foreground bit of the first flag bit.
[0034] According to the above technical means, when the lowest foreground bit of the first flag bit is not equal to the highest flag bit of the current first segment to be encoded, the encoding value of the second structure of the current first segment to be encoded is determined, which can ensure that the current first segment to be encoded has a completed continuous segment, thereby improving the accuracy of the second structure.
[0035] Furthermore, before determining the encoding value of the second structure of the current first segment to be encoded based on the highest foreground bit of the first flag bit, the method further includes:
[0036] Get the second flag bit; the second flag bit is used to indicate whether the statistics of the previous continuous segment are completed;
[0037] When the second flag indicates that statistics of the previous continuous segment are not completed and the lowest foreground bit of the first flag is not the second value, the end position of the previous continuous segment is determined according to the start position of the current first segment to be encoded.
[0038] According to the above technical means, on the one hand, it can ensure that when the statistics of the previous continuous segment are not completed, the end position of the previous continuous segment can be correctly determined, so that the foreground pixel points are not missed in the statistical process. On the other hand, by correctly determining the end position of the continuous segment, it can avoid merging the pixels of the non-continuous segments into one continuous segment by mistake, reducing redundant statistical information. On the one hand, it is helpful to correctly and effectively encode the image, reduce unnecessary information transmission, and reduce computing overhead and processing time, thereby improving encoding efficiency.
[0039] Furthermore, before determining the encoding value of the second structure of the current first segment to be encoded based on the highest foreground bit of the first flag bit, the method further includes:
[0040] According to the starting position of the current first segment to be encoded and the lowest foreground bit of the first flag bit, the starting position of the starting continuous segment in the first flag bit is determined.
[0041] According to the above technical means, on the one hand, the starting position of the continuous segment can be accurately marked, reducing the error and redundancy of the encoding. On the other hand, unnecessary statistical operations can be effectively avoided, reducing the computational complexity of processing data. On the other hand, by accurately locating the starting position of the starting continuous segment, the accuracy of image encoding can be improved.
[0042] Further, based on the highest foreground bit, determining the encoding value of the second structure of the current first segment to be encoded includes:
[0043] According to the lowest foreground bit of the first flag bit, the first flag bit is shifted to obtain the currently updated first flag bit;
[0044] According to the lowest foreground bit of the first flag bit, determining the lowest background bit of the first flag bit currently updated; the lowest background bit represents the position of the lowest invalid bit in the flag bit;
[0045] Determine the encoding value of the second structure of the current continuous segment based on the lowest background bit of the first flag bit currently updated;
[0046] Continue to shift the currently updated first flag bit according to the lowest foreground bit of the currently updated first flag bit to obtain the next updated first flag bit, and determine the encoding value of the second structure of the next continuous segment based on the lowest background bit of the next updated first flag bit, until the next updated first flag bit is equal to the second value, and obtain the encoding value of the second structure of the current first segment to be encoded.
[0047] According to the above technical means, on the one hand, by updating the first flag bit, redundant information in the encoding process can be reduced. On the other hand, by determining the lowest foreground bit and the lowest background bit of the first flag bit, the encoding overhead and the required number of bits can be reduced, which helps to more effectively represent the relevant information of the continuous segment and reduce the amount of data transmitted, thereby saving storage space and improving transmission efficiency.
[0048] Further, based on the lowest background bit of the first flag bit currently updated, determining the encoding value of the second structure of the current continuous segment includes:
[0049] Determine the starting position of the current continuous segment according to the lowest foreground bit of the last updated first flag bit and the starting position of the current first segment to be encoded;
[0050] When the lowest background bit of the updated first flag is less than the highest foreground bit, determining the end position of the current continuous segment according to the lowest background bit of the currently updated first flag and the start position of the current first segment to be encoded;
[0051] According to the start position of the current continuous segment and the end position of the current continuous segment, the encoding value of the second structure of the current continuous segment is determined.
[0052] According to the above technical means, the starting position and the ending position of the continuous segment can be accurately determined through the lowest foreground bit and the lowest background bit, which improves the accuracy of the boundary of the continuous segment, thereby improving the efficiency of encoding and the reliability of encoding.
[0053] Furthermore, after determining the end position of the current continuous segment, the method further includes: inverting the first flag bit currently updated to obtain an inverted flag bit;
[0054] Determine the current shift distance according to the lowest foreground point of the inverted flag bit;
[0055] According to the current shift distance, the first flag bit of the current update is shifted to obtain the first flag bit of the next update;
[0056] Determine the lowest foreground point of the first marker to be updated next according to the current shift distance and the lowest rear point of the first marker to be updated currently;
[0057] The starting position of the next continuous segment is determined according to the lowest foreground point of the next updated first flag bit and the starting position of the current first segment to be encoded.
[0058] According to the above technical means, the starting position of the next continuous segment can be accurately located, the coding overhead is reduced, efficient coding is achieved, and the amount of data transmitted is reduced, thereby saving storage space and improving transmission efficiency.
[0059] Furthermore, when the lowest background bit of the updated first flag bit is greater than or equal to the highest foreground bit, and the highest foreground bit is not equal to the highest identification bit, the end position of the current continuous segment is determined based on the starting position of the current first segment to be encoded and the highest foreground bit; and the second flag bit is updated to the second value.
[0060] According to the above technical means, on the one hand, the accuracy of determining the end position of the current continuous segment can be improved, thereby improving the reliability of data. On the other hand, by accurately determining the end position of the current continuous segment, unnecessary coding bits can be reduced, thereby improving coding efficiency and reducing the burden of data transmission and storage.
[0061] Further, when the lowest background bit of the updated first flag is greater than or equal to the highest foreground bit, and the highest foreground bit is equal to the highest flag bit, the second flag is updated to the first value. When the lowest foreground bit of the first flag is equal to the highest flag bit of the current first segment to be encoded, the second flag is updated to the first value.
[0062] According to the above technical means, the accuracy of determining the end position of the current continuous segment can be improved, thereby improving the reliability of the data.
[0063] Further, when the first flag indicates that all pixels in the current first segment to be encoded are not foreground pixels and the second flag is the first value, the end position of the previous continuous segment is determined based on the starting position of the current first segment to be encoded, and the second flag is updated to the second value.
[0064] According to the above technical means, on the one hand, the accuracy of determining the end position of the previous continuous segment can be improved, thereby improving the reliability of data. On the other hand, by accurately determining the end position of the previous continuous segment, unnecessary coding bits can be reduced, thereby improving coding efficiency and reducing the burden of data transmission and storage.
[0065] Further, based on the encoding values of the first structural bodies of each to-be-encoded row of the segmented image, a skeleton image of the battery tab is determined, including:
[0066] When the segmented image has a second segment to be encoded, encoding the second segment to be encoded in the segmented image line by line; wherein the number of pixels in the second segment to be encoded is less than the number of pixels in the first segment to be encoded;
[0067] Determine, according to the position information of the continuous segments in each second segment to be encoded, the encoding value of the second structure of each second segment to be encoded;
[0068] According to the code value of the second structure of each second segment to be encoded, the code value of each first structure is updated to obtain the code value of each updated first structure;
[0069] A skeleton image is determined according to the code values of each updated first structure body.
[0070] According to the above technical means, by encoding the continuous segment position information in the image, the image data can be effectively compressed, reducing the demand for data storage and transmission, thereby improving the extraction efficiency of the skeleton image of the battery tab, thereby reducing the time complexity of extracting the skeleton image.
[0071] Furthermore, the segmented image of the battery tab is a single-channel image.
[0072] According to the above technical means, on the one hand, single-channel images are simpler than multi-channel images, which reduces the complexity of image processing and reduces the computational cost; on the other hand, single-channel images usually require less storage space because there is no need to store multi-channel color information, which is very beneficial for the storage of large-scale image data.
[0073] In a second aspect, an embodiment of the present application provides a battery tab detection device, the device comprising:
[0074] An acquisition unit, used for acquiring a segmented image of a battery tab;
[0075] The encoding unit is used to encode the segmented image and determine the encoding value of the first structure of each to-be-encoded line in the segmented image; wherein the first structure represents the relevant information of the continuous segment contained in the to-be-encoded line; and the continuous segment represents the foreground information of the segmented image;
[0076] The determination unit is used to determine the skeleton image of the battery tab based on the encoding value of the first structure of each to-be-encoded row of the segmented image; and determine the detection result of the battery tab according to the skeleton image of the battery tab.
[0077] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a processor and a memory, wherein the memory is used to store a computer program, and the processor is used to call and run the computer program stored in the memory to execute the battery tab detection method as described above.
[0078] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by at least one processor, the battery tab detection method as described above is implemented. BRIEF DESCRIPTION OF THE DRAWINGS
[0079] The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present application and are used together with the specification to illustrate the technical solution of the present application. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0080] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps can be decomposed, and some operations / steps can be combined or partially combined, so the actual execution order may change according to actual conditions.
[0081] Figure 1A schematic diagram of an optional battery tab detection method provided in an embodiment of the present application Figure 1 ;
[0082] Figure 2 A schematic diagram of an optional segmented image of a battery tab provided in an embodiment of the present application;
[0083] Figure 3 A schematic diagram of an optional battery tab detection method provided in an embodiment of the present application Figure 2 ;
[0084] Figure 4 A schematic diagram of an optional row to be encoded provided in an embodiment of the present application;
[0085] Figure 5 A schematic diagram of an optional skeleton image of a battery tab provided in an embodiment of the present application;
[0086] Figure 6 A schematic diagram of an optional battery tab detection method provided in an embodiment of the present application Figure 3 ;
[0087] Figure 7 A schematic diagram of an optional battery tab detection method provided in an embodiment of the present application Figure 4 ;
[0088] Figure 8 A schematic diagram of the composition structure of an optional battery tab detection device provided in an embodiment of the present application;
[0089] Fig. 9 A schematic diagram of the composition structure of an optional electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0090] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the specific technical solution of the present application will be further described in detail below in conjunction with the drawings in the embodiments of the present application. The following embodiments are used to illustrate the present application, but are not used to limit the scope of the present application.
[0091] Unless otherwise defined, all technical and scientific terms used in the embodiments of the present application have the same meaning as those commonly understood by those skilled in the art of the present application. The terms used in the embodiments of the present application are only for the purpose of describing the embodiments of the present application and are not intended to limit the present application.
[0092] In the following description, references to “some embodiments,” “this embodiment,” “this embodiment,” and examples, etc., describe a subset of all possible embodiments, but it can be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments, and may be combined with each other without conflict.
[0093] If similar descriptions of "first / second" appear in the application documents, the following instructions are added. In the following description, the terms "first\second\third" involved are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first\second\third" can be interchanged in a specific order or sequence where permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.
[0094] In the related art, the tabs of lithium batteries are extensions of the electrode part of the battery, usually protruding parts of metal or other conductive materials, used to connect the positive electrode (anode) and negative electrode (cathode) of the battery with external circuits or devices. These tabs are usually flat or strip-shaped on the electrodes of the battery to connect the battery and the external circuit. The main functions of the tabs include:
[0095] 1) Conductive connection: The tabs allow current to flow between the battery electrodes and the external circuit, enabling the battery to provide power to the device or receive charging current;
[0096] 2) Mechanical support: Tabs are usually used to fix the electrodes of the battery to ensure that they are firmly connected to the rest of the battery, while also providing mechanical support and stability for the battery;
[0097] 3) Connector: There may be a connector or plug on the tab to easily connect the battery to a device or charger.
[0098] The tab structure and design of lithium batteries can vary for different types of lithium batteries, including lithium-ion batteries, lithium polymer batteries, etc. The shape, size and connection method of the tabs may also vary depending on the battery application and manufacturer. The quality and reliability of the tabs are critical to the performance and life of the battery, so special attention needs to be paid to the manufacturing and connection quality of the tabs in battery manufacturing.
[0099] In the process of lithium battery tab fold detection, extracting the skeleton of the tab cross-section segmentation image is a key step to better analyze the structure and connection of the tab. This process usually requires multiple image traversals and processing. An optional battery tab fold detection process can include the following steps:
[0100] 1) Image acquisition: First, obtain an image of the cross section of the lithium battery tab. This can be done with a high-resolution camera or microscope.
[0101] 2) Image preprocessing: The collected images are preprocessed, including denoising, contrast enhancement, and edge detection, in preparation for subsequent image analysis.
[0102] 3) Image segmentation: Use image segmentation technology to separate the ear section from the background. This can be done by using threshold segmentation, edge detection or other segmentation algorithms.
[0103] 4) Skeleton Extraction: Once the image segmentation is completed, the skeleton of the tab cross section can be extracted. The skeleton is a refined version of the object in the image, usually composed of pixels or line segments.
[0104] 5) Skeleton refinement: After skeleton extraction, it is usually necessary to refine the skeleton to reduce noise and retain the main structural information. This may require multiple iterations and processing.
[0105] 6) Structural Analysis: Perform structural analysis on the skeleton to detect specific features of the tab, such as connection points, bend angles, etc. This may require multiple image passes to extract the required information.
[0106] 7) Result output: Based on the results of the structural analysis, generate a report on the tab folding, including whether it meets the specifications and quality standards.
[0107] 8) Feedback control: If the test results do not meet the standards, they can be fed back to the production process to take appropriate measures, such as reprocessing or adjusting the tabs.
[0108] In the above process of detecting the folding of the battery tab, the traversal and processing of the image may require multiple iterations to ensure accurate extraction and analysis of the tab's skeleton and structural information. The use of computer vision and image processing technology can automate this process and improve the accuracy and efficiency of detection.
[0109] However, in the related art, since the battery tab image is relatively large (for example, the image size is 5120*5120), it is generally necessary to perform more than 50 image traversals to realize skeleton extraction, so the skeleton extraction operation is very time-consuming (according to statistics, in the process of detecting the tab folding, the skeleton extraction generally takes about 150ms, and some individual images even take more than 1s). In order to speed up the detection of tab folding, it is necessary to improve the skeleton extraction algorithm and significantly reduce the time complexity of the algorithm. By observing the tab cross-section segmentation image, it is found that the number of foreground pixels only accounts for a small proportion of the entire image. If all foreground pixels can be quickly extracted, the subsequent image traversal is usually performed on the foreground pixels, which will undoubtedly greatly reduce the image traversal time. Therefore, it takes a lot of time to extract the skeleton image of the battery tab, resulting in low efficiency in skeleton image extraction.
[0110] Based on the above technical problems, the embodiment of the present application provides a battery lug detection method to improve the extraction efficiency of the skeleton image of the battery lug, thereby reducing the time complexity of extracting the skeleton image, and further improving the detection efficiency of the battery lug. The battery lug detection method provided in the embodiment of the present application can be executed by a battery lug detection device and an electronic device, wherein the battery lug detection device can be stored in the electronic device as a software function model, the battery lug detection device can also be integrated in the electronic device as a hardware function module, and the battery lug detection device can also be combined with the electronic device in software and hardware to implement the battery lug detection method, and the embodiment of the present application does not impose any limitation on this.
[0111] In an embodiment of the present application, the electronic device may be a server, which may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers. It may also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, as well as big data and artificial intelligence platforms, but the embodiments of the present application do not limit this.
[0112] In addition, the electronic device can also be a terminal device, which can be a mobile phone, a tablet personal computer (TPC), a media player, a smart TV, a laptop computer (LC), a personal digital assistant (PDA), a personal computer (PC), a camera, a camcorder, a smart watch, a wearable device (WD) or an autonomous driving vehicle, etc., which is not limited to the embodiments of the present application.
[0113] The technical solution of the present application will be described in detail below with reference to the accompanying drawings.
[0114] See also Figure 1 , Figure 1 A schematic diagram of an optional battery tab detection method provided in an embodiment of the present application Figure 1 , the method includes S101 to S104:
[0115] S101, obtaining a segmented image of a battery tab.
[0116] In an embodiment of the present application, a battery lug segmentation image acquisition device can be used to acquire images of the battery lug. Ensure that the image quality is good for subsequent image segmentation. Specifically, the electronic device can obtain the segmented image of the battery lug through the segmented image acquisition device. Here, the segmented image acquisition device can be a high-resolution camera or a microscope or other device. The present application embodiment does not impose any limitation on the acquisition device.
[0117] Figure 2A schematic diagram of an optional segmented image of a battery tab provided in an embodiment of the present application, such as Figure 2 As shown, Figure 2 The white pixels in the figure are foreground pixels, i.e., the pixels of the battery tabs.
[0118] In an embodiment of the present application, after obtaining the segmented image of the battery tab, the segmented image may be preprocessed to reduce noise and enhance the contrast of the segmented image. Exemplarily, the preprocessing may include: image denoising, brightness and contrast enhancement, image smoothing, histogram equalization, etc.
[0119] In some embodiments of the present application, the segmented image of the battery tab may be a single-channel image. In this case, the segmented image is a grayscale image, in which each pixel has a grayscale value, indicating the brightness or grayscale level of the pixel.
[0120] It can be understood that, on the one hand, single-channel images are simpler than multi-channel images, which reduces the complexity of image processing and reduces computational costs; on the other hand, single-channel images usually require less storage space because there is no need to store multi-channel color information, which is very beneficial for the storage of large-scale image data.
[0121] It is understandable that, on the one hand, single-channel images are usually processed faster because there is no need to process multi-channel color information. This is particularly useful in real-time or high-performance computing applications. On the other hand, in some image processing tasks, a single channel of brightness information is often required, for example, edge detection or grayscale analysis. Single-channel images can make these tasks more accurate. In general, the main benefits of using single-channel images are that it can reduce processing complexity, improve performance, reduce storage requirements, and better meet the needs of specific tasks.
[0122] In some embodiments of the present application, the segmented image of the battery tab may also be a multi-channel image. In this case, each channel contains information related to the battery tab. In this case, one channel may be selected to perform segmentation, or information from multiple channels may be combined to improve segmentation accuracy.
[0123] S102, encoding the segmented image, and determining the encoding value of the first structure of each to-be-encoded row in the segmented image; wherein the first structure represents relevant information of the continuous segment included in the to-be-encoded row; and the continuous segment represents foreground information of the segmented image.
[0124] In the embodiment of the present application, the segmented image includes: foreground information and background information, wherein the foreground information generally refers to the part of the object or target of interest in the segmented image, and the foreground information and the background information correspond to each other.
[0125] In an embodiment of the present application, the electronic device encodes the segmented image and determines the encoding value of the first structure of each to-be-encoded row in the foreground information of the segmented image. The foreground information of the segmented image includes the contour, area, shape of the battery tab, and color or texture information related to the battery tab.
[0126] In the embodiment of the present application, a first structure is created for each row to be encoded, which includes relevant information of the continuous segments related to the row. Such information may include the starting position, length, color information, etc. of each continuous segment. For each row to be encoded, the continuous segments therein are extracted, and the continuous segments generally refer to pixel rows with the same characteristics or attributes, and these continuous segments are part of the battery tabs.
[0127] In an embodiment of the present application, the first structure may include: the number of continuous segments, the starting position of each continuous segment, the length of each continuous segment, shape-related information, feature points or key points. Among them, the number of continuous segments is used to indicate how many continuous segments there are in the line to be encoded, that is, the number of segments of the object (continuous segment) in the image. The starting position of each continuous segment is used to indicate the starting position of the continuous segment in the line to be encoded, which is used to determine the relative position of the continuous segment. The length of each continuous segment is used to indicate the span of the continuous segment in the line to be encoded, which is conducive to determining the size of the continuous segment. Shape-related information is used to indicate the width, height, curvature, etc. of the continuous segment to represent the shape or structure information of the continuous segment.
[0128] In the embodiment of the present application, the first structure can be expressed as Struct RLE. Exemplarily, the first structure Struct RLE can be expressed as:
[0129] Struct RLE
[0130] {
[0131] int count = 0;
[0132] LineCompress*sets;
[0133] };
[0134] In the first structure Struct RLE, count represents the number of continuous segments in the line to be encoded; sets is an array used to store the collection of each continuous segment in the line to be encoded.
[0135] In some embodiments of the present application, Figure 3 As shown, the implementation of encoding the segmented image and determining the encoding value of the first structure of each to-be-encoded row in the segmented image may include S1021 to S1023:
[0136] S1021. Encode the current row to be encoded in the segmented image, and determine the encoding value of the second structure of the current row to be encoded; wherein the second structure represents position information of a continuous segment.
[0137] In the embodiment of the present application, a continuous segment is extracted for the current line to be encoded, and the continuous segment generally refers to a pixel region having the same attribute or feature on the line.
[0138] In the embodiment of the present application, a second structure is created for the current row to be encoded, which contains position information about each continuous segment. The position information generally includes the starting pixel coordinates (starting position) and the ending pixel coordinates (ending position) of each continuous segment.
[0139] In the embodiment of the present application, the second structure can be expressed as Struct LineCompress. For example, the second structure Struct LineCompress can be expressed as:
[0140] Struct LineCompress
[0141] {
[0142] int startPos;
[0143] int endPos;
[0144] };
[0145] In the second structure Struct LineCompress, startPos indicates the starting position of the continuous segment, and endPos indicates the ending position of the continuous segment.
[0146] S1022: Determine the encoding value of the first structure body of the current row to be encoded according to the encoding value of each second structure body in the current row to be encoded and the number of second structure bodies.
[0147] In an embodiment of the present application, the second structure of each continuous segment is encoded and converted into binary or other suitable formats. The encoding method should include the position information of each second structure, including the starting and ending pixel coordinates. The encoding values of all second structures are combined into an overall encoding value. This can be done by connecting the encoding values of each second structure in series, or combining them using a specific encoding method. Information about the number of second structures should be included in the encoding, which can be a binary value representing the number. Based on the combined encoding value and quantity information, the encoding value of the first structure is generated, which can be a coded string containing the second structure encoding and quantity information.
[0148] Figure 4A schematic diagram of an optional row to be encoded provided in an embodiment of the present application, such as Figure 4 As shown, the line to be encoded 00001111110011110 includes two continuous segments, and the continuous segments r0 and r1 in the first structure can be expressed as:
[0149] r0.startPos=4, r0.endtPos=9;
[0150] r1.stαrtPos=12, r1.endtPos=15.
[0151] At this time, the count value in the first structure is 2.
[0152] S1023 , continue to determine the encoding value of the second structure of the next row to be encoded, until all the rows to be encoded in the segmented image are traversed, and obtain the encoding value of the first structure of each row to be encoded in the segmented image.
[0153] In an embodiment of the present application, after the current row to be encoded is encoded, the next row to be encoded is selected, which can be selected from the segmented image according to a specific order or rule. Continuous segments are extracted for the selected next row to be encoded, each continuous segment containing pixel regions with the same attributes or features.
[0154] In the embodiment of the present application, the lines to be encoded may be encoded line by line to ensure that the encoding process has appropriate fault tolerance and data integrity, so as to correctly restore the information of the first structure.
[0155] It can be understood that, on the one hand, by encoding the position information of continuous segments in the image, the image data can be effectively compressed, reducing the demand for data storage and transmission; on the other hand, by extracting useful information about continuous segments of the image, when it is necessary to transmit the image or image-related data, a smaller coding value will improve data transmission efficiency and reduce transmission time and cost.
[0156] S103 , determining a skeleton image of the battery tab based on the encoding values of the first structural bodies of each to-be-encoded row of the segmented image.
[0157] In the embodiment of the present application, first, the electronic device obtains the encoding value of the first structure of each row to be encoded in the segmented image. Then, the electronic device uses a skeleton extraction algorithm to convert the encoding value of the first structure of the row to be encoded into the skeleton of the battery tab. Furthermore, if the skeleton of the battery tab is composed of skeleton information of multiple rows to be encoded, it is necessary to merge these skeletons to obtain a complete skeleton image.
[0158] Figure 5 A schematic diagram of an optional skeleton image of a battery tab provided in an embodiment of the present application, such as Figure 5 As shown, Figure 5 The white pixels in the figure are foreground pixels, i.e., the pixels of the skeleton of the battery tab.
[0159] In some embodiments of the present application, the implementation of determining the skeleton image of the battery tab based on the encoding value of the first structure of each to-be-encoded row of the segmented image may include S1031 to S1034:
[0160] S1031. When there is a second segment to be encoded in the segmented image, encode the second segment to be encoded in the segmented image line by line; wherein the number of pixels in the second segment to be encoded is less than the number of pixels in the first segment to be encoded.
[0161] In the embodiment of the present application, the second segment to be encoded is the remaining segment to be encoded that does not meet the number of bits of the data register.
[0162] S1032: Determine the encoding value of the second structure of each second segment to be encoded according to the position information of the continuous segment in each second segment to be encoded.
[0163] S1033: Update the encoding values of the first structures according to the encoding values of the second structures of the second to-be-encoded segments, to obtain the encoding values of the updated first structures.
[0164] S1034: Determine a skeleton image according to the encoding values of each updated first structure body.
[0165] It can be understood that by encoding the continuous segment position information in the image, the image data can be effectively compressed, reducing the demand for data storage and transmission, thereby improving the extraction efficiency of the skeleton image of the battery tab and reducing the time complexity of extracting the skeleton image.
[0166] In an embodiment of the present application, after obtaining the skeleton image of the battery tab, some image post-processing operations may be performed, such as removing noise, filling holes, or smoothing the skeleton image, etc., to obtain a more complete and high-quality skeleton image.
[0167] In the embodiments of the present application, the skeleton image of the battery tab can be used in multiple application fields, including but not limited to the following:
[0168] 1) Quality control and inspection: Skeleton images can be used to detect whether the shape and structure of the battery tabs meet quality standards. Any abnormal skeleton shape may indicate tab folding or other production problems;
[0169] 2) Automated production: On the battery production line, skeleton images can be used for automated production control to ensure that the shape and structure of the battery tabs meet the requirements;
[0170] 3) Battery performance analysis: The shape and structure of the battery tabs may affect the battery performance. Skeleton images can be used to study the impact of the tabs on battery performance.
[0171] 4) Object recognition and classification: Skeleton images can be used for automatic recognition and classification of battery tabs and are often used in object recognition and intelligent manufacturing;
[0172] 5) Shape analysis: The skeleton image provides the geometric shape information of the battery tab, which can be used for shape analysis and comparison, which is conducive to improving battery design and optimizing production processes;
[0173] 6) Quality improvement: By monitoring skeleton images, abnormal problems in the production process can be identified and corrected early, thereby improving the product quality of the battery.
[0174] It should be noted that the application fields of the skeleton image of the battery tab listed above are only examples. In actual application scenarios, other application fields may also be included, and this application does not impose any limitation on this.
[0175] S104: Determine the detection result of the battery tab according to the skeleton image of the battery tab.
[0176] In an embodiment of the present application, the electronic device determines the detection result of the battery tab according to the skeleton image of the battery tab, which may include the following steps:
[0177] 1) Extract features from the skeleton image to obtain feature information of the skeleton image.
[0178] In an embodiment of the present application, the electronic device extracts feature information of the skeleton image from the skeleton image, and the feature information may include: length, width, curvature, angle or other geometric features of the battery tab.
[0179] 2) Perform feature analysis on the feature information of the skeleton image to obtain feature analysis results.
[0180] In an embodiment of the present application, the electronic device analyzes the characteristic information to evaluate the state of the battery tab. For example, the length of the battery tab can be compared with the standard length, the curvature can be checked to see if it is normal, or any abnormal structure can be detected.
[0181] 3) Classify or judge the feature analysis results to obtain the judgment results.
[0182] In the embodiment of the present application, the electronic device classifies or determines the battery tabs according to the characteristic analysis results, which may include, for example, determining whether the battery tabs are normal, whether they are folded or have other defects, or classifying the battery tabs into different quality grades, etc.
[0183] 4) The electronic device generates the detection result of the battery tab according to the judgment result, and the detection result can be output in the form of binary classification (normal / abnormal) or multi-classification (quality level). The detection result is fed back to the relevant personnel or integrated into the automation system, which can be realized through human-machine interface, report or control signal.
[0184] 5) Relevant personnel or the automated system may take corresponding measures according to the test results, for example, automatically removing defective battery tabs or adjusting the production process to improve the production quality of the battery tabs.
[0185] It is understandable that during the battery production process, the detection results of the battery lugs are determined based on the skeleton image of the battery lugs. On the one hand, the detection results of the battery lugs can be used for quality control and analysis to help improve the battery production process. On the other hand, the detection results of the battery lugs help detect problems related to the battery lugs in advance, help to take relevant measures in time to solve related problems, and can reduce the scrap rate of batteries and improve production efficiency.
[0186] In an embodiment of the present application, a method for detecting a battery tab is provided, the method comprising: obtaining a segmented image of the battery tab; encoding the segmented image, and determining the encoding value of the first structure of each row to be encoded in the segmented image; wherein the first structure represents the relevant information of the continuous segment contained in the row to be encoded; the continuous segment represents the foreground information of the segmented image; based on the encoding value of the first structure of each row to be encoded in the segmented image, determining the skeleton image of the battery tab; and determining the detection result of the battery tab according to the skeleton image of the battery tab. The skeleton information in the segmented image of the battery tab is the foreground information of the image. By traversing and encoding the continuous segments in each row to be encoded in the segmented image, the encoding value of the first structure of each row to be encoded is obtained, and the foreground information in the row to be encoded can be quickly extracted. In this way, since the encoding process is only performed on the foreground information of the segmented image, the traversal time of the segmented image can be reduced, thereby improving the extraction efficiency of the skeleton image, reducing the time complexity of extracting the skeleton image, and thus improving the detection efficiency of the battery tab.
[0187] In some embodiments of the present application, Figure 6 As shown, the implementation of encoding the current to-be-encoded row in the segmented image and determining the encoding value of the second structure of the current to-be-encoded row may include S201 to S203:
[0188] S201. For a current first segment to be encoded in a current row to be encoded, determine a first flag of the current segment to be encoded according to pixel values of each pixel of the current segment to be encoded; the first flag is used to indicate whether a pixel in the current segment to be encoded is a foreground pixel.
[0189] In the embodiment of the present application, the current first segment to be encoded is a part of the current row to be encoded. Exemplarily, 32 consecutive pixels in the current row to be encoded can be used as the first segment to be encoded.
[0190] It should be noted that the current row to be encoded has one or more first segments to be encoded, and the current first segment to be encoded is any one of the multiple first segments to be encoded.
[0191] In the embodiment of the present application, the first flag is used to indicate whether a pixel point in the current first segment to be encoded is a foreground pixel point, which helps to accurately identify the foreground area in the segmented image.
[0192] In some embodiments of the present application, the implementation of determining the first flag bit of the current first segment to be encoded according to the pixel values of each pixel point of the current first segment to be encoded may include S2011 to S2013:
[0193] S2011, loading the current first segment to be encoded into the operation register; the number of pixels in the current first segment to be encoded is related to the number of bits of the operation register.
[0194] In the embodiment of the present application, the electronic device loads the current first segment to be encoded into the operation register.
[0195] In the embodiment of the present application, the operation register may be a 256-bit instruction set register. At this time, the number of pixels in the current first segment to be encoded is at most 256 / 8=32. In other words, the number of pixels in the current first segment to be encoded shall not exceed the bit limit of the operation register to ensure the correct loading and processing of data and prevent data loss or overflow.
[0196] It should be noted that the operation register may also be a 256-bit instruction set register, a 64-bit instruction set register, etc. The embodiment of the present application does not impose any limitation on the number of bits of the operation register.
[0197] In the embodiment of the present application, loading the current first to-be-encoded segment into the operation register can be expressed as:
[0198] data=_mm256_loadu_epi8((__m256i*)(LinePS+X))
[0199] Among them, _mm256_loadu_epi8 is an AVX2 instruction used to load pixels (the current first segment to be encoded) into a 256-bit data register.
[0200] S2012. According to the pixel value of each pixel in the operation register, determine whether each pixel is a foreground pixel at the same time, and obtain the determination result of each pixel.
[0201] In the embodiment of the present application, the determination result of each pixel point is used to indicate whether the corresponding pixel point is a foreground pixel point.
[0202] S2013. Determine the first flag bit of the current first segment to be encoded according to the judgment result of each pixel point.
[0203] In some embodiments of the present application, the implementation of determining the first flag bit of the current first segment to be encoded according to the judgment result of each pixel point may include S20131 or S20132:
[0204] S20131. If the judgment result of the pixel point indicates that the pixel point is a foreground pixel point, set the bit corresponding to the pixel point in the first flag bit of the current first segment to be encoded to a first value.
[0205] S20132. If the judgment result of the pixel point indicates that the pixel point is not a foreground pixel point, the bit corresponding to the pixel point in the first flag bit of the current first segment to be encoded is set to a second value.
[0206] It should be noted that S20131 and S20132 are parallel solutions, and either one of them can be executed. The electronic device can execute S20131 or S20132.
[0207] In the embodiment of the present application, the first value is different from the second value, and the first value and the second value can be in parameter form or in digital form.
[0208] Exemplarily, for the first value and the second value, the first value can be set to 1 and the second value can be set to 0; or, the first value can be set to 0 and the second value can be set to 1; or, the first value can be set to true and the second value can be set to false; or, the first value can be set to false and the second value can be set to true. In the embodiment of the present application, the first value is set to 1 and the second value is set to 0, but this is not specifically limited.
[0209] In the embodiment of the present application, the first flag bit of the current first segment to be encoded is determined according to the judgment result of each pixel point, which can be expressed as:
[0210] masktmp=_mm256_cmpeq_epi8(data,_mm256_setzero_si256())
[0211] mask=_mm256_movemask_epi8(_mm256_andnot_si256(masktmp,_mm256_epi8(0xFF)))
[0212] Among them, _mm256_cmpeq_epi8 is used to compare whether the elements at corresponding positions in two 256-bit integer registers are equal, and return the result (equal positions are all 1, and unequal positions are all 0). __mm256_andnot_si256: used to perform bitwise AND operation; __mm256_movemask_epi8: used to extract the highest bit (i.e., the sign bit) of each byte in a 256-bit integer vector, the sign bit of a positive byte is 0, and the sign bit of a negative byte is 1.
[0213] It can be understood that by configuring different flags for foreground pixels and non-foreground pixels, foreground pixels and non-foreground pixels can be effectively represented, which helps to improve the efficiency and accuracy of image processing.
[0214] It can be understood that, on the one hand, loading the current first segment to be encoded into the operation register can reduce the number of data reads, thereby improving memory access efficiency. On the one hand, by simultaneously determining whether multiple pixels are foreground pixels, the image processing speed can be improved. On the one hand, according to the judgment results of each pixel, determining the first flag bit of the current first segment to be encoded can effectively encode the foreground information in the image, thereby saving encoding storage space.
[0215] S202: Encode the first flag bit of the current first segment to be encoded to determine the encoding value of the second structure of the current first segment to be encoded.
[0216] In the embodiment of the present application, after the electronic device obtains the first flag bit of the current first segment to be encoded, the first flag bit is encoded to obtain the encoding value of the second structure of the current first segment to be encoded.
[0217] In some embodiments of the present application, encoding the first flag bit of the current first segment to be encoded and determining the encoding value of the second structure of the current first segment to be encoded may include S301 to S302:
[0218] S301. When the first flag of the current first segment to be encoded indicates that at least one pixel in the current first segment to be encoded is a foreground pixel, determine the lowest foreground bit and the highest foreground bit of the first flag respectively; the lowest foreground bit represents the position of the lowest valid bit in the flag; the highest foreground bit represents the position of the highest valid bit in the flag.
[0219] In the embodiment of the present application, when at least one of the first flag bits of the current first segment to be encoded is a first value (such as 1), it indicates that at least one pixel in the current first segment to be encoded is a foreground pixel.
[0220] In the embodiment of the present application, the most significant bit may be the first value (eg, 1).
[0221] In the embodiment of the present application, the lowest foreground bit indicates the bit whose lowest bit value in the first flag bit is the first value (such as 1), and illustratively, the lowest foreground bit can be represented as index_one_cur. The highest foreground bit indicates the bit whose highest bit value in the first flag bit is the first value, and illustratively, the highest foreground bit can be represented as index_one_msb.
[0222] Exemplarily, assuming that the first flag bit is: 000011111110110011000, the lowest foreground bit index_one_cur is 4, and the highest foreground bit index_one_msb is 17.
[0223] In the embodiment of the present application, determining the lowest foreground bit of the first flag bit can be expressed as:
[0224] _BitScanForward(&index_one_cur,mask)
[0225] Among them, _BitScanForward is used to find the position of the first set bit (bit is 1) starting from the low bit in an unsigned integer, and is used to quickly determine the position of the least significant bit.
[0226] In the embodiment of the present application, determining the highest foreground bit of the first flag bit can be expressed as:
[0227] _BitScanReverse(&index_one_msb,mask)
[0228] Among them, _BitScanReverse is used to find the position of the first set bit (bit is 1) starting from the high bit in an unsigned integer, and is used to quickly determine the position of the most significant bit.
[0229] S302: When the lowest foreground bit of the first flag bit is not equal to the highest flag bit of the current first segment to be encoded, determine the encoding value of the second structure of the current first segment to be encoded based on the highest foreground bit of the first flag bit.
[0230] In the embodiment of the present application, the highest identification bit of the current first segment to be encoded is the identification bit of the highest bit of the current first segment to be encoded. For example, when the number of pixels included in the current first segment to be encoded is 32, the highest identification bit may be 31.
[0231] In the embodiment of the present application, when the lowest foreground bit of the first flag bit is not equal to the highest flag bit of the current first segment to be encoded, it indicates that the current first segment to be encoded has at least one complete continuous segment. When the lowest foreground bit of the first flag bit is equal to the highest flag bit of the current first segment to be encoded, it indicates that the current first segment to be encoded may have a continuous segment that is continuous with the next first segment to be encoded.
[0232] It can be understood that when the lowest foreground bit of the first flag bit is not equal to the highest identification bit of the current first segment to be encoded, determining the encoding value of the second structure of the current first segment to be encoded can ensure that the current first segment to be encoded has a completed continuous segment, thereby improving the accuracy of the second structure.
[0233] S203, continue to determine the first flag bit of the next first segment to be encoded according to the pixel values of each pixel point of the next first segment to be encoded, thereby determining the encoding value of the second structure of the next first segment to be encoded, until the end position of the next first segment to be encoded is smaller than the width of the segmented image, and obtain the encoding value of the second structure of the current row to be encoded.
[0234] In the embodiment of the present application, the width of the segmented image can be expressed as rcImg.Cols.
[0235] It can be understood that, on the one hand, encoding the first flag bit of the current first segment to be encoded can represent the foreground information of the segmented image in a more compact manner, reducing the cost of data storage and data transmission. On the other hand, encoding each first segment to be encoded in the encoding line can help manage and process large images, improve encoding efficiency, and meet real-time requirements.
[0236] In some embodiments of the present application, before determining the encoding value of the second structure of the current first segment to be encoded based on the highest foreground bit of the first flag bit, the method further includes:
[0237] Get the second flag bit; the second flag bit is used to indicate whether the statistics of the previous continuous segment are completed;
[0238] When the second flag indicates that statistics of the previous continuous segment are not completed and the lowest foreground bit of the first flag is not the second value, the end position of the previous continuous segment is determined according to the start position of the current first segment to be encoded.
[0239] In the embodiment of the present application, the second flag bit can be expressed as msbFlg.
[0240] In an embodiment of the present application, when the second flag bit is a first value (such as 1 or True), it indicates that statistics of the previous continuous segment have not been completed; when the second flag bit is a second value (such as 0 or False), it indicates that statistics of the previous continuous segment have been completed.
[0241] In the embodiment of the present application, when the second flag bit indicates that the statistics of the previous continuous segment have not been completed, and the lowest foreground bit of the first flag bit is not the second value, the end position of the previous continuous segment is determined according to the starting position of the current first segment to be encoded, which can be expressed as:
[0242] if true == msbFlg:
[0243] if index_one_cur!=0:
[0244] sets[count].endPos=X-1
[0245] count++
[0246] The above process can be expressed as follows: if the state of msbFlg is true, and the value of index_one_cur is not 0, it means that the previous continuous segment ends at X-1, and the new continuous segment starts at X+index_one_cur.
[0247] It can be understood that according to the above technical means, on the one hand, it can ensure that when the statistics of the previous continuous segment are not completed, the end position of the previous continuous segment can be correctly determined, so that the foreground pixel points are not missed in the statistical process. On the other hand, by correctly determining the end position of the continuous segment, it can avoid merging the pixels of the non-continuous segments into one continuous segment by mistake, reducing redundant statistical information. On the one hand, it helps to correctly and effectively encode images, reduce unnecessary information transmission, and reduce computing overhead and processing time, thereby improving encoding efficiency.
[0248] In some embodiments of the present application, before determining the encoding value of the second structure of the current first segment to be encoded based on the highest foreground bit of the first flag bit, the method further includes:
[0249] According to the starting position of the current first segment to be encoded and the lowest foreground bit of the first flag, the starting position of the starting continuous segment in the first flag is determined. The above process can be expressed as:
[0250] sets[count].startPos=X+index_one_cur
[0251] No matter the second flag bit msbFlg is the first value (True) or the second value (False), a new continuous segment starts at X+index_one_cur.
[0252] It can be understood that, according to the starting position of the current first segment to be encoded and the lowest foreground bit of the first flag bit, the starting position of the starting continuous segment in the first flag bit is determined. On the one hand, the starting position of the continuous segment can be accurately marked, reducing the error and redundancy of the encoding. On the other hand, unnecessary statistical operations can be effectively avoided, reducing the computational complexity of processing data. On the one hand, by accurately locating the starting position of the starting continuous segment, the accuracy of image encoding can be improved.
[0253] In some embodiments of the present application, the implementation of determining the encoding value of the second structure of the current first segment to be encoded based on the highest foreground bit may include S401 to S404:
[0254] S401. Shift the first flag bit according to the lowest foreground bit of the first flag bit to obtain the currently updated first flag bit.
[0255] In the embodiment of the present application, the implementation of S401 can be expressed as:
[0256] movebits=index_one_cur+1;
[0257] msk==mask>>movebits
[0258] Among them, movebits represents the number of shifts, index_one_cur represents the lowest foreground bit of the first flag bit, and msk represents the first flag bit currently updated.
[0259] S402: Determine the lowest background bit of the first flag bit currently updated according to the lowest foreground bit of the first flag bit; the lowest background bit represents the position of the lowest invalid bit in the flag bit.
[0260] In the embodiment of the present application, the lowest background bit indicates that the value of the lowest bit in the first flag bit is the first value (such as 0). For example, the lowest foreground bit can be represented as index_zero_cur.
[0261] Exemplarily, assuming that the first flag bit is: 000011111110110011000, the lowest background bit index_zero_cur is 0.
[0262] In the embodiment of the present application, the implementation of S402 can be expressed as: index_zero_cur=indexTmp+index_one_cur+1.
[0263] S403: Determine the encoding value of the second structure of the current continuous segment based on the lowest background bit of the first flag bit currently updated.
[0264] In some embodiments of the present application, the implementation of determining the encoding value of the second structure of the current continuous segment based on the lowest background bit of the currently updated first flag bit may include S4031 to S4033:
[0265] S4031. Determine the starting position of the current continuous segment according to the lowest foreground bit of the last updated first flag bit and the starting position of the current first segment to be encoded.
[0266] In the embodiment of the present application, the lowest foreground bit of the last updated first flag bit and the starting position of the current first segment to be encoded are added to obtain the starting position of the current continuous segment.
[0267] In the embodiment of the present application, the implementation of S4031 can be expressed as: sets[count].startPos=X+index_one_cur.
[0268] S4032: When the lowest background bit of the first flag bit currently updated is less than the highest foreground bit, determine the end position of the current continuous segment according to the lowest background bit of the first flag bit currently updated and the start position of the current first segment to be encoded.
[0269] In the embodiment of the present application, the lowest background bit of the currently updated first flag bit is added to the starting position of the current first segment to be encoded, and 1 is added to obtain the end position of the current continuous segment. The above process can be expressed as:
[0270] sets.[count],endPos=X+index_zero_cur+1
[0271] S4033. Determine the encoding value of the second structure of the current continuous segment according to the starting position of the current continuous segment and the ending position of the current continuous segment.
[0272] It can be understood that the starting position and the ending position of the continuous segment can be accurately determined by the lowest foreground bit and the lowest background bit, thereby improving the accuracy of the boundary of the continuous segment, thereby improving the efficiency of encoding and improving the reliability of encoding.
[0273] S404. Continue to shift the currently updated first flag bit according to the lowest foreground bit of the currently updated first flag bit to obtain the next updated first flag bit, and determine the encoding value of the second structure of the next continuous segment based on the lowest background bit of the next updated first flag bit, until the next updated first flag bit is equal to the second value, and obtain the encoding value of the second structure of the current first segment to be encoded.
[0274] It can be understood that, on the one hand, by updating the first flag bit, redundant information in the encoding process can be reduced. On the other hand, by determining the lowest foreground bit and the lowest background bit of the first flag bit, the encoding overhead and the required number of bits can be reduced, which helps to more effectively represent the relevant information of the continuous segments and reduce the amount of data transmitted, thereby saving storage space and improving transmission efficiency.
[0275] In some embodiments of the present application, after determining the end position of the current continuous segment, the method further includes:
[0276] Invert the first flag bit currently updated to obtain the inverted flag bit (~mask);
[0277] According to the lowest foreground point of the inverted flag bit (BitScanForward(&indexTmp,~mask), determine the current shift distance (movebits=indexTmp+1);
[0278] According to the current shift distance, the first flag bit of the current update is shifted to obtain the first flag bit of the next update (mask = mask>>movebits);
[0279] According to the current shift distance and the lowest back-end point of the first flag bit currently updated, determine the lowest foreground point of the first flag bit to be updated next (index_one_cur=indexTmp+index_zero_cur+1);
[0280] According to the lowest foreground point of the next updated first flag bit and the starting position of the current first segment to be encoded, the starting position of the next continuous segment is determined (sets.[count], startPos=X+index_one_cur).
[0281] According to the above technical means, the starting position of the next continuous segment can be accurately located, the coding overhead is reduced, efficient coding is achieved, and the amount of data transmitted is reduced, thereby saving storage space and improving transmission efficiency.
[0282] In the embodiment of the present application, the above process can be expressed as:
[0283] if index_zero_cur <index_one_msb:
[0284] sets[count].endPos=X+index_zero_cur–1
[0285] count++
[0286] movebits=indexTmp+1
[0287] mask=mask>>movebits
[0288] _BitScanForward(&indexTmp,mask)
[0289] index_one_cur=indexTmp+index_zero_cur+1
[0290] sets[count].startPos=X+index_one_cur
[0291] movebits=indexTmp+1
[0292] In some embodiments of the present application, the method also includes: when the lowest background bit of the updated first flag bit is greater than or equal to the highest foreground bit, and the highest foreground bit is not equal to the highest identification bit, determining the end position of the current continuous segment based on the starting position and the highest foreground bit of the current first segment to be encoded; and updating the second flag bit to a second value.
[0293] In the embodiment of the present application, when the lowest background bit of the updated first flag bit is greater than or equal to the highest foreground bit, and the highest foreground bit is not equal to the highest flag bit, it indicates that the continuous segments of the current first segment to be encoded have been counted.
[0294] In the embodiment of the present application, the implementation of determining the end position of the current continuous segment according to the start position of the current first segment to be encoded and the highest foreground bit can be expressed as:
[0295] sets[count].endPos=X+index_one_msb
[0296] count++
[0297] msbFlg=false
[0298] In some embodiments of the present application, the method further includes: when the updated first flag bit lowest background bit is greater than or equal to the highest foreground bit, and the highest foreground bit is equal to the highest identification bit, updating the second flag bit to the first value, which can be expressed as:
[0299] if 31 == index_one_msb:
[0300] msbFlg=true
[0301] In the embodiment of the present application, the updated first flag bit, the lowest background bit, is greater than or equal to the highest foreground bit, and the highest foreground bit is equal to the highest flag bit, indicating that the continuous segments of the current first segment to be encoded have not been counted.
[0302] It is understandable that, on the one hand, the accuracy of determining the end position of the current continuous segment can be improved, thereby improving the reliability of data. On the other hand, by accurately determining the end position of the current continuous segment, unnecessary coding bits can be reduced, thereby improving coding efficiency and reducing the burden of data transmission and storage.
[0303] In some embodiments of the present application, the method further includes: when the lowest foreground bit of the first flag bit is equal to the highest identification bit of the current first segment to be encoded, updating the second flag bit to the first value, which can be expressed as:
[0304] if 31 == index_one_cur:
[0305] msbFlag=true
[0306] continue
[0307] In the embodiment of the present application, the lowest foreground bit of the first flag bit is equal to the highest flag bit of the current first segment to be encoded, indicating that the highest flag bit of the current first segment to be encoded is foreground information.
[0308] It can be understood that, according to the above technical means, the accuracy of determining the end position of the current continuous segment can be improved, thereby improving the reliability of the data.
[0309] In some embodiments of the present application, the method also includes: when the first flag indicates that all pixels in the current first segment to be encoded are not foreground pixels and the second flag is a first value, determining the end position of the previous continuous segment based on the starting position of the current first segment to be encoded, and updating the second flag to a second value.
[0310] if 0 == mask:
[0311] if true == msbFlg:
[0312] sets[count].endPos=X-1
[0313] count++
[0314] msbFlg=false
[0315] end if
[0316] In an embodiment of the present application, if the first flag indicates that all pixels in the current first segment to be encoded are not foreground pixels and the statistics of the previous continuous segment have not been completed, the value obtained by subtracting 1 from the starting position of the current first segment to be encoded is used as the end position of the previous continuous segment.
[0317] It is understandable that, on the one hand, the accuracy of determining the end position of the last continuous segment can be improved, thereby improving the reliability of data. On the other hand, by accurately determining the end position of the last continuous segment, unnecessary coding bits can be reduced, thereby improving coding efficiency and reducing the burden of data transmission and storage.
[0318] In a specific embodiment, the battery tab detection method provided by the present application is explained below.
[0319] Figure 7 A schematic diagram of an optional battery tab detection method provided in an embodiment of the present application Figure 4 ,like Figure 7 As shown, the battery tab detection method may include S501 to S513:
[0320] S501. Start.
[0321] S502, traverse row by row.
[0322] S503, load 32 consecutive pixels into the 256-bit instruction set operation register, and determine whether the 32 pixels are non-zero foreground pixels. Save the determination results of the 32 pixels in the unsigned 32-bit integer array mask. If a bit is 1, it means that the pixel of the corresponding bit is a foreground pixel.
[0323] S504: Determine whether the mask value is equal to 0.
[0324] In the embodiment of the present application, if the mask value is equal to 0, S502 is executed; if the mask value is not equal to 0, S505 is executed.
[0325] S505 , respectively searching for the lowest bit index_one_cur and the highest bit index_one_msb of the non-zero bits in the mask through the Windows system instructions _BitScanForward and _BitScanReverse.
[0326] S506. If the status of msbFlg is false, it means that the previous continuous segment has completed the statistics and the new continuous segment starts at X+index_one_cur. If the status of msbFlg is true and the value of index_one_cur is not 0, it means that the previous continuous segment ends at X-1 and the new continuous segment starts at X+index_one_cur.
[0327] S507. Is the value of index_one_cur equal to 31?
[0328] In the embodiment of the present application, if the value of index_one_cur is equal to 31, S502 is executed; if the value of index_one_cur is not equal to 31, S508 is executed.
[0329] In the embodiment of the present application, if the values of the mask are all 0, it means that the 32 pixels currently loaded are all background points.
[0330] S508. Use the instruction _BitScanForward to find the position of the lowest zero bit in the mask, so as to quickly determine the end position of the current continuous segment; then remove the mask from the lowest zero bit to the right to obtain a new mask, and then use the instruction _BitScanForward to find the lowest non-0 bit and the lowest 0 bit in the new mask, thereby determining the starting position and the ending position of the new continuous segment. Repeat this cycle until the new mask is equal to 0, and then the starting position and the ending position of all the continuous segments in the 32-pixel fragment can be obtained.
[0331] S509. Update X: X=X+32.
[0332] S510: Whether the value of X+32 is smaller than the width of the image.
[0333] In the embodiment of the present application, if the value of X+32 is not less than the width of the image, S502 is executed; if the value of X+32 is less than the width of the image, S511 is executed.
[0334] S511, CPU instruction set acceleration ends.
[0335] S512, continue to traverse the remaining pixel points in each row one by one, and find the starting position and the ending position of all the continuous segments in each remaining row.
[0336] S513, end.
[0337] In the embodiment of the present application, based on Figure 7 The process of the battery tab detection method shown provides the algorithm pseudo code of the CPU instruction set acceleration part.
[0338]
[0339]
[0340] Among them, srcImg is the target image to be processed; LinePS is the first address of the current line image; srcImg.cols indicates the width of the image. Instructions starting with _mm256 in the algorithm pseudocode (such as _mm256_loadu_epi8, _mm256_cmpeq_epi8, etc.) are AVX instruction sets: BitScanForward and _BitScanReverse are windows system operation instruction sets. Among them, __mm256_loadu_epi8 is an AVX2 instruction, which is used to load pixels into a 256-bit register. __mm256_setzero_si256 is used to return a 256-bit integer register with all elements set to 0. __mm256_cmpeq_epi8(m256ia,m256i b) is used to compare whether the elements in corresponding positions of two 256-bit integer registers are equal, and return the result (equal positions are all 1, and unequal positions are all 0). __mm256_andnot_si256 is used to perform bitwise AND operations. __mm256_movemask_epi8 is used to extract the highest bit (i.e., the sign bit) of each byte in a 256-bit integer vector. The sign bit of positive bytes is 0, and the sign bit of negative bytes is 1. _BitScanForward is used to find the position of the first set bit (bit is 1) starting from the low bit in an unsigned integer, which is used to quickly determine the position of the least significant bit. __BitScanReverse is used to find the position of the first set bit (bit is 1) starting from the high bit in an unsigned integer, which is used to quickly determine the position of the most significant bit. __mm256_set1_epi8 is used to create a 256-bit integer vector containing the same value.
[0341] In the embodiment of the present application, the battery tab detection method is implemented by the CPU instruction set AVX. The image RLE encoding method (battery tab detection method) implemented in the present application is tested on a 5120*5120 tab segmentation image on a computer with an Intel 7-10700 CPU. It only takes about 0.3ms to complete the extraction of foreground pixels. The proposed image RLE encoding method is applied to the skeleton extraction algorithm, which makes the skeleton extraction speed of the tab segmentation image nearly 5 times faster than before.
[0342] The preferred embodiments of the present application are described in detail above in conjunction with the accompanying drawings. However, the present application is not limited to the specific details in the above embodiments. Within the technical concept of the present application, the technical solution of the present application can be subjected to a variety of simple modifications, and these simple modifications all belong to the protection scope of the present application. For example, the various specific technical features described in the above specific embodiments can be combined in any suitable manner without contradiction. In order to avoid unnecessary repetition, the present application will not further explain various possible combinations. For another example, the various different embodiments of the present application can also be arbitrarily combined, as long as they do not violate the idea of the present application, they should also be regarded as the contents disclosed in the present application. For another example, under the premise of no conflict, the various embodiments and / or the technical features in the various embodiments described in the present application can be arbitrarily combined with the prior art, and the technical solution obtained after the combination should also fall within the protection scope of the present application.
[0343] It should be understood that in the various method embodiments of the present application, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0344] Based on the same inventive concept as the above embodiments, Figure 8 A schematic diagram of the composition structure of an optional battery tab detection device provided in an embodiment of the present application, such as Figure 8 As shown, the battery tab detection device 10 includes an acquisition unit 11, an encoding unit 12 and a determination unit 13; wherein,
[0345] The acquisition unit 11 is used to acquire a segmented image of the battery tab;
[0346] The encoding unit 12 is used to encode the segmented image and determine the encoding value of the first structure of each to-be-encoded row in the segmented image; wherein the first structure represents the relevant information of the continuous segment contained in the to-be-encoded row; and the continuous segment represents the foreground information of the segmented image;
[0347] The determination unit 13 is used to determine the skeleton image of the battery tab based on the encoding value of the first structure of each of the to-be-encoded rows of the segmented image; and determine the detection result of the battery tab according to the skeleton image of the battery tab.
[0348] In some embodiments of the present application, the encoding unit 12 is further used to encode the current row to be encoded in the segmented image, and determine the encoding value of the second structure of the current row to be encoded; wherein the second structure represents the position information of the continuous segment;
[0349] Determine the encoding value of the first structure of the current row to be encoded according to the encoding value of each of the second structures in the current row to be encoded and the number of the second structures;
[0350] Continue to determine the encoding value of the second structure of the next row to be encoded until all the rows to be encoded in the segmented image are traversed, and obtain the encoding value of the first structure of each row to be encoded in the segmented image.
[0351] In some embodiments of the present application, the encoding unit 12 is further used to determine, for the current first segment to be encoded in the current row to be encoded, a first flag of the current first segment to be encoded according to the pixel value of each pixel of the current first segment to be encoded; the first flag is used to indicate whether the pixel in the current first segment to be encoded is a foreground pixel;
[0352] Encode the first flag bit of the current first segment to be encoded to determine the encoding value of the second structure of the current first segment to be encoded;
[0353] Continue to determine the first flag bit of the next first segment to be encoded according to the pixel values of each pixel point of the next first segment to be encoded, thereby determining the encoding value of the second structure of the next first segment to be encoded, until the end position of the next first segment to be encoded is less than the width of the segmented image, and obtain the encoding value of the second structure of the current row to be encoded.
[0354] In some embodiments of the present application, the encoding unit 12 is further configured to load the current first segment to be encoded into an operation register; the number of pixels in the current first segment to be encoded is related to the number of bits of the operation register;
[0355] According to the pixel value of each pixel point in the operation register, simultaneously judging whether each pixel point is a foreground pixel point, and obtaining a judgment result of each pixel point;
[0356] According to the judgment results of each of the pixel points, a first flag bit of the current first segment to be encoded is determined.
[0357] In some embodiments of the present application, the encoding unit 12 is further configured to set a bit corresponding to the pixel point in the first flag bit of the current first segment to be encoded to a first value if the judgment result of the pixel point indicates that the pixel point is a foreground pixel point;
[0358] If the judgment result of the pixel point indicates that the pixel point is not a foreground pixel point, the bit corresponding to the pixel point in the first flag bit of the current first segment to be encoded is set to a second value.
[0359] In some embodiments of the present application, the encoding unit 12 is further configured to, when the first flag bit of the current first segment to be encoded indicates that at least one pixel in the current first segment to be encoded is a foreground pixel, respectively determine the lowest foreground bit and the highest foreground bit of the first flag bit; the lowest foreground bit represents the position of the lowest valid bit in the flag bit; the highest foreground bit represents the position of the highest valid bit in the flag bit;
[0360] When the lowest foreground bit of the first flag bit is not equal to the highest flag bit of the current first segment to be encoded, the encoding value of the second structure of the current first segment to be encoded is determined based on the highest foreground bit of the first flag bit.
[0361] In some embodiments of the present application, before determining the encoding value of the second structure of the current first segment to be encoded based on the highest foreground bit of the first flag bit, the determining unit 13 is further used to obtain a second flag bit; the second flag bit is used to indicate whether the statistics of the previous continuous segment are completed;
[0362] When the second flag bit indicates that statistics of the previous continuous segment have not been completed and the lowest foreground bit of the first flag bit is not the second value, the end position of the previous continuous segment is determined according to the starting position of the current first segment to be encoded.
[0363] In some embodiments of the present application, before determining the encoding value of the second structure of the current first segment to be encoded based on the highest foreground bit of the first flag bit, the determination unit 13 is also used to determine the starting position of the starting continuous segment in the first flag bit based on the starting position of the current first segment to be encoded and the lowest foreground bit of the first flag bit.
[0364] In some embodiments of the present application, the determining unit 13 is further configured to perform a shift process on the first flag bit according to the lowest foreground bit of the first flag bit to obtain a currently updated first flag bit;
[0365] Determine the lowest background bit of the first flag bit currently updated according to the lowest foreground bit of the first flag bit; the lowest background bit represents the position of the lowest invalid bit in the flag bit;
[0366] Determine the encoding value of the second structure of the current continuous segment based on the lowest background bit of the first flag bit currently updated;
[0367] Continue to shift the currently updated first flag bit according to the lowest foreground bit of the currently updated first flag bit to obtain the next updated first flag bit, and determine the encoding value of the second structure of the next continuous segment based on the lowest background bit of the next updated first flag bit, until the next updated first flag bit is equal to the second value, and obtain the encoding value of the second structure of the current first segment to be encoded.
[0368] In some embodiments of the present application, the determining unit 13 is further configured to determine the starting position of the current continuous segment according to the lowest foreground bit of the last updated first flag bit and the starting position of the current first segment to be encoded;
[0369] In the case that the lowest background bit of the updated first flag bit is less than the highest foreground bit, determining the end position of the current continuous segment according to the lowest background bit of the currently updated first flag bit and the start position of the current first segment to be encoded;
[0370] Determine the encoding value of the second structure of the current continuous segment according to the starting position of the current continuous segment and the ending position of the current continuous segment.
[0371] In some embodiments of the present application, after determining the end position of the current continuous segment, the determining unit 13 is further configured to invert the first flag bit of the current update to obtain an inverted flag bit;
[0372] Determine the current shift distance according to the lowest foreground point of the inverted flag bit;
[0373] According to the current shift distance, the first flag bit of the current update is shifted to obtain the first flag bit of the next update;
[0374] Determine the lowest foreground point of the first flag bit to be updated next according to the current shift distance and the lowest rear point of the first flag bit to be updated currently;
[0375] The starting position of the next continuous segment is determined according to the lowest foreground point of the next updated first flag bit and the starting position of the current first segment to be encoded.
[0376] In some embodiments of the present application, the determination unit 13 is also used to determine the end position of the current continuous segment according to the starting position of the current first segment to be encoded and the highest foreground bit when the lowest background bit of the updated first flag bit is greater than or equal to the highest foreground bit, and the highest foreground bit is not equal to the highest identification bit; and update the second flag bit to a second value.
[0377] In some embodiments of the present application, the determination unit 13 is further used to update the second flag bit to the first value when the lowest background bit of the updated first flag bit is greater than or equal to the highest foreground bit, and the highest foreground bit is equal to the highest identification bit.
[0378] In some embodiments of the present application, the determining unit 13 is further configured to update the second flag bit to a first value when the lowest foreground bit of the first flag bit is equal to the highest flag bit of the current first segment to be encoded.
[0379] In some embodiments of the present application, the determination unit 13 is also used to determine the end position of the previous continuous segment according to the starting position of the current first segment to be encoded, and update the second flag to a second value when the first flag indicates that all pixels in the current first segment to be encoded are not foreground pixels and the second flag is a first value.
[0380] In some embodiments of the present application, the determining unit 13 is further configured to, when there is a second segment to be encoded in the segmented image, encode the second segment to be encoded in the segmented image line by line; wherein the number of pixels in the second segment to be encoded is less than the number of pixels in the first segment to be encoded;
[0381] Determining, according to position information of continuous segments in each of the second segments to be encoded, a coding value of a second structure of each of the second segments to be encoded;
[0382] According to the code value of the second structure of each of the second to-be-encoded segments, the code value of each of the first structures is updated to obtain the code value of each updated first structure;
[0383] The skeleton image is determined according to the code values of each updated first structure.
[0384] In some embodiments of the present application, the segmented image of the battery tab is a single-channel image.
[0385] Those skilled in the art should understand that the relevant description of the above-mentioned battery tab detection device in the embodiment of the present application can be understood by referring to the relevant description of the battery tab detection method in the present embodiment.
[0386] Fig. 9 A schematic diagram of the composition structure of an optional electronic device provided in an embodiment of the present application, such as Fig. 9 As shown, the electronic device 20 includes a processor 21 and a memory 22. The memory 22 can store a computer program, and the processor 21 can call and run the computer program from the memory 22 to implement the method in this embodiment.
[0387] The memory 22 may be a separate device independent of the processor 21 , or may be integrated into the processor 21 .
[0388] In some embodiments, Fig. 9 As shown, the electronic device 20 may further include a transceiver 23, and the processor 21 may control the transceiver 23 to communicate with other devices, specifically, may send information or data to other devices, or receive information or data sent by other devices.
[0389] The transceiver 23 may include a transmitter and a receiver. The transceiver 23 may further include an antenna, and the number of the antennas may be one or more.
[0390] It can be understood that the processor of the embodiment of the present application may be an integrated circuit chip with information processing capabilities. In the implementation process, each step of the above method embodiment can be completed by the hardware integrated logic circuit or software instructions in the processor. The above processor can be a general processor, a digital signal processor (DigitalSignal Processor, DSP), an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), a field programmable gate array (Field Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiment of the present application can be directly embodied as a hardware decoding processor to perform, or the hardware and software modules in the decoding processor are combined and executed. The software module can be located in a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, and other mature storage media in the art. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.
[0391] It can also be understood that the memory in the embodiments of the present application can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example but not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM) and direct RAM bus random access memory (DR RAM). It should be noted that the memory described in the embodiments of the present application is intended to include but is not limited to these and any other suitable types of memory.
[0392] An embodiment of the present application also provides a computer-readable storage medium for storing a computer program.
[0393] In some embodiments, the computer-readable storage medium can be applied to the electronic device in the embodiments of the present application, and when the computer program is executed by at least one processor, it implements the corresponding processes implemented by the electronic device in the various methods of the embodiments of the present application. For the sake of brevity, they are not repeated here.
[0394] An embodiment of the present application also provides a computer program product, including computer program instructions.
[0395] In some embodiments, the computer program product can be applied to the electronic device in the embodiments of the present application, and the computer program instructions enable the computer to execute the corresponding processes implemented by the electronic device in the various methods of the embodiments of the present application. For the sake of brevity, they will not be repeated here.
[0396] The embodiment of the present application also provides a computer program.
[0397] In some embodiments, the computer program can be applied to the electronic devices in the embodiments of the present application. When the computer program runs on a computer, the computer executes the corresponding processes implemented by the electronic devices in the various methods of the embodiments of the present application. For the sake of brevity, they will not be repeated here.
[0398] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed in this application can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0399] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described devices and units can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0400] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0401] The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the embodiments of the present application.
[0402] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0403] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0404] The methods disclosed in several method embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments.
[0405] The features disclosed in several product embodiments provided in this application can be arbitrarily combined without conflict to obtain new product embodiments.
[0406] The features disclosed in several method or device embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments or device embodiments.
[0407] 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.
Claims
1. A method for detecting a battery tab, characterized in that: The method comprises: Obtain a segmented image of the battery tab; Encoding the segmented image to determine the encoding value of the first structure of each to-be-encoded row in the segmented image; wherein the first structure represents the relevant information of the continuous segment contained in the to-be-encoded row; and the continuous segment represents the foreground information of the segmented image; Determine a skeleton image of a battery tab based on the encoding values of the first structural body of each of the to-be-encoded rows of the segmented image; The detection result of the battery tab is determined according to the skeleton image of the battery tab.
2. The method according to claim 1, characterized in that The step of encoding the segmented image and determining the encoding value of the first structure of each to-be-encoded row in the segmented image comprises: Encode the current row to be encoded in the segmented image, and determine the encoding value of the second structure of the current row to be encoded; wherein the second structure represents the position information of the continuous segment; Determine the encoding value of the first structure of the current row to be encoded according to the encoding value of each of the second structures in the current row to be encoded and the number of the second structures; Continue to determine the encoding value of the second structure of the next row to be encoded until all the rows to be encoded in the segmented image are traversed, and obtain the encoding value of the first structure of each row to be encoded in the segmented image.
3. The method according to claim 2, characterized in that The step of encoding the current row to be encoded in the segmented image and determining the encoding value of the second structure of the current row to be encoded includes: For the current first segment to be encoded in the current row to be encoded, determining a first flag of the current first segment to be encoded according to the pixel value of each pixel of the current first segment to be encoded; the first flag is used to indicate whether the pixel in the current first segment to be encoded is a foreground pixel; Encode the first flag bit of the current first segment to be encoded to determine the encoding value of the second structure of the current first segment to be encoded; Continue to determine the first flag bit of the next first segment to be encoded according to the pixel values of each pixel point of the next first segment to be encoded, thereby determining the encoding value of the second structure of the next first segment to be encoded, until the end position of the next first segment to be encoded is less than the width of the segmented image, and obtain the encoding value of the second structure of the current row to be encoded.
4. The method according to claim 3, characterized in that The determining, according to the pixel values of each pixel point of the current first segment to be encoded, the first flag bit of the current first segment to be encoded comprises: Loading the current first segment to be encoded into an operation register; the number of pixels in the current first segment to be encoded is related to the number of bits in the operation register; According to the pixel value of each pixel point in the operation register, simultaneously judging whether each pixel point is a foreground pixel point, and obtaining a judgment result of each pixel point; According to the judgment results of each of the pixel points, a first flag bit of the current first segment to be encoded is determined.
5. The method according to claim 4, characterized in that The determining, according to the judgment results of each of the pixel points, the first flag bit of the current first segment to be encoded comprises: If the judgment result of the pixel point indicates that the pixel point is a foreground pixel point, setting the bit corresponding to the pixel point in the first flag bit of the current first segment to be encoded to a first value; If the judgment result of the pixel point indicates that the pixel point is not a foreground pixel point, the bit corresponding to the pixel point in the first flag bit of the current first segment to be encoded is set to a second value.
6. The method according to any one of claims 3 to 5, characterized in that: The step of encoding the first flag bit of the current first segment to be encoded to determine the encoding value of the second structure of the current first segment to be encoded includes: In a case where the first flag bit of the current first segment to be encoded indicates that at least one pixel in the current first segment to be encoded is a foreground pixel, respectively determining a lowest foreground bit and a highest foreground bit of the first flag bit; the lowest foreground bit represents a position where the lowest valid bit in the flag bit is located; and the highest foreground bit represents a position where the highest valid bit in the flag bit is located; When the lowest foreground bit of the first flag bit is not equal to the highest flag bit of the current first segment to be encoded, the encoding value of the second structure of the current first segment to be encoded is determined based on the highest foreground bit of the first flag bit.
7. The method according to claim 6, characterized in that Before determining the encoding value of the second structure of the current first segment to be encoded based on the highest foreground bit of the first flag bit, the method further includes: Obtain a second flag bit; the second flag bit is used to indicate whether the statistics of the previous continuous segment are completed; When the second flag bit indicates that statistics of the previous continuous segment have not been completed and the lowest foreground bit of the first flag bit is not the second value, the end position of the previous continuous segment is determined according to the starting position of the current first segment to be encoded.
8. The method according to claim 6, characterized in that Before determining the encoding value of the second structure of the current first segment to be encoded based on the highest foreground bit of the first flag bit, the method further includes: According to the starting position of the current first segment to be encoded and the lowest foreground bit of the first flag bit, the starting position of the starting continuous segment in the first flag bit is determined.
9. The method according to any one of claims 6 to 8, characterized in that: The determining, based on the highest foreground bit of the first flag bit, the encoding value of the second structure of the current first segment to be encoded includes: According to the lowest foreground bit of the first flag bit, the first flag bit is shifted to obtain a currently updated first flag bit; Determine the lowest background bit of the first flag bit currently updated according to the lowest foreground bit of the first flag bit; the lowest background bit represents the position of the lowest invalid bit in the flag bit; Determine the encoding value of the second structure of the current continuous segment based on the lowest background bit of the first flag bit currently updated; Continue to shift the currently updated first flag bit according to the lowest foreground bit of the currently updated first flag bit to obtain the next updated first flag bit, and determine the encoding value of the second structure of the next continuous segment based on the lowest background bit of the next updated first flag bit, until the next updated first flag bit is equal to the second value, and obtain the encoding value of the second structure of the current first segment to be encoded.
10. The method according to claim 9, characterized in that The step of determining the encoding value of the second structure of the current continuous segment based on the lowest background bit of the first flag bit currently updated comprises: Determine the starting position of the current continuous segment according to the lowest foreground bit of the last updated first flag bit and the starting position of the current first segment to be encoded; In the case that the lowest background bit of the currently updated first flag bit is less than the highest foreground bit, determining the end position of the current continuous segment according to the lowest background bit of the currently updated first flag bit and the start position of the current first segment to be encoded; Determine the encoding value of the second structure of the current continuous segment according to the starting position of the current continuous segment and the ending position of the current continuous segment.
11. The method according to claim 10, characterized in that The method further comprises: Invert the first flag bit of the current update to obtain an inverted flag bit; Determine the current shift distance according to the lowest foreground point of the inverted flag bit; According to the current shift distance, the first flag bit of the current update is shifted to obtain the first flag bit of the next update; Determine the lowest foreground point of the first flag bit to be updated next according to the current shift distance and the lowest rear point of the first flag bit to be updated currently; The starting position of the next continuous segment is determined according to the lowest foreground point of the next updated first flag bit and the starting position of the current first segment to be encoded.
12. The method according to claim 10 or 11, characterized in that: The method further comprises: When the lowest background bit of the currently updated first flag bit is greater than or equal to the highest foreground bit, and the highest foreground bit is not equal to the highest identification bit, the end position of the current continuous segment is determined according to the starting position of the current first segment to be encoded and the highest foreground bit; and the second flag bit is updated to a second value.
13. The method according to claim 10 or 11, characterized in that: The method further comprises: When the lowest background bit of the currently updated first flag bit is greater than or equal to the highest foreground bit, and the highest foreground bit is equal to the highest identification bit, the second flag bit is updated to the first value.
14. The method according to any one of claims 7 to 13, characterized in that The method further comprises: When the lowest foreground bit of the first flag bit is equal to the highest flag bit of the current first segment to be encoded, the second flag bit is updated to the first value.
15. The method according to any one of claims 7 to 13, characterized in that The method further comprises: When the first flag indicates that all pixels in the current first segment to be encoded are not foreground pixels and the second flag is a first value, the end position of the previous continuous segment is determined according to the starting position of the current first segment to be encoded, and the second flag is updated to a second value.
16. The method according to any one of claims 1 to 15, characterized in that The determining of the skeleton image of the battery tab based on the encoding value of the first structure of each of the to-be-encoded rows of the segmented image comprises: In the case where the segmented image has a second segment to be encoded, encoding the second segment to be encoded in the segmented image line by line; wherein the number of pixels in the second segment to be encoded is less than the number of pixels in the first segment to be encoded; Determining, according to position information of continuous segments in each of the second segments to be encoded, a coding value of a second structure of each of the second segments to be encoded; According to the code value of the second structure of each of the second to-be-encoded segments, the code value of each of the first structures is updated to obtain the code value of each updated first structure; The skeleton image is determined according to the code values of each updated first structure.
17. The method according to any one of claims 1 to 15, characterized in that The segmented image of the battery tab is a single-channel image.
18. A battery tab detection device, characterized in that: The device comprises: An acquisition unit, used for acquiring a segmented image of a battery tab; An encoding unit, configured to encode the segmented image and determine the encoding value of a first structure of each to-be-encoded row in the segmented image; wherein the first structure represents relevant information of a continuous segment included in the to-be-encoded row; and the continuous segment represents foreground information of the segmented image; A determination unit is used to determine a skeleton image of a battery tab based on the encoding values of the first structural body in each of the to-be-encoded rows of the segmented image; and to determine a detection result of the battery tab according to the skeleton image of the battery tab.
19. An electronic device, characterized in that: The electronic device comprises: a processor and a memory, wherein the memory is used to store a computer program, and the processor is used to call and run the computer program stored in the memory to execute the battery tab detection method according to any one of claims 1 to 17.
20. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by at least one processor, the battery tab detection method according to any one of claims 1 to 17 is implemented.