CN105120151B - A kind of method and device focused on automatically - Google Patents
A kind of method and device focused on automatically Download PDFInfo
- Publication number
- CN105120151B CN105120151B CN201510510341.8A CN201510510341A CN105120151B CN 105120151 B CN105120151 B CN 105120151B CN 201510510341 A CN201510510341 A CN 201510510341A CN 105120151 B CN105120151 B CN 105120151B
- Authority
- CN
- China
- Prior art keywords
- variable num
- focal length
- focus
- video camera
- camera
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 38
- 238000001514 detection method Methods 0.000 claims abstract description 25
- 230000008859 change Effects 0.000 claims description 55
- 230000000630 rising effect Effects 0.000 claims description 34
- 230000001960 triggered effect Effects 0.000 claims description 5
- 238000007493 shaping process Methods 0.000 claims 3
- 230000007704 transition Effects 0.000 claims 2
- 230000005611 electricity Effects 0.000 claims 1
- 230000008569 process Effects 0.000 description 10
- 230000004297 night vision Effects 0.000 description 9
- 230000004044 response Effects 0.000 description 7
- 230000000694 effects Effects 0.000 description 5
- 238000012544 monitoring process Methods 0.000 description 5
- 238000011897 real-time detection Methods 0.000 description 3
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000006243 chemical reaction Methods 0.000 description 1
- 238000010586 diagram Methods 0.000 description 1
- 230000006872 improvement Effects 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 210000000056 organ Anatomy 0.000 description 1
Landscapes
- Automatic Focus Adjustment (AREA)
- Studio Devices (AREA)
Abstract
本发明提供一种自动聚焦的方法及装置,该方法包括:设置变量num,并设置所述变量num的初始值为第一特征值;实时检测摄像机的焦距及位置中的至少一个是否发生改变;如果是,将所述变量num的当前值增加预定值;实时判断所述变量num的当前值是否为所述第一特征值;如果否,形成聚焦信号,并将所述num的当前值减去所述预定值;根据所述聚焦信号,控制所述摄像机进行聚焦。该装置包括:第一设置单元、检测单元、计算单元、第一判断单元、信号形成器及控制器。本方案能够实现摄像机的自动聚焦。
The present invention provides an automatic focusing method and device, the method comprising: setting a variable num, and setting the initial value of the variable num to the first characteristic value; detecting in real time whether at least one of the focal length and the position of the camera changes; If so, increase the current value of the variable num by a predetermined value; judge in real time whether the current value of the variable num is the first characteristic value; if not, form a focus signal, and subtract the current value of the num The predetermined value; controlling the camera to focus according to the focus signal. The device includes: a first setting unit, a detection unit, a calculation unit, a first judgment unit, a signal generator and a controller. This solution can realize the automatic focus of the camera.
Description
技术领域technical field
本发明涉及视频监控领域,特别涉及一种自动聚焦的方法及装置。The invention relates to the field of video monitoring, in particular to an automatic focusing method and device.
背景技术Background technique
为了安全防范或记录相关过程,监控摄像头的使用越来越广泛,比如商场、交通路口、工厂都安装有监控摄像头,用于记录相应的违法或犯罪行为,为公安机关办案提供证据。为了获得较大的监控范围及较清晰的图像,目前监控一般都采用激光夜视仪,激光夜视仪包括红外激光照明器、可变焦镜头、红外摄像机及云台等组成,当激光夜视仪的云台转动或摄像机镜头变倍后,摄像机拍摄的对象发生变化,需要重新对激光夜视仪进行聚焦,以获得最清晰的视频图像。For safety precautions or to record related processes, surveillance cameras are used more and more widely. For example, shopping malls, traffic intersections, and factories are all equipped with surveillance cameras to record corresponding illegal or criminal acts and provide evidence for public security organs to handle cases. In order to obtain a larger monitoring range and clearer images, laser night vision devices are generally used for monitoring at present. Laser night vision devices include infrared laser illuminator, zoom lens, infrared camera and pan/tilt. After the pan/tilt of the camera is rotated or the camera lens is zoomed in, the object captured by the camera changes, and the laser night vision device needs to be refocused to obtain the clearest video image.
目前,激光夜视仪一般都包含自动聚焦模块,当激光夜视仪的云台发生转动,或摄像机镜头变倍后,都通过人工操作相应的按钮,对激光夜视仪进行聚焦,以获得较好的视频图像质量。At present, laser night vision devices generally include an auto-focus module. When the pan/tilt of the laser night vision device rotates, or the camera lens zooms in, the corresponding button is manually operated to focus the laser night vision device to obtain better Good video image quality.
针对目前对激光夜视仪聚焦的方法,在每次转动激光夜视仪的角度或调整激光夜视仪的拍摄距离后,都需要人工进行繁琐的聚焦工作。In view of the current focusing method of the laser night vision device, after each turning the angle of the laser night vision device or adjusting the shooting distance of the laser night vision device, it is necessary to manually perform tedious focusing work.
发明内容Contents of the invention
本发明提供一种自动聚焦的方法及装置,能够实现摄像机的自动聚焦。The invention provides an automatic focusing method and device, which can realize automatic focusing of a video camera.
本发明实施例提供了一种自动聚焦的方法,设置变量num,并设置所述变量num的初始值为第一特征值,还包括:The embodiment of the present invention provides an automatic focusing method, setting the variable num, and setting the initial value of the variable num to the first eigenvalue, further comprising:
实时检测摄像机的焦距及位置中的至少一个是否发生改变;Detecting in real time whether at least one of the focal length and the position of the camera changes;
如果是,将所述变量num的当前值增加预定值;If so, increasing the current value of the variable num by a predetermined value;
实时判断所述变量num的当前值是否为所述第一特征值;judging in real time whether the current value of the variable num is the first characteristic value;
如果否,形成聚焦信号,并将所述num的当前值减去所述预定值;If not, forming a focus signal and subtracting said predetermined value from said current value of num;
根据所述聚焦信号,控制所述摄像机进行聚焦。According to the focus signal, the camera is controlled to focus.
优选地,所述形成聚焦信号包括:预设一个低电平时间和一个高电平时间,当判断所述变量num的当前值不为所述第一特征值时,开始计时,形成一个低电平的脉冲,当计时时长等于所述低电平时间时,所述脉冲由低电平转换为高电平,形成一个上升沿,当所述计时时长等于所述低电平时间与所述高电平时间之和时,所述脉冲由高电平转换为低电平,形成一个下降沿,以得到由所述上升沿及所述下降沿组成的聚焦信号。Preferably, the forming the focus signal includes: preset a low level time and a high level time, when it is judged that the current value of the variable num is not the first characteristic value, start counting to form a low level time Flat pulse, when the timing duration is equal to the low level time, the pulse is converted from low level to high level, forming a rising edge, when the timing duration is equal to the low level time and the high level When the sum of the level times, the pulse is converted from a high level to a low level to form a falling edge, so as to obtain a focusing signal composed of the rising edge and the falling edge.
优选地,所述根据所述聚焦信号,控制所述摄像机进行聚焦包括:Preferably, the controlling the camera to focus according to the focusing signal includes:
接收所述上升沿和所述下降沿,根据所述上升沿及下降沿,触发所述摄像机上的自动聚焦镜头,对所述摄像机进行聚焦。The rising edge and the falling edge are received, and according to the rising edge and the falling edge, an auto-focus lens on the camera is triggered to focus the camera.
优选地,该方法进一步包括:设置所述变量num的最大值,;Preferably, the method further includes: setting the maximum value of the variable num;
在检测出所述摄像机的焦距及位置中的至少一个发生改变之后,并在将所述变量num的当前值增加预定值之前,进一步包括:判断所述变量num的当前值是否达到所述最大值,如果是,忽略该次改变,继续执行所述实时检测摄像机的焦距及位置中的至少一个是否发生改变,如果否,则继续执行所述将所述变量num的当前值增加预定值。After detecting that at least one of the focal length and position of the camera changes, and before increasing the current value of the variable num by a predetermined value, further comprising: judging whether the current value of the variable num reaches the maximum value , if yes, ignore the change, and continue to execute the real-time detection of whether at least one of the focal length and position of the camera has changed, and if not, continue to execute the step of increasing the current value of the variable num by a predetermined value.
优选地,所述检测到所述焦距及位置中的至少一个发生了改变之后,并在所述将所述变量num的当前值增加预定值之前进一步包括:Preferably, after detecting that at least one of the focal length and position has changed, and before increasing the current value of the variable num by a predetermined value, the method further includes:
判断所述摄像机的焦距及位置中的至少一个发生改变时,所述摄像机是否处于聚焦状态,如果是,忽略本次改变,继续执行所述实时检测摄像机的焦距及位置中的至少一个是否发生改变,如果否,继续执行所述将所述变量num的当前值增加预定值。Determine whether the camera is in a focused state when at least one of the focal length and position of the camera changes, and if so, ignore this change, and continue to perform the real-time detection of whether at least one of the focal length and position of the camera changes , if not, continue to execute the step of increasing the current value of the variable num by a predetermined value.
本发明一个实施例还提供了一种自动聚焦的装置,包括:An embodiment of the present invention also provides an automatic focusing device, including:
第一设置单元,用于设置变量num,并设置所述变量num的初始值为第一特征值;The first setting unit is used to set the variable num, and set the initial value of the variable num to the first characteristic value;
检测单元,用于实时检测摄像机的焦距及位置中的至少一个是否发生改变;a detection unit, configured to detect in real time whether at least one of the focal length and the position of the camera changes;
计算单元,用于根据所述检测单元的检测结果,如果是,将所述第一设置单元设置的所述变量num的当前值增加预定值;A calculation unit, configured to, according to the detection result of the detection unit, if yes, increase the current value of the variable num set by the first setting unit by a predetermined value;
第一判断单元,用于实时判断所述变量num的当前值是否为所述第一特征值;a first judging unit, configured to judge in real time whether the current value of the variable num is the first characteristic value;
信号形成器,用于根据所述第一判断单元的判断结果,如果否,形成聚焦信号,并将所述num的当前值减去所述预定值;A signal generator, configured to form a focus signal according to the judgment result of the first judgment unit, if not, and subtract the predetermined value from the current value of num;
控制器,用于根据所述信号形成器形成的聚焦信号,控制所述摄像机进行聚焦。The controller is configured to control the camera to focus according to the focus signal formed by the signal former.
优选地,所述信号形成器为PWM信号发生器;Preferably, the signal generator is a PWM signal generator;
所述PWM信号发生器与所述第一判断单元相连,预先设定所述PWM信号发生器的低电平时间和高电平时间,当所述第一判断单元判断所述变量num的当前值不为所述第一特征值时,所述PWM信号发生器开始计时,并形成一个低电平的脉冲,当计时时长等于所述低电平时间时,所述脉冲由低电平转换为高电平,形成一个上升沿,将所述上升沿发送给所述控制器,当计时时长等于所述低电平时间与所述高电平时间之和时,所述脉冲由高电平转换成低电平,形成一个下降沿,将所述下降沿发送给所述控制器,由所述上升沿及所述下降沿组成一个聚焦信号。The PWM signal generator is connected to the first judging unit, and the low level time and the high level time of the PWM signal generator are preset, when the first judging unit judges the current value of the variable num When it is not the first characteristic value, the PWM signal generator starts timing and forms a low-level pulse, and when the timing duration is equal to the low-level time, the pulse is converted from low level to high Level, forming a rising edge, sending the rising edge to the controller, when the timing duration is equal to the sum of the low level time and the high level time, the pulse is converted from high level to low level, forming a falling edge, sending the falling edge to the controller, and forming a focusing signal by the rising edge and the falling edge.
优选地,所述控制器为继电器;Preferably, the controller is a relay;
所述继电器分别与所述PWM信号发生器及所述摄像机上的自动聚焦镜头相连,其中所述自动聚焦镜头通过第一触发导线及第二触发导线与所述继电器相连,当所述继电器接收到所述PWM信号发生器发送的上升沿时,所述继电器将所述第一触发导线与所述第二触发导线短接,当所述继电器接收到所述PWM信号发生器发送的下降沿后,所述继电器将所述第一触发导线与所述第二触发导线断开,所述第一触发导线与所述第二触发导线短接后再次断开,形成一个触发信号,所述自动聚焦镜头接收到所述触发信号后,进行一次自动聚焦。The relay is connected to the autofocus lens on the PWM signal generator and the camera respectively, wherein the autofocus lens is connected to the relay through a first trigger wire and a second trigger wire, when the relay receives When the rising edge sent by the PWM signal generator, the relay short-circuits the first trigger wire and the second trigger wire, and when the relay receives the falling edge sent by the PWM signal generator, The relay disconnects the first trigger wire from the second trigger wire, the first trigger wire and the second trigger wire are short-circuited and disconnected again to form a trigger signal, and the autofocus lens After receiving the trigger signal, an automatic focus is performed.
优选地,该装置进一步包括:第二设置单元及第二判断单元;Preferably, the device further includes: a second setting unit and a second judging unit;
所述第二设置单元,用于设置所述变量num的最大值;The second setting unit is configured to set the maximum value of the variable num;
所述第二判断单元,用于所述检测单元检测出所述摄像机的焦距及位置中的至少一个发生改变之后,判断所述变量num的当前值是否达到所述最大值,如果是,忽略该次改变,继续由所述检测单元实时检测摄像机的焦距及位置中的至少一个是否发生改变,如果否,则由所述计算单元将所述将所述第一设置单元设置的所述变量num的当前值增加预定值。The second judging unit is configured to judge whether the current value of the variable num reaches the maximum value after the detection unit detects that at least one of the focal length and the position of the camera has changed, and if so, ignore the change, continue to detect whether at least one of the focal length and position of the camera changes in real time by the detection unit, if not, the calculation unit will set the variable num set by the first setting unit to The current value is increased by a predetermined value.
优选地,该装置进一步包括:第三判断单元;Preferably, the device further includes: a third judging unit;
所述第三判断单元,分别与所述检测单元及所述计算单元相连,当所述检测单元检测到所述摄像机的焦距及位置中的至少一个发生改变时,第三判断单元判断该改变发生时所述摄像机是否处于聚焦状态,如果是,由所述检测单元继续实时检测摄像机的焦距及位置中的至少一个是否发生改变,如果否,由所述计算单元将所述变量num的当前值增加预定值。The third judgment unit is connected to the detection unit and the calculation unit respectively, and when the detection unit detects that at least one of the focal length and position of the camera changes, the third judgment unit judges that the change occurs When the camera is in focus, if so, the detection unit continues to detect whether at least one of the focal length and position of the camera changes in real time, if not, the calculation unit increases the current value of the variable num predetermined value.
本发明实施例提供了一种自动聚焦的方法及装置,预先设置变量num,并将其初始值设置为第一特征值,实时检测摄像机的焦距或位置是否发生改变,如果发生改变,对第一特征值增加一个预定值,实时判断变量num的当前值是否等于第一特征值,如果否,则形成聚焦信号,并将变量num的当前值减去一个预定值,根据形成的聚焦信号,控制摄像机进行一次聚焦,这样,每次摄像机的镜头变倍或云台转动,使摄像机的焦距或位置发生改变时,对应的使变量num增加一个预定值,使变量num的当前值不等于第一特征值,触发摄像机进行聚焦,并在聚焦信号发出后从变量num中减去一个预定值,保证每次摄像机的焦距或位置发生改变之后都触发一次聚焦,无需人工操作,从而实现摄像机的自动聚焦。The embodiment of the present invention provides a method and device for autofocus. The variable num is set in advance, and its initial value is set as the first characteristic value to detect whether the focal length or position of the camera changes in real time. If there is a change, the first Add a predetermined value to the characteristic value, judge in real time whether the current value of the variable num is equal to the first characteristic value, if not, then form a focus signal, and subtract a predetermined value from the current value of the variable num, and control the camera according to the formed focus signal Carry out a focus, so that each time the lens of the camera zooms or the pan/tilt rotates to change the focal length or position of the camera, the variable num is correspondingly increased by a predetermined value, so that the current value of the variable num is not equal to the first characteristic value , trigger the camera to focus, and subtract a predetermined value from the variable num after the focus signal is sent out, so as to ensure that a focus is triggered every time the focal length or position of the camera changes, without manual operation, so as to realize the automatic focus of the camera.
附图说明Description of drawings
图1是本发明一个实施例提供的一种自动聚焦的方法流程图;FIG. 1 is a flow chart of an automatic focusing method provided by an embodiment of the present invention;
图2是本发明另一个实施例提供的一种自动聚焦的方法流程图;Fig. 2 is a flow chart of an automatic focusing method provided by another embodiment of the present invention;
图3是本发明又一个实施例提供的一种自动聚焦的方法流程图;Fig. 3 is a flow chart of an automatic focusing method provided by another embodiment of the present invention;
图4是本发明一个实施例提供的一种自动聚焦的装置示意图。Fig. 4 is a schematic diagram of an automatic focusing device provided by an embodiment of the present invention.
具体实施方式detailed description
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述。显然,所描述的实施例仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the drawings in the embodiments of the present invention. Apparently, the described embodiments are only some of the embodiments of the present invention, but not all of them. Based on the embodiments of the present invention, all other embodiments obtained by persons of ordinary skill in the art without making creative efforts belong to the protection scope of the present invention.
如图1所示,本发明一个实施例提供了一种自动聚焦的方法,包括:As shown in Figure 1, an embodiment of the present invention provides an automatic focusing method, including:
步骤101:设置变量num,并设置所述变量num的初始值为第一特征值;Step 101: Set the variable num, and set the initial value of the variable num to the first eigenvalue;
步骤102:实时检测摄像机的焦距及位置中的至少一个是否发生改变,如果是,执行步骤103,否则继续执行步骤102;Step 102: Real-time detection of whether at least one of the focal length and position of the camera has changed, if yes, execute step 103, otherwise continue to execute step 102;
步骤103:将所述变量num的当前值增加预定值;Step 103: increasing the current value of the variable num by a predetermined value;
步骤104:实时判断所述变量num的当前值是否为所述第一特征值,如果是,继续执行步骤104,否则执行步骤105;Step 104: judge in real time whether the current value of the variable num is the first characteristic value, if yes, continue to execute step 104, otherwise execute step 105;
步骤105:形成聚焦信号,并将所述num的当前值减去所述预定值;Step 105: forming a focus signal, and subtracting the predetermined value from the current value of num;
步骤106:根据所述聚焦信号,控制所述摄像机进行聚焦。Step 106: Control the camera to focus according to the focus signal.
本发明实施例提供了一种自动聚焦的方法,预先设置变量num,并将其初始值设置为第一特征值,实时检测摄像机的焦距或位置是否发生改变,如果发生改变,对第一特征值增加一个预定值,实时判断变量num的当前值是否等于第一特征值,如果否,则形成聚焦信号,并将变量num的当前值减去一个预定值,根据形成的聚焦信号,控制摄像机进行一次聚焦,这样,每次摄像机的镜头变倍或云台转动,使摄像机的焦距或位置发生改变时,对应的使变量num增加一个预定值,使变量num的当前值不等于第一特征值,触发摄像机进行聚焦,并在聚焦信号发出后从变量num中减去一个预定值,保证每次摄像机的焦距或位置发生改变之后都触发一次聚焦,无需人工操作,从而实现摄像机的自动聚焦。The embodiment of the present invention provides a method for automatic focusing. The variable num is set in advance, and its initial value is set as the first characteristic value to detect whether the focal length or position of the camera changes in real time. If there is a change, the first characteristic value Add a predetermined value, judge in real time whether the current value of the variable num is equal to the first characteristic value, if not, then form a focus signal, and subtract a predetermined value from the current value of the variable num, and control the camera once according to the formed focus signal Focusing, in this way, every time the lens of the camera zooms or the pan/tilt rotates to change the focal length or position of the camera, the variable num is correspondingly increased by a predetermined value, so that the current value of the variable num is not equal to the first characteristic value, triggering The camera focuses, and subtracts a predetermined value from the variable num after the focus signal is sent out, so as to ensure that a focus is triggered every time the focal length or position of the camera changes, without manual operation, so as to realize the automatic focus of the camera.
在本发明一个实施例中,聚焦信号是通过PWM信号发生器形成的,预先设定PWM信号发生器的低电平时间和高电平时间,当判断变量num的当前值不等于第一特征值时,PWM信号发生器开始计时,并形成一个低电平的脉冲,当计时时长等于低电平时间时,脉冲由低电平转换为高电平,形成一个上升沿,当计时时长等于低电平时间与高电平时间之和时,脉冲由高电平转换为低电平,形成一个下降沿,继电器通过上升沿及下降沿控制摄像机上的自动聚焦镜头进行自动聚焦,由于不同的继电器及自动聚焦镜头,其相应时间也不同,通过调整高电平时间及低电平时间,可以适应不同的继电器及自动聚焦镜头,实现各种型号摄像机的自动聚焦。In one embodiment of the present invention, the focus signal is formed by a PWM signal generator, and the low level time and high level time of the PWM signal generator are preset, when the current value of the judgment variable num is not equal to the first characteristic value , the PWM signal generator starts timing and forms a low-level pulse. When the timing duration is equal to the low-level time, the pulse is converted from low level to high level to form a rising edge. When the timing duration is equal to the low-level time When the sum of the flat time and the high level time, the pulse is converted from high level to low level, forming a falling edge, the relay controls the autofocus lens on the camera to automatically focus through the rising edge and falling edge, due to different relays and The corresponding time of the auto-focus lens is also different. By adjusting the high-level time and low-level time, it can adapt to different relays and auto-focus lenses, and realize the auto-focus of various types of cameras.
在本发明一个实施例中,摄像机的自动聚焦控制是通过继电器实现的,当继电器接收到PWM信号发生器发送的上升沿时,使自动聚焦镜头的两根触发导线短接,经过一个高电平时间,当继电器接收到PWM信号发生器发送的下降沿时,使自动聚焦镜头的两根触发导线断开,自动聚焦镜头的两根触发导线短接后再次断开,形成一个触发信号,自动聚焦镜头接收到该触发信号后进行一次自动聚焦,从而实现根据电平信号与触发信号之间的转换。In one embodiment of the present invention, the automatic focus control of the camera is realized by a relay. When the relay receives the rising edge sent by the PWM signal generator, the two trigger wires of the automatic focus lens are short-circuited, and a high level Time, when the relay receives the falling edge sent by the PWM signal generator, the two trigger wires of the auto-focus lens are disconnected, and the two trigger wires of the auto-focus lens are short-circuited and then disconnected again to form a trigger signal to automatically focus After receiving the trigger signal, the lens performs an automatic focus, so as to realize the conversion between the level signal and the trigger signal.
在本发明一个实施例中,可以设置变量num的最大值,当检测到摄像机的焦距或位置发生改变后,首先判断变量num的当前值是否到达其最大值,如果没有达到,则对变量num的当前值增加一个预定值,如果已经达到其最大值,则该次焦距或位置发生的改变将被忽略,从而避免连续多次改变焦距或位置,需要持续进行多次自动聚焦,影响摄像机的拍摄效果。In one embodiment of the present invention, the maximum value of the variable num can be set. When the focal length or position of the camera is detected to be changed, it is first judged whether the current value of the variable num reaches its maximum value. The current value is increased by a predetermined value. If the maximum value has been reached, the change of the focal length or position will be ignored, so as to avoid continuous multiple changes of the focal length or position, which requires continuous auto-focusing for multiple times, which will affect the shooting effect of the camera. .
在本发明一个实施例中,在检测到摄像机的焦距或位置发生改变之后,可以进一步判断本次改变发生时,摄像机是否处于聚焦状态,如果是,则忽略本次改变,继续检测摄像机的焦距及位置是否改变,如果否,将对变量num的当前值增加预定值,这样,在摄像机处于聚焦状态时,摄像机的焦距或位置发生的改变将被忽略,由于在当前聚焦完成后,摄像机拍摄的图像已经处于清晰状态,针对处于同一状态的摄像机重复进行聚焦,增加自动聚焦镜头的工作负荷,而且影响摄像机的拍摄效果。In one embodiment of the present invention, after detecting that the focal length or position of the camera has changed, it can be further judged whether the camera is in a focused state when the change occurs. If so, ignore this change and continue to detect the focal length and position of the camera. Whether the position has changed, if not, will add a predetermined value to the current value of the variable num, so that when the camera is in focus, the change of the focal length or position of the camera will be ignored, because after the current focus is completed, the image captured by the camera If it is already in a clear state, repeatedly focusing on the camera in the same state will increase the workload of the auto-focus lens and affect the shooting effect of the camera.
为使本发明的目的、技术方案和优点更加清楚,下面结合附图及具体实施例对本发明作进一步地详细描述。In order to make the purpose, technical solution and advantages of the present invention clearer, the present invention will be further described in detail below in conjunction with the accompanying drawings and specific embodiments.
如图2所示,本发明一个实施例提供了一种自动聚焦的方法,包括:As shown in Figure 2, an embodiment of the present invention provides an automatic focusing method, including:
步骤201:设置变量num,并将其初始值设为0。Step 201: Set the variable num, and set its initial value to 0.
在本发明一个实施例中,定义一个整数型变量num,并规定其初始值为0,用于记录摄像机的焦距或位置发生改变的次数。In one embodiment of the present invention, an integer variable num is defined and its initial value is 0, which is used to record the number of times that the focal length or position of the camera changes.
步骤202:设置变量num的最大值。Step 202: Set the maximum value of the variable num.
在本发明一个实施例中,进一步设置变量num的最大值,当变量num达到最大值后,不允许其继续增大。例如,将变量num的最大值设置为20。In an embodiment of the present invention, the maximum value of the variable num is further set, and when the variable num reaches the maximum value, it is not allowed to continue to increase. For example, set the maximum value of the variable num to 20.
步骤203:实时检测摄像机的焦距或位置是否发生改变,如果是,执行步骤204,否则继续执行步骤203。Step 203: Detect in real time whether the focal length or position of the camera changes, if yes, execute step 204, otherwise continue to execute step 203.
在本发明一个实施例中,如果摄像机的镜头发生变倍或云台发生转动,对应地导致摄像机的焦距或位置发生改变,实时检测摄像机的焦距或位置是否发生改变,如果焦距或位置发生了改变,需要对摄像机重新进行聚焦,对应的执行步骤204,如果焦距或位置没有发生改变,则需要继续对摄像机的焦距及位置进行监控,对应的继续执行步骤203。In one embodiment of the present invention, if the lens of the camera zooms or the pan/tilt rotates, the focal length or position of the camera changes accordingly, and it is detected in real time whether the focal length or position of the camera changes, and if the focal length or position changes , the camera needs to be refocused, correspondingly execute step 204 , if the focal length or position does not change, then need to continue monitoring the focal length and position of the camera, correspondingly continue to execute step 203 .
步骤204:判断变量num的当前值是否等于其最大值,如果是,执行步骤203,否则执行步骤205。Step 204: Judging whether the current value of the variable num is equal to its maximum value, if yes, go to step 203, otherwise go to step 205.
在本发明一个实施例中,在检测到摄像机的焦距或位置发生改变后,首先需要判断变量num的当前值是否等于其最大值,如果是,变量num不允许再增加,避免连续调整摄像机的焦距或位置时,重复对摄像机进行聚焦,本次焦距或位置的改变被忽略,继续执行步骤203,如果否,需要针对本次改变进行聚焦,对应的执行步骤205。例如,如果变量num的当前值为20,检测到摄像机的焦距发生改变时,忽略本次聚焦发生的改变,变量num仍为20,继续对摄像机的焦距及位置进行监控,对应的执行步骤203,如果变量num的当前值为10,检测到摄像机的位置发生改变时,由于变量num的当前值没有超过其最大值,本次位置的改变不能被忽略,需要对本次改变进行记录,相应的执行步骤205。In one embodiment of the present invention, after detecting that the focal length or position of the camera changes, it is first necessary to judge whether the current value of the variable num is equal to its maximum value, and if so, the variable num is not allowed to increase again, so as to avoid continuously adjusting the focal length of the camera or position, repeat focusing on the camera, ignore this change of focal length or position, continue to step 203, if not, need to focus on this change, and perform step 205 accordingly. For example, if the current value of the variable num is 20, when it is detected that the focal length of the camera has changed, ignore the change of this focus, the variable num is still 20, continue to monitor the focal length and position of the camera, and execute step 203 accordingly, If the current value of the variable num is 10, when the position of the camera is detected to change, since the current value of the variable num does not exceed its maximum value, the change of this position cannot be ignored, and the change needs to be recorded and executed accordingly Step 205.
步骤205:对变量num的当前值增加1。Step 205: Add 1 to the current value of the variable num.
在本发明一个实施例中,当检测到摄像机的焦距或位置发生改变,并且变量num的当前值不等于其最大值时,需要针对本次改变进行一次聚焦,对变量num的当前值增加1,记录需要进行聚焦的次数。In one embodiment of the present invention, when it is detected that the focal length or position of the camera changes, and the current value of the variable num is not equal to its maximum value, it is necessary to perform a focusing for this change, and the current value of the variable num is increased by 1, The number of times focusing was required was recorded.
步骤206:实时判断变量num的当前值是否等于0,如果是,继续执行步骤206,否则执行步骤207。Step 206: judge in real time whether the current value of the variable num is equal to 0, if yes, continue to execute step 206, otherwise execute step 207.
在本发明一个实施例中,实时对变量num的当前值进行判断,判断其是否等于其初始值0,如果是,说明摄像机无需进行聚焦,应继续处于等待状态,响应的继续执行步骤206,如果否,说明摄像机的焦距或位置发生改变后还没有进行聚焦,需要对其进行聚焦,响应的执行步骤207。In one embodiment of the present invention, the current value of the variable num is judged in real time to determine whether it is equal to its initial value 0, if yes, it means that the camera does not need to focus and should continue to be in a waiting state, and the response continues to execute step 206, if If no, it means that the focal length or position of the camera has not been focused, and it needs to be focused, and step 207 is executed in response.
步骤207:形成聚焦信号,并将变量num的当前值减去1。Step 207: Form a focus signal, and subtract 1 from the current value of the variable num.
在本发明一个实施例中,聚焦信号是通过PWM信号发生器形成的,根据摄像机的不同,预先设置PWM信号发生器的低电平时间LOWTIME和高电平时间HIGHTIME,当判断变量num的当前值不为0时,PWM信号发生器开始计时,同时PWM信号发生器形成低电平的脉冲,当计时时长等于LOWTIME时,脉冲由低电平转换为高电平,形成一个上升沿,上升沿形成后被发送给继电器,继续计时,当计时时长等于LOWTIME与HIGHTIME之和时,脉冲由高电平转换为低电平,形成一个下降沿,下降沿形成后被发送给继电器,停止计时,聚焦信号就是由一个上升沿和一个下降沿组成的,当聚焦信号发送完毕后,对应的将变量num的当前值减去1,说明已经进行了一次聚焦,剩余的需要聚焦的次数对应的减去1次。例如,预先设置PWM信号发生器的低电平时间LOWTIME为10毫秒,高电平时间HIGHTIME为20毫秒,当变量num的当前值为3时,PWM信号发生器开始计时,同时形成一个低电平的脉冲,当计时时长为10毫秒时,脉冲由低电平转换为高电平,形成一个上升沿,将该上升沿发送给继电器,当计时时长等于30毫秒时,脉冲由高电平转换为低电平,形成一个下降沿,将该下降沿发送给继电器,停止计时,并将变量num的当前值减去1后成为2。In one embodiment of the present invention, the focus signal is formed by a PWM signal generator. According to different cameras, the low level time LOWTIME and the high level time HIGHTIME of the PWM signal generator are preset. When judging the current value of the variable num When it is not 0, the PWM signal generator starts timing, and at the same time the PWM signal generator forms a low-level pulse. When the timing duration is equal to LOWTIME, the pulse is converted from low level to high level, forming a rising edge, and the rising edge forms Then it is sent to the relay to continue timing. When the timing is equal to the sum of LOWTIME and HIGHTIME, the pulse is converted from high level to low level to form a falling edge. After the falling edge is formed, it is sent to the relay to stop timing and focus on the signal It is composed of a rising edge and a falling edge. When the focus signal is sent, the current value of the variable num is correspondingly subtracted by 1, indicating that a focus has been performed, and the remaining number of times to be focused is correspondingly subtracted by 1. . For example, the low level time LOWTIME of the PWM signal generator is preset to 10 milliseconds, and the high level time HIGHTIME is 20 milliseconds. When the current value of the variable num is 3, the PWM signal generator starts timing and forms a low level at the same time The pulse, when the timing is 10 milliseconds, the pulse is converted from low level to high level, forming a rising edge, the rising edge is sent to the relay, when the timing is equal to 30 milliseconds, the pulse is converted from high level to Low level, forming a falling edge, sending the falling edge to the relay, stopping timing, and subtracting 1 from the current value of the variable num to become 2.
步骤208:根据聚焦信号,控制摄像机的自动聚焦镜头进行聚焦。Step 208: Control the auto-focus lens of the camera to focus according to the focus signal.
在本发明一个实施例中,通过继电器控制自动聚焦镜头进行聚焦,当继电器收到PWM信号发生器发送来的上升沿后,将自动聚焦镜头的两根触发导线短接,当继电器收到PWM信号发生器发送来的下降沿后,将自动聚焦镜头的两根触发导线断开,自动聚焦镜头的两根触发导线短接后再断开,形成一个触发信号,自动聚焦镜头根据该触发信号运行,实现摄像机的聚焦。例如,PWM信号发生器形成低电平脉冲的10毫秒是继电器的响应时间,当继电器接收到上升沿后,将自动聚焦镜头的两根触发导线短接,经过20毫秒,继电器接收到下降沿后,将自动聚焦镜头的两根触发导线断开,这20毫秒是自动聚焦镜头的响应时间,两根触发导线短接后又断开,形成一个触发信号,该触发信号使自动聚焦镜头开始运作,完成对摄像机的聚焦。In one embodiment of the present invention, the auto-focus lens is controlled by a relay to focus. When the relay receives the rising edge sent by the PWM signal generator, the two trigger wires of the auto-focus lens are short-circuited. When the relay receives the PWM signal After the falling edge sent by the generator, the two trigger wires of the auto-focus lens are disconnected, the two trigger wires of the auto-focus lens are short-circuited and then disconnected to form a trigger signal, and the auto-focus lens operates according to the trigger signal. Achieve camera focus. For example, 10 milliseconds when the PWM signal generator forms a low-level pulse is the response time of the relay. When the relay receives the rising edge, short the two trigger wires of the auto-focus lens. After 20 milliseconds, the relay receives the falling edge , Disconnect the two trigger wires of the auto-focus lens. The 20 milliseconds is the response time of the auto-focus lens. The two trigger wires are short-circuited and then disconnected to form a trigger signal, which makes the auto-focus lens start to operate. Finish focusing the camera.
如图3所示,本发明一个实施例提供了一种自动聚焦的方法,包括:As shown in Figure 3, an embodiment of the present invention provides an automatic focusing method, including:
步骤301:设置变量num,并将其初始值设为0。Step 301: Set the variable num, and set its initial value to 0.
在本发明一个实施例中,定义一个整数型变量num,并规定其初始值为0,用于记录摄像机的焦距或位置发生改变的次数。In one embodiment of the present invention, an integer variable num is defined and its initial value is 0, which is used to record the number of times that the focal length or position of the camera changes.
步骤302:实时检测摄像机的焦距或位置是否发生改变,如果是,执行步骤303,否则继续执行步骤302。Step 302: Detect in real time whether the focal length or position of the camera changes, if yes, execute step 303, otherwise continue to execute step 302.
在本发明一个实施例中,如果摄像机的镜头发生变倍或云台发生转动,对应地导致摄像机的焦距或位置发生改变,实时检测摄像机的焦距或位置是否发生改变,如果焦距或位置发生了改变,需要对摄像机重新进行聚焦,对应的执行步骤303,如果焦距或位置没有发生改变,则需要继续对摄像机的焦距及位置进行监控,对应的继续执行步骤302。In one embodiment of the present invention, if the lens of the camera zooms or the pan/tilt rotates, the focal length or position of the camera changes accordingly, and it is detected in real time whether the focal length or position of the camera changes, and if the focal length or position changes , the camera needs to be refocused, correspondingly execute step 303 , if the focal length or position does not change, it is necessary to continue monitoring the focal length and position of the camera, correspondingly continue to execute step 302 .
步骤303:判断本次焦距或位置改变时摄像机是否处于聚焦状态,如果是,执行步骤302,否则执行步骤304。Step 303: Determine whether the camera is in focus when the focal length or position is changed this time, if yes, execute step 302, otherwise execute step 304.
在本发明一个实施例中,由于在摄像机聚焦的过程中,如果摄像机的焦距或位置发生改变,那本次聚焦会消除此次焦距或位置改变对摄像机拍摄画面的影响,因而判断焦距或位置改变是否发生在摄像机的聚焦过程中,如果是,本次焦距或位置改变产生的影响已经消除,无需单独进行聚焦,相应的执行步骤302,如果否,还没有对本次焦距或位置的改变进行重新聚焦,对应的执行步骤303。In one embodiment of the present invention, since during the process of camera focusing, if the focal length or position of the camera changes, then this focusing will eliminate the influence of this change of focal length or position on the picture taken by the camera, thus judging the change of focal length or position Whether it happened during the focusing process of the camera, if yes, the impact of this change of focal length or position has been eliminated, and there is no need to focus separately, and correspondingly execute step 302, if no, the change of this focal length or position has not been re-executed focus, correspondingly execute step 303 .
步骤304:对变量num的当前值增加1。Step 304: Add 1 to the current value of the variable num.
本发明一个实施例中,当检测到摄像机的焦距或位置发生改变,并且该次焦距或位置改变不是发生在摄像机聚焦的过程中,需要针对本次改变进行一次聚焦,对变量num的当前值增加1,记录需要进行聚焦的次数。In one embodiment of the present invention, when it is detected that the focal length or position of the camera changes, and the focal length or position change does not occur during the focusing process of the camera, a focus needs to be performed for this change, and the current value of the variable num is increased 1. Record the number of times you need to focus.
步骤305:实时判断变量num的当前值是否等于0,如果是,继续执行步骤305,否则执行步骤306。Step 305: judge in real time whether the current value of the variable num is equal to 0, if yes, continue to execute step 305, otherwise execute step 306.
步骤306:形成聚焦信号,并将变量num的当前值减去1。Step 306: Form a focus signal, and subtract 1 from the current value of the variable num.
步骤307:根据聚焦信号,控制摄像机的自动聚焦镜头进行聚焦。Step 307: Control the auto-focus lens of the camera to focus according to the focus signal.
需要说明的是,本发明实施例中步骤305至步骤307,与图2所示的实施例中步骤206至步骤208依次对应相同,在此不再重复描述。It should be noted that step 305 to step 307 in the embodiment of the present invention are the same as step 206 to step 208 in the embodiment shown in FIG. 2 , and the description will not be repeated here.
如图4所示,本发明一个实施例提供了一种自动聚焦的装置,包括:第一设置单元401、检测单元402、计算单元403、第一判断单元404、信号形成器405及控制器406;As shown in Figure 4, an embodiment of the present invention provides an automatic focusing device, including: a first setting unit 401, a detection unit 402, a calculation unit 403, a first judgment unit 404, a signal generator 405 and a controller 406 ;
第一设置单元401,用于设置变量num,并设置所述变量num的初始值为第一特征值;The first setting unit 401 is configured to set the variable num, and set the initial value of the variable num to the first characteristic value;
检测单元402,用于实时检测摄像机的焦距及位置中的至少一个是否发生改变;A detection unit 402, configured to detect in real time whether at least one of the focal length and the position of the camera changes;
计算单元403,用于根据所述检测单元402的检测结果,如果是,将所述第一设置单元401设置的所述变量num的当前值增加预定值;The calculation unit 403 is configured to, according to the detection result of the detection unit 402, if yes, increase the current value of the variable num set by the first setting unit 401 by a predetermined value;
第一判断单元404,用于实时判断所述变量num的当前值是否为所述第一特征值;A first judging unit 404, configured to judge in real time whether the current value of the variable num is the first feature value;
信号形成器405,用于根据所述第一判断单元的判断结果,如果否,形成聚焦信号,并将所述num的当前值减去所述预定值;A signal generator 405, configured to, according to the judgment result of the first judgment unit, if not, form a focus signal, and subtract the predetermined value from the current value of num;
控制器406,用于根据所述信号形成器405形成的聚焦信号,控制所述摄像机进行聚焦。The controller 406 is configured to control the camera to focus according to the focus signal formed by the signal former 405 .
在本发明一个实施例中,信号形成器405可以为PWM信号发生器,PWM信号发生器与所述第一判断单元404相连,预先根据摄像机及控制器的型号,设定PWM信号发生器的低电平时间和高电平时间,当第一判断单元404判断变量num的当前值不为第一特征值时,PWM信号发生器开始计时,并形成一个低电平的脉冲,当计时时长等于所述低电平时间时,所述脉冲由低电平转换为高电平,形成一个上升沿,将所述上升沿发送给所述控制器,当计时时长等于所述低电平时间与所述高电平时间之和时,所述脉冲由高电平转换成低电平,形成一个下降沿,将所述下降沿发送给所述控制器,由所述上升沿及所述下降沿组成一个聚焦信号。例如,第一特征值为0,根据当前摄像机的型号及控制器的型号,设定低电平时间为10毫秒,高电平时间为20毫秒,当第一判断单元404判断变量num的当前值不0时,PWM信号发生器开始计时,并形成一个低电平的脉冲,当计时时长等于10毫秒时,该脉冲由低电平转换为高电平,形成一个上升沿,继续计时,将计时时长等于30毫秒时,该脉冲由高电平转换成为低电平,形成一个下降沿,停止计时,形成了由上升沿和下降沿组成的聚焦信号。In one embodiment of the present invention, the signal generator 405 can be a PWM signal generator, and the PWM signal generator is connected to the first judging unit 404, and the low voltage of the PWM signal generator is set in advance according to the models of the camera and the controller. Level time and high level time, when the first judging unit 404 judges that the current value of the variable num is not the first characteristic value, the PWM signal generator starts timing and forms a low-level pulse. When the low level time is mentioned, the pulse is converted from low level to high level to form a rising edge, and the rising edge is sent to the controller. When the timing is equal to the low level time and the During the sum of the high level time, the pulse is converted from high level to low level to form a falling edge, and the falling edge is sent to the controller, and a pulse is composed of the rising edge and the falling edge Focus on the signal. For example, the first characteristic value is 0, according to the model of the current camera and the model of the controller, the low level time is set to be 10 milliseconds, and the high level time is 20 milliseconds, when the first judging unit 404 judges the current value of the variable num When it is not 0, the PWM signal generator starts timing and forms a low-level pulse. When the timing duration is equal to 10 milliseconds, the pulse is converted from low level to high level to form a rising edge and continues timing. When the duration is equal to 30 milliseconds, the pulse is converted from a high level to a low level, forming a falling edge, stopping timing, and forming a focusing signal composed of a rising edge and a falling edge.
在本发明一个实施例中,控制器406可以为继电器,继电器分别与PWM信号发生器及自动聚焦镜头相连,其中自动焦距镜头通过其两根触发导线与继电器相连,PWM信号发生器形成低电平脉冲过程中,继电器处于响应阶段,当继电器接收到PWM信号发生器发送的上升沿时,继电器将自动聚焦镜头的两根触发导线短接,PWM信号发生器形成高电平脉冲过程中,自动聚焦镜头处于响应阶段,当继电器接收到PWM信号发生器发送的下降沿时,继电器将自动聚焦镜头的两根触发导线断开,自动聚焦镜头的两根触发导线短接后再次断开,形成一个触发型号,自动聚焦镜头接收到该信号后开始运行,实现摄像机的自动聚焦。例如,自动聚焦镜头通过触发导线1及触发导线2与继电器相连,PWM信号发生器的低电平时间为10毫秒,高电平时间为20毫秒,PWM信号发生器形成低电平脉冲的10毫秒时间,是继电器的响应时间,当PWM信号发生器将低电平脉冲转换为高电平脉冲,形成上升沿后,继电器接收到该上升沿后,将自动聚焦镜头的触发导线1与触发导线2短接,PWM信号发生器形成噶电平脉冲的20毫秒时间,是自动聚焦镜头的相应时间,当PWM信号发生器将高电平脉冲转换为低电平脉冲,形成下降沿后,继电器接收到该下降沿后,将自动聚焦镜头的触发导线1与触发导线2断开,触发导线1与触发导线2短接20毫秒后再断开,形成一个触发信号,自动聚焦镜头接收到该触发信号后,其内部电动元件开始运行,实现对摄像机的自动聚焦。In one embodiment of the present invention, the controller 406 can be a relay, and the relay is connected to the PWM signal generator and the autofocus lens respectively, wherein the autofocus lens is connected to the relay through its two trigger wires, and the PWM signal generator forms a low level During the pulse process, the relay is in the response stage. When the relay receives the rising edge sent by the PWM signal generator, the relay will short-circuit the two trigger wires of the auto-focus lens. During the high-level pulse process of the PWM signal generator, the auto-focus The lens is in the response stage. When the relay receives the falling edge sent by the PWM signal generator, the relay will disconnect the two trigger wires of the auto-focus lens, and the two trigger wires of the auto-focus lens will be shorted and disconnected again to form a trigger Model, the auto-focus lens starts to operate after receiving this signal to realize the auto-focus of the camera. For example, the auto-focus lens is connected to the relay through trigger wire 1 and trigger wire 2, the low level time of the PWM signal generator is 10 milliseconds, the high level time is 20 milliseconds, and the PWM signal generator forms a low level pulse of 10 milliseconds Time is the response time of the relay. When the PWM signal generator converts the low-level pulse into a high-level pulse to form a rising edge, the relay will connect the trigger wire 1 and trigger wire 2 of the autofocus lens after receiving the rising edge. Short-circuit, the 20 millisecond time for the PWM signal generator to form a Karma-level pulse is the corresponding time for the auto-focus lens. When the PWM signal generator converts the high-level pulse into a low-level pulse and forms a falling edge, the relay receives After the falling edge, disconnect trigger wire 1 and trigger wire 2 of the auto-focus lens, short-circuit trigger wire 1 and trigger wire 2 for 20 milliseconds and then disconnect to form a trigger signal. After the auto-focus lens receives the trigger signal , its internal electric components start to run to realize the automatic focus of the camera.
在本发明一个实施例中,该装置可以进一步包括第二设置单元和第二判断单元,第二设置单元用于设置变量num的最大值,第二判断单元用于在检测单元402检测到摄像机的焦距或位置发生改变后,判断变量num的当前值是否达到其最大值,如果达到了,那么本次焦距或位置发生的改变将被忽略,不针对本次的改变进行聚焦,如果没有达到,那么计算单元403对变量num的当前值增加预定值,针对本次改变进行一次聚焦,以避免连续改变焦距或位置,使摄像机长时间持续聚焦。In an embodiment of the present invention, the device may further include a second setting unit and a second judging unit, the second setting unit is used to set the maximum value of the variable num, and the second judging unit is used to detect the After the focal length or position is changed, judge whether the current value of the variable num has reached its maximum value. If it has reached, the change of focal length or position will be ignored, and the focus will not be carried out for this change. If not, then The calculation unit 403 adds a predetermined value to the current value of the variable num, and performs a focusing for this change, so as to avoid continuously changing the focal length or position and make the camera focus continuously for a long time.
在本发明一个实施例中,该装置还可以包括第三判断单元,第三判断单元用于在检测单元402检测到摄像机的焦距或位置发生改变后,判断本次改变发生时摄像机是否处于聚焦状态,如果是,那本次焦距或位置改变产生的影响会在本次改变发生时摄像机进行的聚焦完成后消除,无需单独进行聚焦,因而本次焦距或位置的改变将被忽略,计算单元403无需对变量num的当前值增加预定值,如果否,本次焦距或位置的改变产生的影响还没有被消除,需要针对本次改变进行一次聚焦,由计算单元403将变量num的当前值增加预定值,以避免摄像机重复进行无用的聚焦。In an embodiment of the present invention, the device may further include a third judging unit, which is used to judge whether the camera is in a focused state when the change occurs after the detection unit 402 detects that the focal length or position of the camera changes. , if yes, then the impact of this change in focal length or position will be eliminated after the focus of the camera is completed when this change occurs, and there is no need to focus separately, so this change in focal length or position will be ignored, and the calculation unit 403 does not need to Add a predetermined value to the current value of the variable num, if not, the impact of this change in focal length or position has not been eliminated, and a focus needs to be performed for this change, and the calculation unit 403 increases the current value of the variable num by a predetermined value , to avoid repeated useless focusing of the camera.
根据上述方案,本发明的实施例所提供的一种自动聚焦的方法及装置,至少具有如下有益效果:According to the above solution, an automatic focusing method and device provided by the embodiments of the present invention have at least the following beneficial effects:
1、本发明实施例中,预先设置变量num,并将其初始值设置为第一特征值,实时检测摄像机的焦距或位置是否发生改变,如果发生改变,对第一特征值增加一个预定值,实时判断变量num的当前值是否等于第一特征值,如果否,则形成聚焦信号,并将变量num的当前值减去一个预定值,根据形成的聚焦信号,控制摄像机进行一次聚焦,这样,每次摄像机的镜头变倍或云台转动,使摄像机的焦距或位置发生改变时,对应的使变量num增加一个预定值,使变量num的当前值不等于第一特征值,触发摄像机进行聚焦,并在聚焦信号发出后从变量num中减去一个预定值,保证每次摄像机的焦距或位置发生改变之后都触发一次聚焦,无需人工操作,从而实现摄像机的自动聚焦。1. In the embodiment of the present invention, the variable num is preset, and its initial value is set as the first characteristic value, and whether the focal length or the position of the camera is changed in real time is detected, and if a change occurs, a predetermined value is added to the first characteristic value, Determine in real time whether the current value of the variable num is equal to the first characteristic value, if not, then form a focus signal, and subtract a predetermined value from the current value of the variable num, and control the camera to focus once according to the formed focus signal, so that every When the lens of the secondary camera is zoomed or the pan/tilt is rotated to change the focal length or position of the camera, the variable num is correspondingly increased by a predetermined value so that the current value of the variable num is not equal to the first characteristic value, triggering the camera to focus, and After the focus signal is sent out, a predetermined value is subtracted from the variable num to ensure that a focus is triggered every time the focal length or position of the camera changes, without manual operation, so as to realize the automatic focus of the camera.
2、本发明实施例中,通过检测摄像机的焦距及位置是否发生改变,并记录改变的次数,针对每次改变进行一次自动聚焦,在焦距或位置发生改变后,立即进行对应的自动聚焦,无需人工干预,可以及时将摄像机拍摄的图像调整到清晰的状态,提高了摄像机的拍摄效果。2. In the embodiment of the present invention, by detecting whether the focal length and position of the camera have changed, and recording the number of changes, an automatic focus is performed for each change, and the corresponding automatic focus is performed immediately after the focal length or position is changed. Manual intervention can adjust the image captured by the camera to a clear state in time, improving the shooting effect of the camera.
3、本发明实施例中,继电器及自动聚焦镜头都是摄像机上的自带的部件,只需通过编译相关软件,并对现有硬件进行适当的改造,即可实现摄像机的自动聚焦,成本较低。3. In the embodiment of the present invention, both the relay and the auto-focus lens are self-contained components on the camera. Only by compiling the relevant software and appropriately modifying the existing hardware, the auto-focus of the camera can be realized, and the cost is relatively low. Low.
4、本发明实施例中,可以设置变量num的最大值,当变量num的当前值达到最大值时,摄像机焦距或位置的变化将被忽略,不再对变量num增加预定值,这样,可以避免连续调整摄像机的焦距或位置使摄像机长时间处于自动聚焦的状态,影响摄像机的拍摄效果。4. In the embodiment of the present invention, the maximum value of the variable num can be set. When the current value of the variable num reaches the maximum value, the change of the focal length or position of the camera will be ignored, and the predetermined value will no longer be added to the variable num. In this way, it is possible to avoid Continuously adjusting the focal length or position of the camera keeps the camera in the state of automatic focus for a long time, which affects the shooting effect of the camera.
5、本发明实施例中,在检测到摄像机的焦距或位置发生改变后,可以进一步判断焦距或位置发生改变时摄像机是否处于自动聚焦的状态,如果是,那么本次焦距或位置改变产生的影响会在与之同时进行的自动聚焦过程中消除,无需单独针对本次改变进行自动聚焦,因而不需要对变量num增加预定值,如果否,本次焦距或位置改变产生的影响还没有消除,需要针对本次改变进行一次自动聚焦,因而对变量num值增加预定值,这样,可以避免摄像机进行无用的自动聚焦,可以减轻自动聚焦镜头的负担,延长设备的寿命,并可以提高摄像机的拍摄效果。5. In the embodiment of the present invention, after the focal length or position of the camera is detected to change, it can be further judged whether the camera is in the state of auto-focus when the focal length or position changes, and if so, the impact of this change of focal length or position It will be eliminated during the autofocus process that is carried out at the same time. There is no need to perform autofocus for this change alone, so there is no need to increase the predetermined value of the variable num. If not, the impact of this focal length or position change has not been eliminated. Need Carry out an automatic focus for this change, and thus increase the value of the variable num by a predetermined value. In this way, useless automatic focus of the camera can be avoided, the burden of the automatic focus lens can be reduced, the life of the device can be extended, and the shooting effect of the camera can be improved.
需要说明的是,在本文中,诸如第一和第二之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个〃〃〃〃〃〃”限定的要素,并不排除在包括所述要素的过程、方法、物品或者设备中还存在另外的相同因素。It should be noted that in this article, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply that there is a relationship between these entities or operations. There is no such actual relationship or sequence. Furthermore, the term "comprises", "comprises" or any other variation thereof is intended to cover a non-exclusive inclusion such that a process, method, article or apparatus comprising a set of elements includes not only those elements, but also includes elements not expressly listed. other elements of or also include elements inherent in such a process, method, article, or device. Without further limitations, an element defined by the phrase "comprising a """""" does not exclude the presence of additional same elements in the process, method, article or apparatus comprising said element.
本领域普通技术人员可以理解:实现上述方法实施例的全部或部分步骤可以通过程序指令相关的硬件来完成,前述的程序可以存储在计算机可读取的存储介质中,该程序在执行时,执行包括上述方法实施例的步骤;而前述的存储介质包括:ROM、RAM、磁碟或者光盘等各种可以存储程序代码的介质中。Those of ordinary skill in the art can understand that all or part of the steps to realize the above method embodiments can be completed by program instructions related hardware, and the aforementioned programs can be stored in a computer-readable storage medium. When the program is executed, the It includes the steps of the above method embodiments; and the aforementioned storage medium includes: ROM, RAM, magnetic disk or optical disk and other various media that can store program codes.
最后需要说明的是:以上所述仅为本发明的较佳实施例,仅用于说明本发明的技术方案,并非用于限定本发明的保护范围。凡在本发明的精神和原则之内所做的任何修改、等同替换、改进等,均包含在本发明的保护范围内。Finally, it should be noted that the above descriptions are only preferred embodiments of the present invention, and are only used to illustrate the technical solution of the present invention, and are not used to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principles of the present invention are included in the protection scope of the present invention.
Claims (8)
- A kind of 1. method focused on automatically, it is characterised in that variable num is set, and the initial value of the variable num is set for the One characteristic value, in addition to:At least one whether changing in the focal length of detection video camera and position in real time;If it is, the currency of the variable num is increased into predetermined value;Whether variable num currency described in real-time judge is the First Eigenvalue;If not, forming focus signal, and the currency of the num is subtracted into the predetermined value;According to the focus signal, the video camera is controlled to be focused;Forming focus signal includes:A low level time and a high level time are preset, ought when judge the variable num When preceding value is not the First Eigenvalue, start timing, a low level pulse is formed, when timing duration is equal to the low electricity When between usually, the pulse is high level by low transition, forms a rising edge, when the timing duration is equal to described low When level time is with the high level time sum, the pulse is converted to low level by high level, forms a trailing edge, with Obtain the focus signal being made up of the rising edge and the trailing edge.
- 2. according to the method for claim 1, it is characterised in that it is described according to the focus signal, control the video camera Be focused including:The rising edge and the trailing edge are received, according to the rising edge and trailing edge, is triggered automatic on the video camera Amasthenic lens, the video camera is focused.
- 3. according to the method for claim 1, it is characterised in that further comprise:The maximum of the variable num is set;After at least one in detecting the focal length of the video camera and position changes, and by the variable num Currency increase predetermined value before, further comprise:Judge whether the currency of the variable num reaches the maximum, If it is, ignore this change, continue executing with the video camera of detection in real time focal length and position at least one whether send out It is raw to change, if it is not, then continuing executing with the currency by the variable num increases predetermined value.
- 4. according to any described method in claims 1 to 3, it is characterised in that detect the focal length and position described In it is at least one there occurs change after, and increase taking a step forward for predetermined value in the currency by the variable num Including:Judge the video camera focal length and position in it is at least one when changing, whether the video camera in focusing on shape State, if it is, ignore this change, continue executing with the video camera of detection in real time focal length and position in it is at least one whether Change, if not, continuing executing with the currency by the variable num increases predetermined value.
- A kind of 5. device focused on automatically, it is characterised in that including:First setting unit, for setting variable num, and it is the First Eigenvalue to set the initial value of the variable num;Detection unit, for detect in real time video camera focal length and position at least one whether change;Computing unit, for the testing result according to the detection unit, if it is, the institute that first setting unit is set State variable num currency increase predetermined value;First judging unit, whether the currency for variable num described in real-time judge is the First Eigenvalue;Shaping unit, for the judged result according to first judging unit, if not, form focus signal, and by institute The currency for stating num subtracts the predetermined value;Controller, for the focus signal formed according to the shaping unit, the video camera is controlled to be focused;Shaping unit is PWM signal generator;The PWM signal generator is connected with first judging unit, presets the low level of the PWM signal generator Time and high level time, when first judging unit judges the currency of the variable num not for the First Eigenvalue When, the PWM signal generator starts timing, and forms a low level pulse, when timing duration is equal to the low level During the time, the pulse is high level by low transition, forms a rising edge, the rising edge is sent into the control Device, when timing duration is equal to the low level time with the high level time sum, the pulse is converted into by high level Low level, a trailing edge is formed, the trailing edge is sent to the controller, by the rising edge and the trailing edge group Into a focus signal.
- 6. device according to claim 5, it is characterised in that the controller is relay;The relay is connected with the automatic amasthenic lens on the PWM signal generator and the video camera respectively, wherein institute State automatic amasthenic lens by the first triggering wire and the second triggering wire with the relay to be connected, when the relay receives To the PWM signal generator send rising edge when, the relay will described first triggering wire with described second trigger Wire short circuit, after the relay receives the trailing edge that the PWM signal generator is sent, the relay is by described the One triggers wire disconnects with the described second triggering wire, after the first triggering wire and the described second triggering wire short circuit again Disconnect, form a trigger signal, after the automatic amasthenic lens receives the trigger signal, carry out once automatic focus on.
- 7. device according to claim 5, it is characterised in that further comprise:Second setting unit and the second judgement are single Member;Second setting unit, for setting the maximum of the variable num;Second judging unit, for the detection unit detect the video camera focal length and position in it is at least one After changing, judge whether the currency of the variable num reaches the maximum, if it is, ignore this change, after It is continuous by the detection unit detect in real time video camera focal length and position in it is at least one whether change, if it is not, then The currency of the variable num for setting first setting unit is increased into predetermined value by the computing unit.
- 8. according to any described device in claim 5 to 7, it is characterised in that further comprise:3rd judging unit;3rd judging unit, is connected with the detection unit and the computing unit respectively, when the detection unit detects When at least one into the focal length of the video camera and position changes, the 3rd judging unit judges that when institute occurs for the change State whether video camera is in focus state, if it is, continuing the focal length of detection video camera and position in real time by the detection unit In it is at least one whether change, if not, the currency of the variable num increased by the computing unit predetermined Value.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510510341.8A CN105120151B (en) | 2015-08-19 | 2015-08-19 | A kind of method and device focused on automatically |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510510341.8A CN105120151B (en) | 2015-08-19 | 2015-08-19 | A kind of method and device focused on automatically |
Publications (2)
Publication Number | Publication Date |
---|---|
CN105120151A CN105120151A (en) | 2015-12-02 |
CN105120151B true CN105120151B (en) | 2017-12-05 |
Family
ID=54668027
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201510510341.8A Active CN105120151B (en) | 2015-08-19 | 2015-08-19 | A kind of method and device focused on automatically |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN105120151B (en) |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US4873543A (en) * | 1986-11-01 | 1989-10-10 | Olympus Optical Co., Ltd. | Automatic focusing camera |
CN1506743A (en) * | 2002-12-06 | 2004-06-23 | ������������ʽ���� | Automatic focusing device for camera and controlling method thereof |
CN102053339A (en) * | 2010-11-23 | 2011-05-11 | 天津市亚安科技电子有限公司 | Automatic focusing method |
CN102457666A (en) * | 2010-10-19 | 2012-05-16 | 赵菲 | Automatic focusing device based on FPGA |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP5956782B2 (en) * | 2011-05-26 | 2016-07-27 | キヤノン株式会社 | Imaging device and imaging apparatus |
-
2015
- 2015-08-19 CN CN201510510341.8A patent/CN105120151B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US4873543A (en) * | 1986-11-01 | 1989-10-10 | Olympus Optical Co., Ltd. | Automatic focusing camera |
CN1506743A (en) * | 2002-12-06 | 2004-06-23 | ������������ʽ���� | Automatic focusing device for camera and controlling method thereof |
CN102457666A (en) * | 2010-10-19 | 2012-05-16 | 赵菲 | Automatic focusing device based on FPGA |
CN102053339A (en) * | 2010-11-23 | 2011-05-11 | 天津市亚安科技电子有限公司 | Automatic focusing method |
Also Published As
Publication number | Publication date |
---|---|
CN105120151A (en) | 2015-12-02 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
JP5848507B2 (en) | Image capturing apparatus and method with tracking function | |
JP5942444B2 (en) | Digital camera | |
US8169530B2 (en) | Camera having an autofocusing system | |
US8330849B2 (en) | Auto focusing apparatus and auto focusing method, and image sensing apparatus for stable focus detection | |
US7463302B2 (en) | Focus control device and focus control method | |
CN102970485B (en) | A kind of Atomatic focusing method and device | |
US20170332005A1 (en) | Imaging apparatus, imaging apparatus control method, lens apparatus, and lens apparatus control method | |
JP2018138988A (en) | Camera focus adjustment for scene monitoring | |
CN103945133A (en) | Auto-focus device and method for visible light lens | |
JP2010191082A5 (en) | ||
US10284767B2 (en) | Shooting device, shooting method, and non-transitory computer readable recording medium storing program | |
JP5234099B2 (en) | Autofocus device | |
JP2017034569A (en) | Imaging apparatus and control method therefor | |
CN102036017A (en) | Flash module control method | |
JP5002289B2 (en) | Imaging device | |
CN105120151B (en) | A kind of method and device focused on automatically | |
JP4962021B2 (en) | Focus adjustment device and imaging device | |
US7602436B2 (en) | Lens apparatus | |
US20170318231A1 (en) | View angle control apparatus and view angle control method | |
CN103973982A (en) | Night vision device capable of automatically focusing laser and focusing method | |
JP6179410B2 (en) | IMAGING DEVICE AND METHOD OF DETERMINING WATER DROP ADJUSTMENT IN IMAGING DEVICE IMAGING WINDOW | |
JP4438428B2 (en) | Video camera, in-focus position search method, camera body and interchangeable lens | |
US8611737B2 (en) | Lens driving device, control method, and lens system | |
US20130242159A1 (en) | Imaging device and display process method | |
JP2008283258A (en) | Electronic camera and information processing system |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
TR01 | Transfer of patent right |
Effective date of registration: 20190211 Address after: 250100 North Sixth Floor, S05 Building, No. 1036 Tidal Road, Jinan High-tech Zone, Shandong Province Patentee after: Shandong Wave Artificial Intelligence Research Institute Co., Ltd. Address before: No. 1036, Shandong high tech Zone wave road, Ji'nan, Shandong Patentee before: Inspur Group Co., Ltd. |
|
TR01 | Transfer of patent right | ||
CP01 | Change in the name or title of a patent holder |
Address after: North 6th floor, S05 building, Langchao Science Park, 1036 Langchao Road, hi tech Zone, Jinan City, Shandong Province, 250100 Patentee after: Jinan Tengming Information Technology Co.,Ltd. Address before: North 6th floor, S05 building, Langchao Science Park, 1036 Langchao Road, hi tech Zone, Jinan City, Shandong Province, 250100 Patentee before: SHANDONG INSPUR ARTIFICIAL INTELLIGENCE RESEARCH INSTITUTE Co.,Ltd. |
|
CP01 | Change in the name or title of a patent holder | ||
CP01 | Change in the name or title of a patent holder |
Address after: North 6th floor, S05 building, Langchao Science Park, 1036 Langchao Road, hi tech Zone, Jinan City, Shandong Province, 250100 Patentee after: Shandong Langchao Digital Energy Technology Co.,Ltd. Address before: North 6th floor, S05 building, Langchao Science Park, 1036 Langchao Road, hi tech Zone, Jinan City, Shandong Province, 250100 Patentee before: Jinan Tengming Information Technology Co.,Ltd. |
|
CP01 | Change in the name or title of a patent holder |