Disclosure of Invention
In view of the foregoing defects in the prior art, an object of the embodiments of the present invention is to provide an auto-focusing method and apparatus, a laser device, and a storage medium with high accuracy.
The purpose of the embodiment of the invention is realized by the following technical scheme:
in order to solve the above technical problem, in a first aspect, an embodiment of the present invention provides an auto-focusing method, which is applied to a laser device, and includes:
acquiring an image of the position of a processed object acquired by a camera;
acquiring an imaging position of a laser scanning line output by the laser equipment in the image;
acquiring imaging deviation between the imaging position and a preset focus position, wherein the preset focus position is a position of the laser scanning line in an image when the focus of the laser scanning line falls on the processed object;
and adjusting according to the imaging deviation so that the focal point of the laser scanning line falls on the processed object.
In some embodiments, the step of adjusting according to the imaging deviation to make the focal point of the laser scanning line fall on the processed object further includes:
and adjusting the distance between the laser equipment and the processed object according to the imaging deviation until the position of the laser scanning line in the image is at the preset focus position.
In some embodiments, the step of adjusting the distance between the laser device and the processed object according to the imaging deviation further comprises:
calculating actual deviation according to the imaging deviation and by combining the current focal length of the camera;
judging whether the imaging position is on a first side or a second side of the preset focus position;
and if the first side is the first side, increasing the actual deviation of the distance between the laser equipment and the processed object.
In some embodiments, the method further comprises:
and if the second side is the first side, reducing the actual deviation of the distance between the laser equipment and the processed object.
In some embodiments, the step of adjusting according to the imaging deviation to make the focal point of the laser scanning line fall on the processed object further includes:
and adjusting the focal length of the laser equipment according to the imaging deviation so that the focal point of the laser scanning line falls on the processed object.
In some embodiments, the step of adjusting the focal length of the laser device according to the imaging deviation further comprises:
calculating actual deviation according to the imaging deviation and by combining the current focal length of the camera;
calculating the actual distance between the laser equipment and the processed object according to the actual deviation and the focal length of the laser equipment;
and adjusting the focal length of the laser device so that the focal length of the laser device is equal to the actual distance.
In some embodiments, the step of calculating an actual distance between the laser device and the processed object according to the actual deviation and in combination with the focal length of the laser device further comprises:
judging whether the imaging position is on a first side or a second side of the preset focus position;
if the distance is the first side, taking the sum of the focal length of the laser equipment and the actual deviation as the actual distance;
and if the distance is the second side, taking the difference between the focal length of the laser equipment and the actual deviation as the actual distance.
In order to solve the above technical problem, in a second aspect, an embodiment of the present invention provides an automatic focusing apparatus, including:
the first acquisition module is used for acquiring an image of the position of the processed object acquired by the camera;
the second acquisition module is used for acquiring the imaging position of the laser scanning line output by the laser equipment in the image;
a third obtaining module, configured to obtain an imaging deviation between the imaging position and a preset focus position, where the preset focus position is a position of the laser scanning line in an image when a focus of the laser scanning line falls on the processed object;
and the adjusting module is used for adjusting according to the imaging deviation so as to enable the focus of the laser scanning line to fall on the processed object.
In order to solve the above technical problem, in a third aspect, an embodiment of the present invention provides a laser apparatus, including:
at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of the first aspect as described above.
In order to solve the above technical problem, in a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium storing computer-executable instructions for causing a computer to perform the method according to the first aspect.
In order to solve the above technical problem, in a fifth aspect, the present invention further provides a computer program product, which includes a computer program stored on a computer-readable storage medium, the computer program including program instructions, which, when executed by a computer, cause the computer to execute the method according to the first aspect.
Compared with the prior art, the invention has the beneficial effects that: different from the prior art, embodiments of the present invention provide an auto-focusing method, an auto-focusing device, a laser device, and a storage medium, where the method obtains an image of a position of an object to be processed, which is acquired by a camera, an imaging position of a laser scanning line output by the laser device in the image, and an imaging deviation between the imaging position and a preset focus position, and finally adjusts according to the imaging deviation, so that a focus of the laser scanning line falls on the object to be processed, thereby achieving precise focusing of the laser device on a plane or a surface of the object to be processed.
Detailed Description
The present invention will be described in detail with reference to specific examples. The following examples will assist those skilled in the art in further understanding the invention, but are not intended to limit the invention in any way. It should be noted that variations and modifications can be made by persons skilled in the art without departing from the spirit of the invention. All falling within the scope of the present invention.
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
It should be noted that, if not conflicted, the various features of the embodiments of the invention may be combined with each other within the scope of protection of the present application. Additionally, while functional block divisions are performed in apparatus schematics, with logical sequences shown in flowcharts, in some cases, steps shown or described may be performed in sequences other than block divisions in apparatus or flowcharts. Further, the terms "first," "second," and the like, as used herein, do not limit the data and the execution order, but merely distinguish the same items or similar items having substantially the same functions and actions.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs. The terminology used in the description of the invention herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. As used herein, the term "and/or" includes any and all combinations of one or more of the associated listed items.
In addition, the technical features involved in the embodiments of the present invention described below may be combined with each other as long as they do not conflict with each other.
Please refer to fig. 1, which is a schematic diagram of an exemplary system structure applied to an embodiment of the auto-focusing method of the present invention. As shown in fig. 1, the system architecture includes: the device comprises a laser device 10, a camera 20 and an object to be processed 30, wherein the laser device 10 and the camera 20 are connected in a communication mode.
In order to obtain sufficient power density to process the surface of the processed object when the laser device 10 is in operation, the focal point of the laser scanning line or laser scanning point emitted by the laser device 10 needs to be able to fall on the currently processed surface of the processed object 30. The embodiment of the invention determines whether the focus of the laser scanning line emitted by the laser device 10 falls on the processed object by analyzing the image shot by the camera 20.
The laser device 10 may be any device capable of emitting a laser scanning line or a laser scanning spot, and the maximum power density can be obtained when the laser device 10 is operated and the focal point is on the surface of the object 30 to be processed. For example, the laser device 10 may be a laser cleaning head, a laser cutting machine, a laser marking machine, etc., and may be specifically configured according to actual situations, in the embodiment of the present invention, the laser cleaning head is taken as an example, and the surface of the corresponding object 30 to be processed is cleaned by the laser scanning lines emitted by the laser cleaning head in the embodiment of the present invention.
In addition, the laser device 10 may be provided with a device capable of adjusting the focal length therein, and the focal length may be adjusted by mechanical adjustment, such as by adjusting the spacing of the optical lenses to adjust the focal length of the laser device 10; or by electrical adjustment, such as activating a liquid crystal area in a liquid crystal lens to adjust the focal length of the laser device 10. Alternatively, the laser device 10 may be connected to a mechanical motion structure, such as a moving platform/moving sub-base such as a grating ruler and a KK module, which can move along a certain direction on a guide rail, and the mechanical motion structure can adjust the distance between the laser device 10 and the object 30 to be processed.
The two modes can be set according to actual needs, for example, when a miniaturized laser device 10 needs to be selected, the laser device 10 can be selected to be mounted on a grating scale. Alternatively, when it is necessary to keep the distance between the laser apparatus 10 and the object 30 to be processed constant, the laser apparatus 10 having the focusing module provided therein may be selected. The embodiment of the present invention is exemplified by a laser apparatus 10 having a focusing module provided therein.
It should be noted that the automatic focusing method provided by the embodiment of the present invention is generally performed by the laser device 10, and accordingly, the automatic focusing device is generally disposed in the laser device 10.
The camera 20 may be a CCD camera, an infrared camera, or the like capable of acquiring image features of the laser scanning line, that is, a camera capable of distinguishing or identifying the laser scanning line from the acquired image. For example, when the image acquired by the camera 20 is a grayscale image, the grayscale of the laser scanning line in the image is different from the grayscale of the surrounding object in the image, so the position of the laser scanning line in the image can be identified. Alternatively, the color of the laser scanning line in the image is different from the color of the surrounding object in the image, and therefore the position of the laser scanning line in the image can also be identified.
Further, please refer to fig. 2, which shows a schematic diagram of an auto-focusing method according to an embodiment of the present invention. When the upper surface of the object 30 to be processed is processed by the laser apparatus 10 as shown in fig. 1, the laser apparatus 10 outputs a laser scanning line to the upper surface of the object 30 to be processed, and there are three cases as shown in fig. 2 in which the distance from the laser apparatus 10 is the laser scanning line hitting the upper surface of the object 30 to be processed:
in the first case, when the laser scanning line is located at the position B, that is, the height of the upper surface of the object 30 to be processed at the position B in fig. 1, the focal point of the laser scanning line is located just above the upper surface of the object 30 to be processed, and at this time, the distance between the laser scanning line and the laser device 10 is the focal distance of the laser device 10, and the power density of the laser scanning line on the upper surface of the object 30 to be processed reaches the maximum. At this time, in the image captured by the camera 20, the laser scanning line passes through the diaphragm 22 of the camera 20, and is imaged on the position b in the imaging element 21, and the position b can be set as a preset focal position as a reference for accurate focusing of the laser scanning line.
In the second case, the laser scanning line is located at the position a, at which the distance between the laser scanning line and the laser device 10 is shorter than the focal length of the laser device 10, and after passing through the diaphragm 22 of the camera, the laser scanning line is finally imaged on the position a of the imaging element 21, and by obtaining the distance between the position a and the position B and combining the focal length of the camera 20, the actual deviation h1 of the position a relative to the position B (focal position) can be obtained, and the focal length or the height position of the laser device 10 is adjusted according to the actual deviation h1, so that the focal point of the laser scanning line is located at the position a, and the laser scanning line located on the upper surface of the object to be processed can reach the maximum power density.
In the third case, the laser scanning line is located at the position C, at this time, the distance between the laser scanning line and the laser device 10 is longer than the focal length of the laser device 10, the laser scanning line passes through the diaphragm 22 of the camera, and is finally imaged on the position C of the imaging element 21, by obtaining the distance between the position C and the position B and combining the focal length of the camera 20, the actual deviation h2 of the position C relative to the position B (focal position) can be obtained, and the focal length or the height position of the laser device 10 is adjusted according to the actual deviation h2, so that the focal point of the laser scanning line is located at the position C, and the laser scanning line located on the upper surface of the object to be processed can reach the maximum power density.
It should be noted that, in fig. 2, the laser scanning line is simplified to be a point, in practical application, the laser scanning line in the image should be a straight line, and the distance between the acquisition position a and the acquisition position b, or the distance between the acquisition position c and the acquisition position b, refers to a shortest distance between the laser scanning line in the image and the preset focal position, where the shortest distance may be a shortest distance between two laser scanning lines in the image at the current imaging position and the preset focal position.
In addition, when the object 30 to be processed is an irregular object, the current surface to be processed in the image is acquired according to the preset shape of the current surface to be processed, the laser scanning line in the image of the current surface to be processed is further identified, and the imaging deviation of the laser scanning line is acquired. For example, when the object 30 to be processed is a ladder post and the emission direction of the laser scanning line of the laser device 10 is directly below, the upper surface of the ladder post placed horizontally may be taken as the current surface to be processed, and an image of the current surface to be processed may be extracted from the image captured by the camera 20 according to the image characteristics thereof. Wherein the currently processed surface is a surface of the same height. In other embodiments, the placement mode of the laser device 10 and the light emitting direction thereof may be set according to actual needs, and need not be limited by the embodiments of the present invention.
In the embodiment of the present invention, since there may be two cases where the focal point of the laser scanning line does not fall on the surface of the object to be processed, such as a case where the distance from the position a to the laser apparatus 10 is shorter than the focal length of the laser apparatus 10, and a case where the distance from the position C to the laser apparatus 10 is longer than the focal length of the laser apparatus 10, when the imaging deviation is adjusted separately, the adjustment directions of the two cases are opposite. Therefore, in calculating the imaging deviation, it is also necessary to determine whether the laser scanning line is imaged on the imaging element 21 on the first side (i.e., the side on which the position c is located) or the second side (i.e., the side on which the position a is located) of the preset focal position b. Further, the specific values of the imaging deviation can be expressed by using positive and negative signs respectively.
Specifically, the embodiments of the present invention will be further explained below with reference to the drawings.
An embodiment of the present invention provides an automatic focusing method, which is applied to the laser device 10 and can be executed by the laser device 10, please refer to fig. 3, which shows a flow chart of an automatic focusing method applied according to the above system structure, and the method includes, but is not limited to, the following steps:
step 110: and acquiring an image of the position of the processed object acquired by the camera.
In the embodiment of the present invention, the image of the position of the processed object includes a laser scanning line. The image of the position of the object to be processed may be an image including the entire object to be processed, or may be an image including a partial structure of the object to be processed.
After recognizing the position of the processed object, the camera acquires and stores the current image. Specifically, the camera may also collect and store the current image after recognizing the laser scanning line. The method for identifying the processed object or the laser scanning line is selected according to the type of the camera and the image shot by the camera, for example, whether the processed object or the laser scanning line exists in the image currently collected by the camera in real time can be determined through gray scale or color.
Step 120: and acquiring the imaging position of the laser scanning line output by the laser equipment in the image.
And acquiring an imaging position of a laser scanning line output by the equipment in the image after acquiring the image of the position of the processed object, wherein the imaging position may have three conditions. As shown in fig. 2, the case where the distance H1 between the laser scanning line and the laser device is shorter than the focal length of the laser cleaning head, respectively, the imaging position of the laser scanning line in the image is the position a; under the condition that the distance H between the laser scanning line and the laser equipment is equal to the focal length of the laser cleaning head, the imaging position of the laser scanning line in the image is the position b; and the distance H2 between the laser scanning line and the laser device is longer than the focal length of the laser cleaning head, and the imaging position of the laser scanning line in the image is the position c.
Step 130: and acquiring imaging deviation between the imaging position and a preset focus position, wherein the preset focus position is the position of the laser scanning line in an image when the focus of the laser scanning line falls on the processed object.
In the embodiment of the present invention, as shown in fig. 2, when the position b is set as the preset focal position, and the imaging position of the laser scanning line in the image is the position a, the shortest distance between the position a and the position b is the imaging deviation between the acquired imaging position and the preset focal position. Or, the imaging position of the laser scanning line in the image is position c, and the shortest distance between position b and position c is the imaging deviation between the acquired imaging position and the preset focus position.
It should be noted that fig. 2 simplifies the laser scanning line into one point, and in practical use, the laser scanning line is a line, and the imaging deviation between the imaging position and the preset focus position is obtained, specifically, the shortest distance between the laser scanning line at the preset focus position and the laser scanning line at the imaging position is obtained as the imaging deviation.
Step 140: and adjusting according to the imaging deviation so that the focal point of the laser scanning line falls on the processed object.
After the imaging deviation between the imaging position and the preset focus position in the image is obtained, the actual distance between the laser scanning line and the laser device and the actual deviation of the focal length of the laser device can be correspondingly obtained according to the focal length of the laser device or the camera, the focal length of the laser device or the distance between the laser device and the processed object is adjusted according to the actual deviation, the focus of the laser scanning line is made to fall on the processed object, and the processed object can be processed by the laser scanning line with the maximum power density finally.
The embodiment of the invention provides an automatic focusing method, which comprises the steps of acquiring an image of a position where a processed object is located, acquired by a camera, an imaging position of a laser scanning line output by laser equipment in the image and imaging deviation between the imaging position and a preset focus position, and finally adjusting according to the imaging deviation to enable the focus of the laser scanning line to fall on the processed object, so that accurate focusing of the laser equipment on the plane or the surface of the processed object is realized.
In some embodiments, when the surface of the object to be processed is cleaned due to the irradiation of the scanning line output from the laser device to the object to be processed, the surface of the object to be processed is inevitably peeled off to generate spatters and dust, which may affect the image formation, for example, cause the laser scanning line to become thick, or cause practical problems such as insufficient edge definition, blurring, and the like. Therefore, before the step of acquiring the imaging position of the laser scanning line output by the laser device in the image (step 120), the method further comprises: the image is processed by filtering, edge detection and/or image erosion operations to obtain clear scan lines.
Referring to fig. 4, a schematic flow chart of another auto-focusing method is shown, which adjusts the distance between the laser device and the processed object according to the imaging deviation of the laser scanning line in the image to achieve auto-focusing, specifically, the method is different from the method described in fig. 3 and the related embodiment, in that the step 140 further includes:
step 140 a: and adjusting the distance between the laser equipment and the processed object according to the imaging deviation until the position of the laser scanning line in the image is at the preset focus position.
In the embodiment of the present invention, after the imaging deviation is obtained through calculation, the distance between the laser device and the object to be processed is adjusted according to the imaging deviation until the position of the laser scanning line in the image is located at the preset focal position, that is, the focal point of the laser scanning line falls on the object to be processed.
Specifically, as shown in fig. 2, the distance between the laser device and the object to be processed is adjusted to be the distance H, i.e., the position of the laser scanning line in the image is located at the preset focal position b. Alternatively, the distance between the laser device and the object to be processed may be adjusted by a mechanical movement structure with a guide rail.
In some embodiments, please refer to fig. 5, which illustrates a sub-flowchart of step 140a of the method shown in fig. 4, wherein the step 140a further includes:
step 141 a: and calculating the actual deviation according to the imaging deviation and by combining the current focal length of the camera.
Step 142 a: determining whether the imaging position is on a first side or a second side of the preset focus position. If the first side is the first side, go to step 143 a; if the second side is the first side, go to step 144 a.
Step 143 a: and if the first side is the first side, increasing the actual deviation of the distance between the laser equipment and the processed object.
Step 144 a: and if the second side is the first side, reducing the actual deviation of the distance between the laser equipment and the processed object.
In the embodiment of the present invention, when calculating the actual deviation, it is necessary to simultaneously determine whether the imaging position is on the first side or the second side of the preset focus position to determine whether the distance between the laser apparatus and the object to be processed is shorter than the focal length of the laser apparatus or longer than the focal length of the laser apparatus to determine whether the distance between the laser apparatus and the object to be processed needs to increase or decrease the actual deviation.
The first side and the second side are two sides which separate the image when the laser scanning line is at a preset focus position in the image, and the first side and the second side are two opposite and non-intersecting sides. And, when the imaging position is on the first side of the preset focus position, the distance between the laser scanning line and the laser device is shorter than the focal length of the laser device, and therefore, the actual deviation needs to be increased; when the imaging position is on the second side of the preset focus position, the distance of the laser scanning line from the laser device is longer than the focal length of the laser device, and therefore, it is necessary to reduce the actual deviation. For example, in fig. 2, the position a is on a first side of the preset focus position b, and the position b is on a second side of the preset focus position b.
Specifically, taking fig. 2 as an example, when the imaging position of the laser scanning line output by the laser device 10 in the image is position a, the actual deviation h1 can be calculated according to the distance between position a and the preset focal position b, that is, the imaging deviation, and the focal length of the camera 20. Alternatively, the actual deviation h1 may be calculated from the distance between the position a and the preset focal position b, in combination with the focal length of the laser device 10. Since the position a is on the first side of the preset focal position b, the distance H1 between the laser device 10 and the object to be processed is increased by the actual deviation H1, i.e. the distance between the laser scanning line and the laser device 10 reaches the focal length H of the laser device 10, so that the position of the laser scanning line in the image is at the preset focal position b.
When the imaging position of the laser scanning line output by the laser device 10 in the image is position c, the actual deviation h2 can be calculated according to the distance between position c and the preset focal position b, that is, the imaging deviation, and the focal length of the camera 20. Alternatively, the actual deviation h2 may be calculated from the distance between the position c and the preset focal position b in combination with the focal length of the laser apparatus 10. Since the position c is on the second side of the preset focal position b, the distance H2 between the laser device 10 and the object to be processed is reduced by the actual deviation H2, i.e. the distance between the laser scanning line and the laser device 10 reaches the focal length H of the laser device 10, so that the position of the laser scanning line in the image is at the preset focal position b.
It should be noted that the focal length of the camera 20 and/or the focal length value of the laser device 10 are/is pre-stored in the laser device 10, and according to a trigonometric function and a geometric theorem, the imaging deviation may be calculated by combining the focal length of the camera 20 to obtain the actual deviation, or may be calculated by combining the focal length of the laser device 10 to obtain the actual deviation. Preferably, the embodiment of the present invention performs calculation in combination with the focal length of the camera 20 to obtain the actual deviation. The focal length of the camera 20 and the focal length of the laser device 10 may or may not be equal.
Referring to fig. 6, a flowchart of another auto-focusing method is shown, which adjusts the focal length of a laser device according to the imaging deviation of a laser scanning line in an image to achieve auto-focusing, specifically, unlike the method shown in fig. 3, the step 140 further includes:
step 140 b: and adjusting the focal length of the laser equipment according to the imaging deviation so that the focal point of the laser scanning line falls on the processed object.
In the embodiment of the present invention, after the imaging deviation is obtained through calculation, the focal length of the laser device is adjusted according to the imaging deviation until the focal point of the laser scanning line falls on the processed object, that is, the position of the laser scanning line in the image is located at the preset focal position after the focal length is adjusted.
Specifically, as shown in fig. 2, the focal distance between the laser device and the object to be processed is readjusted, for example, the focal distance H is adjusted to H1 or H2, so that the focal point of the laser scanning line falls on the position a or the position C, that is, the position a or the position C of the laser scanning line in the image will be located on the preset focal position b after the focal distance is adjusted. Alternatively, the focal length of the laser device 10 may be adjusted mechanically or electrically to achieve focusing of the laser device.
In some embodiments, please refer to fig. 7, which illustrates a sub-flowchart of step 140b of the method shown in fig. 6, wherein the step 140b further includes:
step 141 b: and calculating the actual deviation according to the imaging deviation and by combining the current focal length of the camera.
Step 142 b: and calculating the actual distance between the laser equipment and the processed object according to the actual deviation and the focal length of the laser equipment.
Step 143 b: and adjusting the focal length of the laser device so that the focal length of the laser device is equal to the actual distance.
In the embodiment of the present invention, the actual deviation can be calculated according to the imaging deviation and the current focal length of the camera, and the actual distance between the laser device to be processed and the object to be processed can be calculated by combining the focal length of the laser device, and further, the focal length of the laser device is adjusted until the focal length of the laser device is equal to the actual distance, so that the focal point of the laser scanning line finally falls on the object to be processed.
Further, in some embodiments, please refer to fig. 8, which shows a sub-flowchart of step 142b of the method shown in fig. 7, wherein the step 142b further includes:
the step 144 b: judging whether the imaging position is on a first side or a second side of the preset focus position;
the step 145 b: if the distance is the first side, taking the sum of the focal length of the laser equipment and the actual deviation as the actual distance;
the step 146 b: and if the distance is the second side, taking the difference between the focal length of the laser equipment and the actual deviation as the actual distance.
The same as the step 142a, when calculating the actual deviation, it is also necessary to determine whether the imaging position is on the first side or the second side of the preset focal position, according to the relationship between the distance between the laser scanning line and the laser device and the length of the focal length of the laser device. That is, as shown in fig. 2, it is determined whether the laser scanning line is imaged on the imaging element 21 on the first side (i.e., the side on which the position c is located) or the second side (i.e., the side on which the position a is located) of the preset focal position b.
Specifically, when the imaging position is on the first side of the preset focus position, the distance between the laser scanning line/the object to be processed and the laser device is shorter than the focal length of the laser device, and therefore, the sum of the focal length of the laser device and the actual deviation needs to be taken as the actual distance; when the imaging position is on the second side of the preset focus position, the distance between the laser scanning line and the laser device is longer than the focal length of the laser device, and therefore, the difference between the focal length of the laser device and the actual deviation needs to be taken as the actual distance. Further, the distance between the laser scanning line/the processed object and the laser device is adjusted to be the actual distance, so that the position of the laser scanning line in the image is moved to a preset focus position, and automatic focusing is completed.
An embodiment of the present invention further provides an automatic focusing apparatus, please refer to fig. 9, which shows a structure of an automatic focusing apparatus provided in an embodiment of the present application, where the automatic focusing apparatus 200 includes: a first obtaining module 210, a second obtaining module 220, a third obtaining module 230, and an adjusting module 240.
The first obtaining module 210 is configured to obtain an image of a position of the processed object, where the image is acquired by the camera;
the second obtaining module 220 is configured to obtain an imaging position of a laser scanning line output by the laser device in the image;
the third obtaining module 230 is configured to obtain an imaging deviation between the imaging position and a preset focus position, where the preset focus position is a position of the laser scanning line in the image when the focus of the laser scanning line falls on the processed object;
the adjusting module 240 is configured to adjust according to the imaging deviation so that the focal point of the laser scanning line falls on the processed object.
In some embodiments, the adjusting module 240 is further configured to adjust a distance between the laser device and the processed object according to the imaging deviation until the position of the laser scanning line in the image is at the preset focus position.
In some embodiments, the adjusting module 240 is further configured to calculate an actual deviation according to the imaging deviation and in combination with a current focal length of the camera. Determining whether the imaging position is on a first side or a second side of the preset focus position. And if the first side is the first side, increasing the actual deviation of the distance between the laser equipment and the processed object. And if the second side is the first side, reducing the actual deviation of the distance between the laser equipment and the processed object.
In some embodiments, the adjusting module 240 is further configured to adjust a focal length of the laser device according to the imaging deviation, so that a focal point of the laser scanning line falls on the processed object.
In some embodiments, the adjusting module 240 is further configured to calculate an actual deviation according to the imaging deviation and in combination with the current focal length of the camera; calculating the actual distance between the laser equipment and the processed object according to the actual deviation and the focal length of the laser equipment; and adjusting the focal length of the laser device so that the focal length of the laser device is equal to the actual distance.
In some embodiments, the adjusting module 240 is further configured to determine whether the imaging position is on a first side or a second side of the preset focus position; if the distance is the first side, taking the sum of the focal length of the laser equipment and the actual deviation as the actual distance; and if the distance is the second side, taking the difference between the focal length of the laser equipment and the actual deviation as the actual distance.
It should be noted that, since the autofocus apparatus in the present embodiment is based on the same inventive concept as the method embodiment, the corresponding content in the method embodiment is also applicable to the apparatus embodiment, and is not described in detail herein.
An embodiment of the present invention further provides a laser device, please refer to fig. 10, which shows a hardware structure of a laser device capable of performing the auto-focusing method described in fig. 3 to fig. 8. The laser device 10 may be the laser device 10 shown in fig. 1 and/or fig. 2.
The laser apparatus 10 includes: at least one processor 11; and a memory 12 communicatively coupled to the at least one processor 11, which is exemplified by one processor 11 in fig. 10. The memory 12 stores instructions executable by the at least one processor 11, the instructions being executable by the at least one processor 11 to enable the at least one processor 11 to perform the auto-focusing method described above with respect to fig. 3-8. The processor 11 and the memory 12 may be connected by a bus or other means, and fig. 10 illustrates the connection by a bus as an example.
The memory 12, which is a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules, such as program instructions/modules corresponding to the auto-focusing method in the embodiment of the present application, for example, the modules shown in fig. 9. The processor 11 executes various functional applications of the server and data processing by running nonvolatile software programs, instructions and modules stored in the memory 12, that is, the autofocus method of the above-described method embodiment is realized.
The memory 12 may include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data area may store data created according to use of the auto-focusing device, and the like. Further, the memory 12 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid state storage device. In some embodiments, the memory 12 optionally includes memory located remotely from the processor 11, which may be connected to the autofocus device via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The one or more modules are stored in the memory 12 and when executed by the one or more processors 11 perform the auto-focusing method in any of the method embodiments described above, e.g., perform the method steps of fig. 3-8 described above, implementing the functionality of the modules and units in fig. 9.
The product can execute the method provided by the embodiment of the application, and has the corresponding functional modules and beneficial effects of the execution method. For technical details that are not described in detail in this embodiment, reference may be made to the methods provided in the embodiments of the present application.
Embodiments of the present application also provide a non-transitory computer-readable storage medium storing computer-executable instructions for execution by one or more processors, for example, to perform the method steps of fig. 3 to 8 described above, to implement the functions of the modules and units in fig. 9.
Embodiments of the present application also provide a computer program product comprising a computer program stored on a non-transitory computer-readable storage medium, the computer program comprising program instructions that, when executed by a computer, cause the computer to perform necessary graphics processing to obtain clear scan line positions and an auto-focusing method in any of the above method embodiments, for example, to perform the method steps of fig. 3 to 8 described above, and to implement the functions of the modules and units in fig. 9.
The embodiment of the invention provides an automatic focusing method, an automatic focusing device, laser equipment and a storage medium, wherein the method comprises the steps of acquiring an image of the position of a processed object acquired by a camera, the imaging position of a laser scanning line output by the laser equipment in the image and the imaging deviation between the imaging position and a preset focus position, and finally adjusting according to the imaging deviation to enable the focus of the laser scanning line to fall on the processed object, so that the laser equipment can be accurately focused on the plane or the surface of the processed object.
It should be noted that the above-described device embodiments are merely illustrative, where the units described as separate parts may or may not be physically separate, and the parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment.
Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented by software plus a general hardware platform, and certainly can also be implemented by hardware. It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware related to instructions of a computer program, which can be stored in a computer readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. The storage medium may be a magnetic disk, an optical disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), or the like.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; within the idea of the invention, also technical features in the above embodiments or in different embodiments may be combined, steps may be implemented in any order, and there are many other variations of the different aspects of the invention as described above, which are not provided in detail for the sake of brevity; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present invention.