Die-cast clock surface recognition method and system based on machine vision

By graying and filtering the die-cast clock image, the grayscale range is extracted, the internal structure influence is removed, and the contour detection and defect judgment model is combined, the problem of internal structure interference in clock surface recognition is solved, and the recognition accuracy is improved and Validity.

CN118628502BActive Publication Date: 2024-12-10DALIAN YAMING AUTOMOTIVE PARTS
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411118958.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-15
Publication Date
2024-12-10
Estimated Expiration
2044-08-15

AI Technical Summary

Technical Problem

The existing clock surface recognition technology is difficult to eliminate the impact of the clock internal structure on surface defect recognition, resulting in inaccurate identification results.

Method used

By performing image preprocessing on the die-cast clock image, including grayscale and filtering, extracting the grayscale range, removing the influence of internal structure, obtaining a surface profile diagram, and analyzing and determining whether there are defects on the surface through the contour detection algorithm and defect judgment model.

Benefits of technology

It improves the accuracy and effectiveness of clock surface recognition, can effectively distinguish the internal structure of the clock from surface defects, reduces misjudgment, and enhances the accuracy and rationality of recognition.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118628502B_ABST
    Figure CN118628502B_ABST
Patent Text Reader

Abstract

The invention discloses a die-cast clock surface recognition method and system based on machine vision, which relates to the technical field of clock surface recognition, and comprises the following steps: performing image acquisition on a die-cast clock to obtain a clock image; performing image preprocessing on the clock image to obtain a preprocessed image; performing edge contour extraction on the preprocessed image, and removing the influence of the internal structure of the clock on the image surface to obtain a surface contour map; analyzing the surface contour map to determine whether there are defects on the surface of the die-cast clock; the invention is used to solve the problem that the existing clock surface recognition technology still has the difficulty in eliminating the influence of the internal structure of the clock on the surface defect recognition, resulting in inaccurate results of the clock surface defect judgment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the technical field of clock surface recognition, and in particular to a method and system for recognizing the surface of a die-cast clock based on machine vision. Background Art

[0002] Clock surface recognition technology refers to the method and technology of automatically detecting, analyzing and identifying the appearance surface of die-cast clocks by using machine vision and image processing technology. By processing and analyzing the image of the die-cast clock surface, the surface defects of the die-cast clock can be identified and detected.

[0003] Existing clock surface recognition technology usually recognizes surface defects of die-cast clocks by edge recognition and contour extraction. However, there are different structures inside the die-cast clock, and these structures will greatly interfere with edge recognition and contour extraction, thereby affecting the judgment of surface defects. Existing clock surface recognition technology is also difficult to remove the interference of the internal structure of the die-cast clock on the recognition result, and the structures of different products are also different, which further increases the difficulty of surface defect recognition. For example, in the Chinese patent application publication number CN113516619A, a product surface defect recognition method based on image processing technology is disclosed. The scheme is based on the obtained product image, grayscale operation is performed on the picture to obtain a grayscale image; the defect point recognition algorithm is used to calculate and output the defect point area and the center point coordinates on the image for the grayscale image; finally, the laser marking machine is triggered according to the output value to laser label the product and mark the unqualified word. However, the above-mentioned surface defect recognition method is only used for surface defect recognition of the product. The existing clock surface recognition technology still has the problem that it is difficult to eliminate the influence of the internal structure of the clock on the surface defect recognition, resulting in inaccurate results of clock surface defect judgment. Summary of the invention

[0004] The present invention aims to solve at least one of the technical problems in the prior art to a certain extent, by acquiring an image of a die-cast clock to obtain a clock image, then performing image preprocessing on the clock image, processing it through grayscale and filtering technology to obtain a preprocessed image, then performing a preliminary analysis on the preprocessed image, extracting the grayscale range of the grayscale value in the preprocessed image, further analyzing the grayscale range, removing the influence of the internal structure of the clock on the image surface and obtaining a surface contour map, and finally analyzing the surface contour map to determine whether there are defects on the surface of the die-cast clock, so as to solve the problem that the existing clock surface recognition technology still has the difficulty in eliminating the influence of the internal structure of the clock on the recognition of surface defects, resulting in inaccurate results of clock surface defect judgment.

[0005] To achieve the above objectives, in a first aspect, the present application provides a method for surface recognition of a die-cast clock based on machine vision, comprising the following steps:

[0006] Capturing images of the die-cast clock to obtain a clock image;

[0007] Performing image preprocessing on the clock image to obtain a preprocessed image;

[0008] Extract edge contours from the preprocessed image and remove the influence of the internal structure of the clock on the image surface to obtain a surface contour map;

[0009] Analyze the surface profile to determine whether there are defects on the surface of the die-cast clock;

[0010] The edge contour of the preprocessed image is extracted, and the influence of the internal structure of the clock on the image surface is removed. The surface contour map is obtained, which includes the following sub-steps:

[0011] Perform a preliminary analysis on the preprocessed image and extract the grayscale range of the grayscale value in the preprocessed image;

[0012] The grayscale range is further analyzed to remove the influence of the internal structure of the clock on the image surface and obtain the surface contour map.

[0013] Furthermore, collecting an image of the die-cast clock to obtain the clock image includes the following sub-steps:

[0014] Place the die-cast clock in the shooting area;

[0015] The shooting area is photographed by a high-definition camera to obtain a clock image.

[0016] Furthermore, performing image preprocessing on the clock image to obtain a preprocessed image includes the following sub-steps:

[0017] Grayscale the clock image to obtain a clock grayscale image;

[0018] The pixels in the clock grayscale image are numbered and marked as P(n,m), where n is a positive integer and is the horizontal coordinate of P, and m is a positive integer and is the vertical coordinate of P;

[0019] For P(n,m), obtain the grayscale value corresponding to P(n,m), mark it as the grayscale value to be filtered, mark the grayscale value corresponding to P(n-1,m-1) as the upper left grayscale value, the grayscale value corresponding to P(n,m-1) as the positive upper grayscale value, the grayscale value corresponding to P(n+1,m-1) as the upper right grayscale value, the grayscale value corresponding to P(n-1,m) as the positive left grayscale value, the grayscale value corresponding to P(n+1,m) as the positive right grayscale value, the grayscale value corresponding to P(n-1,m+1) as the lower left grayscale value, the grayscale value corresponding to P(n,m+1) as the positive lower grayscale value, and the grayscale value corresponding to P(n+1,m+1) as the lower right grayscale value;

[0020] Obtaining a Gaussian kernel, wherein the Gaussian kernel includes a first weight, a second weight, and a third weight;

[0021] By formula:

[0022] Calculate the gray value after filtering, where G(n,m) is the gray value after filtering of P(n,m), UL is the upper left gray value, UR is the upper right gray value, DL is the lower left gray value, DR is the lower right gray value, ZU is the positive upper gray value, ZL is the positive left gray value, ZR is the positive right gray value, ZD is the positive lower gray value, TBF is the gray value to be filtered, K1 is the first weight, K2 is the second weight, and K3 is the third weight;

[0023] Calculate the filtered grayscale value of each P(n,m) and fill it to get the preprocessed image.

[0024] Furthermore, preliminary analysis of the preprocessed image includes the following sub-steps:

[0025] The number of grayscale values ​​after filtering ranging from 0 to 255 is counted respectively, and marked as a single-value grayscale number, wherein the single-value grayscale number includes a single-value grayscale number of 1 to a single-value grayscale number of 255;

[0026] A rectangular coordinate system is established with grayscale values ​​0 to 255 as the X-axis and single-value grayscale numbers as the Y-axis, named the grayscale distribution coordinate system, and the single-value grayscale numbers are entered into the grayscale distribution coordinate system;

[0027] Perform polynomial fitting on the grayscale distribution coordinate system to obtain the grayscale distribution curve;

[0028] The grayscale distribution curve is a waveform, and the grayscale value corresponding to the trough of the grayscale distribution curve is obtained and marked as the separation grayscale value;

[0029] The grayscale value from 0 to 255 is divided into several grayscale ranges based on the grayscale value.

[0030] Furthermore, further analysis of the grayscale range includes the following sub-steps:

[0031] The grayscale range is sorted and numbered in ascending order, and the symbol S i Represents, where i is a positive integer and i is the sequence number of S;

[0032] For S i , S i Mark it as the target surface, and mark the rest of the grayscale range as the impact elimination range;

[0033] The filtered gray value of the target surface is retained, and the gray values ​​that affect the elimination range are all changed to 1 to obtain the surface image. S is filtered in the order of i from small to large. i Perform analysis to obtain different surface images;

[0034] The contour of the surface image is extracted using a contour detection algorithm to obtain a surface contour map.

[0035] Further, analyzing the surface profile to determine whether there are defects on the surface of the die-cast clock includes the following sub-steps:

[0036] Conduct a preliminary analysis of the surface profile to determine whether there is a risk of defects in the surface profile;

[0037] If there is a risk of defect in the surface profile image, the corresponding surface profile image is marked as an image to be confirmed;

[0038] Perform a depth comparison on the image to be confirmed to determine whether there are any defects in the image to be confirmed.

[0039] Furthermore, preliminary analysis of the surface profile includes the following sub-steps:

[0040] Establish a defect judgment model and conduct sample training on the defect judgment model through big data samples;

[0041] Input the surface profile image into the defect judgment model;

[0042] The judgment result of the defect judgment model is obtained. If the judgment result is that there is a defect, the surface contour image is marked as an image to be confirmed, and the area judged as having a defect by the defect judgment model is marked as a defect to be confirmed area.

[0043] Furthermore, performing depth comparison on the image to be confirmed includes the following sub-steps:

[0044] Establishing a category analysis model, wherein the category analysis model is used to determine whether the defect confirmation area in the image to be confirmed is a texture image unique to the die-cast clock;

[0045] Input the image to be confirmed into the category analysis model;

[0046] The output result of the category analysis model is obtained. If the output result is a non-category design, the defective area to be confirmed in the image to be confirmed is marked as a defective area.

[0047] In a second aspect, the present application provides a die-cast clock surface recognition system based on machine vision, including an image acquisition module, an image preprocessing module, a contour extraction module and a defect judgment module; the image acquisition module, the image preprocessing module and the defect judgment module are respectively connected to the contour extraction module;

[0048] The image acquisition module is used to acquire images of the die-cast clock to obtain a clock image;

[0049] The image preprocessing module is used to perform image preprocessing on the clock image to obtain a preprocessed image;

[0050] The contour extraction module is used to extract edge contours from the preprocessed image and remove the influence of the internal structure of the clock on the image surface to obtain a surface contour map;

[0051] The defect judgment module is used to analyze the surface profile diagram to judge whether there are defects on the surface of the die-cast clock.

[0052] Beneficial effects of the present invention: The present invention acquires an image of a die-cast clock by performing image acquisition on the die-cast clock, and then performs image preprocessing on the clock image, processes the image by graying and filtering technology to obtain a preprocessed image, and then performs preliminary analysis on the preprocessed image to extract the grayscale range of the grayscale value in the preprocessed image. The advantage is that the grayscale range reflects the distribution of the grayscale values ​​of the clock surface and the internal structure seen through the surface, which is used to subsequently eliminate the influence of the internal structure of the clock on the judgment of the clock surface defects, thereby improving the accuracy and effectiveness of clock surface recognition;

[0053] The present invention further analyzes the grayscale range, removes the influence of the internal structure of the clock on the image surface and obtains a surface profile. The advantage is that most of the multiple surface profiles are normal structures of the clock, and only a few surface profiles may have defects. By extracting multiple surface profiles, the internal structure of the clock can be distinguished from the surface, further improving the accuracy and effectiveness of clock surface recognition.

[0054] The present invention performs a preliminary analysis on the surface contour map to determine whether there is a risk of defect in the surface contour map. If there is a risk of defect in the surface contour map, the corresponding surface contour map is marked as an image to be confirmed, and then a depth comparison is performed on the image to be confirmed to determine whether there is a defect in the image to be confirmed. The advantage is that the internal structure of the clock may be misjudged as a surface defect, and therefore further confirmation is required. Clocks of the same batch or the same model have the same internal structure, that is, the surface contour map is the same. Through further comparison, images belonging to the internal structure of the clock itself in the images to be confirmed can be screened out and eliminated. The remaining images to be confirmed are images that prove that the clock surface has defects, thereby improving the accuracy and rationality of clock surface recognition. BRIEF DESCRIPTION OF THE DRAWINGS

[0055] Figure 1 It is a functional block diagram of the system of the present invention.

[0056] Figure 2 It is the clock image of the present invention.

[0057] Figure 3 It is a schematic diagram of the position distribution of the grayscale value to be filtered and the grayscale values ​​of other points of the present invention.

[0058] Figure 4 This is the preprocessed image of the present invention.

[0059] Figure 5 It is a schematic diagram of the grayscale distribution coordinate system and grayscale distribution curve of the present invention.

[0060] Figure 6 This is the first surface image of the present invention.

[0061] Figure 7 The figure is a flow chart of the steps of the method of the present invention. DETAILED DESCRIPTION

[0062] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0063] Example 1, please refer to Figure 1 As shown, the present application provides a die-cast clock surface recognition system based on machine vision, including an image acquisition module, an image preprocessing module, a contour extraction module and a defect judgment module; the image acquisition module, the image preprocessing module and the defect judgment module are respectively connected to the contour extraction module data;

