Method, device and equipment for determining installation angle of light source and storage medium

CN117647181BActive Publication Date: 2026-09-04CHERY AUTOMOBILE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311606970.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-11-24
Publication Date
2026-09-04
Estimated Expiration
2043-11-24

AI Technical Summary

Technical Problem

[0004]然而,在相关技术中往往无法对光源的照射角度进行准确的设置,无法对产品具有合适的照度,从而影响成像质量,导致机器视觉测量的精确度较低

Benefits of technology

[0021] In this embodiment, the illuminance at each sampling point within the target area of ​​the stage is assessed using a first light source and a second light source. A penalty function and the illuminance variance between the illuminance at each sampling point within the target area and the illuminance at the center point within the target area are then determined. Based on this illuminance variance and the penalty function, a target function is constructed. Based on this target function, an annealing algorithm is used to determine the target light source installation angles for the first and second light sources. Constructing the target function based on the illuminance variance and the penalty function ensures a more accurate determination of the target light source installation angles. Installing the first and second light sources at these target angles results in more uniform illuminance within the target area of ​​the stage, providing better illumination for the object to be inspected on the stage and improving the effectiveness of machine vision inspection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117647181B_ABST
    Figure CN117647181B_ABST
Patent Text Reader

Abstract

Embodiments of the application disclose a light source installation angle determination method, device and equipment and a storage medium, and belong to the field of computer vision. The method comprises the following steps: determining the illuminance of each sampling point in a target region in a stage based on the irradiation distance between the first light source, the second light source and each sampling point in the stage and the light source installation angle of the first light source and the second light source; determining the illuminance variance of each sampling point in the target region and the illuminance of a central point in the target region based on the illuminance of each sampling point in the target region; determining a penalty function based on the illuminance of each sampling point in the target region and the illuminance of the central point in the target region; determining a target function based on the penalty function and the illuminance variance, wherein the target function value of the target function is used to indicate the uniformity of the illuminance of each sampling point in the target region under different light source installation angles; and determining a target light source installation angle based on the target function through an annealing algorithm.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer vision, and in particular to a method, apparatus, device, and storage medium for determining the installation angle of a light source. Background Technology

[0002] When inspecting product dimensions using machine vision, industrial cameras are typically used to photograph the product to obtain an image of it.

[0003] When using industrial cameras to photograph products, a light source is usually required. Front illumination is used to illuminate the product, with the light source and camera mounted on the same side of the object being measured. However, during the scanning process using machine vision technology, the distribution of light sources around the object directly affects the image quality, and thus the accuracy of machine vision measurements.

[0004] However, in related technologies, it is often impossible to accurately set the illumination angle of the light source, resulting in unsuitable illumination for the product, which affects the imaging quality and leads to low accuracy in machine vision measurements. Summary of the Invention

[0005] This application provides a method, apparatus, device, and storage medium for determining the installation angle of a light source. The technical solution is as follows:

[0006] On one hand, embodiments of this application provide a method for determining the installation angle of a light source, the method comprising:

[0007] Based on the illumination distance between the first light source and the second light source and each sampling point in the stage, and the installation angle of the first light source and the second light source, the illuminance of each sampling point in the target area in the stage is determined. The first light source and the second light source are symmetrical about the vertical plane. The stage is set horizontally, and the first light source and the second light source emit light towards the stage. The installation angle of the light source refers to the angle between the tilt direction of the first light source and the second light source and the vertical direction.

[0008] Based on the illuminance of each sampling point within the target area, determine the illuminance variance between the illuminance of each sampling point within the target area and the illuminance of the center point within the target area;

[0009] Based on the illuminance of each sampling point in the target area and the illuminance of the center point in the target area, a penalty function is determined. The penalty function is used to constrain the maximum illuminance difference between each sampling point in the target area and the center point in the target area.

[0010] The objective function is determined based on the penalty function and the illuminance variance. The objective function value is used to indicate the uniformity of illuminance at each sampling point in the target area under different light source installation angles.

[0011] Based on the objective function, the installation angle of the target light source is determined by the annealing algorithm.

[0012] On the other hand, embodiments of this application provide a device for determining the installation angle of a light source, the device comprising:

[0013] The first determining module is used to determine the illuminance of each sampling point in the target area of ​​the stage based on the illumination distance between the first light source and the second light source and each sampling point in the stage, as well as the installation angle of the first light source and the second light source. The first light source and the second light source are symmetrical about the vertical plane, the stage is horizontally set, and the first light source and the second light source emit light towards the stage. The installation angle of the light source refers to the angle between the tilt direction of the first light source and the second light source and the vertical direction.

[0014] The second determining module is used to determine the illuminance variance between the illuminance of each sampling point in the target area and the illuminance of the center point in the target area, based on the illuminance of each sampling point in the target area.

[0015] The third determining module is used to determine a penalty function based on the illuminance of each sampling point in the target area and the illuminance of the center point in the target area. The penalty function is used to constrain the maximum illuminance difference between each sampling point in the target area and the center point in the target area.

[0016] The fourth determining module is used to determine the target function based on the penalty function and the illuminance variance. The target function value is used to indicate the uniformity of illuminance at each sampling point in the target area under different light source installation angles.

[0017] The fifth determining module is used to determine the installation angle of the target light source based on the objective function using an annealing algorithm.

[0018] On the other hand, embodiments of this application provide a computer device, the computer device including a processor and a memory; the memory stores at least one instruction, the at least one instruction being executed by the processor to implement the method for determining the light source installation angle as described above.

[0019] On the other hand, embodiments of this application provide a computer-readable storage medium storing at least one piece of program code, which is loaded and executed by a processor to implement the method for determining the light source installation angle as described above.

[0020] On the other hand, embodiments of this application provide a computer program product including computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the method for determining the light source installation angle provided in the various optional implementations of the above aspects.

[0021] In this embodiment, the illuminance at each sampling point within the target area of ​​the stage is assessed using a first light source and a second light source. A penalty function and the illuminance variance between the illuminance at each sampling point within the target area and the illuminance at the center point within the target area are then determined. Based on this illuminance variance and the penalty function, a target function is constructed. Based on this target function, an annealing algorithm is used to determine the target light source installation angles for the first and second light sources. Constructing the target function based on the illuminance variance and the penalty function ensures a more accurate determination of the target light source installation angles. Installing the first and second light sources at these target angles results in more uniform illuminance within the target area of ​​the stage, providing better illumination for the object to be inspected on the stage and improving the effectiveness of machine vision inspection. Attached Figure Description

[0022] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0023] Figure 1 A flowchart illustrating a method for determining the installation angle of a light source according to an exemplary embodiment of this application is shown;

[0024] Figure 2 A schematic diagram illustrating the installation of a light source according to an exemplary embodiment of this application is shown;

[0025] Figure 3 A flowchart illustrating the process of determining the installation angle of a target light source according to an exemplary embodiment of this application is shown;

[0026] Figure 4 A schematic diagram of an illuminance distribution map provided in an exemplary embodiment of this application is shown;

[0027] Figure 5 This illustration shows a schematic diagram of the angle difference provided by an exemplary embodiment of this application;

[0028] Figure 6A schematic diagram illustrating the installation of a light source according to an exemplary embodiment of this application is shown;

[0029] Figure 7 A schematic diagram of an annealing algorithm parameter setting interface provided in an exemplary embodiment of this application is shown;

[0030] Figure 8 A structural block diagram of a light source installation angle determination device provided in one embodiment of this application is shown;

[0031] Figure 9 A structural block diagram of a computer device provided in an exemplary embodiment of this application is shown. Detailed Implementation

[0032] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.

[0033] Annealing, or annealing algorithm, refers to the application of the annealing concept to combinatorial optimization. It's a stochastic optimization algorithm based on the Monte Carlo iterative solution strategy, drawing inspiration from the similarity between the annealing process of solid materials in physics and general combinatorial optimization problems. Annealing, in metal annealing, involves heating the metal to a certain temperature, holding it for a sufficient time, and then cooling it at an appropriate rate—a metal heat treatment process. Simulated annealing originates from the principle of solid-state annealing. The solid is heated to a sufficiently high temperature and then slowly cooled. During heating, the particles inside the solid become disordered with increasing temperature, increasing internal energy. During slow cooling, the particles gradually become ordered, reaching an equilibrium state at each temperature, and finally reaching the ground state at room temperature, where the internal energy is minimized. Compared to other optimization algorithms, the biggest advantage of annealing is its ability to find the optimal solution globally, without limiting the solution range to the neighborhood of a particular extreme value.

[0034] Forward illumination refers to mounting the light source and camera on the same side of the object being measured. The advantage of forward illumination is that it allows for simpler installation while still illuminating the target object. The method for determining the light source installation angle provided in this application is applied to the aforementioned forward illumination scenario.

[0035] Machine vision refers to the application of image analysis technology in factory automation. It uses optical systems, industrial digital cameras, and image processing tools to simulate human visual capabilities and make corresponding decisions. During the scanning and measurement of objects using machine vision technology, the distribution of light sources around the object directly affects the image quality, and similarly, it directly impacts the measurement accuracy of machine vision inspection methods.

[0036] Figure 1A flowchart illustrating a method for determining the installation angle of a light source according to an exemplary embodiment of this application is shown. The method includes the following steps:

[0037] Step 101: Based on the illumination distance between the first light source and the second light source and each sampling point in the stage, as well as the installation angle of the first light source and the second light source, determine the illuminance of each sampling point in the target area of ​​the stage.

[0038] The first light source and the second light source are symmetrical about the vertical plane. The stage is set horizontally, and the first light source and the second light source emit light towards the stage. The installation angle of the light source refers to the angle between the tilt direction of the first light source and the second light source and the vertical direction.

[0039] The installation angle of the light source is a value to be determined, and it is an unknown variable in the determined illuminance expression. The method for determining the installation angle of the target light source provided in this application embodiment can determine the installation angle of the target light source. Since the installation angle of the light source refers to the angle between the tilt direction of the first light source and the second light source and the vertical direction, and the first light source and the second light source are symmetrical about the vertical plane, the installation angles of the target light source of the first light source and the second light source are the same.

[0040] Figure 2 This diagram illustrates the installation of a light source according to an exemplary embodiment of this application, including a first light source 201, a second light source 202, and a stage 203. The first light source 201 and the second light source 202 are installed at a height of h, and have the same dimensions. The first light source 201 and the second light source 202 are symmetrical about a vertical plane 205. A target area 204 is located in the stage 203, which is used to place the object to be measured. Multiple sampling points are uniformly distributed within the target area. The illumination distance of the first light source to the first sampling point 206 in the stage is a straight-line distance d. The light source installation angle is the angle θ between the tilt direction of the first and second light sources and the vertical direction.

[0041] The first and second light sources illuminate the sampling points in the target area. Each light source emits light to different sampling points, and the illuminance of the sampling point is the sum of the illuminance of the different light sources to that sampling point.

[0042] Step 102: Based on the illuminance of each sampling point in the target area, determine the illuminance variance between the illuminance of each sampling point in the target area and the illuminance of the center point in the target area.

[0043] After determining the illuminance at each sampling point within the target area, since the light source has a certain tilt angle, the illuminance at different sampling points may be different. There may be a certain difference between the illuminance at each sampling point and the center point of the target area. Therefore, the illuminance variance between each sampling point and the center point of the target area can be determined.

[0044] In this embodiment of the application, it is assumed that the object is usually placed at the center of the area jointly illuminated by the two light sources. The target area is also set at the center of the area jointly illuminated. That is, it is assumed that the object is placed near the center point of the target area. Therefore, the illuminance variance between the illuminance of each sampling point in the target area and the center point of the target area is determined with the center point of the target area as the reference.

[0045] Step 103: Determine the penalty function based on the illuminance of each sampling point in the target area and the illuminance of the center point in the target area.

[0046] The penalty function is used to constrain the maximum illuminance difference between each sampling point within the target area and the center point within the target area.

[0047] The penalty function is a function that imposes penalties. By constructing the penalty function, the constraint of the maximum illuminance difference between each sampling point in the target area and the center point in the target area is transformed into an unconstrained problem when performing annealing algorithm analysis.

[0048] In this embodiment, a penalty function is used to constrain the maximum illuminance difference between each sampling point within the target area and the center point within the target area. Therefore, in machine vision inspection scenarios, it is desirable for the illuminance of each sampling point within the target area to be uniform, meaning the maximum illuminance difference between each sampling point within the target area and the center point within the target area should approach zero. However, it is usually difficult to make the illuminance of each sampling point completely identical. Therefore, a penalty function is used to constrain the maximum illuminance difference as an allowable range for illuminance difference.

[0049] Step 104: Determine the objective function based on the penalty function and the illuminance variance.

[0050] The objective function value is used to indicate the uniformity of illuminance at each sampling point within the target area under different light source installation angles.

[0051] The penalty function is used to constrain the difference between the maximum illuminance within the target area and the illuminance at the center point of the target area. The illuminance variance is used to constrain the difference between the illuminance at all sampling points within the target area and the illuminance at the center point of the target area. Thus, the objective function is determined based on the penalty function and the illuminance variance. Therefore, the objective function value can characterize the uniformity of illuminance at each sampling point within the target area.

[0052] Step 105: Based on the objective function, determine the installation angle of the target light source using the annealing algorithm.

[0053] When using the annealing algorithm, it is first necessary to determine the starting point of the annealing algorithm, that is, to determine the initial angle. It is also necessary to set the range of values ​​for the installation angle, the maximum number of iterations, the tolerance value of the penalty function, the initial temperature, the temperature reduction ratio, and the number of iterations after the optimal angle, etc. The temperature reduction ratio is used to control the convergence speed.

[0054] In the objective function, the light source installation angle is an unknown parameter. An initial angle is randomly determined by the annealing algorithm, and a similar random angle is generated based on this initial angle. By comparing the function values ​​of the initial angle and the random angle, the probability of accepting the random angle as the optimal angle is determined. If the set number of iterations and termination conditions are not reached, the temperature is reduced, and the above process is repeated until the set number of iterations is reached or the termination conditions are met, and the optimal angle is determined as the target light source installation angle.

[0055] In summary, in this embodiment, by using the illuminance of the first and second light sources at each sampling point within the target area of ​​the stage, a penalty function and the illuminance variance between the illuminance at each sampling point within the target area and the illuminance at the center point within the target area are determined. Based on this illuminance variance and the penalty function, a target function is constructed. Then, based on this target function, an annealing algorithm is used to determine the target light source installation angles for the first and second light sources. Constructing the target function based on the illuminance variance and the penalty function allows for more accurate determination of the target light source installation angles. Installing the first and second light sources at these target angles results in more uniform illuminance within the target area of ​​the stage, providing better illumination for the object to be inspected on the stage and improving the effectiveness of machine vision inspection.

[0056] In this embodiment, the penalty function includes a penalty factor, which is used to constrain the difference between the maximum illuminance and the illuminance at the center point within the target area. In this embodiment, the penalty function constrains the maximum illuminance difference between each sampling point within the target area and the center point within the target area. Therefore, in determining the penalty function, it is necessary to determine the penalty function based on the maximum illuminance, the illuminance at the center point within the target area, and the penalty factor. The process of determining the target light source installation angle based on the objective function will be described below through an exemplary embodiment.

[0057] Figure 3 A flowchart illustrating a process for determining the installation angle of a target light source according to an exemplary embodiment of this application is shown. The process includes the following steps:

[0058] Step 301: Based on the illuminance of each sampling point within the target area, determine the maximum illuminance among the illuminances of each sampling point within the target area.

[0059] Since the penalty function is used to constrain the maximum illuminance difference between each sampling point in the target area and the center point in the target area, it is necessary to first determine the maximum value of the illuminance of each sampling point in the target area.

[0060] After determining the illuminance at each sampling point, the maximum illuminance among all sampling points in the target area can be determined by comparing the illuminance at all sampling points.

[0061] Step 302: Determine the penalty function based on the maximum illuminance, the illuminance at the center point within the target area, and the penalty factor.

[0062] The penalty factor is used to constrain the difference between the maximum illuminance and the illuminance at the center point within the target area.

[0063] Optionally, the penalty function is Where φ is a coefficient, a is a penalty factor, E(p, q) is the maximum illuminance, and E(c, b) is the illuminance at the center point. Optionally, the value of a can be 0-0.5.

[0064] Step 303: Determine the objective function based on the penalty function and the illuminance variance.

[0065] Optionally, when the penalty function is M as described in step 302 above, the objective function is S[E(p, q)] + M, where S represents the variance of the illuminance between the sampling point and the center point of the target area.

[0066] Step 304: If the penalty function includes the i-th candidate penalty factor, determine the i-th candidate light source installation angle and the i-th illuminance distribution map corresponding to the i-th candidate penalty factor by using the annealing algorithm based on the objective function.

[0067] The i-th illuminance distribution map is used to characterize the illuminance distribution of the target area under the installation angle of the i-th candidate light source.

[0068] Assuming the penalty function includes m candidate penalty factors, then i is a positive integer less than or equal to m. Different penalty factors in the penalty function determine different optimal installation angles; therefore, the m candidate penalty factors correspond to m candidate light source installation angles.

[0069] The annealing algorithm includes an annealing temperature parameter. In this embodiment, it is assumed that the annealing temperature parameter has n candidate temperature values.

[0070] Step 304A: Given the annealing temperature parameter as the j-th temperature value, determine the j-th objective function value based on the j-th angle.

[0071] When j equals 1, that is, when the annealing temperature parameter is the first temperature value, the first objective function value is determined based on the first angle. The first angle can be a pre-set initial angle value or a random angle value within the angle range.

