Edge top surface defect detection method of die casting

By storing the digital model points and their direction vectors of the edge and top surface region in the die casting inspection, and using the direction vectors to accurately locate and mark the defect area, the problem of side interference in the edge and top surface inspection of die castings is solved, and high-precision defect detection is achieved.

CN121639652APending Publication Date: 2026-03-10EASY THINKING HANGZHOU TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-05
Publication Date
2026-03-10

AI Technical Summary

Technical Problem

When detecting defects on the top surface of the edges of die-cast parts, conventional methods are easily affected by interference from the side areas, leading to false or missed detections of defects, and the segmentation of the top surface area is inaccurate.

Method used

By storing the digital model points and their direction vectors of the edge top surface region in a standard information database, the direction vectors are used to accurately locate the edge top surface region. Defect areas are marked by comparing grayscale averages and using skeleton points, thus avoiding lateral interference and improving detection accuracy.

Benefits of technology

It enables accurate positioning and high-precision detection of defects on the edges and top surfaces of die-cast parts, reducing false detections and missed detections, and improving the accuracy of detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121639652A_ABST
    Figure CN121639652A_ABST
Patent Text Reader

Abstract

The invention discloses a method for detecting edge top surface defects of a die casting, which comprises the following steps of: acquiring an image of the die casting, and respectively converting a three-dimensional digital-analog point and a spatial direction vector thereof stored in a standard information base into a to-be-detected image to obtain a conversion point Ak and a direction vector Ek thereof; g pixel points are searched for at each conversion point Ak along the direction vector, the average gray value of the G pixel points is counted, and if the difference value between the average gray value and the gray value at the conversion point Ak is larger than a threshold value, the image coordinate where the conversion point Ak is located is marked as the defect point position; according to the method, the digital-analog point of the edge top surface area and the direction vector of the digital-analog point are stored in the standard information base, the edge top surface area in the to-be-detected image is accurately positioned through the digital-analog point during detection, and meanwhile, the direction vector is taken as a detection direction, so that interference of edge side surface points is effectively avoided, and the defect identification precision is improved. The method is suitable for top surface defect detection of edges in different forms such as straight edges and arc edges.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing, and more specifically to a method for detecting edge and top surface defects in die-cast parts. Background Technology

[0002] Integrated die-casting technology is increasingly widely used in production processes due to its advantages such as significantly reducing the number of parts, greatly improving production efficiency, and lowering production costs. Visual inspection of surface defects by photographing die-cast parts is a low-cost and highly efficient defect detection method. Die-cast parts generally have complex surface structures, mainly characterized by square, triangular, and circular grooves (such as those composed of numerous edges). Figure 1 These grooves are often critical locations in die castings, requiring high die casting quality, but they are also locations where defects (cold shuts, cracks) are prone to occur in die castings.

[0003] In the inspection drawing of die-cast parts, the width of the edges is generally less than 50 pixels, usually only 10-20 pixels. Therefore, in the inspection drawing of die-cast parts, the image formed by the top surface of the edges is a relatively thin straight line or arc-shaped strip area (such as...). Figure 2 (The area marked with color) Furthermore, during actual inspection, the brightness of the top surface area of ​​the defective edge is uneven, and conventional image segmentation methods are prone to inaccurate segmentation of the top surface area.

[0004] Meanwhile, the top and side surfaces of an edge have different angles relative to the light source. The top surface receives more light, resulting in a brighter image, while the side surfaces receive less light due to occlusion, resulting in a darker image. Furthermore, the brightness of the top surface varies at different locations. Therefore, conventional defect detection methods are susceptible to interference from the side surfaces, leading to false positives and false negatives. Summary of the Invention

[0005] To address the aforementioned technical problems, this invention provides a method for detecting edge and top surface defects in die-cast parts. This method stores the digital model points and their direction vectors of the edge and top surface region in a standard information database. During detection, the digital model points accurately locate the edge and top surface region in the image to be inspected. Simultaneously, the direction vector is used as the detection direction, effectively avoiding interference from the side edge points and improving defect identification accuracy. This method is applicable to the detection of edge and top surface defects of different shapes, such as straight edges and rounded edges.

[0006] The technical solution is as follows:

[0007] A method for detecting edge and top surface defects in die castings involves the following standard information database acquisition process before die casting inspection: From a batch of die castings to be inspected, a defect-free die casting is selected and designated as a standard part; an image of the standard part is captured by a camera, and the edge and top surface area is selected within the standard part image;

