Size detection method and device, electronic equipment and readable storage medium
By using an image quality detection model to screen qualified images and a metrological model to detect hole size, the problems of low detection efficiency and wear in existing technologies are solved, and fast and accurate hole size detection is achieved.
Patent Information
- Application Number
- CN202210885292.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-26
- Publication Date
- 2026-02-10
- Estimated Expiration
- 2042-07-26
AI Technical Summary
In existing technologies, hole size detection is inefficient and can easily cause wear and tear on materials.
An image quality detection model is used to detect the quality of the image to be processed. If the image is qualified, a measurement model is used to detect its size. Feature extraction and fusion processing are used to improve the accuracy and efficiency of the detection.
It improves testing speed and efficiency, avoids material wear, and ensures the accuracy of test results.
Smart Images

Figure CN115205273B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of measurement, in particular to a size detection method, a size detection device, an electronic device and a computer readable storage medium. BACKGROUND
[0002] At present, various electronic devices, mechanical devices and the like are increasingly precise, and the size of the holes thereon also needs to be more accurate. Generally, after the material is drilled, whether the size of the hole meets the requirements is measured by manual measurement, however, the detection efficiency of this method is low, the speed is slow, and wear is easy to occur. SUMMARY
[0003] Therefore, the purpose of the present application is to provide a size detection method, a size detection device, an electronic device and a computer readable storage medium, to improve the detection speed and efficiency, and to avoid wear on the material.
[0004] To solve the above technical problems, the present application provides a size detection method, comprising:
[0005] obtaining a to-be-processed image;
[0006] detecting the quality of the to-be-processed image by using an image quality detection model to obtain a detection result;
[0007] if the detection result is qualified, detecting the size of a target object in the to-be-processed image by using a measurement model to obtain a corresponding size detection result.
[0008] Optionally, the detection of the quality of the to-be-processed image by using the image quality detection model to obtain the detection result comprises:
[0009] performing feature extraction processing on the to-be-processed image to obtain at least two types of image features;
[0010] generating feature weights corresponding to each type of image feature respectively;
[0011] performing feature fusion processing on each type of image feature based on the feature weights to obtain a fused feature;
[0012] performing classification processing on the fused feature by using the image quality detection model to obtain the detection result.
[0013] Optionally, the generation of the feature weights corresponding to each type of image feature respectively comprises:
[0014] generating feature information gain corresponding to each type of image feature respectively;
[0015] The feature weight corresponding to each type of image feature is obtained by using the feature information gain based on a rule that the feature information gain is negatively correlated with the feature weight.
[0016] Optionally, the size of the target object in the to-be-processed image is detected by using the metrology model to obtain a corresponding size detection result, including:
[0017] The to-be-measured region of the to-be-processed image is detected to obtain a to-be-measured region including the target object.
[0018] The size of the target object in the to-be-measured region is detected by using the metrology model to obtain the size detection result.
[0019] Optionally, the to-be-measured region of the to-be-processed image is detected to obtain a to-be-measured region including the target object, including:
[0020] The to-be-processed image is binarized to obtain a binarized image.
[0021] The preset object feature data corresponding to the target object is obtained, and the binarized image is detected based on the preset object feature data to obtain a detection result.
[0022] If the detection result is a hit, a to-be-measured region is obtained.
[0023] If the detection result is a miss, a preset shape template corresponding to the target object is obtained, and the binarized image is processed by shape matching based on the preset shape template to obtain the to-be-measured region.
[0024] Optionally, the size of the target object in the to-be-measured region is detected by using the metrology model to obtain the size detection result, including:
[0025] The coordinate data corresponding to the target object is obtained.
[0026] A target metrology model is determined based on the shape type of the target object.
[0027] The to-be-measured region is measured based on the coordinate data by using the target metrology model to obtain a size detection result corresponding to the target object.
[0028] Optionally, the target metrology model is determined based on the shape type of the target object, including:
[0029] The shape type is determined based on the data format of the coordinate data.
[0030] The target metrology model is obtained based on a corresponding relationship between the shape type and the metrology model.
[0031] Optionally, the measurement processing of the to-be-measured region based on the coordinate data by using the target metrology model to obtain the size detection result corresponding to the target object comprises:
[0032] inputting the coordinate data and the to-be-measured region into the target metrology model to obtain an initial detection result;
[0033] obtaining a preset standard result and a preset tolerance range;
[0034] obtaining a detection difference value by using the initial detection result and the preset standard result, and determining whether the detection difference value is in the preset tolerance range;
[0035] if the detection difference value is in the preset tolerance range, determining that the size detection result is qualified;
[0036] if the detection difference value is not in the preset tolerance range, updating the coordinate data, and obtaining the size detection result by using the target metrology model and the updated coordinate data.
[0037] Optionally, the updating of the coordinate data and the obtaining of the size detection result by using the target metrology model and the updated coordinate data comprise:
[0038] obtaining an update instruction, and updating the coordinate data based on the update instruction to obtain the target coordinate data;
[0039] inputting the target coordinate data and the to-be-measured region into the target metrology model to obtain a re-judgment detection result;
[0040] if the re-judgment detection result is in the preset tolerance range, determining that the size detection result is qualified;
[0041] if the re-judgment detection result is not in the preset tolerance range, determining that the size detection result is unqualified.
[0042] Optionally, the inputting of the coordinate data and the to-be-measured region into the target metrology model to obtain an initial detection result comprises:
[0043] determining a standard graph based on the coordinate data by using the target metrology model;
[0044] constructing a plurality of adjacent rectangular detection units based on each edge of the standard graph respectively, and superimposing the standard graph and the to-be-measured region;
[0045] Determine target coordinates of the plurality of rectangular detection units, and obtain the initial detection result based on the target coordinates; wherein the target coordinates are coordinates corresponding to the boundary of the target object in the rectangular detection unit.
[0046] Optionally, the determining the target coordinates of the plurality of rectangular detection units, and obtaining the initial detection result based on the target coordinates comprises:
[0047] Segmenting the boundary of the target object using each of the rectangular detection units to obtain target boundaries in each of the rectangular detection units;
[0048] Determining the center coordinates of the target boundaries as initial target coordinates;
[0049] Performing outlier deletion processing on the initial target coordinates to obtain the target coordinates;
[0050] Performing graph fitting based on the target coordinates to obtain a fitted graph, and measuring the fitted graph to obtain the initial detection result.
[0051] The application further provides a size detection device, comprising:
[0052] An acquisition module configured to acquire a to-be-processed image;
[0053] A quality detection module configured to perform quality detection on the to-be-processed image using an image quality detection model to obtain a detection result;
[0054] A size detection module configured to perform size detection on a target object in the to-be-processed image using a metrology model to obtain a corresponding size detection result if the detection result is qualified.
[0055] The application further provides an electronic device comprising a memory and a processor, wherein:
[0056] The memory is configured to save a computer program;
[0057] The processor is configured to execute the computer program to implement the size detection method described above.
[0058] The application further provides a computer-readable storage medium configured to save a computer program, wherein the computer program is executed by a processor to implement the size detection method described above.
[0059] The size detection method provided by the application comprises the following steps: acquiring a to-be-processed image; performing quality detection on the to-be-processed image using an image quality detection model to obtain a detection result; and performing size detection on a target object in the to-be-processed image using a metrology model to obtain a corresponding size detection result if the detection result is qualified.
[0060] It can be seen that the method obtains the corresponding to-be-processed image of the material to be measured, judges whether the quality of the to-be-processed image is qualified, and then determines whether the to-be-processed image can be accurately detected. If the detection result is qualified, it indicates that the quality of the to-be-processed image is good, and accurate size detection results can be obtained by detecting the to-be-processed image, and therefore the target object to be detected is detected. By setting the image quality detection model, the size detection of the to-be-processed image can be avoided when the quality of the to-be-processed image is poor, thereby improving the detection efficiency and reducing the consumption of computing resources. By using the measurement model to automatically detect the target object on the to-be-processed image, the detection speed can be improved, thereby improving the detection efficiency and avoiding the abrasion of the material.
[0061] In addition, the application also provides a size detection device, an electronic device and a computer readable storage medium, which also have the above beneficial effects. BRIEF DESCRIPTION OF DRAWINGS
[0062] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related art, the drawings needed to be used in the embodiments or the related art description will be briefly introduced. Obviously, the drawings in the following description are only embodiments of the present application, and for those skilled in the art, other drawings can be obtained without creative labor on the basis of the provided drawings.
[0063] Figure 1 A structural schematic diagram of an electronic device provided by an embodiment of the present application;
[0064] Figure 2 A flowchart of a size detection method provided by an embodiment of the present application;
[0065] Figure 3 An effect comparison diagram of connected region detection and shape matching provided by an embodiment of the present application;
[0066] Figure 4 A straight line size detection process diagram provided by an embodiment of the present application;
[0067] Figure 5 A rectangular size detection process diagram provided by an embodiment of the present application;
[0068] Figure 6 A circular size detection process diagram provided by an embodiment of the present application;
[0069] Figure 7 A structural schematic diagram of a size detection device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0070] In order to make the purposes, technical solutions, and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the protection scope of the present application.
[0071] Each step in the present application can be performed by a designated electronic device, which is not limited in form, for example, can be a general-purpose computing device such as a computer or a server. Please refer to Figure 1 , Figure 1 A structural schematic diagram of an electronic device provided by the embodiments of the present application is shown. The electronic device 100 can include a processor 101 and a memory 102, and can further include one or more of a multimedia component 103, an information input / output (I / O) interface 104, and a communication component 105.
[0072] The processor 101 is configured to control the overall operation of the electronic device 100 to complete all or part of the steps of the size detection method described above; the memory 102 is configured to store various types of data to support the operation of the electronic device 100, which can include, for example, instructions for operating any application or method on the electronic device 100, and application-related data. The memory 102 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as one or more of a static random access memory (SRAM), an electrically erasable programmable read-only memory (EEPROM), an erasable programmable read-only memory (EPROM), a programmable read-only memory (PROM), a read-only memory (ROM), a magnetic memory, a flash memory, a magnetic disk, or an optical disk.
[0073] The multimedia component 103 can include a screen and an audio component. The screen can be, for example, a touch screen. The audio component is configured to output and / or input audio signals. For example, the audio component can include a microphone configured to receive an external audio signal. The received audio signal can be further stored in the memory 102 or transmitted through the communication component 105. The audio component also includes at least one speaker configured to output audio signals.
[0074] The electronic device 100 can be implemented by one or more application specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, micro-controllers, microprocessors, or other electronic elements for performing the size detection method proposed in the present application.
[0075] In a specific embodiment, the electronic device described above can have a material loading component, a detection component, and a control component. The control component can be the processor 101 described above, and the detection component can be connected to other components such as the control component through the I / O interface 104 described above. The material loading component is used to load materials waiting to be subjected to size detection, and can specifically have a plurality of jigs. The control component can specifically consist of a motion control card, an industrial computer, and a display. The industrial computer can control the detection component to move to the detection position of the material through the motion control card, and can also control the plurality of jigs of the material loading component to receive detection in turn. Specifically, the material is placed on the material loading component, and then moved to the detection position by the control component. The detection component takes pictures online through the camera and the like, and then calculates and analyzes based on the size detection method of the present application to obtain the size detection result. Finally, the size detection result is fed back to the control component. The control component can further visually display the size detection result, and can also give an alarm when necessary, for example, if the detection result is not within the tolerance range of the material.
[0076] Please refer to Figure 2 , Figure 2 A flowchart of a size detection method provided by an embodiment of the present application. The method comprises:
[0077] S201: Obtain a to-be-processed image.
[0078] The to-be-processed image refers to an image obtained after image acquisition of a material that needs to be subjected to size detection processing. The specific content of the to-be-processed image is not limited, for example, it can be an image of good quality that clearly records the shape of the material, or an image of poor quality that does not clearly record the shape of the material due to interference factors such as light and foreign matter obstruction. The to-be-processed image can be obtained in real time, for example, it can be obtained by real-time photography of the material using an image acquisition component such as a camera, or it can be an image obtained by pre-acquisition. The number of to-be-processed images can be one or more, and the specific number is not limited.
[0079] S202: Use an image quality detection model to detect the quality of the to-be-processed image, and obtain a detection result.
[0080] The image quality detection model refers to a network model capable of evaluating the quality of a to-be-processed image. In this application, the quality of the to-be-processed image refers to whether the to-be-processed image clearly records the shape of the material. The clear shape of the material usually refers to a complete shape and a clear boundary. In addition, the clear shape of the material can be further required according to needs. The image quality detection model is trained via training images and reaches convergence, and has the ability to distinguish whether the image quality is good. Therefore, suitable training images can be selected and assigned with good or poor training labels, so that the image quality detection model learns how to distinguish good and poor in the training process. The selection and labeling process of the training images can be performed manually, or can be automatically labeled by using a labeling network model capable of automatic image labeling. It should be noted that the specific type and structure of the image quality detection model are not limited.
[0081] The image quality detection model can be regarded as a filter for filtering the to-be-processed image based on the image quality. When it considers that the quality of the to-be-processed image is good, it can output a qualified detection result, and then perform subsequent steps on the to-be-processed image. When it considers that the quality of the to-be-processed image is poor, it can output an unqualified detection result and filter it out. Through this filtering process, subsequent steps can be avoided for to-be-processed images with poor quality. It can be understood that if the image quality is poor, the accuracy and reliability of the size detection result obtained after the subsequent steps are performed cannot be guaranteed, which causes waste of computing resources and low detection efficiency.
[0082] The embodiment does not limit the specific training process of the image quality detection model. The training process of the image quality detection model is different according to different model structures and other factors. Generally, the training process of the model is the same as the processing process of the input data in the use process. The difference lies in that, in the training process, after obtaining the prediction result of the model, the prediction result and the training label of the training data are used to iteratively update the model parameters, and the model learns how to judge whether the quality of the to-be-processed image is qualified, i.e., whether it is good, in the process of parameter iteration. In addition, the training process can be one-time training or multiple-time training. For example, the image quality detection model can be additionally trained according to a period, or the image quality detection model can be additionally trained when the data in the training database is updated.
[0083] Specifically, in one embodiment, the model can extract features from the input image by itself. In another embodiment, the model does not perform feature extraction, and in this case, the to-be-processed image input into the model needs to be extracted. In order to provide more information for the image quality detection model to make more accurate judgments, different types of image features can be extracted from multiple angles. In this case, the generation process of the detection result can include the following steps:
[0084] Step 11: performing feature extraction processing on the image to be processed to obtain at least two types of image features;
[0085] Step 12: generating feature weights corresponding to each type of image feature respectively;
[0086] Step 13: performing feature fusion processing on each type of image feature based on the feature weights to obtain a fused feature;
[0087] Step 14: performing classification processing on the fused feature using an image quality detection model to obtain a detection result.
[0088] The feature extraction processing can extract image features of the image to be processed from at least two different types of factors, and the specific type of the image features is not limited, for example, it can be shape features, gray level features, gradient direction features, etc. The feature extraction processing methods corresponding to different types of image features can be different, for example, they can include image gray level long strip acquisition, binary processing, manual marking, etc.
[0089] Different types of image features can reflect the quality of the image to be processed from different angles, and by fusing them, comprehensive information compatible with various types of information, i.e., a fused feature, can be obtained. It can be understood that different types of image features have different representation abilities for the quality of the image, in order to highlight the features with relatively strong representation abilities and weaken the features with relatively weak representation abilities, feature weights can be generated for each type of image feature, and the feature weights are used to represent the representation ability of the corresponding image feature for the quality of the image. Based on the feature weights, the feature fusion of each type of image feature can obtain a fused feature. The fused feature is input into the image quality detection model, so that the image quality detection model outputs a detection result according to the input information. The specific implementation of the feature fusion is not limited in this embodiment, for example, it can be weighted summation or weighted average processing based on the feature weights.
[0090] The embodiment does not limit the generation manner of the feature weight, and in a specific implementation, the feature information gain can be used as the feature weight. Specifically, in machine learning, the entropy is used to represent the confusion degree of the distribution of a random variable, and the more confused the distribution is, the greater the entropy is. In the decision tree algorithm, the information gain is an important index for feature selection, which defines how much information a feature can bring to the classification system, and the more information brought, the more important the feature is, and the greater the information gain is. The information entropy can represent the complexity (uncertainty) of the random variable, the conditional entropy can represent the complexity (uncertainty) of the random variable under a certain condition, and the information gain is the difference between the information entropy and the conditional entropy, that is, the information gain represents the degree of reduction of the information complexity (uncertainty) under a certain condition. In the decision tree algorithm, the key is that there are multiple features, and then which feature is selected according to which standard. This problem can be measured by the information gain. If the information gain is the smallest after selecting a feature (the degree of reduction of information uncertainty is the largest), the feature can be selected.
[0091] Specifically, in the embodiment, when the information gain corresponding to a certain type of image feature is smaller, it means that the degree of reduction of information uncertainty of the type of image feature is the largest, and the type of image feature can provide more information for the image quality detection model. Therefore, first, the feature information gain corresponding to each type of image feature is generated, and based on the rule that the feature information gain is negatively correlated with the feature weight, the feature weight corresponding to each type of image feature is obtained by using the feature information gain. That is, the type of image feature with the smallest feature information gain is given the largest weight. It can be understood that the sum of all feature weights should be equal to one. For example, when there are three types of image features, the corresponding feature weights can be 0.6, 0.3 and 0.1, and the fusion feature can be obtained by feature weighting and summation.
[0092] S203: If the detection result is qualified, the metrology model is used to detect the size of the target object in the to-be-processed image to obtain a corresponding size detection result.
[0093] When the detection result is qualified, it means that the quality of the corresponding to-be-processed image is good, and the size detection result will not be unreliable. At this time, the metrology model can be used to detect the target object. The target object refers to an object in the to-be-processed image that needs to be detected in size, for example, a round hole, a square hole or an object with any shape. The specific form of the size detection result is not limited, which can be in the form of indicating whether the tolerance of the target object is in a specified interval, or in the form of the specific size of the target object.
[0094] It can be understood that, in order to detect the size of the target object, the target object needs to be located in the image to be processed first. That is, the image to be processed can be first detected to obtain a detection region including the target object, and then the target object in the detection region is detected by using the measurement model to obtain a size detection result. The embodiment is not limited to a specific detection region detection method. In an embodiment, the following method can be used:
[0095] Step 21: performing binaryzation processing on the image to be processed to obtain a binary image;
[0096] Step 22: obtaining preset object feature data corresponding to the target object, performing connected region detection on the binary image based on the preset object feature data to obtain a detection result;
[0097] Step 23: if the detection result is a hit, obtaining the detection region;
[0098] Step 24: if the detection result is a miss, obtaining a preset shape template corresponding to the target object, and performing shape matching processing on the binary image by using the preset shape template to obtain the detection region.
[0099] Specifically, the above steps 21 to 24 can be referred to as a positioning method combining blob analysis and template matching. Blob analysis in computer vision refers to identifying a connected region in an image. Specifically, blob analysis is a process of extracting and labeling connected regions from a binary image after foreground / background separation. In the present embodiment, the binary image after foreground / background separation is obtained by performing binaryzation processing on the image to be processed. The preset object feature data refers to feature data describing the shape of the target object, such as data describing the area, length, width, radius, etc. of the target object. Based on the preset object feature data, the connected region of the target object can be detected to obtain a detection result. If the detection result is a hit, it means that the connected region of the target object is found. Since the image to be processed is used to record the target object, the detected connected region can be directly determined as the target object.
[0100] If the detection result is a miss, it means that no connected region of the target object is found. In this case, the binary image can be matched by using a preset shape template. The preset shape template is a template of the specific shape of the target object. Through shape matching processing, a part with a similar or identical shape can be found in the binary image, and the position and surrounding area of the part in the image to be processed can be determined as the detection region. It should be noted that the present application does not limit the execution steps after the shape matching processing does not obtain the detection region. For example, the image to be processed can be discarded.
[0101] Please refer to Figure 3 , Figure 3 An effect comparison diagram of the connected region detection and shape matching provided by the embodiment of the present application, wherein the target object is Figure 3 The white rounded rectangle in the center of the left side is divided into two parts by the diagonal black invisible part due to reasons such as reflection. Only the connected region 1 or the connected region 2 in the image in the upper right corner can be identified by using blob analysis, but the entire rounded rectangle cannot be identified. After shape matching by using the preset shape template, it can be determined that the combined region of the connected region 1, the connected region 2 and the diagonal black invisible part in the middle matches the shape of the target object, at this time, the combined region can be determined as the target object. Figure 3
[0102] In an embodiment, after the to-be-measured region is determined, the to-be-measured region can be cropped from the to-be-processed image to obtain a to-be-measured region image, which is used for subsequent size measurement. In another embodiment, after the to-be-measured region is determined, in order to quickly identify the target object and perform size detection, the coordinate data corresponding to the target object can be obtained first, which is used to preliminarily describe the size and / or position of the target object, and can be manually input. The target metrology model is determined based on the shape type of the target object. The shape type is used to represent the specific shape of the target object, such as a circle, a rectangle, etc. Different target metrology models can be used to detect different shapes of target objects. The present embodiment does not limit the way of determining the shape type. In an embodiment, the shape type can be determined according to the type of the preset shape template used in the previous connected region detection. In another embodiment, different shapes of target objects usually need different formats of coordinate data to represent their positions. For example, a straight line can be in the format of a starting point coordinate + length, a circle is in the format of a center coordinate + radius, and a rectangle is in the format of a center coordinate + long side length + short side length. Therefore, the shape type can be determined based on the data format of the coordinate data, and then the target metrology model is obtained based on the correspondence between the shape type and the metrology model. The target metrology model is used to perform measurement processing on the to-be-measured region based on the coordinate data, and the size detection result corresponding to the target object is obtained.
[0103] In order to reduce misjudgment and improve detection accuracy, the measurement processing process can include the following steps:
[0104] Step 31: input the coordinate data and the to-be-measured region into the target metrology model to obtain an initial detection result;
[0105] Step 32: obtain a preset standard result and a preset tolerance range;
[0106] Step 33: obtaining a detection difference value by using the initial detection result and the preset standard result, and judging whether the detection difference value is in a preset tolerance range;
[0107] Step 34: if the detection difference value is in the preset tolerance range, determining that the size detection result is qualified;
[0108] Step 35: if the detection difference value is not in the preset tolerance range, updating the coordinate data, and obtaining the size detection result by using the target metrology model and the updated target coordinate data.
[0109] The preset standard result refers to a standard size of a standard part corresponding to the target object, and the preset tolerance range refers to a legal difference between the target object and the preset standard result. After the coordinate data and the to-be-measured region are input into the target metrology model, the obtained result is referred to as an initial detection result. The detection difference value is obtained by using the initial detection result and the preset standard result, and the detection difference value can represent the difference between the size of the target object and the standard size. If the difference is in the preset tolerance range, it indicates that the error range between the target object and the standard part is small, and the product is qualified, so that the size detection result can be determined as qualified. If the detection difference value is not in the preset tolerance range, in order to avoid the error caused by the coordinate data to the detection result, the coordinate data can be updated, and the target metrology model and the updated target coordinate data are used for re-determination, and the size detection result is obtained according to the re-determination result.
[0110] Specifically, in the re-determination process, the coordinate data needs to be updated to target coordinate data. In an embodiment, an update instruction can be obtained, and the coordinate data is updated based on the update instruction to obtain the target coordinate data. The update instruction can directly include new target coordinate data, or can include description data describing how to change the coordinate data. The target coordinate data and the to-be-measured region are input into the target metrology model to obtain a re-determination detection result. The generation manner of the re-determination detection result is the same as that of the initial detection result, and the specific process will be described in subsequent content. If the re-determination detection result is in the preset tolerance range, it indicates that the initial detection is misjudged, and the size detection result can be determined as qualified. If the re-determination detection result is not in the preset tolerance range, both detections are determined as unqualified, and it is considered that there is no misjudgment for unqualified, and the size detection result is determined as unqualified.
[0111] The generation process of the initial detection result and the re-determination detection result is not limited in the present application. It can be understood that if different metrology models are used, the measurement manner can also be changed. In an embodiment, a small-granularity fitting measurement manner can be used to improve the accuracy of the detection result. Specifically, the following steps are included:
[0112] Step 41: determining a standard graph based on the coordinate data by using the target metrology model;
[0113] Step 42: based on each edge of the standard graph, a plurality of adjacent rectangular detection units are constructed, and the standard graph and the to-be-measured region are superimposed;
[0114] Step 43: target coordinates of the plurality of rectangular detection units are determined, and an initial detection result is obtained based on the target coordinates.
[0115] Specifically, based on the coordinate data, the position and size of the target object can be preliminarily determined, and based on this, a standard graph of the same shape type and similar size as the target object can be generated, for example, a standard circle. The standard graph includes at least one edge, and on each edge, a plurality of adjacent rectangular detection units are constructed, that is, the edges are divided into smaller granularity by using the plurality of rectangular detection units. The standard graph is superimposed on the to-be-measured region based on the coordinate data, so that the rectangular detection units can intersect with the edges of the target object.
[0116] After superposition is completed, the target coordinates corresponding to each rectangular detection unit can be determined. The target coordinates are the coordinates corresponding to the boundary of the target object (i.e., the edge of the target object) in the rectangular detection unit, and can be specifically the center coordinates of a small section of the boundary of the target object in the rectangular detection unit, or other position coordinates. Shape fitting can be performed using the target coordinates, and the size of the fitted graph is the initial detection result. Specifically, the boundary of the target object can be segmented by using each rectangular detection unit to obtain the target boundary in each rectangular detection unit, and the center coordinates of the target boundary are determined as the initial target coordinates. In order to avoid interference, the initial target coordinates can be subjected to outlier deletion processing, and the initial target coordinates that are obviously offset are deleted to obtain the target coordinates. Based on the target coordinates, the graph is fitted, and the fitted graph is measured to obtain the initial detection result.
[0117] In an embodiment, the target object is a straight line. Please refer to Figure 4 , Figure 4 A straight line size detection process diagram provided by an embodiment of the present application. In the created measurement model, there is a data structure for storing the parameters of the to-be-measured straight line, which is the coordinate data. After determining that the target object is a straight line, a reference straight line segment is generated, which is used to be superimposed in a neighborhood of the to-be-measured straight line (such as Figure 4The first figure shows). The reference straight line segment parameters (such as starting coordinates) are passed into the metrology model to parameterize the metrology model, and then the metrology model is used to measure the to-be-measured straight line, and the specific measurement process includes: (1) generating a rectangular region (the rectangular region needs to contain the to-be-measured straight line) with the reference straight line segment as the reference; (2) equally dividing the rectangular region into a plurality of small rectangular regions (i.e., rectangular detection units) ; (3) for each small rectangular region, first performing mean filtering processing, then extracting the boundary line (i.e., the target boundary) corresponding to the to-be-measured straight line in each small rectangular region by using the gradient transformation method, and obtaining the midpoint coordinates (i.e., the initial target coordinates) of the boundary line, as shown in Figure 4 The second figure shows, where the "x" position is the midpoint of the small rectangular boundary line; (4) using the MAD (Median absolute deviation) algorithm to remove outlier center points (i.e., outlier points), and then using the least squares method to fit a straight line (such as Figure 4 The third figure shows), which can reduce the interference of noise points near the straight line. Finally, the to-be-measured straight line can be measured to obtain the detection result, for example, the starting coordinates of the detected straight line segment.
[0118] Please refer to Figure 5 , Figure 5 A rectangular size detection process diagram is provided for the embodiments of the present application. The overall process is similar, and the difference lies in that the standard graph is a rectangle, and the coordinate data can be in the form of the center coordinates of the rectangle, the offset angle, and the length and width. In addition, in the above step (3), the four sides of the rectangle need to be equally divided into a plurality of small rectangular regions (i.e., rectangular detection units, such as Figure 5 The second figure shows), according to the above straight line method, the midpoint of the target boundary in each small rectangle is found (such as Figure 5 The third figure shows), the outlier points are removed, and then the remaining midpoints are connected, and then the least squares method is used to fit the rectangle (such as Figure 5 The fourth figure), and finally the detection result can be measured, for example, the center coordinates, the offset angle, the length, and the width.
[0119] Please refer to Figure 6 , Figure 6 A circular size detection process diagram is provided for the embodiments of the present application. The overall process is similar, and the difference lies in that the standard graph is a circle, and the coordinate data can include the center coordinates of the circle and the radius of the circle. In addition, in the above step (3), the reference circle is equally divided into a plurality of small rectangles (i.e., rectangular detection units, such as Figure 6 The upper right figure shows), the midpoint of each small rectangle is obtained (such as Figure 6 The lower left figure shows), the MAD algorithm is used to remove outlier center points, and then the least squares method is used to fit a circle (such as Figure 6The center coordinates and the radius of the circle can be obtained as the measurement result (as shown in the lower right part of the figure).
[0120] It should be noted that the above is only an example of the size measurement process of the target object with three shapes. For other shapes, such as an ellipse, an irregular figure, etc., a similar idea can also be used for measurement, that is, a standard figure is generated, a plurality of rectangular detection units intersecting the target object are determined, initial target coordinates are located, outliers are removed to obtain target coordinates and shape fitting is performed to obtain a fitted figure, and the fitted figure is measured to obtain an initial detection result or a re-determination detection result.
[0121] By applying the size detection method provided in the embodiments of the present application, the corresponding to-be-processed image of the material to be measured is obtained, and it is determined whether the quality of the to-be-processed image is qualified, and then it is determined whether it can be accurately sized. If the detection result is qualified, it means that the quality of the to-be-processed image is good, and accurate size detection results can be obtained by detecting it, so the target object to be detected is sized. By setting the image quality detection model, the to-be-processed image can not be sized when the quality of the to-be-processed image is poor, thereby improving the detection efficiency and reducing the consumption of computing resources. By using the metrology model to automatically detect the target object on the to-be-processed image, the detection speed can be improved, thereby improving the detection efficiency and avoiding wear and tear of the material.
[0122] The size detection device provided in the embodiments of the present application will be described below. The size detection device described below can be correspondingly referred to the size detection method described above.
[0123] Please refer to Figure 7 , Figure 7 A structure diagram of a size detection device provided in the embodiments of the present application includes:
[0124] The acquisition module 710 is configured to acquire a to-be-processed image.
[0125] The quality detection module 720 is configured to perform quality detection on the to-be-processed image by using an image quality detection model to obtain a detection result.
[0126] The size detection module 730 is configured to, if the detection result is qualified, perform size detection on a target object in the to-be-processed image by using a metrology model to obtain a corresponding size detection result.
[0127] Optionally, the quality detection module 720 includes:
[0128] The feature extraction unit is configured to perform feature extraction processing on the to-be-processed image to obtain at least two types of image features.
[0129] The weight generation unit is configured to generate feature weights corresponding to the image features of each category respectively.
[0130] The fusion processing unit is configured to perform feature fusion processing on the image features of each category based on the feature weights to obtain fused features.
[0131] The model processing unit is configured to perform classification processing on the fused features by using the image quality detection model to obtain a detection result.
[0132] Optionally, the weight generation unit comprises:
[0133] The information gain determination subunit is configured to generate feature information gains corresponding to the image features of each category respectively.
[0134] The feature weight generation subunit is configured to obtain the feature weights corresponding to the image features of each category by using the feature information gains based on a rule that the feature information gains and the feature weights are negatively correlated.
[0135] Optionally, the size detection module 730 comprises:
[0136] The to-be-measured region positioning unit is configured to perform to-be-measured region detection on the to-be-processed image to obtain a to-be-measured region comprising the target object.
[0137] The detection unit is configured to perform size detection on the target object in the to-be-measured region by using the metrology model to obtain a size detection result.
[0138] Optionally, the to-be-measured region positioning unit comprises:
[0139] The binarization processing subunit is configured to perform binarization processing on the to-be-processed image to obtain a binarized image.
[0140] The connectivity detection subunit is configured to obtain preset object feature data corresponding to the target object, perform connectivity region detection on the binarized image based on the preset object feature data, and obtain a detection result.
[0141] The hit subunit is configured to obtain the to-be-measured region if the detection result is a hit.
[0142] The shape matching subunit is configured to obtain a preset shape template corresponding to the target object, perform shape matching processing on the binarized image by using the preset shape template, and obtain the to-be-measured region if the detection result is a miss.
[0143] Optionally, the detection unit comprises:
[0144] The coordinate acquisition subunit is configured to obtain coordinate data corresponding to the target object.
[0145] The model determination subunit is configured to determine a target metrology model based on a shape type of the target object.
[0146] The measurement unit is configured to perform a measurement process on the to-be-measured region based on the coordinate data by using the target metrology model, and obtain a size detection result corresponding to the target object.
[0147] Optionally, the model determination subunit comprises:
[0148] The type determination subunit is configured to determine the shape type based on a data format of the coordinate data.
[0149] The target model selection subunit is configured to obtain the target metrology model based on a correspondence between the shape type and the metrology model.
[0150] Optionally, the measurement unit comprises:
[0151] The preliminary inspection subunit is configured to input the coordinate data and the to-be-measured region into the target metrology model, and obtain an initial detection result.
[0152] The standard acquisition subunit is configured to acquire a preset standard result and a preset tolerance range.
[0153] The tolerance judgment subunit is configured to obtain a detection difference value by using the initial detection result and the preset standard result, and determine whether the detection difference value is within the preset tolerance range.
[0154] The qualified judgment subunit is configured to determine that the size detection result is qualified if the detection difference value is within the preset tolerance range.
[0155] The re-judgment subunit is configured to update the coordinate data if the detection difference value is not within the preset tolerance range, and obtain the size detection result by using the target metrology model and the updated coordinate data.
[0156] Optionally, the re-judgment subunit comprises:
[0157] The coordinate updating subunit is configured to acquire an updating instruction, and update the coordinate data based on the updating instruction to obtain target coordinate data.
[0158] The re-judgment result generation subunit is configured to input the target coordinate data and the to-be-measured region into the target metrology model, and obtain a re-judgment detection result.
[0159] The re-judgment qualified subunit is configured to determine that the size detection result is qualified if the re-judgment detection result is within the preset tolerance range.
[0160] The re-judgment unqualified subunit is configured to determine that the size detection result is unqualified if the re-judgment detection result is not within the preset tolerance range.
[0161] Optionally, the preliminary inspection subunit comprises:
[0162] The standard figure generating subunit is configured to determine a standard figure based on the coordinate data by using a target metrology model.
[0163] The rectangular detection unit constructing subunit is configured to construct a plurality of adjacent rectangular detection units based on each edge of the standard figure, and superimpose the standard figure and the to-be-measured region.
[0164] The initial result determining subunit is configured to determine target coordinates of the plurality of rectangular detection units, and obtain an initial detection result based on the target coordinates, wherein the target coordinates are coordinates corresponding to the boundary of the target object in the rectangular detection unit.
[0165] Optionally, the initial result determining subunit comprises:
[0166] The segmenting subunit is configured to segment the boundary of the target object by using each rectangular detection unit to obtain a target boundary in each rectangular detection unit.
[0167] The initial coordinate determining subunit is configured to determine a center coordinate of the target boundary as an initial target coordinate.
[0168] The outlier filtering subunit is configured to perform outlier deletion processing on the initial target coordinate to obtain the target coordinate.
[0169] The fitting measuring subunit is configured to perform figure fitting based on the target coordinate to obtain a fitted figure, and measure the fitted figure to obtain the initial detection result.
[0170] The computer readable storage medium provided by the embodiments of the present application is described below, and the computer readable storage medium described below can be correspondingly referred to the size detection method described above.
[0171] The present application also provides a computer readable storage medium, and the computer readable storage medium stores a computer program, and the computer program is executed by a processor to implement the steps of the size detection method described above.
[0172] The computer readable storage medium can include a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and various media that can store program codes.
[0173] The embodiments in the specification are described in a progressive manner, and each embodiment focuses on the difference from other embodiments. The same or similar parts of each embodiment can be referred to each other. For the device disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple, and the related parts can be referred to the method part.
[0174] Those skilled in the art can further understand that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be realized in electronic hardware, computer software or a combination of both. In order to clearly illustrate the interchangeability of hardware and software, the components and steps of each example have been described in the above description in a general manner. Whether the functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.
[0175] The steps of the method or algorithm described in combination with the embodiments disclosed herein can be directly implemented by hardware, a software module executed by a processor, or a combination of both. The software module can be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0176] Finally, it should be noted that, in this document, relationships such as first and second are intended to distinguish one entity or operation from another, and do not necessarily require or imply any actual such relationship or order between the entities or operations. Moreover, the term including, comprising or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or apparatus including a series of elements includes not only those elements, but also other elements not explicitly listed, or other elements inherent in such a process, method, article or apparatus.
[0177] The principles and implementation modes of the present application are described in specific examples in this document, and the above description of the examples is only to help understand the method of the present application and its core idea; at the same time, for those skilled in the art, according to the idea of the present application, there will be changes in specific implementation modes and application scope, and the above description of the content of the specification should not be understood as a limitation of the present application.
Claims
1. A method for size detection, characterized in that, include: Obtain the image to be processed; The image to be processed is subjected to quality detection using an image quality detection model to obtain the detection result; If the detection result is qualified, the size of the target object in the image to be processed is detected using the metrology model to obtain the corresponding size detection result; wherein, based on the data format of the coordinate data of the target object, the shape type of the target object is determined, and based on the correspondence between the shape type and the metrology model, a target metrology model is obtained; using the target metrology model, the measurement processing is performed on the area to be measured including the target object based on the coordinate data to obtain the size detection result corresponding to the target object; The step of using an image quality detection model to perform quality detection on the image to be processed and obtaining the detection result includes: The image to be processed is subjected to feature extraction processing to obtain at least two types of image features; Generate feature weights for each type of image feature; the feature weights are used to characterize the ability of the corresponding image features to represent the quality of the image. Based on the aforementioned feature weights, feature fusion processing is performed on various image features to obtain fused features. Different types of image features can reflect the quality of the image to be processed from different perspectives. By fusion, fused features compatible with various types of information are obtained. The quality of the image to be processed refers to whether the image to be processed clearly records the shape of the material. Clear material shape includes: complete shape and clear boundary. The image quality detection model is used to classify the fused features to obtain the detection result.
2. The size detection method according to claim 1, characterized in that, The step of generating corresponding feature weights for various image features includes: Generate feature information gains corresponding to each of the aforementioned image features; Based on the rule that the feature information gain and the feature weight are negatively correlated, the feature weights corresponding to each type of image feature are obtained using the feature information gain.
3. The size detection method according to claim 1, characterized in that, The step of using a metrological model to detect the size of the target object in the image to be processed, and obtaining the corresponding size detection result, includes: The image to be processed is subjected to region detection to obtain the region to be detected, which includes the target object; The size of the target object in the area to be measured is detected using the measurement model, and the size detection result is obtained.
4. The size detection method according to claim 3, characterized in that, The step of detecting the region to be tested in the image to be processed to obtain the region to be tested including the target object includes: The image to be processed is binarized to obtain a binarized image; Obtain preset object feature data corresponding to the target object, and perform connected component detection on the binarized image based on the preset object feature data to obtain the detection result; If the detection result is a hit, then the area to be tested is obtained; If the detection result is a miss, a preset shape template corresponding to the target object is obtained, and the preset shape template is used to perform shape matching processing on the binarized image to obtain the region to be tested.
5. The size detection method according to claim 3, characterized in that, The step of using the target measurement model to measure the area to be measured based on the coordinate data to obtain the size detection result corresponding to the target object includes: The coordinate data and the area to be measured are input into the target measurement model to obtain the initial detection results; Obtain preset standard results and preset tolerance ranges; The detection difference is obtained using the initial detection result and the preset standard result, and it is determined whether the detection difference is within the preset tolerance range; If the result is within the preset tolerance range, then the dimensional inspection result is determined to be qualified. If the target is not within the preset tolerance range, the coordinate data is updated, and the size detection result is obtained using the target measurement model and the updated target coordinate data.
6. The size detection method according to claim 5, characterized in that, The step of updating the coordinate data and obtaining the size detection result using the target measurement model and the updated target coordinate data includes: Obtain the update instruction, and update the coordinate data based on the update instruction to obtain the target coordinate data; The target coordinate data and the area to be tested are input into the target measurement model to obtain the re-judgment detection result; If the re-judgment test result is within the preset tolerance range, then the dimensional test result is determined to be qualified; If the re-judgment test result is not within the preset tolerance range, then the dimensional test result is determined to be unqualified.
7. The size detection method according to claim 5, characterized in that, The step of inputting the coordinate data and the area to be measured into the target measurement model to obtain the initial detection result includes: Using the target measurement model and based on the coordinate data, a standard graphic is determined; Multiple adjacent rectangular detection units are constructed based on each side of the standard graphic, and the standard graphic and the area to be tested are superimposed. The target coordinates of the multiple rectangular detection units are determined, and the initial detection result is obtained based on the target coordinates; wherein the target coordinates are the coordinates corresponding to the boundary of the target object in the rectangular detection unit.
8. The size detection method according to claim 7, characterized in that, The step of determining the target coordinates of the plurality of rectangular detection units and obtaining the initial detection result based on the target coordinates includes: The boundary of the target object is segmented using each of the rectangular detection units to obtain the target boundary circled by each of the rectangular detection units. The center coordinates of the target boundary are determined as the initial target coordinates; The initial target coordinates are processed by outlier removal to obtain the target coordinates; Based on the target coordinates, a graphic is fitted to obtain a fitted graphic, and the fitted graphic is measured to obtain the initial detection result.
9. A size detection device, characterized in that, include: The acquisition module is used to acquire the image to be processed; The quality detection module is used to perform quality detection on the image to be processed using an image quality detection model to obtain the detection result; The size detection module is used to perform size detection on the target object in the image to be processed using a measurement model if the detection result is qualified, and obtain the corresponding size detection result; wherein, based on the data format of the coordinate data of the target object, the shape type of the target object is determined, and based on the correspondence between the shape type and the measurement model, a target measurement model is obtained; using the target measurement model, the measurement processing is performed on the area to be measured including the target object based on the coordinate data to obtain the size detection result corresponding to the target object; The quality inspection module includes: The feature extraction unit is used to perform feature extraction processing on the image to be processed to obtain at least two types of image features; The weight generation unit is used to generate feature weights corresponding to various types of image features; the feature weights are used to characterize the ability of the corresponding image features to characterize the quality of the image. The fusion processing unit is used to perform feature fusion processing on various image features based on the feature weights to obtain fused features. Different types of image features can reflect the quality of the image to be processed from different perspectives. By fusion, fused features compatible with various types of information are obtained. The quality of the image to be processed refers to whether the image to be processed clearly records the shape of the material. Clear material shape includes: complete shape and clear boundary. The model processing unit is used to classify the fused features using the image quality detection model to obtain the detection result.
10. An electronic device, characterized in that, Includes memory and processor, wherein: The memory is used to store computer programs; The processor is configured to execute the computer program to implement the size detection method as described in any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that, Used to store a computer program, wherein the computer program, when executed by a processor, implements the size detection method as described in any one of claims 1 to 8.
Citation Information
Patent Citations
Shape and position dimension non-contact photoelectric detection method for pylon component hole
CN101387493A
Contour determination method and device, detection equipment and storage medium
CN113160223A
Image processing method and device, electronic equipment and storage medium
CN113762032A
Self-adaptive product appearance defect positioning method and system
CN114486918A
Aggregate particle size intelligent detection method and device, computer equipment and storage medium
CN114708249A