Automobile part defect detection method and system
By determining the optimal shooting position in the detection of defects of automobile parts and performing a series of processing on the image to generate target feature images, the problem of image noise affecting detection accuracy in the prior art is solved, and higher detection accuracy and accuracy are achieved.
Patent Information
- Application Number
- CN202510228979.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-28
- Publication Date
- 2025-03-28
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The prior art affects the accuracy of defect recognition due to the high image noise in automotive parts defect detection.
By obtaining the initial position and movement range of the camera of the automotive parts shooting, the optimal shooting position is determined; then the image is subjected to metal reflection elimination, Fourier transform filtering, transformation enhancement processing and feature extraction to generate the target feature image; finally, the target feature image is input into the training recognition model for defect detection.
It improves the clarity of the image, effectively eliminates the noise caused by metal reflection, highlights details, suppresses background information, and improves the accuracy and accuracy of defect detection.
Smart Images

Figure CN119722678A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of defect detection, and in particular relates to a method and system for detecting defects in automobile parts. Background Art
[0002] Auto parts are specifically components of an automobile body. More important auto parts are generally made of metal. Existing defect detection algorithms usually capture images of auto parts and then input the images into a trained model for defect detection. However, for actual auto parts, due to issues with their material, environment, and shooting location, there is a lot of noise in the image, which affects the accuracy of defect recognition. Summary of the invention
[0003] In order to solve the above technical problems, the present invention provides an automobile parts defect detection method and system, which are used to solve the technical problems in the prior art.
[0004] On the one hand, the present invention provides the following technical solution, a method for detecting defects in automobile parts, comprising: Acquire the initial position and moving range of the camera for photographing automobile parts, and determine the photographing position based on the initial position and the moving range; Acquire an image of an automobile part at a corresponding shooting position, and perform metal reflection elimination on the image of the automobile part to obtain a processed image; Performing Fourier transform filtering on the processed image to obtain a filtered image; Performing transformation enhancement processing on the filtered image to obtain an enhanced image, and performing feature extraction on the enhanced image to obtain a target feature image; A training image is acquired and input into a preset recognition model for training, and the target feature image is input into the trained preset recognition model for defect detection to output a defect detection result.
[0005] Compared with the prior art, the beneficial effects of the present invention are as follows: the present invention first obtains the initial position and the moving range of the camera for photographing automobile parts, and determines the photographing position based on the initial position and the moving range; then obtains the image of the automobile parts at the corresponding photographing position, and performs metal reflection elimination on the image of the automobile parts to obtain a processed image; then performs Fourier transform filtering processing on the processed image to obtain a filtered image; then performs transform enhancement processing on the filtered image to obtain an enhanced image, and performs feature extraction on the enhanced image to obtain a target feature image; finally, obtains a training image and inputs the training image into a preset recognition model for training, and inputs the target feature image into the trained preset recognition model for defect detection to output a defect detection result. First, the present invention determines the best shooting position, thereby improving the clarity of the photographed image, and then eliminates reflection on the image, which can effectively remove the noise caused by metal reflection in the image, and can also effectively highlight the details in the image, and then enhances and extracts features on the image, which can suppress the image background information and highlight the feature information in the image, thereby further improving the precision and accuracy of defect detection.
[0006] Preferably, the step of determining the shooting position based on the initial position and the moving range includes: Determine the first search step length based on the moving range , according to the first search step length and the initial position and in a first preset direction, the position of the automobile parts shooting camera is moved in sequence for several times and the corresponding first to-be-determined automobile parts image is acquired, wherein is the depth of field; Calculate the evaluation values of several first pending automobile parts images : ; In the formula, is the image size, , Indicates location ,Location The gray value of the pixel at Determine the increasing and decreasing relationship of the evaluation values of the first undetermined automobile component image obtained in the last three movement processes, and if the evaluation values of the first undetermined automobile component image obtained in the last three movement processes are in an increasing relationship, continue to move the position of the automobile component shooting camera; If the evaluation values of the first undetermined automobile parts images obtained in the last three moving processes are in a decreasing relationship, then according to the second search step length Reversely moving the position of the automobile component photographing camera in turn for several times and acquiring the corresponding second to-be-determined automobile component image; Determine a target image in the second undetermined automobile part image, calculate an evaluation value of the target image, and determine an increasing or decreasing relationship between the evaluation values of the target image obtained in the last two movement processes. If the evaluation values of the target image obtained in the last two movement processes are in an increasing relationship, continue to move the position of the automobile part shooting camera; If the evaluation values of the target images obtained in the last two movement processes are in decreasing relationship, then according to the third search step and sequentially moving the position of the automobile component photographing camera several times according to the first preset direction and acquiring the corresponding third to-be-determined automobile component image; Determine the increasing and decreasing relationship of the evaluation values of the target image of the third undetermined automobile part image obtained in the last two movement processes. If the evaluation values of the target of the third undetermined automobile part image obtained in the last two movement processes are in a decreasing relationship, return to the previous position and use the previous position as the shooting position.
[0007] Preferably, the step of removing metal reflection from the image of the automobile parts to obtain a processed image comprises: The automobile parts image is grayed and normalized to obtain a grayscale image. , based on the grayscale image Calculate the first elimination factor : ; ; In the formula, express The expected value at is the Gaussian standard deviation, represents the exposure threshold, is a constant, is the exposure adjustment factor, Represents a grayscale image The gray value at ; Based on the grayscale image Calculate the second elimination factor : ; In the formula, is the first Laplace operator, It is a Gaussian low-pass filter; Extract the first color image of the automobile parts image in the RGB channel respectively , second color image With the third color image , based on the first color image , second color image With the third color image Calculate the third elimination factor : ; In the formula, represents the mean of three channels; Based on the first elimination factor The second elimination factor , the third elimination factor Determine the image to be processed : ; In the formula, Represents recursive filtering.
[0008] Preferably, the step of performing Fourier transform filtering on the processed image to obtain a filtered image includes: The processed image is divided into a plurality of sub-processed images, and the plurality of sub-processed images are subjected to Fourier transformation to obtain sub-transformed images. ; Calculate the transform coefficients of each sub-transformed image : ; In the formula, , Respectively represent Sub-transformed images, pixel coordinate positions of processed images, Indicates The first spatial frequency and the second spatial frequency of the sub-transformed image, is an imaginary unit, is a differential operator; Determine the rejection threshold : ; In the formula, is the image parameter, To estimate the noise standard deviation, For the The size of the sub-transformed images; Will be less than the rejection threshold The transformation coefficient The transformed coefficients are eliminated, and a transform spectrum is determined according to the remaining transform coefficients. The transform spectrum is subjected to fast Fourier transform and inverse Fourier transform in sequence to obtain a filtered image.
[0009] Preferably, the step of performing transformation enhancement processing on the filtered image to obtain an enhanced image comprises: The segmentation threshold of the filtered image is determined by using a preset segmentation algorithm. ; Based on the segmentation threshold Determine the enhanced image: ; In the formula, , Respectively represent the gray levels of pixels in the enhanced image and the filtered image, is the enhancement factor, is the maximum gray level in the filtered image.
[0010] Preferably, the preset segmentation algorithm is Otsu algorithm.
[0011] Preferably, the step of extracting features from the enhanced image to obtain a target feature image comprises: Using a preset operator to determine the gradient and gradient direction of the pixel points in the enhanced image; Performing maximum value suppression on pixel points in the enhanced image based on the gradient and the gradient direction to obtain a first feature point set; Determining an extraction threshold, and screening the first feature point set based on the extraction threshold to obtain a second feature point set; Converting the pixels in the second feature point set into a matrix form to obtain a feature matrix; Using a second Laplace operator to perform a convolution operation on the feature matrix to obtain a convolution result; Pixel points in the convolution result that are smaller than a preset threshold are removed from the second feature point set to obtain a third feature point set, and the pixel points in the third feature point set are combined and connected to obtain a target feature image.
[0012] In a second aspect, the present invention provides the following technical solution: an automobile parts defect detection system, the system comprising: A position module, used to obtain an initial position and a moving range of a camera for photographing automobile parts, and determine a photographing position based on the initial position and the moving range; A processing module, used for acquiring an image of an automobile part at a corresponding shooting position, and performing metal reflection elimination on the image of the automobile part to obtain a processed image; A filtering module, used for performing Fourier transform filtering on the processed image to obtain a filtered image; An enhancement module, used for performing transformation enhancement processing on the filtered image to obtain an enhanced image, and performing feature extraction on the enhanced image to obtain a target feature image; The detection module is used to obtain a training image and input the training image into a preset recognition model for training, input the target feature image into the trained preset recognition model for defect detection, and output a defect detection result.
[0013] In a third aspect, the present invention provides the following technical solution: a computer comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned automotive parts defect detection method when executing the computer program.
[0014] In a fourth aspect, the present invention provides the following technical solution: a storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the above-mentioned automobile parts defect detection method. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0016] Figure 1 A flowchart of a method for detecting defects in automotive parts provided in Embodiment 1 of the present invention; Figure 2 A structural block diagram of an automobile parts defect detection system provided in Embodiment 2 of the present invention; Figure 3 A schematic diagram of the hardware structure of a computer provided in another embodiment of the present invention.
[0017] The embodiments of the present invention will be further described below with reference to the accompanying drawings. DETAILED DESCRIPTION
[0018] Embodiments of the present invention are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the embodiments of the present invention, and should not be construed as limiting the present invention.
[0019] In the description of the embodiments of the present invention, it should be understood that the terms "length", "width", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside" and "outside" etc., indicating orientations or positional relationships, are based on the orientations or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the embodiments of the present invention and simplifying the description, and do not indicate or imply that the referred device or element must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be understood as a limitation on the present invention.
[0020] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of the embodiments of the present invention, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.
[0021] In the embodiments of the present invention, unless otherwise clearly specified and limited, the terms "installed", "connected", "connected", "fixed" and the like should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium, it can be the internal connection of two elements or the interaction relationship between two elements. For ordinary technicians in this field, the specific meanings of the above terms in the embodiments of the present invention can be understood according to specific circumstances.
[0022] Embodiment 1 In the first embodiment of the present invention, Figure 1 As shown, a method for detecting defects in automobile parts comprises: S1, obtaining an initial position and a moving range of a camera for photographing automobile parts, and determining a photographing position based on the initial position and the moving range; The moving range here specifically refers to the moving range of the camera for photographing automobile parts on the Z axis, and the process of determining the shooting position is actually to determine the optimal distance between the camera and the automobile parts.
[0023] Wherein, the step S1 comprises: S11, determining a first search step length using the moving range as an interval , according to the first search step length and the initial position and in a first preset direction, the position of the automobile parts shooting camera is moved in sequence for several times and the corresponding first to-be-determined automobile parts image is acquired, wherein is the depth of field; Specifically, the first preset direction here is the positive direction of the Z axis, and by moving according to the first search step length each time, a plurality of first to-be-determined automobile parts images can be obtained.
[0024] S12, calculating the evaluation values of a plurality of first pending automobile parts images : ; In the formula, is the image size, , Indicates location ,Location The gray value of the pixel at S13, determining the increasing and decreasing relationship of the evaluation values of the first undetermined automobile component image obtained in the last three movement processes, and if the evaluation values of the first undetermined automobile component image obtained in the last three movement processes are in an increasing relationship, continuing to move the position of the automobile component shooting camera; Specifically, if the evaluation values of the first undetermined automobile component image obtained in the last three movement processes are in an increasing relationship, it indicates that the optimal position has not been reached, and therefore further movement is required.
[0025] S14: If the evaluation values of the first undetermined automobile parts images obtained in the last three moving processes are in a decreasing relationship, then according to the second search step length Reversely moving the position of the automobile component photographing camera in turn for several times and acquiring the corresponding second to-be-determined automobile component image; Specifically, if the evaluation values of the first undetermined automobile parts image obtained in the last three movement processes are in a decreasing relationship, it means that the optimal position has been exceeded, so it is necessary to move in the opposite direction, that is, move in the negative direction of the Z axis, and at the same time, the step size needs to be shortened to ensure that the shooting position can be quickly searched. At the same time, in the process of moving in the direction, the starting point is the position of the last movement in the first preset direction.
[0026] S15, determining a target image in the second pending automobile part image, calculating an evaluation value of the target image, and judging an increasing and decreasing relationship between the evaluation values of the target images obtained in the last two movement processes; if the evaluation values of the target images obtained in the last two movement processes are in an increasing relationship, continuing to move the position of the automobile part shooting camera; Specifically, in the subsequent two searches, the calculated evaluation value is specifically the target image, and the target image is specifically a rectangular area determined with the center of the image as the center point, and the rectangular area includes the automobile parts, that is, the target image.
[0027] S16: If the evaluation values of the target images obtained in the last two movement processes are in decreasing relationship, then according to the third search step length and sequentially moving the position of the automobile component photographing camera several times according to the first preset direction and acquiring the corresponding third to-be-determined automobile component image; Specifically, similarly, if it is a decreasing relationship, it means that the shooting position has been exceeded, so it is necessary to continue to shorten the step length and continue to move in the first preset direction, and the starting point of the movement is the position of the last movement in the opposite direction.
[0028] S17, determining the increasing and decreasing relationship of the evaluation values of the target image of the third undetermined automobile component image obtained in the last two movement processes, if the evaluation values of the target image of the third undetermined automobile component image obtained in the last two movement processes are in a decreasing relationship, returning to the previous position and using the previous position as the shooting position; Specifically, assuming that the evaluation value of the penultimate movement and the evaluation value of the penultimate movement are in a decreasing relationship, the position of the penultimate movement is used as the shooting position; The determination of the shooting position here is only to determine the best height of the camera. As for the camera posture, the default camera lens is facing the car parts.
[0029] S2, acquiring an image of an automobile part at a corresponding shooting position, and performing metal reflection elimination on the image of the automobile part to obtain a processed image; Wherein, the step S2 comprises: S21, grayscale processing and normalization processing are performed on the automobile parts image to obtain a grayscale image , based on the grayscale image Calculate the first elimination factor : ; ; In the formula, express The expected value at is the Gaussian standard deviation, represents the exposure threshold, is a constant, is the exposure adjustment factor, Represents a grayscale image The gray value at ; Specifically, the first elimination factor is mainly used to eliminate the exposure in the image, and When the gray value is close to 0.5, the higher the exposure brightness, is 0.3, and the Gaussian standard deviation is 0.2.
[0030] S22, based on the grayscale image Calculate the second elimination factor : ; In the formula, is the first Laplace operator, It is a Gaussian low-pass filter; Specifically, the second elimination factor is mainly used to highlight the details in the image and improve the image contrast.
[0031] S23, extracting the first color images of the automobile parts image in the RGB channels respectively , second color image With the third color image , based on the first color image , second color image With the third color image Calculate the third elimination factor : ; In the formula, represents the mean of three channels; Specifically, the third elimination factor mainly improves the image saturation.
[0032] S24, based on the first elimination factor The second elimination factor , the third elimination factor Determine the image to be processed : ; In the formula, Represents recursive filtering.
[0033] S3, performing Fourier transform filtering on the processed image to obtain a filtered image; Wherein, the step S3 comprises: S31, dividing the processed image into a plurality of sub-processed images, and performing Fourier transform on the plurality of sub-processed images to obtain sub-transformed images .
[0034] S32, calculating the transformation coefficient of each sub-transformation image : ; In the formula, , Respectively represent Sub-transformed images, pixel coordinate positions of processed images, Indicates The first spatial frequency and the second spatial frequency of the sub-transformed image, is an imaginary unit, is a differential operator; Specifically, the first spatial frequency and the second spatial frequency correspond to The spatial frequency at .
[0035] S33, determine the elimination threshold : ; In the formula, is the image parameter, To estimate the noise standard deviation, For the The size of the sub-transformed image.
[0036] S34, will be less than the rejection threshold The transformation coefficient The transformed image is removed, and a transform spectrum is determined according to the remaining transform coefficients, and the transform spectrum is subjected to fast Fourier transform and inverse Fourier transform in sequence to obtain a filtered image; Specifically, the transform spectrum here is a 2D ST spectrum, and the remaining transform coefficients are summed up to obtain a 2D ST spectrum, and the Fourier transform here is specifically a two-dimensional Fourier transform.
[0037] S4, performing transformation enhancement processing on the filtered image to obtain an enhanced image, and performing feature extraction on the enhanced image to obtain a target feature image; Wherein, the step S4 comprises: S411: Using a preset segmentation algorithm to determine the segmentation threshold of the filtered image ; The preset segmentation algorithm is the Otsu algorithm, and a segmentation threshold can be determined by the Otsu algorithm, and the image is divided into a foreground and a background by the segmentation threshold.
[0038] S412: Based on the segmentation threshold Determine the enhanced image: ; In the formula, , Respectively represent the gray levels of pixels in the enhanced image and the filtered image, is the enhancement factor, is the maximum gray level in the filtered image; Specifically, the enhancement factor here is 0.5-0.9.
[0039] Wherein, the step S4 further includes: S421, using a preset operator to determine the gradient and gradient direction of a pixel point in the enhanced image; Specifically, the preset operator here is the Canny operator, and the subsequent maximum value suppression is a common usage of this operator.
[0040] S422, performing maximum value suppression on pixel points in the enhanced image based on the gradient and the gradient direction to obtain a first feature point set; S423, determining an extraction threshold, and screening the first feature point set based on the extraction threshold to obtain a second feature point set; Specifically, the extraction threshold here can be determined by a double-threshold Otsu algorithm, where the two thresholds are a large threshold and a small threshold, and points smaller than the small threshold are screened out to obtain the second feature point set.
[0041] S424, converting the pixel points in the second feature point set into a matrix form to obtain a feature matrix; S425, using a second Laplace operator to perform a convolution operation on the feature matrix to obtain a convolution result; Specifically, the second Laplacian operator here is also in matrix form. According to the number of elements in the matrix of the second Laplacian operator, the pixel points are converted into a feature matrix with the corresponding number of elements. The rectangular form of the Laplacian operator is: .
[0042] S426, removing pixels in the convolution result that are smaller than a preset threshold from the second feature point set to obtain a third feature point set, and combining and connecting the pixels in the third feature point set to obtain a target feature image; Specifically, the preset threshold is -20.
[0043] S5, acquiring a training image and inputting the training image into a preset recognition model for training, inputting the target feature image into the trained preset recognition model for defect detection, and outputting a defect detection result; Specifically, the preset recognition model is the Yolov5 model commonly used in the prior art.
[0044] The automobile parts defect detection method provided in the first embodiment of the present invention first obtains the initial position and the moving range of the automobile parts shooting camera, and determines the shooting position based on the initial position and the moving range; then obtains the automobile parts image at the corresponding shooting position, and performs metal reflection elimination on the automobile parts image to obtain a processed image; then performs Fourier transform filtering processing on the processed image to obtain a filtered image; then performs transform enhancement processing on the filtered image to obtain an enhanced image, and performs feature extraction on the enhanced image to obtain a target feature image; finally, obtains a training image and inputs the training image into a preset recognition model for training, and inputs the target feature image into the trained preset recognition model for defect detection to output a defect detection result. First, the present invention determines the best shooting position, thereby improving the clarity of the captured image, and then eliminates the reflection of the image, which can effectively remove the noise caused by the metal reflection in the image, and can also effectively highlight the details in the image, and then enhances and extracts the image, which can suppress the image background information and highlight the feature information in the image, thereby further improving the precision and accuracy of defect detection.
[0045] Embodiment 2 like Figure 2 As shown, in the second embodiment of the present invention, a system for detecting defects in automobile parts is provided, and the system comprises: Position module 1, used to obtain the initial position and moving range of the camera for photographing automobile parts, and determine the photographing position based on the initial position and the moving range; Processing module 2, used for acquiring an image of an automobile part at a corresponding shooting position, and performing metal reflection elimination on the image of the automobile part to obtain a processed image; A filtering module 3, used for performing Fourier transform filtering on the processed image to obtain a filtered image; The enhancement module 4 is used to perform transformation enhancement processing on the filtered image to obtain an enhanced image, and perform feature extraction on the enhanced image to obtain a target feature image; The detection module 5 is used to obtain a training image and input the training image into a preset recognition model for training, and input the target feature image into the trained preset recognition model for defect detection to output a defect detection result; The position module 1 comprises: The first search submodule is used to determine the first search step length based on the moving range. , according to the first search step length and the initial position and in a first preset direction, the position of the automobile parts shooting camera is moved in sequence for several times and the corresponding first to-be-determined automobile parts image is acquired, wherein is the depth of field; An evaluation value submodule, used to calculate the evaluation values of a plurality of first pending automobile parts images : ; In the formula, is the image size, , Indicates location ,Location The gray value of the pixel at A first judgment submodule is used to judge the increasing and decreasing relationship of the evaluation values of the first undetermined automobile component image obtained in the last three movement processes, and if the evaluation values of the first undetermined automobile component image obtained in the last three movement processes are in an increasing relationship, continue to move the position of the automobile component shooting camera; The second search submodule is used to, if the evaluation values of the first undetermined automobile parts images obtained in the last three movement processes are in a decreasing relationship, search according to the second search step length Reversely moving the position of the automobile component photographing camera in turn for several times and acquiring the corresponding second to-be-determined automobile component image; A second judgment submodule is used to determine a target image in the second pending automobile part image, calculate an evaluation value of the target image, and determine an increasing and decreasing relationship between the evaluation values of the target images obtained in the last two movement processes. If the evaluation values of the target images obtained in the last two movement processes are in an increasing relationship, the position of the automobile part shooting camera is continued to be moved; The third search submodule is used to, if the evaluation values of the target images obtained in the last two movement processes are in a decreasing relationship, then according to the third search step length and sequentially moving the position of the automobile component photographing camera several times according to the first preset direction and acquiring the corresponding third to-be-determined automobile component image; The position output submodule is used to determine the increasing and decreasing relationship of the evaluation values of the target image of the third undetermined automobile parts image obtained in the last two movement processes. If the evaluation values of the target of the third undetermined automobile parts image obtained in the last two movement processes are in a decreasing relationship, the previous position is returned and the previous position is used as the shooting position.
[0046] The processing module 2 comprises: The first elimination submodule is used to perform grayscale processing and normalization processing on the automobile parts image to obtain a grayscale image , based on the grayscale image Calculate the first elimination factor : ; ; In the formula, express The expected value at is the Gaussian standard deviation, represents the exposure threshold, is a constant, is the exposure adjustment factor, Represents a grayscale image The gray value at ; The second elimination submodule is used to eliminate the grayscale image based on the grayscale image. Calculate the second elimination factor : ; In the formula, is the first Laplace operator, It is a Gaussian low-pass filter; The third elimination submodule is used to extract the first color image of the automobile parts image in the RGB channel respectively. , second color image With the third color image , based on the first color image , second color image With the third color image Calculate the third elimination factor : ; In the formula, represents the mean of three channels; A processing submodule is used for eliminating the first factor based on The second elimination factor , the third elimination factor Determine the image to be processed : ; In the formula, Represents recursive filtering.
[0047] The filtering module 3 comprises: The transformation submodule is used to divide the processed image into a plurality of sub-processed images, and perform Fourier transformation on the plurality of sub-processed images to obtain sub-transformed images. ; A transform coefficient submodule, used to calculate the transform coefficient of each sub-transform image : ; In the formula, , Respectively represent Sub-transformed images, pixel coordinate positions of processed images, Indicates The first spatial frequency and the second spatial frequency of the sub-transformed image, is an imaginary unit, is a differential operator; The rejection threshold submodule is used to determine the rejection threshold : ; In the formula, is the image parameter, To estimate the noise standard deviation, For the The size of the sub-transformed images; The rejection submodule is used to remove the The transformation coefficient The transformed coefficients are eliminated, and a transform spectrum is determined according to the remaining transform coefficients. The transform spectrum is subjected to fast Fourier transform and inverse Fourier transform in sequence to obtain a filtered image.
[0048] The enhancement module 4 comprises: A threshold determination submodule is used to determine the segmentation threshold of the filtered image using a preset segmentation algorithm ; The enhancement determination submodule is used to determine the segmentation threshold based on the segmentation threshold. Determine the enhanced image: ; In the formula, , Respectively represent the gray levels of pixels in the enhanced image and the filtered image, is the enhancement factor, is the maximum gray level in the filtered image.
[0049] The enhancement module 4 also includes: A gradient submodule, used to determine the gradient and gradient direction of the pixel points in the enhanced image using a preset operator; A suppression submodule, used for performing maximum value suppression on pixel points in the enhanced image based on the gradient and the gradient direction to obtain a first feature point set; a screening submodule, configured to determine an extraction threshold, and screen the first feature point set based on the extraction threshold to obtain a second feature point set; A matrix submodule, used for converting the pixel points in the second feature point set into a matrix form to obtain a feature matrix; A convolution submodule, used for performing a convolution operation on the feature matrix using a second Laplace operator to obtain a convolution result; The feature output submodule is used to remove the pixel points in the convolution result that are smaller than a preset threshold from the second feature point set to obtain a third feature point set, and combine and connect the pixel points in the third feature point set to obtain a target feature image.
[0050] In some other embodiments of the present invention, the embodiments of the present invention provide the following technical solutions: a computer, comprising a memory 102, a processor 101, and a computer program stored in the memory 102 and executable on the processor 101; the processor 101 implements the above-mentioned automobile parts defect detection method when executing the computer program.
[0051] Specifically, the processor 101 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiment of the present invention.
[0052] Among them, the memory 102 may include a large-capacity memory for data or instructions. By way of example and not limitation, the memory 102 may include a hard disk drive (HDD), a floppy disk drive, a solid state drive (SSD), a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a universal serial bus (USB) drive, or a combination of two or more of these. Where appropriate, the memory 102 may include a removable or non-removable (or fixed) medium. Where appropriate, the memory 102 may be inside or outside the data processing device. In a specific embodiment, the memory 102 is a non-volatile memory. In a specific embodiment, the memory 102 includes a read-only memory (ROM) and a random access memory (RAM). Where appropriate, the ROM may be a mask-programmed ROM, a programmable ROM (PROM), an erasable PROM (EPROM), an electrically erasable PROM (EEPROM), an electrically alterable ROM (EAROM) or a flash memory (FLASH), or a combination of two or more of these. Under appropriate circumstances, the RAM can be a static random access memory (SRAM) or a dynamic random access memory (DRAM), wherein the DRAM can be a fast page mode dynamic random access memory (FPMDRAM), an extended data output dynamic random access memory (EDODRAM), a synchronous dynamic random access memory (SDRAM), etc.
[0053] The memory 102 may be used to store or cache various data files that need to be processed and / or used for communication, as well as possible computer program instructions executed by the processor 101 .
[0054] The processor 101 implements the above-mentioned automobile parts defect detection method by reading and executing the computer program instructions stored in the memory 102.
[0055] In some embodiments, the computer may further include a communication interface 103 and a bus 100. Figure 3 As shown, the processor 101, the memory 102, and the communication interface 103 are connected via a bus 100 and communicate with each other.
[0056] The communication interface 103 is used to implement communication between the modules, devices, units and / or equipment in the embodiment of the present invention. The communication interface 103 can also implement data communication with other components such as: external devices, image / data acquisition equipment, databases, external storage, and image / data processing workstations.
[0057] The bus 100 includes hardware, software or both, and couples the components of the computer device to each other. The bus 100 includes but is not limited to at least one of the following: a data bus, an address bus, a control bus, an expansion bus, and a local bus. By way of example and not limitation, bus 100 may include an Accelerated Graphics Port (AGP) or other graphics bus, an Extended Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), a Hyper Transport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an InfiniBand interconnect, a Low Pin Count (LPC) bus, a memory bus, a Micro Channel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local Bus (VLB) bus, or other suitable buses or a combination of two or more of these. Where appropriate, bus 100 may include one or more buses. Although embodiments of the present invention describe and illustrate a particular bus, the present invention contemplates any suitable bus or interconnect.
[0058] The computer can execute the automobile component defect detection method of the present invention based on the acquired automobile component defect detection system, thereby realizing automobile component defect detection.
[0059] In some further embodiments of the present invention, in combination with the above-mentioned automobile parts defect detection method, the embodiments of the present invention provide the following technical solutions: a storage medium having a computer program stored thereon, and the computer program implements the above-mentioned automobile parts defect detection method when executed by a processor.
[0060] Those skilled in the art will appreciate that the logic and / or steps represented in the flowchart or otherwise described herein, for example, may be considered as an ordered list of executable instructions for implementing logical functions, and may be specifically implemented in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or in conjunction with such instruction execution systems, devices or apparatuses. For purposes of this specification, "computer-readable medium" may be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in conjunction with such instruction execution systems, devices or apparatuses.
[0061] More specific examples of readable media (a non-exhaustive list) include the following: an electrical connection with one or more wires (electronic device), a portable computer disk case (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be a paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, deciphering or, if necessary, processing in another suitable manner, and then stored in a computer memory.
[0062] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or a combination thereof: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0063] The technical features of the above-described embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above-described embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0064] The above-mentioned embodiments only express several implementation methods of the present invention, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for ordinary technicians in this field, several variations and improvements can be made without departing from the concept of the present invention, and these all belong to the protection scope of the present invention. Therefore, the protection scope of the patent of the present invention shall be subject to the attached claims.
Claims
1. A method for detecting defects in automobile parts, characterized in that: include: Acquire the initial position and moving range of the camera for photographing automobile parts, and determine the photographing position based on the initial position and the moving range; Acquire an image of an automobile part at a corresponding shooting position, and perform metal reflection elimination on the image of the automobile part to obtain a processed image; Performing Fourier transform filtering on the processed image to obtain a filtered image; Performing transformation enhancement processing on the filtered image to obtain an enhanced image, and performing feature extraction on the enhanced image to obtain a target feature image; A training image is acquired and input into a preset recognition model for training, and the target feature image is input into the trained preset recognition model for defect detection to output a defect detection result.
2. The method for detecting defects in automobile parts according to claim 1, characterized in that: The step of determining the shooting position based on the initial position and the moving range comprises: Determine the first search step length based on the moving range , according to the first search step length and the initial position and in a first preset direction, the position of the automobile parts shooting camera is moved in sequence for several times and the corresponding first to-be-determined automobile parts image is acquired, wherein is the depth of field; Calculate the evaluation values of several first pending automobile parts images : ; In the formula, is the image size, , Indicates location ,Location The gray value of the pixel at Determine the increasing and decreasing relationship of the evaluation values of the first undetermined automobile component image obtained in the last three movement processes, and if the evaluation values of the first undetermined automobile component image obtained in the last three movement processes are in an increasing relationship, continue to move the position of the automobile component shooting camera; If the evaluation values of the first undetermined automobile parts images obtained in the last three moving processes are in a decreasing relationship, then according to the second search step length Reversely moving the position of the automobile component photographing camera in turn for several times and acquiring the corresponding second to-be-determined automobile component image; Determine a target image in the second undetermined automobile part image, calculate an evaluation value of the target image, and determine an increasing or decreasing relationship between the evaluation values of the target image obtained in the last two movement processes. If the evaluation values of the target image obtained in the last two movement processes are in an increasing relationship, continue to move the position of the automobile part shooting camera; If the evaluation values of the target images obtained in the last two movement processes are in decreasing relationship, then according to the third search step and sequentially moving the position of the automobile component photographing camera several times according to the first preset direction and acquiring the corresponding third to-be-determined automobile component image; Determine the increasing and decreasing relationship of the evaluation values of the target image of the third undetermined automobile part image obtained in the last two movement processes. If the evaluation values of the target of the third undetermined automobile part image obtained in the last two movement processes are in a decreasing relationship, return to the previous position and use the previous position as the shooting position.
3. The method for detecting defects in automobile parts according to claim 1, characterized in that: The step of removing metal reflection from the automobile parts image to obtain a processed image comprises: The automobile parts image is grayed and normalized to obtain a grayscale image. , based on the grayscale image Calculate the first elimination factor : ; ; In the formula, express The expected value at is the Gaussian standard deviation, represents the exposure threshold, is a constant, is the exposure adjustment factor, Represents a grayscale image The gray value at ; Based on the grayscale image Calculate the second elimination factor : ; In the formula, is the first Laplacian operator, is a Gaussian low-pass filter; Extract the first color image of the automobile parts image in the RGB channel respectively , second color image With the third color image , based on the first color image , second color image With the third color image Calculate the third elimination factor : ; In the formula, represents the mean of three channels; Based on the first elimination factor The second elimination factor , the third elimination factor Determine the image to be processed : ; In the formula, Represents recursive filtering.
4. The method for detecting defects in automobile parts according to claim 1, characterized in that: The step of performing Fourier transform filtering on the processed image to obtain a filtered image comprises: The processed image is divided into a plurality of sub-processed images, and the plurality of sub-processed images are subjected to Fourier transformation to obtain sub-transformed images. ; Calculate the transform coefficients of each sub-transformed image : ; In the formula, , Respectively represent Sub-transformed images, pixel coordinate positions of processed images, Indicates The first spatial frequency and the second spatial frequency of the sub-transformed image, is an imaginary unit, is a differential operator; Determine the rejection threshold : ; In the formula, is the image parameter, To estimate the noise standard deviation, For the The size of the sub-transformed images; Will be less than the rejection threshold The transformation coefficient The transformed coefficients are eliminated, and a transform spectrum is determined according to the remaining transform coefficients. The transform spectrum is subjected to fast Fourier transform and inverse Fourier transform in sequence to obtain a filtered image.
5. The method for detecting defects in automobile parts according to claim 1, characterized in that: The step of performing transformation enhancement processing on the filtered image to obtain an enhanced image comprises: The segmentation threshold of the filtered image is determined by using a preset segmentation algorithm. ; Based on the segmentation threshold Determine the enhanced image: ; In the formula, , Respectively represent the gray levels of pixels in the enhanced image and the filtered image, is the enhancement factor, is the maximum gray level in the filtered image.
6. The method for detecting defects in automobile parts according to claim 5, characterized in that: The preset segmentation algorithm is the Otsu algorithm.
7. The method for detecting defects in automobile parts according to claim 1, characterized in that: The step of extracting features from the enhanced image to obtain a target feature image comprises: Using a preset operator to determine the gradient and gradient direction of the pixel points in the enhanced image; Performing maximum value suppression on pixel points in the enhanced image based on the gradient and the gradient direction to obtain a first feature point set; Determining an extraction threshold, and screening the first feature point set based on the extraction threshold to obtain a second feature point set; Converting the pixels in the second feature point set into a matrix form to obtain a feature matrix; Using a second Laplace operator to perform a convolution operation on the feature matrix to obtain a convolution result; Pixel points in the convolution result that are smaller than a preset threshold are removed from the second feature point set to obtain a third feature point set, and the pixel points in the third feature point set are combined and connected to obtain a target feature image.
8. An automobile parts defect detection system, characterized in that: The system comprises: A position module, used to obtain an initial position and a moving range of a camera for photographing automobile parts, and determine a photographing position based on the initial position and the moving range; A processing module, used for acquiring an image of an automobile part at a corresponding shooting position, and performing metal reflection elimination on the image of the automobile part to obtain a processed image; A filtering module, used for performing Fourier transform filtering on the processed image to obtain a filtered image; An enhancement module, used for performing transformation enhancement processing on the filtered image to obtain an enhanced image, and performing feature extraction on the enhanced image to obtain a target feature image; The detection module is used to obtain a training image and input the training image into a preset recognition model for training, input the target feature image into the trained preset recognition model for defect detection, and output a defect detection result.
9. A computer comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the automobile parts defect detection method according to any one of claims 1 to 7 is implemented.
10. A storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by the processor, the automobile parts defect detection method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
MRI (magnetic resonance imaging) image rebuilding method based on iterative projection
CN102609905A
High-resolution light guide plate image defect detection method
CN109102497A
Automatic focusing method and automatic focusing system
CN112601015A
Microscope automatic focusing method and device based on image definition evaluation
CN113109936A
Surface defect detection method and device, computer equipment and storage medium
CN115830004A
Cited By
Paint-sprayed aluminum plate flatness detection method and system
CN120953237A
A method and system for detecting flatness of a paint-sprayed aluminum plate
CN120953237B
Board card defect detection method and system based on image processing
CN121982021A