CN115484455A - Camera image out-of-focus detection method, device, electronic equipment and storage medium - Google Patents

Camera image out-of-focus detection method, device, electronic equipment and storage medium Download PDF

Info

Publication number
CN115484455A
CN115484455A CN202211110324.1A CN202211110324A CN115484455A CN 115484455 A CN115484455 A CN 115484455A CN 202211110324 A CN202211110324 A CN 202211110324A CN 115484455 A CN115484455 A CN 115484455A
Authority
CN
China
Prior art keywords
video image
image
frame video
current frame
index
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.)
Pending
Application number
CN202211110324.1A
Other languages
Chinese (zh)
Inventor
荣继
隋治强
彭海
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Ruima Video Technology Co ltd
Original Assignee
Beijing Ruima Video Technology Co ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Beijing Ruima Video Technology Co ltd filed Critical Beijing Ruima Video Technology Co ltd
Priority to CN202211110324.1A priority Critical patent/CN115484455A/en
Publication of CN115484455A publication Critical patent/CN115484455A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N17/00Diagnosis, testing or measuring for television systems or their details
    • H04N17/002Diagnosis, testing or measuring for television systems or their details for television cameras

Landscapes

  • Engineering & Computer Science (AREA)
  • Health & Medical Sciences (AREA)
  • Biomedical Technology (AREA)
  • General Health & Medical Sciences (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Studio Devices (AREA)

Abstract

The application discloses a camera image out-of-focus detection method and device, electronic equipment and a storage medium. Firstly, acquiring a video image acquired by a target camera, and calculating the horizontal and longitudinal gradient strength in the current frame video image to obtain a gradient strength map; calculating the mean value of the gradient intensity image to obtain the definition index of the current frame video image; then extracting a consistency characteristic diagram of the current frame video image and the previous frame video image; carrying out average value calculation on the consistency characteristic images of the current frame video image and the previous frame video image to obtain a consistency index of the current frame video image to the previous frame video image; and finally, obtaining an image out-of-focus detection result based on the definition index and the consistency index. The method and the device have the advantages that the gradient intensity index and the consistency characteristic index of the front frame and the back frame of the image are cooperatively detected, so that the detection accuracy is improved; and the number of dynamic images for carrying out consistency characteristic index calculation is 2, and the detection speed is improved.

Description

摄像头图像失焦检测方法、装置、电子设备及存储介质Camera image out-of-focus detection method, device, electronic equipment and storage medium

技术领域technical field

本发明涉及视频图像处理技术领域,特别涉及一种摄像头图像失焦检测方法、装置、电子设备及存储介质。The present invention relates to the technical field of video image processing, in particular to a camera image out-of-focus detection method, device, electronic equipment and storage medium.

背景技术Background technique

国内外许多场景都安装监控摄像头,用于公共安全、交通等领域。在一些情况下,被不法分子用非正常手段进行干扰,或者由于天气原因导致监控摄像头发生图像失焦的情况。现有方案是通过采取人工查看摄像头视频图像的方式,人工做出是否失焦的判断。Surveillance cameras are installed in many scenes at home and abroad for public security, transportation and other fields. In some cases, criminals use abnormal means to interfere, or the image of the surveillance camera is out of focus due to weather. The existing solution is to manually check whether the camera is out of focus by manually checking the video image of the camera.

然而,人工实时监控大量摄像头的工作量极大,并且受到环境等因素影响较大,容易造成误判。However, the workload of manual real-time monitoring of a large number of cameras is enormous, and it is greatly affected by factors such as the environment, which is likely to cause misjudgment.

发明内容Contents of the invention

基于此,本申请实施例提供了一种摄像头图像失焦检测方法、装置、电子设备及存储介质,通过图像处理技术,自动检测摄像头是否图像失焦,能够在毫秒级别的时间内做出报警响应,极大地降低了摄像头的维护工作量,并极大地缩短报警反应时间,提高检测的准确度。Based on this, the embodiment of the present application provides a camera image out-of-focus detection method, device, electronic equipment, and storage medium. Through image processing technology, it can automatically detect whether the camera image is out of focus, and can make an alarm response within milliseconds. , which greatly reduces the maintenance workload of the camera, greatly shortens the alarm response time, and improves the detection accuracy.

第一方面,提供了一种摄像头图像失焦检测方法,该方法包括:In the first aspect, a camera image out-of-focus detection method is provided, the method comprising:

获取目标摄像头所采集的视频图像,计算当前帧视频图像中横向和纵向的梯度强度,得到梯度强度图;Obtain the video image collected by the target camera, calculate the horizontal and vertical gradient strengths in the current frame video image, and obtain the gradient strength map;

对所述梯度强度图进行均值计算,得到所述当前帧视频图像的清晰度指数dft;Carry out mean value calculation to described gradient intensity map, obtain the sharpness index dft of described current frame video image;

提取所述当前帧视频图像和上一帧视频图像的一致性特征图;Extracting the consistency feature map of the current frame video image and the previous frame video image;

对所述当前帧视频图像和所述上一帧视频图像的一致性特征图进行平均值计算,得到当前帧视频图像对比于上一帧视频图像的一致性指数sim;Carry out average value calculation to the consistency feature map of described current frame video image and described last frame video image, obtain the consistency index sim of current frame video image contrast with last frame video image;

基于所述清晰度指数dft和所述一致性指数sim得到图像失焦检测结果。An image out-of-focus detection result is obtained based on the sharpness index dft and the consistency index sim.

可选地,该方法还包括:Optionally, the method also includes:

保存当前帧视频图像的图像数据,用于下一帧视频图像的失焦检测。The image data of the current frame video image is saved for out-of-focus detection of the next frame video image.

可选地,所述基于所述清晰度指数dft和所述一致性指数sim得到图像失焦检测结果,包括:Optionally, the obtaining the image out-of-focus detection result based on the sharpness index dft and the consistency index sim includes:

根据预设的清晰度指数阈值和一致性指数阈值对所述清晰度指数dft和所述一致性指数sim进行校验;Verifying the definition index dft and the consistency index sim according to the preset definition index threshold and consistency index threshold;

当所述清晰度指数dft低于所述清晰度指数阈值,且所述一致性指数sim高于一致性指数阈值时,则确定所述目标摄像头的正在发生图像失焦,并通过预定的通信通道进行失焦报警。When the sharpness index dft is lower than the sharpness index threshold and the consistency index sim is higher than the consistency index threshold, it is determined that the image of the target camera is out of focus, and through a predetermined communication channel Carry out out-of-focus alarm.

可选地,所述计算当前帧视频图像中横向和纵向的梯度强度,得到梯度强度图,包括:Optionally, the calculation of the horizontal and vertical gradient strengths in the current frame video image to obtain a gradient strength map includes:

计算当前帧视频图像中所有像素的灰度值,将当前帧视频图像转换为灰度图像;Calculate the grayscale value of all pixels in the current frame video image, and convert the current frame video image into a grayscale image;

采用前向差商计算各个像素点近似梯度进而得到梯度强度图。The approximate gradient of each pixel is calculated by using the forward difference quotient to obtain the gradient intensity map.

可选地,对所述梯度强度图进行均值计算,得到所述当前帧视频图像的清晰度指数dft,包括:Optionally, performing mean calculation on the gradient intensity map to obtain the definition index dft of the current frame video image, including:

根据第一公式确定清晰度指数dft,所述第一公式具体包括:Determine the definition index dft according to the first formula, and the first formula specifically includes:

Figure BDA0003843802850000021
Figure BDA0003843802850000021

其中,w表示图像的宽度,h表示图像的高度,

Figure BDA0003843802850000022
表示当前图像某个像素点对应的x方向的梯度强度值,
Figure BDA0003843802850000023
表示当前图像某个像素点对应的y方向的梯度强度值,k表示图像中像素点的索引值。Among them, w represents the width of the image, h represents the height of the image,
Figure BDA0003843802850000022
Indicates the gradient strength value in the x direction corresponding to a certain pixel in the current image,
Figure BDA0003843802850000023
Indicates the gradient strength value in the y direction corresponding to a certain pixel in the current image, and k indicates the index value of the pixel in the image.

可选地,提取所述当前帧视频图像和上一帧视频图像的一致性特征图,包括:Optionally, extracting the consistency feature map of the current frame video image and the previous frame video image includes:

基于当前帧视频图像中像素点的灰度值和上一帧视频图像对应像素点的灰度值确定该像素点的一致性特征值;Determine the consistent feature value of the pixel based on the grayscale value of the pixel in the current frame video image and the grayscale value of the corresponding pixel in the previous frame of video image;

遍历视频图像中的所有像素点,得到一致性特征图。Traverse all the pixels in the video image to get the consistent feature map.

可选地,对所述当前帧视频图像和所述上一帧视频图像的一致性特征图进行平均值计算,得到当前帧视频图像对比于上一帧视频图像的一致性指数sim,包括:Optionally, performing average calculation on the consistency feature map of the current frame video image and the previous frame video image to obtain the consistency index sim of the current frame video image compared with the previous frame video image, including:

根据第二公式确定一致性指数sim,所述第二公式具体包括:Determine the consistency index sim according to the second formula, and the second formula specifically includes:

Figure BDA0003843802850000031
Figure BDA0003843802850000031

其中,w表示图像的宽度,h表示图像的高度,simP表示当前帧视频图像在像素点(x,y)位置上的一致性特征值。Among them, w represents the width of the image, h represents the height of the image, and simP represents the consistent feature value of the current frame video image at the pixel (x, y) position.

第二方面,提供了一种摄像头图像失焦检测装置,该装置包括:In a second aspect, a camera image out-of-focus detection device is provided, the device comprising:

梯度计算模块,用于获取目标摄像头所采集的视频图像,计算当前帧视频图像中横向和纵向的梯度强度,得到梯度强度图;The gradient calculation module is used to obtain the video image collected by the target camera, calculate the horizontal and vertical gradient strengths in the current frame video image, and obtain the gradient strength map;

第一计算模块,用于对所述梯度强度图进行均值计算,得到所述当前帧视频图像的清晰度指数dft;The first calculation module is used to calculate the mean value of the gradient intensity map to obtain the definition index dft of the current frame video image;

提取模块,用于提取所述当前帧视频图像和上一帧视频图像的一致性特征图;An extraction module, used to extract the consistency feature map of the current frame video image and the previous frame video image;

第二计算模块,用于对所述当前帧视频图像和所述上一帧视频图像的一致性特征图进行平均值计算,得到当前帧视频图像对比于上一帧视频图像的一致性指数sim;The second calculation module is used to calculate the average value of the consistency feature map of the current frame video image and the previous frame video image, and obtain the consistency index sim of the current frame video image compared with the previous frame video image;

检测模块,基于所述清晰度指数dft和所述一致性指数sim得到图像失焦检测结果。The detection module obtains an image out-of-focus detection result based on the sharpness index dft and the consistency index sim.

第三方面,提供了一种电子设备,包括存储器和处理器,存储器存储有计算机程序,处理器执行计算机程序时实现上述第一方面任一所述的摄像头图像失焦检测方法。In a third aspect, an electronic device is provided, including a memory and a processor, the memory stores a computer program, and when the processor executes the computer program, the camera image defocus detection method described in any one of the above first aspects is implemented.

第四方面,提供了一种计算机可读存储介质,其上存储有计算机程序,计算机程序被处理器执行时实现上述第一方面任一所述的摄像头图像失焦检测方法。In a fourth aspect, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the camera image defocus detection method described in any one of the above-mentioned first aspects is implemented.

本申请实施例提供的技术方案中,首先获取目标摄像头所采集的视频图像,计算当前帧视频图像中横向和纵向的梯度强度,得到梯度强度图;对梯度强度图进行均值计算,得到当前帧视频图像的清晰度指数;然后提取当前帧视频图像和上一帧视频图像的一致性特征图;对当前帧视频图像和上一帧视频图像的一致性特征图进行平均值计算,得到当前帧视频图像对比于上一帧视频图像的一致性指数;最后基于清晰度指数和一致性指数得到图像失焦检测结果。In the technical solution provided by the embodiment of the present application, first obtain the video image collected by the target camera, calculate the horizontal and vertical gradient strengths in the current frame video image, and obtain the gradient strength map; perform mean calculation on the gradient strength map to obtain the current frame video The sharpness index of the image; then extract the consistency feature map of the current frame video image and the previous frame video image; calculate the average value of the consistency feature map of the current frame video image and the previous frame video image to obtain the current frame video image Compared with the consistency index of the previous frame video image; finally, the image out-of-focus detection result is obtained based on the sharpness index and the consistency index.

本申请实施例提供的技术方案带来的有益效果至少包括:The beneficial effects brought by the technical solutions provided by the embodiments of the present application at least include:

(1)检测算法使用的是图像的梯度强度指数和图像的前后帧的一致性特征指数协同检测,准确度有很大提升。(1) The detection algorithm uses the gradient strength index of the image and the consistency feature index of the front and rear frames of the image to jointly detect, and the accuracy is greatly improved.

(2)进行一致性特征指数计算的动态图像数量为2,时间检测自动报警反应时间达到毫秒级,检测的反应速度特别快。(2) The number of dynamic images for the calculation of the consistency characteristic index is 2, the automatic alarm response time of time detection reaches the millisecond level, and the detection reaction speed is particularly fast.

附图说明Description of drawings

为了更清楚地说明本发明的实施方式或现有技术中的技术方案,下面将对实施方式或现有技术描述中所需要使用的附图作简单地介绍。显而易见地,下面描述中的附图仅仅是示例性的,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据提供的附图引申获得其它的实施附图。In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following will briefly introduce the accompanying drawings that are required in the description of the embodiments or the prior art. Apparently, the drawings in the following description are only exemplary, and those skilled in the art can obtain other implementation drawings according to the provided drawings without creative effort.

图1为本申请实施例提供的一种摄像头图像失焦检测方法的步骤流程图;FIG. 1 is a flow chart of the steps of a camera image out-of-focus detection method provided by an embodiment of the present application;

图2为本申请可选的一种实施例提供的摄像头图像失焦检测方法的步骤流程图;FIG. 2 is a flow chart of the steps of a camera image out-of-focus detection method provided in an optional embodiment of the present application;

图3为本申请实施例提供的一种摄像头图像失焦检测装置的框图;FIG. 3 is a block diagram of a camera image out-of-focus detection device provided by an embodiment of the present application;

图4为本申请实施例提供的一种电子设备的示意图。FIG. 4 is a schematic diagram of an electronic device provided by an embodiment of the present application.

具体实施方式detailed description

为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。In order to make the purpose, technical solution and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described here are only used to explain the present application, and are not intended to limit the present application.

在本发明的描述中,术语“包括”、“具有”以及他们的任何变形,意图在于覆盖不排他的包含,例如,包括了一系列步骤或单元的过程、方法、系统、产品或设备不必限于已明确列出的那些步骤或单元,而是还可包含虽然并未明确列出的但对于这些过程、方法、产品或设备固有的其它步骤或单元,或者基于本发明构思进一步的优化方案所增加的步骤或单元。In the description of the present invention, the terms "comprising", "having" and any variations thereof are intended to cover a non-exclusive inclusion, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to Those steps or units that have been explicitly listed, but may also include other steps or units that are not explicitly listed but inherent to these processes, methods, products or equipment, or are added based on the further optimization scheme of the present invention. steps or units.

为了解决现有技术中存在的人工维护摄像头图像失焦的实时检测问题,本发明通过图像处理技术,自动检测摄像头是否图像失焦,能够在毫秒级别的时间内做出报警响应,极大地降低了摄像头的维护工作量,并极大地缩短报警反应时间,提高检测的准确度。本发明通过图像处理技术,自动检测摄像头是否发生图像失焦,能够在毫秒级别的时间内做出报警响应。请参考图1,其示出了本申请实施例提供的一种摄像头图像失焦检测方法的流程图,该方法可以包括以下步骤:In order to solve the real-time detection problem of manual maintenance camera image out-of-focus existing in the prior art, the present invention automatically detects whether the camera image is out of focus through image processing technology, and can make an alarm response within milliseconds, greatly reducing the The maintenance workload of the camera is reduced, and the alarm response time is greatly shortened, and the detection accuracy is improved. The present invention automatically detects whether the image of the camera is out of focus through the image processing technology, and can make an alarm response within millisecond level. Please refer to FIG. 1, which shows a flow chart of a camera image out-of-focus detection method provided by an embodiment of the present application. The method may include the following steps:

步骤101,获取目标摄像头所采集的视频图像,计算当前帧视频图像中横向和纵向的梯度强度,得到梯度强度图。In step 101, the video image collected by the target camera is obtained, and the horizontal and vertical gradient strengths in the current frame of the video image are calculated to obtain a gradient strength map.

在本申请实施例中,计算当前帧视频图像中所有像素的灰度值,将当前帧视频图像转换为灰度图像。采用前向差商计算各个像素点近似梯度进而得到梯度强度图。In the embodiment of the present application, the grayscale values of all pixels in the current frame video image are calculated, and the current frame video image is converted into a grayscale image. The approximate gradient of each pixel is calculated by using the forward difference quotient to obtain the gradient intensity map.

在本步骤中计算摄像头当前时刻的视频图像的横向和纵向的梯度强度,得到梯度强度图中,In this step, the horizontal and vertical gradient strengths of the video image at the current moment of the camera are calculated to obtain the gradient strength map,

图像的灰度,指的是图像像素的强度,黑色为最暗,白色为最亮,黑色用0来表示,白色用255来表示。The gray level of the image refers to the intensity of the image pixel, black is the darkest, white is the brightest, black is represented by 0, and white is represented by 255.

一个像素,基本上是用RGB三个颜色分量来表示的。R(0-255),G(0-255),B(0-255)。A pixel is basically represented by three color components of RGB. R (0-255), G (0-255), B (0-255).

图像的灰度,就是去掉颜色之后,还剩下的东西,表示了图像的明暗程度。The grayscale of the image is what is left after removing the color, which represents the lightness and darkness of the image.

通过下面的方法计算得到像素的灰度值f(x,y)。The gray value f(x,y) of the pixel is calculated by the following method.

方法:f(x,y)=(R(x,y)+G(x,y)+B(x,y))/3Method: f(x,y)=(R(x,y)+G(x,y)+B(x,y))/3

x,y表示图像中像素的坐标。x, y represent the coordinates of the pixels in the image.

通过上面的方法,图像就转换为灰度图像,其实就是像素位置的二元函数f(x,y),只不过是离散的,图像梯度就是这个二元离散函数的偏导。计算图像梯度是逐个像素点求的。Through the above method, the image is converted into a grayscale image, which is actually the binary function f(x, y) of the pixel position, but it is discrete, and the image gradient is the partial derivative of this binary discrete function. The image gradient is calculated pixel by pixel.

连续二元函数的偏导数为:The partial derivatives of continuous binary functions are:

Figure BDA0003843802850000061
Figure BDA0003843802850000061

Figure BDA0003843802850000062
Figure BDA0003843802850000062

但是图像是离散函数,Δx没有办法趋于0,最小只能是间隔1,因此需要使用有限差分来计算近似梯度,本方法采用的是前向差商计算近似梯度。因此,图像偏导公式转变为如下公式:But the image is a discrete function, there is no way for Δx to tend to 0, and the minimum can only be an interval of 1, so it is necessary to use finite difference to calculate the approximate gradient. This method uses the forward difference quotient to calculate the approximate gradient. Therefore, the image partial derivative formula is transformed into the following formula:

Figure BDA0003843802850000063
Figure BDA0003843802850000063

Figure BDA0003843802850000064
Figure BDA0003843802850000064

x,y表示图像中像素的坐标。x, y represent the coordinates of the pixels in the image.

步骤102,对梯度强度图进行均值计算,得到当前帧视频图像的清晰度指数dft。Step 102, performing mean calculation on the gradient intensity map to obtain the sharpness index dft of the current frame video image.

在本申请实施例中,对视频图像的横向和纵向的梯度强度图进行均值计算,得到图像的清晰度指数dft,包括:In the embodiment of the present application, the average value calculation is performed on the horizontal and vertical gradient intensity maps of the video image to obtain the image definition index dft, including:

根据第一公式确定清晰度指数dft,第一公式具体包括:Determine the definition index dft according to the first formula, the first formula specifically includes:

Figure BDA0003843802850000071
Figure BDA0003843802850000071

其中,w表示图像的宽度,h表示图像的高度,

Figure BDA0003843802850000072
表示当前图像某个像素点对应的x方向的梯度强度值,
Figure BDA0003843802850000073
表示当前图像某个像素点对应的y方向的梯度强度值,k表示图像中像素点的索引值。Among them, w represents the width of the image, h represents the height of the image,
Figure BDA0003843802850000072
Indicates the gradient strength value in the x direction corresponding to a certain pixel of the current image,
Figure BDA0003843802850000073
Indicates the gradient strength value in the y direction corresponding to a certain pixel in the current image, and k indicates the index value of the pixel in the image.

步骤103,提取当前帧视频图像和上一帧视频图像的一致性特征图。Step 103, extracting the consistency feature map between the video image of the current frame and the video image of the previous frame.

在本申请实施例中,提取当前帧视频图像和上一帧视频图像的一致性特征图,包括:In the embodiment of the present application, the consistency feature map of the current frame video image and the previous frame video image is extracted, including:

基于当前帧视频图像中像素点的灰度值和上一帧视频图像对应像素点的灰度值确定该像素点的一致性特征值;遍历视频图像中的所有像素点,得到一致性特征图。Determine the consistent feature value of the pixel based on the gray value of the pixel in the current frame video image and the gray value of the corresponding pixel in the previous frame video image; traverse all the pixels in the video image to obtain the consistent feature map.

具体地,具体通过:Specifically, through:

simP(x,y)=abs(f(x,y)-fp(x,y))simP(x,y)=abs(f(x,y)-fp(x,y))

进行确定,其中,x,y表示图像中某个像素的坐标,f(x,y)为当前图像的灰度值,fp(x,y)为当前图像前一帧图像的灰度值,simP(x,y)为当前图像在像素点(x,y)位置上的像素一致性特征值,abs函数表示对输入参数进行求绝对值计算。Determine, where x, y represent the coordinates of a pixel in the image, f(x, y) is the gray value of the current image, fp(x, y) is the gray value of the previous frame of the current image, simP (x, y) is the pixel consistency feature value of the current image at the pixel point (x, y), and the abs function means to calculate the absolute value of the input parameters.

步骤104,对当前帧视频图像和上一帧视频图像的一致性特征图进行平均值计算,得到当前帧视频图像对比于上一帧视频图像的一致性指数sim。Step 104: Perform average calculation on the consistency feature map of the current frame video image and the previous frame video image to obtain the consistency index sim of the current frame video image compared with the previous frame video image.

在本申请实施例中,根据第二公式确定一致性指数sim,第二公式具体包括:In the embodiment of the present application, the consistency index sim is determined according to the second formula, and the second formula specifically includes:

Figure BDA0003843802850000081
Figure BDA0003843802850000081

其中,w表示图像的宽度,h表示图像的高度,simP表示当前帧视频图像在像素点(x,y)位置上的一致性特征值。Among them, w represents the width of the image, h represents the height of the image, and simP represents the consistent feature value of the current frame video image at the pixel (x, y) position.

步骤105,基于清晰度指数dft和一致性指数sim得到图像失焦检测结果。In step 105, an image out-of-focus detection result is obtained based on the definition index dft and the consistency index sim.

其中,对sim值和dft值进行校验,sim值越高,则前后帧图像的差异越大,sim值越低,则前后帧图像的差异越小。dft指数值越高,则说明图像越清晰,dft指数值越低,则说明图像越模糊。Wherein, the sim value and the dft value are checked, the higher the sim value, the greater the difference between the front and back frame images, and the lower the sim value, the smaller the difference between the front and back frame images. The higher the dft index value, the clearer the image, and the lower the dft index value, the blurrier the image.

在本申请实施例中,根据预设的清晰度指数阈值和一致性指数阈值对清晰度指数dft和一致性指数sim进行校验;当清晰度指数dft低于清晰度指数阈值,且一致性指数sim高于一致性指数阈值时,则确定目标摄像头的正在发生图像失焦,并通过预定的通信通道进行失焦报警。In the embodiment of the present application, the clarity index dft and the consistency index sim are verified according to the preset clarity index threshold and consistency index threshold; when the clarity index dft is lower than the clarity index threshold, and the consistency index When the sim is higher than the consistency index threshold, it is determined that the image of the target camera is out of focus, and an out-of-focus alarm is issued through a predetermined communication channel.

具体地,本申请中预设的清晰度指数阈值可以为(7.0-10.0)之间任意数,一致性指数阈值可以为(3.0-5.0)任意数。Specifically, the preset sharpness index threshold in this application may be any number between (7.0-10.0), and the consistency index threshold may be any number (3.0-5.0).

当dft指数低于预设值(7.0-10.0),并且sim指数高于预设值(3.0-5.0),本方法则认为摄像头本帧视频图像对比之前的图像,正在发生图像失焦的变化,即通过预定的通信通道进行失焦报警。反之,则认为没有失焦,不进行报警。When the dft index is lower than the preset value (7.0-10.0), and the sim index is higher than the preset value (3.0-5.0), this method considers that the current frame video image of the camera is changing from the previous image, and the image is out of focus. That is, an out-of-focus alarm is performed through a predetermined communication channel. On the contrary, it is considered that there is no out-of-focus, and no alarm is issued.

在步骤105之后还包括:Also include after step 105:

步骤106,保存当前帧视频图像的图像数据,用于下一帧视频图像的失焦检测。Step 106, saving the image data of the current frame of video image for defocus detection of the next frame of video image.

在本申请实施例中,保存当前图像数据到缓存,用于后续视频图像的失焦检测。In the embodiment of the present application, the current image data is stored in the cache for defocus detection of subsequent video images.

如图2,给出了通过本申请方法进行摄像头图像失焦检测处理流程,具体包括了:As shown in Figure 2, the processing flow of camera image out-of-focus detection through the method of this application is given, which specifically includes:

步骤201,提取当前图像的梯度强度;Step 201, extracting the gradient strength of the current image;

步骤202,计算当前图像的梯度强度指数;Step 202, calculating the gradient strength index of the current image;

步骤203,提取当前图像与前一帧图像的一致性特征图;Step 203, extracting the consistency feature map between the current image and the previous frame image;

步骤204,计算当前图像与前一帧图像的一致性特征指数;Step 204, calculating the consistency feature index between the current image and the previous frame image;

步骤205,使用梯度强度指数和一致性特征指数进行失焦检测;Step 205, using the gradient strength index and the consistency characteristic index to perform out-of-focus detection;

步骤206,更新或添加缓存图像数据。Step 206, updating or adding cached image data.

综上可以看出,本申请使用单帧视频图像梯度强度图和多帧视频图像的前后帧的一致性特征图进行图像的特征计算。并且提出了基于计算梯度强度图的方法和计算图像的前后帧的一致性特征图的方法。同时检测算法使用的是图像的梯度强度指数和图像的前后帧的一致性特征指数协同检测。To sum up, it can be seen that this application uses the gradient intensity map of a single frame video image and the consistency feature map of the preceding and following frames of a multi-frame video image to perform image feature calculation. And a method based on calculating the gradient intensity map and a method of calculating the consistency feature map of the front and back frames of the image are proposed. The simultaneous detection algorithm uses the gradient strength index of the image and the consistency feature index of the front and rear frames of the image to jointly detect.

请参考图3,其示出了本申请实施例提供的一种摄像头图像失焦检测装置300的框图。如图3所示,该装置300可以包括:梯度计算模块301、第一计算模块302、提取模块303、第二计算模块304以及检测模块305。Please refer to FIG. 3 , which shows a block diagram of a camera image out-of-focus detection device 300 provided by an embodiment of the present application. As shown in FIG. 3 , the apparatus 300 may include: a gradient calculation module 301 , a first calculation module 302 , an extraction module 303 , a second calculation module 304 and a detection module 305 .

梯度计算模块301,用于获取目标摄像头所采集的视频图像,计算当前帧视频图像中横向和纵向的梯度强度,得到梯度强度图;The gradient calculation module 301 is used to obtain the video image collected by the target camera, calculate the horizontal and vertical gradient strength in the current frame video image, and obtain the gradient strength map;

第一计算模块302,用于对梯度强度图进行均值计算,得到当前帧视频图像的清晰度指数dft;The first calculation module 302 is used to calculate the mean value of the gradient intensity map to obtain the definition index dft of the current frame video image;

提取模块303,用于提取当前帧视频图像和上一帧视频图像的一致性特征图;The extraction module 303 is used to extract the consistency feature map of the current frame video image and the previous frame video image;

第二计算模块304,用于对当前帧视频图像和上一帧视频图像的一致性特征图进行平均值计算,得到当前帧视频图像对比于上一帧视频图像的一致性指数sim;The second calculation module 304 is used to calculate the average value of the consistency feature map of the current frame video image and the previous frame video image, and obtain the consistency index sim of the current frame video image compared with the previous frame video image;

检测模块305,基于清晰度指数dft和一致性指数sim得到图像失焦检测结果。The detection module 305 obtains an image out-of-focus detection result based on the definition index dft and the consistency index sim.

关于摄像头图像失焦检测装置的具体限定可以参见上文中对于摄像头图像失焦检测方法的限定,在此不再赘述。上述摄像头图像失焦检测装置中的各个模块可全部或部分通过软件、硬件及其组合来实现。上述各模块可以硬件形式内嵌于或独立于计算机设备中的处理器中,也可以以软件形式存储于计算机设备中的存储器中,以便于处理器调用执行以上各个模块对应的操作。For the specific limitations of the camera image out-of-focus detection device, refer to the above-mentioned definition of the camera image out-of-focus detection method, which will not be repeated here. Each module in the above camera image out-of-focus detection device can be fully or partially realized by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, and can also be stored in the memory of the computer device in the form of software, so that the processor can invoke and execute the corresponding operations of the above-mentioned modules.

在一个实施例中,提供了一种电子设备,该电子设备可以是计算机,其内部结构图可以如图4所示。该电子设备包括通过系统总线连接的处理器、存储器和网络接口。其中,该设备的处理器用于提供计算和控制能力。该设备的存储器包括非易失性存储介质、内存储器。该非易失性存储介质存储有操作系统、计算机程序和数据库。该内存储器为非易失性存储介质中的操作系统和计算机程序的运行提供环境。该计算机设备的数据库用于摄像头图像失焦检测数据。该计算机设备的网络接口用于与外部的终端通过网络连接通信。该计算机程序被处理器执行时以实现一种摄像头图像失焦检测方法。In one embodiment, an electronic device is provided. The electronic device may be a computer, and its internal structure may be as shown in FIG. 4 . The electronic device includes a processor, memory and network interface connected by a system bus. Among them, the processor of the device is used to provide computing and control capabilities. The memory of the device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, computer programs and databases. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The database of the computer device is used for camera image out-of-focus detection data. The network interface of the computer device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, a camera image out-of-focus detection method is realized.

本领域技术人员可以理解,如图4中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的计算机设备的限定,具体的计算机设备可以包括比图中所示更多或更少的部件,或者组合某些部件,或者具有不同的部件布置。Those skilled in the art can understand that the structure shown in Figure 4 is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation to the computer equipment on which the solution of the application is applied. The specific computer equipment More or fewer components than shown in the figures may be included, or certain components may be combined, or have a different arrangement of components.

在本申请的一个实施例中,提供了一种计算机可读存储介质,其上存储有计算机程序,计算机程序被处理器执行时实现上述摄像头图像失焦检测方法的步骤。In one embodiment of the present application, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the above-mentioned camera image out-of-focus detection method are implemented.

本实施例提供的计算机可读存储介质,其实现原理和技术效果与上述方法实施例类似,在此不再赘述。The implementation principle and technical effect of the computer-readable storage medium provided in this embodiment are similar to those of the above-mentioned method embodiments, and details are not repeated here.

本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成,所述的计算机程序可存储于一非易失性计算机可读取存储介质中,该计算机程序在执行时,可包括如上述各方法的实施例的流程。其中,本申请所提供的各实施例中所使用的对存储器、存储、数据库或其它介质的任何引用,均可包括非易失性和/或易失性存储器。非易失性存储器可包括只读存储器(ROM)、可编程ROM(PROM)、电可编程ROM(EPROM)、电可擦除可编程ROM(EEPROM)或闪存。易失性存储器可包括随机存取存储器(RAM)或者外部高速缓冲存储器。作为说明而非局限,RAM以M种形式可得,诸如静态RAM(SRAM)、动态RAM(DRAM)、同步DRAM(SDRAM)、双数据率SDRAM(DDRSDRAM)、增强型SDRAM(ESDRAM)、同步链路(SyMchliMk)DRAM(SLDRAM)、存储器总线(RaMbus)直接RAM(RDRAM)、直接存储器总线动态RAM(DRDRAM)、以及存储器总线动态RAM(RDRAM)等。Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be implemented through computer programs to instruct related hardware, and the computer programs can be stored in a non-volatile computer-readable memory In the medium, when the computer program is executed, it may include the processes of the embodiments of the above-mentioned methods. Wherein, any references to memory, storage, database or other media used in the various embodiments provided in the present application may include non-volatile and/or volatile memory. Nonvolatile memory can include read only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in M forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), Synchronous Chain Road (SyMchliMk) DRAM (SLDRAM), memory bus (RaMbus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

以上实施例的各技术特征可以进行任意的组合(只要这些技术特征的组合不存在矛盾),为使描述简洁,未对上述实施例中的各个技术特征所有可能的组合都进行描述;这些未明确写出的实施例,也都应当认为是本说明书记载的范围。The technical features of the above embodiments can be combined arbitrarily (as long as there is no contradiction in the combination of these technical features), for the sake of concise description, all possible combinations of the various technical features in the above embodiments are not described; these are not clear All the written examples should also be regarded as within the scope of the description in this specification.

上文中通过一般性说明及具体实施例对本申请作了较为具体和详细的描述。应当理解,基于本申请的技术构思,还可以对这些具体实施例作出若干常规的调整或进一步的创新;但只要未脱离本申请的技术构思,这些常规的调整或进一步的创新得到的技术方案也同样落入本申请的权利要求保护范围。The present application has been described more specifically and in detail through general descriptions and specific examples above. It should be understood that based on the technical concept of the present application, some conventional adjustments or further innovations can also be made to these specific embodiments; Also fall within the protection scope of the claims of the present application.

Claims (10)

1. A camera image out-of-focus detection method is characterized by comprising the following steps:
acquiring a video image acquired by a target camera, and calculating the horizontal and longitudinal gradient strength in the current frame video image to obtain a gradient strength map;
performing mean value calculation on the gradient intensity image to obtain a definition index dft of the current frame video image;
extracting a consistency characteristic diagram of the current frame video image and the previous frame video image;
calculating the average value of the consistency characteristic graphs of the current frame video image and the previous frame video image to obtain a consistency index sim of the current frame video image compared with the previous frame video image;
and obtaining an image out-of-focus detection result based on the definition index dft and the consistency index sim.
2. The method of claim 1, further comprising:
and saving the image data of the current frame video image for the out-of-focus detection of the next frame video image.
3. The method according to claim 1, wherein the deriving an out-of-focus image detection result based on the sharpness index dft and the consistency index sim comprises:
verifying the definition index dft and the consistency index sim according to a preset definition index threshold and a consistency index threshold;
and when the definition index dft is lower than the definition index threshold value and the consistency index sim is higher than the consistency index threshold value, determining that the target camera is in the process of image defocusing, and performing defocusing alarm through a preset communication channel.
4. The method of claim 1, wherein the calculating the horizontal and vertical gradient strengths in the video image of the current frame to obtain a gradient strength map comprises:
calculating the gray values of all pixels in the current frame video image, and converting the current frame video image into a gray image;
and calculating the approximate gradient of each pixel point by adopting a forward difference quotient to obtain a gradient intensity graph.
5. The method according to claim 1, wherein the averaging the gradient intensity map to obtain the sharpness index dft of the current frame video image comprises:
determining a sharpness index dft according to a first formula, wherein the first formula specifically comprises:
Figure FDA0003843802840000021
wherein,w represents the width of the image, h represents the height of the image,
Figure FDA0003843802840000022
representing the gradient intensity value in the x direction corresponding to a certain pixel point of the current image,
Figure FDA0003843802840000023
and k represents an index value of a pixel point in the image.
6. The method of claim 1, wherein extracting the consistent feature map of the current frame video image and the previous frame video image comprises:
determining the consistency characteristic value of a pixel point based on the gray value of the pixel point in the current frame video image and the gray value of the pixel point corresponding to the previous frame video image;
and traversing all pixel points in the video image to obtain a consistency characteristic diagram.
7. The method of claim 1, wherein averaging the consistency feature maps of the current frame video image and the previous frame video image to obtain a consistency index sim of the current frame video image compared to the previous frame video image comprises:
determining a consistency index sim according to a second formula, wherein the second formula specifically comprises:
Figure FDA0003843802840000024
wherein w represents the width of the image, h represents the height of the image, and simP represents the consistency characteristic value of the current frame video image at the position of the pixel point (x, y).
8. A camera image out-of-focus detection apparatus, the apparatus comprising:
the gradient calculation module is used for acquiring a video image acquired by the target camera, and calculating the transverse and longitudinal gradient strength in the current frame video image to obtain a gradient strength map;
the first calculation module is used for calculating the mean value of the gradient intensity image to obtain the definition index dft of the current frame video image;
the extraction module is used for extracting the consistency characteristic graph of the current frame video image and the previous frame video image;
the second calculation module is used for carrying out average value calculation on the consistency characteristic images of the current frame video image and the previous frame video image to obtain a consistency index sim of the current frame video image compared with the previous frame video image;
and the detection module is used for obtaining an image out-of-focus detection result based on the definition index dft and the consistency index sim.
9. An electronic device, comprising a memory and a processor, the memory storing a computer program which, when executed by the processor, implements the camera image out-of-focus detection method according to any one of claims 1 to 7.
10. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the camera image out-of-focus detection method according to any one of claims 1 to 7.
CN202211110324.1A 2022-09-13 2022-09-13 Camera image out-of-focus detection method, device, electronic equipment and storage medium Pending CN115484455A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211110324.1A CN115484455A (en) 2022-09-13 2022-09-13 Camera image out-of-focus detection method, device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211110324.1A CN115484455A (en) 2022-09-13 2022-09-13 Camera image out-of-focus detection method, device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN115484455A true CN115484455A (en) 2022-12-16

Family

ID=84423442

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211110324.1A Pending CN115484455A (en) 2022-09-13 2022-09-13 Camera image out-of-focus detection method, device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115484455A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116156245A (en) * 2023-01-06 2023-05-23 深圳市朗驰欣创科技股份有限公司 Video jitter rapid detection method, device, computer equipment and medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100315512A1 (en) * 2008-03-05 2010-12-16 Huawei Device Co., Ltd Method and System for Processing Images
CN108833770A (en) * 2018-05-23 2018-11-16 释码融和(上海)信息科技有限公司 Image definition calculation method, calculating equipment and focusing system for focusing
WO2022057670A1 (en) * 2020-09-17 2022-03-24 深圳光峰科技股份有限公司 Real-time focusing method, apparatus and system, and computer-readable storage medium
CN114339182A (en) * 2021-12-30 2022-04-12 上海顺久电子科技有限公司 Focusing method of projection equipment, projection equipment and storage medium
CN114913171A (en) * 2022-06-22 2022-08-16 杭州萤石软件有限公司 Image out-of-focus detection method and device, electronic equipment and storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100315512A1 (en) * 2008-03-05 2010-12-16 Huawei Device Co., Ltd Method and System for Processing Images
CN108833770A (en) * 2018-05-23 2018-11-16 释码融和(上海)信息科技有限公司 Image definition calculation method, calculating equipment and focusing system for focusing
WO2022057670A1 (en) * 2020-09-17 2022-03-24 深圳光峰科技股份有限公司 Real-time focusing method, apparatus and system, and computer-readable storage medium
CN114339182A (en) * 2021-12-30 2022-04-12 上海顺久电子科技有限公司 Focusing method of projection equipment, projection equipment and storage medium
CN114913171A (en) * 2022-06-22 2022-08-16 杭州萤石软件有限公司 Image out-of-focus detection method and device, electronic equipment and storage medium

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116156245A (en) * 2023-01-06 2023-05-23 深圳市朗驰欣创科技股份有限公司 Video jitter rapid detection method, device, computer equipment and medium

Similar Documents

Publication Publication Date Title
US20210099646A1 (en) Method and Apparatus for Detecting Subject, Electronic Device, and Computer Readable Storage Medium
CN109447942B (en) Image ambiguity determining method, apparatus, computer device and storage medium
CN114049499A (en) Target object detection method, device and storage medium for continuous contour
CN111915541B (en) Image enhancement processing method, device, equipment and medium based on artificial intelligence
CN108805103A (en) Image processing method and device, electronic equipment and computer readable storage medium
CN112312030A (en) Photographing light supplement method and device, computer equipment and storage medium
CN109035287B (en) Foreground image extraction method and device and moving vehicle identification method and device
CN114764775A (en) Infrared image quality evaluation method, device and storage medium
CN110620881A (en) License plate exposure compensation method and device, computer equipment and storage medium
WO2020233397A1 (en) Method and apparatus for detecting target in video, and computing device and storage medium
CN114141187B (en) Mura compensation method, device and system and display equipment
CN111488945A (en) Image processing method, image processing device, computer equipment and computer readable storage medium
CN113888429A (en) Image brightening method and device, electronic device
WO2022194079A1 (en) Sky region segmentation method and apparatus, computer device, and storage medium
CN116645527A (en) Image recognition method, system, electronic device and storage medium
CN116994194A (en) Abnormal picture identification method, system, computer equipment and media
CN111091146A (en) Image similarity acquisition method, device, computer equipment and storage medium
CN115484455A (en) Camera image out-of-focus detection method, device, electronic equipment and storage medium
CN112258467B (en) Image definition detection method and device and storage medium
CN112036342B (en) Document snapshot method, device and computer storage medium
JPWO2022165462A5 (en)
CN111445411A (en) Image denoising method and device, computer equipment and storage medium
CN113573137B (en) Video canvas boundary detection method, system, terminal equipment and storage medium
US11495006B2 (en) Object detection method for static scene and associated electronic device
CN111402147B (en) Video image processing method, video image processing device, computer equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination