Method and device for detecting switching between optical filters, storage medium and electronic device

文档序号:566887 发布日期:2021-05-18 浏览:3次 中文

阅读说明:本技术 一种滤光片间切换检测方法、装置、存储介质及电子装置 (Method and device for detecting switching between optical filters, storage medium and electronic device ) 是由 周贞 于 2021-01-22 设计创作,主要内容包括:本发明实施例提供了一种滤光片间切换检测方法、装置、存储介质及电子装置,其方法包括在确定滤光片切换结束的情况下,采集第一帧图像的第一曝光参数和第二帧图像的第二曝光参数;在所述第一曝光参数和所述第二曝光参数满足第一曝光条件的情况下,采集第一分量和第二分量;根据所述第一分量以及所述第二分量确定所述滤光片切换是否完全。通过本发明,解决了检测精度较低的问题,进而达到了提高检测精度的效果。(The embodiment of the invention provides a method and a device for detecting switching between optical filters, a storage medium and an electronic device, wherein the method comprises the steps of collecting a first exposure parameter of a first frame image and a second exposure parameter of a second frame image under the condition of determining the switching end of the optical filters; acquiring a first component and a second component under the condition that the first exposure parameter and the second exposure parameter meet a first exposure condition; determining whether the filter switching is complete according to the first component and the second component. By the method and the device, the problem of low detection precision is solved, and the effect of improving the detection precision is further achieved.)

1. A method for detecting switching between optical filters is characterized by comprising the following steps:

acquiring a first exposure parameter of a first frame image and a second exposure parameter of a second frame image under the condition that the optical filter switching is determined to be finished, wherein the first frame image is a frame image obtained by shooting a first target object before the optical filter switching is executed, and the second frame image is a frame image obtained by shooting the first target object after the optical filter switching is determined to be finished;

acquiring a first component and a second component under the condition that the first exposure parameter and the second exposure parameter meet a first exposure condition, wherein the first component is a color component of a first color of the first frame image, and the second component is a color component of the first color of the second frame image;

determining whether the filter switching is complete according to the first component and the second component.

2. The method of claim 1,

the acquiring the first component and the second component comprises:

acquiring a first target component and a second target component, wherein the first target component comprises a color component of the first type of color of each image block included in the first frame image, the second component is an average color component of the first type of color of all image blocks included in the first frame image, and the first component comprises the first target component and the second target component;

acquiring a third target component and a fourth target component, wherein the third target component comprises a color component of the first type of color of each image block included in the second frame image, the fourth target component is an average color component of the first type of color of all image blocks included in the second frame image, and the second component comprises the third target component and the fourth target component;

determining whether the filter switching is complete based on the first component and the second component comprises:

determining that the optical filter is switched completely under the condition that the first target component and the third target component meet a first condition and the second target component and the fourth target component meet a second condition;

determining that the filter is not switched completely if the first target component, the third target component, and/or the second target component, and the fourth target component are determined not to satisfy the first condition.

3. The method of claim 2, wherein the acquiring a first target component and a second target component comprises:

determining each image block included in the first frame image;

for a first image block included in the first frame image, determining a color component of the first type of color of the first image block to obtain the first target component in the following manner, where the first image block is any image block included in the first frame image: determining a color mean value of a first type of color of the first image block and a color mean value of a second type of color of the first image block; determining the ratio of the color mean value of the first type of color of the first image block to the color mean value of the second type of color of the first image block as the color component of the first type of color of the first image block;

and carrying out weighted average on the color components of the first type of colors of all the image blocks included in the first frame image to obtain the second target component.

4. The method of claim 2, wherein the acquiring a third target component and a fourth target component comprises:

determining each image block included in the second frame image;

for a second image block included in the second frame image, determining a color component of the first type of color of the second image block in the following manner to obtain the third target component, where the second image block is any image block included in the second frame image: determining a color mean value of a first type of color of the second image block and a color mean value of a second type of color of the second image block; determining the ratio of the color mean value of the first type of color of the second image block to the color mean value of the second type of color of the second image block as the color component of the first type of color of the second image block;

and performing weighted average on the color components of the first type of colors of all the image blocks included in the second frame of image to obtain the fourth target component.

5. The method of claim 3, wherein the determining that the first frame image comprises each image block comprises:

dividing the first frame image into N image blocks according to a preset first mode to determine each image block included in the first frame image, wherein N is a positive integer greater than 1.

6. The method of claim 4, wherein the determining that the second frame image comprises each image block comprises:

and dividing the second frame image into N image blocks according to a preset first mode so as to determine each image block included in the second frame image.

7. The method of claim 2, wherein prior to determining whether the filter switching is complete based on the first component and the second component, the method comprises:

determining a switching mode of the optical filter switching;

determining the first condition and the second condition according to the switching pattern.