[0008] Obtain the edge points of the top surface region of the edge. For each edge point, perform the following processing: find S edge points around the edge point, fit a straight line using the found edge points, obtain the direction vector of the straight line, and record the direction vector of the straight line as the direction vector of the current edge point.

[0009] The pixels within the top surface region of the edge are denoted as top surface points. For each top surface point, the following processing is performed: find the edge point that is closest to the top surface point, and record the direction vector corresponding to the edge point as the direction vector of the top surface point.

[0010] The camera intrinsic parameter matrix and the transformation matrix RT between the pre-acquired camera coordinate system and the standard part digital model coordinate system are used. 标准 Each edge point and its direction vector, and each top surface point and its direction vector are transformed into the digital model coordinate system, and the corresponding three-dimensional digital model point and its spatial direction vector are obtained. The three-dimensional digital model point and the spatial direction vector are associated and stored in the standard information database.

[0011] When inspecting die-cast parts, the following steps are used to detect defects in the top surface area of ​​the edges:

[0012] 1) The camera captures an image of the current die-cast part, which is recorded as the image to be inspected;

[0013] Obtain the transformation matrix RT between the camera coordinate system and the current die-cast part's digital model coordinate system. 检测 ;

[0014] 2) Using the camera intrinsic parameter matrix and transformation relation matrix RT 检测 Each 3D digital model point and its spatial direction vector stored in the standard information database are converted into the image to be examined, resulting in conversion point A. k and its direction vector E k k = 1, 2...N, where N is the sum of the number of edge points and top surface points;

[0015] 3) At each transition point A k Find and transform point A along the direction vector respectively. k Calculate the average grayscale value of the G nearest pixels. If the average grayscale value is similar to that of the transition point A, then... k If the difference between the gray values ​​at a given point is greater than the threshold, then mark the transition point A. k The image coordinates indicate the location of the defect point.

[0016] Preferably, the edge top surface region is manually selected in the standard part image, and skeleton points are obtained in the edge top surface region, with the distance between adjacent skeleton points being less than L pixels; the transformation relation matrix RT is then used. 标准 Transform each skeleton point into the digital model coordinate system to obtain the corresponding 3D skeleton point and store it in the standard information database.

[0017] It also includes step 4): using the camera intrinsic parameter matrix and the transformation relation matrix RT 检测 Each 3D skeleton point stored in the standard information database is converted into the image to be inspected to obtain the converted skeleton points;

[0018] For each conversion skeleton point, find the number of defect points in the area surrounding the single conversion skeleton point. If the number is greater than the preset value I, mark the conversion skeleton point as an abnormal point.

[0019] If the length of consecutive abnormal points is greater than the preset value II, then the local area on the top surface of the edge where the abnormal point is located is marked as an abnormal area.

[0020] Furthermore, taking each transformation skeleton point as the center, the number of defect points in the area surrounding a single transformation skeleton point is found as follows:

[0021] Using the transformed skeleton point as the center, draw a rectangular area with the short side of the rectangular area parallel to the extension direction of the edge. Find the number of defect points in the rectangular area.

[0022] Preferably, L is 2 to 5; preset value I is 10 to 50; preset value II is 10 to 50.

[0023] Preferably, S is 5-10 and G is 5-30.

[0024] Furthermore, let Q be the edge point / top surface point. i The direction vector is H i ;

[0025] Q, the edge point / top point i and its direction vector H i Transform them to the digital model coordinate system to obtain the corresponding three-dimensional digital model points Q. i ''' and its spatial direction vector H i The method is as follows:

[0026] Using the camera intrinsic parameter matrix to locate point Q i and its direction vector H i Transform to the camera coordinate system to obtain the 3D point Q. i 'and direction vector H i ';

[0027] Using RT 标准 The three-dimensional point Q i 'and direction vector H i 'And the camera optical center C is transformed into the digital model coordinate system, corresponding to point Q.' i ''、Direction H i '', and the camera optical center C'; calculate point Q iThe intersection point Q of the ray R formed by the optical center C of the camera and the digital model of the die-cast part. i ''', the intersection point Q i Let's denote the edge point Q. i The corresponding three-dimensional digital model points;

[0028] Obtain the intersection point Q i The digital model triangle A contains '''; with the direction of ray R and direction H i The cross product vector of '' is the normal vector, passing through the intersection point Q. i Construct plane B; denote the direction vector of the line intersecting triangular facet A and plane B as the spatial direction vector H. i '''.

