control method for simultaneously automatically focusing most 12 cameras

文档序号:1708172 发布日期:2019-12-13 浏览:37次 中文

阅读说明:本技术 一种最多支持12相机同时自动对焦的控制方法 (control method for simultaneously automatically focusing most 12 cameras ) 是由 朱金伟 谢华辉 于 2019-08-29 设计创作,主要内容包括:本发明涉及视觉检测技术领域,尤其是一种最多支持12相机同时自动对焦的控制方法;它包括以下步骤:S1将工业相机通过电动滑台安装普通镜头或者通过液态镜头控制器安装液态镜头;S2电动滑台或者液态镜头控制器信号连接自动对焦控制器,工业相机信号连接工控机;S3自动对焦控制器通过工业通讯协议与工控机交互;S4工控机下发指令使得电动滑台或者液态镜头控制器控制普通镜头或者液态镜头焦点前后循环移动;S5工业相机反馈图像信息给工控机;S6工控机根据自动对焦算法判断当前镜头是否为最佳对焦位置,是则停止运动并获取清晰图像,否则重复s4-s6步骤,直至获得最佳对焦位置;利于视觉检测的快速完成。(The invention relates to the technical field of visual detection, in particular to a control method for automatic focusing of at most 12 cameras simultaneously; it comprises the following steps: s1, mounting a common lens on the industrial camera through an electric sliding table or mounting a liquid lens through a liquid lens controller; s2, the electric sliding table or the liquid lens controller is in signal connection with the automatic focusing controller, and the industrial camera is in signal connection with the industrial personal computer; s3 the automatic focusing controller interacts with the industrial personal computer through the industrial communication protocol; an industrial personal computer (S4) issues an instruction to enable an electric sliding table or a liquid lens controller to control the focus of the common lens or the liquid lens to move back and forth circularly; s5 the industrial camera feeds back image information to the industrial personal computer; the industrial personal computer of S6 judges whether the current lens is the best focusing position according to the automatic focusing algorithm, if so, the movement is stopped and a clear image is obtained, otherwise, the steps of S4-S6 are repeated until the best focusing position is obtained; the rapid completion of the visual detection is facilitated.)

1. a control method for automatic focusing of at most 12 cameras simultaneously is characterized by comprising the following steps: it comprises the following steps:

S1, mounting a common lens on the industrial camera through an electric sliding table or mounting a liquid lens through a liquid lens controller;

S2, the electric sliding table or the liquid lens controller is in signal connection with the automatic focusing controller, and the industrial camera is in signal connection with the industrial personal computer;

s3 the automatic focusing controller interacts with the industrial personal computer through the industrial communication protocol;

An industrial personal computer (S4) issues an instruction to enable an electric sliding table or a liquid lens controller to control the focus of the common lens or the liquid lens to move back and forth circularly;

s5 the industrial camera feeds back image information to the industrial personal computer;

and the industrial personal computer of S6 judges whether the current lens is the best focusing position according to the automatic focusing algorithm, if so, the movement is stopped and a clear image is obtained, otherwise, the steps of S4-S6 are repeated until the best focusing position is obtained.

2. the method of claim 1, wherein the method further comprises: the automatic focusing device comprises an electric sliding table, an industrial camera and a common lens, wherein the electric sliding table, the industrial camera and the common lens are twelve in number, one automatic focusing controller is arranged, and one industrial personal computer is arranged.

3. The method of claim 1, wherein the method further comprises: the automatic focusing system comprises a liquid lens controller, an industrial camera, a liquid lens, an automatic focusing controller and an industrial personal computer, wherein the liquid lens controller, the industrial camera and the liquid lens are twelve respectively, and the automatic focusing controller and the industrial personal computer are one.

4. The method of claim 1, wherein the method further comprises: the automatic focusing algorithm specifically comprises the following steps:

Acquiring an image with a fixed resolution of X Y, wherein the image is provided with X Y pixel points; x and Y are integers greater than 1; converting the RGB value of each pixel point into a brightness value M, wherein the conversion formula is M ═ ((R × 299) + (G × 587) + (B × 114))/1000; calculating the absolute value of the brightness difference between a pixel point and a transversely adjacent pixel point, calculating the absolute value of the brightness difference between the pixel point and a longitudinally adjacent pixel point, and calculating the sum of the absolute values of the brightness differences of all the pixel points on an image; the position where the sum value is maximum is the focusing position. That is, the industrial control machine calculates the sum of the absolute values of the brightness difference values in real time in the process that the electric sliding table drives the lens to move back and forth, and the focus position can be known after one cycle.

5. The method of claim 1, wherein the method further comprises: the automatic focusing algorithm specifically comprises the following steps:

S11: assigning the search boundary InitL and InitR of the movement of the focusing lens to L and R correspondingly, and obtaining the resolution f (L) and f (R) of the focusing module when the focusing lens is positioned at the search boundary; wherein, L and R are variables, and InitL and InitR are constants; f (x) is the resolution of the focusing module when the focusing lens is searched to the x position; x is a variable, and x is a value between InitL and InitR. L ═ InitL ═ 0.2A, R ═ InitR ═ 2A, f (L) ═ 0.07, and f (R) ═ 0.07.

S12: setting focusing points x1 and x2 of the focusing lens by a golden section method, wherein x1 is L + (1-tau) x (R-L), x2 is L + tau (R-L), and tau is 0.618, and acquiring f (x1) and f (x 2); wherein x1 and x2 are variables. x1 is 0.8696, x2 is 1.3124, f (x1) is 0.19, f (x2) is 0.15, and since f (x1) > f (x2), the operation proceeds to step S15.

s13: it is determined whether f (x1) is greater than f (x 2).

s14: when f (x1) < f (x2), L ═ x1, x1 ═ x2, and x2 ═ L + τ x (R-L), which respectively indicate that x1 is assigned to L, x2 is assigned to x1, and x2 is calculated using the reassigned L according to the golden section method.

S15: when f (x1) > f (x2), R is x2, x2 is x1, and x1 is L + (1- τ) x (R-L), which respectively indicate that x2 is assigned to R and x1 is assigned to x2, and x1 is calculated according to the golden section method using the re-assigned R. In this embodiment, R is 1.3124, x2 is 0.8696, and x1 is 0.6138.

S16: judging whether L is not equal to InitL and R is not equal to InitR; when L ≠ InitL and R ≠ InitR does not hold, it returns to step S13. Since the value of L does not change, L ≠ InitL and R ≠ InitR are not true, and it is necessary to return to S13 to compare the size between f (x1) and f (x2) when x1 ≠ 0.6138 and x2 ≠ 0.8696.

s17: when L ≠ InitL and R ≠ InitR are established, the corresponding focus L is acquired.

Technical Field

The invention relates to the technical field of visual detection, in particular to a control method for automatic focusing of at most 12 cameras simultaneously.

background

In the production of some precision parts, visual inspection of multiple faces of the part using a visual camera is required. Because the product size is inconsistent, when equipment or production line switch different specification products, can produce a difficult point of present industry vision trade, the debugging camera lens degree of depth problem: at present, industrial products with multiple detection faces can only confirm the focusing condition of each face and adjust the working distance through engineers.

disclosure of Invention

Aiming at the defects of the prior art, the invention provides an industrial camera control method capable of automatically focusing multiple surfaces of a product.

The technical scheme of the invention is as follows:

a control method for automatic focusing of at most 12 cameras simultaneously is characterized by comprising the following steps: it comprises the following steps:

S1, mounting a common lens on the industrial camera through an electric sliding table or mounting a liquid lens through a liquid lens controller;

S2, the electric sliding table or the liquid lens controller is in signal connection with the automatic focusing controller, and the industrial camera is in signal connection with the industrial personal computer;

S3 the automatic focusing controller interacts with the industrial personal computer through the industrial communication protocol;

An industrial personal computer (S4) issues an instruction to enable an electric sliding table or a liquid lens controller to control the focus of the common lens or the liquid lens to move back and forth circularly;

S5 the industrial camera feeds back image information to the industrial personal computer;

And the industrial personal computer of S6 judges whether the current lens is the best focusing position according to the automatic focusing algorithm, if so, the movement is stopped and a clear image is obtained, otherwise, the steps of S4-S6 are repeated until the best focusing position is obtained.

