End face detection method, device and equipment of tab and storage medium
In machine vision inspection in the field of industrial manufacturing, the determination of the fixed point and size of the cropping frame and the local image filling technology are used to solve the problem of inaccurate detection caused by random position and complex background in the detection of the tab end face, improve the detection accuracy and Distortion is reduced.
Patent Information
- Application Number
- CN202411236205.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-04
- Publication Date
- 2024-10-08
- Estimated Expiration
- 2044-09-04
AI Technical Summary
In machine vision inspection in the field of industrial manufacturing, the end face detection of the tabs results in inaccurate detection results due to the random location of the tabs and the complex background.
By obtaining the area of interest in the image to be detected, determining the fixed point and size of the cropping frame, filling the non-overlapping areas, and adjusting the size of the local image to input the end face detection model, reducing the impact of background noise and tab distortion.
It improves the accuracy of pole end surface detection, reduces the impact of background noise on detection results, and reduces distortion before and after pole scaling.
Smart Images

Figure CN118747798A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computers, and in particular to a method, device, equipment and storage medium for detecting the end face of a tab. Background Art
[0002] In the field of industrial manufacturing, target detection is a very commonly used method in machine vision inspection, such as end face inspection of tabs.
[0003] However, in current industrial manufacturing scenarios, the locations of the tabs are random and the background factors are complex, which makes it difficult to detect the end faces of the tabs, resulting in inaccurate detection results for the end faces of the tabs. Summary of the invention
[0004] The present application at least provides a method, device, equipment and storage medium for detecting the end face of a tab.
[0005] The present application provides a method for detecting the end face of a pole lug, comprising: acquiring an image to be detected, wherein the image to be detected contains an area of interest corresponding to the pole lug; determining the cropping frame by taking a first preset position in the area of interest as a fixed point of a cropping frame and an input image size allowed by an end face detection model as a size of the cropping frame; filling the target area in response to the presence of a target area in the cropping frame that does not overlap with the image to be detected; cropping the overlapping area in the image to be detected, and splicing the cropped overlapping area with the filled target area to obtain a partial image, wherein the overlapping area is an overlapping area between the cropping frame and the image to be detected; and inputting the partial image into the end face detection model to obtain an end face detection result of the pole lug.
[0006] In the above scheme, the cropping frame is determined by first taking the first preset position in the region of interest contained in the image to be detected as the fixed point of the cropping frame and the input image size allowed by the end face detection model as the size of the cropping frame. If the region of interest is at the edge of the image to be detected, it may cause the cropping frame to be at least partially outside the image to be detected. Therefore, this part of the area is filled to maintain the size of the local image. Compared with directly using the overlapping area as the input of the end face detection model or scaling the overlapping area to the input image size as the input of the end face detection model, this scheme ensures the size of the scaled image by filling the area in the cropping frame that does not overlap with the image to be detected, thereby reducing the distortion of the pole ear before and after scaling, and thus making the end face detection result more accurate.
[0007] In some embodiments, the end face detection method of the tab further includes: in response to the absence of a target area in the cropping frame that does not overlap with the image to be detected, cropping the overlapping area in the image to be detected to obtain a partial image.
[0008] In the above solution, if there is no target area in the cropping frame that does not overlap with the image to be detected, the local image can be directly cropped from the image to be detected.
[0009] In some embodiments, the first preset position is the center point of the region of interest, and the fixed point of the cropping frame is the center point of the cropping frame.
[0010] In the above solution, by determining the fixed point at the center point of the region of interest, the end face of the tab can be more completely located within the local image.
[0011] In some embodiments, in response to the presence of a target area in the cropping frame that does not overlap with the image to be detected, the target area is filled, including: filling the target area with a preset filling value; or, cropping other areas in the image to be detected except the overlapping area according to the size of the target area to obtain a supplementary area, and filling the target area with the supplementary area.
[0012] In the above solution, multiple ways of filling the target area are provided, which can improve the flexibility of filling the target area.
[0013] In some embodiments, the method further includes: determining first coordinates of a plurality of first sampling points in the boundary of the image to be detected in a preset coordinate system and second coordinates of a plurality of second sampling points in the boundary of the cropping frame in a preset coordinate system, wherein the preset coordinate system is established with a second preset position in the image to be detected as the origin of the coordinate system; based on each first coordinate and each second coordinate, determining whether a target area exists in the cropping frame or whether a target area does not exist in the cropping frame.
[0014] In the above solution, by establishing a preset coordinate system according to the image to be detected, the process of determining the non-overlapping area between the zoomed image and the image to be detected is made more convenient.
[0015] In some embodiments, the image to be detected is obtained by scaling an initial image, wherein the initial image includes an initial region of interest corresponding to the pole ear, and obtaining the image to be detected includes: determining the scaling ratio of the initial image according to the size of the initial region of interest in the initial image, the input image size, and a preset maximum scaling ratio; scaling the initial image according to the scaling ratio to obtain the image to be detected, wherein the initial region of interest in the initial image becomes the region of interest in the image to be detected after scaling.
[0016] In the above scheme, by first determining the scaling ratio of the initial image according to the size of the initial region of interest, the input image size and the preset maximum scaling ratio and scaling the initial image, compared to obtaining a local image from the initial image, scaling the initial image and then cropping it can adjust the proportion of the region of interest in the cropping frame, thereby facilitating subsequent end face detection.
[0017] In some embodiments, the size of the initial region of interest in the initial image includes height and width, and the scaling ratio of the initial image is determined according to the size of the initial region of interest in the initial image, the input image size, and a preset maximum scaling ratio, including: obtaining a first ratio between the input image size and the height, and a second ratio between the input image size and the width; selecting one from the first ratio, the second ratio, and the preset maximum scaling ratio as the scaling ratio of the initial image.
[0018] In the above solution, at least one available scaling ratio is first determined according to multiple methods, and then one of the multiple scaling ratios is selected as the scaling ratio of the initial image, so that the selection of the scaling ratio is more diverse.
[0019] In some embodiments, the method also includes: using a semantic segmentation network to process the initial image to obtain a mask map of the initial image about the ear; performing connected domain extraction on the mask map to obtain the position of the initial region of interest in the mask map; and determining the position of the initial region of interest in the initial image based on the position of the initial region of interest in the mask map.
[0020] In the above scheme, semantic segmentation is a fine-grained computer vision task. Classifying each pixel will obtain a more accurate region of interest.
[0021] In some embodiments, the end face detection result includes the position of the defect in the initial region of interest, and the local image is input into the end face detection model to obtain the end face detection result about the pole ear, including: inputting the local image into the end face detection model to obtain the position of the defect in the local image; based on the position of the defect in the local image, the position of the region of interest in the local image and the scaling ratio, determining the position of the defect in the initial region of interest.
[0022] In the above solution, by converting the position of the defect in the local image into the position of the defect in the initial region of interest, it is convenient to perform post-processing according to the position of the defect in the initial region of interest.
[0023] In some embodiments, the method also includes: determining the position of the region of interest in the image to be detected based on the position of the initial region of interest in the initial image and the scaling ratio; in response to the presence of a target area in the cropping frame that does not overlap with the image to be detected, determining the position of the region of interest in the local image based on the relative position relationship between the target area and the region of interest.
[0024] In the above scheme, the target area is located on the side of the region of interest close to the origin of the local image, or the target area is located on the side of the region of interest far from the origin of the local image. The coordinates of the region of interest in the local image will be different. Therefore, by considering the relative position relationship between the target area and the region of interest, the position of the region of interest in the local image can be determined more accurately.
[0025] In some embodiments, based on the position of the defect in the local image, the position of the region of interest in the local image, and the scaling ratio, the position of the defect in the initial region of interest is determined, including: taking the difference between the horizontal coordinate of the defect in the local image and the horizontal coordinate of the region of interest in the local image as the horizontal coordinate of the defect in the region of interest; and taking the difference between the vertical coordinate of the defect in the local image and the vertical coordinate of the region of interest in the local image as the vertical coordinate of the defect in the region of interest; based on the scaling ratio, inversely transforming the horizontal coordinate and the vertical coordinate of the defect in the region of interest to obtain the horizontal coordinate and vertical coordinate of the defect in the initial region of interest.
[0026] In the above scheme, the position of the defect in the local image is first converted to the position in the region of interest, and then the position of the defect in the initial region of interest is determined by the inverse transformation of the scaling process.
[0027] The present application provides an end face detection device for a pole lug, comprising: an image acquisition module, a cropping frame determination module, a local image acquisition module and a target detection module; the image acquisition module is used to acquire an image to be detected, wherein the image to be detected contains an area of interest corresponding to the pole lug; the cropping frame determination module is used to determine the cropping frame by taking a first preset position in the area of interest as a fixed point of the cropping frame and an input image size allowed by an end face detection model as a size of the cropping frame; the local image acquisition module is used to fill the target area in response to the existence of a target area in the cropping frame that does not overlap with the image to be detected; the overlapping area in the image to be detected is cropped, and the cropped overlapping area is spliced with the filled target area to obtain a local image, wherein the overlapping area is the overlapping area between the cropping frame and the image to be detected; the target detection module is used to input the local image into the end face detection model to obtain an end face detection result about the pole lug.
[0028] The present application provides an electronic device, including a memory and a processor coupled to each other, wherein the processor is used to execute program instructions stored in the memory to implement the above-mentioned end face detection method of the tab.
[0029] The present application provides a computer-readable storage medium on which program instructions are stored. When the program instructions are executed by a processor, the above-mentioned end face detection method of the tab is implemented.
[0030] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] 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.
[0032] Figure 1 is a schematic flow chart of a method for detecting the end face of a tab provided in some embodiments; Figure 2 is a schematic diagram including an image to be detected and a cropping frame provided by some embodiments; Figure 3 is a schematic diagram of an image to be detected and a plurality of first sampling points and a plurality of second sampling points in a cropping frame provided by some embodiments; Figure 4 Some embodiments provide Figure 1 Schematic diagram of the sub-process of step S11; Figure 5 is another schematic flow chart of a method for detecting the end face of a tab provided in some embodiments; Figure 6 is another schematic flow chart of a method for detecting the end face of a tab provided in some embodiments; Figure 7 is a schematic structural diagram of an end face detection device for a tab provided in some embodiments; Figure 8 is a schematic diagram of a framework of an electronic device provided in some embodiments; Fig. 9 It is a schematic diagram of a framework of a computer-readable storage medium provided by some embodiments. DETAILED DESCRIPTION
[0033] The scheme of the embodiment of the present application is described in detail below in conjunction with the drawings of the specification.
[0034] In the following description, for the purpose of explanation rather than limitation, specific details such as specific subsystem structures, interfaces, and technologies are provided to facilitate a thorough understanding of the present application.
[0035] The term "and / or" in this article is only a description of the association relationship of associated objects, indicating that there may be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the objects associated before and after are in an "or" relationship. In addition, "many" in this article means two or more than two. In addition, the term "at least one" in this article means any combination of at least two of any one or more of a plurality of, for example, including at least one of A, B, and C, can mean including any one or more elements selected from the set consisting of A, B, and C.
[0036] In the field of industrial manufacturing, object detection is a very common method in machine vision inspection, such as product defect detection. For object detection scenarios, it is very important for the detection results that the pictures actually fed into the model inference are consistent with the style of the training set.
[0037] For example, in scenarios such as end face inspection of tabs, because the tabs are small, if the defect detection is performed directly on the image to be inspected, it is likely that the background in the image to be inspected will interfere with the inspection results. In addition, considering that the tabs are generally multi-layer structures and each layer is relatively thin, if the region of interest in the image to be inspected is directly scaled, it is likely that the end face of the tab in the region of interest will be distorted, which will also affect the end face inspection results.
[0038] Therefore, this scheme proposes a method for detecting the end face of the pole ear, by first determining the cropping frame based on the first preset position in the region of interest contained in the image to be detected as the fixed point of the cropping frame and the input image size allowed by the end face detection model as the size of the cropping frame, and obtaining the area overlapping with the cropping frame in the image to be detected, so that the end face detection can be performed directly based on the local image later. Compared with directly using the image to be detected to detect the end face of the pole ear, this scheme can reduce the impact of background noise in the image to be detected on the end face detection result, thereby improving the accuracy of the end face detection result. In addition, this scheme does not directly crop the region of interest in the image to be detected, and then scales the cropped area according to the image size allowed by the end face detection model, which can reduce the distortion of the pole ear in the image input to the end face detection model, and further improve the accuracy of the end face detection result.
[0039] See also Figure 1, the end face detection method of the pole lug provided in the present application may include the contents of the following steps S11 to S15. Step S11: Acquire the image to be detected. The image to be detected contains the region of interest corresponding to the pole lug. Step S12: Determine the cropping frame by taking the first preset position in the region of interest as the fixed point of the cropping frame and the input image size allowed by the end face detection model as the size of the cropping frame. Step S13: In response to the existence of a target area in the cropping frame that does not overlap with the image to be detected, fill the target area. Step S14: Crop the overlapping area in the image to be detected, and splice the cropped overlapping area with the filled target area to obtain a partial image. The overlapping area is the overlapping area between the cropping frame and the image to be detected. Step S15: Input the partial image into the end face detection model to obtain the end face detection result of the pole lug.
[0040] The region of interest corresponding to the tab can be considered as the image region containing the tab. In the structure of the battery, the tab can be used to connect the electrode material inside the battery with the external circuit. Using the first preset position in the region of interest as the fixed point of the cropping frame and using the input image size allowed by the end face detection model as the size of the cropping frame can be specifically understood as: the relative position of the first preset position in the region of interest is the same as the relative position of the first preset position in the cropping frame. Exemplarily, if the first preset position is the center of the region of interest, then the first preset position is also in the center of the cropping frame, or, if the first preset position is the upper left corner of the region of interest, then the first preset position is also in the upper left corner of the cropping frame. In other embodiments, the first preset position can also be other positions in the region of interest. Because there will be an overlapping area between the cropping frame and the region to be detected, the region to be detected can be cropped based on the overlapping area to obtain a partial image. Exemplarily, the overlapping area between the cropping frame and the image to be detected can be the area covered by the cropping frame in the image to be detected, that is, the intersection between the cropping frame and the image to be detected. In some application scenarios, if there is a target area in the cropping frame that does not overlap with the image to be detected, the target area can be filled. Figure 2As shown, there is a target area beyond the image to be detected P1 on the left side of the cropping frame, then the target area can be filled, and the combination of the overlapping area and the target area is used as a local image, that is, the area in the cropping frame obtained after filling is used as a local image. For example, if the partial area in the cropping frame exceeds the image to be detected, other areas except the overlapping area in the image to be detected can be cut according to the exceeding part to obtain a supplementary area, and then the overlapped area cut down is combined with the supplementary area to obtain a local image of the input image size. In some application scenarios, the way to obtain the local image can be to directly cut the image to be detected according to the overlapping area to obtain the local image, or in some application scenarios, the way to obtain the local image can also be: if the partial area in the cropping frame exceeds the image to be detected, the image to be detected is enlarged so that there is no area beyond the image to be detected in the cropping frame, or it can also be to adjust the fixed point position, for example, the original fixed point is the center point in the region of interest, then the fixed point can be moved away from the cropping frame in the direction beyond the image to be detected until the cropping frame completely overlaps with the image to be detected.
[0041] In some application scenarios, the end face detection model can be a convolutional neural network, a feedforward neural network, a neural network based on an attention mechanism, etc. The structure of the end face detection model can include a feature extraction layer and a detection head connected to the feature extraction layer, and the detection head can output the end face detection result. In some application scenarios, if the target detection is defect detection, the end face detection result can be a defect detection result. Exemplarily, if the tab is a tab, the end face detection result can be a detection result of whether there is a defect in the tab.
[0042] In the above scheme, the cropping frame is determined by first taking the first preset position in the region of interest contained in the image to be detected as the fixed point of the cropping frame and the input image size allowed by the end face detection model as the size of the cropping frame. If the region of interest is at the edge of the image to be detected, it may cause the cropping frame to be at least partially outside the image to be detected. Therefore, this part of the area is filled to maintain the size of the local image. Compared with directly using the overlapping area as the input of the end face detection model or scaling the overlapping area to the input image size as the input of the end face detection model, this scheme ensures the size of the scaled image by filling the area in the cropping frame that does not overlap with the image to be detected, thereby reducing the distortion of the pole ear before and after scaling, and thus making the end face detection result more accurate.
[0043] In addition, this solution does not directly crop the area of interest in the image to be inspected and then scale the cropped area according to the image size allowed by the end face detection model. This can reduce the distortion of the pole ears in the image input to the end face detection model, and further improve the accuracy of the end face detection results.
[0044] In some embodiments, the end face detection method of the tab may include the following steps: in response to the absence of a target area in the cropping frame that does not overlap with the image to be detected, cropping the overlapping area in the image to be detected to obtain a partial image.
[0045] In some application scenarios, if the entire area of the cropping frame overlaps with the image to be detected, the image to be detected is directly cropped according to the cropping frame to obtain a partial image.
[0046] That is, the overlapping part between the cropping frame and the image to be detected is cropped as a local image.
[0047] In the above solution, if there is no target area in the cropping frame that does not overlap with the image to be detected, the local image can be directly cropped from the image to be detected.
[0048] In some embodiments, the first preset position is the center point of the region of interest, and the fixed point of the cropping frame is the center point of the cropping frame.
[0049] The first preset position is the center point of the region of interest, and the above step S12 can be to use the first preset position as a fixed point and expand horizontally and vertically. , get the cropping frame. Indicates the input image size. For example, you can refer to Figure 2 , Figure 2 In the figure, P1 is the image to be detected, P2 is the region of interest, and P3 is the cropping frame. The size of the image to be detected is 6451*6922, the size of the region of interest is 4622*2368, and the size of the cropping frame is 5120*5120. It can be 5120.
[0050] In the above solution, by determining the fixed point at the center point of the region of interest, the end face of the tab can be more completely located within the local image.
[0051] In some embodiments, in response to the presence of a target area in the cropping frame that does not overlap with the image to be detected, the target area can be filled by: filling with a preset filling value, or cropping other areas in the image to be detected except the overlapping area according to the size of the target area to obtain a supplementary area, and then filling the target area with the supplementary area.
[0052] Exemplarily, the preset filling value may be an average pixel value of each pixel point in the image to be detected, or a fixed pixel value. The method of cropping other areas in the image to be detected except the overlapping area according to the size of the target area may be to crop other areas in the image to be detected close to the target area, or to randomly select areas for cropping.
[0053] In the above solution, multiple ways of filling the target area are provided, which can improve the flexibility of filling the target area.
[0054] In some embodiments, the method further includes: determining first coordinates of a plurality of first sampling points in the boundary of the image to be detected in a preset coordinate system and second coordinates of a plurality of second sampling points in the boundary of the cropping frame in a preset coordinate system, wherein the preset coordinate system is established with a second preset position in the image to be detected as the origin of the coordinate system. Based on the coordinates of each vertex in the image to be detected and the coordinates of each vertex in the cropping frame, it is determined whether a target area exists in the cropping frame or whether a target area does not exist in the cropping frame.
[0055] The shape of the image to be detected and the cropping box can be rectangular or non-rectangular. Figure 3 , taking the shape of the image to be detected and the cropping frame as a rectangle as an example, the several first sampling points 10 in the boundary of the image to be detected can be vertices in the image to be detected, such as the upper left vertex, the upper right vertex, the lower left vertex and the lower right vertex, and the several second sampling points 20 in the boundary of the cropping frame can be vertices in the cropping frame, such as the upper left vertex, the upper right vertex, the lower left vertex and the lower right vertex. When the image to be detected and the cropping frame are non-rectangular, sampling can be performed on the boundaries of the image to be detected and the cropping frame respectively according to respective preset sampling intervals to obtain several first sampling points and several second sampling points. Optionally, the second preset position in the image to be detected includes but is not limited to one of the vertices in the image to be detected, and can also be other points in the image to be detected. Please continue to refer to Figure 4 In some application scenarios, the upper left vertex of the image to be detected is used as the origin O of the preset coordinate system, and the upper boundary extension direction and the left boundary extension direction of the image to be detected are used as the extension directions of the two axes of the preset coordinate system. If the coordinates of the vertices in the cropping frame are on the negative half axis of the x-axis or the y-axis, it is determined that there is a target detection area in the cropping frame. If the vertices of the cropping frame are all on the positive half axis of the x-axis or the y-axis, it is determined that there is no target area in the cropping frame.
[0056] In the above solution, by establishing a preset coordinate system according to the image to be detected, the process of determining the non-overlapping area between the zoomed image and the image to be detected is made more convenient.
[0057] In some embodiments, the image to be detected is obtained by scaling the initial image, and the initial image contains the initial region of interest of the tab. Figure 4 , step S11 may also include the following steps: step S111: determining the scaling ratio of the initial image according to the size of the initial region of interest in the initial image, the input image size and the preset maximum scaling ratio. step S112: scaling the initial image according to the scaling ratio to obtain the image to be detected.
[0058] Among them, the initial region of interest in the initial image is the region of interest in the image to be detected after scaling. If the size of the initial image is different from that of the image to be detected, the size of the initial region of interest in the initial image is different from that of the region of interest in the image to be detected. The region of interest in the image to be detected and the initial region of interest in the initial image are regions of interest about the same pole ear. The image to be detected can be obtained by reducing the size of the initial image, or it can also be obtained by enlarging the size of the initial image. In some application scenarios, if the area occupied by the pole ear in the initial image is large, directly obtaining a partial image from the initial image may cause the partial image to be unable to contain the complete pole ear, so the initial image can be first reduced to obtain the image to be detected and then the partial image can be obtained from the image to be detected. In some application scenarios, if the area occupied by the pole ear in the initial image is small and the background noise is large, the initial image can be enlarged to obtain the image to be detected and then the partial image can be obtained from the image to be detected. According to the size of the initial region of interest in the initial image, the size of the input image and the preset maximum scaling ratio, the scaling ratio of the initial image can be determined by first determining one or more candidate ratios based on the ratio between the size of the region of interest and the size of the input image, and then selecting a ratio between each candidate ratio and the preset maximum scaling ratio as the scaling ratio of the initial image.
[0059] In the above scheme, by first determining the scaling ratio of the initial image according to the size of the initial region of interest, the input image size and the preset maximum scaling ratio and scaling the initial image, compared to obtaining a local image from the initial image, scaling the initial image and then cropping it can adjust the proportion of the region of interest in the cropping frame, thereby facilitating subsequent end face detection.
[0060] In some embodiments, the size of the initial region of interest in the initial image includes height and width. The implementation of the above step S111 may be: obtaining a first ratio between the input image size and the height, and a second ratio between the input image size and the width. Then, selecting one from the first ratio, the second ratio, and the preset maximum scaling ratio as the scaling ratio of the initial image.
[0061] The method of selecting one from the first ratio, the second ratio and the preset maximum zoom ratio may be to select the largest one, the smallest one or the middle one, or to select one randomly. In some application scenarios, the smallest one is selected from the first ratio, the second ratio and the preset maximum zoom ratio as an example.
[0062] In the above solution, at least one available scaling ratio is first determined according to multiple methods, and then one of the multiple scaling ratios is selected as the scaling ratio of the initial image, so that the selection of the scaling ratio is more diverse.
[0063] In some embodiments, see Figure 5 The method further comprises the following steps: Step S21: Processing the initial image using a semantic segmentation network to obtain a mask map of the initial image about the pole ear. Step S22: Extracting a connected domain from the mask map to obtain the position of the initial region of interest in the mask map. Step S23: Determining the position of the initial region of interest in the initial image based on the position of the initial region of interest in the mask map.
[0064] The semantic segmentation network can be a lightweight network of a small backbone network, which can achieve more accurate determination of the region of interest. In some application scenarios, the initial image is input into the semantic segmentation network to obtain a binary mask map, and the maximum circumscribed rectangle is found for the connected domain in the binary mask map to obtain the region of interest. In some application scenarios, the maximum circumscribed rectangle can also be enlarged by a certain proportion as the region of interest. Among them, the size of the initial image and the size of the mask map can be the same, then the position of the region of interest in the mask map is the same as the position of the region of interest in the initial image. After obtaining the position of the initial region of interest in the initial image, the size of the initial region of interest can be determined based on the position information of the initial region of interest. For example, the difference between the maximum and minimum values of the horizontal coordinates of each pixel in the initial region of interest is used as the width of the initial region of interest, and the difference between the maximum and minimum values of the vertical coordinates of each pixel is used as the height of the initial region of interest.
[0065] In the above scheme, semantic segmentation is a fine-grained computer vision task. Classifying each pixel will obtain a more accurate region of interest.
[0066] In some embodiments, the end face detection result includes the position of the defect in the initial region of interest. The above step S14 may include the following steps: inputting the local image into the end face detection model to obtain the position of the defect in the local image. Then, based on the position of the defect in the local image, the position of the region of interest in the local image, and the scaling ratio, the position of the defect in the initial region of interest is determined.
[0067] Exemplarily, the position of the defect in the local image can be subtracted from the position of the region of interest in the local image to obtain the position of the defect in the region of interest. Optionally, the position of the defect in the region of interest in the image to be detected can be converted to the position of the defect in the initial image according to the inverse operation of the scaling method from the initial image to the image to be detected. In some other embodiments, the end face detection result may also include parameters such as the area size of the defect.
[0068] In the above solution, by converting the position of the defect in the local image into the position of the defect in the region of interest, it is convenient to perform post-processing according to the position of the defect in the region of interest.
[0069] In some embodiments, see Figure 6 , the method of determining the position of the region of interest in the local image may include the following steps: Step S31: Based on the position of the initial region of interest in the initial image and the scaling ratio, determine the position of the region of interest in the image to be detected. Step S32: In response to the existence of a target region in the cropping frame that does not overlap with the image to be detected, determine the position of the region of interest in the local image based on the relative position relationship between the target region and the region of interest.
[0070] Based on the position of the initial region of interest in the initial image and the scaling ratio, the position of the region of interest in the image to be detected can be determined by multiplying the width and height of the initial region of interest by the scaling ratio to obtain the size of the region of interest, and then using the relative position relationship between the initial region of interest in the initial image and the boundary or center point of the initial image as the relative position relationship between the region of interest and the boundary or center point of the image to be detected, thereby obtaining the position of the region of interest in the image to be detected. Based on the relative position relationship between the target region and the region of interest, the position of the region of interest in the local image can be determined by establishing a coordinate system with a point in the local image as the origin, and then determining the position of the region of interest in the local image based on the respective sizes of the target region and the region of interest and the relative position relationship between the target region and the region of interest. For example, please continue to refer to Figure 2 and Figure 3 , the upper left vertex of the local image can be used as the origin of the coordinate system corresponding to the local image, the extension direction of the upper boundary can be used as the extension direction of the X axis, and the extension direction of the left boundary can be used as the extension direction of the Y axis. If the coordinate of the upper left vertex of the target area in the preset coordinate system of the image to be detected is (-249, 1249), and the upper left vertex of the target area is exactly the origin of the coordinate system of the local image, then the difference between the horizontal coordinate of each pixel point in the region of interest in the preset coordinate system of the image to be detected and the horizontal coordinate of the upper left vertex of the target area in the preset coordinate system is used as the horizontal coordinate of each pixel point in the region of interest in the local image coordinate system, and the difference between the vertical coordinate of each pixel point in the region of interest in the preset coordinate system of the image to be detected and the vertical coordinate of the upper left vertex of the target area in the preset coordinate system is used as the vertical coordinate of each pixel point in the region of interest in the local image coordinate system.
[0071] In the above scheme, the target area is located on the side of the region of interest close to the origin of the local image, or the target area is located on the side of the region of interest far from the origin of the local image. The coordinates of the region of interest in the local image will be different. Therefore, by considering the relative position relationship between the target area and the region of interest, the position of the region of interest in the local image can be determined more accurately.
[0072] In some embodiments, based on the position of the defect in the local image, the position of the region of interest in the local image, and the scaling ratio, the position of the defect in the initial region of interest is determined, including: taking the difference between the horizontal coordinate of the defect in the local image and the horizontal coordinate of the region of interest in the local image as the horizontal coordinate of the defect in the region of interest; and taking the difference between the vertical coordinate of the defect in the local image and the vertical coordinate of the region of interest in the local image as the vertical coordinate of the defect in the region of interest; based on the scaling ratio, inversely transforming the horizontal coordinate and the vertical coordinate of the defect in the region of interest to obtain the horizontal coordinate and vertical coordinate of the defect in the initial region of interest.
[0073] The horizontal coordinate of the region of interest in the local image can be specifically the horizontal coordinate of the upper left vertex or center point of the region of interest in the coordinate system of the local image, and the vertical coordinate of the region of interest in the local image can be specifically the vertical coordinate of the upper left vertex or center point of the region of interest in the coordinate system of the local image. The horizontal coordinate of the defect in the local image can be considered as the coordinate of the upper left vertex or center point of the defect circumscribed rectangular box. Because the region of interest is obtained by scaling the initial region of interest according to the scaling ratio, the horizontal coordinate and vertical coordinate of the defect in the initial region of interest can be obtained by inverse transformation.
[0074] In the above scheme, the position of the defect in the local image is first converted to the position in the region of interest, and then the position of the defect in the initial region of interest is determined by the inverse transformation of the scaling process.
[0075] In some application scenarios, the initial image is input into the semantic segmentation network to obtain a binary mask map, and then the connected domain is extracted from the mask map to obtain the position of the initial region of interest in the mask map. Based on the position of the initial region of interest in the mask map, the position of the initial region of interest in the initial image is determined. The initial image is then scaled according to the scaling ratio of the initial image to obtain the image to be detected. Specifically, after obtaining a first ratio between the input image size and the height and a second ratio between the input image size and the width, the smallest one is selected from the first ratio, the second ratio, and the preset maximum scaling ratio as an example.
[0076] After obtaining the image to be detected, the center point of the area of interest in the image to be detected is used as the fixed point, and it is expanded horizontally and vertically to keep the center of the key area unchanged before and after scaling, and a cropping frame is obtained. Based on the cropping frame, a local image is obtained, which is used as the input of the end face detection model.
[0077] In response to the absence of a target area that does not overlap with the image to be detected in the cropping frame, the overlapping area in the image to be detected is cropped to obtain a partial image. Or, in response to the presence of a target area that does not overlap with the image to be detected in the cropping frame, the target area is filled; the overlapping area in the image to be detected is cropped, and the cropped overlapping area is spliced with the filled target area to obtain a partial image.
[0078] After obtaining the local image, the local image is input into the end face inspection model to obtain the position of the defect in the local image. Then, based on the position of the defect in the local image, the position of the region of interest in the local image, and the scaling ratio, the position of the defect in the initial region of interest is determined.
[0079] The position of the defect in the local image in the end face inspection result can be presented by the position of the detection frame. The position of the defect in the region of interest in the local image can be determined by the following method: establish a coordinate system for the region of interest, and the position of the defect in the region of interest can be considered as the position in the coordinate system corresponding to the region of interest. Post-processing in this coordinate system can be filtered by more information (such as the ratio of the horizontal and vertical coordinates of the frame in the region of interest). The coordinates of the final end face inspection result can be transformed to the initial image for display, and the above process can be reversed.
[0080] In the above schemes, the target detection scheme can alleviate the high dependence of defect detection in the industrial field on consistent imaging. It solves the problem of large image differences caused by different product models and hardware selection. Pre-identification of key areas removes background interference factors and greatly reduces the difficulty of detection. The industrial process using the end face detection model is suitable for most detection scenarios without the need for specific optimization for each scenario, which greatly enhances the detection stability and is of great significance to the general development of the algorithm. Coordinate transformation is performed after the end face detection results, so that the detection process can provide coordinates and other information for scenarios that need to actively adjust the strictness of products of different specifications.
[0081] See also Figure 7The air pressure detection device 30 provided in the present application includes an image acquisition module 31, a cropping frame determination module 32, a local image acquisition module 33 and a target detection module 34; the image acquisition module 31 is used to acquire the image to be detected, which contains the region of interest corresponding to the pole ear; the cropping frame determination module 32 is used to determine the cropping frame by taking the first preset position in the region of interest as the fixed point of the cropping frame and the input image size allowed by the end face detection model as the size of the cropping frame; the local image acquisition module 33 is used to fill the target area in response to the existence of a target area in the cropping frame that does not overlap with the image to be detected; the overlapping area in the image to be detected is cropped, and the cropped overlapping area is spliced with the filled target area to obtain a local image, and the overlapping area is the overlapping area between the cropping frame and the image to be detected; the target detection module 34 is used to input the local image into the end face detection model to obtain the end face detection result of the pole ear.
[0082] In the above scheme, the cropping frame is determined by first taking the first preset position in the region of interest contained in the image to be detected as the fixed point of the cropping frame and the input image size allowed by the end face detection model as the size of the cropping frame. If the region of interest is at the edge of the image to be detected, it may cause the cropping frame to be at least partially outside the image to be detected. Therefore, this part of the area is filled to maintain the size of the local image. Compared with directly using the overlapping area as the input of the end face detection model or scaling the overlapping area to the input image size as the input of the end face detection model, this scheme ensures the size of the scaled image by filling the area in the cropping frame that does not overlap with the image to be detected, thereby reducing the distortion of the pole ear before and after scaling, and thus making the end face detection result more accurate.
[0083] In some embodiments, the local image acquisition module 33 is further used to perform the following steps: in response to the absence of a target area in the cropping frame that does not overlap with the image to be detected, cropping the overlapping area in the image to be detected to obtain a local image.
[0084] In the above solution, if there is no target area in the cropping frame that does not overlap with the image to be detected, the local image can be directly cropped from the image to be detected.
[0085] In some embodiments, the first preset position is the center point of the region of interest, and the fixed point of the cropping frame is the center point of the cropping frame.
[0086] In the above solution, by determining the fixed point at the center point of the region of interest, the end face of the tab can be more completely located within the local image.
[0087] In some embodiments, the local image acquisition module 33 fills the target area in response to the presence of a target area in the cropping frame that does not overlap with the image to be detected, including: filling the target area with a preset filling value; or, cropping other areas in the image to be detected except the overlapping area according to the size of the target area to obtain a supplementary area, and filling the target area with the supplementary area.
[0088] In the above solution, multiple ways of filling the target area are provided, which can improve the flexibility of filling the target area.
[0089] In some embodiments, the local image acquisition 33 is also used to: determine the first coordinates of several first sampling points in the boundary of the image to be detected in a preset coordinate system and the second coordinates of several second sampling points in the boundary of the cropping frame in the preset coordinate system, the preset coordinate system is established with the second preset position in the image to be detected as the origin of the coordinate system; based on each first coordinate and each second coordinate, determine whether the target area exists in the cropping frame or whether the target area does not exist in the cropping frame.
[0090] In the above solution, by establishing a preset coordinate system according to the image to be detected, the process of determining the non-overlapping area between the zoomed image and the image to be detected is made more convenient.
[0091] In some embodiments, the image to be detected is obtained by scaling the initial image, and the initial image includes an initial region of interest of the pole ear. The image acquisition module 31 is used to: determine the scaling ratio of the initial image according to the size of the initial region of interest in the initial image, the input image size, and a preset maximum scaling ratio; scale the initial image according to the scaling ratio to obtain the image to be detected, wherein the initial region of interest in the initial image becomes the region of interest in the image to be detected after scaling.
[0092] In the above scheme, by first determining the scaling ratio of the initial image according to the size of the initial region of interest, the input image size and the preset maximum scaling ratio and scaling the initial image, compared to obtaining a local image from the initial image, scaling the initial image and then cropping it can adjust the proportion of the region of interest in the cropping frame, thereby facilitating subsequent end face detection.
[0093] In some embodiments, the size of the initial region of interest in the initial image includes height and width, and the image acquisition module 31 determines the scaling ratio of the initial image according to the size of the initial region of interest in the initial image, the input image size, and a preset maximum scaling ratio, including: acquiring a first ratio between the input image size and the height, and a second ratio between the input image size and the width; selecting one from the first ratio, the second ratio, and the preset maximum scaling ratio as the scaling ratio of the initial image.
[0094] In the above solution, at least one available scaling ratio is first determined according to multiple methods, and then one of the multiple scaling ratios is selected as the scaling ratio of the initial image, so that the selection of the scaling ratio is more diverse.
[0095] In some embodiments, the image acquisition module 31 is also used to: process the initial image using a semantic segmentation network to obtain a mask map of the initial image about the ear; extract connected domains from the mask map to obtain the position of the initial region of interest in the mask map; and determine the position of the initial region of interest in the initial image based on the position of the initial region of interest in the mask map.
[0096] In the above scheme, semantic segmentation is a fine-grained computer vision task. Classifying each pixel will obtain a more accurate region of interest.
[0097] In some embodiments, the end face detection result includes the position of the defect in the initial region of interest. The target detection module 34 inputs the local image into the end face detection model to obtain the end face detection result about the pole ear, including: inputting the local image into the end face detection model to obtain the position of the defect in the local image; based on the position of the defect in the local image, the position of the region of interest in the local image and the scaling ratio, determining the position of the defect in the initial region of interest.
[0098] In the above solution, by converting the position of the defect in the local image into the position of the defect in the region of interest, it is convenient to perform post-processing according to the position of the defect in the region of interest.
[0099] In some embodiments, the target detection module 34 is also used to: determine the position of the region of interest in the image to be detected based on the position of the initial region of interest in the initial image and the scaling ratio; in response to the presence of a target region in the cropping frame that does not overlap with the image to be detected, determine the position of the region of interest in the local image based on the relative position relationship between the target region and the region of interest.
[0100] In the above scheme, the target area is located on the side of the region of interest close to the origin of the local image, or the target area is located on the side of the region of interest far from the origin of the local image. The coordinates of the region of interest in the local image will be different. Therefore, by considering the relative position relationship between the target area and the region of interest, the position of the region of interest in the local image can be determined more accurately.
[0101] In some embodiments, the target detection module 34 determines the position of the defect in the initial region of interest based on the position of the defect in the local image, the position of the region of interest in the local image, and the scaling ratio, including: taking the difference between the horizontal coordinate of the defect in the local image and the horizontal coordinate of the region of interest in the local image as the horizontal coordinate of the defect in the region of interest; and taking the difference between the vertical coordinate of the defect in the local image and the vertical coordinate of the region of interest in the local image as the vertical coordinate of the defect in the region of interest; based on the scaling ratio, inversely transforming the horizontal coordinate and the vertical coordinate of the defect in the region of interest to obtain the horizontal coordinate and vertical coordinate of the defect in the initial region of interest.
[0102] In the above scheme, the position of the defect in the local image is first converted to the position in the region of interest, and then the position of the defect in the initial region of interest is determined by the inverse transformation of the scaling process.
[0103] See also Figure 8 , Figure 8 The electronic device 40 includes a memory 41 and a processor 42 coupled to each other, and the processor 42 is used to execute program instructions stored in the memory 41 to implement the steps in any of the above-mentioned embodiments of the end face detection method of the tab.
[0104] Specifically, the processor 42 is used to control itself and the memory 41 to implement the steps of any of the above-mentioned embodiments of the end face detection method of the pole ear, or to implement the steps of any of the above-mentioned embodiments of the end face detection method of the pole ear. The processor 42 can also be called a CPU (Central Processing Unit). The processor 42 may be an integrated circuit chip with signal processing capabilities. The processor 42 can also be a general-purpose 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 general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. In addition, the processor 42 can be implemented by an integrated circuit chip.
[0105] See also Fig. 9 , Fig. 9The computer-readable storage medium 50 stores program instructions 51 that can be executed by a processor, and the program instructions 51 are used to implement the steps in any of the above-mentioned embodiments of the end face detection method of the tab.
[0106] In some embodiments, the functions or modules included in the device provided by the embodiments of the present disclosure can be used to execute the method described in the above method embodiments. The specific implementation can refer to the description of the above method embodiments, and for the sake of brevity, it will not be repeated here.
[0107] The above description of various embodiments tends to emphasize the differences between the various embodiments. The same or similar aspects can be referenced to each other, and for the sake of brevity, they will not be repeated herein.
[0108] In the several embodiments provided in the present application, it should be understood that the disclosed methods and devices can be implemented in other ways. For example, the device implementation described above is only schematic. For example, the division of modules or units is only a logical function division. There may be other division methods in actual implementation, such as 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, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.
[0109] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0110] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) or a processor to execute all or part of the steps of each implementation method of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program code.
Claims
1. A method for detecting the end face of a tab, characterized in that: include: Acquire an image to be detected, wherein the image to be detected includes a region of interest corresponding to the tab; Determine the cropping frame by taking a first preset position in the region of interest as a fixed point of the cropping frame and an input image size allowed by the end face detection model as a size of the cropping frame; In response to the existence of a target area in the cropping frame that does not overlap with the image to be detected, filling the target area; Cropping the overlapping area in the image to be detected, and splicing the cropped overlapping area with the filled target area to obtain a local image, wherein the overlapping area is the overlapping area between the cropping frame and the image to be detected; The local image is input into the end face detection model to obtain an end face detection result of the tab.
2. The method for detecting the end face of a tab according to claim 1, characterized in that: The end face detection method of the tab also includes: In response to the absence of a target area in the cropping frame that does not overlap with the image to be detected, the overlapping area in the image to be detected is cropped to obtain the partial image.
3. The method for detecting the end face of a tab according to claim 1, characterized in that: The first preset position is the center point of the region of interest, and the fixed point of the cropping frame is the center point of the cropping frame.
4. The method for detecting the end face of a tab according to claim 3, characterized in that: In response to the existence of a target area in the cropping frame that does not overlap with the image to be detected, filling the target area includes: Fill the target area with a preset filling value; or, The other regions in the image to be detected except the overlapping region are cropped according to the size of the target region to obtain a supplementary region, and the target region is filled with the supplementary region.
5. The method for detecting the end face of a tab according to any one of claims 2 to 4, characterized in that: The method further comprises: Determine first coordinates of a plurality of first sampling points in the boundary of the image to be detected in a preset coordinate system and second coordinates of a plurality of second sampling points in the boundary of the cropping frame in the preset coordinate system, wherein the preset coordinate system is established with a second preset position in the image to be detected as the origin of the coordinate system; Based on each of the first coordinates and each of the second coordinates, it is determined whether the target area exists in the cropping frame or whether the target area does not exist in the cropping frame.
6. The method for detecting the end face of a tab according to any one of claims 1 to 4, characterized in that: The image to be detected is obtained by scaling the initial image, wherein the initial image contains an initial region of interest corresponding to the tab, and obtaining the image to be detected includes: Determining a scaling ratio of the initial image according to a size of the initial region of interest in the initial image, a size of the input image, and a preset maximum scaling ratio; The initial image is scaled according to the scaling ratio to obtain the image to be detected, wherein the initial region of interest in the initial image becomes the region of interest in the image to be detected after the scaling process.
7. The method for detecting the end face of a tab according to claim 6, characterized in that: The size of the initial region of interest in the initial image includes a height and a width, and determining the scaling ratio of the initial image according to the size of the initial region of interest in the initial image, the input image size, and a preset maximum scaling ratio includes: Acquire a first ratio between the input image size and the height, and a second ratio between the input image size and the width; Select one from the first ratio, the second ratio and the preset maximum scaling ratio as the scaling ratio of the initial image.
8. The method for detecting the end face of a tab according to claim 6, characterized in that: The method further comprises: Processing the initial image using a semantic segmentation network to obtain a mask image of the initial image with respect to the tab; Performing connected domain extraction on the mask map to obtain the position of the initial region of interest in the mask map; Based on the position of the initial region of interest in the mask image, the position of the initial region of interest in the initial image is determined.
9. The method for detecting the end face of a tab according to claim 6, characterized in that: The end face detection result includes the position of the defect in the initial region of interest, and the inputting of the local image into the end face detection model to obtain the end face detection result about the tab includes: Inputting the local image into the end face detection model to obtain the position of the defect in the local image; The position of the defect in the initial region of interest is determined based on the position of the defect in the partial image, the position of the region of interest in the partial image, and the scaling ratio.
10. The method for detecting the end face of a tab according to claim 9, characterized in that: The method further comprises: Determining the position of the region of interest in the image to be detected based on the position of the initial region of interest in the initial image and the scaling ratio; In response to the existence of a target area in the cropping frame that does not overlap with the image to be detected, a position of the region of interest in the partial image is determined based on a relative positional relationship between the target area and the region of interest.
11. The method for detecting the end face of a tab according to claim 9, characterized in that: The determining the position of the defect in the initial region of interest based on the position of the defect in the partial image, the position of the region of interest in the partial image, and the scaling ratio comprises: Taking the difference between the abscissa of the defect in the partial image and the abscissa of the region of interest in the partial image as the abscissa of the defect in the region of interest; and Taking the difference between the ordinate of the defect in the partial image and the ordinate of the region of interest in the partial image as the ordinate of the defect in the region of interest; Based on the scaling ratio, the abscissa and the ordinate of the defect in the region of interest are inversely transformed to obtain the abscissa and the ordinate of the defect in the initial region of interest.
12. A terminal lug end face detection device, characterized in that: include: An image acquisition module, used for acquiring an image to be detected, wherein the image to be detected includes a region of interest corresponding to the tab; A cropping frame determination module, configured to determine the cropping frame by taking a first preset position in the region of interest as a fixed point in the cropping frame and an input image size allowed by an end face detection model as a size of the cropping frame; Partial image acquisition, for filling the target area in response to the existence of a target area in the cropping frame that does not overlap with the image to be detected; Cropping the overlapping area in the image to be detected, and splicing the cropped overlapping area with the filled target area to obtain a local image, wherein the overlapping area is the overlapping area between the cropping frame and the image to be detected; The target detection module is used to input the local image into the end face detection model to obtain the end face detection result of the tab.
13. An electronic device, characterized in that: It comprises a memory and a processor coupled to each other, wherein the processor is used to execute program instructions stored in the memory to implement the end face detection method of the pole lug according to any one of claims 1 to 11.
14. A computer-readable storage medium having program instructions stored thereon, characterized in that: When the program instructions are executed by a processor, the end face detection method of a tab according to any one of claims 1 to 11 is implemented.
Citation Information
Patent Citations
Defect detection method, device and equipment for battery pole piece and storage medium
CN115205247A
Blood vessel key point position determination method and device, computer equipment and storage medium
CN116030071A
Image processing method and device and moving tool
CN117765230A
Information processing apparatus, information processing method, and storage medium
US20230419633A1
Method for machine-learning based training and segmentation of overlapping objects
WO2023283411A2