[0029] Furthermore, let the three-dimensional digital model point be denoted as Q. i The spatial direction vector is H. i ''';

[0030] The three-dimensional digital model point Q i ''' and its spatial direction vector H i '''Transformed into the image to be inspected, the transformation point A is obtained. k and its direction vector E k The method is as follows:

[0031] Based on the transformation relation matrix RT 检测 The three-dimensional digital model point Q i ''' and its spatial direction vector H i Transforming to the camera coordinate system, we get point A. k 'and direction E k ';

[0032] Calculation by A k The intersection point A of the ray R pointing to the optical center of the camera and the image plane. k '';

[0033] Assume the direction of ray R' and direction E k The cross product of ' is the normal, passing through intersection point A. k The plane F of '';

[0034] Obtain the direction vector E of the intersection line between the image plane and plane F. k '';

[0035] Using the camera intrinsic parameter matrix, the intersection point A k '' and direction vector E k Transform to the image coordinate system to obtain transformation point A. k and direction vector E k .

[0036] Preferably, during the acquisition of the standard information database, the edge points of the top surface region of the edge are obtained, and the following processing is performed on each edge point: T neighboring edge points are found on both sides of a single edge point, and straight lines are fitted using the edge points found on both sides to obtain the direction vectors of the two lines, and the angle between the two direction vectors is determined:

[0037] If the included angle is less than the preset value III, then the edge points found on both sides are used to fit a straight line together, and the direction vector of the line fit together is stored in correspondence with the image coordinates of the current edge point.

[0038] If the included angle is not less than the preset value III, the fitting error of each fitted line is obtained, and the direction vector of the line with the smaller fitting error is stored corresponding to the current edge point; where the preset value III is 10°~30°.

[0039] Furthermore, the transformation matrix between the camera coordinate system and the digital model coordinate system is obtained in the following way:

[0040] The camera used to capture images of die-cast parts is referred to as the image acquisition camera;

[0041] At least two auxiliary cameras are placed around the image acquisition camera. Multiple cameras acquire images of the die casting, resulting in multiple images. Any two cameras form a binocular system. The common field of view of all cameras includes multiple edge features on the die casting. At least four non-parallel edge features are selected and marked as edges to be processed. In the die casting digital model, the planes corresponding to the edges to be processed are marked as planes to be processed. Each edge to be processed and the plane to be processed are stored accordingly.

[0042] The transformation matrix between the camera coordinate system and the digital model coordinate system is obtained using the following steps:

[0043] ① Select the edges to be processed from multiple images and extract the edge lines of each edge to be processed;

[0044] The image captured by the imaging camera is designated as the first image; other images are designated as auxiliary images.

[0045] The edge lines extracted from the first image are denoted as the first edge lines; the edge lines selected in the auxiliary image are denoted as the auxiliary edge lines.

[0046] ②The following processing is performed on each first edge line:

[0047] Take any point on the first edge line and denote it as point A; using the fundamental matrix between the image acquisition camera and other cameras, find the epipolar line corresponding to point A in each auxiliary image, calculate the intersection of the auxiliary edge line and the epipolar line respectively, and find D neighboring pixels on both sides of the intersection point along the epipolar line; denote the intersection point and the D found pixels as suspected points.

[0048] Let any one of the auxiliary images be the second image, and let the epipolar line in the second image be the reference epipolar line, and the suspected point in the second image be the reference point;

[0049] Using the fundamental matrix between the second image acquisition camera and other auxiliary cameras, the epipolar lines of each suspected point in the other auxiliary images are obtained in the second image and denoted as suspected epipolar lines.

[0050] In the second image, the intersection points between each suspected epipolar line and the baseline epipolar line are obtained, and the intersection points and each baseline point are stored in the point set C. The centroid of the point set C is recorded as the corresponding point B of point A.

[0051] ③ Using the extrinsic parameters between the cameras corresponding to the first and second images, reconstruct the three-dimensional coordinates of the multiple pairs of corresponding points obtained in step ②;

[0052] Based on the edge to be processed corresponding to the three-dimensional coordinates, find the plane to be processed and match the plane to be processed for each three-dimensional coordinate;

[0053] ④ Based on the distance between each 3D coordinate and the corresponding plane to be processed, establish an objective function, and use the optimization method to iteratively find the rotation and translation matrix that minimizes the distance, denoted as the transformation relationship matrix between the camera coordinate system and the digital model coordinate system.

[0054] To further improve the accuracy of finding points with the same name, the following steps are preferably performed on point set C:

[0055] Get the coordinate components of each point in point set C on the X-axis / Y-axis. After rounding the coordinate components, if there are identical coordinate components, store the points corresponding to the identical coordinate components in the overlapping point set.

