METHOD OF AUTOMATICALLY SETTING OPTICAL PARAMETERS AND AUTOMATED OPTICAL INSPECTION SYSTEM USING THE SAME

20220373468 · 2022-11-24

Assignee

Inventors

Cpc classification

International classification

Abstract

A method of automatically setting optical parameters, using Automatic Optical Inspection (AOI) System, the method includes: obtaining a recommended object image when the AOI system under a first recommended optical parameter set; performing computation on a standard image of a and a recommended image of the to-be-measured object according to an optimized error function to obtain a recommended error value between the standard image and the recommended image; determining whether the recommended error value converges, when determining that the recommended error value does not converge, performing computation according to the recommended error value and first recommended optical parameter set to obtain a second recommended optical parameter set; when the recommended error value converges, deciding the first recommended optical parameter set as the best optical parameter set of the AOI system.

Claims

1. A method for automatically setting optical parameters, suitable for an automatic optical inspection (Automated Optical Inspection, AOI) system, the AOI system comprises a camera module, an error calculation module, an automatic setting module and an optical parameter recommendation module, the method comprises: photographing, by the camera module, a to-be-inspected object to obtain a recommended object image under the AOI system being set with a first recommended optical parameter set; calculating, by the error calculation module, a recommended error value between an object standard picture and the recommended object image according to an optimized error function; determining, by the error calculation module, whether the recommended error value converges; when the recommended error value is determined not converged, calculating, by the optical parameter recommendation module, a second recommended optical parameter set according to the recommended error value and the first recommended optical parameter set , and setting, by the automatic setting module, the AOI system according to the second recommended optical parameter set; and when the recommended error value is determined converged, using, by the error calculation module, the first recommended optical parameter set as an optimal optical parameter set.

2. The method according to claim 1, further comprises: photographing, by the camera module, the to-be-inspected object to obtain a plurality of initial object images respectively under the AOI system being set with a plurality of initial optical parameter sets; calculating, by the error calculation module, a plurality of initial error values between the object standard picture and the initial object images according to the optimized error function; and obtaining, by the optical parameter recommendation module, the first recommended optical parameter set according to the initial error values and the initial optical parameter sets.

3. The method according to claim 2, further comprises: obtaining, by the optical parameter recommendation module, the second recommended optical parameter set according to the initial error values and the initial optical parameter sets when the recommended error value has not converged.

4. The method according to claim 2, further comprises: calculating, by the optical parameter recommendation module, a plurality of expected values of a plurality of candidate optical parameter sets with respect to the initial optical parameter sets respectively; and using, by the optical parameter recommendation module, the candidate optical parameter set corresponding to the maximum one of the expected values as the first recommended optical parameter set.

5. The method according to claim 4, wherein step of calculating the expected values of the candidate optical parameter sets with respect to the initial optical parameter sets further comprises: calculating, by the optical parameter recommendation module, a plurality of differences between each candidate optical parameter set and each initial optical parameter set; and calculating, by the optical parameter recommendation module, the expected values according to the differences and the initial error values.

6. The method according to claim 1, wherein the AOI system further comprises a light source module, the method further comprises: setting, by the automatic setting module, the camera module and/or the light source module according to the optimal optical parameter set.

7. The method according to claim 1, wherein the AOI system further comprises an optimization module, and the method further comprises: calculating, by the optimization module, on a training standard picture, an expert standard image, and a non-expert standard image to obtain the optimized error function.

8. The method according to claim 7, further comprises: obtaining, by the optimization module, a plurality of optimization weights of the optimized error function by minimizing a between the training standard picture and the expert standard image and not minimizing an error between the training standard picture and the non-expert standard image.

9. An automatic optical inspection (Automated Optical Inspection, AOI) system, comprises: a camera module, configured to photograph a to-be-inspected object to obtain a recommended object image under the AOI system being set with a first recommended optical parameter set; an error calculation module, configured to calculate a recommended error value between an object standard picture and the recommended object image according to an optimized error function and determine whether the recommended error value converges; an optical parameter recommendation module, configured to calculate a second recommended optical parameter set according to the recommended error value and the first recommended optical parameter set when the recommended error value has not converged; and an automatic setting module, configured to set the AOI system according to the second recommended optical parameter set; wherein the error calculation module is further configured to use the first recommended optical parameter set as an optimal optical parameter set when the recommended error value has converged.

10. The AOI system according to claim 9, wherein the camera module is further configured to photograph the to-be-inspected object to obtain a plurality of initial object images respectively under the AOI system being set with a plurality of initial optical parameter sets; the error calculation module is further configured to calculate on the object standard picture and the initial object images according to the optimized error function to obtain a plurality of initial error values between the initial object images and the object standard picture; and the optical parameter recommendation module is further configured to obtain the first recommended optical parameter set according to the initial error values and the initial optical parameter sets.

11. The AOI system according to claim 10, wherein the optical parameter recommendation module is further configured to obtain the second recommended optical parameter set according to the initial error values and the initial optical parameter sets when the recommended error value has not converged.

12. The AOI system according to claim 10, wherein the optical parameter recommendation module is further configured to: calculate a plurality of expected values of a plurality of candidate optical parameter sets with respect to the initial optical parameter sets respectively; and use the candidate optical parameter set corresponding to the maximum one of the expected values as the first recommended optical parameter set.

13. The AOI system according to claim 12, wherein the optical parameter recommendation module is further configured to: calculate a plurality of differences between each candidate optical parameter set and each initial optical parameter set; and calculate the expected values according to the differences and the initial error values.

14. The AOI system according to claim 9, further comprises a light source module, the automatic setting module is further configured to set the camera module and/or the light source module according to the optimal optical parameter set.

15. The AOI system according to claim 9, further comprises: an optimization module, is configured to calculate on a training standard picture, an expert standard image, and a non-expert standard image to obtain the optimized error function.

16. The AOI system according to claim 15, wherein the optimization module is further configured to: obtain a plurality of optimization weights of the optimized error function by minimizing an error between the training standard picture and the expert standard image and not minimizing an error between the training standard picture and the non-expert standard image, to obtain.

Description

BRIEF DESCRIPTION OF THE DRAWINGS

[0007] FIG. 1 shows a schematic diagram of an Automated Optical Inspection (AOI) system according to an embodiment of the present disclosure;

[0008] FIGS. 2A and 2B show a flowchart of a method of the AOI system of FIG. 1 for automatically setting an automatic optical parameter; and

[0009] FIGS. 3A(a) to 3H(b) show the process of obtaining a recommended optical parameters group of FIGS. 2A and 2B.

[0010] In the following detailed description, for purposes of explanation, numerous specific details are set forth in order to provide a thorough understanding of the disclosed embodiments. It will be apparent, however, that one or more embodiments may be practiced without these specific details. In other instances, well-known structures and devices are schematically shown in order to simplify the drawing.

DETAILED DESCRIPTION

[0011] Referring to FIGS. 1 to 2 and 3A(a) to 3H(b), FIG. 1 shows a schematic diagram of an Automated Optical Inspection (AOI) system 100 according to an embodiment of the present disclosure, FIGS. 2A and 2B show a flowchart of a method of the AOI system 100 of FIG. 1 for automatically setting an automatic optical parameter, and FIGS. 3A(a) to 3H(b) show the process of obtaining a recommended optical parameter group PR.sub.n of FIGS. 2A and 2B.

[0012] As shown in FIG. 1, the AOI system 100 includes an optimization module 110, an error calculation module 120, an optical parameter recommendation module 130, a camera module 140, an automatic setting module 150 and a light source module 160. The camera module 140 is, for example, an optical camera or a linear optical scanner. The light source module 160 includes, for example, at least one light source (not shown). At least one of the optimization module 110, the error calculation module 120, the optical parameter recommendation module 130 and the automatic setting module 150 is, for example, a physical circuit (circuit) formed by at least one semiconductor manufacturing process, or formed by a firmware in an operation processor. In addition, at least one of the optimization module 110, the error calculation module 120, the optical parameter recommendation module 130, and the automatic setting module 150 could be integrated into ingle module, or integrated into a controller (not shown) or operation processor (not shown).

[0013] As shown in FIG. 1, under the AOI system 100 being set by the recommended optical parameter set PR.sub.n (for example, the first recommended optical parameter set PR.sub.1 in FIG. 3B), the camera module 140 photograph a to-be tested object to obtain a recommended object image MR.sub.n. The error calculation module 120 is configured to calculate a recommended error value ER.sub.n between the object standard picture F2 and the recommended object image MR.sub.n according to the optimized error function EF. Then, the error calculation module 120 determines whether the recommended error value ER.sub.n has converged. When the recommended error value ER.sub.n has converged, the error calculation module 120 determines that the recommended optical parameter set PR.sub.n (for example, the first recommended optical parameter set PR.sub.1 in FIG. 3B) is the optimal optical parameter set of the AOI system 100. When the recommended error value ER.sub.n has not converged, the optical parameter recommendation module 130 is configured to calculate the recommended error value ER.sub.n and the first recommended optical parameter set PR.sub.1 to obtain another recommended optical parameter set PR.sub.n+1 (for example, the second recommended optical parameter set PR.sub.2 in FIG. 3E). As a result, the AOI system 100 could automatically obtain the optimal optical parameter set, thereby improving the conventional manual dimming problem.

[0014] The “optical parameter set” herein includes, for example, at least one optical parameter type, such as P parameter types, wherein the x.sup.(1) custom-character x.sup.(2) custom-character x.sup.(3) . . . x.sup.(P) respectively represent different optical parameter types, such as light source parameter(s) of the light source module 160 and/or the camera parameter(s) of the camera module 140, wherein the light source parameters are optical parameter types such as color temperature, brightness, illuminating angle, illuminating time and/or illuminating angle of the illuminating light, etc., and the camera parameters are optical parameter types such as the exposure time of the camera module 140, etc. P represents the number of the optical parameter types, and the embodiment of the disclosure does not limit the maximum value of P. In the present embodiment, the number of the optical parameter types is two, for example, x.sup.(1) and x.sup.(2), which are the exposure time of the camera module 140 and the illuminating time of the light source module 160 respectively. The illuminating mode of the light source module 160 could be set by the automatic setting module 150 according to the relevant optical parameter type of the recommended optical parameter set PR.sub.n, and the camera mode of the camera module 140 could be set by the automatic setting module 150 according to the relevant optical parameter type of the recommended optical parameter set PR.sub.n. The light source module 160 provides the to-be-inspected object (not shown) with the illuminating light, and the camera module 140 photographs the to-be-inspected object to obtain the recommended object image of the to-be-inspected object. The aforementioned “to-be-inspected object” is, for example, any product that could be inspected online (for example, defect inspection, detection of product type, etc.) through the AOI system, such as semiconductor chips, circuit boards, etc. However, the present disclosure does not limit the type of the test object.

[0015] The description of the method of the AOI system 100 for automatically setting the optical parameter in the present embodiment of the present disclosure is described with the flowcharts in FIGS. 2A and 2B.

[0016] In step S110, the optimized error function EF is obtained. The optimized error function EF of the embodiment is obtained by calculation by the optimization module 110 (as shown in FIG. 1). However, in other embodiments, the optimized error function EF could be obtained in advance by performing offline calculations, and thus the AOI system could not include (or omit) the optimization module.

[0017] In step S110, the optimization module 110 calculates the training standard picture F1 (shown in FIG. 1), at least one expert standard image M11.sub.s (shown in FIG. 1) and at least one non-expert standard image M12.sub.t (shown in FIG. 1) to obtain the optimized error function EF, wherein S is a positive integer equal to or greater than 1, and the maximum value of S depends on the total number of the expert standard image M11.sub.s; however, such exemplification is not meant to be for limiting. In addition, t is a positive integer equal to or greater than 1, and the maximum value of t depends on the total number of non-expert standard image M12.sub.t; however, such exemplification is not meant to be for limiting. The number of the training standard pictures F1 is, for example, one, and the number of the expert standard images M11.sub.s could be at least one. Each expert could select one image that is closest (for example, it could be the closest in terms of various color information such as color temperature and brightness) to the training standard picture F1 from several images, and the image selected by each expert is defined as “expert standard image”, and the unselected images are defined as “non-expert standard image(s)”. The present embodiment of the disclosure does not limit the number of expert standard images M11.sub.s and the number of non-expert standard images M12.sub.t. As shown in FIG. 1, the training standard picture F1, the expert standard image M11.sub.s and the non-expert standard image M12.sub.t could be stored in a first database D1, and the object standard picture F2 could be stored in a second database D2. At least one of the first database D1 and the second database D2 could belong to the AOI system 100, but the embodiment of the disclosure is not limited thereto.

[0018] In an embodiment, the optimization module 110 obtains the optimization weight Λ of the optimized error function EF by minimizing the error between the training standard picture F1 and the expert standard image M11.sub.s and maximizing (or non-minimizing) the error between the training standard picture F1 and the non-expert standard image M12.sub.t. For example, the optimization module 110 sets a target error TE1 (as shown in the following formula (1)) between the training standard picture F1 and the expert standard image M11.sub.s to 0 and sets a target error TE2 (as shown in the following formula (2)) between the training standard picture F1 and the non-expert standard image M12.sub.t to 1, to obtain the optimization weight Λ (as shown in the following formula (3)) of the optimized error function EF. The error calculation function f of formulas (1) and (2) could use various error analysis techniques or mathematical methods to perform error analysis on the vectors in the error calculation function f, such as calculation of the weighted Euclidean distance or calculation of Mahalanobis distance; however, such exemplification is not meant to be for limiting.

[00001] f ( V 1 , U 1 s | Λ ) = TE 1 ( 1 ) f ( V 1 , W 1 t | Λ ) = TE 2 ( 2 ) e = .Math. s ( f ( V 1 , U 1 s | Λ ) ) 2 + .Math. t ( 1 - f ( V 1 , W 1 t | Λ ) ) 2 ( 3 ) Λ _ = argmin Λ .Math. s ( f ( V 1 , U 1 s | Λ ) ) 2 + .Math. t ( 1 - f ( V 1 , W 1 t | Λ ) ) 2 ( 4 )

[0019] In formula (1), the vector V1 is, for example, pixel-level characteristic vector of the training standard picture F1, and the vector U1.sub.s is, for example, pixel-level characteristic vector of the S.sup.th expert standard image M11.sub.s . In formula (2), the vector W1.sub.t is, for example, pixel-level characteristic vector of the t.sup.th non-expert standard image M12.sub.t. In formula (3), e is the total error value, and the optimization weight Λ is obtained under the sum of the error value of all expert standard images and the error value of all non-expert standard images is 0 or close to 0. In formula (4), the optimization module 110 could optimize the optimization weight Λ by using the mathematical method of argmin. For example, the optimization module 110 could determine the optimization weight Λ corresponding to the smallest total error value e as optimal optimization weight Λ . The optimal optimization weight Λ is, for example, a matrix including at least one constant or multiple constants. In the present embodiment, the vector V1, the vector U1.sub.s and the vector W1.sub.t are pixel-level characteristic vectors, such as RGB or HSV (Hue, Saturation, Lightness), but in other embodiments, the vector V1, the vector U1.sub.s and the vector W1.sub.t could be the image-level characteristic vectors, for example, the characteristic vectors extracted from deep learning models.

[0020] After the optimal optimization weight Λ is obtained, the optimized error function EF could be created according to the optimal optimization weight Λ, as shown in the following formula (5). In formula (5), the vector V2 is the pixel-level characteristic vector of the standard picture (for example, the object standard picture), and the vector U2 is the pixel-level characteristic vector of the object image (for example, the initial object image and/or the recommended object image). In the present embodiment, the vectors V2 and U2 are the pixel-level characteristic vectors, for example, RGB or HSV (Hue, Saturation, Lightness). However, in other embodiments, the vectors V2 and U2 could also be the image-level characteristic vectors, for example, the characteristic vectors extracted by the deep learning model.

[0021] After substituting the vectors V2 and U2 into the formula (5), the error value (for example, the initial error value and/or the recommended error value) between the vectors V2 and U2 is obtained (or calculated) according to the optimized error function EF, wherein the error value represents the difference between the object image and the standard picture F2. The smaller the error value is, the smaller (for example, the closer the image is in color information) the difference between the vectors V2 and U2 is. On the contrary, the greater the error value is, the greater the difference between the vectors V2 and U2 is.


EF(V2, U2|Λ)=ET.sub.mcustom-characterER.sub.n . . . (

[0022] After the optimized error function EF is obtained, steps S120 to S190 could be performed to determine the optical parameter set for automatic setting the optical parameters. For clarity, the steps S120 to S190 of the method for automatically setting the optical parameter in the present embodiment are used to determine the optical parameter set, wherein the optical parameter set includes two optical parameter types, for example, x.sup.(1) and x.sup.(2). In an embodiment, in the steps of determining the optical parameter set (for example, steps S120 to S190), the x.sup.(2) (for example, the axis of abscissa of the coordinates in FIGS. 3A(a) to 3H(b)) is determined in the case of x.sup.(1) being a fixed value. In another embodiment, in the steps of determining the optical parameter set (for example, steps S120 to S190), the x.sup.(1) and x.sup.(2) are determined in the case of x.sup.(1) and x.sup.(2) being variable. In other embodiments, the optical parameter set could include P optical parameter types x.sup.(1) custom-character x.sup.(2) custom-character x.sup.(3) . . . x.sup.(P), and the steps for determining the optical parameter set is performed under the case that at least one of x.sup.(1) custom-character x.sup.(2) custom-character x.sup.(3) . . . x.sup.(P) is variable.

[0023] In step S120, the AOI system 100 could calculate the object standard picture F2 of M initial object image MT.sub.m, according to the optimized error function EF, to obtain the first recommended optical parameter set PR.sub.1. The subscript m of the symbol MT.sub.m represents the m.sup.th initial object image, wherein m is a positive integer ranging between 1 to M, and M is the total number of initial object images. The present disclosure does not limit the maximum value of M.

[0024] Step S120 could include steps S121 to S123.

[0025] In step S121, in the case of the AOI system 100 being set with M initial optical parameter sets PT.sub.m, the camera module 140 captures M initial object images MT.sub.m. For example, in the case of the AOI system 100 being set with the initial optical parameter set PT.sub.1, the camera module 140 captures the initial object images MT.sub.1. Then, in the case of the AOI system 100 being set with the initial optical parameter set PT.sub.2, the camera module 140 captures the initial object images MT.sub.2. As a result, the AOI system 100 is successively set with M initial optical parameter sets PT.sub.m, and the camera module 140 successively captures M initial object images MT.sub.m. The optical parameter types included in the initial optical parameter sets PT.sub.m are not limited in the present disclosure. As shown in FIG. 3A(a), the number of the initial optical parameter sets PT.sub.m of the present embodiment of the present disclosure are three (that is, M=3), such as the initial optical parameter sets PT.sub.1, PT.sub.2 and PT.sub.3. The initial optical parameter sets PT.sub.1, PT.sub.2 and PT.sub.3 could be expressed as PT.sub.1[x.sup.(1), x.sup.(2)], PT.sub.2[x.sup.(1), x.sup.(2)] and PT.sub.3[x.sup.(1), x.sup.(2)], the other optical parameter sets have similar expression forms, and the similarities will not be repeated here.

[0026] In step S122, the error calculation module 120 calculates the object standard picture F2 and M initial object image MT.sub.m, according to the optimized error function EF, to respectively obtain M initial error value ET.sub.m between M initial object image MT.sub.m and the object standard picture F2, wherein m is a positive integer ranging between 1 to M. As shown in FIG. 3A(a), the number of the initial error value ET.sub.m of the present embodiment of the present disclosure are three (i.e., M=3), such as the initial error values ET.sub.1, ET.sub.2 and ET.sub.3.

[0027] In FIG. 3A(a), a curve C1 represents the relationship between the optical parameter set and the error value in the 0.sup.th iteration, and each point in FIG. 3A(b) represents the minimum one (called the “minimum error value”) of the error values in the iteration. FIGS. 3B to 3H(b) have similar definition, and similarities will not be repeated here. In the stage of the method for automatically setting the optical parameter of FIG. 3A(b), the recommended optical parameter set PR.sub.n has not been introduced into the calculation (the iteration process of steps S140 to S180 has not been performed), and thus the iteration corresponding to the minimum error value is 0.sup.th.

[0028] In step S123, the optical parameter recommendation module 130 calculates M initial error value ET.sub.m and M initial optical parameter sets PT.sub.m to obtain the first recommended optical parameter set PR.sub.1 .

[0029] In the method for automatically setting the optical parameter, the optical parameter recommendation module 130 could use one of a plurality of implementations to determine the optical parameter sets. For example, the optical parameter recommendation module 130 could obtain the recommended optical parameter set according to formulas (6) to (7). However, as long as the recommended optical parameter set could be obtained, the method of obtaining the recommended optical parameter set in the present embodiment of the present disclosure is not limited to using formulas (6) to (7).

[00002] Corr ( xT i , xR j ) = exp { - .Math. k = 1 P θ k .Math. "\[LeftBracketingBar]" xT i [ x ( k ) ] - x R j [ x ( k ) ] .Math. "\[RightBracketingBar]" 2 } ( 6 ) Φ ( x R j ) = E ( .Math. i = 1 Q E F ( V 2 , U 2 i .Math. Λ ¯ ) Corr ( xT i , x R j ) < f min ) ( 7 )

[0030] In formulas (6) and (7), xR.sub.j is the candidate optical parameter set, wherein j is a positive integer between 1 to J which could represent that xR.sub.j is the j.sup.th candidate optical parameter set, and J is the number of the candidate optical parameter sets. xR.sub.j includes a plurality of the optical parameter types, and it could be represented by xR.sub.j[x.sup.(1), x.sup.(2), x.sup.(3), . . . , x.sup.(P)]. The candidate optical parameter set could be one that has not been calculated to obtain the error value among all optical parameter sets. The embodiment of the present disclosure does not limit the maximum value of J, and it could depend on the number of optical parameter types and/or the value range thereof.

[0031] In formulas (6) and (7), xT.sub.i is the selected optical parameter set, wherein i is a positive integer between 1 and Q and represents the i.sup.th selected optical parameter set, and Q is the number of the selected optical parameter sets. xT.sub.i includes a plurality of the optical parameter types, and it could be expressed as xT.sub.i[x.sup.(1), x.sup.(2), x.sup.(3), . . . , x.sup.(P)]. The selected optical parameter set xT.sub.i includes the initial optical parameter sets PT.sub.m and/or recommended optical parameter sets PR.sub.n from which the error values have been derived. For example, in FIG. 3B (in the first iteration), the selected optical parameter sets xT.sub.i includes the initial optical parameter sets PT.sub.1, PT.sub.2 and PT.sub.3 of FIG. 3A(a) (drawn as solid dots). In FIG. 3D (in the second iteration), the selected optical parameter sets xT.sub.i includes the initial optical parameter sets PT.sub.1, PT.sub.2 and PT.sub.3 of FIG. 3C(a) and the first recommended optical parameter set PR.sub.1 (drawn as solid dots). In formula (6), θ.sub.K represents the weight of the k.sup.th optical parameter type x.sup.(k) and is a constant. The values of several weights θ.sub.K of different several optical parameter types x.sup.(k) could be different or the same. In addition, the aforementioned k is a positive integer between 1 and Q, wherein Q is the number of the selected optical parameter sets. The number of the recommended optical parameter sets increases with the number of iterations, that is, the value of Q increases accordingly. The maximum value of Q depends on the number of the iterations, and the present disclosure does not limit the maximum value of Q.

[0032] In formula (6), Corr(xT.sub.i, xR.sub.j) is the difference between the j.sup.th candidate optical parameter set xR.sub.j and the i.sup.th selected optical parameter set xT.sub.i. In the calculation of the exponential function “exp”, the greater the difference between the j.sup.th candidate optical parameter set xR.sub.j and the i.sup.th selected optical parameter set xT.sub.i is, the smaller the value of Corr(xT.sub.i, xR.sub.j) is; however, the smaller the difference between the j.sup.th candidate optical parameter set xR.sub.j and the i.sup.th selected optical parameter set xT.sub.i is, the greater the value of Corr(xT.sub.i, xR.sub.j) is.

[0033] In formula (7), Φ(xRj) is the j.sup.th expected value (or probability) of the j.sup.th candidate optical parameter set xR.sub.j with respect to all the selected optical parameter set xT.sub.i, wherein the expected value Φ(xR.sub.j) ranges between, for example, 0 to 1. The expected value analysis function E is configured to obtain the expected value of the j.sup.th candidate optical parameter set xR.sub.j with respect to all the i.sup.th selected optical parameter set xT.sub.i by using various statistical or probability analysis techniques. Q represents the number of all the i.sup.th selected optical parameter set xT.sub.i. For example, in FIG. 3B (the first iteration), the number of the selected optical parameter sets xT.sub.i are three (for example, the number of solid dots), that is, Q is equal to 3. In FIG. 3D (in the second iteration), the number of the selected optical parameter sets xT.sub.i are four (for example, the number of solid dots), that is, Q is equal to 4.

[0034] In formula (7), f.sub.min represents the minimum one of the error values corresponding to the selected optical parameter sets xT.sub.i. For example, in FIG. 3B (in the first iteration), f.sub.min is the latest initial error value ET.sub.2 (as shown in FIG. 3A(b)) in the current iteration. In FIG. 3D (in the second iteration), f.sub.min is the latest minimum error value in the current iteration, that is, the rightmost initial error value ET.sub.2 (i.e., the minimum one of the initial error value ET.sub.1 to ET.sub.3) in FIG. 3C(b). In FIG. 3F (in the third iteration), f.sub.min is the latest minimum error value in the current iteration, that is, the rightmost initial error value ET.sub.2 (i.e., the minimum one of the initial error value ET.sub.1 to ET.sub.3 and the recommended error value ER.sub.1) in FIG. 3E(b).

[0035] In formula (7), EF(V2, U2.sub.i|Λ) could represent the error value between the image-level characteristic vector V2 of the object standard picture F2 and the image-level characteristic vector U2.sub.i of the i.sup.th selected image, wherein the selected image refers to the image that has been used to be calculated for obtaining the error value. For example, in FIG. 3B (in the first iteration), the selected image is the initial object image MT.sub.1 (it is obtained by the camera module 140 according to the first initial optical parameter set PT.sub.1 in FIG. 3A(a)), the initial object image MT.sub.2 (it is obtained by the camera module 140 according to the second initial optical parameter set PT.sub.2 in FIG. 3A(a)) and the initial object image MT.sub.3 (it is obtained by the camera module 140 according to the third initial optical parameter set PT.sub.3 in FIG. 3A(a)). In FIG. 3D (in the second iteration), the selected images are the initial object images MT.sub.1, MT.sub.2 and MT.sub.3 and the first recommended object image MR.sub.1 (it is obtained by the camera module 140 according to the first initial optical parameter set PT.sub.1 in FIG. 3C(a)). In the present embodiment, the vectors V2 and U2.sub.i are the image-level characteristic vectors, for example, RGB or HSV (Hue, Saturation, Lightness). However, in other embodiments, the vectors V2 and U2.sub.i could also be the image-level characteristic vectors, for example, the characteristic vectors extracted by the deep learning model.

[0036] As shown in formulas (6) and (7), when the greater the difference of the j.sup.th candidate optical parameter set xR.sub.j with respect to the i.sup.th selected optical parameter set xT.sub.i is (that is, the smaller the value of Corr(xT.sub.i, xR.sub.j) is), the greater the expected value is, and it means that the j.sup.th candidate optical parameter set xR.sub.j has a greater probability of generating a smaller error value than f.sub.min. Each candidate optical parameter set could obtain one expected value Φ(xR.sub.j). The optical parameter recommendation module 130 could use J candidate optical parameter sets xR.sub.j with different values to obtain corresponding J expected values Φ(xR.sub.j), and use the j.sup.th candidate optical parameter set xR.sub.j corresponding to the maximum one of the J expected values Φ(xR.sub.j) as the recommended optical parameter set PR.sub.n .

[0037] Referring to FIGS. 3B to 3C(b), the process of obtaining the first recommended optical parameter set PR.sub.1 based on formulas (6) to (7) is described below. The optical parameter recommendation module 130 first obtains several expected values Φ(xR.sub.j) of several candidate optical parameter sets xR.sub.j with respect to all the selected optical parameter sets xT.sub.i, and then uses (selects) the candidate optical parameter sets xR.sub.j corresponding to the maximum one of the expected values Φ(xR.sub.j) as the first recommended optical parameter set. The process of obtaining the expected value Φ(xR.sub.1) of the first candidate optical parameter set xR.sub.1 is described below.

[0038] As shown in FIG. 3A(a), when the number of the selected optical parameter sets xT.sub.i is 3 (Q=3), and formula (6) is calculated in case of the initial optical parameter sets PT.sub.m including PT.sub.1, PT.sub.2 and PT.sub.3. In case of i being equal to 1 and j being equal to 1, the optical parameter recommendation module 130 performs the calculation of formula (6) to obtain the first selected optical parameter set xT.sub.1 (for example, the initial optical parameter set PT.sub.1) and the value of Corr(xT.sub.1, xR.sub.1) of the first candidate optical parameter set xR.sub.1 (calculation formula: Corr(xT.sub.1, xR.sub.1)=exp{−Σ.sub.k=1.sup.Pθ.sub.k|xT.sub.1[x.sup.(k)]−xR.sub.1[x.sup.(k)]|.sup.2}) and obtain the initial error value ET.sub.1 (the initial error value ET.sub.1 is the result value of EF(V2, U2.sub.1|Λ)) of formula (7)) of the pixel-level characteristic vector V2 of the object standard picture F2 and the pixel-level characteristic vector U2.sub.i of the first selected image (for example, the first initial object image MT.sub.1).

