Focal length adjusting method for penetrating, welding and marking all-in-one machine
By using a stepper motor and an improved Brenner gradient algorithm on the welding and marking machine, high-precision and efficient automatic focal length adjustment is achieved, solving the problems of time-consuming and labor-intensive operation and inaccurate accuracy of independent equipment, and improving production efficiency and equipment versatility.
Patent Information
- Application Number
- CN202510947469.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-10
- Publication Date
- 2025-10-10
AI Technical Summary
Existing focal length detection equipment operates independently, resulting in time-consuming and labor-intensive operations, data confusion affecting press-fitting accuracy, and a lack of automation and versatility, leading to low production efficiency.
A stepper motor is used to move the focus gradually and finely. The image gradient value is calculated by combining the improved Brenner gradient algorithm and Roberts function. The focus is adjusted automatically by taking pictures with an industrial camera and performing image binarization processing, thus reducing manual intervention and errors.
It improves the accuracy and efficiency of focal length adjustment, reduces the difficulty of operation and human error, increases production efficiency by 100%, and reduces equipment costs by 30%. It is suitable for various welding and marking machines.
Smart Images

Figure CN120755487A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of focus adjustment of welding and marking integrated machine, and particularly relates to a focus adjustment method of welding and marking integrated machine. BACKGROUND
[0002] The welding and marking integrated machine is a multi-process integrated device integrating laser welding, cutting and marking functions, and realizes efficient and high-precision processing through a single platform, and is widely used in the fields of automobile manufacturing, aerospace, electronic manufacturing, medical equipment and the like. As a core device in the field of laser processing, the welding and marking integrated machine integrates three functions of laser welding, cutting and marking, and the core advantage is that multiple processes are realized through a single device, which significantly improves production efficiency and reduces process cost.
[0003] However, the focus detection device, the pressing device, the welding device and the marking device on the market are independently operated, and one person is needed to operate each device, which is time-consuming and laborious. Moreover, the data detected by the focus detection device must correspond to the product one by one, and if the data is disordered, the pressing precision will be affected, which loses the significance of focus detection. SUMMARY
[0004] The present application provides a focus adjustment method of welding and marking integrated machine. The step motor is moved step by step in the focus direction to accurately approach the focus position, which greatly improves the precision of focus adjustment. Meanwhile, the phased adjustment strategy improves the adjustment efficiency while ensuring the precision. Compared with the single-step adjustment method, the focus position can be found more quickly. The improved Brenner gradient algorithm is used to calculate the image gradient value, which can more accurately reflect the change of image definition and provide more reliable basis for judging whether the focus position is reached. The gradient value comparison avoids unnecessary movement and adjustment, reduces the adjustment time, improves the overall adjustment efficiency, and the method is not dependent on specific devices or scenes, and is suitable for focus adjustment of various welding and marking integrated machines, has strong universality, can realize automatic execution of the focus adjustment method, reduces manual intervention, reduces operation difficulty and human error, improves the stability and consistency of the production process, greatly saves manpower, and the total cost of the integrated device is reduced by 30% compared with the total cost of independent devices. Since the integrated machine has high automation, it can work 24 hours a day, and the production efficiency is 100% higher than that of independent devices.
[0005] In order to solve the above problems, the present application provides the following technical scheme: a focus adjustment method of welding and marking integrated machine, comprising the following steps:
[0006] Step 1: The step motor is moved in the focus direction to the focus position at a distance of 50um each time.
[0007] Step two: after the stepper motor stops moving, take a photo by the industrial camera, process the image by binaryzation, determine the current position of the target, then cut the target out of the original image to obtain the current cutting image.
[0008] Step three: calculate the gradient value of the current cutting image, compare the gradient value of the current cutting image with the gradient value of the last cutting image, and execute according to the comparison result.
[0009] Step four: the stepper motor moves in the focal length direction to the focal point direction by 10um each time.
[0010] Step five: after the stepper motor stops moving, take a photo by the industrial camera, process the image by binaryzation, determine the current position of the target, then cut the target out of the original image to obtain the new cutting image.
[0011] Step six: calculate the gradient value of the new cutting image, compare the gradient value of the new cutting image with the gradient value of the last cutting image, and execute according to the comparison result.
[0012] Further, the method for calculating the gradient value in steps three and six is improved Brenner gradient algorithm, which adds Roberts function on the basis of Brenner gradient algorithm.
[0013] Further, in steps three and six, the formula of the Roberts function is:
[0014]
[0015] wherein, represents the sum in X and Y directions of the two-dimensional image; x direction starts from 1 to M-2; M represents the width of the image; y direction starts from 1 to N-2; N represents the height of the image; f(x,y) represents the value of the pixel point with coordinate x,y on the image; f(x+2,y) represents the value of the pixel point with coordinate x+2,y on the image; f(x+1,y+1) represents the value of the pixel point with coordinate x+1,y+1 on the image; f(x+1,y) represents the value of the pixel point with coordinate x+1,y on the image; f(x,y+1) represents the value of the pixel point with coordinate x,y+1 on the image.
[0016] Further, in step three, when the current cutting image is the first image, compare with 0.
[0017] Further, the comparison result in step three includes:
[0018] (1) the current cutting image gradient value is greater than the last cutting image gradient value, then record the current stepper motor position value, and update the maximum gradient value variable;
[0019] (2) the current cutting image gradient value is less than 90% of the maximum gradient value, then the stepper motor retreats to the stepper motor position value corresponding to the maximum gradient value minus 50um, clears the maximum gradient value variable, and then jumps to step four, otherwise jumps to step one.
[0020] Further, in step six, when the new cutting image is the first image, then compare with 0.
[0021] Further, the comparison result in step six includes:
[0022] (1) the new cutting image gradient value is greater than the last cutting image gradient value, then record the current stepper motor position value, and update the maximum gradient value variable;
[0023] (2) the new cutting image gradient value is less than 95% of the maximum gradient value, then the stepper motor retreats to the stepper motor position value corresponding to the maximum gradient value, at this time the position where the stepper motor stops is the position where the image gradient value is the largest, which is also the position corresponding to the focal point.
[0024] A computer program product, when the computer program product is read by a computer, executes the method as claimed in any one of the above.
[0025] A computer readable storage medium, wherein a processor executable program is stored, the processor executable program is used to execute the method as claimed in any one of the above when executed by a processor.
[0026] A focal length adjustment device of a welding marking and engraving integrated machine, comprising a processor and a memory, wherein the memory includes a computer readable storage medium, and a processor executable program is stored in the computer readable storage medium, the processor executable program is used to execute the method as claimed in any one of the above when executed by a processor.
[0027] The present invention provides a focal length adjustment method for a welding and marking all-in-one machine, which has the following beneficial effects: through the gradual and fine movement of the stepping motor in the focal length direction, the focus position can be approached more accurately, which greatly improves the accuracy of the focal length adjustment. At the same time, the staged adjustment strategy improves the adjustment efficiency while ensuring the accuracy. Compared with the single-step adjustment method, the focus position can be found faster. The improved Brenner gradient algorithm is used to calculate the image gradient value, which can more accurately reflect the clarity change of the image, provide a more reliable basis for judging whether the focus position is reached, and further improve the accuracy of the focal length adjustment. By comparing the gradient values, unnecessary movement and adjustment are avoided, the adjustment time is reduced, and the overall adjustment efficiency is improved. Moreover, the method does not depend on specific equipment or scenarios, is suitable for the focal length adjustment of various welding and marking all-in-one machines, has strong versatility, can realize the automatic execution of the focal length adjustment method, reduce manual intervention, reduce the difficulty of operation and human errors, improve the stability and consistency of the production process, greatly save manpower, and the cost of the integrated equipment is also reduced by 30% compared with the total cost of the independent equipment. Due to the high degree of automation of the all-in-one machine, it can work 24 hours a day, and the production efficiency is 100% higher than that of the independent equipment. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Fig. 1 It is a flow chart of a method for adjusting the focal length of a welding and marking integrated machine according to the present invention;
[0029] Fig. 2 This is a flowchart of a focal length adjustment method for a welding and marking integrated machine according to the present invention. DETAILED DESCRIPTION
[0030] See also Figs. 1-2 The present invention provides a technical solution: a method for adjusting the focal length of a welding and marking integrated machine, comprising the following steps:
[0031] Step 1: The stepper motor moves in the focal length direction toward the focal point at a distance of 50 μm each time.
[0032] Step 2: After the stepper motor moves once and stops, take a photo with an industrial camera, perform image binarization on the photo, determine the current position of the target, and then cut the target out of the original image to obtain the current cut image.
[0033] Step 3: Calculate the gradient value of the current cut image, compare the gradient value of the current cut image with the gradient value of the previous cut image, and make corresponding judgments based on the comparison results before execution.
[0034] Step 4: The stepper motor moves in the focal length direction toward the focal point at a distance of 10 μm each time.
[0035] Step five: after the stepper motor stops moving once, take a picture through the industrial camera, determine the current position of the target by image binarization processing, then cut the target out of the original image to obtain a new cutting image.
[0036] Step six: calculate the gradient value of the new cutting image, compare the gradient value of the new cutting image with the gradient value of the last cutting image, and execute according to the comparison result.
[0037] Specifically, the method for calculating the gradient value in steps three and six is improved Brenner gradient algorithm, which adds Roberts function based on Brenner gradient algorithm.
[0038] Specifically, in steps three and six, the formula of Roberts function is:
[0039]
[0040] wherein, represents the sum in X and Y directions of the two-dimensional image; x direction starts from 1 to M-2; M represents the width of the image; y direction starts from 1 to N-2; N represents the height of the image; f(x,y) represents the value of the pixel point with coordinates x,y on the image; f(x+2,y) represents the value of the pixel point with coordinates x+2,y on the image; f(x+1,y+1) represents the value of the pixel point with coordinates x+1,y+1 on the image; f(x+1,y) represents the value of the pixel point with coordinates x+1,y on the image; f(x,y+1) represents the value of the pixel point with coordinates x,y+1 on the image.
[0041] Specifically, in step three, when the current cutting image is the first image, it is compared with 0.
[0042] Specifically, the comparison result in step three includes:
[0043] (1) if the gradient value of the current cutting image is greater than the gradient value of the last cutting image, record the position value of the stepper motor, and update the maximum gradient value variable;
[0044] (2) if the gradient value of the current cutting image is less than 90% of the maximum gradient value, the stepper motor returns to the stepper motor position value corresponding to the maximum gradient value minus 50um, clears the maximum gradient value variable, then jumps to step four, otherwise jumps to step one.
[0045] Specifically, in step six, when the new cutting image is the first image, it is compared with 0.
[0046] Specifically, the comparison result in step six includes:
[0047] (1) new cutting image gradient value is greater than last cutting image gradient value, then record current stepper motor position value, and update maximum gradient value variable;
[0048] (2) new cutting image gradient value is less than 95% of maximum gradient value, then stepper motor retreats to maximum gradient value corresponding stepper motor position value, at this time, the position where stepper motor stops is the position where image gradient value is maximum, and is the position corresponding to focus point.
[0049] At the same time, the application also proposes a computer program product, when the computer program product is read by computer, the method as above is executed.
[0050] At the same time, the application also proposes a computer readable storage medium, wherein the processor executable program is stored, and the processor executable program is used for executing the method as above when executed by processor.
[0051] At the same time, the application also proposes a welding mark marking and engraving integrated machine focal length adjustment equipment, which contains processor and memory, wherein the memory includes computer readable storage medium, and the processor executable program is stored in the memory, and the processor executable program is used for executing the method as above when executed by processor.
[0052] The application provides a welding mark marking and engraving integrated machine focal length adjustment method:
[0053] 1. In the focal length direction, the stepper motor moves to the focus point direction once with 50um step.
[0054] 2. After the motor is stable, the industrial camera takes a picture, then the target approximate position is determined through image binarization processing, and then the target is cut out from the original image.
[0055] 3. The cut-out image is calculated by improved Brenner gradient algorithm to obtain the gradient value of the current cutting image, and then compared with the gradient value of the last image (if it is the first image, it is compared with 0), if it is greater than the gradient value of the last image, the current motor position value is recorded, and the maximum gradient value variable is updated, if the current image gradient value is less than 90% of the maximum gradient value, the motor retreats to the motor position value corresponding to the maximum gradient value minus 50um, the maximum gradient value variable is cleared, and then jumps to step 4, otherwise jumps to step 1.
[0056] Vcur represents the gradient value of the current picture
[0057] Vmax represents the gradient value of the current picture
[0058] Fbrenner() represents Brenner algorithm
[0059] POScur represents the current motor position value
[0060] POSmax represents the motor position value when the gradient value is maximum
[0061] FMOTORINMOVE() represents the motor move absolute position function
[0062] FMOTORRELMOVE() represents the motor move relative position function
[0063] lableCuSearch:
[0064]
[0065]
[0066] 4. In the direction of the focal length step motor to the focal point direction step move once.
[0067] 5. Motor stop after the industrial camera, and then through the image binarization processing, determine the target approximate position, and then cut the target from the original image.
[0068] 6. The cut image is calculated by the improved Brenner gradient algorithm to calculate the gradient value of the current cut image, and then compared with the gradient value of the last image (if it is the first image, it is compared with 0). If it is greater than the gradient value of the last image, record the current motor position value, and update the maximum gradient value variable. If the current image gradient value is less than 95% of the maximum gradient value, the motor will retreat to the motor position value corresponding to the maximum gradient value. At this time, the position of the motor stop is the position of the maximum image gradient value, which is the position corresponding to the focal point.
[0069] The improved Brenner gradient algorithm is based on the Brenner gradient algorithm and adds Roberts function.
[0070] Formula:
[0071]
[0072] It represents the sum in the X and Y directions of the two-dimensional image; the x direction starts from 1 to M-2; M represents the width of the image, and the y direction starts from 1 to N-2; N represents the height of the image.
[0073] f(x,y) represents the value of the pixel point with coordinates x,y on the image;
[0074] f(x+2,y) represents the value of the pixel point with coordinates x+2,y on the image;
[0075] f(x + 1, y + 1) represents the value of the pixel point with coordinates x + 1, y + 1 on the image;
[0076] f(x + 1, y) represents the value of the pixel point with coordinates x + 1, y on the image;
[0077] f(x, y + 1) represents the value of the pixel point with coordinates x, y + 1 on the image.
[0078] Image binarization processing is a key technology in digital image processing, and its core goal is to convert grayscale images or color images into binary images containing only black and white colors. This process is achieved by setting a threshold value, which can significantly simplify image information and highlight target features. It has important application value in focus adjustment and target recognition of the welding and marking integrated machine.
[0079] Core principles of image binarization
[0080] 1. Threshold segmentation mechanism
[0081] Global threshold method: set a single threshold T for the entire image, and divide the pixels into two categories:
[0082]
[0083] 2. Local threshold method: dynamically calculate the threshold value according to the pixel neighborhood (such as adaptive mean method, Niblack algorithm), which is suitable for images with uneven lighting (such as curved workpiece surface marking characters).
[0084] 3. Threshold selection method
[0085] Otsu algorithm: automatically determine the global threshold based on maximum inter-class variance, suitable for bimodal histogram images (such as welding pool and background segmentation).
[0086] Iterative threshold method: update the threshold value by iterative calculation of the mean until convergence, suitable for images with more noise.
[0087] Manual setting method: adjust the threshold value based on experience or experiment, suitable for specific scenarios (such as focus adjustment of fixed workpieces in welding and marking).
[0088] Application of image binarization processing in focus adjustment of welding and marking integrated machine:
[0089] Steps: After the industrial camera captures the image, separate the laser spot or marking characters from the background through binarization; calculate the geometric center or contour of the target in the binary image as the reference point for focus adjustment.
[0090] Advantages: reduce the amount of calculation, binary image only need to deal with black and white two colors, accelerate the subsequent gradient calculation; improve robustness, eliminate the interference of light fluctuation and background noise, such as the influence of welding splash on spot identification.
[0091] While embodiments of the application have been shown and described, it is to be understood that the embodiments described are merely divergences of the principles and spirit of the application and that numerous modifications, changes, substitutions, and alterations can be made thereto without departing from the spirit and scope of the application as defined by the appended claims and their equivalents.
Claims
1. A method for adjusting the focal length of a welding and marking machine, characterized in that: The following steps are involved: S1: The stepper motor moves in the focal length direction towards the focal point at a distance of 50 μm each time; S2: After the stepper motor moves once and stops steadily, an industrial camera is used to take a picture, the picture is binarized to determine the current position of the target, and then the target is cut out from the original image to obtain a current cut image; S3: Calculate the gradient value of the current cut image, compare the gradient value of the current cut image with the gradient value of the previous cut image, and make a corresponding judgment based on the comparison result before executing; S4: The stepper motor moves in the focal length direction toward the focal point at a distance of 10 μm each time; S5: After the stepper motor moves once and stops steadily, an industrial camera is used to take a picture, the picture is binarized to determine the current position of the target, and then the target is cut out from the original image to obtain a new cut image; S6: Calculate the gradient value of the newly cut image, compare the gradient value of the newly cut image with the gradient value of the previous cut image, and make a corresponding judgment based on the comparison result before executing.
2. A focal length adjustment method for a welding and marking integrated machine according to claim 1, characterized in that: The method for calculating the gradient value in step S3 and step S6 is an improved Brenner gradient algorithm, and the improved Brenner gradient algorithm is to add Roberts function on the basis of the Brenner gradient algorithm.
3. The focal length adjustment method of a welding and marking integrated machine according to claim 1, characterized in that: In step S3 and step S6, the formula of the Roberts function is: in, It represents the sum of the X and Y directions of a two-dimensional image; the x direction starts from 1 and ends at M-2; M represents the width of the image, the y direction starts from 1 and ends at N-2; N represents the height of the image; f(x,y) represents the value of the pixel with coordinates x,y on the image; f(x+2,y) represents the value of the pixel with coordinates x+2,y on the image; f(x+1,y+1) represents the value of the pixel with coordinates x+1,y+1 on the image; f(x+1,y) represents the value of the pixel with coordinates x+1,y+1 on the image; f(x,y+1) represents the value of the pixel with coordinates x,y+1 on the image.
4. The focal length adjustment method of a welding and marking integrated machine according to claim 1, characterized in that: In step S3, when the current cut image is the first image, it is compared with 0.
5. The focal length adjustment method of a welding and marking integrated machine according to claim 1, characterized in that: The comparison results in step S3 include: (1) If the gradient value of the current cutting image is greater than the gradient value of the previous cutting image, the current position value of the stepper motor is recorded and the maximum gradient value variable is updated; (2) If the current cutting image gradient value is less than 90% of the maximum gradient value, the stepper motor returns to the stepper motor position value corresponding to the maximum gradient value minus 50 μm, the maximum gradient value variable is cleared, and then the process jumps to step S4; otherwise, the process jumps to step S1.
6. A focal length adjustment method for a welding and marking integrated machine according to claim 1, characterized in that: In step S6, when the newly cut image is the first image, it is compared with 0.
7. The focal length adjustment method of a welding and marking integrated machine according to claim 1, characterized in that: The comparison results in step S6 include: (1) If the gradient value of the new cut image is greater than the gradient value of the previous cut image, the current position value of the stepper motor is recorded and the maximum gradient value variable is updated; (2) If the gradient value of the newly cut image is less than 95% of the maximum gradient value, the stepper motor returns to the stepper motor position value corresponding to the maximum gradient value. At this time, the position where the stepper motor stops is the position where the image gradient value is the largest, which is also the position corresponding to the focus.
8. A computer program product, characterized in that When the computer program product is read by a computer, the method according to any one of claims 1 to 7 is executed.
9. A computer-readable storage medium storing a program executable by a processor, characterized in that: The processor-executable program is used to perform the method according to any one of claims 1 to 7 when executed by the processor.
10. A focal length adjustment device for a welding and marking machine, characterized in that: The computer comprises a processor and a memory, wherein the memory comprises a computer-readable storage medium storing a program executable by the processor, and the program executable by the processor is used to execute the method according to any one of claims 1 to 7 when executed by the processor.