[0072] Step 304B: Perturb the j-th angle to obtain the z-th angle.

[0073] The j-th angle is perturbed by randomly generating an angle value close to the j-th angle. For example, at the j-th angle, a random angle between [-1, 1] can be generated using the rand function, and this random angle is added to the j-th angle to obtain the new z-th angle.

[0074] Step 304C: Based on the j-th objective function value, the j-th temperature value, and the z-th objective function value corresponding to the z-th angle, determine the i-th candidate light source installation angle from the j-th angle and the z-th angle.

[0075] The z-th angle is input into the objective function, and the objective function value corresponding to the z-th angle is obtained.

[0076] Subsequently, based on the j-th objective function value, the j-th temperature value, and the z-th objective function value, the acceptance probability P for the z-th angle is determined. A decision is then made regarding whether to accept the z-th angle as the i-th candidate light source installation angle with probability P. If accepted, the z-th angle is determined as the i-th candidate light source installation angle; if rejected, the j-th angle is determined as the i-th candidate light source installation angle.

[0077] Step 304D: Switch the annealing temperature parameter to the (j+1)th temperature value, and perturb the installation angle of the i-th candidate light source to obtain the (j+1)th angle. The (j+1)th temperature value is lower than the j-th temperature value.

[0078] After determining the installation angle of the i-th candidate light source, the installation angle of the i-th candidate light source is perturbed again to obtain the (j+1)-th angle that is close to the installation angle of the i-th candidate light source.

[0079] When switching annealing temperatures, the switching can be based on the temperature reduction ratio, which is a preset value. For example, if the j-th temperature value is 100 and the temperature reduction ratio is 0.95, then the (j+1)-th temperature value is 95 degrees.

[0080] Step 304E: Update the installation angle of the i-th candidate light source based on the objective function value corresponding to the installation angle of the i-th candidate light source, the (j+1)-th temperature value, and the (j+1)-th objective function value corresponding to the (j+1)-th angle.

[0081] The computer device inputs the (j+1)th angle into the objective function to obtain the (j+1)th objective function value. Then, based on the objective function value corresponding to the installation angle of the ith candidate light source, the (j+1)th temperature value, and the (j+1)th objective function value, it determines the acceptance probability of the (j+1)th angle, and makes a decision on whether to accept the (j+1)th objective function value. If the (j+1)th angle is accepted, the installation angle of the ith candidate light source is updated to the (j+1)th angle; if the (j+1)th angle is not accepted, the installation angle of the ith candidate light source remains at its original value.

[0082] Step 305: Based on the m illuminance distribution maps corresponding to the m candidate penalty factors, determine the installation angle of the target light source from the installation angles of the m candidate light sources corresponding to the m candidate penalty factors.

[0083] While determining the installation angles of m candidate light sources corresponding to m candidate penalty factors, the computer equipment can also generate m illuminance distribution maps under the installation angles of m candidate light sources based on the illuminance of each sampling point.

[0084] After determining m illuminance distribution maps, it is necessary to select a suitable angle from the m candidate light source installation angles as the target light source installation angle based on the size of the area where the item is placed.

[0085] The computer equipment determines the illuminance difference between the maximum and minimum illuminance within the object placement area under different candidate light source installation angles, based on the size of the object placement area in the target region and the illuminance at each sampling point within the target region indicated by the illuminance distribution map. Subsequently, based on the m illuminance differences corresponding to m illuminance distribution maps, the installation angle of the candidate light source corresponding to the illuminance distribution map with the minimum illuminance difference is determined as the target light source installation angle.

[0086] Figure 4 This illustration shows a schematic diagram of an illuminance distribution map provided in an exemplary embodiment of this application. The two-dimensional illuminance distribution map is a schematic representation of a horizontal cross-section of the three-dimensional illuminance distribution map. The horizontal axis represents the distance from the sampling point in the target area to the edge of the target area, and the vertical axis represents the illuminance. The two-dimensional illuminance distribution map shows the illuminance distribution corresponding to different penalty factors 'a'. It can be seen that if the size of the object placement area is between 20mm and 30mm, the illuminance difference is minimized when the candidate light source installation angle corresponding to a penalty function of 0 is selected as the target light source installation angle. When the object placement area is larger, such as between 17mm and 31mm, the illuminance difference is minimized when the candidate light source installation angle corresponding to a penalty function of 0.1 is selected as the target light source installation angle.

[0087] In this embodiment, the difference between the maximum illuminance within the target area and the illuminance at the center point of the target area is constrained based on a penalty factor. This constrains the uniformity of illuminance at each sampling point within the target area, thereby improving the lighting quality of objects on the stage and enhancing the accuracy of machine vision inspection results. Furthermore, the annealing algorithm can randomly select more angles when determining the installation angle of candidate light sources, i.e., it globally searches for the optimal angle under the penalty factor, making the determined installation angle of candidate light sources more accurate.

[0088] In this embodiment, before determining the installation angle of the target light source, it is necessary to first determine the installation position and size of the first light source, the installation position and size of the second light source, the position and size of the stage, and the size of the target area, etc., to facilitate the determination of the installation height of the first and second light sources relative to the stage, as well as parameters such as the illumination distance and illumination angle of the light source points to different sampling points. In this embodiment, the first and second light sources are symmetrical with respect to the vertical plane, that is, the installation angles of the target light sources for the first and second light sources are the same. After determining the above parameters, the illuminance at different sampling points within the stage can be determined.

[0089] When determining the illuminance at different sampling points, the illuminance at the j-th sampling point of the first light source is first determined based on the illumination distance of the i-th light source point to the j-th sampling point, the installation angle of the first light source, and the illumination angle of the i-th light source point to the j-th sampling point.

[0090] Assume that both the first and second light sources include k light source points, and there are s sampling points in the target area, where i is a positive integer less than or equal to k, and j is a positive integer less than or equal to m.

