A material hardness detection method and system based on image recognition
Patent Information
- Application Number
- CN202610903647.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-23
- Publication Date
- 2026-10-13
AI Technical Summary
[0005]针对上述存在的技术不足,本发明的目的是提出一种基于图像识别的材料硬度检测方法,旨在解决现有技术中在管材外壁和球面轴承等曲面零件表面采集压痕图像时,因表面法线与光轴不垂直导致压痕透视缩短畸变成椭圆,直接测量畸变压痕引入系统偏差且三维重建校正实时性不足的技术问题
本发明通过采用自适应直方图均衡化与高斯滤波对曲面单幅压痕图像进行预处理,增强了低对比度下压痕边缘的可辨识性,为后续亚像素级边缘定位提供了高质量输入;同时,利用基于Zernike矩的亚像素边缘检测,将边缘定位精度提升至亚像素级别,为精确量化畸变特征奠定基础。
Smart Images

Figure CN122905941A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image recognition technology, and in particular to a method and system for detecting material hardness based on image recognition. Background Technology
[0002] Currently, in the hardness testing of curved parts such as pipe outer walls and spherical bearings, digital cameras are widely used to acquire indentation images. The diameter or diagonal dimensions of the indentation are then extracted through steps such as grayscale enhancement, edge detection, and ellipse fitting. The hardness value is then calculated using Brinell, Rockwell, or Vickers hardness formulas. This processing approach typically assumes the surface to be tested is an ideal plane and performs simple projection correction based on homography to directly reconstruct the geometric dimensions of the indentation from the image coordinates.
[0003] For example, when the surface to be measured is the outer wall of a pipe or the surface of a spherical bearing, the circular indentation is distorted into an ellipse in the image due to perspective shortening caused by the constantly changing angle between the normal to each point on the surface and the camera's optical axis. Following the planar assumption, directly measuring the major axis of the ellipse or the uncorrected diameter introduces systematic bias due to higher-order perspective shortening caused by the tilt angle, and this bias increases significantly as the radius of curvature decreases and the tilt angle increases. While 3D reconstruction-assisted correction can restore the surface morphology, it requires additional 3D scanning equipment and complex data processing, has poor real-time performance, and is difficult to deploy on high-speed online inspection production lines.
[0004] Therefore, there is an urgent need for a material hardness testing method that can automatically estimate the curvature of local surfaces and the tilt angle of normals for curved parts such as pipe outer walls and spherical bearings using only a single indentation image, without presetting the workpiece curvature radius or adding three-dimensional measurement hardware, and perform precise geometric correction of perspective distortion indentations, so as to eliminate system bias and significantly improve the accuracy and online detection efficiency of curved surface hardness testing. Summary of the Invention
[0005] To address the aforementioned technical shortcomings, the purpose of this invention is to propose a material hardness detection method based on image recognition. This method aims to solve the technical problems in the prior art where, when acquiring indentation images on the outer wall of pipes and curved parts such as spherical bearings, the surface normal is not perpendicular to the optical axis, causing the indentation to be distorted into an ellipse due to perspective shortening. Direct measurement of the distorted indentation introduces system bias, and the real-time performance of three-dimensional reconstruction correction is insufficient.
[0006] To solve the above-mentioned technical problems, the present invention adopts the following technical solution: The present invention provides a material hardness detection method based on image recognition.
[0007] The image recognition-based material hardness detection method includes: Step S10: Obtain a single indentation image of the curved part surface, and perform indentation region enhancement and denoising tasks based on the single indentation image using adaptive histogram equalization and Gaussian filtering mechanism, and output an enhanced and denoised indentation image; Step S20: Based on the enhanced and denoised indentation image, the sub-pixel edge detection mechanism of Zernike moments is used to perform the indentation edge extraction task, and the sub-pixel edge point set of the indentation is output; Step S30: Based on the indentation sub-pixel edge point set, the least squares ellipse fitting and discrete Fourier transform mechanism are used to perform the indentation edge morphology characterization task, and the reference ellipse parameters, second harmonic amplitude and fourth harmonic amplitude are output. Step S40: Based on the reference ellipse parameters, second-order harmonic amplitude and fourth-order harmonic amplitude, the surface parameter inversion task is performed using the perspective projection surface coupled bending model and joint iterative optimization mechanism, and the local surface normal tilt angle and equivalent radius of curvature are output. Step S50: Based on the local surface normal tilt angle and the equivalent radius of curvature, perform hardness calculation on the indentation sub-pixel edge point set using the back projection arc length recovery mechanism, and output the material hardness value.
[0008] Preferably, step S10, which involves acquiring a single indentation image of the curved part surface, performing indentation region enhancement and denoising based on the single indentation image using adaptive histogram equalization and Gaussian filtering mechanisms, and outputting an enhanced and denoised indentation image, specifically includes: Step S101: Acquire a single original image of the surface of the curved part after an indentation is formed under a given test force using a digital camera. The surface of the curved part is the outer wall of a pipe, the surface of a spherical part, or a local curved surface with a stable curvature. Step S102: Convert the single original image into a grayscale image, and perform adaptive histogram equalization on the grayscale image to enhance the grayscale contrast between the indentation edge and the curved background, thereby obtaining an equalized indentation image. Step S103: Apply a 5×5 Gaussian filter kernel to the equalized indentation image to suppress random noise and obtain an enhanced denoised indentation image, wherein the enhanced denoised indentation image serves as the input image for sub-pixel edge extraction in step S20.
[0009] Preferably, step S20, which involves performing indentation edge extraction based on the enhanced and denoised indentation image using a Zernike moment sub-pixel edge detection mechanism and outputting a set of indentation sub-pixel edge points, specifically includes: Step S201: The enhanced and denoised indentation image is processed by adaptive threshold segmentation and morphological closing operation to extract the indentation region and obtain indentation candidate regions; Step S202: Use the Canny operator to perform coarse localization within the candidate indentation area to obtain a pixel-level edge point set; Step S203: For each edge point in the pixel-level edge point set, the Zernike moment method is used to calculate the sub-pixel offset of the edge grayscale transition, and the pixel-level edge points are corrected to sub-pixel positions to obtain the indentation sub-pixel edge point set:
[0010] in, For the sub-pixel edge point set of the indentation, and The first The x and y coordinates of each sub-pixel edge point in the image coordinate system This represents the number of subpixel edge points of the indentation.
[0011] Preferably, in step S202, after coarse positioning using the Canny operator, the method further includes a step of correcting the edge point positions using an improved Zernike moment method, specifically including: For the grayscale distribution in the neighborhood of a pixel-level edge point in a pixel-level edge point set, calculate the Zernike moment magnitude and Zernike moment phase, determine the edge normal direction based on the Zernike moment phase, and determine the sub-pixel offset of the edge point along the edge normal direction based on the Zernike moment magnitude. When the subpixel offset is greater than 0.5 pixels, the subpixel offset is truncated to 0.5 pixels. When the sub-pixel offset is less than 0.1 pixels, the original pixel-level edge point position is retained; When the subpixel offset is greater than or equal to 0.1 pixels and less than or equal to 0.5 pixels, the edge point position is corrected according to the subpixel offset.
[0012] Preferably, step S30, which involves performing the indentation edge morphology representation task based on the indentation sub-pixel edge point set using least-squares ellipse fitting and discrete Fourier transform mechanisms, and outputting the reference ellipse parameters, second-order harmonic amplitude, and fourth-order harmonic amplitude, specifically includes: Step S301: Perform least-squares ellipse fitting on the indentation sub-pixel edge point set to obtain reference ellipse parameters, the reference ellipse parameters including the ellipse center coordinates. Long half shaft short half shaft and major axis rotation angle ,in, and These are the x and y coordinates of the ellipse center in the image coordinate system, and the semi-major axis. Used to represent the length of the major semi-axis and minor semi-axis of the indentation projection ellipse. Used to represent the length of the minor semi-axis and the rotation angle of the major axis of the indentation projection ellipse. Used to indicate the angle of rotation of the major semi-axis relative to the horizontal axis of the image; Step S302: Using the coordinates of the center of the ellipse Using the origin of polar coordinates, the set of indentation sub-pixel edge points is converted into a radius function. :
[0013] in, and The first Image coordinates of sub-pixel edge points of the indentation. For the first The polar angle of each indentation sub-pixel edge point relative to the center of the ellipse; Step S303: For the radius function Perform Discrete Fourier Transform to extract the second harmonic amplitude. Second harmonic phase Fourth harmonic amplitude Phase of the fourth harmonic And the reference ellipse parameters and the second harmonic amplitude and the amplitude of the fourth harmonic As the input for the surface parameter inversion in step S40, where, Used to characterize the degree of ellipticity in the indentation projection. Used to characterize the degree of four-lobed edge distortion caused by curvature bending.
[0014] Preferably, in step S40, the step of performing the surface parameter inversion task based on the reference ellipse parameters, the second harmonic amplitude, and the fourth harmonic amplitude, using a perspective projection surface coupled bending model and a joint iterative optimization mechanism, and outputting the local surface normal tilt angle and equivalent radius of curvature, specifically includes: Step S401: The polar coordinate radius function of the indentation edge points after perspective projection by the camera is approximated by Taylor expansion and perturbation theory to obtain the predicted second-order harmonic relation. And the prediction formula for fourth-order harmonics ; Step S402: Initialize the parameters to be solved, based on the semi-major axis in the reference ellipse parameters. and short half shaft Calculate the initial tilt angle :
[0015] Initial true radius Set to:
[0016] in, This is the initial value of the local surface normal inclination angle. This is the initial value for the true radius of the indentation. The average radius obtained from the radius function in step S30; and the amplitude of the fourth harmonic Initial tilt angle and initial true radius Substituting into the predicted fourth harmonic relationship The inverse solution yields the initial equivalent radius of curvature. ; Step S403: Construct the objective function :
[0017] in, The equivalent radius of curvature in the current iteration , and These are the preset weights corresponding to the second-order harmonic error term, the fourth-order harmonic error term, and the radius of curvature constraint term, respectively. When the objective function When the preset convergence condition is met or the preset maximum number of iterations is reached, the local surface normal tilt angle is output. and the equivalent radius of curvature .
[0018] Preferably, step S50, which involves performing a hardness calculation task on the indentation sub-pixel edge point set using a back-projection arc length recovery mechanism based on the local surface normal tilt angle and the equivalent radius of curvature, and outputting the material hardness value, specifically includes: Step S501: Based on the local surface normal tilt angle and the equivalent radius of curvature, the sub-pixel edge point set of the indentation is mapped to the indentation center tangent plane using the pinhole back projection and surface arc length unfolding algorithm, and the true equivalent diameter of the indentation is calculated along the surface unfolding. ; Step S502: According to the preset test force The preset indenter geometry parameters and the true equivalent diameter of the indentation. The material hardness value is calculated based on the preset corresponding hardness standard formula; Step S503: Output the material hardness value and the correction confidence index, wherein the correction confidence index is based on the objective function. The number of effective points in the indentation sub-pixel edge point set The second harmonic amplitude and the amplitude of the fourth harmonic Confirmation is used to indicate whether the current hardness test result meets the preset reliable output conditions.
[0019] The present invention also provides a material hardness detection system based on image recognition, comprising: The image preprocessing module is used to acquire a single indentation image of the surface of the curved part, and to perform an enhanced and denoised indentation region task based on the single indentation image using adaptive histogram equalization and Gaussian filtering mechanism, and output an enhanced and denoised indentation image. The edge detection module is used to perform the indentation edge extraction task based on the enhanced and denoised indentation image using a Zernike moment sub-pixel edge detection mechanism, and output the indentation sub-pixel edge point set; The harmonic analysis module is used to perform the indentation edge morphology characterization task based on the indentation sub-pixel edge point set using least squares ellipse fitting and discrete Fourier transform mechanism, and outputs the reference ellipse parameters, second-order harmonic amplitude and fourth-order harmonic amplitude. The surface parameter inversion module is used to perform surface parameter inversion tasks based on the reference ellipse parameters, second-order harmonic amplitude, and fourth-order harmonic amplitude, using a perspective projection surface coupled bending model and a joint iterative optimization mechanism, and outputs the local surface normal tilt angle and equivalent radius of curvature. The hardness calculation module is used to perform hardness calculation tasks on the indentation sub-pixel edge point set using a back-projection arc length recovery mechanism based on the local surface normal tilt angle and the equivalent radius of curvature, and output the material hardness value.
[0020] The present invention also provides an image recognition-based material hardness testing device, the image recognition-based material hardness testing device comprising: a memory, a processor, and an image recognition-based material hardness testing program stored in the memory and executable on the processor, wherein the image recognition-based material hardness testing program implements the above method when executed by the processor.
[0021] The present invention also provides a computer program product, the computer program product including an image recognition-based material hardness detection program, which implements the above method when executed by a processor.
[0022] The beneficial effects of this invention are as follows: This invention preprocesses a single-image indentation image of a curved surface using adaptive histogram equalization and Gaussian filtering, enhancing the recognizability of indentation edges under low contrast and providing high-quality input for subsequent sub-pixel-level edge localization. At the same time, it utilizes Zernike moment-based sub-pixel edge detection to improve edge localization accuracy to the sub-pixel level, laying the foundation for accurate quantification of distortion features.
[0023] By introducing least-squares elliptic fitting and discrete Fourier transform to perform harmonic analysis on the distorted profile, the perspective distortion characteristics of the indentation are parameterized for the first time as reference ellipse parameters and second- and fourth-order harmonic amplitudes and phases. Based on the constructed perspective projection and surface coupled distortion model, the tilt angle of the three-dimensional surface normal and the equivalent radius of curvature are inverted from two-dimensional image information. Finally, the true size of the indentation is corrected through the back-projection arc length recovery mechanism. Attached Figure Description
[0024] Figure 1 This is a schematic flowchart of the first embodiment of a material hardness detection method based on image recognition according to the present invention. Detailed Implementation
[0025] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments.
[0026] Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0027] Example 1: As Figure 1 The diagram shown is a flowchart of a first embodiment of a material hardness detection method based on image recognition according to the present invention.
[0028] In the first embodiment, the material hardness detection method based on image recognition includes: Step S10: Obtain a single indentation image of the curved part surface, and perform indentation region enhancement and denoising tasks based on the single indentation image using adaptive histogram equalization and Gaussian filtering mechanism, and output an enhanced and denoised indentation image; The input for this step is a single image of an indentation formed on the surface of curved parts such as pipe outer walls or spherical bearings under a given test force, captured by a digital camera. This image includes the complete geometry of the indentation, perspective distortion caused by the curved surface, and the reflective characteristics of the metal surface. The adaptive histogram equalization mechanism does not uniformly stretch the grayscale of the entire image; instead, it remaps the grayscale values based on the grayscale distribution function within the local neighborhood centered on each pixel. For scenes with uneven lighting caused by the curvature of the surface, it can enhance the boundary contrast in the dark areas of the indentation while suppressing overexposure in the bright areas. The Gaussian filtering mechanism uses a 5×5 convolution kernel to smooth the equalized image, primarily used to reduce fine surface textures or high-frequency noise introduced by the sensor, without significantly shifting edge positions. The final output enhanced denoised indentation image has a clearer grayscale transition between the indentation boundary and the substrate, and the noise level is reduced. This image is directly used as the input for sub-pixel edge detection in step S20, so that the edge signal has a high signal-to-noise ratio and continuity in spatial distribution, providing a stable image basis for subsequent accurate edge localization.
[0029] After the combined processing of adaptive histogram equalization and Gaussian filtering, the intermediate image undergoes two changes. Firstly, the indentation boundaries, originally close to the substrate grayscale in the dark areas of the curved surface, are dynamically stretched, enhancing the local contrast on both sides of the edge. This makes it easier for subsequent edge detection operators to distinguish the boundary from the background, reducing missed detections or edge breaks caused by slight grayscale differences. Secondly, Gaussian filtering, while smoothing the image, effectively suppresses high-frequency details such as metal surface textures, making the image gradient calculation more stable and thus constraining false edge responses caused by noise. These two operations form a clear causal chain: a high-contrast, noise-suppressed image input makes subsequent Zernike moment-based subpixel edge detection less affected by local grayscale fluctuations when calculating moment features, thereby limiting the uncertainty of edge localization to a smaller range. Without such preprocessing, the low contrast and random noise in the original image directly interfere with the subpixel localization algorithm, resulting in significant coordinate fluctuations in the output edge point set, weakening the accuracy of the entire distortion contour analysis and parameter inversion chain.
[0030] In traditional image processing of indentation on curved surfaces, global histogram equalization or fixed threshold segmentation is often used to enhance the image. However, when dealing with regional brightness differences caused by the reflection of curved surfaces on metal surfaces, global operations can easily introduce new problems. For example, while global histogram equalization improves the contrast of dark areas, it may also excessively amplify noise in bright areas, even causing over-enhancement of some areas at the edge of the indentation. Simple global threshold segmentation causes edge expansion in reflective bright areas and edge contraction in dark areas, resulting in systematic deformation of the extracted contours. This step combines adaptive local contrast enhancement with Gaussian filtering at a specific scale to enhance weak edges without introducing additional artifacts or noise amplification. This approach improves the quality of curved surface indentation images at the algorithmic level without changing the lighting and camera hardware. It makes the boundary areas that were originally difficult to identify due to uneven lighting clear, providing a reliable data front-end for subsequent accurate quantification of distortion features and avoiding the introduction of boundary positioning errors into the subsequent inversion model due to improper preprocessing.
[0031] For example, in a scenario where Rockwell hardness testing is performed on the outer wall of an alloy pipe, the curvature of the pipe wall causes the indentation to receive more light near the arch, resulting in high grayscale, while the sloping areas on both sides are less bright because they face away from the light source. In the original image, the grayscale difference between the boundary of the indentation on the side and the substrate is extremely small, almost indistinguishable. After this step, adaptive histogram equalization redistributes the grayscale values in the dark areas, which were originally concentrated in narrow intervals, based on the local grayscale distribution of the 8×8 neighborhood around each pixel. This makes the boundary contour of the indentation stand out from the background, while preventing large-scale overexposure in the bright areas. Subsequently, Gaussian filtering smooths the high-frequency pixel fluctuations caused by the fine tool marks on the pipe surface. In the processed enhanced and denoised indentation image, the indentation exhibits a relatively continuous and smooth boundary transition in the entire circumference. This image provides an ideal input source with uniform contrast and low noise level for the sub-pixel edge detection in step S20, allowing each segment of the indentation contour to be detected with similar confidence.
[0032] Step S20: Based on the enhanced and denoised indentation image, the sub-pixel edge detection mechanism of Zernike moments is used to perform the indentation edge extraction task, and the sub-pixel edge point set of the indentation is output; The direct object of this step is the enhanced and denoised indentation image output from step S10, and a sub-pixel edge point set of the indentation is generated based on it. This edge point set is a set of indentation boundary coordinates accurate to the sub-pixel level. The horizontal and vertical coordinates of each point are no longer integer row and column numbers, but floating-point numbers with decimal places. Its generation goes through three stages: First, the region of the indentation is extracted from the enhanced image using adaptive thresholding and morphological operations; then, the Canny operator is used for coarse localization within the region to obtain edge points with integer pixel accuracy; finally, for each pixel-level edge point, an improved Zernike moment is calculated in its small neighborhood. Using the relationship between the magnitude and phase of the Zernike moment and the ideal step edge model, the precise offset of the edge point at the sub-pixel scale is calculated, improving the localization accuracy to about 0.1 pixels. The output sub-pixel edge point set of the indentation is the direct data source for the ellipse fitting and discrete Fourier transform performed in step S30. Its high spatial accuracy determines the accuracy of subsequent harmonic feature extraction and distortion parameter quantization, and it is a key intermediary connecting image processing and geometric analysis.
[0033] Through this processing, the geometric description of the indentation contour is improved from a discrete pixel level to a continuous sub-pixel level. The grayscale change at the boundary of the indentation during optical imaging is gradual. Pixel-level edge detection is essentially sampling the nearest integer point of this continuous boundary. This quantization process itself loses information about minute spatial variations. For subsequent dimensional measurements requiring micrometer-level precision, these quantization errors are directly added to the indentation diameter or ellipse parameters. By introducing the improved Zernike moment sub-pixel edge detection mechanism, the true position of the indentation boundary is reconstructed using floating-point coordinates. This allows minute deformations, local fluctuations, and systematic contour changes caused by surface perspective distortion to be more completely preserved in the coordinate point set. This refined edge point set enables the ellipse fitting in step S30 to more accurately capture the changes in major and minor axes caused by surface tilt, and the discrete Fourier transform can more sensitively extract higher-order harmonic components representing distortion characteristics, avoiding the problems of fitting parameter shifts or harmonic information obscuring due to pixel-level quantization errors.
[0034] In traditional material hardness image detection processes, obtaining the indentation diameter largely relies on pixel-level edges. This can be achieved by statistically analyzing the horizontal or vertical span of connected components in a binary image, or by performing circle fitting on integer pixel edge points. When the image spatial resolution is 10 micrometers per pixel, a misjudgment of even a single pixel at the outermost edge can result in a diameter deviation on the order of 10 micrometers, which is already quite significant for small indentations. In curved surfaces such as pipe outer walls, perspective distortion is a systematic, gradual deformation. Its subtle effects on the contour require sub-pixel-level coordinates for accurate quantification. Using only pixel-level edges often results in the loss of these higher-order details due to discretization. This step employs a sub-pixel edge detection method based on Zernike moments, utilizing the moment characteristics along the edge gradient direction for localization. This method is insensitive to edge direction and is particularly suitable for circular or elliptical contours. Without adding extra hardware or altering the optical path, the localization accuracy is improved by nearly an order of magnitude, enabling subsequent harmonic analysis to capture the subtle contour fluctuations caused by curvature coupling. This solves the difficulty of accurately inverting surface parameters due to excessive quantization errors in traditional methods.
[0035] For example, suppose an indentation image acquired from the surface of a spherical bearing has an actual indentation diameter of approximately 500 micrometers, with the upper boundary of the image spreading to a width of 3 to 5 pixels. If the traditional Canny operator is used, which only outputs integer pixel coordinates, the location of any boundary point will be at a discrete integer position, and the fitted diameter may fluctuate around discrete values such as 488 micrometers or 512 micrometers. However, in this step, for each initial pixel-level edge point within the indentation area, the improved Zernike moment method calculates a complex moment in its 7×7 neighborhood and uses the grayscale profile of that point to match an ideal step model, accurately locating the edge at a sub-pixel position between two integer pixels. For example, the final coordinates of an edge point may be 0.43 pixels away from the pixel center. After finely locating all edge points, the complete set of sub-pixel edge points constitutes a smooth and continuous contour, which records the minute asymmetries and distortion details of the indentation shape. This high-precision point set compresses the basic uncertainty of diameter measurement to the micrometer level, providing the necessary data foundation for the precise quantification of the contour harmonic components caused by perspective shortening in step S30.
[0036] Step S30: Based on the indentation sub-pixel edge point set, the least squares ellipse fitting and discrete Fourier transform mechanism are used to perform the indentation edge morphology characterization task, and the reference ellipse parameters, second harmonic amplitude and fourth harmonic amplitude are output. This step uses the indentation sub-pixel edge point set output in step S20 as the processing object. Through least-squares ellipse fitting and discrete Fourier transform, it outputs the reference ellipse parameters and the amplitude and phase of the harmonic components. The reference ellipse parameters include the center coordinates of the ellipse, the major semi-axis a, the minor semi-axis b, and the major axis rotation angle. These are mathematical descriptions of the overall macroscopic shape of the distorted indentation, reflecting the primary effect of projecting a perfect circle into an ellipse due to the inclination of the surface normal. The Discrete Fourier Transform deals with the polar coordinate radius function established with the center of the ellipse as the origin. That is, the distance from each edge point to the center of the ellipse varies with the azimuth angle. The change in radius function. After performing spectral analysis on this radius function, the average radius C0, the second harmonic amplitude C2, and the phase can be obtained. Fourth harmonic amplitude C4 and phase C2 primarily characterizes the symmetry distortion caused by perspective shortening, while C4 reflects higher-order deformation resulting from the coupling of surface curvature and tilt angle. The relationship between the second-order and fourth-order harmonic phases was also observed and recorded during the procedure. ≈ This feature provides a basis for subsequently distinguishing the contributions of tilt and curvature. These parameters constitute the observation input of the perspective projection and surface coupling model in step S40, and serve as a bridge connecting two-dimensional image features with three-dimensional physical parameters.
[0037] This process transforms the originally complex nonlinear distortion contour into a set of feature quantities with clear physical meaning. Least squares ellipse fitting provides a regular reference geometry for the contour, identifying the direction of maximum deformation caused by surface tilt as the direction of the ellipse's minor axis. However, the indentation distortion on the real surface is not a perfect ellipse; it also contains contour fluctuations that cannot be described by a single ellipse. The role of discrete Fourier transform is to extract these residual fluctuations, systematically decomposing the deviation between the indentation contour and the reference ellipse into harmonic components of different frequencies. The second harmonic C2 carries the main tilt distortion information, and its amplitude is related to the tilt angle; the fourth harmonic C4 mainly originates from the coupling effect of surface curvature and tilt, and is a key feature quantity for decoupling the radius of curvature and the tilt angle. By accurately extracting these harmonic components, the surface parameter inversion in step S40 can obtain sufficient constraints, avoiding the multiple solutions that may occur when solving solely with ellipse parameters. The entire process transforms the image contour problem into a mathematical model problem with analytical relationships, providing a clear foundation for constructing the objective function for subsequent iterative optimization.
[0038] Traditional methods for indenting curved surfaces typically involve directly fitting an ellipse and then substituting its major or minor axis, or some average of both, as the indentation diameter into the hardness formula, completely ignoring the internal differences in distortion characteristics under different surface conditions. This approach essentially simplifies complex three-dimensional projection distortion into a simple two-dimensional elliptical problem. When the workpiece's radius of curvature is small or the tilt angle is large, the relationship between the major axis and the true diameter is no longer a simple linear mapping, and directly using the major axis introduces systematic biases. This step introduces Discrete Fourier Transform (DFT) for harmonic analysis, preserving not only the macroscopic shape described by the elliptical parameters but also extracting high-frequency details such as second- and fourth-order harmonic components. In previous techniques, this high-order harmonic information was often discarded as interference, but this step utilizes it as crucial information. In particular, by capturing phase relationship characteristics... ≈ This step provides a criterion for distinguishing between tilt-dominated and curvature-dominated distortions, enabling step S40 to more accurately separate the two parameters based on harmonic characteristics during inversion, thus solving the problem of insufficient parameter interpretation caused by oversimplification of the model in previous techniques.
[0039] Step S40: Based on the reference ellipse parameters, second-order harmonic amplitude and fourth-order harmonic amplitude, the surface parameter inversion task is performed using the perspective projection surface coupled bending model and joint iterative optimization mechanism, and the local surface normal tilt angle and equivalent radius of curvature are output. This step takes the reference ellipse parameters (a, b, etc.) provided in step S30, as well as the second and fourth harmonic amplitudes C2 and C4 and their phases, as inputs. Based on the pre-built perspective projection and surface coupling distortion model and the joint iterative optimization mechanism, it inverts and outputs the local surface normal tilt angle. And the equivalent radius of curvature Rfinal. The perspective projection and surface coupled distortion model is the theoretical core of this step. It decomposes the spatial coordinates of any indentation edge point on the surface into the macroscopic displacement of the local micro-tangent plane and the local depth offset caused by the curvature of the surface. Then, through pinhole projection imaging, the predictive relationship related to the observable harmonic amplitude is derived. A joint iterative optimization mechanism constructs a cost function J that includes the second-order harmonic residual, the fourth-order harmonic residual, and the curvature radius prior constraint. By minimizing this cost function, iterative updates are performed synchronously until convergence. The output is directly used as the physical parameter for back-projection arc length recovery in step S50, which is the input basis for geometric correction.
[0040] When processing surface indentation based on a single image, retrieving the surface pose and curvature from a perspective-distorted elliptical image is inherently an ill-posed problem due to the lack of depth information. Traditional correction methods either assume the workpiece is a strictly cylindrical surface with a known nominal diameter or introduce additional structured light or a third-person perspective, but these approaches increase hardware complexity or limit applicability. The mechanism employed in this step does not rely on the CAD model or nominal dimensions of the workpiece as hard constraints. Instead, it utilizes the subtle image feature of the fourth harmonic generated by the surface curvature, explicitly expressing it in the model as the radius of curvature R and the tilt angle. The function is denoted by . Since the fourth harmonic is sensitive to changes in the radius of curvature, it, combined with the main tilt information provided by the second harmonic, is sufficient to provide enough constraints for the joint iterative optimization to overcome ill-conditioning. This approach, without adding additional equipment such as multi-view or structured light, calculates the surface parameters from the harmonic information of a single image, improving the adaptability of the detection method to workpieces with unknown curvature.
[0041] Step S50: Based on the local surface normal tilt angle and the equivalent radius of curvature, perform hardness calculation on the indentation sub-pixel edge point set using the back projection arc length recovery mechanism, and output the material hardness value.
[0042] The input to this step is the local surface normal tilt angle and equivalent radius of curvature output from step S40. The processing object is the sub-pixel edge point set of the indentation generated in step S20. The output is the material hardness value and the correction confidence index. The core task of the back-projection arc length recovery mechanism is to inversely map the edge point set on the two-dimensional distorted image back to the real surface in three-dimensional space using known surface spatial parameters, and then unfold along the surface to calculate the true arc length of the indentation. The specific process is as follows: using the pinhole back-projection principle, the two-dimensional sub-pixel edge points are inversely calculated into spatial points on the surface in the camera coordinate system; then these spatial points are unfolded along the surface arc to the central tangent plane, and the true equivalent diameter of the indentation is obtained by fitting on the tangent plane. Finally, the known test force, the geometric parameters of the indenter, and the correction diameter are substituted into the corresponding Vickers, Rockwell, or Brinell hardness standard formulas to calculate the material hardness value. The output correction confidence index evaluates the consistency of the entire inversion and correction process based on the cost function residual, providing a reliability reference for the measured value.
[0043] Traditional methods for hardness testing of pipes or spherical parts often involve directly measuring a diameter (such as the major or minor axis) of the elliptical profile on the distorted image and substituting it into a formula, or making corrections based on simple planar correction formulas. This approach, failing to consider the influence of surface curvature on projection and arc length, results in a deviation between the obtained diameter and the actual value related to the tilt angle and curvature. This deviation manifests differently on workpieces with varying curvatures and cannot be eliminated by a uniform calibration coefficient. This step, through a back-projection arc length recovery mechanism, switches the hardness calculation benchmark from "distorted image diameter" to "true arc length diameter in physical space." It not only corrects for perspective shortening caused by normal tilt but also compensates for the nonlinear difference between arc length and straight chord length caused by surface curvature—something traditional ellipse correction methods cannot address. Without introducing surface-specific calibration blocks or additional 3D scanning equipment, this mechanism successfully unifies indentation measurements on surfaces with different curvatures to a physical space benchmark, improving the accuracy and consistency of measurement results and resolving the long-standing problem of incomplete calibration in surface hardness testing.
[0044] For example, in a hardness sampling inspection scenario for titanium alloy pipes used in aerospace applications, the inversion process in the preceding steps yields a local surface normal tilt angle of 32° and an equivalent radius of curvature of 25 mm at the test point. After receiving this information, step S50 performs a back-projection operation on the sub-pixel edge point set of the indentation provided in step S20. Taking a sub-pixel point on the edge of the indentation as an example, its position on the image is "shortened" due to perspective projection. The back-projection algorithm calculates the coordinates of the corresponding three-dimensional curved surface based on the pinhole model and the known radius of curvature of 25 mm. Then, it unfolds along the curved surface to the tangent plane to obtain the position of the edge point on the unfolded circle, thereby calculating the arc segment length instead of the straight-line distance in space. After processing the entire circumference of the edge point set, the diameter of the circle fitted by all unfolded points is calculated to be 412.5 micrometers. Substituting this corrected diameter into the Brinell hardness formula, combined with a test force of 3000 kg and the parameters of the cemented carbide ball indenter, the hardness value is obtained as 285 HBW. Meanwhile, the output confidence index shows that the residuals in the solution process are at a low level, indicating that the correction results of this measurement are reliable.
[0045] Example 2: Furthermore, the present invention provides an image recognition-based material hardness detection system, employing an image recognition-based material hardness detection method as described in the above embodiments, which can solve the technical problem of image recognition-based material hardness detection. The beneficial effects of the image recognition-based material hardness detection system provided by the present invention are the same as those of the image recognition-based material hardness detection method provided in the above embodiments, and other technical features of the image recognition-based material hardness detection system are the same as those disclosed in the methods of the above embodiments, and will not be repeated here.
[0046] Example 3: This invention provides an image recognition-based material hardness testing device. The device includes at least one processor and a memory communicatively connected to the processor. The memory stores instructions executable by the processor, which are then executed to enable the processor to perform the image recognition-based material hardness testing method described in Example 1. This image recognition-based material hardness testing device can include, but is not limited to, mobile terminals such as mobile phones, laptops, digital radio receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Description), PMPs (Portable Media Players), and in-vehicle terminals (e.g., in-vehicle navigation terminals), as well as fixed terminals such as digital TVs and desktop computers. This image recognition-based material hardness testing device is merely an example and should not limit the functionality or scope of the invention. The device may also include a processing unit (e.g., a central processing unit, a graphics processing unit), which can perform various appropriate actions and processes based on a program stored in a read-only memory or a program loaded from a storage device into a random access memory. The random access memory also stores various programs and data required for the operation of an image recognition-based material hardness testing device. The processing unit, read-only memory, and random access memory are interconnected via a bus. The I / O interface is also connected to the bus. Typically, the following systems can be connected to the I / O interface: input devices including, for example, touchscreens, touchpads, keyboards, mice, image sensors, microphones, accelerometers, gyroscopes, etc.; output devices including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices including, for example, magnetic tapes, hard disks, etc.; and communication devices. The communication device allows the image recognition-based material hardness testing device to communicate wirelessly or wiredly with other devices to exchange data. While an image recognition-based material hardness testing device with various systems has been described, it should be understood that implementing or possessing all the systems described is not required. Alternatively, more or fewer systems can be implemented.
[0047] Example 4: This invention also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the image recognition-based material hardness detection method described above. The computer program product provided by this invention can solve the technical problem of image recognition-based material hardness detection. Compared with the prior art, the beneficial effects of the computer program product provided by this invention are the same as those of the image recognition-based material hardness detection method provided in the above embodiments, and will not be repeated here.
[0048] In particular, according to the embodiments disclosed in this invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this invention include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from a storage device, or installed from a read-only memory. When the computer program is executed by a processing device, it performs the functions defined in the methods of the embodiments disclosed in this invention.
[0049] It should be understood that the various parts disclosed in this invention can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics may be combined in any suitable manner in one or more embodiments or examples.
[0050] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Therefore, if these modifications and variations fall within the scope of the present invention and its equivalents, the present invention also intends to include these modifications and variations.
Claims
1. A material hardness detection method based on image recognition, characterized in that, The methods include: Step S10: Obtain a single indentation image of the curved part surface, and perform indentation region enhancement and denoising tasks based on the single indentation image using adaptive histogram equalization and Gaussian filtering mechanism, and output an enhanced and denoised indentation image; Step S20: Based on the enhanced and denoised indentation image, the sub-pixel edge detection mechanism of Zernike moments is used to perform the indentation edge extraction task, and the sub-pixel edge point set of the indentation is output; Step S30: Based on the indentation sub-pixel edge point set, the least squares ellipse fitting and discrete Fourier transform mechanism are used to perform the indentation edge morphology characterization task, and the reference ellipse parameters, second harmonic amplitude and fourth harmonic amplitude are output. Step S40: Based on the reference ellipse parameters, second-order harmonic amplitude and fourth-order harmonic amplitude, the surface parameter inversion task is performed using the perspective projection surface coupled bending model and joint iterative optimization mechanism, and the local surface normal tilt angle and equivalent radius of curvature are output. Step S50: Based on the local surface normal tilt angle and the equivalent radius of curvature, perform hardness calculation on the indentation sub-pixel edge point set using the back projection arc length recovery mechanism, and output the material hardness value.
2. The material hardness detection method based on image recognition as described in claim 1, characterized in that, In step S10, a single indentation image of the curved part surface is acquired. Based on the single indentation image, an adaptive histogram equalization and Gaussian filtering mechanism are used to perform indentation region enhancement and denoising tasks, and an enhanced and denoised indentation image is output. This step specifically includes: Step S101: Acquire a single original image of the surface of the curved part after an indentation is formed under a given test force using a digital camera. The surface of the curved part is the outer wall of a pipe, the surface of a spherical part, or a local curved surface with a stable curvature. Step S102: Convert the single original image into a grayscale image, and perform adaptive histogram equalization on the grayscale image to enhance the grayscale contrast between the indentation edge and the curved background, thereby obtaining an equalized indentation image. Step S103: Apply a 5×5 Gaussian filter kernel to the equalized indentation image to suppress random noise and obtain an enhanced denoised indentation image, wherein the enhanced denoised indentation image serves as the input image for sub-pixel edge extraction in step S20.
3. The material hardness detection method based on image recognition as described in claim 1, characterized in that, Step S20, which involves performing indentation edge extraction using a Zernike moment sub-pixel edge detection mechanism based on the enhanced and denoised indentation image, and outputting a set of sub-pixel edge points for the indentation, specifically includes: Step S201: The enhanced and denoised indentation image is processed by adaptive threshold segmentation and morphological closing operation to extract the indentation region and obtain indentation candidate regions; Step S202: Use the Canny operator to perform coarse localization within the candidate indentation area to obtain a pixel-level edge point set; Step S203: For each edge point in the pixel-level edge point set, the Zernike moment method is used to calculate the sub-pixel offset of the edge grayscale transition, and the pixel-level edge points are corrected to sub-pixel positions to obtain the indentation sub-pixel edge point set: in, For the sub-pixel edge point set of the indentation, and The first The x and y coordinates of each sub-pixel edge point in the image coordinate system This represents the number of subpixel edge points of the indentation.
4. The material hardness detection method based on image recognition as described in claim 3, characterized in that, In step S202, after coarse localization using the Canny operator, the method further includes correcting the edge point positions using the improved Zernike moment method, specifically including: For the grayscale distribution in the neighborhood of a pixel-level edge point in a pixel-level edge point set, calculate the Zernike moment magnitude and Zernike moment phase, determine the edge normal direction based on the Zernike moment phase, and determine the sub-pixel offset of the edge point along the edge normal direction based on the Zernike moment magnitude. When the subpixel offset is greater than 0.5 pixels, the subpixel offset is truncated to 0.5 pixels. When the sub-pixel offset is less than 0.1 pixels, the original pixel-level edge point position is retained; When the subpixel offset is greater than or equal to 0.1 pixels and less than or equal to 0.5 pixels, the edge point position is corrected according to the subpixel offset.
5. The material hardness detection method based on image recognition as described in claim 1, characterized in that, Step S30, which involves performing the indentation edge morphology representation task based on the sub-pixel edge point set using least-squares ellipse fitting and discrete Fourier transform mechanisms, and outputting the reference ellipse parameters, second-order harmonic amplitude, and fourth-order harmonic amplitude, specifically includes: Step S301: Perform least-squares ellipse fitting on the indentation sub-pixel edge point set to obtain reference ellipse parameters, the reference ellipse parameters including the ellipse center coordinates. Long half shaft short half shaft and major axis rotation angle ,in, and These are the x and y coordinates of the ellipse center in the image coordinate system, and the semi-major axis. Used to represent the length of the major semi-axis and minor semi-axis of the indentation projection ellipse. Used to represent the length of the minor semi-axis and the rotation angle of the major axis of the indentation projection ellipse. Used to indicate the angle of rotation of the major semi-axis relative to the horizontal axis of the image; Step S302: Using the coordinates of the center of the ellipse Using the origin of polar coordinates, the set of indentation sub-pixel edge points is converted into a radius function. : in, and The first Image coordinates of sub-pixel edge points of the indentation. For the first The polar angle of each indentation sub-pixel edge point relative to the center of the ellipse; Step S303: For the radius function Perform Discrete Fourier Transform to extract the second harmonic amplitude. Second harmonic phase Fourth harmonic amplitude Phase of the fourth harmonic And the reference ellipse parameters and the second harmonic amplitude and the amplitude of the fourth harmonic As the input for the surface parameter inversion in step S40, where, Used to characterize the degree of ellipticity in the indentation projection. Used to characterize the degree of four-lobed edge distortion caused by curvature bending.
6. The material hardness detection method based on image recognition as described in claim 5, characterized in that, In step S40, based on the reference ellipse parameters, second-order harmonic amplitude, and fourth-order harmonic amplitude, the surface parameter inversion task is performed using a perspective projection surface coupled bending model and a joint iterative optimization mechanism, outputting the local surface normal tilt angle and equivalent radius of curvature. This step specifically includes: Step S401: The polar coordinate radius function of the indentation edge points after perspective projection by the camera is approximated by Taylor expansion and perturbation theory to obtain the predicted second-order harmonic relation. And the prediction formula for fourth-order harmonics ; Step S402: Initialize the parameters to be solved, based on the semi-major axis in the reference ellipse parameters. and short half shaft Calculate the initial tilt angle : Initial true radius Set to: in, This is the initial value of the local surface normal inclination angle. This is the initial value for the true radius of the indentation. The average radius obtained from the radius function in step S30; and the amplitude of the fourth harmonic Initial tilt angle and initial true radius Substituting into the predicted fourth harmonic relationship The inverse solution yields the initial equivalent radius of curvature. ; Step S403: Construct the objective function : in, The equivalent radius of curvature in the current iteration , and These are the preset weights corresponding to the second-order harmonic error term, the fourth-order harmonic error term, and the radius of curvature constraint term, respectively. When the objective function When the preset convergence condition is met or the preset maximum number of iterations is reached, the local surface normal tilt angle is output. and the equivalent radius of curvature .
7. The material hardness detection method based on image recognition as described in claim 1, characterized in that, Step S50, which involves performing a hardness calculation task on the indentation sub-pixel edge point set using a back-projection arc length recovery mechanism based on the local surface normal tilt angle and the equivalent radius of curvature, and outputting the material hardness value, specifically includes: Step S501: Based on the local surface normal tilt angle and the equivalent radius of curvature, the sub-pixel edge point set of the indentation is mapped to the indentation center tangent plane using the pinhole back projection and surface arc length unfolding algorithm, and the true equivalent diameter of the indentation is calculated along the surface unfolding. ; Step S502: According to the preset test force The preset indenter geometry parameters and the true equivalent diameter of the indentation. The material hardness value is calculated based on the preset corresponding hardness standard formula; Step S503: Output the material hardness value and the correction confidence index, wherein the correction confidence index is based on the objective function. The number of effective points in the indentation sub-pixel edge point set The second harmonic amplitude and the amplitude of the fourth harmonic Confirmation is used to indicate whether the current hardness test result meets the preset reliable output conditions.
8. A material hardness testing system based on image recognition, applied to the material hardness testing method based on image recognition as described in any one of claims 1 to 7, characterized in that, The image recognition-based material hardness testing system includes: The image preprocessing module is used to acquire a single indentation image of the surface of the curved part, and to perform an enhanced and denoised indentation region task based on the single indentation image using adaptive histogram equalization and Gaussian filtering mechanism, and output an enhanced and denoised indentation image. The edge detection module is used to perform the indentation edge extraction task based on the enhanced and denoised indentation image using a Zernike moment sub-pixel edge detection mechanism, and output the indentation sub-pixel edge point set; The harmonic analysis module is used to perform the indentation edge morphology characterization task based on the indentation sub-pixel edge point set using least squares ellipse fitting and discrete Fourier transform mechanism, and outputs the reference ellipse parameters, second-order harmonic amplitude and fourth-order harmonic amplitude. The surface parameter inversion module is used to perform surface parameter inversion tasks based on the reference ellipse parameters, second-order harmonic amplitude, and fourth-order harmonic amplitude, using a perspective projection surface coupled bending model and a joint iterative optimization mechanism, and outputs the local surface normal tilt angle and equivalent radius of curvature. The hardness calculation module is used to perform hardness calculation tasks on the indentation sub-pixel edge point set using a back-projection arc length recovery mechanism based on the local surface normal tilt angle and the equivalent radius of curvature, and output the material hardness value.
9. A material hardness testing device based on image recognition, characterized in that, The image recognition-based material hardness testing device includes: a memory, a processor, and an image recognition-based material hardness testing program stored in the memory and executable on the processor. When the image recognition-based material hardness testing program is executed by the processor, it implements an image recognition-based material hardness testing method according to any one of claims 1 to 7.
10. A computer program product, characterized in that, The computer program product includes an image recognition-based material hardness detection program, which, when executed by a processor, implements an image recognition-based material hardness detection method according to any one of claims 1 to 7.