[0039] In case of i being equal to 2 and j being equal to 1, the optical parameter recommendation module 130 performs the calculation of formula (6) to obtain the second selected optical parameter set xT.sub.2 (for example, the initial optical parameter set PT.sub.2) and the value of Corr(xT.sub.2, xR.sub.1) of the first candidate optical parameter set xR.sub.1 (calculation formula: Corr(xT.sub.2, xR.sub.1)=exp{−Σ.sub.k=1.sup.Pθ.sub.k|xT.sub.2[x.sup.(k)]−xR.sub.1[x.sup.(k)]|.sup.2}) and obtain the initial error value ET.sub.2 (the initial error value ET.sub.2 is the result value of EF(V2, U2.sub.2|Λ))of formula (7)) of the pixel-level characteristic vector V2 of the object standard picture F2 and the pixel-level characteristic vector U2.sub.2 of the second selected image (for example, the second initial object image MT.sub.2).

[0040] In a case of i being equal to 3 (value of Q) and j being equal to 1, the optical parameter recommendation module 130 performs the calculation of formula (6) to obtain the third selected optical parameter set xT.sub.3 (for example, the initial optical parameter set PT.sub.3) and the value of Corr(xT.sub.3, xR.sub.1) of the first candidate optical parameter set xR.sub.1 (based on formula Corr(xT.sub.3, xR.sub.1)=exp{−Σ.sub.k=1.sup.Pθ.sub.k|xT.sub.3[x.sup.(k)]−xR.sub.1[x.sup.(k)]|.sup.2}) and obtain the initial error value ET.sub.3 (the initial error value ET.sub.3 is the result value of EF(V2, U2.sub.3|Λ)) of formula (7)) between the pixel-level characteristic vector V2 of the object standard picture F2 and the pixel-level characteristic vector U2.sub.3 of the third selected image (for example, the third initial object image MT.sub.3).