[0064] The image acquisition module is used to acquire images of the die-cast clock to obtain a clock image;

[0065] The image acquisition module is configured with an image acquisition strategy, which includes:

[0066] Place the die-cast clock in the shooting area;

[0067] See also Figure 2 As shown, the shooting area is photographed by a high-definition camera to obtain a clock image;

[0068] In actual application, the high-definition camera uses the existing high-definition camera, and a fixing device is set in the shooting area to ensure that each die-cast clock is photographed at the same position and angle. The clock image obtained is as follows: Figure 2 shown.

[0069] The image preprocessing module is used to perform image preprocessing on the clock image to obtain a preprocessed image;

[0070] The image preprocessing module is configured with an image preprocessing strategy, which includes:

[0071] Grayscale the clock image to obtain a clock grayscale image;

[0072] The pixels in the clock grayscale image are numbered and marked as P(n,m), where n is a positive integer and is the horizontal coordinate of P, and m is a positive integer and is the vertical coordinate of P;

[0073] See also Figure 3 As shown, for P(n,m), obtain the grayscale value corresponding to P(n,m), mark it as the grayscale value to be filtered, mark the grayscale value corresponding to P(n-1,m-1) as the upper left grayscale value, the grayscale value corresponding to P(n,m-1) as the positive upper grayscale value, the grayscale value corresponding to P(n+1,m-1) as the upper right grayscale value, the grayscale value corresponding to P(n-1,m) as the positive left grayscale value, the grayscale value corresponding to P(n+1,m) as the positive right grayscale value, the grayscale value corresponding to P(n-1,m+1) as the lower left grayscale value, the grayscale value corresponding to P(n,m+1) as the positive lower grayscale value, and the grayscale value corresponding to P(n+1,m+1) as the lower right grayscale value;

[0074] In practical applications, the numbers are P(1,1) to P(554,554), that is, the maximum value of n and m is 554; the position distribution of the gray value to be filtered and the gray value of the remaining points is as follows: Figure 3 As shown, the grayscale value to be filtered is 189, the grayscale value on the upper left is 225, the grayscale value directly above is 207, the grayscale value on the upper right is 199, the grayscale value directly on the left is 193, the grayscale value directly on the right is 207, the grayscale value on the lower left is 200, the grayscale value directly below is 216, and the grayscale value on the lower right is 227;

[0075] Obtaining a Gaussian kernel, the Gaussian kernel including a first weight, a second weight, and a third weight;

[0076] By formula:

[0077] Calculate the gray value after filtering, where G(n,m) is the gray value after filtering of P(n,m), UL is the upper left gray value, UR is the upper right gray value, DL is the lower left gray value, DR is the lower right gray value, ZU is the positive upper gray value, ZL is the positive left gray value, ZR is the positive right gray value, ZD is the positive lower gray value, TBF is the gray value to be filtered, K1 is the first weight, K2 is the second weight, and K3 is the third weight;

[0078] See also Figure 4 As shown, the filtered gray value of each P(n,m) is calculated and filled to obtain a preprocessed image;

[0079] In practical applications, the Gaussian kernel is the Gaussian kernel of the existing Gaussian filter, and the weights are 0.05, 0.1, and 0.4 from small to large, so the first weight is 0.05, the second weight is 0.1, and the third weight is 0.4. The gray value after filtering is 200 by calculation, and the calculation result retains integers. The pixel point corresponding to the gray value to be filtered is P(135,57), so the gray value corresponding to P(135,57) is changed to 200. After filtering each P(n,m), the preprocessed image is obtained as follows Figure 4 shown.

[0080] The contour extraction module is used to extract the edge contour of the preprocessed image and remove the influence of the internal structure of the clock on the image surface to obtain a surface contour map; the contour extraction module includes a gray range extraction unit and a surface contour recognition unit;

[0081] The grayscale range extraction unit is used to perform preliminary analysis on the preprocessed image and extract the grayscale range of the grayscale value in the preprocessed image;

[0082] The grayscale range extraction unit is configured with a grayscale range extraction strategy, and the grayscale range extraction strategy includes:

[0083] The number of grayscale values ​​from 0 to 255 after filtering is counted respectively, which are marked as single-value grayscale numbers, and the single-value grayscale numbers include single-value grayscale numbers 1 to single-value grayscale numbers 255;

[0084] See also Figure 5 As shown, a rectangular coordinate system is established with grayscale values ​​0 to 255 as the X-axis and single-valued grayscale numbers as the Y-axis, named the grayscale distribution coordinate system, and the single-valued grayscale numbers are entered into the grayscale distribution coordinate system;

[0085] Perform polynomial fitting on the grayscale distribution coordinate system to obtain the grayscale distribution curve;

[0086] The grayscale distribution curve is a waveform, and the grayscale value corresponding to the trough of the grayscale distribution curve is obtained and marked as the separation grayscale value;

[0087] The grayscale value is divided into several grayscale ranges from 0 to 255 by using the grayscale value as the partition;

[0088] In practical applications, the grayscale distribution coordinate system and grayscale distribution curve are statistically constructed as follows: Figure 5 As shown, the obtained separation grayscale values ​​include 0, 130, 200 and 255, that is, the grayscale range includes [0,130), [130,200) and [200,255];

[0089] The surface contour recognition unit is used to further analyze the grayscale range, remove the influence of the clock internal structure on the image surface and obtain the surface contour map.

[0090] The surface contour recognition unit is configured with a surface contour recognition strategy, which includes:

[0091] The grayscale range is sorted and numbered in ascending order, and the symbol S i Represents, where i is a positive integer and i is the sequence number of S;

[0092] For S i , S i Mark it as the target surface, and mark the rest of the grayscale range as the impact elimination range;

[0093] See also Figure 6 As shown in the figure, the filtered gray value of the target surface is retained, and the gray values ​​that affect the elimination range are all changed to 1 to obtain the surface image. S is filtered in the order of i from small to large. i Perform analysis to obtain different surface images;

[0094] The contour of the surface image is extracted by using a contour detection algorithm to obtain a surface contour map;

[0095] In practical applications, [0,130) is marked as the target surface, [130,200) and [200,255] are marked as the influence elimination range, and then the pixels with grayscale values ​​in [0,130) in the preprocessed image are retained, and the grayscale values ​​of the remaining pixels are set to 255 to obtain the first surface image, as shown in Figure 6 As shown, the second surface image and the third surface image are obtained by similar analysis; the contour of the surface image is extracted by the existing OpenCV technology to obtain the first surface contour map, the second surface contour map and the third surface contour map.

[0096] The defect judgment module is used to analyze the surface profile map to determine whether there are defects on the surface of the die-cast clock; the defect judgment module includes a defect judgment unit and a defect confirmation unit;

[0097] The defect judgment unit is used to perform a preliminary analysis on the surface profile image to determine whether the surface profile image has a defect risk; if the surface profile image has a defect risk, the corresponding surface profile image is marked as an image to be confirmed;

[0098] The defect judgment unit is configured with a defect judgment strategy, which includes:

[0099] Establish a defect judgment model and conduct sample training on the defect judgment model through big data samples;

[0100] Input the surface profile image into the defect judgment model;

[0101] Obtaining the judgment result of the defect judgment model, if the judgment result is that there is a defect, marking the surface contour image as an image to be confirmed, and marking the area judged as having a defect by the defect judgment model as a defect to be confirmed area;

[0102] In practical applications, the defect judgment model uses the existing surface defect detection technology based on deep learning, and detects that both the second surface profile image and the third surface profile image output defect signals, then the second surface profile image and the third surface profile image are marked as the first image to be confirmed and the second image to be confirmed respectively;

[0103] The defect confirmation unit is used to perform depth comparison on the image to be confirmed to determine whether there are defects in the image to be confirmed;

[0104] The defect confirmation unit is configured with a defect confirmation strategy, which includes:

[0105] Establishing a category analysis model, the category analysis model is used to confirm whether the defect confirmation area in the image to be confirmed is a texture image unique to the die-cast clock;

[0106] Input the image to be confirmed into the category analysis model;

[0107] The output result of the category analysis model is obtained. If the output result is a non-category design, the defective area to be confirmed in the image to be confirmed is marked as a defective area.

[0108] In actual applications, the category analysis model uses existing similarity analysis technology to analyze the similarity of the images to be confirmed of the current model of die-cast clocks. If the image to be confirmed is the same as multiple images to be confirmed, it is judged as a category design, that is, the internal structure of the clock is misjudged as a defect. Otherwise, it is confirmed that the die-cast clock has defects.

[0109] Example 2, please refer to Figure 7 As shown, the present application provides a die-cast clock surface recognition method based on machine vision, comprising the following steps:

[0110] Step S1, collecting an image of the die-cast clock to obtain a clock image; Step S1 includes the following sub-steps:

[0111] Step S101, placing the die-cast clock in a shooting area;

[0112] Step S102, photographing the shooting area with a high-definition camera to obtain a clock image;

[0113] Step S2, performing image preprocessing on the clock image to obtain a preprocessed image; Step S2 includes the following sub-steps:

[0114] Step S201, grayscale processing is performed on the clock image to obtain a clock grayscale image;

[0115] Step S202, numbering the pixel points in the clock grayscale image, marking them as P(n,m), where n is a positive integer and n is the horizontal coordinate of P, and m is a positive integer and m is the vertical coordinate of P;

[0116] Step S203, for P(n,m), obtain the grayscale value corresponding to P(n,m), mark it as the grayscale value to be filtered, mark the grayscale value corresponding to P(n-1,m-1) as the upper left grayscale value, the grayscale value corresponding to P(n,m-1) as the positive upper grayscale value, the grayscale value corresponding to P(n+1,m-1) as the upper right grayscale value, the grayscale value corresponding to P(n-1,m) as the positive left grayscale value, the grayscale value corresponding to P(n+1,m) as the positive right grayscale value, the grayscale value corresponding to P(n-1,m+1) as the lower left grayscale value, the grayscale value corresponding to P(n,m+1) as the positive lower grayscale value, and the grayscale value corresponding to P(n+1,m+1) as the lower right grayscale value;

[0117] Step S204, obtaining a Gaussian kernel, where the Gaussian kernel includes a first weight, a second weight, and a third weight;

[0118] Step S205, by formula:

[0119] Calculate the gray value after filtering, where G(n,m) is the gray value after filtering of P(n,m), UL is the upper left gray value, UR is the upper right gray value, DL is the lower left gray value, DR is the lower right gray value, ZU is the positive upper gray value, ZL is the positive left gray value, ZR is the positive right gray value, ZD is the positive lower gray value, TBF is the gray value to be filtered, K1 is the first weight, K2 is the second weight, and K3 is the third weight;

[0120] Step S206, calculating the filtered grayscale value of each P(n,m) and filling it to obtain a preprocessed image;

[0121] Step S3, extracting edge contours from the preprocessed image, and removing the influence of the internal structure of the clock on the image surface, to obtain a surface contour map; Step S3 includes the following sub-steps:

[0122] Step S301, performing preliminary analysis on the preprocessed image to extract the grayscale range of the grayscale value in the preprocessed image;

[0123] Step S301 includes the following sub-steps:

[0124] Step S3011, respectively counting the number of grayscale values ​​from 0 to 255 after filtering, marking them as single-valued grayscale numbers, which include single-valued grayscale numbers 1 to single-valued grayscale numbers 255;

[0125] Step S3012, establishing a rectangular coordinate system with grayscale values ​​0 to 255 as the X-axis and the single-valued grayscale number as the Y-axis, named the grayscale distribution coordinate system, and entering the single-valued grayscale number into the grayscale distribution coordinate system;

[0126] Step S3013, performing polynomial fitting on the grayscale distribution coordinate system to obtain a grayscale distribution curve;

[0127] Step S3014, the grayscale distribution curve is a waveform, and the grayscale value corresponding to the trough of the grayscale distribution curve is obtained and marked as the separation grayscale value;

[0128] Step S3015, dividing the grayscale value from 0 to 255 into a plurality of grayscale ranges based on the grayscale value;

[0129] Step S302, further analyzing the grayscale range, removing the influence of the internal structure of the clock on the image surface and obtaining a surface contour map;

[0130] Step S302 includes the following sub-steps:

[0131] Step S3021, sort and number them in ascending order of grayscale range, using symbol S i Represents, where i is a positive integer and i is the sequence number of S;

[0132] Step S3022, for S i , S i Mark it as the target surface, and mark the rest of the grayscale range as the impact elimination range;

[0133] Step S3023, retain the filtered gray value of the target surface, change all the gray values ​​affecting the elimination range to 1, obtain the surface image, and perform filtering on S in the order of i from small to large. i Perform analysis to obtain different surface images;

[0134] Step S3024, extracting the contour of the surface image by using a contour detection algorithm to obtain a surface contour map;

[0135] Step S4, analyzing the surface profile to determine whether there are defects on the surface of the die-cast clock; Step S4 includes the following sub-steps:

[0136] Step S401, performing a preliminary analysis on the surface profile map to determine whether there is a defect risk in the surface profile map;

[0137] Step S401 includes the following sub-steps:

[0138] Step S4011, establishing a defect judgment model, and performing sample training on the defect judgment model through big data samples;

[0139] Step S4012, inputting the surface profile image into the defect judgment model;

[0140] Step S4013, obtaining the judgment result of the defect judgment model. If the judgment result is that there is a defect, the surface contour image is marked as an image to be confirmed, and the area judged as having a defect by the defect judgment model is marked as a defect to be confirmed area;