8. The method of claim 1, wherein before acquiring the second exposure parameter for the second frame image if the end of the filter switching is determined, the method further comprises:

under the condition of receiving an optical filter switching end signal, continuously acquiring a frame image obtained by shooting the first target image and an exposure parameter of the frame image;

and under the condition that the exposure parameters of at least a preset number of continuously acquired frame images meet a preset exposure condition, determining the last shot frame image as the second frame image.

9. The method of claim 2,

when the switching mode of the optical filter switching is that the visible light filter is switched into the infrared optical filter, the first condition includes that the difference value of the first target component and the third target component is greater than or equal to a first preset value, and the second condition includes that the difference value of the second target component and the fourth target component is also greater than or equal to the first preset value;

when the switching mode of the optical filter switching is switching from an infrared optical filter to a visible light optical filter, the first condition includes that the difference between the third target component and the first target component is greater than or equal to the first preset value, and the second condition includes that the difference between the fourth target component and the second target component is also greater than or equal to the first preset value.

10. An apparatus for detecting switching between filters, comprising:

the exposure parameter acquisition module is used for acquiring a first exposure parameter of a first frame image and a second exposure parameter of a second frame image under the condition that the optical filter switching is determined to be finished, wherein the first frame image is a frame image obtained by shooting a first target object before the optical filter switching is executed, and the second frame image is a frame image obtained by shooting the first target object after the optical filter switching is determined to be finished;

a component acquiring module, configured to acquire a first component and a second component when the first exposure parameter and the second exposure parameter satisfy a first exposure condition, where the first component is a color component of a first type of color of the first frame image, and the second component is a color component of the first type of color of the second frame image;

and the detection module is used for determining whether the optical filter is switched completely according to the first component and the second component.

11. A storage medium, in which a computer program is stored, wherein the computer program is arranged to perform the method of any of claims 1 to 9 when executed.

12. An electronic device comprising a memory and a processor, wherein the memory has stored therein a computer program, and wherein the processor is arranged to execute the computer program to perform the method of any of claims 1 to 9.

Technical Field

The embodiment of the invention relates to the technical field of image acquisition technology, in particular to a method and a device for detecting switching between optical filters, a storage medium and an electronic device.

Background

When image acquisition is carried out, an optical filter is often required to be arranged so as to improve the image acquisition quality; the filter functions in two ways, one is to select the desired radiation band and the other is to trim the incoming light. The filters provided in the camera are mainly used to select the desired radiation band.

At present, cameras can be classified into color cameras and black-and-white cameras according to color classification, wherein visible light filters are used for the color cameras, and the visible light filters can only pass through visible light wave bands; the black-and-white camera uses an infrared filter which can only pass through an infrared band.

The existing image acquisition equipment integrating the visible light filter and the infrared filter can automatically control the switching of the visible light filter and the infrared filter through the visible light intensity and the invisible light intensity in the environment, thereby achieving the purpose of automatically switching black and white and color.

However, due to problems of the service life of the optical filter or a mechanical structure, when the optical filter is switched, the problem that the optical filter is stuck and the switching is unsuccessful exists, so that the switching of the optical filter needs to be detected to ensure the image acquisition quality.

Disclosure of Invention

The embodiment of the invention provides a method and a device for detecting switching between optical filters, a storage medium and an electronic device, which are used for at least solving the problems of complex switching and low detection precision of the optical filters in the related art.

According to an embodiment of the present invention, there is provided a method for detecting switching between filters, including:

acquiring a first exposure parameter of a first frame image and a second exposure parameter of a second frame image under the condition that the optical filter switching is determined to be finished, wherein the first frame image is a frame image obtained by shooting a first target object before the optical filter switching is executed, and the second frame image is a frame image obtained by shooting the first target object after the optical filter switching is determined to be finished;

acquiring a first component and a second component under the condition that the first exposure parameter and the second exposure parameter meet a first exposure condition, wherein the first component is a color component of a first color of the first frame image, and the second component is a color component of the first color of the second frame image;

determining whether the filter switching is complete according to the first component and the second component.

In one exemplary embodiment of the present invention,

the acquiring the first component and the second component comprises:

acquiring a first target component and a second target component, wherein the first target component comprises a color component of the first type of color of each image block included in the first frame image, the second component is an average color component of the first type of color of all image blocks included in the first frame image, and the first component comprises the first target component and the second target component;

acquiring a third target component and a fourth target component, wherein the third target component comprises a color component of the first type of color of each image block included in the second frame image, the fourth target component is an average color component of the first type of color of all image blocks included in the second frame image, and the second component comprises the third target component and the fourth target component;

determining whether the filter switching is complete based on the first component and the second component comprises:

determining that the optical filter is switched completely under the condition that the first target component and the third target component meet a first condition and the second target component and the fourth target component meet a second condition;

