Slender target detection method and detection device
By extracting and stitching the feature information of the target image in different preset directions and inputting it into the target detection network, the problem of difficulty in detecting elongated defects in the prior art is solved, and higher detection accuracy is achieved.
Patent Information
- Application Number
- CN202411601876.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-11
- Publication Date
- 2025-03-28
- Estimated Expiration
- 2044-11-11
AI Technical Summary
The prior art is difficult to accurately detect elongated defects, especially when the aspect ratio difference in images is large and the characteristics are not significant.
By extracting the characteristic information of the target image to be detected in different preset directions and splicing it into the target feature information, the target detection network is input to output the type and position information of the elongated target.
This method can deeply extract feature information of the target image to be detected, avoid omissions, improve detection accuracy, and solve the problem that traditional methods are difficult to capture and deal with feature problems.
Smart Images

Figure CN119722575A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of artificial intelligence technology, and in particular relates to a detection method and a detection device for a slender target. Background Art
[0002] Defect detection is crucial in industrial production. It allows for the early detection and removal of substandard products, ensuring that final product performance meets expected standards. Furthermore, high-quality products identified through defect detection enhance customer trust and satisfaction, thereby strengthening brand image. Furthermore, timely detection and removal of defective products significantly reduces scrap rates and material waste. Furthermore, early defect detection avoids subsequent rework and repairs, saving significant time and money. Therefore, defect detection remains a core concern for businesses.
[0003] Early defect detection relied mainly on manual inspection, but manual inspection is slow and cannot meet the high-speed requirements of large-scale production. Different inspectors may have different judgment criteria, resulting in inconsistent inspection results. In addition, long periods of repetitive work can easily cause fatigue, increasing the risk of missed detections. Obviously, this method is not only inefficient, but also easily affected by human factors, resulting in missed detections and false detections. With the development of the manufacturing industry, the requirements for product quality are getting higher and higher, and traditional manual inspection methods can no longer meet the needs of modern production. For this reason, simple machines are gradually used in the existing technology for defect detection, such as optical comparators, ultrasonic detectors, and X-ray detectors. Although traditional mechanical detection equipment can improve efficiency to some extent, its detection accuracy and flexibility are still limited. Moreover, these devices are often only able to detect specific types of defects and have difficulty identifying complex or subtle defects.
[0004] To overcome these limitations, existing technologies have emerged that utilize machine vision for defect detection. The specific inspection process involves: capturing images of the object being inspected using industrial cameras; performing image processing such as denoising and enhancement; extracting key features from the image; detecting defects using template matching and machine learning; and classifying and marking detected defects within the image. Defect detection methods have also emerged based on deep learning technologies, particularly convolutional neural networks, which can automatically learn and identify various types of defects based on large amounts of data. Furthermore, the application of techniques such as transfer learning and reinforcement learning has made model training more efficient and detection results more stable.
[0005] However, slender targets often appear in industrial inspections, and the information ratio of slender targets in the vertical and horizontal directions is extremely unbalanced. Currently, traditional machine vision methods usually rely on manually designed features, such as edges, contours, and textures. For slender targets, because their edges are very subtle, their contours may not be obvious or complete, and their texture information is very limited, the features of slender targets may not be significant enough or difficult to capture. The aspect ratios of slender targets in images vary greatly, which makes it difficult for traditional geometric feature-based methods (i.e., assuming that the target has a standard structure or shape) to process them effectively. For example, although the Hough transform can be used to detect straight lines, it is not effective for detecting curved or irregular slender targets.
[0006] Although deep learning models can detect targets with complex shapes, slender targets (such as wires, pipes, blood vessels, etc.) usually have complex shapes and structures. These targets may appear in the image in various postures, such as bent, twisted, or partially occluded. In order for the model to accurately recognize these complex and changeable shapes, a large amount of labeled data is required to cover as many changes as possible. However, the frequency of occurrence of slender targets in images may be low, that is, the data set of slender targets is small, which will lead to an imbalance of positive and negative samples in the data set, affecting the prediction accuracy of the model. In addition, the data set of slender targets is small, which can easily lead to overfitting of the model, that is, it performs well on the training data but poorly on new data, so that when the model is applied to real-world scenarios, it is impossible to accurately predict slender targets. Therefore, various defect detection schemes in the existing technology cannot achieve accurate detection of slender defects.
[0007] In summary, there is an urgent need in the prior art for a detection solution that can accurately detect slender defects. Summary of the Invention
[0008] The present invention provides a method and a device for detecting a slender target, which are used to solve the problem that defect detection solutions in the prior art cannot accurately detect slender defects.
[0009] In order to solve the above technical problems, in a first aspect, the present invention provides a method for detecting a slender target, comprising:
[0010] Acquire the target image to be detected;
[0011] respectively extracting first feature information of the target image to be detected in different preset directions;
[0012] splicing the first feature information to obtain target feature information;
[0013] The target feature information is input into a target detection network, and the type and position information of the elongated target in the target image to be detected is output.
[0014] Optionally, respectively extracting first feature information of the target image to be detected in different preset directions includes:
[0015] Splitting the target convolutional layer into one-dimensional convolutional layers, wherein the number of the one-dimensional convolutional layers is the same as the dimension of the target convolutional layer;
[0016] The target image to be detected is input into each of the one-dimensional convolutional layers respectively, and the first feature information of the target image to be detected in different preset directions is extracted.
[0017] Optionally, the combining of the first feature information to obtain target feature information includes:
[0018] Inputting the target image to be detected into the target convolution layer, and extracting second feature information of the target image to be detected, wherein the number of channels of the target image to be detected input into the target convolution layer is greater than the number of the target convolution layers;
[0019] The second feature information and the first feature information are concatenated to obtain target feature information.
[0020] Optionally, inputting the target image to be detected into each of the one-dimensional convolutional layers respectively, and extracting first feature information of the target image to be detected in different preset directions, includes:
[0021] Inputting the target image to be detected into a backbone feature extraction network in a target detection model, and outputting third feature information;
[0022] The third feature information is input into each of the one-dimensional convolutional layers in the neck feature extraction network in the target detection model, and the first feature information in different preset directions is output.
[0023] Optionally, the combining of the first feature information to obtain target feature information includes:
[0024] Extracting original feature information of the target image to be detected;
[0025] The first feature information and the original feature information are concatenated to obtain target feature information.
[0026] Optionally, before acquiring the target image to be detected, the method further includes:
[0027] Acquire an image to be detected, and divide the image to be detected into different connected domains according to pixel values of the image to be detected, wherein each connected domain corresponds to a unique pixel threshold segment;
[0028] For a target pixel threshold segment, select a pixel value at a preset position in the target pixel threshold segment as a target pixel value, and unify pixel values in a target connected domain corresponding to the target pixel threshold segment as the target pixel value, to obtain a first image to be detected;
[0029] Acquiring contour information in the first image to be detected;
[0030] Obtaining a slender target in the first image to be detected according to the contour information;
[0031] The slender target is displayed in the first image to be detected to generate the target image to be detected.
[0032] Optionally, dividing the image to be detected into different connected domains according to pixel values of the image to be detected includes:
[0033] Dividing the pixel values of the image to be detected into different pixel threshold segments;
[0034] Extracting pixel thresholds at the ends of each pixel threshold segment to form initial population individuals in the genetic algorithm;
[0035] Performing multiple crossovers and mutations on the individuals of the initial population to obtain individuals of a new population;
[0036] Inputting each of the new population individuals and the initial population individuals into a preset global fitness function to obtain fitness values of the new population individuals and the initial population individuals;
[0037] The population with the maximum fitness value is taken as the target population;
[0038] A pixel threshold corresponding to each individual in the target population is determined, and the image to be detected is divided into different connected domains according to the pixel threshold.
[0039] Optionally, the global fitness function is:
[0040] σ 2 (t) = p i1 (T)*(μ i1 (T) - μ t ) 2 +p i0 (T)*(μ i0 (T) - μ t ) 2 ;
[0041] Among them, σ 2 (T) is the fitness value of the individual in the population, p i1 (T) is the ratio of the foreground pixels of the individual population to the global value, μ i1(T) is the mean foreground pixel value of each individual in the population, μ t is the global pixel mean of the population, p i0 (T) is the ratio of the background pixels of the individuals in the population to the global value, μ i0 (T) is the background pixel mean of each individual in the population, and T is the pixel threshold corresponding to the individual in the population.
[0042] Optionally, obtaining the slender target in the first image to be detected according to the contour information includes:
[0043] Obtaining the size information of slender targets;
[0044] Filtering the target contour corresponding to the elongated target from the contour information according to the size information;
[0045] According to the convex hull algorithm, solving the convex hull contour corresponding to the target contour;
[0046] The convex hull contour is used as the contour of the slender object to obtain the slender object in the first image to be detected.
[0047] In a second aspect, the present invention provides a device for detecting an elongated target, comprising:
[0048] An acquisition module is used to acquire the target image to be detected;
[0049] An extraction module, configured to respectively extract first feature information of the target image to be detected in different preset directions;
[0050] a splicing module, configured to splice the first feature information to obtain target feature information;
[0051] The output module is used to input the target feature information into the target detection network and output the type and position information of the slender target in the target image to be detected.
[0052] Compared with the prior art, the method for detecting slender targets provided by the present invention has the following beneficial effects:
[0053] When extracting the feature information of the target image to be detected, the solution of the present invention will extract the first feature information of the target image to be detected in different preset directions. In this way, the feature information of the target image to be detected in different preset directions can be deeply extracted, and the feature information of the target image to be detected in a certain direction will not be missed. In this way, compared with the prior art, the solution of the present invention avoids the problem that the features of slender targets are difficult to capture and effectively process using traditional machine vision methods; and compared with the deep learning model in the prior art, the solution of the present invention accurately extracts the feature information of the target image to be detected in different preset directions, thereby enabling the target detection network to accurately predict the slender target based on the accurate feature information, thereby avoiding the problem in the prior art that the slender target cannot be accurately predicted due to insufficient training data when the deep learning model is used to detect the slender target. In summary, the solution of the present invention solves the problem that the various detection schemes for slender defects in the prior art cannot accurately detect slender defects. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only part of the embodiments of the present invention, rather than all the embodiments. For ordinary technicians in this field, without paying any creative work, other drawings obtained based on these drawings all fall within the scope of protection of the present invention.
[0055] Figure 1 This is a flow chart of a method for detecting a slender target provided by an embodiment of the present invention.
[0056] Figure 2 This is a flow chart of another method for detecting an elongated target provided by an embodiment of the present invention.
[0057] Figure 3 It is a structural diagram of a neural network structure provided by an embodiment of the present invention.
[0058] Figure 4 It is a structural diagram of another neural network structure provided by an embodiment of the present invention.
[0059] Figure 5 This is a structural diagram of another neural network structure provided by an embodiment of the present invention.
[0060] Figure 6 This is a flowchart of another method for detecting slender targets provided by an embodiment of the present invention.
[0061] Figure 7This is an mAP50 image of a YOLOv8 model provided by an embodiment of the present invention.
[0062] Figure 8 is an mAP50 image of an improved model provided by an embodiment of the present invention.
[0063] Figure 9 This is a YOLOv8 confusion matrix diagram provided by an embodiment of the present invention.
[0064] Figure 10 This is a confusion matrix diagram of an improved model provided by an embodiment of the present invention.
[0065] Figure 11 It is a schematic diagram of the test results of an improved model provided by an embodiment of the present invention.
[0066] Figure 12 This is an identification diagram of a slender target workpiece provided by an embodiment of the present invention.
[0067] Figure 13 It is a structural schematic diagram of a detection device for a slender target provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0068] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0069] In order to make the description of the present disclosure more detailed and complete, the following is an illustrative description of the implementation methods and specific examples of the present invention; however, this is not the only form of implementing or using the specific embodiments of the present invention. The implementation methods cover the features of multiple specific embodiments and the method steps and their sequence for constructing and operating these specific embodiments. However, other specific embodiments can also be used to achieve the same or equivalent functions and step sequences. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0070] It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and the accompanying drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or precedence. It should be understood that the terms used in this manner are interchangeable where appropriate, such that the embodiments of the present invention described herein can be practiced in an order other than that illustrated or described herein.
[0071] In addition, in the description of the embodiments of the present invention, "multiple" refers to two or more than two, and other quantifiers should be understood similarly. The preferred embodiments described herein are only used to illustrate and explain the present invention, and are not used to limit the present invention. In addition, the embodiments of the present invention and the features in the embodiments may be combined with each other if there is no conflict.
[0072] like Figure 1 Shown is a flow chart of a method for detecting a slender target provided by the present invention, which includes the following steps.
[0073] Step S110: Acquire the target image to be detected.
[0074] It should be noted that the target image to be detected obtained in this step is an image containing the slender target to be detected. The target image to be detected can be obtained in any feasible manner, for example, by photographing or filming the slender target with an industrial camera to obtain the target image to be detected.
[0075] Step S120 , extracting first feature information of the target image to be detected in different preset directions respectively.
[0076] It should be noted that in this step, the different preset directions can be any preset directions and can be set according to the specific needs of the application. For example, a coordinate system is established for the target image to be detected, and the different preset directions can be 30 degrees, 60 degrees, 90 degrees, 120 degrees, 150 degrees, and 180 degrees in the coordinate system, and the above angles are the angles between the preset directions and the positive half axis of the X-axis. As a specific example, the different preset directions in this step can be vertical and horizontal directions, and further, feature information of the target image to be detected in the vertical and horizontal directions can be extracted.
[0077] It should be noted that the method for extracting the first feature information of the target image to be detected in different preset directions in this step can be any feasible method. For example, edge detection algorithms can be used to extract edge information in the image and further analyze the distribution of these edges in the vertical and horizontal directions; histograms of the image in different directions can also be calculated to obtain detailed pixel distribution information, thereby obtaining feature information of the image in the vertical and horizontal directions; wavelet transforms can also be used to extract feature information of the image in the vertical and horizontal directions, etc.
[0078] Step S130: concatenate the first feature information to obtain target feature information.
[0079] It should be noted that, in this step, the method of splicing the first feature information can be any feasible method, for example, the first feature information in different preset directions can be directly spliced in the channel dimension, or corresponding weights can be set for the first feature information in different preset directions, and the first feature information in each direction can be weightedly fused according to different weights, or a convolutional neural network can be used to automatically learn how to fuse the first feature information in different preset directions.
[0080] Step S140: input the target feature information into a target detection network, and output the type and position information of the elongated target in the target image to be detected.
[0081] It should be noted that the target detection network in this step can be any target detection network that can output the type and position information of the elongated target in the target image to be detected after inputting the target feature information into the target detection network. For example, the target detection network can be a YOLO series model, a Single Shot MultiBoxDetector (SSD) model, or a Deformable Convolutional Networks (DCN) model, etc., wherein if the target feature information is input into the YOLO series model, the YOLO model will divide it into a grid and predict the bounding box in each grid unit, and then output the position information and category probability of the bounding box, thereby determining the type and position information of the slender target; if the target feature information is input into the SSD model, the target feature information can be passed to the convolutional layers of different scales of the SSD model. On the feature map formed by the convolutional layer of each scale, a series of default boxes will be generated, and the offsets and categories of these default boxes will be predicted. Redundant bounding boxes are removed by non-maximum suppression, and finally the position information and type of the slender target can be output; if the target feature information is input into the DCN model, the feature information can be further extracted through the deformable convolutional layer of the DCN model. The feature information can be used for classification and bounding box regression, and then the position information and type of the slender target can be output.
[0082] It should be noted that, in this step, the defect category of the slender object can be obtained through the type of the slender object finally output.
[0083] In this way, when extracting the feature information of the target image to be detected, the solution of the embodiment of the present invention will extract the first feature information of the target image to be detected in different preset directions. In this way, the feature information of the target image to be detected in different preset directions can be deeply extracted, and the feature information of the target image to be detected in a certain direction will not be missed. In this way, compared with the prior art, the solution of the embodiment of the present invention avoids the problem that the features of slender targets in traditional machine vision methods are difficult to capture and effectively process; and compared with the deep learning model in the prior art, the solution of the embodiment of the present invention accurately extracts the feature information of the target image to be detected in different preset directions, so that the target detection network can accurately predict the slender target based on the accurate feature information, avoiding the problem in the prior art that the slender target cannot be accurately predicted due to insufficient training data when the deep learning model is used to detect the slender target. In summary, the solution of the embodiment of the present invention solves the problem that the various detection schemes for slender defects in the prior art cannot accurately detect slender defects.
[0084] In an optional implementation, Figure 2 FIG. 1 is another flow chart of an embodiment of the present invention, wherein step S120 includes:
[0085] Step S121, splitting the target convolutional layer into one-dimensional convolutional layers;
[0086] Step S122: input the target image to be detected into each of the one-dimensional convolutional layers respectively, and extract first feature information of the target image to be detected in different preset directions.
[0087] The number of the one-dimensional convolutional layers is the same as the dimension of the target convolutional layer.
[0088] It should be noted that the dimension of the target convolutional layer can be set according to the specific needs of the application. For example, it can be a two-dimensional convolutional layer or a three-dimensional convolutional layer. Naturally, when the target convolutional layer is a two-dimensional convolutional layer, the number of one-dimensional convolutional layers obtained by splitting the target convolutional layer is two, and when the target convolutional layer is a three-dimensional convolutional layer, the number of one-dimensional convolutional layers obtained by splitting the target convolutional layer is three.
[0089] The height and length of the convolution kernel of the target convolution layer can be set according to the specific needs of the application. For example, the height and length of the convolution kernel of the target convolution layer are 3*3 or 5*5. Naturally, when the height and length of the convolution kernel of the target convolution layer are 3*3, the height and length of the convolution kernels of the two one-dimensional convolution layers obtained by splitting the target convolution layer are 1*3 and 3*1 respectively. When the height and length of the convolution kernel of the target convolution layer are 5*5, the height and length of the convolution kernels of the two one-dimensional convolution layers obtained by splitting the target convolution layer are 1*5 and 5*1 respectively.
[0090] In this way, when the target image to be detected is input into each one-dimensional convolution layer respectively, the first feature information of the target image to be detected in different preset directions can be extracted. For example, when the target image to be detected is input into two one-dimensional convolution layers of 1*3 and 3*1 obtained by splitting the 3*3 target convolution layer respectively, the first feature information of the target image to be detected in the vertical direction and the first feature information in the horizontal direction can be extracted respectively. For slender targets, the 3*3 convolution kernel considers the information of a 3*3 area at the same time when extracting features. After splitting it into 1*3 and 3*1 convolution kernels, the 1*3 convolution kernel can better capture the feature changes of the target in the length direction (such as the long axis direction of a slender target), and the 3*1 convolution kernel is better at capturing the feature changes of the target in the width direction (the short axis direction of a slender target).
[0091] Furthermore, the split convolution kernels can have different parameter settings. For example, they can have different step sizes and padding methods. This flexibility allows the model to better adapt to the different shapes and sizes of slender objects. Furthermore, during the computational process, the smaller convolution kernel size can also reduce computational complexity. This is very beneficial for processing large-scale image data or running the model on resource-constrained devices.
[0092] In an optional implementation, step S130 includes:
[0093] Inputting the target image to be detected into the target convolution layer to extract second feature information of the target image to be detected;
[0094] The second feature information and the first feature information are concatenated to obtain target feature information.
[0095] The number of channels of the target image to be detected input into the target convolution layer is greater than the number of the target convolution layers.
[0096] It should be noted that the method of splicing the second feature information and the first feature information can be any feasible method.
[0097] It's understandable that when the target image to be detected is input into the target convolution layer, and the number of input channels of the target image to be detected is greater than the number of target convolution layers, the original feature channels of the target image to be detected can be compressed into fewer channels. For slender targets, the numerous original feature channels may contain a large amount of local details, noise, and redundant information. The process of compressing the channels is like removing these less important details, thereby extracting more representative semantic features.
[0098] Optionally, in this implementation, the original feature information of the target image to be detected can also be extracted, and the original feature information can be spliced together with the first feature information and the second feature information to obtain the target feature information, so that the target feature information finally used for target detection retains the original feature information of the slender target. Retaining the original feature information of the slender target can enable the feature information to retain the original information characteristics of the image, so that the obtained target feature information can retain the direct features of the image, so that the detection results of the slender target obtained based on the target feature information are more accurate. In addition, when the target image to be detected is input into the target convolution layer, the compression of the channel will cause the target image to be detected to lose some information, so the splicing of the original feature information can supplement the lost information of the second feature information and the first feature information.
[0099] As a specific example, Figure 3 The figure shows an architecture diagram of a neural network provided by an embodiment of the present invention. Figure 3 In the above example, assuming that the number of target convolution layers is two, the original feature information of the target image to be detected is input into the two convolution layers in sequence to obtain the second feature information, and the second feature information is concatenated with the original feature information to output the final feature information. Such a neural network architecture is Figure 3 It is named as the first feature module.
[0100] In an optional implementation, step S122 includes:
[0101] Inputting the target image to be detected into a backbone feature extraction network in a target detection model, and outputting third feature information;
[0102] The third feature information is input into each of the one-dimensional convolutional layers in the neck feature extraction network in the target detection model, and the first feature information in different preset directions is output.
[0103] It should be noted that in this implementation, the backbone feature extraction network extracts features at different levels of the target image to be detected through multi-layer convolution operations. For example, the backbone feature extraction network can be a residual network, a visual geometry group network (VGG) or a mobile network convolutional neural network architecture. It is understandable that by inputting the target image to be detected into the backbone feature extraction network, rich features can be extracted from the target image to be detected.
[0104] It should be noted that in this implementation, the neck feature extraction network is located in the target detection model, between the backbone feature extraction network and the detection head network, and is used to further process the features of the backbone feature extraction network to improve detection performance. The neck feature extraction network can fuse feature information at different levels, enhance feature representation, and improve the quality of feature information. Specifically, the neck feature extraction network can be a Feature Pyramid Network (FPN) or a Path Aggregation Network (PANet).
[0105] It can be understood that in this implementation, the one-dimensional convolution layer obtained by splitting the target convolution layer is set in the neck feature extraction network, which can utilize the features initially extracted by the backbone and provide more suitable slender target features to the detection head after fine processing, balance the degree of feature abstraction, and will not interfere with the backbone network structure and the general feature extraction process. It is conducive to balancing the feature extraction of multiple target types, reducing the burden on the detection head, improving the efficiency and accuracy of slender target detection, and better cooperating with other modules for feature fusion, which is not conducive to exerting its fusion advantages in the detection head network.
[0106] In an optional implementation, step S130 includes:
[0107] Extracting original feature information of the target image to be detected;
[0108] The first feature information and the original feature information are concatenated to obtain target feature information.
[0109] It should be noted that, in this implementation, the original feature information of the target to be detected is the feature information directly extracted from the image of the target to be detected, and the feature information has not been further processed or enhanced.
[0110] It can be understood that the original feature information is spliced together with the first feature information to obtain the target feature information, so that the target feature information finally used for target detection retains the original feature information of the slender target. Retaining the original feature information of the slender target can make the feature information retain the original information characteristics of the image, so that the obtained target feature information can retain the direct features of the image, making the detection results of the slender target obtained based on the target feature information more accurate. In addition, when the target image to be detected is input into the target convolution layer, the compression of the channel will cause the target image to be detected to lose some information, so splicing the original feature information can supplement the information lost in the first feature information.
[0111] As a specific example, Figure 4The figure shows another neural network architecture diagram provided by an embodiment of the present invention. Figure 4 In the neural network, the original feature information is input into two one-dimensional convolutional layers to obtain two first feature information for splicing. The first feature information can also be spliced with the original feature information to obtain the final output feature information. Figure 4 It is named as the second feature module.
[0112] As a specific example, Figure 5 The figure shows another architecture diagram of a neural network provided by an embodiment of the present invention. Figure 5 In the process, the feature information of the target image to be detected can be taken as input and input into the convolution layer to obtain the original feature information. Then, the original feature information can be input into the first feature module and the second feature module respectively. The feature information output by the two feature modules can be spliced and input into the normalization module for normalization to obtain the target feature information. The target feature information is input into the efficient channel attention mechanism module (i.e., the convolution block attention module) to output the first target feature information. The first target feature information is spliced with the original feature information to obtain the final output feature information. Figure 5 The module shown can be called the target feature module. Specifically, the algorithm executed by the normalization module can be expressed as follows:
[0113]
[0114] Where γ is the preset scaling parameter, β is the preset offset parameter, ∈ is a preset constant with a very small value to ensure that the denominator is not 0, E(x) is the expectation of x, σ(x) is the variance of x, x is the feature information input by the normalization module, and y is the feature information output by the normalization module.
[0115] Optionally, in this implementation, feature information of the original feature information in different preset directions can be extracted to obtain first feature information in different preset directions, and then the first feature information in each different preset direction and the original feature information can be spliced to obtain target feature information.
[0116] In an optional implementation, Figure 6 FIG. 1 is a flow chart of another method for detecting an elongated target provided by an embodiment of the present invention. Before step S110, the method further includes:
[0117] Step S101 : obtaining an image to be detected, and dividing the image to be detected into different connected domains according to pixel values of the image to be detected.
[0118] Each of the connected domains corresponds to a unique pixel threshold segment.
[0119] It should be noted that in this step, the image to be detected is an image having an elongated target. It is understood that the image to be detected has its own corresponding pixel value range, i.e., the pixel threshold range between the minimum and maximum values of all pixels in the image to be detected. In this step, "dividing the image to be detected into different connected domains according to the pixel values of the image to be detected" means "dividing the pixel threshold range corresponding to the image to be detected into multiple continuous pixel threshold segments, and dividing the image in the image to be detected corresponding to each pixel threshold segment to form a connected domain."
[0120] Optionally, since a color image has three pixel channels, namely red, green and blue channels, if the connected domain of the color image to be detected is directly divided based on the pixel value, each pixel channel needs to be divided. Therefore, in this step, the color image to be detected can be first converted into a grayscale image format. The image corresponding to the grayscale image format has only one pixel channel, which can effectively save the division resources of the image to be detected.
[0121] Step S102 : for a target pixel threshold segment, select a pixel value at a preset position in the target pixel threshold segment as a target pixel value, and unify the pixel values in the target connected domain corresponding to the target pixel threshold segment into the target pixel value, thereby obtaining a first image to be detected.
[0122] It should be noted that, in this step, the target pixel threshold segment is any pixel threshold segment corresponding to the image to be detected.
[0123] It should be noted that the preset position in the target pixel threshold segment can be set according to specific application needs. For example, in order to make the first image to be detected obtained in this step clearer and easier to identify, the maximum pixel value in the target pixel threshold segment can be used as the target pixel value, and the pixel values in the target connected domain can be uniformly set to the aforementioned maximum pixel value.
[0124] It should be noted that the method of unifying the pixel values in the target connected domain into the target pixel values in this step can be any feasible method. For example, all pixel values in the target connected domain can be directly set to the target pixel values, or the connected domain can be processed by dilation and erosion, and then the target pixel value can be assigned to the target connected domain.
[0125] It can be understood that in this step, unifying the pixel values in the target connected domain into the target pixel values can enhance the contrast between the target connected domain and other connected domains, thereby highlighting the boundaries in the image to be detected, thereby making the outline of the slender target in the image to be detected appear.
[0126] Step S103: Acquire contour information in the first image to be detected.
[0127] Step S104: obtaining the slender target in the first image to be detected according to the contour information.
[0128] It can be understood that through the above steps, various boundaries in the image to be detected (i.e., the contour information in this step) can be revealed, and the contour of the natural slender target is within these boundaries. Then, the contour of the slender target in the first image to be detected can be obtained within these boundaries, and the slender target in the first image to be detected can be determined.
[0129] Step S105 : Displaying the elongated target in the first image to be detected to generate the target image to be detected.
[0130] It should be noted that, in this step, the mode of displaying the elongated target in the first image to be detected can be any mode that can be realized. For example, for the first image to be detected after grayscale processing, the inside of the outline information of the elongated target in the first image to be detected can be filled, all filled with (255,255,255) pixels, converting to binary data is (1,1,1), and the outer background of the outline information is filled with pixel binary data (0,0,0), and finally the first image to be detected after pixel filling and the colored image to be detected are carried out bitwise AND, like this, the pixel of the elongated target in the colored image to be detected remains unchanged, and because (0,0,0) is black, the background outside the elongated target is all filled with black background. Like this, the colored elongated target and the outer black background of the elongated target are included in the target image to be detected that is finally generated, and it can be understood that the black background can make the colored elongated target more conspicuous.
[0131] It is understandable that slender objects are often easily confused with other lines or structures in the background, which increases the difficulty of detection. Steps S101 to S105 can effectively extract slender objects so that the object detection network can accurately output the location information and type of slender objects.
[0132] In an optional implementation, step S101 includes:
[0133] Dividing the pixel values of the image to be detected into different pixel threshold segments;
[0134] Extracting pixel thresholds at the ends of each pixel threshold segment to form initial population individuals in the genetic algorithm;
[0135] Performing multiple crossovers and mutations on the individuals of the initial population to obtain individuals of a new population;
[0136] Inputting each of the new population individuals and the initial population individuals into a preset global fitness function to obtain fitness values of the new population individuals and the initial population individuals;
[0137] The population with the maximum fitness value is taken as the target population;
[0138] A pixel threshold corresponding to each individual in the target population is determined, and the image to be detected is divided into different connected domains according to the pixel threshold.
[0139] It can be understood that dividing the pixel values of the image to be detected into different pixel threshold segments means extracting multiple pixel values from the sequence of all pixel values in the image to be detected, arranged from small to large, as pixel thresholds. A pixel threshold segment is naturally formed between two adjacent pixel thresholds. Furthermore, in this implementation, the multiple extracted pixel values are set as individuals in a population, and these individuals can form an initial population.
[0140] After obtaining the initial population, the initial population can be initialized, and the number of iterations, crossover probability, and mutation probability of the population initialization can be set according to the specific needs of the application. For example, the number of iterations can be set to 100, the crossover probability can be set to 0.2, and the mutation probability can be set to 0.06. Furthermore, after the initial population is initialized, the population can be cross-mutated based on the above-mentioned crossover probability and mutation probability. The specific individuals undergoing crossover mutation can be set according to the needs of the application and are not specified in detail here. Finally, after the population is cross-mutated, it can be continuously iterated based on the number of iterations to obtain multiple new populations (i.e., a new population is generated after a crossover mutation is performed on the population, and the next new population is obtained after a crossover mutation is performed on the previous new population).
[0141] It should be noted that, in this implementation, the global fitness function can be set according to specific needs of the application.
[0142] It is understood that the target population ultimately obtained is the population with the maximum fitness value. In other words, each individual in the target population represents the optimal pixel threshold to be found for highlighting the boundary of the image to be detected. By dividing the connected domain based on these optimal pixel thresholds and then unifying the pixels in the connected domain to a set threshold (for example, the maximum pixel threshold in the pixel threshold segment), the contour information in the image to be detected can be better highlighted.
[0143] In an optional implementation, the global fitness function is:
[0144] σ 2 (T) = p i1 (T)*(μ i1 (T) - μt ) 2 +p i0 (T)*(μ i0 (T) - μ t ) 2 ;
[0145] Among them, σ 2 (T) is the fitness value of the individual in the population, p i1 (T) is the ratio of the foreground pixels of the individual population to the global value, μ i1 (T) is the mean foreground pixel value of each individual in the population, μ t is the global pixel mean of the population, p i0 (T) is the ratio of the background pixels of the individuals in the population to the global value, μ i0 (T) is the background pixel mean of each individual in the population, and T is the pixel threshold corresponding to the individual in the population.
[0146] It should be noted that the global fitness function in this implementation is the calculation formula of the maximum inter-class variance. For detailed explanation of each parameter, please refer to the parameter definition of the maximum inter-class variance.
[0147] Understandably, p i1 (T)*(μ i1 (T) - μ t ) 2 It can represent the maximum value of the distance between the foreground pixel of the individual population and the global pixel mean, p i0 (T)*(μ i0 (T) - μ t ) 2 It can represent the maximum value of the distance between the background pixel of the individual in the population and the global pixel mean. Since the global pixel mean is a fixed value, 2 (T) takes the maximum value when p i1 (T)*(μ i1 (T) - μ t ) 2 and p i0 (T)*(μ i0 (T) - μ t ) 2 will take the maximum value, naturally at this time μ i1 (T) and μ i0 The value of (T) is the farthest away, so the boundary between the foreground and background of the corresponding pixel threshold is naturally clearer. Therefore, the corresponding pixel threshold at this time is the optimal solution, and the outline formed based on this population threshold is naturally clear.
[0148] In an optional implementation, step S104 includes:
[0149] Obtaining the size information of slender targets;
[0150] Filtering the target contour corresponding to the elongated target from the contour information according to the size information;
[0151] According to the convex hull algorithm, solving the convex hull contour corresponding to the target contour;
[0152] The convex hull contour is used as the contour of the slender object to obtain the slender object in the first image to be detected.
[0153] It should be noted that the size information of the slender target in this implementation is the actual size information of the slender target, and the size information of the slender target can be obtained by on-site measurement or pre-measurement.
[0154] Furthermore, the size information of each contour information in the first image to be detected is measured, the size information of each contour information corresponding to the size information of the slender object is selected, and the contour information is determined as the contour information of the slender object.
[0155] Specifically, the convex hull algorithm in this implementation can be any convex hull algorithm. The convex hull algorithm is used to find the smallest convex polygon (the smallest convex polygon containing all points) for a set of points. Obviously, the set of points in the convex hull algorithm mentioned in this implementation corresponds to the contour information of the slender target. It is understood that the convex hull algorithm can accurately find the smallest convex polygon containing all given points, which can clearly accurately extract the target contour of the slender target. Furthermore, the contour generated by the convex hull algorithm is a closed polygon, ensuring the integrity of the contour.
[0156] As a specific example, after the embodiment of the present invention adopts the above-mentioned detection method for slender targets, as shown in FIG. Figure 7 and Figure 8 The mAP50 images shown are for object detection using the YOLOv8 model and the improved model of the present invention. mAP stands for mean average precision and is an important metric for measuring model performance in object detection. It comprehensively considers the model's detection accuracy for different categories and the importance of each category. The "50" in mAP50 refers to the intersection-over-union (IoU) threshold of 0.5. IoU is the ratio of the intersection area of the model's predicted bounding box to the union area of the ground-truth bounding box, and is used to measure prediction accuracy.
[0157] As a specific example, after the embodiment of the present invention adopts the above-mentioned detection method for slender targets, as shown in FIG. Figure 9 and Figure 10Shown are the confusion matrix diagrams of target detection obtained using the YOLOv8 model and the confusion matrix diagrams of target detection obtained using the target detection model (improved model) of the present invention.
[0158] As a specific example, 1970 images of dispensing defects (a type of elongated defect) were collected as the dataset of the present invention. Some images may have multiple defects. The dataset was divided into training set, test set, and validation set in a ratio of 8:1:1. The original model (using the YOLOv8n model) and the improved model (using the target detection method of the present invention) were trained on the images in the training set, and the training weights were imported into the network structure to test the test set. The specific test results are as follows: Figure 11 As shown in the table.
[0159] As a specific example, Figure 12 Shown is an identification diagram of a certain slender target workpiece detected by the target detection method of the present invention.
[0160] Based on the above-mentioned method for detecting slender targets, an embodiment of the present invention provides a device for detecting slender targets, such as Figure 13 As shown, the detection device for slender targets includes:
[0161] An acquisition module 1310 is configured to acquire an image of a target to be detected;
[0162] An extraction module 1320 is configured to extract first feature information of the target image to be detected in different preset directions respectively;
[0163] A splicing module 1330 is configured to splice the first feature information to obtain target feature information;
[0164] The output module 1340 is configured to input the target feature information into a target detection network and output the type and position information of the elongated target in the target image to be detected.
[0165] For other details about how the modules in the above-mentioned device for detecting slender targets implement the above-mentioned technical solution, reference may be made to the description of the method for detecting slender targets provided in the above-mentioned embodiment of the invention, which will not be repeated here.
[0166] In the several embodiments provided by the present invention, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the modules is merely a logical function division. In actual implementation, there may be other division methods, such as multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interface, device or module, which can be electrical, mechanical or other forms.
[0167] The modules described as separate components may or may not be physically separate, and the components shown as modules may or may not be physical modules, that is, they may be located in one place or distributed across multiple network modules. Some or all of the modules may be selected to achieve the purpose of the present embodiment according to actual needs.
[0168] In addition, the functional modules in the various embodiments of the present invention may be integrated into a single processing module, each module may exist physically separately, or two or more modules may be integrated into a single module. The integrated modules may be implemented in the form of hardware or software functional modules. If the integrated modules are implemented in the form of software functional modules and sold or used as independent products, they may be stored in a computer-readable storage medium.
[0169] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware, or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.
[0170] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website, computer, server or data center to another website, computer, server or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) method. The computer-readable storage medium can be any available medium that a computer can store or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium), or a semiconductor medium (e.g., an SSD (solid state disk)).
[0171] The technical solution provided by the present invention is introduced in detail above. Specific examples are used in the present invention to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as limiting the present invention.
[0172] It will be understood by those skilled in the art that embodiments of the present invention may be provided as methods, systems, or computer program products. Thus, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, optical storage, etc.) containing computer-usable program code.
[0173] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the present invention. It should be understood that each process and / or block in the flowcharts and / or block diagrams, as well as combinations of processes and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowcharts and / or block diagrams. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0174] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0175] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0176] Obviously, those skilled in the art may make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if such changes and modifications fall within the scope of the claims and their equivalents, the present invention is intended to include such changes and modifications.
Claims
1. A method for detecting a slender target, characterized in that: include: Acquire the target image to be detected; Respectively extracting first feature information of the target image to be detected in different preset directions; Concatenate the first feature information to obtain target feature information; The target feature information is input into a target detection network, and the type and position information of the elongated target in the target image to be detected is output.
2. The method for detecting a slender target according to claim 1, characterized in that: The step of respectively extracting first feature information of the target image to be detected in different preset directions includes: Splitting the target convolutional layer into one-dimensional convolutional layers, wherein the number of the one-dimensional convolutional layers is the same as the dimension of the target convolutional layer; The target image to be detected is input into each of the one-dimensional convolutional layers respectively, and the first feature information of the target image to be detected in different preset directions is extracted.
3. The method for detecting a slender target according to claim 2, characterized in that: The step of combining the first feature information to obtain target feature information includes: Inputting the target image to be detected into the target convolution layer, and extracting second feature information of the target image to be detected, wherein the number of channels of the target image to be detected input into the target convolution layer is greater than the number of the target convolution layers; The second feature information and the first feature information are concatenated to obtain target feature information.
4. The method for detecting a slender target according to claim 2, characterized in that: Inputting the target image to be detected into each of the one-dimensional convolutional layers respectively, and extracting first feature information of the target image to be detected in different preset directions, comprises: Inputting the target image to be detected into a backbone feature extraction network in a target detection model, and outputting third feature information; The third feature information is input into each of the one-dimensional convolutional layers in the neck feature extraction network in the target detection model, and the first feature information in different preset directions is output.
5. The method for detecting a slender target according to claim 1, characterized in that: The step of combining the first feature information to obtain target feature information includes: Extracting original feature information of the target image to be detected; The first feature information and the original feature information are concatenated to obtain target feature information.
6. The method for detecting a slender target according to claim 1, characterized in that: Before acquiring the target image to be detected, the method further includes: Acquire an image to be detected, and divide the image to be detected into different connected domains according to the pixel values of the image to be detected, wherein each connected domain corresponds to a unique pixel threshold segment; For a target pixel threshold segment, a pixel value at a preset position in the target pixel threshold segment is selected as a target pixel value, and pixel values in a target connected domain corresponding to the target pixel threshold segment are unified as the target pixel value, to obtain a first image to be detected; Acquire contour information in the first image to be detected; Obtaining, according to the contour information, a slender target in the first image to be detected; The slender target is displayed in the first image to be detected to generate the target image to be detected.
7. The method for detecting a slender target according to claim 6, characterized in that: The step of dividing the image to be detected into different connected domains according to pixel values of the image to be detected includes: Dividing the pixel values of the image to be detected into different pixel threshold segments; Extracting pixel thresholds at the ends of each pixel threshold segment to form initial population individuals in the genetic algorithm; Performing multiple crossovers and mutations on the individuals of the initial population to obtain individuals of a new population; Inputting each of the new population individuals and the initial population individuals into a preset global fitness function to obtain fitness values of the new population individuals and the initial population individuals; The population with the maximum fitness value is taken as the target population; A pixel threshold corresponding to each individual in the target population is determined, and the image to be detected is divided into different connected domains according to the pixel threshold.
8. The method for detecting a slender target according to claim 7, characterized in that: The global fitness function is: s 2 (T)=p i1 (T)*(μ i1 (T)-m t ) 2 +p i0 (T)*(μ i0 (T)-m t ) 2 ; Among them, σ 2 (T) is the fitness value of the individual in the population, p i1 (T) is the ratio of the foreground pixels of the individual population to the global value, μ i1 (T) is the mean foreground pixel of each individual in the population, μ t is the global pixel mean of the population, p i0 (T) is the ratio of the background pixels of the individuals in the population to the global value, μ i0 (T) is the background pixel mean of each individual in the population, and T is the pixel threshold corresponding to the individual in the population.
9. The method for detecting a slender target according to claim 6, characterized in that: The step of obtaining the elongated target in the first image to be detected according to the contour information includes: Obtaining the size information of slender objects; According to the size information, selecting the target contour corresponding to the elongated target from the contour information; According to the convex hull algorithm, solving the convex hull contour corresponding to the target contour; The convex hull contour is used as the contour of the slender object to obtain the slender object in the first image to be detected.
10. A device for detecting a slender target, characterized in that: include: An acquisition module is used to acquire the target image to be detected; An extraction module, used to respectively extract first feature information of the target image to be detected in different preset directions; A splicing module, used for splicing the first feature information to obtain target feature information; The output module is used to input the target feature information into the target detection network and output the type and position information of the elongated target in the target image to be detected.
Citation Information
Patent Citations
METHOD FOR SELECTING AN OPTIMIZED EVALUATION SUB-FEATURE FOR CONTROLLING A FREEFORM SURFACE AND METHOD FOR CONTROLLING A FREEFORM SURFACE
AT11770U1
A method for detecting slender objects based on a convolution neural network
CN109446888A
Power line classification method based on deep learning under complex background
CN112364878A
Aerial image target detection method, equipment and medium
CN114140683A
Slender target detection system and method based on key point displacement vector representation
CN114463652A