[0141] Step S402: if there is a risk of defect in the surface profile image, the corresponding surface profile image is marked as an image to be confirmed;

[0142] Step S403, performing depth comparison on the image to be confirmed to determine whether there are defects in the image to be confirmed;

[0143] Step S403 includes the following sub-steps:

[0144] Step S4031, establishing a category analysis model, the category analysis model is used to confirm whether the defect confirmation area in the image to be confirmed is a texture image unique to the die-cast clock;

[0145] Step S4032, inputting the image to be confirmed into the category analysis model;

[0146] Step S4033, obtaining the output result of the category analysis model. If the output result is a non-category design, the defective area to be confirmed in the image to be confirmed is marked as a defective area.

[0147] Embodiment 3, the present application provides an electronic device, including a processor and a memory, the memory storing computer-readable instructions, when the computer-readable instructions are executed by the processor, the steps in the above method are executed. Through the above technical solution, the processor and the memory are interconnected and communicate with each other through a communication bus and / or other forms of connection mechanisms, the memory stores a computer program executable by the processor, when the electronic device is running, the processor executes the computer program to execute the method in any optional implementation of the above embodiment, to achieve the following functions: image acquisition of the die-cast clock to obtain a clock image; image preprocessing of the clock image to obtain a preprocessed image; edge contour extraction of the preprocessed image, while removing the influence of the internal structure of the clock on the image surface, to obtain a surface contour map; analysis of the surface contour map to determine whether there are defects on the surface of the die-cast clock.

[0148] Embodiment 4, the present application provides a storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps in any of the above methods are executed. Through the above technical solution, when the computer program is executed by the processor, the method in any optional implementation of the above embodiment is executed to achieve the following functions: image acquisition of the die-cast clock to obtain a clock image; image preprocessing of the clock image to obtain a preprocessed image; edge contour extraction of the preprocessed image, while removing the influence of the internal structure of the clock on the image surface, to obtain a surface contour map; analysis of the surface contour map to determine whether there are defects on the surface of the die-cast clock.

[0149] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.

[0150] It should be understood by those skilled in the art that the embodiments of the present invention may be provided as methods, systems or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware aspects. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media containing computer-usable program codes. Among them, the storage medium may be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (Static Random Access Memory, referred to as SRAM), electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, referred to as EEPROM), erasable programmable read-only memory (Erasable Programmable Read Only Memory, referred to as EPROM), programmable read-only memory (Programmable Read-Only Memory, referred to as PROM), read-only memory (Read-Only Memory, referred to as ROM), magnetic memory, flash memory, magnetic disk or optical disk. These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0151] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.

Claims