[0041] Then, the optical parameter recommendation module 130 could obtain the quotient of

[00003] E T 3 Corr ( xT 1 , xR 1 ) ,

the quotient of

[00004] E T 3 Corr ( xT 2 , xR 1 )

and the quotient of

[00005] E T 3 Corr ( xT 3 , xR 1 )

according to formula (7), and after obtaining the sum of these quotients (the sum calculation formula:

[00006] .Math. i = 1 Q E F ( V 2 , U 2 i | Λ ¯ ) Corr ( xT i , x R 1 ) ) ,

calculates the expected value analysis function E of the operation formula (7) to obtain the expected value Φ(xR.sub.1) of the first candidate optical parameter set xR.sub.1.

[0042] According to the aforementioned principle, the optical parameter recommendation module 130 could obtain J expected values Φ(xR.sub.j) of J different candidate optical parameter sets xR.sub.j. The optical parameter recommendation module 130 could select the maximum one of J expected values Φ(xR.sub.j), and uses (selects) the maximum one as the first (i.e., n=1) recommended optical parameter set PR.sub.1, as shown in FIG. 3B.

[0043] After the first recommended optical parameter set PR.sub.1 is obtained, step S124 is performed, and the automatic setting module 150 sets the AOI system 100 according to the first recommended optical parameter set PR.sub.1. The automatic setting module 150 could set the light source module 160 and the camera module 140 according to the first recommended optical parameter set PR.sub.1 . For example, as x.sup.(1) of the first recommended optical parameter set PR.sub.1[x.sup.(1), x.sup.(2)] is the exposure time and x.sup.(2) of the first recommended optical parameter set PR.sub.1[x.sup.(1), x.sup.(2)] is the illuminating time, the automatic setting module 150 sets the exposure time of the camera module 140 to the value of x.sup.(1) of the first recommended optical parameter set PR.sub.1[x.sup.(1), x.sup.(2)], and sets the illuminating time of the light source module 160 to the value of x.sup.(2) of the first recommended optical parameter set PR.sub.1[x.sup.(1), x.sup.(2)]. The automatic setting module 150 could automatically set the light source module 160 and/or the camera module 140 according to the recommended optical parameter set without manual operation. As a result, it could reduce the time required for setting the optical parameters and increase the effectiveness of the automatic setting of optical parameters. In another embodiment, the AOI system 100 could optionally omit the automatic setting module 150 if it is manually set.

[0044] In performing step S130, the error calculation module 120 sets the initial value of n to 1. The order of performing steps S130 and S124 is not limited, that is, one of steps S130 and S124 could be performed first or both of steps S130 and S124 could be performed simultaneously.

[0045] In step S140, the camera module 140 photographs the to-be-inspected object, under the AOI system 100 set by using the first recommended optical parameter set PR.sub.1, to obtain the first recommended object image MR.sub.1.