[0091] Optionally, the computer device determines the first angular difference between the light illuminating the j-th sampling point from the i-th light source point and the optical axis of the i-th light source point based on the illumination angle of the i-th light source point to the j-th sampling point and the installation angle of the light source.

[0092] The optical axis of the i-th light source point is perpendicular to the plane where the first light source is located.

[0093] Please refer to Figure 5 The diagram illustrates an angular difference provided by an exemplary embodiment of this application, wherein the optical axis 503 of the i-th light source point 502 in the first light source 501 is perpendicular to the plane of the first light source, and the first angular difference between the light 504 irradiated by the i-th light source point 502 to the j-th sampling point and the optical axis 503 is β.

[0094] Optionally, the computer device determines the second angle difference between the light illuminating the j-th sampling point from the i-th light source point and the vertical direction, based on the illumination angle of the i-th light source point to the j-th sampling point.

[0095] Please refer to Figure 5 The angle γ between the light ray 504 from the i-th light source point illuminating the j-th sampling point and the vertical direction is the second angle difference.

[0096] Optionally, the computer device determines the illumination distance between the i-th light source point and the j-th sampling point based on the position of the i-th light source point and the position of the j-th sampling point.

[0097] Please refer to Figure 5 , where the Euclidean distance d between the i-th light source point and the j-th sampling point is the illumination distance between the i-th light source point and the j-th sampling point.

[0098] Finally, the computer device determines the illuminance of the i-th light source point on the j-th sampling point based on the first angle difference, the second angle difference, and the illumination distance.

[0099] The illuminance of the i-th light source point to the j-th sampling point in the first light source is E = I × cosγ × cosβ / d 2 , where I is the light intensity of the first light source.

[0100] Simultaneously, it is necessary to determine the illuminance of the i-th light source point to the j-th sampling point based on the illumination distance of the i-th light source point to the j-th sampling point, the installation angle of the second light source, and the illumination angle of the i-th light source point to the j-th sampling point.

[0101] In this embodiment, the method for determining the illuminance of the i-th light source point in the second light source relative to the j-th sampling point can refer to the above-described process for determining the illuminance of the i-th light source point in the first light source relative to the j-th sampling point, and will not be repeated in this embodiment.

[0102] Finally, the illuminance of the first light source and the first light source point to the kth light source point in the second light source are summed to obtain the illuminance of the jth sampling point.

[0103] The illuminance of each sampling point within the target area is the sum of the illuminance of the first light source and all light source points within the second light source relative to the sampling point.

[0104] In this embodiment of the application, virtual sampling points are set in the target area to calculate the illuminance of each sampling point, so as to determine the uniformity of illuminance in the target area based on the illuminance of each sampling point.

[0105] The process of determining the installation angle of the target light source will be illustrated below with an exemplary example.

[0106] Figure 6This diagram illustrates the installation of a light source according to an exemplary embodiment of this application. The first light source 601 and the second light source 602 both have a light-emitting plane size of 300mm × 300mm, θ is the installation angle, and the vertical distance between the bottom of the light source and the stage is 800mm. Both the first light source 601 and the second light source 602 include 16 × 16 light source points, meaning each light source contains 256 evenly distributed light source points. Let i be the row number of the light source point and j be the column number, i.e., M1(i, j) is the light source point in the i-th row and j-th column of the first light source 601, where i and j are both positive integers less than or equal to 15.

[0107] Construct a spatial rectangular coordinate system with the midpoint of one side of the target region as the origin O. Assume the coordinates of M1(i, j) are (X1, Y1, Z1), then:

[0108] X1 = 20 × j

[0109] Y1=-750+i×20×sinθ

[0110] Z1=800+i×20×cosθ

[0111] The first light source 601 and the second light source 602 are symmetrical about the XOZ plane. Assuming that the coordinates of the light source point M2(i, j) in the second light source are (X2, Y2, Z2), then:

[0112] X2 = 20 × j

[0113] Y2=750-i×20×sinθ

[0114] Z2=800+i×20×cosθ

[0115] Assume the target area in stage 603 is a rectangular region with dimensions of 300mm × 1500mm. The sampling points within this region form an 11 × 51 point matrix. M(p, q) represents the sampling point in the p-th row and q-th column within the target region, where p is a positive integer less than or equal to 10, and q is a positive integer less than or equal to 50. Assume the coordinates of M(p, q) are (X... n Y n Z n ),but:

[0116] X n =30×p

[0117] Y n =-750+30×q

[0118] Z n =0

[0119] Since the installation angle of the light source is θ, the normal vector of the plane where the first light source is located is (0, -cosθ, sinθ), the normal vector of the plane where the second light source is located is (0, cosθ, sinθ), and the normal vector of the stage plane is (0, 0, 1).

[0120] If the computer device determines that the angle between the light source point M1(i,j) and the optical axis of the light source point in the first light source is β1, then:

[0121]

[0122] The computer equipment determines that the angle between the ray from the light source point M1(i,j) in the first light source to the sampling point M(p,q) in the target area and the vertical distance (i.e., the normal to the stage plane) is γ1. Then:

[0123]

[0124] The computer equipment determines that the illumination distance from the light source point M1(i,j) in the first light source to the sampling point M(p,q) in the target area is d1. Then:

[0125]

[0126] Similarly, the computer device can determine the angle β2 between the light source point M2(i,j) in the second light source and the optical axis of the light source point, the angle γ2 between the light ray from the light source point M2(i,j) in the second light source to the sampling point M(p,q) in the target area and the vertical distance (i.e., the normal to the stage plane), and determine the illumination distance d2 from the light source point M2(i,j) in the second light source to the sampling point M(p,q) in the target area.

[0127] Then the illuminance at sampling point M(p, q) within the target area can be determined as:

[0128]

[0129] Where I represents the light intensity of the first and second light sources.

[0130] The computer equipment can determine the illuminance variance between each illuminance point and the center point within the target area as follows:

[0131]

[0132] Where E is the average illuminance at each point within the target area.