[0056] In point set C, points not stored in the overlapping point set are removed, and the centroid of point set C is denoted as point B, which is the same name as point A; further, the objective function is E(R,T) = ,in, Let represent the distance between the i-th 3D coordinate and its corresponding plane to be processed, n be the number of 3D coordinate points, R be the rotation matrix, and T be the translation matrix.

[0057] This method accurately locates the edge top surface region in the image under test by using the digital model points of the top surface region, which solves the problem that the edge top surface cannot be accurately located because it is thin and easily interfered with by the surrounding area.

[0058] By defining the direction of defect detection using a directional vector, the points on the top surface of the edge are compared in grayscale only on the top surface area, thus solving the problem of false defect detection caused by interference from the side surface area.

[0059] By marking skeleton points, the area where defects are located can be found, which solves the problem of discrete distribution of defect points and difficulty in identifying abnormal areas (defect areas). Attached Figure Description

[0060] Figure 1 This is a schematic diagram of the edge of a die-cast part;

[0061] Figure 2 In order to be in Figure 1 A schematic diagram showing the top surface area after marking a portion of the edge;

[0062] Figure 3 This is a schematic diagram illustrating the process of finding abnormal regions based on skeleton points. Detailed Implementation

[0063] The technical solution of the present invention will be described in detail below with reference to specific embodiments.

[0064] A method for detecting edge and top surface defects in die castings involves the following standard information database acquisition process before die casting inspection: From a batch of die castings to be inspected, a defect-free die casting is selected and designated as a standard part; an image of the standard part is captured by a camera, and the edge and top surface area (e.g., [image not specified]) is selected within the standard part image. Figure 2 );

[0065] Obtain the edge points of the top surface region of the edge. For each edge point, perform the following processing: find S edge points around the edge point, fit a straight line using the found edge points, obtain the direction vector of the straight line, and record the direction vector of the straight line as the direction vector of the current edge point.

[0066] The pixels within the top surface region of the edge are denoted as top surface points. For each top surface point, the following processing is performed: find the edge point that is closest to the top surface point, and record the direction vector corresponding to the edge point as the direction vector of the top surface point.

[0067] The camera intrinsic parameter matrix and the transformation matrix RT between the pre-acquired camera coordinate system and the standard part digital model coordinate system are used. 标准 Each edge point and its direction vector, and each top surface point and its direction vector are transformed into the digital model coordinate system, and the corresponding three-dimensional digital model point and its spatial direction vector are obtained. The three-dimensional digital model point and the spatial direction vector are associated and stored in the standard information database.

[0068] The above standard information database storage process only needs to be performed once. When conducting batch die-casting part inspections, the data in the standard information database can be directly called.

[0069] When inspecting die-cast parts, the following steps are used to detect defects in the top surface area of ​​the edges:

[0070] 1) The camera captures an image of the current die-cast part, which is recorded as the image to be inspected;

[0071] Obtain the transformation matrix RT between the camera coordinate system and the current die-cast part's digital model coordinate system. 检测 ;

[0072] 2) Using the camera intrinsic parameter matrix and transformation relation matrix RT 检测 Each 3D digital model point and its spatial direction vector stored in the standard information database are converted into the image to be examined, resulting in conversion point A. k and its direction vector E k k = 1, 2...N, where N is the sum of the number of edge points and top surface points;

[0073] 3) At each transition point A k Find and transform point A along the direction vector respectively. k Calculate the average grayscale value of the G nearest pixels. If the average grayscale value is similar to that of the transition point A, then... k If the difference between the gray values ​​at a given point is greater than the threshold, then mark the transition point A. k The image coordinates indicate the location of the defect point.

[0074] Since defect points are often discrete, it is difficult to effectively identify the location of abnormal areas. Therefore, as a preferred implementation method, abnormal areas (defect areas) are further identified through skeleton points, as follows:

[0075] In the standard part image, manually select the top surface area of ​​the edge, and obtain skeleton points in the top surface area of ​​the edge, with the distance between adjacent skeleton points being less than L pixels; use the transformation relation matrix RT 标准 Transform each skeleton point into the digital model coordinate system to obtain the corresponding 3D skeleton point and store it in the standard information database.

[0076] It also includes step 4): using the camera intrinsic parameter matrix and the transformation relation matrix RT 检测 Each 3D skeleton point stored in the standard information database is converted into the image to be inspected to obtain the converted skeleton points;

[0077] For each conversion skeleton point, find the number of defect points in the area surrounding the single conversion skeleton point. If the number is greater than the preset value I, mark the conversion skeleton point as an abnormal point.