1. A die-cast clock surface recognition method based on machine vision, characterized in that: The steps include: Capturing images of the die-cast clock to obtain a clock image; Performing image preprocessing on the clock image to obtain a preprocessed image; Extract edge contours from the preprocessed image and remove the influence of the internal structure of the clock on the image surface to obtain a surface contour map; Analyze the surface profile to determine whether there are defects on the surface of the die-cast clock; The edge contour of the preprocessed image is extracted, and the influence of the internal structure of the clock on the image surface is removed. The surface contour map is obtained, which includes the following sub-steps: Perform a preliminary analysis on the preprocessed image and extract the grayscale range of the grayscale value in the preprocessed image; Further analysis is performed on the grayscale range to remove the influence of the clock's internal structure on the image surface and obtain a surface contour map; Performing image preprocessing on the clock image to obtain a preprocessed image includes the following sub-steps: Grayscale the clock image to obtain a clock grayscale image; The pixels in the clock grayscale image are numbered and marked as P(n,m), where n is a positive integer and is the horizontal coordinate of P, and m is a positive integer and is the vertical coordinate of P; For P(n,m), obtain the grayscale value corresponding to P(n,m), mark it as the grayscale value to be filtered, mark the grayscale value corresponding to P(n-1,m-1) as the upper left grayscale value, the grayscale value corresponding to P(n,m-1) as the positive upper grayscale value, the grayscale value corresponding to P(n+1,m-1) as the upper right grayscale value, the grayscale value corresponding to P(n-1,m) as the positive left grayscale value, the grayscale value corresponding to P(n+1,m) as the positive right grayscale value, the grayscale value corresponding to P(n-1,m+1) as the lower left grayscale value, the grayscale value corresponding to P(n,m+1) as the positive lower grayscale value, and the grayscale value corresponding to P(n+1,m+1) as the lower right grayscale value; Obtaining a Gaussian kernel, wherein the Gaussian kernel includes a first weight, a second weight, and a third weight; By formula: Calculate the gray value after filtering, where G(n,m) is the gray value after filtering of P(n,m), UL is the upper left gray value, UR is the upper right gray value, DL is the lower left gray value, DR is the lower right gray value, ZU is the positive upper gray value, ZL is the positive left gray value, ZR is the positive right gray value, ZD is the positive lower gray value, TBF is the gray value to be filtered, K1 is the first weight, K2 is the second weight, and K3 is the third weight; Calculate the filtered grayscale value of each P(n,m) and fill it to get the preprocessed image; The initial analysis of the preprocessed image includes the following sub-steps: The number of grayscale values ​​after filtering ranging from 0 to 255 is counted respectively, and marked as a single-value grayscale number, wherein the single-value grayscale number includes a single-value grayscale number of 1 to a single-value grayscale number of 255; A rectangular coordinate system is established with grayscale values ​​0 to 255 as the X-axis and single-value grayscale numbers as the Y-axis, named the grayscale distribution coordinate system, and the single-value grayscale numbers are entered into the grayscale distribution coordinate system; Perform polynomial fitting on the grayscale distribution coordinate system to obtain the grayscale distribution curve; The grayscale distribution curve is a waveform, and the grayscale value corresponding to the trough of the grayscale distribution curve is obtained and marked as the separation grayscale value; The grayscale value is divided into several grayscale ranges from 0 to 255 by using the grayscale value as the partition; Further analysis of the grayscale range includes the following sub-steps: The grayscale range is sorted and numbered in ascending order, and the symbol S is used to represent the grayscale range. i Represents, where i is a positive integer and i is the sequence number of S; For S i , S i Mark it as the target surface, and mark the rest of the grayscale range as the impact elimination range; The filtered gray value of the target surface is retained, and the gray values ​​that affect the elimination range are all changed to 1 to obtain the surface image. S is filtered in the order of i from small to large. i Perform analysis to obtain different surface images; The contour of the surface image is extracted using a contour detection algorithm to obtain a surface contour map.

2. The die-cast clock surface recognition method based on machine vision according to claim 1 is characterized in that: The image acquisition of the die-cast clock includes the following sub-steps: Place the die-cast clock in the shooting area; The shooting area is photographed by a high-definition camera to obtain a clock image.

3. The die-cast clock surface recognition method based on machine vision according to claim 2 is characterized in that: Analyzing the surface profile to determine whether there are defects on the surface of the die-cast clock includes the following sub-steps: Conduct a preliminary analysis of the surface profile to determine whether there is a risk of defects in the surface profile; If there is a risk of defect in the surface profile image, the corresponding surface profile image is marked as an image to be confirmed; Perform a depth comparison on the image to be confirmed to determine whether there are any defects in the image to be confirmed.

4. The method for recognizing the surface of a die-cast clock based on machine vision according to claim 3, characterized in that: The initial analysis of the surface profile consists of the following sub-steps: Establish a defect judgment model and conduct sample training on the defect judgment model through big data samples; Input the surface profile image into the defect judgment model; The judgment result of the defect judgment model is obtained. If the judgment result is that there is a defect, the surface contour image is marked as an image to be confirmed, and the area judged as having a defect by the defect judgment model is marked as a defect to be confirmed area.

5. The method for recognizing the surface of a die-cast clock based on machine vision according to claim 4, characterized in that: The depth comparison of the image to be confirmed includes the following sub-steps: Establishing a category analysis model, wherein the category analysis model is used to determine whether the defect confirmation area in the image to be confirmed is a texture image unique to the die-cast clock; Input the image to be confirmed into the category analysis model; The output result of the category analysis model is obtained. If the output result is a non-category design, the defective area to be confirmed in the image to be confirmed is marked as a defective area.

6. A die-cast clock surface recognition system based on machine vision, used to implement the die-cast clock surface recognition method based on machine vision according to any one of claims 1 to 5, characterized in that: It includes an image acquisition module, an image preprocessing module, a contour extraction module and a defect judgment module; the image acquisition module, the image preprocessing module and the defect judgment module are respectively connected to the contour extraction module; The image acquisition module is used to acquire images of the die-cast clock to obtain a clock image; The image preprocessing module is used to perform image preprocessing on the clock image to obtain a preprocessed image; The contour extraction module is used to extract edge contours from the preprocessed image and remove the influence of the internal structure of the clock on the image surface to obtain a surface contour map; The defect judgment module is used to analyze the surface profile diagram to judge whether there are defects on the surface of the die-cast clock.