[0046] In step S150, the error calculation module 120 calculates the first recommended error value ER.sub.1 (as shown in FIG. 3C(a) between the object standard picture F2 and the first recommended object image MR.sub.1, according to the optimized error function EF of formula (5), the pixel-level characteristic vector V2 of the object standard picture F2 and the pixel-level characteristic vector U2 of the first recommended object image MR.sub.1.

[0047] As shown in FIG. 3C(a), the optical parameter recommendation module 130 could obtain a fitting curve C2 of the initial error values ET.sub.1, ET.sub.2, ET.sub.3 and the recommended error value ER.sub.n by using curve fitting method.

[0048] In step S160, the error calculation module 120 determines whether the recommended error value converges. When the recommended error value converges has converged, the process proceeds to step S190; when the recommended error value has not converged, the process proceeds to step S170.

[0049] In step S160 of an embodiment, when the recommended error value is equal to or less than a convergence threshold or the difference between any two of the recommended error values in several iterations is within a convergence range, the error calculation module 120 determines that the error value has converged. The aforementioned “convergence threshold” is, for example, any value ranging between 0.1 to 0.3 (including endpoint), “several iterations” is, for example, equal to or greater than 3 times, and “convergence range” is, for example, between any value ranging between 0.1 to 0.3 (including the endpoint), but the embodiment of the present disclosure is not limited thereto.

[0050] As shown in FIG. 3C(b), the first recommended error value ER.sub.1 obtained in step S150 is not less than the minimum error value obtained in the previous iteration (it is the minimum initial error value ET.sub.2 of the initial error values obtained in 0.sup.th iteration), and thus in the first iteration, the minimum error value still is initial error value ET.sub.2. Since the first recommended error value ER.sub.1 is not less than the minimum error value in the previous iteration (it is the initial error value ET.sub.2 in 0.sup.th iteration), the error calculation module 120 determines that the minimum error value has not yet converged, and thus the process proceeds to step S170.

[0051] In step S170, the optical parameter recommendation module 130 calculates n recommended error values, n recommended optical parameter sets, M initial error values and M initial optical parameter sets to obtain the (n+1).sup.th recommended optical parameter set. In other words, the optical parameter recommendation module 130 calculates, by using formulas (6) and (7), all selected optical parameter sets xT.sub.i (including n recommended optical parameter sets and M initial optical parameter sets) and all obtained (calculated) error values (including n recommended error values and M initial error values) to obtain the next (i.e., (n+1).sup.th) recommended optical parameter set (i.e., the (n+1).sup.th recommended optical parameter set).

[0052] The process (corresponding to FIGS. 3D to 3E(b)) of obtaining the second recommended optical parameter set PR.sub.2 through formulas (6) to (7) is described below. In the process, the optical parameter recommendation module 130 first calculates the expected values Φ(xR.sub.j) of each of the plurality of the candidate optical parameter sets xR.sub.j with respect to all the selected optical parameter sets xT.sub.i, and then uses (selects) the candidate optical parameter set xR.sub.j corresponding to the maximum one of the expected values Φ(xR.sub.j) as the second recommended optical parameter set PR.sub.2 The following takes the first candidate optical parameter sets xR.sub.1 as an example to illustrate the process of calculating the expected value Φ(xR.sub.j).

[0053] As shown in FIG. 3C(a), the number of selected optical parameter sets xT.sub.i is four (Q=4), which include three initial optical parameter sets PT.sub.1, PT.sub.2 and PT.sub.3 and one recommended optical parameter set PR.sub.1 .

[0054] In case of i being equal to 1 and j being equal to 1, the optical parameter recommendation module 130 calculates, according to formula (6), the first (i.e., i=1) selected optical parameter set xT.sub.1 (e.g., the initial optical parameter set PT.sub.1) and the value of Corr (xT.sub.1, xR.sub.1) of the first (i.e., j=1) candidate optical parameter set xR.sub.1 (calculation formula: Corr(xT.sub.1, xR.sub.1)=exp{−Σ.sub.k=1.sup.Pθ.sub.k|xT.sub.1[x.sup.(k)]−xR.sub.1[x.sup.(k)]|.sup.2}), and obtains the initial error value ET.sub.1 (the initial error value ET.sub.1 is the result value of EF(V2, U2.sub.1|Λ)) of formula (7)) of the pixel-level characteristic vector V2 of the object standard picture F2 and the pixel-level characteristic vector U2.sub.1 of the first (i.e., i=1) selected image (e.g., the first initial object image MT.sub.1).

[0055] In a case of i being equal to 2 and j being equal to 1, the optical parameter recommendation module 130 calculates, according to formula (6), the second (i.e., i=2) selected optical parameter set xT.sub.2 (e.g., the initial optical parameter set PT.sub.2) and the value of Corr(xT.sub.2, xR.sub.1) of the first (i.e., j=1) candidate optical parameter set xR.sub.1 (calculation formula: Corr(xT.sub.2, xR.sub.1)=exp{−Σ.sub.k=1.sup.Pθ.sub.k|xT.sub.2[x.sup.(k)]−xR.sub.1[x.sup.(k)]|.sup.2}), and obtains the initial error value ET.sub.2 (the initial error value ET.sub.2 is the result value of EF(V2, U2.sub.2|Λ)) of formula (7)) between the pixel-level characteristic vector V2 of the object standard picture F2 and the pixel-level characteristic vector U2.sub.2 of the second (i.e., i=2) selected image (e.g., the second initial object image MT.sub.2).

[0056] In case of i being equal to 3 and j being equal to 1, the optical parameter recommendation module 130 calculates, according to formula (6), the third (i.e., i=3) selected optical parameter set xT.sub.3 (e.g., the initial optical parameter set PT.sub.3) and the value of Corr(xT.sub.3, xR.sub.1) of the first (i.e., j=1) candidate optical parameter set xR.sub.1 (calculation formula: Corr(xT.sub.3, xR.sub.1)=exp{−Σ.sub.k=1.sup.Pθ.sub.k|xT.sub.3[x.sup.(k)]−xR.sub.1[x.sup.(k)]|.sup.2}), and obtains the initial error value ET.sub.3 (the initial error value ET.sub.3 is the result value of EF(V2, U2.sub.3|Λ)) of formula (7)) of the pixel-level characteristic vector V2 of the object standard picture F2 and the pixel-level characteristic vector U2.sub.3 of the third (i.e., i=3) selected image (e.g., the third initial object image MT.sub.3).

[0057] In case of i being equal to 4 and j being equal to 1, the optical parameter recommendation module 130 calculates, according to formula (6), the fourth (i.e., i=4) selected optical parameter set xT.sub.4 (e.g., the recommended optical parameter set PR.sub.1) and the value of Corr(xT.sub.4, xR.sub.1) of the first (i.e., j=1) candidate optical parameter set xR.sub.1 (calculation formula: Corr(xT.sub.4, xR.sub.1)=exp{−Σ.sub.k=1.sup.Pθ.sub.k|xT.sub.4[x.sup.(k)]−xR.sub.1[x.sup.(k)]|.sup.2}), and obtains the first recommended error value ER.sub.1 (the first recommended error value ER.sub.1 is the result value of EF(V2, U2.sub.4|Λ)) of formula (7)) of the pixel-level characteristic vector V2 of the object standard picture F2 and the pixel-level characteristic vector U2.sub.4 of the fourth (i.e., i=4) selected image (e.g., the recommended optical parameter set PR.sub.1).

[0058] Then, the optical parameter recommendation module 130 could obtain the quotient of

[00007] E T 3 Corr ( xT 1 , xR 1 ) ,

the quotient of

[00008] E T 3 Corr ( xT 2 , xR 1 )

and the quotient of

[00009] E T 3 Corr ( xT 3 , xR 1 )