determining that the filter is not switched completely if the first target component, the third target component, and/or the second target component, and the fourth target component are determined not to satisfy the first condition.

In one exemplary embodiment of the present invention,

the acquiring the first target component and the second target component comprises:

determining each image block included in the first frame image;

for a first image block included in the first frame image, determining a color component of the first type of color of the first image block to obtain the first target component in the following manner, where the first image block is any image block included in the first frame image: determining a color mean value of a first type of color of the first image block and a color mean value of a second type of color of the first image block; determining the ratio of the color mean value of the first type of color of the first image block to the color mean value of the second type of color of the first image block as the color component of the first type of color of the first image block;

and carrying out weighted average on the color components of the first type of colors of all the image blocks included in the first frame image to obtain the second target component.

In an exemplary embodiment, the acquiring the third target component and the fourth target component includes:

determining each image block included in the second frame image;

for a second image block included in the second frame image, determining a color component of the first type of color of the second image block in the following manner to obtain the third target component, where the second image block is any image block included in the second frame image: determining a color mean value of a first type of color of the second image block and a color mean value of a second type of color of the second image block; determining the ratio of the color mean value of the first type of color of the second image block to the color mean value of the second type of color of the second image block as the color component of the first type of color of the second image block;

and performing weighted average on the color components of the first type of colors of all the image blocks included in the second frame of image to obtain the fourth target component.

In an exemplary embodiment, the determining that the first frame image includes the respective image blocks includes:

dividing the first frame image into N image blocks according to a preset first mode to determine each image block included in the first frame image, wherein N is a positive integer greater than 1.

In an exemplary embodiment, the determining that the second frame image includes the respective image blocks includes:

and dividing the second frame image into N image blocks according to a preset first mode so as to determine each image block included in the second frame image.

In one exemplary embodiment, before determining whether the filter switching is complete according to the first component and the second component, the method comprises:

determining a switching mode of the optical filter switching;

determining the first condition and the second condition according to the switching pattern.

In an exemplary embodiment, before acquiring the second exposure parameter of the second frame image in the case that the end of the filter switching is determined, the method further includes:

under the condition of receiving an optical filter switching end signal, continuously acquiring a frame image obtained by shooting the first target image and an exposure parameter of the frame image;

and under the condition that the exposure parameters of at least a preset number of continuously acquired frame images meet a preset exposure condition, determining the last shot frame image as the second frame image.

In an exemplary embodiment, in a case where the switching mode of the filter switching is switching from a visible light filter to an infrared filter, the first condition includes that the difference values of the first target component and the third target component are both greater than or equal to a first preset value, and the second condition includes that the difference values of the second target component and the fourth target component are also greater than or equal to the first preset value;

when the switching mode of the optical filter switching is switching from an infrared optical filter to a visible light optical filter, the first condition includes that the difference between the third target component and the first target component is greater than or equal to the first preset value, and the second condition includes that the difference between the fourth target component and the second target component is also greater than or equal to the first preset value.

According to another embodiment of the present invention, there is provided an inter-filter switching detection apparatus including:

the exposure parameter acquisition module is used for acquiring a first exposure parameter of a first frame image and a second exposure parameter of a second frame image under the condition that the optical filter switching is determined to be finished, wherein the first frame image is a frame image obtained by shooting a first target object before the optical filter switching is executed, and the second frame image is a frame image obtained by shooting the first target object after the optical filter switching is determined to be finished;

a component acquiring module, configured to acquire a first component and a second component when the first exposure parameter and the second exposure parameter satisfy a first exposure condition, where the first component is a color component of a first type of color of the first frame image, and the second component is a color component of the first type of color of the second frame image;

a previous frame component acquisition module, configured to determine a third component and a fourth component when the switching mode completes switching, where the third component indicates the first color component of the pixel block of each target image of the second sequential frame, and the fourth component indicates the first color component of the target image of the second sequential frame;

and the detection module is used for determining whether the optical filter is switched completely according to the first component and the second component.

According to a further embodiment of the present invention, there is also provided a computer-readable storage medium having a computer program stored thereon, wherein the computer program is arranged to perform the steps of any of the above method embodiments when executed.

According to yet another embodiment of the present invention, there is also provided an electronic device, including a memory in which a computer program is stored and a processor configured to execute the computer program to perform the steps in any of the above method embodiments.

According to the invention, the first component and the second component are collected after the switching is finished, so that the problem of inaccurate detection of the switching result of the optical filter can be solved, and the effect of improving the switching detection of the optical filter is achieved.

Drawings

Fig. 1 is a block diagram of a hardware structure of a mobile terminal according to an embodiment of the present invention;

FIG. 2 is a flowchart illustrating a method for detecting switching between filters according to an embodiment of the present invention;

FIG. 3 is a block diagram of an apparatus for detecting switching between filters according to an embodiment of the present invention;