[0133] Based on the illuminance at each sampling point within the target area and the illuminance at the center point within the target area, the computer device determines the penalty function as follows:

[0134]

[0135] Where E(6, 26) are the coordinates of the center of the target region, and M is the function value of the penalty function. is a coefficient, MAX(E(p,q)) is the maximum illuminance of each sampling point in the target area, and a is a penalty factor.

[0136] Then the objective function can be determined as S[E(p, q)] + M.

[0137] The computer equipment then uses an annealing algorithm to determine the installation angle of the target light source.

[0138] For example, the installation angle of the candidate light source and the illuminance variance corresponding to different candidate penalty factors obtained by the annealing algorithm are shown in Table 1.

[0139] Table 1

[0140] Candidate light source installation angle 26.64° 30.71° 32.14° 33.36° 35.37° Illuminance variance 33.11 31.61 31.41 30.62 29.83

[0141] Optionally, when the computer determines the installation angle of the target light source through the annealing algorithm, it can set various parameters of the annealing algorithm, such as the initial temperature value, the temperature reduction rate, and the number of iterations. Figure 7 This diagram illustrates a parameter setting interface for an annealing algorithm provided in an exemplary embodiment of this application. The interface allows setting parameters such as the initial temperature, cooling rate, initial angle, angle range, maximum number of iterations, and function tolerance. In the diagram, the initial temperature is set to 100, the cooling rate to 0.95, the initial angle to 0.2π, the angle range to 0-0.5π, the maximum number of iterations to 200, and the function tolerance to 0.5.

[0142] Furthermore, in this embodiment, by continuously changing the value of the penalty factor in the penalty function, different candidate installation angles corresponding to different penalty factors are obtained, and then the target light source installation angle is selected by the computer device based on the size of the object placement area.

[0143] The following are embodiments of the apparatus described in this application, which can be used to execute the embodiments of the method described in this application. For details not disclosed in the apparatus embodiments of this application, please refer to the embodiments of the method described in this application.

[0144] Please refer to Figure 8 The diagram illustrates a structural block diagram of a device for determining the installation angle of a light source according to an embodiment of this application. This device may include:

[0145] The first determining module 801 is used to determine the illuminance of each sampling point in the target area of ​​the stage based on the illumination distance between the first light source and the second light source and each sampling point in the stage, and the installation angle of the first light source and the second light source. The first light source and the second light source are symmetrical about the vertical plane, the stage is horizontally set, and the first light source and the second light source emit light towards the stage. The installation angle of the light source refers to the angle between the tilt direction of the first light source and the second light source and the vertical direction.

[0146] The second determining module 802 is used to determine the illuminance variance between the illuminance of each sampling point in the target area and the illuminance of the center point in the target area, based on the illuminance of each sampling point in the target area.

[0147] The third determining module 803 is used to determine a penalty function based on the illuminance of each sampling point in the target area and the illuminance of the center point in the target area. The penalty function is used to constrain the maximum illuminance difference between each sampling point in the target area and the center point in the target area.

[0148] The fourth determining module 804 is used to determine a target function based on the penalty function and the illuminance variance. The target function value is used to indicate the uniformity of illuminance at each sampling point in the target area under different light source installation angles.

[0149] The fifth determining module 805 is used to determine the installation angle of the target light source based on the objective function using an annealing algorithm.

[0150] Optionally, the penalty function may include a penalty factor.

[0151] The third determining module 803 is used to determine the maximum illuminance among the illuminances of each sampling point in the target area based on the illuminance of each sampling point in the target area; and to determine the penalty function based on the maximum illuminance, the illuminance of the center point in the target area, and the penalty factor, wherein the penalty factor is used to constrain the difference between the maximum illuminance and the illuminance of the center point in the target area.

[0152] Optionally, there are m candidate penalty factors, where m is an integer greater than 1;

[0153] The fifth determining module 805 is used for:

[0154] When the penalty function includes the i-th candidate penalty factor, based on the objective function, the annealing algorithm is used to determine the i-th candidate light source installation angle and the i-th illuminance distribution map corresponding to the i-th candidate penalty factor, wherein the i-th illuminance distribution map is used to characterize the illuminance distribution of the target area under the i-th candidate light source installation angle;

[0155] Based on m illuminance distribution maps corresponding to m candidate penalty factors, the installation angle of the target light source is determined from the m candidate light source installation angles corresponding to the m candidate penalty factors.

[0156] Optionally, the fifth determining module 805 is used for:

[0157] Based on the size of the object placement area in the target area and the illuminance of each sampling point in the target area indicated by the illuminance distribution map, the illuminance difference between the maximum and minimum illuminance in the object placement area under different candidate light source installation angles is determined.

[0158] Based on the m illuminance distribution maps corresponding to the m illuminance differences, the installation angle of the candidate light source corresponding to the illuminance distribution map with the smallest illuminance difference is determined as the installation angle of the target light source.

[0159] Optionally, the annealing algorithm includes an annealing temperature parameter, which has n candidate temperature values;

[0160] The fifth determining module 805 is used for:

[0161] Given that the annealing temperature parameter is the j-th temperature value, the j-th objective function value is determined based on the j-th angle;

[0162] The j-th angle is perturbed to obtain the z-th angle;

[0163] Based on the j-th objective function value, the j-th temperature value, and the z-th objective function value corresponding to the z-th angle, the i-th candidate light source installation angle is determined from the j-th angle and the z-th angle;

[0164] Switch the annealing temperature parameter to the (j+1)th temperature value, and perturb the installation angle of the i-th candidate light source to obtain the (j+1)th angle, wherein the (j+1)th temperature value is lower than the j-th temperature value;

[0165] The installation angle of the i-th candidate light source is updated based on the objective function value corresponding to the installation angle of the i-th candidate light source, the (j+1)-th temperature value, and the (j+1)-th objective function value corresponding to the (j+1)-th angle.

[0166] Optionally, both the first light source and the second light source include k light source points, and there are s sampling points within the target area;