according to formula (7), and after obtaining the sum of these quotients (the sum calculation formula:

[00010] .Math. i = 1 Q E F ( V 2 , U 2 i | Λ ¯ ) Corr ( xT i , x R 2 ) ) ,

the optical parameter recommendation module 130 calculates the expected value analysis function E of the operation formula (7) to obtain the expected value Φ(xR.sub.2) of the first candidate optical parameter set xR.sub.1.

[0059] According to the aforementioned principle, the optical parameter recommendation module 130 could obtain J expected values Φ(xR.sub.j) of J different candidate optical parameter sets xR.sub.j. The optical parameter recommendation module 130 could select the maximum one of J expected values Φ(xR.sub.j), and uses (selects) the candidate optical parameter sets xR.sub.j corresponding to the maximum one of the expected values as the second (i.e., n=2) recommended optical parameter set PR.sub.2, as shown in FIG. 3D.

[0060] After the second recommended optical parameter set PR.sub.2 is obtained, step S175 is performed.

[0061] In step S175, the automatic setting module 150 sets the AOI system 100 according to the second ((n+1).sup.th) recommended optical parameter set PR.sub.2.

[0062] In step S180, the value of n is accumulated by 1 (n=2), and then the next iteration is performed, that is, step S140 is performed again. In the second (n=2) iteration, under the AOI system being set with the second recommended optical parameter set PR.sub.2, the camera module 140 photographs the to-be-inspected object to obtain the second recommended object image MR.sub.2. Then, step S150 is performed, in the second iteration, the optical parameter recommendation module 130 perform calculation, according to the optimized error function EF of formula (5), the second recommended error value ER.sub.2 between the object standard picture F2 and the second recommended object image MR.sub.2, as shown in FIG. 3E(a). In FIG. 3E(a), the optical parameter recommendation module 130 could obtain a fitting curve C3 of the initial error values ET.sub.1, ET.sub.2, ET.sub.3 and the recommended error values ER.sub.1 and ER.sub.2 by using curve fitting method. Then, in step S160, the optical parameter recommendation module 130 determines whether the recommended error value converges. When the recommended error value has converged, the process proceeds to step S190; when the recommended error value has not converged, the process proceeds to step S170. As shown in FIG. 3E(b), the second recommended error value ER.sub.2 is not less than the first recommended error value ER.sub.1 and the minimum error value (the initial error value ET.sub.2) in the previous iterations (the 0.sup.th iteration and the first iteration), the optical parameter recommendation module 130 determines that the recommended error value has not converged, and then the process proceeds to step S170.

[0063] In step S170, the optical parameter recommendation module 130 obtains the third recommended optical parameter set PR.sub.3 by using the aforementioned process of determining the recommended optical parameter set. In step S175, the automatic setting module 150 sets the AOI system 100 according to the third recommended optical parameter set PR.sub.3. In step S180, the optical parameter recommendation module 130 updates value of n (n=3) and executes the next iteration (the third iteration) in step S180. In third iteration, similar to the aforementioned second iteration, steps S140 to S160 are performed to obtain the third recommended error value ER.sub.3 (as shown in FIGS. 3F and 3G(a)). Then, in step S160, as shown in FIG. 3G(b), although the third recommended error value ER.sub.3 is less than the recommended error values ER.sub.1 and ER.sub.2 in the previous iteration and the minimum error value ET.sub.2, the optical parameter recommendation module 130 determines that the recommended error value has not converged due to the third recommended error value ER.sub.3 being not less than the convergence threshold, and performs steps S170 to S180 to obtain the n.sup.th recommended optical parameter set PR.sub.n in the next iteration.

[0064] As shown in FIG. 3H(a), the optical parameter recommendation module 130 sequentially obtains the fourth recommended error value ER.sub.4 in the fourth (i.e., n=4) iteration, the fifth recommended error value ER.sub.5 in the fifth (i.e., n=5) iteration, the sixth recommended error value ER.sub.6 in the sixth (i.e., n=6) iteration and the seventh recommended error value ER.sub.7 in the seventh (i.e., n=7) iteration. As shown in FIG. 3H(b), in step S160 of the seventh iteration, the seventh recommended error value ER.sub.7 has been lower than the aforementioned convergence threshold, and the optical parameter recommendation module 130 determines that the recommended error value ER.sub.7 has converged accordingly. Then, in step S190, the optical parameter recommendation module 130 uses (selects) the minimum recommended error value in the seventh iteration (namely the seventh recommended optical parameter set PR.sub.7 corresponding to the seventh recommended error value ER.sub.7) as the optimal optical parameter set of the AOI system 100.

[0065] The light source module 160 and the camera module 140 of the AOI system 100 could be set according to the optimal optical parameter set, and operates on production line, such that the image captured by the camera module 140 has the better/best quality (for example, color presentation) for improving the accuracy of the AOI system 100 inspecting/detecting the products.

[0066] In summary, the embodiment of the present disclosure provides the method for automatically setting the automatic optical parameter and the AOI system using the same, which could automatically obtain the optimal optical parameter set by using machine learning technology. In the method for automatically setting the automatic optical parameter, it is necessary to perform up to tens of thousands, hundreds of thousands or even more iterations for P or all optical parameter sets in a short time, wherein the calculation process is much complicated and it must be performed by a computer but not (or can't) be done by a human brain. Since the method for automatically setting the optical parameter set is performed by the computer, at least one of all the optical parameters that affects the presentation (or quality) of the product image captured by the camera could be considered in the process to improve the quality of the captured product image and increase the inspection/detection accuracy. Compared with manual dimming, the embodiments of the present disclosure have at least one of the following technical effects: (1). misjudgment resulted from human factors could be avoided, thereby improving dimming stability; (2). the time required for dimming could be reduced; (3). labor cost could be reduced; (4). the number of optical parameter types added to the dimming process could be many or more; or/and (5). the detection accuracy of the AOI system could be increased.

[0067] It will be apparent to those skilled in the art that various modifications and variations could be made to the disclosed embodiments. It is intended that the specification and examples be considered as exemplary only, with a true scope of the disclosure being indicated by the following claims and their equivalents.