in one embodiment, twelve electric sliding tables, twelve industrial cameras and twelve common lenses are arranged, one automatic focusing controller is arranged, and one industrial personal computer is arranged. This embodiment mainly employs an electric slide table for performing the position (i.e., focus) movement of the lens.

in one embodiment, twelve liquid lens controllers, twelve industrial cameras and twelve liquid lenses are provided, one automatic focusing controller and one industrial personal computer are provided. This embodiment mainly uses a liquid lens controller to perform the focus movement of the lens.

In one embodiment, the auto-focusing algorithm specifically includes the following steps:

acquiring an image with a fixed resolution of X Y, wherein the image is provided with X Y pixel points; x and Y are integers greater than 1; converting the RGB value of each pixel point into a brightness value M, wherein the conversion formula is M ═ ((R × 299) + (G × 587) + (B × 114))/1000; calculating the absolute value of the brightness difference between a pixel point and a transversely adjacent pixel point, calculating the absolute value of the brightness difference between the pixel point and a longitudinally adjacent pixel point, and calculating the sum of the absolute values of the brightness differences of all the pixel points on an image; the position where the sum value is maximum is the focusing position. That is, the industrial control machine calculates the sum of the absolute values of the brightness difference values in real time in the process that the electric sliding table drives the lens to move back and forth, and the focus position can be known after one cycle.

In one embodiment, the auto-focusing algorithm specifically includes the following steps:

S11: assigning the search boundary InitL and InitR of the movement of the focusing lens to L and R correspondingly, and obtaining the resolution f (L) and f (R) of the focusing module when the focusing lens is positioned at the search boundary; wherein, L and R are variables, and InitL and InitR are constants; f (x) is the resolution of the focusing module when the focusing lens is searched to the x position; x is a variable, and x is a value between InitL and InitR. L ═ InitL ═ 0.2A, R ═ InitR ═ 2A, f (L) ═ 0.07, and f (R) ═ 0.07.

S12: setting focusing points x1 and x2 of the focusing lens by a golden section method, wherein x1 is L + (1-tau) x (R-L), x2 is L + tau (R-L), and tau is 0.618, and acquiring f (x1) and f (x 2); wherein x1 and x2 are variables. x1 is 0.8696, x2 is 1.3124, f (x1) is 0.19, f (x2) is 0.15, and since f (x1) > f (x2), the operation proceeds to step S15.

S13: it is determined whether f (x1) is greater than f (x 2).

s14: when f (x1) < f (x2), L ═ x1, x1 ═ x2, and x2 ═ L + τ x (R-L), which respectively indicate that x1 is assigned to L, x2 is assigned to x1, and x2 is calculated using the reassigned L according to the golden section method.

S15: when f (x1) > f (x2), R is x2, x2 is x1, and x1 is L + (1- τ) x (R-L), which respectively indicate that x2 is assigned to R and x1 is assigned to x2, and x1 is calculated according to the golden section method using the re-assigned R. In this embodiment, R is 1.3124, x2 is 0.8696, and x1 is 0.6138.

S16: judging whether L is not equal to InitL and R is not equal to InitR; when L ≠ InitL and R ≠ InitR does not hold, it returns to step S13. Since the value of L does not change, L ≠ InitL and R ≠ InitR are not true, and it is necessary to return to S13 to compare the size between f (x1) and f (x2) when x1 ≠ 0.6138 and x2 ≠ 0.8696.

s17: when L ≠ InitL and R ≠ InitR are established, the corresponding focus L is acquired.

The invention has the beneficial effects that: and judging the clearest focusing surface of a plurality of surfaces of the product, if so, capturing the image, otherwise, automatically focusing, and carrying out omnibearing data acquisition and recording on the appearance of the product in a short time, so that the rapid visual detection is facilitated.

drawings

FIG. 1 is a schematic structural view of example 1 of the present invention;

Fig. 2 is a schematic structural diagram of embodiment 2 of the present invention.

Detailed Description

The following further describes embodiments of the present invention with reference to the accompanying drawings:

8页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:激光光源控制方法、激光夜视成像装置以及存储介质

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!