[0167] The first determining module 801 is used for:

[0168] Based on the illumination distance of the i-th light source point to the j-th sampling point in the first light source, the light source installation angle of the first light source, and the illumination angle of the i-th light source point to the j-th sampling point in the first light source, the illuminance of the i-th light source point to the j-th sampling point in the first light source is determined, where i is a positive integer less than or equal to k, and j is a positive integer less than or equal to m.

[0169] Based on the illumination distance of the i-th light source point in the second light source to the j-th sampling point, the installation angle of the second light source, and the illumination angle of the i-th light source point in the second light source to the j-th sampling point, the illuminance of the i-th light source point in the second light source to the j-th sampling point is determined;

[0170] The illuminance of the first light source and the first light source point to the kth light source point of the second light source at the jth sampling point is summed to obtain the illuminance of the jth sampling point.

[0171] Optionally, the first determining module 801 is used for:

[0172] Based on the illumination angle of the i-th light source point to the j-th sampling point and the installation angle of the light source, a first angular difference between the light ray from the i-th light source point to the j-th sampling point and the optical axis of the i-th light source point is determined, wherein the optical axis of the i-th light source point is perpendicular to the plane where the first light source is located.

[0173] Based on the illumination angle of the i-th light source point to the j-th sampling point, determine the second angle difference between the light ray from the i-th light source point to the j-th sampling point and the vertical direction;

[0174] Based on the position of the i-th light source point and the position of the j-th sampling point, the illumination distance between the i-th light source point and the j-th sampling point is determined;

[0175] Based on the first angle difference, the second angle difference, and the illumination distance, the illuminance of the i-th light source point on the j-th sampling point is determined.

[0176] In summary, in this embodiment, by using the illuminance of the first and second light sources at each sampling point within the target area of ​​the stage, a penalty function and the illuminance variance between the illuminance at each sampling point within the target area and the illuminance at the center point within the target area are determined. Based on this illuminance variance and the penalty function, a target function is constructed. Then, based on this target function, an annealing algorithm is used to determine the target light source installation angles for the first and second light sources. Constructing the target function based on the illuminance variance and the penalty function allows for more accurate determination of the target light source installation angles. Installing the first and second light sources at these target angles results in more uniform illuminance within the target area of ​​the stage, providing better illumination for the object to be inspected on the stage and improving the effectiveness of machine vision inspection.

[0177] Figure 9 This illustration shows a structural block diagram of a computer device 900 provided in an exemplary embodiment of this application. The computer device 900 may be a smartphone, tablet computer, MP3 player (Moving Picture Experts Group Audio Layer III), MP4 player (Moving Picture Experts Group Audio Layer IV), laptop computer, or desktop computer. The computer device 900 may also be referred to as user equipment, portable terminal, laptop terminal, desktop terminal, or other names.

[0178] Typically, computer device 900 includes a processor 901 and a memory 902.

[0179] Processor 901 may include one or more processing cores, such as a quad-core processor or an octa-core processor. Processor 901 may be implemented using at least one hardware form selected from DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). Processor 901 may also include a main processor and a coprocessor. The main processor, also known as a CPU (Central Processing Unit), is used to process data in the wake-up state; the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, processor 901 may integrate a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the screen. In some embodiments, processor 901 may also include an AI (Artificial Intelligence) processor, which is used to handle computational operations related to machine learning.

[0180] The memory 902 may include one or more computer-readable storage media, which may be non-transitory. The memory 902 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices or flash memory devices. In some embodiments, the non-transitory computer-readable storage media in the memory 902 is used to store at least one instruction, which is executed by the processor 901 to implement the method for determining the light source installation angle provided in the method embodiments of this application.

[0181] In some embodiments, the computer device 900 also includes other components, as those skilled in the art will understand. Figure 9 The structure shown does not constitute a limitation on the computer device 900, and may include more or fewer components than shown, or combine certain components, or use different component arrangements.

[0182] Optionally, the computer-readable storage medium may include: read-only memory (ROM), random access memory (RAM), solid-state drives (SSDs), or optical discs, etc. The random access memory may include resistive random access memory (ReRAM) and dynamic random access memory (DRAM). The sequence numbers of the embodiments in this application are merely descriptive and do not represent the superiority or inferiority of the embodiments.

[0183] This application also provides a computer device, which includes a processor and a memory. The memory stores at least one instruction, at least one program, a code set, or an instruction set. The at least one instruction, the at least one program, the code set, or the instruction set is loaded and executed by the processor to implement the method for determining the installation angle of the light source as described in any of the above embodiments of this application.

[0184] This application also provides a computer-readable storage medium storing at least one instruction, at least one program, code set, or instruction set, wherein the at least one instruction, the at least one program, the code set, or the instruction set is loaded and executed by a processor to implement the method for determining the installation angle of the light source as described in any of the above embodiments of this application.

[0185] This application also provides a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the method for determining the light source installation angle described in any of the above embodiments.

[0186] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware or by a program instructing related hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.

[0187] The above description is merely an optional embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.

Claims

1. A method for determining the installation angle of a light source, characterized in that, The method includes: Based on the illumination distance between the first light source, the second light source and each sampling point in the stage, and the installation angle of the first light source and the second light source, the illuminance of each sampling point in the target area in the stage is determined, wherein the first light source and the second light source are symmetrical about the vertical plane; Determine the illuminance variance between each sampling point within the target area and the center point within the target area; Determine the maximum illuminance among the illuminance values ​​at each sampling point within the target area; Based on the maximum illuminance, the illuminance at the center point, and the penalty factor, a penalty function is determined. The penalty factor is used to constrain the difference between the maximum illuminance and the illuminance at the center point, and the penalty function is used to constrain the maximum illuminance difference between each sampling point and the center point. The objective function is determined based on the penalty function and the illuminance variance. The objective function value is used to indicate the uniformity of illuminance at each sampling point in the target area under different light source installation angles. When the penalty function includes the i-th candidate penalty factor, based on the objective function, the installation angle of the i-th candidate light source is determined by the annealing algorithm, and the illuminance distribution map corresponding to the i-th candidate penalty factor is determined. Based on m illuminance distribution maps corresponding to m candidate penalty factors, the installation angle of the target light source is determined from the m candidate light source installation angles corresponding to the m candidate penalty factors, where m is an integer greater than 1 and i is less than or equal to m.