[0078] If the length of consecutive abnormal points is greater than the preset value II, then the local area on the top surface of the edge where the abnormal point is located is marked as an abnormal area.

[0079] Specifically, taking each transformation skeleton point as the center, the number of defect points in the area surrounding a single transformation skeleton point is found as follows:

[0080] like Figure 3 A rectangular region is drawn centered on the transformed skeleton point, with the shorter side of the rectangular region parallel to the extension direction of the edge. The number of defect points is then found within the rectangular region. In this embodiment, the longer side of the rectangular region is greater than or equal to the width of the edge.

[0081] In practice, L is set to 2-5; preset value I is set to 10-50; preset value II is set to 10-50; S is set to 5-10; and G is set to 5-30.

[0082] In detail, let Q be the edge point / top surface point. i The direction vector is H i ;

[0083] Q, the edge point / top point i and its direction vector H i Transform them to the digital model coordinate system to obtain the corresponding three-dimensional digital model points Q. i ''' and its spatial direction vector H i The method is as follows:

[0084] Using the camera intrinsic parameter matrix to locate point Q i and its direction vector H i Transform to the camera coordinate system to obtain the 3D point Q. i 'and direction vector H i ';

[0085] Using RT 标准 The three-dimensional point Q i 'and direction vector H i 'And the camera optical center C is transformed into the digital model coordinate system, corresponding to point Q.' i ''、Direction H i '', and the camera optical center C'; calculate point Q i The intersection point Q of the ray R formed by the optical center C of the camera and the digital model of the die-cast part. i ''', the intersection point Q i Let's denote the edge point Q. i The corresponding three-dimensional digital model points;

[0086] Obtain the intersection point Q i The digital model triangle A contains '''; with the direction of ray R and direction H i The cross product vector of '' is the normal vector, passing through the intersection point Q. i Construct plane B; denote the direction vector of the line intersecting triangular facet A and plane B as the spatial direction vector H. i '''.

[0087] More specifically, let the three-dimensional digital model point be denoted as Q. i The spatial direction vector is H. i ''';

[0088] The three-dimensional digital model point Q i ''' and its spatial direction vector H i '''Transformed into the image to be inspected, the transformation point A is obtained. k and its direction vector E k The method is as follows:

[0089] Based on the transformation relation matrix RT 检测 The three-dimensional digital model point Q i ''' and its spatial direction vector H i Transforming to the camera coordinate system, we get point A. k 'and direction E k ';

[0090] Calculation by A k The intersection point A of the ray R pointing to the optical center of the camera and the image plane. k '';

[0091] Assume the direction of ray R' and direction E k The cross product of ' is the normal, passing through intersection point A. k The plane F of '';

[0092] Obtain the direction vector E of the intersection line between the image plane and plane F. k '';

[0093] Using the camera intrinsic parameter matrix, the intersection point A k '' and direction vector E k Transform to the image coordinate system to obtain transformation point A. k and direction vector E k .

[0094] Since there are two straight lines in different directions at the corners of the elongated edge region, this is a preferred implementation method:

[0095] During the acquisition of the standard information database, the edge points of the top surface region of the edge are obtained. For each edge point, the following processing is performed: T neighboring edge points are found on both sides of a single edge point. Straight lines are fitted using the edge points found on both sides to obtain the direction vectors of the two lines. The angle between the two direction vectors is then determined.

[0096] If the included angle is less than the preset value III, then the edge points found on both sides are used to fit a straight line together, and the direction vector of the line fit together is stored in correspondence with the image coordinates of the current edge point.

[0097] If the included angle is not less than the preset value III, the fitting error (distance from the edge point to the line) of each fitted line is obtained, and the direction vector of the line with the smaller fitting error is stored corresponding to the current edge point; where the preset value III is 10°~30°.

[0098] This embodiment also provides a method for obtaining the transformation relationship matrix between the camera coordinate system and the digital model coordinate system, the steps of which are as follows:

[0099] The camera used to capture images of die-cast parts is referred to as the image acquisition camera;

[0100] At least two auxiliary cameras are placed around the image acquisition camera. Multiple cameras acquire images of the die casting, resulting in multiple images. Any two cameras form a binocular system. The common field of view of all cameras includes multiple edge features on the die casting. At least four non-parallel edge features are selected and marked as edges to be processed. In the die casting digital model, the planes corresponding to the edges to be processed are marked as planes to be processed. Each edge to be processed and the plane to be processed are stored accordingly.

[0101] The transformation matrix between the camera coordinate system and the digital model coordinate system is obtained using the following steps:

[0102] ① Select the edges to be processed from multiple images and extract the edge lines of each edge to be processed;

[0103] The image captured by the imaging camera is designated as the first image; other images are designated as auxiliary images.

[0104] The edge lines extracted from the first image are denoted as the first edge lines; the edge lines selected in the auxiliary image are denoted as the auxiliary edge lines.

[0105] ②The following processing is performed on each first edge line:

[0106] Take any point (e.g., the midpoint) on the first edge line and denote it as point A. Using the fundamental matrix between the image acquisition camera and other cameras, find the epipolar line corresponding to point A in each auxiliary image. Calculate the intersection of the auxiliary edge line and the epipolar line. Find D neighboring pixels along the epipolar line on both sides of the intersection point. Record the intersection point and the D found pixels as potential points.

[0107] Let any one of the auxiliary images be the second image, and let the epipolar line in the second image be the reference epipolar line, and the suspected point in the second image be the reference point;

[0108] Using the fundamental matrix between the second image acquisition camera and other auxiliary cameras, the epipolar lines of each suspected point in the other auxiliary images are obtained in the second image and denoted as suspected epipolar lines.

[0109] In the second image, the intersection points between each suspected epipolar line and the baseline epipolar line are obtained, and the intersection points and each baseline point are stored in the point set C. The centroid of the point set C is recorded as the corresponding point B of point A.

[0110] ③ Using the extrinsic parameters between the cameras corresponding to the first and second images, reconstruct the three-dimensional coordinates (coordinates in the image acquisition camera coordinate system) of the multiple pairs of corresponding points obtained in step ②.

[0111] Based on the edge to be processed corresponding to the three-dimensional coordinates, find the plane to be processed and match the plane to be processed for each three-dimensional coordinate;

[0112] ④ Based on the distance between each three-dimensional coordinate and the corresponding plane to be processed, establish an objective function, and use the optimization method to iteratively find the rotation and translation matrix that minimizes the distance, which is denoted as the transformation relationship matrix between the camera coordinate system (image acquisition camera coordinate system) and the digital model coordinate system.

[0113] To further improve the accuracy of finding points with the same name, the following optimization steps are performed on point set C:

[0114] Get the coordinate components of each point in point set C on the X-axis / Y-axis. After rounding the coordinate components, if there are identical coordinate components, store the points corresponding to the identical coordinate components in the overlapping point set.

[0115] In point set C, points not stored in the overlapping point set are removed, and the centroid of point set C is denoted as point B, which is the same name as point A; wherein, the objective function is E(R,T) = ,in, Let represent the distance between the i-th 3D coordinate and its corresponding plane to be processed, n be the number of 3D coordinate points, R be the rotation matrix, and T be the translation matrix. The objective function is minimized by iteratively adjusting R and T using either the least squares method or the ICP point cloud registration method.

[0116] This method accurately locates the edge top surface region in the image to be inspected by using the digital model points in the top surface region, which solves the problem that the edge top surface is too thin and easily interfered with by the surrounding area, making it impossible to accurately locate the edge top surface. It also limits the direction of defect detection by using the direction vector, so that the points on the edge top surface are only compared in grayscale on the top surface region, which solves the problem of false defect detection due to interference from the side surface region.

[0117] The foregoing description of specific exemplary embodiments of the present invention is for illustrative and descriptive purposes. It is not intended to be exhaustive, nor to limit the invention to the precise forms disclosed; obviously, many changes and variations are possible in accordance with the foregoing teachings. The exemplary embodiments were chosen and described to explain the specific principles of the invention and its practical application, thereby enabling others skilled in the art to implement and utilize various exemplary embodiments of the invention, as well as their different alternatives and modifications. The scope of the invention is intended to be defined by the appended claims and their equivalents.

Claims