FIG. 4 is a flowchart illustrating an embodiment of filter switching detection according to the present invention.

Detailed Description

Hereinafter, embodiments of the present invention will be described in detail with reference to the accompanying drawings in conjunction with the embodiments.

It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order.

The method embodiments provided in the embodiments of the present application may be executed in a mobile terminal, a computer terminal, or a similar computing device. Taking the operation on a mobile terminal as an example, fig. 1 is a block diagram of a hardware structure of the mobile terminal of the method for detecting switching between optical filters according to the embodiment of the present invention. As shown in fig. 1, the mobile terminal may include one or more (only one shown in fig. 1) processors 102 (the processor 102 may include, but is not limited to, a processing device such as a microprocessor MCU or a programmable logic device FPGA), and a memory 104 for storing data, wherein the mobile terminal may further include a transmission device 106 for communication functions and an input-output device 108. It will be understood by those skilled in the art that the structure shown in fig. 1 is only an illustration, and does not limit the structure of the mobile terminal. For example, the mobile terminal may also include more or fewer components than shown in FIG. 1, or have a different configuration than shown in FIG. 1.

The memory 104 may be used to store a computer program, for example, a software program and a module of application software, such as a computer program corresponding to a method for detecting switching between filters in the embodiment of the present invention, and the processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, so as to implement the method described above. The memory 104 may include high speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include memory located remotely from the processor 102, which may be connected to the mobile terminal over a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.

The transmission device 106 is used for receiving or transmitting data via a network. Specific examples of the network described above may include a wireless network provided by a communication provider of the mobile terminal. In one example, the transmission device 106 includes a Network adapter (NIC), which can be connected to other Network devices through a base station so as to communicate with the internet. In one example, the transmission device 106 may be a Radio Frequency (RF) module, which is used for communicating with the internet in a wireless manner.

In this embodiment, a method for detecting switching between filters is provided, and fig. 2 is a flowchart according to an embodiment of the present invention, as shown in fig. 2, the flowchart includes the following steps:

step S202, under the condition that the optical filter switching is determined to be finished, acquiring a first exposure parameter of a first frame image and a second exposure parameter of a second frame image, wherein the first frame image is a frame image obtained by shooting a first target object before the optical filter switching is executed, and the second frame image is a frame image obtained by shooting the first target object after the optical filter switching is determined to be finished;

in the present embodiment, the exposure parameters at least include a shutter parameter S, a gain parameter G, and an aperture opening parameter a, where the gain parameter G is also called sensitivity, and another parameter can be determined according to any two of the three exposure parameters; for example, assuming that the first exposure parameters are S0, G0, a0, determining any two values of S0, G0, a0, a third value may be determined; similarly, assuming that the second exposure parameters are S2, G2, a2, any two values of S2, G2, a2 are determined, and the third value may be determined.

Step S204, under the condition that the first exposure parameter and the second exposure parameter meet a first exposure condition, acquiring a first component and a second component, wherein the first component is a color component of a first color of a first frame image, and the second component is a color component of a first color of a second frame image;

in the present embodiment, the first frame image and the second frame image each include a plurality of colors, for example, red, white, yellow, blue, green, etc., and thus there are a plurality of corresponding color components, for example, red component, white component, yellow component, blue component, green component, etc., and since the photosensitivity of red and blue is good, the red component and the blue component are generally collected.

Because the filters are switched, the color components before and after the filters are switched are necessarily different, for example, after the visible light filters are switched to the infrared filters, the values of the red and blue components are reduced; when the infrared filter is switched to the visible light filter, the values of the red component and the blue component are increased, so that the switching state can be judged only by collecting the color component and correspondingly processing the color component.

It should be noted that, the collection of the image color components can be realized by the prior art, for example, by a preset image monochrome collection algorithm, or by a color collection device, and will not be described herein again.

In step S206, it is determined whether the filter switching is complete according to the first component and the second component.

In the present embodiment, after the first component and the second component are obtained, calculation between the first component and the second component is performed to determine a change in color components before and after the switching of the filter, and whether the switching of the filter is complete is determined according to the calculation.

Through the steps, the color component is not influenced by the switching abnormal reason, so that the interference of other reasons to the color component detection is reduced, the problem of low optical filter switching detection precision is solved, and the optical filter switching detection precision is improved.

In an alternative embodiment of the method according to the invention,

acquiring the first component and the second component comprises:

step S2042, collecting a first target component and a second target component, wherein the first target component comprises color components of a first type of color of each image block included in a first frame image, the second component is an average color component of the first type of colors of all image blocks included in the first frame image, and the first component comprises the first target component and the second target component;

step S2044, collecting a third target component and a fourth target component, wherein the third target component comprises color components of the first type of color of each image block included in the second frame image, the fourth target component is an average color component of the first type of color of all image blocks included in the second frame image, and the second component comprises the third target component and the fourth target component;

in this embodiment, taking the collection of the red component as an example, when the first component is collected, the first frame image is firstly divided into N image blocks, then the red components rgb0.. Rgbn-1 of the respective image blocks are collected respectively to determine the first target component, and then the red component Rg0 of the first frame image is obtained according to the red components rgb0.. Rgbn-1 of the respective image blocks to determine the second target component.

Similarly, when the second component is acquired, the second frame image is divided into N image blocks, then the red component rga0.. Rgan-1 of each image block is acquired respectively to determine the first target component, and then the red component Rg1 of the first frame image is obtained according to the red component rga0.. Rgan-1 of each image block to determine the second target component.

The first frame image is divided into N image blocks by the method of dividing the first frame image into image blocks with the same size and shape according to the length or width of the first frame image in an equal proportion, or dividing the first frame image into image blocks with different sizes according to different proportions, or dividing the first frame image into image blocks with different shapes and sizes, as long as the color components of the image blocks can be acquired.

It should be noted that the image block division of the image can be implemented by the prior art, and is not described herein again.

Determining whether the filter switching is complete based on the first component and the second component comprises:

determining that the optical filter is completely switched under the condition that the first target component and the third target component meet the first condition and the second target component and the fourth target component meet the second condition;

and under the condition that the first target component and the third target component are determined not to meet the first condition and/or the second target component and the fourth target component are determined not to meet the second condition, determining that the optical filter is not completely switched.

In this embodiment, taking the collection of the red component as an example, assuming that the switching mode of the filter switching is from the visible light filter to the infrared filter, the first condition includes that the difference between the first target component and the third target component is greater than or equal to a first preset value, that is, Rga0-Rgb0> ═ Rthresh, Rga1-Rgb1> ═ Rthresh … Rgan-1-Rgbn-1> ═ Rthresh, and the second condition includes that the difference between the second target component and the fourth target component is also greater than or equal to the first preset value, that is, Rg1-Rg0> ═ Rthresh, it is determined that the filter switching is complete, or else the filter switching is incomplete, for example, if the first target component and the third target component do not satisfy the first condition, and/or the second target component and the fourth target component do not satisfy the second condition, it is determined that the filter is not completely switched;

if the first target component and the third target component satisfy the first condition, that is, Rga0-Rgb0> ═ Rthresh, Rga1-Rgb1> ═ Rthresh … Rgaa-1-Rgba-1> ═ Rthresh, and Rga0-Rgb0< eps … Rgan-1-Rgbn-1< eps, it may be determined that the filter switching is incomplete; where eps is a very small threshold.

Similarly, assuming that the switching mode of the optical filter switching is to switch the infrared optical filter to the visible light optical filter, the first condition includes that the difference between the third target component and the first target component is greater than or equal to the first preset value, that is,

rgb0-Rga0> -Rthresh, Rgb1-Rga1> -Rthresh … Rgbn-1-Rgan-1> -Rthresh, and the difference between the fourth target component and the second target component is also greater than or equal to the first preset value, that is, Rg0-Rg1> -Rthresh, the filter switching is determined to be complete, otherwise, the filter switching is determined to be incomplete.

Wherein, if the first target component and the third target component satisfy the first condition, that is,

rgb0-Rga0> -Rthresh, Rgb1-Rga1> -Rthresh … Rgba-1-Rgaa-1> -Rthresh, but Rgb0-Rga0< eps … Rgbn-1-Rgan-1< eps, the filter switching was also judged incomplete.

It should be noted that, as long as any one of the first condition and/or the second condition is not satisfied, it may be determined that the optical filter is not completely switched; the value of Sthresh may be, but is not limited to, 0.08 to 0.12ms, preferably 0.1ms, the value of Rthresh may be, but is not limited to, 0.3 to 0.7, preferably 0.5, and the value of eps may be, but is not limited to, 0.15 to 0.3, preferably 0.2.

In an optional embodiment, acquiring the first target component and the second target component comprises:

step S20422, determining each image block included in the first frame image;

for a first image block included in a first frame image, determining a color component of a first type of color of the first image block to obtain a first target component in the following manner, wherein the first image block is any image block included in the first frame image:

step 20424, determining a color mean value of a first type of color of the first image block and a color mean value of a second type of color of the first image block;

step S20426, determining a ratio of the color mean value of the first type of color of the first image block to the color mean value of the second type of color of the first image block as a color component of the first type of color of the first image block;

step S20428, performing weighted average on the color components of the first type of color of all the image blocks included in the first frame image to obtain a second target component.

In the embodiment, assuming that the height of a first frame image obtained by shooting a first target object is H, the image is equally divided into N image blocks with the height of H/N, then the red value R and the green value G of each pixel (R, G, B) in the image block are counted to obtain color average values Raverage and Gaverage, and then a red component Rgn ═ Raverage/Gaverage of each image block is obtained through Raverage and Gaverage; the red components of all blocks are then weighted and averaged to obtain the red component Rg of the image, which is the second target component.