2. The method according to claim 1, characterized in that, The determination of the target light source installation angle from the m candidate light source installation angles corresponding to the m candidate penalty factors, based on the m illuminance distribution maps corresponding to the m candidate penalty factors, includes: Based on the size of the object placement area in the target area and the illuminance of each sampling point in the target area indicated by the illuminance distribution map, the illuminance difference between the maximum and minimum illuminance in the object placement area under different candidate light source installation angles is determined. Based on the m illuminance distribution maps corresponding to the m illuminance differences, the installation angle of the candidate light source corresponding to the illuminance distribution map with the smallest illuminance difference is determined as the installation angle of the target light source.

3. The method according to claim 1, characterized in that, The annealing algorithm includes an annealing temperature parameter, which has n candidate temperature values; When the penalty function includes the i-th candidate penalty factor, the installation angle of the i-th candidate light source is determined based on the objective function using an annealing algorithm, including: Given that the annealing temperature parameter is a temperature value of t, the objective function value of the objective function is determined based on the angle of t. The z-th angle is obtained by perturbing the t-th angle; Based on the t-th objective function value, the t-th temperature value, and the z-th objective function value corresponding to the z-th angle, the installation angle of the i-th candidate light source is determined from the t-th angle and the z-th angle; Switch the annealing temperature parameter to the (t+1)th temperature value, and perturb the installation angle of the i-th candidate light source to obtain the (t+1)th angle, wherein the (t+1)th temperature value is lower than the t-th temperature value; The installation angle of the i-th candidate light source is updated based on the objective function value corresponding to the installation angle of the i-th candidate light source, the temperature value at t+1, and the objective function value corresponding to the angle at t+1.

4. The method according to claim 1, characterized in that, Both the first light source and the second light source include k light source points, and there are s sampling points within the target area; The determination of the illuminance of each sampling point within the target area of ​​the stage based on the illumination distances between the first and second light sources and each sampling point in the stage, and the installation angles of the first and second light sources, includes: Based on the illumination distance of the i-th light source point to the j-th sampling point in the first light source, the light source installation angle of the first light source, and the illumination angle of the i-th light source point to the j-th sampling point in the first light source, the illuminance of the i-th light source point to the j-th sampling point in the first light source is determined, where i is a positive integer less than or equal to k, and j is a positive integer less than or equal to s. Based on the illumination distance of the i-th light source point in the second light source to the j-th sampling point, the installation angle of the second light source, and the illumination angle of the i-th light source point in the second light source to the j-th sampling point, the illuminance of the i-th light source point in the second light source to the j-th sampling point is determined; The illuminance of the j-th sampling point is obtained by summing the illuminance of the first light source and the k-th light source points of the second light source relative to the j-th sampling point.

5. The method according to claim 4, characterized in that, The determination of the illuminance of the i-th light source point on the j-th sampling point based on the illumination distance of the i-th light source point to the j-th sampling point, the installation angle of the first light source, and the illumination angle of the i-th light source point to the j-th sampling point includes: Based on the illumination angle of the i-th light source point to the j-th sampling point and the installation angle of the light source, a first angular difference between the light ray from the i-th light source point to the j-th sampling point and the optical axis of the i-th light source point is determined, wherein the optical axis of the i-th light source point is perpendicular to the plane where the first light source is located. Based on the illumination angle of the i-th light source point to the j-th sampling point, determine the second angle difference between the light ray from the i-th light source point to the j-th sampling point and the vertical direction; Based on the position of the i-th light source point and the position of the j-th sampling point, the illumination distance between the i-th light source point and the j-th sampling point is determined; Based on the first angle difference, the second angle difference, and the illumination distance, the illuminance of the i-th light source point on the j-th sampling point is determined.

6. A device for determining the installation angle of a light source, characterized in that, The device includes: The first determining module is used to determine the illuminance of each sampling point in the target area of ​​the stage based on the illumination distance between the first light source, the second light source and each sampling point in the stage, and the installation angle of the first light source and the second light source, wherein the first light source and the second light source are symmetrical about the vertical plane; The second determining module is used to determine the illuminance variance between each sampling point in the target area and the center point in the target area; The third determining module is used to determine the maximum illuminance among the illuminances of each sampling point in the target area; and to determine a penalty function based on the maximum illuminance, the illuminance of the center point, and a penalty factor, wherein the penalty factor is used to constrain the difference between the maximum illuminance and the illuminance of the center point in the target area, and the penalty function is used to constrain the maximum illuminance difference between each sampling point and the center point. The fourth determining module is used to determine the target function based on the penalty function and the illuminance variance. The target function value is used to indicate the uniformity of illuminance at each sampling point in the target area under different light source installation angles. The fifth determining module is used to determine the installation angle of the i-th candidate light source based on the objective function by using an annealing algorithm when the penalty function includes the i-th candidate penalty factor, and to determine the i-th illuminance distribution map corresponding to the i-th candidate penalty factor; and to determine the target light source installation angle from the m candidate light source installation angles corresponding to the m candidate penalty factors based on the m illuminance distribution maps corresponding to the m candidate penalty factors, where m is an integer greater than 1 and i is less than or equal to m.

7. A computer device, characterized in that, The computer device includes a processor and a memory; the memory stores at least one instruction, which is executed by the processor to implement the method for determining the installation angle of the light source as described in any one of claims 1 to 5.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores at least one piece of program code, which is loaded and executed by a processor to implement the method for determining the installation angle of the light source as described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Method, device, equipment and storage medium for determining illumination parameter

    CN109214350A

  • Diffuse reflection light source system for visual inspection and design method

    CN110596122A