1. A method of detecting a top surface defect of a parting edge of a die casting, characterized by, Before the die casting detection, the following standard information base acquisition process is carried out: in the batch of die castings to be detected, a die casting without defects is selected as a standard part; a camera collects an image of the standard part, and an edge top surface region is framed in the image of the standard part; Edge points in the edge top surface region are acquired, and the following processing is performed for each edge point: S edge points are found around the edge point, a straight line is fitted by using the found edge points, a direction vector of the straight line is acquired, and the direction vector of the straight line is recorded as a direction vector of the current edge point; Pixel points in the edge top surface region are recorded as top surface points, and the following processing is performed for each top surface point: the nearest edge point to the top surface point is found, and the direction vector corresponding to the edge point is recorded as the direction vector of the top surface point; The camera intrinsic parameter matrix and the conversion relationship matrix RT between the camera coordinate system and the standard part model coordinate system are pre-acquired 标准 The edge points and their direction vectors, the top surface points and their direction vectors are respectively converted to the model coordinate system, the corresponding three-dimensional model points and their spatial direction vectors are obtained, and the three-dimensional model points and the spatial direction vectors are stored in the standard information library. When the die casting detection is performed, the following steps are used to detect defects in the edge top surface region: 1) A camera collects an image of a current die casting, which is recorded as a detection image; obtaining a conversion relationship matrix RT between the camera coordinate system and the current die casting numerical model coordinate system 检测 ; 2) using camera intrinsic matrix and transformation matrix RT 检测 Each three-dimensional model point and its spatial direction vector stored in the standard information library are converted into the to-be-inspected graph respectively to obtain converted point A k and its direction vector E k ; k = 1, 2 … N, N is the sum of the number of edge points and top points. 3) At each conversion point A k , respectively, find the G pixel points closest to the conversion point A k in the direction vector, calculate the average gray value of the G pixel points, and if the difference between the average gray value and the gray value of the conversion point A k is greater than a threshold value, mark the image coordinates where the conversion point A k is located as the defect point position.

2. The method of detecting the edge top surface defect of the die casting according to claim 1, wherein: An edge top surface region is manually framed in the image of the standard part, and skeleton points are acquired in the edge top surface region, and the distance between adjacent skeleton points is less than L pixels; Using the conversion relationship matrix RT 标准 Convert each skeleton point to the digital model coordinate system to obtain the corresponding three-dimensional skeleton point of each skeleton point and store it in the standard information library. Also comprising step 4): using camera intrinsic matrix and conversion relationship matrix RT 检测 Converting each three-dimensional skeleton point stored in the standard information base into the to-be-inspected image respectively to obtain converted skeleton points; The number of defect points in the region around each conversion skeleton point is found, and if the number is greater than a preset value I, the conversion skeleton point is marked as an abnormal point; If the length of the continuous abnormal points is greater than a preset value II, the local region of the edge top surface where the abnormal points are located is marked as an abnormal region.

3. The method of detecting the edge top surface defect of the die casting according to claim 2, wherein: The number of defect points in the region around each conversion skeleton point is found in the following manner: A rectangular region is made with the conversion skeleton point as the center, and the short side direction of the rectangular region is parallel to the extension direction of the edge, and the number of defect points in the rectangular region is found.

4. The method of detecting the edge top surface defect of the die casting according to claim 2, wherein: L is 2-5; the preset value I is 10-50; and the preset value II is 10-50.

5. The method of detecting edge top surface defects of a die casting according to claim 1, wherein: S is 5-10; and G is 5-30.

6. The method of detecting edge top surface defects of a die casting according to claim 1, wherein: Edge point / Top point is Q i Direction vector is H i ; The edge point / top surface point Q i and its directional vector H i are respectively converted into the digital model coordinate system to obtain the corresponding three-dimensional digital model point Q i and its spatial directional vector H i in the following manner: The point Q i and its direction vector H i are converted to the camera coordinate system by using the camera intrinsic matrix, to obtain a three-dimensional point Q i and a direction vector H i . Using RT 标准 The three-dimensional point Q i ' and the direction vector H i ' are converted to the digital-analog coordinate system, and the corresponding points Q i '', the direction H i '', and the camera optical center C' are obtained; Calculate point Q i The intersection point Q of the ray R formed by the optical center C of the camera and the digital model of the die-cast part. i ''', the intersection point Q i Let's denote the edge point Q. i The corresponding three-dimensional digital model points; Obtain the intersection point Q i The direction of the ray R and the direction H i The cross product vector of the direction of the ray R and the direction H i Make the plane B through the intersection point Q i The direction vector of the line intersecting the triangle A and the plane B is the spatial direction vector H 7. The method of detecting the edge top surface defect of the die casting according to claim 6, wherein: The three-dimensional model point is Q i The spatial direction vector is H i '; The three-dimensional model point Q i and its spatial directional vector H i are converted into the image to be examined, respectively, to obtain the converted point A k and its directional vector E k in the following manner: According to the conversion relationship matrix RT 检测 Convert the three-dimensional model point Q i ' and its spatial direction vector H i ' to the camera coordinate system, and correspondingly obtain point A k ' and direction E k '; A k The intersection A of the ray R' pointing to the camera optical center and the image plane k ''; The direction of the ray R' has the cross product with the direction E k of the plane F passing through the intersection point A k of the plane F passing through the intersection point A acquiring a direction vector E of the intersection of the image plane with the plane F k ''; The intersection point A k and the direction vector E k are converted to the image coordinate system using the camera intrinsic matrix, resulting in the converted point A k and the direction vector E k .