In an optional embodiment, the acquiring the third target component and the fourth target component includes:

step 20462, determining each image block included in the second frame image;

for a second image block included in a second frame image, determining a color component of a first type of color of the second image block in the following manner to obtain a third target component, wherein the second image block is any image block included in the second frame image:

step 20464, determining a color mean value of the first type of color of the second image block and a color mean value of the second type of color of the second image block;

step 20466, determining the ratio of the color mean value of the first type of color of the second image block to the color mean value of the second type of color of the second image block as the color component of the first type of color of the second image block;

step S20468, performing weighted average on the color components of the first type of color of all image blocks included in the second frame image to obtain a fourth target component.

In the embodiment, assuming that the height of the second frame image obtained by shooting the first target object is H, the image is equally divided into N image blocks with the height of H/N, then the red value R and the green value G of each pixel (R, G, B) in the image block are counted to obtain color average values Raverage and Gaverage, and then the red component Rgn ═ Raverage/Gaverage of each image block is obtained through Raverage and Gaverage; the red components of all blocks are then weighted and averaged to obtain the red component Rg of the image, which is the second target component.

In an alternative embodiment, determining the respective image blocks included in the first frame image comprises:

dividing the first frame image into N image blocks according to a preset first mode to determine each image block included in the first frame image, wherein N is a positive integer greater than 1.

In this embodiment, the first frame image may be divided into N image blocks by dividing the image into image blocks with the same size according to an equal proportion, or divided into image blocks with different sizes according to different proportions.

In an alternative embodiment, determining the respective image blocks included in the second frame image comprises:

and dividing the second frame image into N image blocks according to a preset first mode to determine each image block included in the second frame image.

In this embodiment, the second frame image may be divided into N image blocks by dividing the image into image blocks with the same size according to an equal proportion, or may be divided into image blocks with different sizes according to different proportions.

In an alternative embodiment, before determining whether the filter switching is complete based on the first component and the second component, the method comprises:

determining a switching mode for switching the optical filter;

the first condition and the second condition are determined according to the switching pattern.

In this embodiment, the switching mode for determining the switching of the optical filter may be that a switching signal is output by the control unit when the optical filter is switched, and then a switching end signal is output after the switching is completed, and the switching mode is determined by acquiring the switching signal and the end signal; for example, when the visible light filter is switched to the infrared filter, a first switching signal is received when the switching is performed, and a first switching end signal is obtained after the switching is finished; and when the infrared filter is switched to the visible light filter, respectively acquiring a second switching signal and a second switching end signal.

Then, different switching modes are determined according to the acquired different signals, for example, when a first switching signal is received, the first switching mode is determined, and when a second switching signal is received, the second switching mode is determined.

It should be noted that, determining the switching mode of the optical filter may also be obtained by detecting the switching action, or determined in other ways; taking the detection of the switching action as an example, for example, when the visible light filter is switched to the infrared filter, the action change of switching the visible light filter to the infrared filter, such as the mechanical change of the lens switching process, is collected; similarly, when the infrared filter is switched to the visible light filter, the switching process can be determined by collecting the action change of the switching process.

In an optional embodiment, before acquiring the second exposure parameter of the second frame image in the case that the end of the filter switching is determined, the method further includes:

step S2022, continuously acquiring a frame image obtained by capturing the first target image and an exposure parameter of the frame image when the optical filter switching end signal is received;

in step S2024, in a case where it is determined that the exposure parameters of at least a predetermined number of frame images continuously acquired satisfy a predetermined exposure condition, the last captured frame image is determined as a second frame image.

In this embodiment, when receiving the filter switching end signal, a preset number of frame images and exposure parameters are acquired, for example, 10 frames of images may be acquired; it should be noted that, the continuous acquisition of the real-time frame images and the exposure parameters thereof may be real-time recording, or recording after receiving the end signal.

The exposure condition may (but is not limited to) be that the first exposure parameter and the second exposure parameter satisfy: S2-S0< Sthresh and G2-G0< Gthresh and a2-a0< athhresh, and hold 10 consecutive frames.

Wherein Sthresh may have a value of (but not limited to) 0.08-0.12ms, preferably 0.1ms, Gthresh may have a value of (but not limited to) 0.1-0.3DB, preferably 0.2DB, and athhresh may have a value of 50, wherein the aperture range is 0-10000.

