Storage medium, routing detection device, routing detection model training device and method
Through training of the trace detection model, using line segment detection and edge feature extraction technology, the problems of missed and misdetection of manual trace standardization are solved, and efficient and accurate automatic detection is achieved.
Patent Information
- Application Number
- CN202010362054.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-04-30
- Publication Date
- 2025-02-25
- Estimated Expiration
- 2040-08-23
AI Technical Summary
In the prior art, there are missed and mis-checking in the standardization of manual inspection and traces, resulting in a decrease in product yield and an increase in labor costs.
By acquiring sample images and their labels, performing line segment detection and edge feature extraction, generating training features, and training classification models based on these features, automatic detection of trace normativeness is achieved.
It improves the work efficiency of standardized routing inspections, reduces manual errors, improves the accuracy of inspection results, and reduces labor costs.
Smart Images

Figure CN113592761B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of machine learning, and in particular to a non-transitory readable storage medium, a routing detection device, and a training device and a training method for a routing detection model. Background Art
[0002] There are a large number of circuits in electronic products, so a large number of wirings need to be laid. In the production process, in order to improve the yield of the product, the wiring needs to be checked. At present, manual inspection is generally used to judge whether the wiring is standardized. However, due to the phenomenon of missed inspection and false inspection in manual inspection, the product yield is reduced and the labor cost is increased.
[0003] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention
[0004] The purpose of the present disclosure is to overcome the deficiencies of the above-mentioned prior art and to provide a readable storage medium, a routing detection device, a training device and a training method for a routing detection model, which can improve the work efficiency of routing compliance inspection.
[0005] According to one aspect of the present disclosure, a method for training a routing detection model is provided, comprising:
[0006] Obtaining a sample image and a sample label of the sample image;
[0007] Performing line segment detection on the sample image and acquiring line segment edge features of the sample image;
[0008] Generate training features according to the line segment edge features;
[0009] The classification model is trained according to the sample labels and the training features to obtain a routing detection model.
[0010] In an exemplary embodiment of the present disclosure, performing line segment detection on the sample image and acquiring line segment edge features of the sample image includes:
[0011] Preprocessing the sample image to obtain a target sample image;
[0012] Determining a region of interest in the target sample image;
[0013] Performing line segment detection on the region of interest of the target sample image to obtain a line segment detection result, wherein the line segment detection result includes the coordinates of the endpoints of each detected line segment;
[0014] Generate a line segment detection image according to the line segment detection result;
[0015] The line segment edge features of the edge points are acquired according to the line segment detection image as the line segment edge features of the sample image; the line segment edge features of each edge point include the coordinates of the edge point and the slope of the line segment to which it belongs.
[0016] In an exemplary embodiment of the present disclosure, the preprocessing of the sample image to obtain a target sample image includes:
[0017] Get a standard image;
[0018] registering the sample image according to the standard image;
[0019] The registered sample image is down-sampled to obtain a target sample image.
[0020] In an exemplary embodiment of the present disclosure, determining the region of interest in the target sample image includes:
[0021] Get the region of interest parameters including the location information of the region of interest;
[0022] A region of interest is determined in the target sample image according to the region of interest parameters.
[0023] In an exemplary embodiment of the present disclosure, generating a line segment detection image according to the line segment detection result includes:
[0024] Determine the length of each line segment detected in the target sample image according to the line segment detection result;
[0025] Screening out line segments whose lengths are within a length threshold range as reference line segments, and using the endpoint coordinates of the reference line segments as reference endpoint coordinates;
[0026] A line segment detection image is generated according to the reference endpoint coordinates of the reference line segment.
[0027] In an exemplary embodiment of the present disclosure, the step of generating a line segment detection image according to the reference endpoint coordinates of the reference line segment includes:
[0028] Generate a line connecting two endpoints of each reference line segment according to the reference endpoint coordinates of the reference line segment to obtain one or more target line segments;
[0029] A pixel value is set for each target line segment, and the pixel value of the same target line segment is the same, so as to obtain a line segment detection image containing one or more target line segments; if there are multiple target line segments, the pixel values of different target line segments are different.
[0030] In an exemplary embodiment of the present disclosure, acquiring line segment edge features of edge points according to the line segment detection image as line segment edge features of the sample image includes:
[0031] Determine the total number of edge points of the target line segment in the line segment detection image, and obtain the line segment edge feature of each edge point of the target line segment; the line segment edge feature of each edge point includes the coordinates of the edge point and the slope of the target line segment to which it belongs;
[0032] Compare the total number of edge points of the target line segment in the line segment detection image with a quantity threshold;
[0033] If the total number of edge points of the target line segment in the line segment detection image is not greater than the quantity threshold, taking the line segment edge feature of each edge point as the line segment edge feature of the sample image;
[0034] If the total number of edge points of the target line segment in the line segment detection image is greater than the quantity threshold, the line segment detection image is downsampled at a preset sampling ratio, and the line segment edge features of the edge points of the target line segment in the downsampled line segment detection image are used as the line segment edge features of the sample image, and the sampling ratio is the ratio of the quantity threshold to the number of edge points of the line segment detection image before downsampling.
[0035] In an exemplary embodiment of the present disclosure, downsampling the line segment detection image at a preset sampling ratio includes:
[0036] Obtaining the coordinates of the pixel points of the target line segment in the line segment detection image and the slope of the target line segment to which it belongs;
[0037] Determine the floating-point coordinates of the pixel points of the target line segment and the floating-point slope of the target line segment according to a preset sampling ratio, the coordinates of the pixel points of the target line segment and the slope of the target line segment; the sampling ratio is the ratio of the number threshold to the total number of edge points of the line segment detection image before downsampling;
[0038] Determine a line segment edge feature of the edge point of the target line segment in the downsampled line segment detection image according to the floating-point coordinates and the floating-point slope of the target line segment.
[0039] In an exemplary embodiment of the present disclosure, generating the training feature according to the line segment edge feature includes:
[0040] The line segment edge features are normalized to obtain training features.
[0041] In an exemplary embodiment of the present disclosure, the classification model is a support vector machine model or a convolutional neural network model.
[0042] According to one aspect of the present disclosure, a training device for a routing detection model is provided, comprising:
[0043] An acquisition unit is configured to: acquire a sample image and a sample label of the sample image;
[0044] A detection unit is configured to: perform line segment detection on the sample image and obtain line segment edge features of the sample image;
[0045] A processing unit is configured to: generate a training feature according to the line segment edge feature;
[0046] The generating unit is configured to: train the classification model according to the sample labels and the training features to obtain a routing detection model.
[0047] According to one aspect of the present disclosure, a wiring detection method is provided, comprising:
[0048] Execute any one of the training methods described above to generate a routing detection model;
[0049] Acquire the image to be detected;
[0050] Performing line segment detection on the image to be detected, and obtaining line segment edge features of the image to be detected;
[0051] The line segment edge features are input into a line detection model to obtain a detection result, and whether the image to be detected is normal is determined according to the detection result.
[0052] In an exemplary embodiment of the present disclosure, performing line segment detection on the image to be detected includes:
[0053] Preprocessing the image to be detected to obtain a target image to be detected;
[0054] Determining a region of interest in the target image to be detected;
[0055] Performing line segment detection on the region of interest of the target image to be detected to obtain a line segment detection result of the image to be detected, wherein the line segment detection result includes the endpoint coordinates of each detected line segment;
[0056] Generate a line segment detection image according to each of the line segment detection results;
[0057] The line segment edge features of the edge points are acquired according to the line segment detection image as the line segment edge features of the image to be detected; the line segment edge features of each edge point include the coordinates of the edge point and the slope of the line segment to which it belongs.
[0058] According to one aspect of the present disclosure, there is provided a wiring detection device, comprising:
[0059] The image acquisition device is configured to: acquire an image to be detected;
[0060] A memory configured to: store executable instructions;
[0061] A processor is coupled to the image acquisition device and the memory, and the processor is configured to: obtain the image to be detected and the executable instructions, and execute any one of the above-mentioned line detection methods by executing the executable instructions.
[0062] According to one aspect of the present disclosure, a non-volatile readable storage medium is provided, on which a computer program is stored, and when the computer program is executed, any one of the training methods described above is implemented, or when the computer program is executed, any one of the routing detection methods described above is implemented.
[0063] The readable storage medium, the line detection device, the training device and the method of the line detection model disclosed in the present invention can obtain the line edge features in the sample image and the image to be detected by line segment detection, which is used to reflect the pattern of the line. By training the line detection model based on the sample image and the sample label, and using the line detection model to classify the lines of the image to be detected, it is possible to check whether the lines are standardized by machine learning, avoid manual inspection, improve work efficiency, and reduce labor costs. At the same time, it can also avoid missed detections, wrong detections, etc. caused by staff operating errors, etc., which is conducive to improving the accuracy of the inspection results.
[0064] 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 disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0065] The accompanying drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the specification are used to explain the principles of the present disclosure. Obviously, the accompanying drawings described below are only some embodiments of the present disclosure, and for ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without creative work.
[0066] Figure 1 The present invention is a flowchart of an embodiment of the training method disclosed herein.
[0067] Figure 2 Flow chart of step S120 of an implementation of the training method disclosed herein.
[0068] Figure 3 Flow chart of step S1210 of an implementation of the training method disclosed herein.
[0069] Figure 4 This is a flowchart of step S1250 of an implementation of the training method disclosed herein.
[0070] Figure 5 It is a block diagram of an embodiment of the training device disclosed herein.
[0071] Figure 6 The figure is a flow chart of an implementation of the wiring detection method disclosed in the present invention.
[0072] Figure 7 Flow chart of step S230 of an implementation of the wiring detection method disclosed herein.
[0073] Figure 8 It is a block diagram of an implementation of the routing detection device disclosed in the present invention.
[0074] Fig. 9 It is a schematic diagram of an embodiment of a readable storage medium of the present invention. DETAILED DESCRIPTION
[0075] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as being limited to the examples set forth herein; on the contrary, these embodiments are provided so that the present disclosure will be more comprehensive and complete, and the concepts of the example embodiments are fully conveyed to those skilled in the art. The described features, structures, or characteristics may be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present disclosure. However, those skilled in the art will appreciate that the technical solutions of the present disclosure may be practiced while omitting one or more of the specific details, or other methods, components, devices, steps, etc. may be adopted. In other cases, known technical solutions are not shown or described in detail to avoid obscuring various aspects of the present disclosure.
[0076] In addition, the accompanying drawings are only schematic illustrations of the present disclosure and are not necessarily drawn to scale. The same reference numerals in the figures represent the same or similar parts, and their repeated description will be omitted. Some of the block diagrams shown in the accompanying drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software form, or implemented in one or more hardware modules or integrated circuits, or implemented in different networks and / or processor devices and / or microcontroller devices.
[0077] The terms "a", "an", "the" and "said" are used to indicate the presence of one or more elements / components / etc.; the terms "including" and "having" are used to express an open-ended inclusion and mean that additional elements / components / etc. may exist in addition to the listed elements / components / etc.; the terms "first", "second", etc. are used merely as labels and are not intended to limit the quantity of their objects.
[0078] The embodiments of the present disclosure provide a method for training a routing detection model, such as Figure 1 As shown, the training method may include steps S110 to S140, wherein:
[0079] Step S110, obtaining a sample image and a sample label of the sample image;
[0080] Step S120, performing line segment detection on the sample image, and obtaining line segment edge features of the sample image;
[0081] Step S130, generating training features according to the line segment edge features;
[0082] Step S140: training a classification model according to the sample labels and the training features to obtain a routing detection model.
[0083] The training method disclosed in the present invention can obtain the line edge features of the sample image by line segment detection to reflect the pattern of the line, and train a line detection model based on the sample image and the sample label. The line detection model can be used to classify the lines of the image to be detected, so as to check whether the lines are standardized by machine learning, avoid manual inspection, improve work efficiency, and reduce labor costs. At the same time, it can also avoid missed inspections and wrong inspections caused by staff operating errors, which is conducive to improving the accuracy of the inspection results.
[0084] The following is a detailed description of the training method of the embodiment of the present disclosure:
[0085] In step S110 , a sample image and a sample label of the sample image are obtained.
[0086] The sample image may be an image of an electronic device to be inspected, which includes a pattern of wiring. The electronic device may be a circuit board or other device with wiring, which is not particularly limited here. The sample labels include at least two types: standard and non-standard.
[0087] In some embodiments of the present disclosure, there may be multiple sample images, and each sample image corresponds to a sample label, that is, whether the routing reflected by each sample image is standard is determined.
[0088] It should be noted that multiple sample images may be for the same wiring area of the same electronic device to ensure the uniformity of the evaluation object. Of course, for different electronic devices or different wiring areas of the same electronic device, there may be common problems that are not standardized. In this case, multiple sample images may also be for different electronic devices or different areas of the same electronic device, but the standard for determining whether they are standardized or not is unified.
[0089] In step S120, line segment detection is performed on the sample image, and line segment edge features of the sample image are obtained.
[0090] The routing can be identified by line segment detection, and the routing can be characterized by line segment edge features to facilitate subsequent generation of training features.
[0091] like Figure 2 As shown, in some embodiments of the present disclosure, taking the processing process of a sample image as an example: performing line segment detection on the sample image and obtaining the line segment edge features of the sample image; that is, step S120, may include steps S1210 to S1250, wherein:
[0092] Step S1210: pre-process the sample image to obtain a target sample image.
[0093] Preprocessing may include: performing operations such as correction and size conversion on the sample image to facilitate line segment detection.
[0094] like Figure 3 As shown, in some embodiments of the present disclosure, the sample image is preprocessed to obtain a target sample image; that is, step S1210 may include steps S12110 to S12130, wherein:
[0095] S12110. Obtain a standard image.
[0096] The standard image and the sample image are images corresponding to the same routing area, and can be pre-set or collected, which meet the conditions for line segment collection. The standard image can be obtained at the same time as the sample image and sample label, that is, step S12110 and step S110 can be performed at the same time.
[0097] S12120. Register the sample image according to the standard image.
[0098] SIFT (Scale-invariant feature transform) algorithm can be used for registration, and deep learning registration methods based on RegNet network model or other network models can also be used for registration. No special limitation is made on the registration method here.
[0099] S12130. Down-sample the registered sample image to obtain a target sample image.
[0100] A target sample image with a smaller data volume can be obtained by downsampling for processing. The downsampling ratio can be 1 / 4, but is not limited to this, and can also be 1 / 2 or other ratios. The downsampling of the sample image can be achieved by using the resize function based on opencv (Open Source Computer Vision Library). Of course, other methods can also be used. The specific method of downsampling the target sample image is not specifically limited here.
[0101] Step S1220: determine a region of interest in the target sample image.
[0102] The area of interest can be determined based on pre-acquired location information, for example:
[0103] In some embodiments of the present disclosure, determining the region of interest in the target sample image, i.e., step S1220, may include steps S12210 and S12220, wherein:
[0104] Step S12210: Obtain the region of interest parameters including the region of interest location information.
[0105] The region of interest parameters may include the coordinates of a reference point of the region of interest and the height and width of the region of interest. Taking the region of interest as a rectangle as an example, the reference point may be a vertex of the region of interest, or the center or other point of the region of interest, as long as the region of interest can be determined in the target sample image.
[0106] In addition, the region of interest parameters can be obtained simultaneously with the above-mentioned training samples and sample labels, that is, step S12210 can be executed simultaneously with step S110.
[0107] Step S12220: determine a region of interest in the target sample image according to the region of interest parameters.
[0108] Based on the region of interest parameters obtained in step S12210, the region of interest can be screened out in the target sample image. For example, based on opencv, the region of interest can be screened out in the target sample image according to the region of interest parameters.
[0109] Step S1230: Perform line segment detection on the region of interest of the target sample image to obtain a line segment detection result, wherein the line segment detection result includes the endpoint coordinates of each detected line segment.
[0110] The endpoint coordinates include the horizontal coordinate and the vertical coordinate in a reference coordinate system. The LSD line segment detection algorithm of opencv can be used to perform line segment detection on the region of interest of the target sample image, detect the endpoint coordinates of each line segment in the region of interest, and obtain the line segment detection result containing the coordinates of each endpoint. Of course, the Hough transform method or other methods can also be used to implement line segment detection, as long as the endpoint coordinates of each line segment can be obtained.
[0111] Step S1240: Generate a line segment detection image according to the line segment detection result.
[0112] A target line segment may be generated according to the endpoint coordinates of each line segment in the line segment detection result, and a line segment detection image including one or more target line segments may be obtained.
[0113] In some embodiments of the present disclosure, generating a line segment detection image according to the line segment detection result, that is, step S1240, may include steps S12410 to S12430, wherein:
[0114] Step S12410: Determine the length of each line segment detected in the target sample image according to the line segment detection result.
[0115] The length of the corresponding line segment can be determined according to the coordinates of each endpoint of the line segment detection result, that is, the distance between two endpoints belonging to the same line segment, and the distance can be represented by the number of pixels. For example, for the coordinates of two endpoints belonging to the same line segment, the two endpoint coordinates both include the horizontal coordinate and the vertical coordinate in the reference coordinate system.
[0116] Step S12420: Filter out line segments whose lengths are within a length threshold range as reference line segments, and use the endpoint coordinates of the reference line segments as reference endpoint coordinates.
[0117] The length threshold range has an upper limit and a lower limit. The length of each line segment can be compared with the upper limit and the lower limit of the length threshold range, and the endpoint coordinates of the line segment whose length is not less than the lower limit and not greater than the upper limit are screened out as reference endpoint coordinates, that is, the endpoint coordinates of the line segment whose length is within the length threshold range are screened out as reference endpoint coordinates, so as to remove line segments that are too small and too large in length. The size of the length threshold range can be pre-set depending on the resolution of the target sample image and the actual size of the routing, and is not specifically limited here. The purpose is to remove non-routing line segments, that is, to remove noise. For example, in some embodiments of the present disclosure, the length threshold range can be 30-100.
[0118] Step S12430: Generate a line segment detection image according to the reference endpoint coordinates of the reference line segment.
[0119] In some embodiments of the present disclosure, generating a line segment detection image according to the reference endpoint coordinates of the reference line segment, that is, step S12430, may include step S124310 and step S124320, wherein:
[0120] Step S124310: Generate a line connecting the two endpoints of each reference line segment according to the reference endpoint coordinates of the reference line segment to obtain one or more target line segments.
[0121] For each selected reference line segment, a line connecting the two endpoints is generated to obtain a target line segment, that is, each target line segment includes two reference endpoints and a line between the reference endpoints. The reference line segment and the target line segment may completely overlap or only partially overlap. If there are multiple reference line segments, each reference line segment can be selected in turn according to a preset order, and multiple target line segments corresponding to each reference line segment can be generated.
[0122] For example, each reference line segment may be numbered, and different reference line segments may have different numbers, so that they may be sorted according to the number size, thereby determining the order of selecting the reference line segments. The number may be a positive integer, such as 1, 2, 3, etc. Among them, the line between the two reference endpoints may be generated based on the line function of opencv. Of course, other functions or algorithms may also be used to generate the target line segment.
[0123] Step S124320, setting a pixel value for each target line segment, and the pixel value of the same target line segment is the same, so as to obtain a line segment detection image containing multiple target line segments; if the number of the target line segments is multiple, the pixel values of different target line segments are different.
[0124] For multiple target line segments, in order to distinguish each of the target line segments, different pixel values may be assigned to different target line segments, and the pixel value may be a grayscale. For example, for any target line segment, the number of the reference line segment corresponding to its endpoint may be used as the pixel value of the target line segment, so that the grayscale of each pixel point of the target line segment is equal to the number.
[0125] Step S1250: acquiring line segment edge features of edge points according to the line segment detection image as line segment edge features of the sample image, wherein the line segment edge features of each edge point include the coordinates of the edge point and the slope of the line segment to which it belongs.
[0126] like Figure 4 As shown, in some embodiments of the present disclosure, the line segment edge features of the edge points are obtained according to the line segment detection image as the line segment edge features of the sample image; that is, step S1250 may include steps S12510 to S12540, wherein:
[0127] Step S12510, determine the total number of edge points of the target line segment in the line segment detection image, and obtain the line segment edge features of each edge point of the target line segment; the line segment edge features of each edge point include the coordinates of the edge point and the slope of the target line segment to which it belongs.
[0128] The slope of the line segment to which the edge point belongs refers to the slope of the target line segment to which the edge point belongs. In each target line segment, the line segment edge feature of each edge point includes the coordinates of the edge point and the slope of the target line segment to which it belongs. The coordinates of each edge point include the horizontal coordinate and the vertical coordinate of the edge point in the reference coordinate system. The slope of the target line segment can be represented by the angle between the target line segment and the horizontal coordinate axis.
[0129] Step S12520: compare the total number of edge points of the target line segment in the line segment detection image with a quantity threshold.
[0130] In order to limit the number of edge points and reduce the amount of calculation, the total number of edge points of all target line segments may be compared with a quantity threshold. The value of the quantity threshold is not particularly limited herein, for example, the quantity threshold may be 1000.
[0131] Step S12530: If the total number of edge points of the target line segment in the line segment detection image is not greater than the quantity threshold, the line segment edge feature of each edge point is used as the line segment edge feature of the sample image.
[0132] If the number of edge points is less than or equal to the number threshold, the line segment edge features of each edge point can be directly used as training features to train the classification model.
[0133] Step S12540: If the total number of edge points of the target line segment in the line segment detection image is greater than the quantity threshold, the line segment detection image is downsampled at a preset sampling ratio, and the line segment edge features of the edge points of the target line segment in the downsampled line segment detection image are used as the line segment edge features of the sample image. The sampling ratio is the ratio of the quantity threshold to the total number of edge points of the line segment detection image before downsampling.
[0134] If the number of edge points is greater than the quantity threshold, it means that the number of edge points is too large. Therefore, the line segment detection image can be downsampled to reduce the number of edge points. The sampling ratio adopts the ratio of the quantity threshold to the total number of edge points of the line segment detection image before downsampling, which can ensure that the number of edge points after downsampling is less than or equal to the quantity threshold.
[0135] In some embodiments of the present disclosure, downsampling the line segment detection image at a preset sampling ratio, that is, step S12540, may include steps S125410 to S125430, wherein:
[0136] Step S125410, obtaining the coordinates of the pixel points of the target line segment in the line segment detection image and the slope of the target line segment to which it belongs.
[0137] Step S125420, determine the floating-point coordinates of the pixel points of the target line segment and the floating-point slope of the target line segment according to a preset sampling ratio, the coordinates of the pixel points of the target line segment and the slope of the target line segment; the sampling ratio is the ratio of the quantity threshold to the total number of edge points of the line segment detection image before downsampling.
[0138] Step S125430: Determine the line segment edge features of the edge points of the target line segment in the downsampled line segment detection image according to the floating-point coordinates and the floating-point slope of the target line segment.
[0139] Further, for example:
[0140] Create three two-dimensional arrays arr_sum_x, arr_count_x; arr_sum_y, arr_count_y; arr_sum_a, arr_count_a with the same width and height as the line segment detection image. The data type of each two-dimensional array is floating point type and is initialized to 0.
[0141] The horizontal coordinate j, the vertical coordinate i and the slope of the target line segment to which each pixel of the line segment detection image belongs are traversed in a preset order. The slope can be represented by the angle a between the pixel and the horizontal coordinate axis.
[0142] The floating-point coordinates of the downsampled pixel are calculated according to the sampling ratio, the floating-point coordinates x_float = j × ratio, the floating-point coordinates y_float = i × ratio, ratio is the sampling ratio, ratio = threshod / n, n> threshod, threshod is the number threshold, n is the number of edge points of the line segment detection image before downsampling, 1> ratio> 0. The floating-point coordinates can be rounded to get: x_int = int (x_float + 0.5), y_int = int (y_float + 0.5), add x_float to the value of the corresponding position of arr_sum_x, add y_float to the value of the corresponding position of arr_sum_y, add a to the value of the corresponding position of arr_sum_a, and add 1 to the values of the corresponding positions of arr_count_x, arr_count_y, and arr_count_a, respectively.
[0143] Traverse to obtain the horizontal coordinate j and vertical coordinate i of the pixel point of the reference image. If arr_count[i][j] is greater than 0, the floating-point coordinates of the edge point of the reference image can be calculated, thereby obtaining the line segment edge features of the edge point, where:
[0144] x2_float=arr_sum_x[i][j] / arr_count[i][j];
[0145] y2_float=arr_sum_y[i][j] / arr_count[i][j];
[0146] a2_float=arr_sum_a[i][j] / arr_count[i][j].
[0147] x2_float is the floating-point horizontal coordinate of the pixel, y2_float is the floating-point vertical coordinate of the pixel, and a2_float is the floating-point slope of the pixel.
[0148] In step S130, training features are generated according to the line segment edge features.
[0149] The line segment edge features of the edge point can be normalized to obtain training features. For example, the horizontal coordinate of the edge point can be divided by the width of the line segment detection image; the vertical coordinate can be divided by the height of the line segment detection image; the slope of the target line segment to which the edge point belongs is represented by the angle between the target line segment to which the edge point belongs and the horizontal coordinate axis. If the angle is radians, the angle can be divided by π, and π can be 3.1416.
[0150] In step S140, a preset classification model is trained according to the sample labels and the training features to obtain a routing detection model.
[0151] The classification model can use a support vector machine model (SVM). Alternatively, deep learning point cloud classification technology can also be used to use a PointNet network model or other convolutional neural network model with classification function as a classification model, and the training features are used as point cloud data for training. The routing detection model can be used to judge whether the routing is standardized and output a standardized or non-standard result. For example, different numbers (such as 1 and 0) can be output to represent standard and non-standard.
[0152] In some embodiments of the present disclosure, if there are multiple sample images, the above steps S120 to S130 can be performed on each sample image to obtain the training features of each sample image, that is, multiple training features, and the specific details are not repeated here. At the same time, the number of sample labels is also multiple, and corresponds to the sample images one by one. Accordingly, the classification model can be trained according to the training features and sample labels of each sample image to obtain a line detection model.
[0153] The present disclosure provides a training device for a line detection model. Figure 5 As shown, the training device may include an acquisition unit 1, a detection unit 2, a processing unit 3 and a generation unit 4, wherein:
[0154] The acquisition unit 1 is configured to: acquire a sample image and a sample label of the sample image;
[0155] The detection unit 2 is configured to: perform line segment detection on the sample image and obtain line segment edge features of the sample image;
[0156] The processing unit 3 is configured to: generate training features according to the line segment edge features;
[0157] The generating unit 4 is configured to: train the classification model according to the sample labels and the training features to obtain a routing detection model.
[0158] The details and beneficial effects of each part of the training device in the embodiment of the present disclosure have been described in detail in the embodiment of the training method above, and will not be described in detail here.
[0159] The present disclosure also provides a wiring detection method. Figure 6 As shown, the wiring detection method includes steps S210 to S230, wherein:
[0160] Step S210, obtaining an image to be detected;
[0161] Step S220, performing line segment detection on the image to be detected, and obtaining line segment edge features of the image to be detected;
[0162] Step S230: input the line segment edge feature into the line detection model to obtain a detection result, and determine whether the image to be detected is normal according to the detection result.
[0163] The following is a detailed description of the disclosed routing detection method:
[0164] In step S210, an image to be detected is obtained.
[0165] The image to be inspected may be an image of a wiring area of an electronic device, which may be obtained by photographing with a photographic device such as an industrial camera.
[0166] In step S220, line segment detection is performed on the image to be detected, and line segment edge features of the image to be detected are obtained.
[0167] like Figure 7 As shown, in some embodiments of the present disclosure, line segment detection is performed on each of the images to be detected, that is, step S220, which may include steps S2210 to S2250, wherein:
[0168] Step S2210, preprocessing the image to be detected to obtain a target image to be detected;
[0169] Step S2220, determining a region of interest in the target image to be detected;
[0170] Step S2230, performing line segment detection on the region of interest of the target image to be detected to obtain a line segment detection result of the image to be detected, wherein the line segment detection result includes the endpoint coordinates of each detected line segment;
[0171] Step S2240, generating a line segment detection image according to each of the line segment detection results;
[0172] Step S2250: acquiring line segment edge features of edge points in the line segment detection image as line segment edge features of the image to be detected; the line segment edge features of each edge point include the coordinates of the edge point and the slope of the line segment to which it belongs.
[0173] The method for performing line segment detection on the image to be detected can be the same as the method for performing line segment detection on the sample image, as long as the sample image is replaced by the image to be detected. Therefore, the specific details can be referred to the implementation method of performing line segment detection on the sample image above, and will not be repeated here.
[0174] In step S230, the line segment edge feature is input into a line detection model to obtain a detection result, and whether the image to be detected is normal is determined according to the detection result.
[0175] The routing detection model in this embodiment can use the training method of the routing detection model in any implementation mode described above to generate the routing detection model. For details, please refer to the implementation mode of the training method described above, which will not be repeated here.
[0176] The routing detection model can be used to determine whether the routing is standard and output a standard or non-standard result. For example, different numbers (such as 1 and 0) can be output to represent standard and non-standard.
[0177] It should be noted that, although the steps of the method in the present disclosure are described in a specific order in the drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps, etc.
[0178] The present disclosure provides a wiring detection device, such as Figure 8 As shown, the line detection device may include an image acquisition device 100, a memory 200 and a processor 300, wherein:
[0179] The image acquisition device 100 is configured to: capture an image to be detected;
[0180] The memory 200 is configured to: store executable instructions;
[0181] The processor 300 is coupled to the image acquisition device 100 and the memory 200, and the processor 300 is configured to: obtain the image to be detected from the image acquisition device 100, and obtain the executable instructions from the memory 200; and the processor 300 is configured to: execute the routing detection method of any of the above-mentioned embodiments by executing the executable instructions, thereby outputting a result of whether the routing is standardized.
[0182] The details and beneficial effects of each part of the routing detection device in the embodiment of the present disclosure have been described in detail in the embodiment of the routing detection method above, and will not be described in detail here.
[0183] It should be noted that although several devices of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more devices, modules, units or circuits described above can be embodied in one device, module, unit or circuit. Conversely, the features and functions of one device, module, unit or circuit described above can be further divided into multiple devices, modules, units or circuits.
[0184] The disclosed embodiments also provide a non-transitory readable storage medium having a computer program stored thereon, which, when executed, implements the training method of the routing detection model of any of the above-mentioned embodiments, or implements the routing detection method of any of the above-mentioned embodiments. In some embodiments, various aspects of the present invention may also be implemented in the form of a program product, which includes a program code, and when the program product is run on a terminal device, the program code is used to cause the terminal device to execute the steps of various exemplary embodiments of the present invention described in the above-mentioned training method of this specification.
[0185] like Fig. 9 As shown, a program product for implementing the above training method according to an embodiment of the present invention is described, which can adopt a portable compact disk read-only memory (CD-ROM) and include program code, and can be run on a terminal device, such as a personal computer. However, the program product of the present invention is not limited thereto, and in this document, the non-transitory readable storage medium 500 can be any tangible medium containing or storing a program, which can be used by or in combination with an instruction execution system, an apparatus or a device.
[0186] The program product may adopt any combination of one or more readable media. The readable medium may be a non-transient readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, a system, device or device of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination thereof. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof.
[0187] Computer readable signal media may include data signals propagated in baseband or as part of a carrier wave, in which readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Readable signal media may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0188] The program code embodied on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the foregoing.
[0189] Program code for performing the operations of the present invention may be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., through the Internet using an Internet service provider).
[0190] Through the description of the above implementation methods, it is easy for those skilled in the art to understand that the example implementation methods described here can be implemented by software or by combining software with necessary hardware. Therefore, the technical solution according to the implementation methods of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which can be a personal computer, a server, a mobile terminal, or a network device, etc.) to execute the method according to the implementation methods of the present disclosure.
[0191] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any modification, use or adaptation of the present disclosure, which follows the general principles of the present disclosure and includes common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present disclosure are indicated by the appended claims.
Claims
1. A training method for a routing detection model, characterized in that: include: Obtaining a sample image and a sample label of the sample image; Performing line segment detection on the sample image and acquiring line segment edge features of the sample image; Generate training features according to the line segment edge features; The classification model is trained according to the sample labels and the training features to obtain a routing detection model; The performing line segment detection on the sample image and obtaining line segment edge features of the sample image includes: Preprocessing the sample image to obtain a target sample image; Determining a region of interest in the target sample image; Performing line segment detection on the region of interest of the target sample image to obtain a line segment detection result, wherein the line segment detection result includes the coordinates of the endpoints of each detected line segment; Generate a line segment detection image according to the line segment detection result; The line segment edge features of the edge points are acquired according to the line segment detection image as the line segment edge features of the sample image; the line segment edge features of each edge point include the coordinates of the edge point and the slope of the line segment to which it belongs.
2. The training method according to claim 1, characterized in that: The preprocessing of the sample image to obtain a target sample image includes: Get a standard image; registering the sample image according to the standard image; The registered sample image is down-sampled to obtain a target sample image.
3. The training method according to claim 1, characterized in that: The determining of the region of interest in the target sample image comprises: Get the region of interest parameters including the location information of the region of interest; A region of interest is determined in the target sample image according to the region of interest parameters.
4. The training method according to claim 1, characterized in that: The generating a line segment detection image according to the line segment detection result comprises: Determine the length of each line segment detected in the target sample image according to the line segment detection result; Screening out line segments whose lengths are within a length threshold range as reference line segments, and using the endpoint coordinates of the reference line segments as reference endpoint coordinates; A line segment detection image is generated according to the reference endpoint coordinates of the reference line segment.
5. The training method according to claim 4, characterized in that: The step of generating a line segment detection image according to the reference endpoint coordinates of the reference line segment comprises: Generate a line connecting two endpoints of each reference line segment according to the reference endpoint coordinates of the reference line segment to obtain one or more target line segments; A pixel value is set for each target line segment, and the pixel value of the same target line segment is the same, so as to obtain a line segment detection image containing one or more target line segments; if there are multiple target line segments, the pixel values of different target line segments are different.
6. The training method according to claim 5, characterized in that: Acquiring line segment edge features of edge points according to the line segment detection image as line segment edge features of the sample image includes: Determine the total number of edge points of the target line segment in the line segment detection image, and obtain the line segment edge feature of each edge point of the target line segment; the line segment edge feature of each edge point includes the coordinates of the edge point and the slope of the target line segment to which it belongs; Compare the total number of edge points of the target line segment in the line segment detection image with a quantity threshold; If the total number of edge points of the target line segment in the line segment detection image is not greater than the quantity threshold, taking the line segment edge feature of each edge point as the line segment edge feature of the sample image; If the total number of edge points of the target line segment in the line segment detection image is greater than the quantity threshold, the line segment detection image is downsampled at a preset sampling ratio, and the line segment edge features of the edge points of the target line segment in the downsampled line segment detection image are used as the line segment edge features of the sample image, and the sampling ratio is the ratio of the quantity threshold to the number of edge points of the line segment detection image before downsampling.
7. The training method according to claim 6, characterized in that: Downsampling the line segment detection image at a preset sampling ratio includes: Obtaining the coordinates of the pixel points of the target line segment in the line segment detection image and the slope of the target line segment to which it belongs; Determine the floating-point coordinates of the pixel points of the target line segment and the floating-point slope of the target line segment according to a preset sampling ratio, the coordinates of the pixel points of the target line segment and the slope of the target line segment; the sampling ratio is the ratio of the number threshold to the total number of edge points of the line segment detection image before downsampling; Determine a line segment edge feature of the edge point of the target line segment in the downsampled line segment detection image according to the floating-point coordinates and the floating-point slope of the target line segment.
8. The training method according to any one of claims 1 to 7, characterized in that: The step of generating the training feature according to the line segment edge feature comprises: The line segment edge features are normalized to obtain training features.
9. The training method according to any one of claims 1 to 7, characterized in that: The classification model is a support vector machine model or a convolutional neural network model.
10. A wiring detection method, characterized in that: include: Acquire the image to be detected; Performing line segment detection on the image to be detected, and obtaining line segment edge features of the image to be detected; Inputting the line segment edge features into a line detection model to obtain a detection result, and determining whether the image to be detected is normal according to the detection result; Performing line segment detection on the image to be detected, comprising: Preprocessing the image to be detected to obtain a target image to be detected; Determining a region of interest in the target image to be detected; Performing line segment detection on the region of interest of the target image to be detected to obtain a line segment detection result of the image to be detected, wherein the line segment detection result includes the endpoint coordinates of each detected line segment; Generate a line segment detection image according to each of the line segment detection results; The line segment edge features of the edge points are acquired according to the line segment detection image as the line segment edge features of the image to be detected; the line segment edge features of each edge point include the coordinates of the edge point and the slope of the line segment to which it belongs.
11. A wiring detection device, characterized in that: include: The image acquisition device is configured to: acquire an image to be detected; A memory configured to: store executable instructions; A processor is coupled to the image acquisition device and the memory, and the processor is configured to: acquire the image to be detected and the executable instruction, and execute the line detection method according to claim 10 by executing the executable instruction.
12. A non-transitory readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed, the training method described in any one of claims 1 to 9 is implemented, or when the computer program is executed, the routing detection method described in claim 10 is implemented.
Citation Information
Patent Citations
Image quality detection method and device, and storage medium
CN109376628A
Shielding image detection method and device, electronic equipment and storage medium
CN111046956A