8. The method of detecting edge top surface defects of a die casting according to Claim 1, wherein: In the standard information base acquisition process, the edge points in the edge top surface region are acquired, and the following processing is performed for each edge point: T adjacent edge points are found on both sides of the single edge point, a straight line is fitted by using the edge points found on both sides, the direction vectors of the two straight lines are acquired, and the included angle between the two direction vectors is determined: If the included angle is less than a preset value III, a straight line is fitted by using the edge points found on both sides, and the direction vector of the fitted straight line is stored in correspondence with the image coordinates of the current edge point; If the included angle is not less than the preset value III, the fitting errors of the fitted straight lines are respectively acquired, and the direction vector of the straight line with the smaller fitting error is stored in correspondence with the current edge point; and the preset value III is 10°-30°.

9. The method of detecting edge top surface defects of a die casting according to Claim 1, wherein: The conversion relationship matrix between the camera coordinate system and the digital model coordinate system is acquired in the following manner: A camera used to collect the image of the die casting is recorded as an image collection camera; At least two auxiliary cameras are placed around the image acquisition camera, and multiple cameras acquire die casting images to obtain multiple images, wherein any two cameras form a binocular system, and the common field of view of all cameras includes multiple edge features on the die casting, at least four non-parallel edge features are selected from the edge features, and the at least four non-parallel edge features are denoted as to-be-processed edges, in the die casting model, planes corresponding to the to-be-processed edges are denoted as to-be-processed planes, and each pair of to-be-processed edge and to-be-processed plane is stored correspondingly; The conversion relationship matrix between the camera coordinate system and the model coordinate system is obtained by the following steps: ①In the multiple images, the to-be-processed edges are selected respectively, and the edge lines of the to-be-processed edges are extracted respectively; The image acquired by the image acquisition camera is denoted as a first image; and other images are denoted as auxiliary images; The edge lines extracted in the first image are denoted as first edge lines; and the edge lines selected in the auxiliary images are denoted as auxiliary edge lines; ②The following processing is performed on each first edge line: A point on the first edge line is selected at random and denoted as point A; the epipolar line corresponding to point A in each auxiliary image is searched by using the fundamental matrix between the image acquisition camera and other cameras, the intersection points of the auxiliary edge lines and the epipolar lines are calculated, and D adjacent pixel points on both sides of the intersection points are searched along the epipolar lines; the intersection points and the D pixel points searched are denoted as suspected points; Any one of the auxiliary images is denoted as a second image, the epipolar line in the second image is denoted as a reference epipolar line, and the suspected points in the second image are denoted as reference points; The epipolar lines of the suspected points in other auxiliary images in the second image are obtained by using the fundamental matrix between the image acquisition camera of the second image and other auxiliary cameras, and the epipolar lines are denoted as suspected epipolar lines; In the second image, the intersection points between the suspected epipolar lines and the reference epipolar line are obtained, and the intersection points and the reference points are stored in a point set C; and the centroid point of the point set C is denoted as the homonymous point B of point A; ③The three-dimensional coordinates of the multiple pairs of homonymous points obtained in step ② are reconstructed by using the external parameters between the cameras corresponding to the first image and the second image; According to the to-be-processed edges corresponding to the three-dimensional coordinates, the to-be-processed planes are searched, and the to-be-processed planes are matched with the three-dimensional coordinates respectively; ④A target function is established based on the distances between the three-dimensional coordinates and the corresponding to-be-processed planes, and a rotation and translation matrix that minimizes the distances is iteratively obtained by using an optimization method, and the rotation and translation matrix is denoted as the conversion relationship matrix between the camera coordinate system and the model coordinate system.

10. The method of detecting edge top surface defects of a die casting according to claim 9, wherein: The following steps are further performed on the point set C: The coordinate components of the points in the point set C on the X-axis and the Y-axis are obtained, the coordinate components are rounded, and if there are same coordinate components, the points corresponding to the same coordinate components are stored in an overlapping point set; In the point set C, the points not stored in the overlapping point set are removed, and the centroid point of the point set C is denoted as the homonymous point B of point A. The objective function is E(R, T) = åi=1n||xi - (Rxi + T)||2 wherein, denotes the distance value between the ith three-dimensional coordinate and its corresponding to-be-processed plane, n is the number of three-dimensional coordinate points, R is a rotation matrix, and T is a translation matrix.