Through the above description of the embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but the former is a better implementation mode in many cases. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which is stored in a storage medium (e.g., ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal device (e.g., a mobile phone, a computer, a server, or a network device) to execute the method according to the embodiments of the present invention.

In this embodiment, a device for detecting switching between optical filters is also provided, and the device is used to implement the foregoing embodiments and preferred embodiments, and the description of the device that has been already made is omitted. As used below, the term "module" may be a combination of software and/or hardware that implements a predetermined function. Although the means described in the embodiments below are preferably implemented in software, an implementation in hardware, or a combination of software and hardware is also possible and contemplated.

Fig. 3 is a block diagram of an inter-filter switching detection apparatus according to an embodiment of the present invention, as shown in fig. 3, the apparatus includes:

the exposure parameter acquisition module 32 is configured to acquire a first exposure parameter of a first frame image and a second exposure parameter of a second frame image when it is determined that the optical filter is switched, where the first frame image is a frame image obtained by shooting a first target object before the optical filter is switched, and the second frame image is a frame image obtained by shooting the first target object after it is determined that the optical filter is switched;

the component acquiring module 34 is configured to acquire a first component and a second component when the first exposure parameter and the second exposure parameter satisfy a first exposure condition, where the first component is a color component of a first type of color of the first frame image, and the second component is a color component of a first type of color of the second frame image;

and a detection module 36, configured to determine whether the filter switching is complete according to the first component and the second component.

In an alternative embodiment, the component acquisition module 34 includes:

a first target component acquiring unit 342, configured to acquire a first target component and a second target component, where the first target component includes a color component of a first type color of each image block included in the first frame image, the second component is an average color component of the first type colors of all image blocks included in the first frame image, and the first component includes the first target component and the second target component;

a second target component acquiring unit 344, configured to acquire a third target component and a fourth target component, where the third target component includes a color component of a first type color of each image block included in the second frame image, the fourth target component is an average color component of the first type colors of all image blocks included in the second frame image, and the second component includes the third target component and the fourth target component;

the detection module 36 includes:

a first determining unit 362, configured to determine that the optical filter is completely switched when it is determined that the first target component and the third target component satisfy the first condition and that the second target component and the fourth target component satisfy the second condition;

a second judging unit 364, configured to determine that the optical filter is not completely switched if it is determined that the first target component and the third target component do not satisfy the first condition, and/or the second target component and the fourth target component do not satisfy the second condition.

In an alternative embodiment, the first determining unit 362 includes:

a first image block determining unit 3622 for determining each image block included in the first frame image;

a first color averaging unit 3624, configured to determine, for a first image block included in the first frame image, a color component of a first type color of the first image block to obtain a first target component, where the first image block is any image block included in the first frame image: determining a color mean value of a first type of color of the first image block and a color mean value of a second type of color of the first image block; determining the ratio of the color mean value of the first type of color of the first image block to the color mean value of the second type of color of the first image block as the color component of the first type of color of the first image block;

a first processing unit 3626, configured to perform weighted average on the color components of the first type colors of all image blocks included in the first frame image to obtain a second target component.

In an alternative embodiment, the second target cell 364 comprises:

a second image determining unit 3642 for determining each image block included in the second frame image;

a second color averaging unit 3644, configured to determine, for a second image block included in the second frame image, a color component of the first type of color of the second image block in the following manner to obtain a third target component, where the second image block is any image block included in the second frame image: determining a color mean value of a first type of color of the second image block and a color mean value of a second type of color of the second image block; determining the ratio of the color mean value of the first type of color of the second image block to the color mean value of the second type of color of the second image block as the color component of the first type of color of the second image block;

a second processing unit 3646, configured to perform weighted average on the color components of the first type colors of all image blocks included in the second frame image to obtain a fourth target component.

In an alternative embodiment, the first image determining unit 3622 includes:

the first image dividing unit 3628 is configured to divide the first frame image into N image blocks according to a preset first manner to determine each image block included in the first frame image, where N is a positive integer greater than 1.

In an alternative embodiment, the second image determining unit 3642 includes:

a second image dividing unit 3648, configured to divide the second frame image into N image blocks according to the first manner to determine each image block included in the second frame image, where N is a positive integer greater than 1.

In an optional embodiment, the apparatus further comprises:

a mode determination module 302 for determining a switching mode for switching the optical filter;

the condition determining module 304 determines a first condition and a second condition according to the switching mode.

In an optional embodiment, the apparatus further comprises:

the exposure acquisition module 306 is used for continuously acquiring a frame image obtained by shooting the first target image and an exposure parameter of the frame image under the condition of receiving the optical filter switching end signal;

the second frame determination module 308 determines the last captured frame image as the second frame image when determining that the exposure parameters of at least a predetermined number of frame images continuously acquired satisfy a predetermined exposure condition.

In an alternative embodiment, the apparatus further comprises,

a first mode determining unit 3022, configured to, when the switching mode of the optical filter switching is switching from the visible light filter to the infrared filter, determine that the first condition includes that the difference between the first target component and the third target component is greater than or equal to a first preset value, and the second condition includes that the difference between the second target component and the fourth target component is also greater than or equal to the first preset value;

a second mode determining unit 3024, configured to, when the switching mode of the filter switching is switching from the infrared filter to the visible light filter, determine that the first condition includes that differences between the third target component and the first target component are greater than or equal to a first preset value, and the second condition includes that differences between the fourth target component and the second target component are also greater than or equal to the first preset value.

It should be noted that, the above modules may be implemented by software or hardware, and for the latter, the following may be implemented, but not limited to: the modules are all positioned in the same processor; alternatively, the modules are respectively located in different processors in any combination.

The present invention will be explained below with reference to specific examples.

As shown in fig. 4, when the filter needs to be switched from the visible light filter to the infrared filter, the blocked red component rgb0.. Rgbn-1 of the previous frame and the red component Rg0 of the image are collected first (corresponding to S402 in fig. 4); then the image acquisition device signal drives the filter switching device to switch the filter from the visible light filter to the infrared filter (corresponding to S404 in fig. 4).

Then acquiring an optical filter switching end signal and detecting the exposure condition (corresponding to S406 in fig. 4); assuming that the previous frame exposure parameters are S0, G0, a0, the current frame exposure parameters are S2, G2, a2, and when the previous frame exposure parameters and the current frame exposure parameters satisfy the first exposure condition, i.e., S2-S0< Sthresh, G2-G0< Gthresh, and a2-a0< athhresh, and continuous 10 frames are maintained, it is determined that the exposure of the image capturing apparatus is stable (corresponding to S408 in fig. 4).

The block red component rga0.. Rgan-1 of the image at this time and the red component Rg1 of the image are recorded (corresponding to step S410 in fig. 4).

At this time, if the block red component rga0.. Rgan-1 of the image and the red component Rg1 of the image satisfy the first component condition, that is,

when Rga0-Rgb0> is Rthresh, Rga1-Rgb1> is Rthresh … Rgan-1-Rgbn-1> is Rthresh, and Rg1-Rg0> is Rthresh, it is determined that the filter switching is successful (corresponding to steps S412-S414 in fig. 4);

if the first component condition is not satisfied and the second component condition is satisfied, that is,

and Rga0-Rgb0> ═ Rthresh, Rga1-Rgb1> ═ Rthresh … Rgaa-1-Rgba-1> ═ Rthresh, and Rgaa-Rgba < eps … Rgan-1-Rgb n-1< eps, the filter switching is judged to be incomplete, wherein eps is the first threshold (corresponding to step S416 in fig. 4).

Similarly, when the filter needs to be switched from the infrared filter to the visible light filter, the block red component rga0.. Rgan-1 of the image at that time and the red component Rg1 of the image are recorded under the condition that the first exposure condition is satisfied.

If the block red component rga0.. Rgan-1 of the image and the red component Rg1 of the image satisfy the third component condition, that is,

rgb0-Rga0> -Rthresh, Rgb1-Rga1> -Rthresh … Rgbn-1-Rgan-1> -Rthresh and Rg0-Rg1> -Rthresh, it is determined that the filter switching is successful (corresponding to step S418 in fig. 4);

if the third component condition is not satisfied and the fourth component condition is satisfied, that is, Rgb0-Rga0> -Rthresh, Rgb1-Rga1> -Rthresh … Rgba-1-Rgaa-1> -Rthresh, and Rgba-Rgaa < eps … Rgbn-1-Rgan-1< eps, it is determined that the filter switching is incomplete (corresponding to step S420 in fig. 4).

Embodiments of the present invention also provide a computer-readable storage medium having a computer program stored thereon, wherein the computer program is arranged to perform the steps of any of the above-mentioned method embodiments when executed.

In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to: various media capable of storing computer programs, such as a usb disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic disk, or an optical disk.

Embodiments of the present invention also provide an electronic device comprising a memory having a computer program stored therein and a processor arranged to run the computer program to perform the steps of any of the above method embodiments.

In an exemplary embodiment, the electronic apparatus may further include a transmission device and an input/output device, wherein the transmission device is connected to the processor, and the input/output device is connected to the processor.

In an exemplary embodiment, for specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementations, and details of this embodiment are not described herein again.

It will be apparent to those skilled in the art that the various modules or steps of the invention described above may be implemented using a general purpose computing device, they may be centralized on a single computing device or distributed across a network of computing devices, and they may be implemented using program code executable by the computing devices, such that they may be stored in a memory device and executed by the computing device, and in some cases, the steps shown or described may be performed in an order different than that described herein, or they may be separately fabricated into various integrated circuit modules, or multiple ones of them may be fabricated into a single integrated circuit module. Thus, the present invention is not limited to any specific combination of hardware and software.

The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, or improvement made within the principle of the present invention should be included in the protection scope of the present invention.

18页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:镜头模块

网友询问留言

已有0条留言

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

精彩留言,会给你点赞!