[go: up one dir, main page]

CN115334228B - Video processing method and related device - Google Patents

Video processing method and related device Download PDF

Info

Publication number
CN115334228B
CN115334228B CN202110454370.2A CN202110454370A CN115334228B CN 115334228 B CN115334228 B CN 115334228B CN 202110454370 A CN202110454370 A CN 202110454370A CN 115334228 B CN115334228 B CN 115334228B
Authority
CN
China
Prior art keywords
image
terminal
target
block
area
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202110454370.2A
Other languages
Chinese (zh)
Other versions
CN115334228A (en
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.)
Huawei Technologies Co Ltd
Original Assignee
Huawei Technologies 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 Huawei Technologies Co Ltd filed Critical Huawei Technologies Co Ltd
Priority to CN202110454370.2A priority Critical patent/CN115334228B/en
Priority to PCT/CN2022/087554 priority patent/WO2022228196A1/en
Publication of CN115334228A publication Critical patent/CN115334228A/en
Application granted granted Critical
Publication of CN115334228B publication Critical patent/CN115334228B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N23/00Cameras or camera modules comprising electronic image sensors; Control thereof
    • H04N23/60Control of cameras or camera modules
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N23/00Cameras or camera modules comprising electronic image sensors; Control thereof
    • H04N23/70Circuitry for compensating brightness variation in the scene
    • H04N23/76Circuitry for compensating brightness variation in the scene by influencing the image signals
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N23/00Cameras or camera modules comprising electronic image sensors; Control thereof
    • H04N23/80Camera processing pipelines; Components thereof
    • H04N23/81Camera processing pipelines; Components thereof for suppressing or minimising disturbance in the image signal generation

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Studio Devices (AREA)

Abstract

The application discloses a video processing method which is applied to a terminal. The method comprises the following steps: when the terminal is in a night scene shooting mode, detecting whether a lamplight area exists in an image shot by the terminal; when a lamplight area exists in an image shot by a terminal, determining a first image in an image sequence acquired by the terminal, wherein the adjacent area of the lamplight area in the first image is overexposed; determining a second image and a third image in the image sequence according to the first image, wherein the overexposure degree of the adjacent areas of the light areas in the second image and the third image is smaller than that of the adjacent areas of the light areas in the first image; generating a target image according to the first image, the second image and the third image; based on the target image, a video is generated. Based on the scheme, the tremble image in the video can be replaced by the image which is normally displayed, so that the problem that the light area in the video picture is abnormally widened due to lens shake is solved.

Description

一种视频处理方法及相关装置A video processing method and related device

技术领域Technical Field

本申请涉及视频处理技术领域,尤其涉及一种视频处理方法及相关装置。The present application relates to the field of video processing technology, and in particular to a video processing method and related devices.

背景技术Background Art

随着社会的发展,人们越来越多的使用各种终端进行视频拍摄,包括消费者领域以及视频监控领域等。智能手机等便携式终端设备拍摄视频时的镜头抖动问题一直是生成高质量视频的最大难点之一。由于便携式终端比较轻便,用户通常会一边移动一边使用便携式终端拍摄视频,导致视频画面不稳定。在用户的移动过程中,便携式终端的镜头会发生抖动,从而导致视频画面中的灯光区域被更大区域的感光元件感应到,出现视频画面中的灯光区域不正常外扩的现象。With the development of society, people are increasingly using various terminals to shoot videos, including in the consumer field and video surveillance field. The lens shake problem when shooting videos with portable terminal devices such as smartphones has always been one of the biggest difficulties in generating high-quality videos. Since portable terminals are relatively light, users usually use portable terminals to shoot videos while moving, resulting in unstable video images. During the user's movement, the lens of the portable terminal will shake, causing the light area in the video image to be sensed by the photosensitive element in a larger area, resulting in the abnormal expansion of the light area in the video image.

目前,亟需一种视频处理方案,以解决由镜头抖动所引起的视频画面中的灯光区域不正常外扩的问题。Currently, there is an urgent need for a video processing solution to solve the problem of abnormal expansion of the light area in the video image caused by lens shaking.

发明内容Summary of the invention

本申请提供了一种视频处理方法,能够将视频中的震颤图像替换为正常显示的图像,从而解决由镜头抖动所引起的视频画面中的灯光区域不正常外扩的问题。The present application provides a video processing method, which can replace the shaky image in the video with a normally displayed image, thereby solving the problem of abnormal expansion of the light area in the video screen caused by lens shaking.

本申请第一方面提供一种视频处理方法,该方法可以应用于终端。该方法包括:当终端处于夜景拍摄模式时,检测所述终端拍摄的图像中是否存在灯光区域。The first aspect of the present application provides a video processing method, which can be applied to a terminal. The method comprises: when the terminal is in a night scene shooting mode, detecting whether there is a light area in an image shot by the terminal.

当所述终端拍摄的图像中存在灯光区域时,终端在采集的图像序列中确定第一图像,所述第一图像中的灯光区域的邻近区域出现过曝。所述第一图像中的灯光区域的邻近区域出现过曝是指该邻近区域中的像素的亮度值过高。第一图像中的灯光区域的邻近区域出现过曝的原因是终端在采集第一图像的时候发生了抖动位移,使得终端中对应于邻近区域的感光元件同样感应到了灯光区域内的光线,最终导致第一图像中的灯光区域的邻近区域出现过曝。When there is a light area in the image captured by the terminal, the terminal determines a first image in the acquired image sequence, and an area adjacent to the light area in the first image is overexposed. The overexposure of the area adjacent to the light area in the first image means that the brightness value of the pixels in the adjacent area is too high. The reason why the area adjacent to the light area in the first image is overexposed is that the terminal has a jitter displacement when acquiring the first image, so that the photosensitive element corresponding to the adjacent area in the terminal also senses the light in the light area, which ultimately causes the area adjacent to the light area in the first image to be overexposed.

在确定第一图像后,终端根据所述第一图像在所述图像序列中确定第二图像和第三图像,所述第一图像的采集时刻位于所述第二图像的采集时刻与所述第三图像的采集时刻之间,所述第二图像以及所述第三图像中的灯光区域的邻近区域的过曝程度小于所述第一图像中的灯光区域邻近区域的过曝程度。其中,第二图像以及第三图像中的灯光区域与第一图像中的灯光区域具有对应关系,即第二图像以及第三图像中的灯光区域与第一图像中的灯光区域表示的是相同的画面内容。例如,第二图像和第三图像中的灯光区域表示的是某一个路灯的发光区域;第一图像中的灯光区域也是表示同一个路灯的发光区域。After determining the first image, the terminal determines the second image and the third image in the image sequence according to the first image, the acquisition time of the first image is between the acquisition time of the second image and the acquisition time of the third image, and the overexposure degree of the adjacent area of the light area in the second image and the third image is less than the overexposure degree of the adjacent area of the light area in the first image. Among them, the light area in the second image and the third image has a corresponding relationship with the light area in the first image, that is, the light area in the second image and the third image represents the same picture content as the light area in the first image. For example, the light area in the second image and the third image represents the light-emitting area of a street lamp; the light area in the first image also represents the light-emitting area of the same street lamp.

终端根据所述第一图像、所述第二图像和所述第三图像生成目标图像,所述目标图像用于替换所述第一图像,所述目标图像的灯光区域的邻近区域的过曝程度小于所述第一图像的灯光区域的邻近区域的过曝程度。其中,第二图像和第三图像用于作为参考图像来生成替换第一图像的目标图像,以使得生成的目标图像的灯光区域的邻近区域的过曝程度小于所述第一图像的灯光区域的邻近区域的过曝程度。The terminal generates a target image based on the first image, the second image, and the third image, the target image is used to replace the first image, and the overexposure degree of the neighboring area of the light area of the target image is smaller than the overexposure degree of the neighboring area of the light area of the first image. The second image and the third image are used as reference images to generate a target image to replace the first image, so that the overexposure degree of the neighboring area of the light area of the generated target image is smaller than the overexposure degree of the neighboring area of the light area of the first image.

终端基于所述目标图像,生成视频。具体地,终端可以是将采集得到的图像序列中的第一图像替换为目标图像,从而生成视频。The terminal generates a video based on the target image. Specifically, the terminal may replace the first image in the acquired image sequence with the target image, thereby generating a video.

本实施例中,通过在夜景拍摄模式下定位灯光区域的邻近区域出现过曝的震颤图像,将震颤图像前后的图像作为参考图像,并基于震颤图像以及参考图像来生成用于替换震颤图像的目标图像。通过本方案,能够将视频中的震颤图像替换为正常显示的图像,从而解决由镜头抖动所引起的视频画面中的光亮部分灯光区域不正常外扩的问题。In this embodiment, by locating the overexposed trembling image in the vicinity of the light area in the night scene shooting mode, the images before and after the trembling image are used as reference images, and a target image for replacing the trembling image is generated based on the trembling image and the reference image. Through this solution, the trembling image in the video can be replaced with a normally displayed image, thereby solving the problem of abnormal expansion of the bright part of the light area in the video screen caused by lens shaking.

在一种可能的实现方式中,终端可以通过图像识别的方式或者是预先训练好的神经网络来检测拍摄的图像中是否存在灯光区域。In a possible implementation, the terminal may detect whether there is a light area in the captured image by means of image recognition or a pre-trained neural network.

具体地,终端可以通过检测拍摄的图像中的像素的亮度值,来判断图像中是否存在灯光区域。具体地,灯光区域内的像素的亮度值均大于或等于特定阈值,且灯光区域内的像素的亮度值与灯光区域的相邻区域的像素的亮度值之间的差异值大于或等于预设设定的差值。Specifically, the terminal can determine whether there is a light area in the image by detecting the brightness value of the pixels in the captured image. Specifically, the brightness values of the pixels in the light area are all greater than or equal to a specific threshold, and the difference between the brightness value of the pixels in the light area and the brightness value of the pixels in the adjacent area of the light area is greater than or equal to a preset difference.

其中,上述的特定阈值的取值可以为180-230,例如特定阈值具体为224;预先设定的差值的取值可以为25-50,例如预设设定的差值为32。例如,当终端检测到图像中存在有某一个区域内的像素的亮度值均大于或等于224,且该区域内的像素的亮度值与相邻区域的像素的亮度值之间的差异值大于或等于32,则终端可以确定该区域为灯光区域。其中,灯光区域的相邻区域可以是由与灯光区域内的像素相邻的像素所构成,即灯光区域的相邻区域内的像素与灯光区域内的像素相邻。The value of the above-mentioned specific threshold can be 180-230, for example, the specific threshold is specifically 224; the value of the preset difference can be 25-50, for example, the preset difference is 32. For example, when the terminal detects that the brightness values of pixels in a certain area in the image are greater than or equal to 224, and the difference between the brightness values of the pixels in the area and the brightness values of the pixels in the adjacent area is greater than or equal to 32, the terminal can determine that the area is a light area. The adjacent area of the light area can be composed of pixels adjacent to the pixels in the light area, that is, the pixels in the adjacent area of the light area are adjacent to the pixels in the light area.

此外,在终端确定图像中存在灯光区域之后,终端还可以根据位于灯光区域内的像素的坐标,确定图像中的灯光区域的位置。其中,图像中的灯光区域的位置可以是以灯光区域的边界的像素的坐标来确定,即由灯光区域的边界的像素所包围的区域即为灯光区域。终端可以通过记录灯光区域的边界的像素的坐标或者是灯光区域内的所有像素的坐标,来确定灯光区域的位置。In addition, after the terminal determines that there is a light area in the image, the terminal can also determine the position of the light area in the image according to the coordinates of the pixels located in the light area. The position of the light area in the image can be determined by the coordinates of the pixels at the boundary of the light area, that is, the area surrounded by the pixels at the boundary of the light area is the light area. The terminal can determine the position of the light area by recording the coordinates of the pixels at the boundary of the light area or the coordinates of all pixels in the light area.

具体地,上述第二图像以及所述第三图像中的灯光区域的邻近区域的过曝程度小于所述第一图像中的灯光区域邻近区域的过曝程度可以是指:第二图像以及所述第三图像中的灯光区域的邻近区域中发生过曝的区域的面积小于第一图像中的灯光区域的邻近区域中发生过曝的区域的面积;或者,第二图像以及所述第三图像中的灯光区域的邻近区域中发生过曝的像素的亮度值小于第一图像中的灯光区域的邻近区域中发生过曝的像素的亮度值。Specifically, the degree of overexposure of the areas adjacent to the light area in the second image and the third image is less than the degree of overexposure of the areas adjacent to the light area in the first image, which may mean that: the area of the overexposed area in the areas adjacent to the light area in the second image and the third image is smaller than the area of the overexposed area in the areas adjacent to the light area in the first image; or, the brightness value of the overexposed pixels in the areas adjacent to the light area in the second image and the third image is smaller than the brightness value of the overexposed pixels in the areas adjacent to the light area in the first image.

可选的,第二图像以及所述第三图像中的灯光区域的邻近区域中发生过曝的区域的面积可以为0,即第二图像和第三图像中的灯光区域的邻近区域并没有发生过曝。总的来说,相对于第一图像,第二图像和第三图像是终端在抖动位移较小或者是没有发生抖动位移的情况下采集的,因此第二图像以及所述第三图像中的灯光区域的邻近区域的过曝程度小于所述第一图像中的灯光区域邻近区域的过曝程度。Optionally, the area of the overexposed region in the second image and the adjacent region of the light region in the third image may be 0, that is, the adjacent region of the light region in the second image and the third image is not overexposed. In general, compared with the first image, the second image and the third image are captured by the terminal with less jitter displacement or no jitter displacement, so the overexposure degree of the adjacent region of the light region in the second image and the third image is less than the overexposure degree of the adjacent region of the light region in the first image.

在一种可能的实现方式中,所述方法还包括:当环境光的光照度小于第一预设阈值时,所述终端进入夜景拍摄模式。示例性地,第一预设阈值的取值可以为30-60,例如第一预设阈值为50。终端在拍摄的过程中,可以检测环境光的光照度,环境光的光照度小于50时,终端则进入夜景拍摄模式。或,当所述终端获取到用于触发进入夜景拍摄模式的指令时,所述终端进入夜景拍摄模式。例如,在用户操作终端进行拍摄的过程中,用户可以通过触控终端屏幕的方式,向终端下发进入夜景拍摄模式的指令;这样一来,当终端获取到用于触发进入夜景拍摄模式的指令时,终端则进入夜景拍摄模式。In a possible implementation, the method further includes: when the illumination of the ambient light is less than a first preset threshold, the terminal enters a night scene shooting mode. Exemplarily, the value of the first preset threshold may be 30-60, for example, the first preset threshold is 50. During the shooting process, the terminal may detect the illumination of the ambient light, and when the illumination of the ambient light is less than 50, the terminal enters the night scene shooting mode. Or, when the terminal obtains an instruction for triggering entry into the night scene shooting mode, the terminal enters the night scene shooting mode. For example, in the process of the user operating the terminal to shoot, the user may send an instruction to the terminal to enter the night scene shooting mode by touching the terminal screen; in this way, when the terminal obtains an instruction for triggering entry into the night scene shooting mode, the terminal enters the night scene shooting mode.

此外,终端还可以是根据拍摄过程中的预览图像的画面内容和/或预览图像各区域的环境亮度值,来确定当前拍摄场景是否为夜景场景,从而确定是否进入夜景拍摄模式。例如,当预览图像的画面内容包括夜晚天空或者夜景灯源等内容时,终端可以确定当前拍摄场景为夜景场景,从而进入夜景拍摄模式;或者,当预览图像的各区域中的环境亮度值符合夜景环境下图像的亮度分布特性时,终端可以确定当前拍摄场景为夜景场景,从而进入夜景拍摄模式。In addition, the terminal can also determine whether the current shooting scene is a night scene according to the picture content of the preview image during shooting and/or the ambient brightness value of each area of the preview image, thereby determining whether to enter the night scene shooting mode. For example, when the picture content of the preview image includes the night sky or night scene light sources, the terminal can determine that the current shooting scene is a night scene, thereby entering the night scene shooting mode; or, when the ambient brightness value of each area of the preview image meets the brightness distribution characteristics of the image in the night scene environment, the terminal can determine that the current shooting scene is a night scene, thereby entering the night scene shooting mode.

在一种可能的实现方式中,所述终端采集所述第一图像时的抖动位移大于第二预设阈值。其中,第二预设阈值可以为300-400,例如第二预设阈值具体为360。所述终端采集所述第一图像时的抖动位移可以称为第一图像的抖动值。具体地,终端可以获取记录了终端在采集第一图像时的运动情况的传感器数据,并且基于传感器数据计算得到第一图像的抖动值。终端也可以是计算图像的对比度值,并根据图像的对比度值来确定图像的抖动值,即图像的对比度值越小,则图像的抖动值越大。此外,终端还可以基于预先训练好的神经网络来确定图像的抖动值。In a possible implementation, the jitter displacement when the terminal collects the first image is greater than a second preset threshold. The second preset threshold may be 300-400, for example, the second preset threshold is specifically 360. The jitter displacement when the terminal collects the first image may be referred to as the jitter value of the first image. Specifically, the terminal may obtain sensor data that records the movement of the terminal when collecting the first image, and calculate the jitter value of the first image based on the sensor data. The terminal may also calculate the contrast value of the image, and determine the jitter value of the image based on the contrast value of the image, that is, the smaller the contrast value of the image, the larger the jitter value of the image. In addition, the terminal may also determine the jitter value of the image based on a pre-trained neural network.

在一种可能的实现方式中,终端还可以确定所述多个图像是否存在局部灯光区域。只有在某一个图像存在局部灯光区域且该图像的抖动值大于或等于第二预设阈值时,终端将该图像确定为震颤图像。In a possible implementation, the terminal may also determine whether there is a local light area in the multiple images. Only when a certain image has a local light area and the jitter value of the image is greater than or equal to a second preset threshold, the terminal determines the image as a trembling image.

其中,第一图像中存在局部灯光区域,所述第一图像中目标像素的个数与第一图像的像素总个数的比值在预设范围内,所述目标像素为所述第一图像中的灯光区域内的像素。也就是说,第一图像中的灯光区域的面积与第一图像中所有区域的面积的比值在预设范围内。所述预设范围的取值例如可以为2%-20%,即第一图像中的灯光区域在第一图像中的面积占比在2%-20%内。示例性地,终端可以确定所述多个图像中的每个图像中目标像素的个数,所述目标像素是指灯光区域内的像素,其中灯光区域的定义可以参考上述的描述。然后,终端获取每个图像中目标像素的个数与图像的像素总个数的比值,并判断该比值是否在预设范围内。如果图像中目标像素的个数与图像的像素总个数的比值在预设范围内,则终端确定该图像中存在局部灯光区域;如果图像中目标像素的个数与图像的像素总个数的比值不在预设范围内,则终端确定该图像中不存在局部灯光区域。Wherein, there is a local light area in the first image, the ratio of the number of target pixels in the first image to the total number of pixels in the first image is within a preset range, and the target pixel is a pixel in the light area in the first image. That is, the ratio of the area of the light area in the first image to the area of all areas in the first image is within a preset range. The value of the preset range can be, for example, 2%-20%, that is, the area of the light area in the first image accounts for 2%-20% of the area in the first image. Exemplarily, the terminal can determine the number of target pixels in each of the multiple images, the target pixel refers to the pixel in the light area, and the definition of the light area can refer to the above description. Then, the terminal obtains the ratio of the number of target pixels in each image to the total number of pixels in the image, and determines whether the ratio is within the preset range. If the ratio of the number of target pixels in the image to the total number of pixels in the image is within the preset range, the terminal determines that there is a local light area in the image; if the ratio of the number of target pixels in the image to the total number of pixels in the image is not within the preset range, the terminal determines that there is no local light area in the image.

在一种可能的实现方式中,所述终端根据所述第一图像在所述多个图像中确定第二图像和第三图像,包括以下的过程:终端分别确定所述多个图像中每个图像的稳定值,所述稳定值为所述图像的抖动值与所述图像和所述第一图像之间的采集时间差之和的倒数。其中,图像的稳定值与该图像的抖动值以及该图像与第一图像之间的采集时间差呈负相关的关系。也就是说,图像的抖动值越大,则该图像的稳定值越小;图像与第一图像之间的采集时间差越大,则该图像的稳定值越小。简单来说,终端需要尽可能地选择抖动值小且靠近第一图像的图像作为第二图像和第三图像。In a possible implementation, the terminal determines the second image and the third image from the multiple images based on the first image, including the following process: the terminal determines the stability value of each of the multiple images respectively, and the stability value is the reciprocal of the sum of the jitter value of the image and the acquisition time difference between the image and the first image. Among them, the stability value of the image is negatively correlated with the jitter value of the image and the acquisition time difference between the image and the first image. In other words, the larger the jitter value of the image, the smaller the stability value of the image; the larger the acquisition time difference between the image and the first image, the smaller the stability value of the image. In short, the terminal needs to select images with small jitter values and close to the first image as the second image and the third image as much as possible.

然后,终端确定所述多个图像中稳定值最大的图像为所述第二图像,并根据所述第二图像的采集时刻,在所述多个图像中确定所述第三图像,以使得所述第一图像的采集时刻位于所述第二图像的采集时刻与所述第三图像的采集时刻之间。Then, the terminal determines that the image with the largest stability value among the multiple images is the second image, and determines the third image among the multiple images based on the acquisition time of the second image, so that the acquisition time of the first image is between the acquisition time of the second image and the acquisition time of the third image.

具体地,终端可以根据所述第二图像的采集时刻,在所述多个图像中确定一个或多个图像,所述第一图像的采集时刻位于所述第二图像的采集时刻与所述一个或多个图像的采集时刻之间;然后,终端在所述一个或多个图像中确定稳定值最大的图像为所述第三图像。基于上述的方式所确定的第二图像的稳定值大于第三图像,因此第二图像可以认为是用于生成目标图像的主参考图像,第三图像则可以认为是用于生成目标图像的次参考图像。Specifically, the terminal can determine one or more images from the multiple images according to the acquisition time of the second image, and the acquisition time of the first image is between the acquisition time of the second image and the acquisition time of the one or more images; then, the terminal determines the image with the largest stability value from the one or more images as the third image. Based on the stability value of the second image determined in the above manner is greater than that of the third image, the second image can be considered as the primary reference image for generating the target image, and the third image can be considered as the secondary reference image for generating the target image.

在一种可能的实现方式中,所述终端根据所述第一图像和所述第三图像确定所述多个图像块分别对应的运动矢量,包括以下的过程:首先,终端获取第一图像块对应的多个候选运动矢量。其中,所述第二图像中的多个图像块包括所述第一图像块,所述第一图像块可以为所述多个图像块中的任意一个图像块。然后,终端根据所述第一图像块的位置,确定所述多个候选运动矢量中每个候选运动矢量对应的第二图像块和第三图像块,所述第一图像包括所述第二图像块,所述第三图像包括所述第三图像块。In a possible implementation, the terminal determines the motion vectors corresponding to the multiple image blocks respectively according to the first image and the third image, including the following process: First, the terminal obtains multiple candidate motion vectors corresponding to the first image block. The multiple image blocks in the second image include the first image block, and the first image block can be any one of the multiple image blocks. Then, the terminal determines the second image block and the third image block corresponding to each candidate motion vector in the multiple candidate motion vectors according to the position of the first image block, the first image includes the second image block, and the third image includes the third image block.

其次,终端根据所述第一图像块、所述第二图像块和所述第三图像块,确定所述每个候选运动矢量对应的目标误差值,所述目标误差值是基于所述第一图像块与所述第二图像块之间的误差值以及所述第一图像块与所述第三图像块之间的误差值得到的。其中,两个图像块之间的误差值表示两个图像块之间的差异,误差值越大,则两个图像块之间的差异越大。Secondly, the terminal determines a target error value corresponding to each candidate motion vector according to the first image block, the second image block and the third image block, wherein the target error value is obtained based on an error value between the first image block and the second image block and an error value between the first image block and the third image block. The error value between two image blocks represents a difference between the two image blocks, and the larger the error value, the larger the difference between the two image blocks.

最后,终端根据所述每个候选运动矢量对应的目标误差值,在所述多个候选运动矢量中确定目标误差值最小的运动矢量为所述第一图像块对应的运动矢量。Finally, the terminal determines, according to the target error value corresponding to each candidate motion vector, a motion vector with the smallest target error value among the multiple candidate motion vectors as the motion vector corresponding to the first image block.

在一种可能的实现方式中,所述多个候选运动矢量,包括:一个或多个预设运动矢量、随机生成的一个或多个运动矢量和/或与所述第一图像块相邻的图像块对应的运动矢量。In a possible implementation manner, the multiple candidate motion vectors include: one or more preset motion vectors, one or more randomly generated motion vectors and/or motion vectors corresponding to an image block adjacent to the first image block.

由于第二图像与第三图像是采集时刻相近的两个图像,因此第二图像中的物体相对于第三图像的位移较小,从而可以认为第二图像中的图像块对应的运动矢量是在预设范围内的。这样一来,终端可以获取一个或多个预设运动矢量,并将这些预设运动矢量作为候选运动矢量。此外,为了尽可能地保证能够获取到第一图像块实际对应的运动矢量,还可以随机生成一个或多个运动矢量或者选取第一图像块相邻的图像块对应的运动矢量来作为候选运动矢量,从而避免候选运动矢量的取值范围过于局限。Since the second image and the third image are two images captured at similar times, the displacement of the object in the second image relative to the third image is small, so it can be considered that the motion vector corresponding to the image block in the second image is within the preset range. In this way, the terminal can obtain one or more preset motion vectors and use these preset motion vectors as candidate motion vectors. In addition, in order to ensure that the motion vector actually corresponding to the first image block can be obtained as much as possible, one or more motion vectors can be randomly generated or the motion vector corresponding to the image block adjacent to the first image block can be selected as the candidate motion vector, so as to avoid the value range of the candidate motion vector being too limited.

在一种可能的实现方式中,在终端基于第二图像的多个图像块生成目标图像之后,若所述目标图像中存在无法基于所述多个图像块生成图像的区域,则终端对所述第三图像进行划分,得到所述第三图像的多个图像块。In one possible implementation, after the terminal generates a target image based on multiple image blocks of the second image, if there is an area in the target image where an image cannot be generated based on the multiple image blocks, the terminal divides the third image to obtain multiple image blocks of the third image.

然后,终端根据所述第一图像和所述第二图像确定所述第三图像的多个图像块分别对应的运动矢量。其中,终端确定所述第三图像的多个图像块分别对应的运动矢量的过程与上述终端确定第二图像的多个图像块对应的运动矢量的过程类似,具体可以参考上述实施例的描述,在此不再赘述。Then, the terminal determines the motion vectors corresponding to the multiple image blocks of the third image respectively according to the first image and the second image. The process of the terminal determining the motion vectors corresponding to the multiple image blocks of the third image respectively is similar to the process of the terminal determining the motion vectors corresponding to the multiple image blocks of the second image. For details, please refer to the description of the above embodiment, which will not be repeated here.

最后,终端根据所述第三图像的多个图像块对应的运动矢量以及所述第三图像的多个图像块,更新所述目标图像,得到新的目标图像,所述新的目标图像用于替换所述第一图像。其中,终端更新所述目标图像是指终端根据第三图像的多个图像块对应的运动矢量,将所述第三图像中的图像块移动至目标图像中的空洞区域,从而实现空洞区域的填充。对于目标图像中已经存在有图像的区域,则不再更新这些已经存在有图像的区域。Finally, the terminal updates the target image according to the motion vectors corresponding to the multiple image blocks of the third image and the multiple image blocks of the third image, and obtains a new target image, and the new target image is used to replace the first image. The terminal updates the target image means that the terminal moves the image blocks in the third image to the hole area in the target image according to the motion vectors corresponding to the multiple image blocks of the third image, thereby filling the hole area. For areas in the target image where images already exist, these areas where images already exist are no longer updated.

本方案中,通过求取第三图像的运动矢量并基于第三图像的运动矢量来更新目标图像,能够有效消除目标图像中的空洞区域,提高目标图像的图像质量。In this solution, by obtaining the motion vector of the third image and updating the target image based on the motion vector of the third image, the hole area in the target image can be effectively eliminated and the image quality of the target image can be improved.

在一种可能的实现方式中,终端根据所述第一图像的曝光时间,获取所述第一图像对应的传感器数据,所述传感器数据用于记录所述终端在所述第一图像的曝光时间内的运动情况。所述传感器数据例如可以为陀螺仪数据,所述陀螺仪数据可以是记录了所述终端在所述第一图像的曝光时间内的角速度。在得到传感器数据之后,终端再根据所述传感器数据确定所述第一图像的抖动值,即基于所述传感器数据确定所述终端在所述第一图像的曝光期间的抖动位移。In a possible implementation, the terminal obtains sensor data corresponding to the first image according to the exposure time of the first image, and the sensor data is used to record the movement of the terminal during the exposure time of the first image. The sensor data may be, for example, gyroscope data, and the gyroscope data may record the angular velocity of the terminal during the exposure time of the first image. After obtaining the sensor data, the terminal determines the jitter value of the first image according to the sensor data, that is, determines the jitter displacement of the terminal during the exposure period of the first image based on the sensor data.

本申请第二方面提供一种视频处理装置,包括:A second aspect of the present application provides a video processing device, including:

检测单元,用于当终端处于夜景拍摄模式时,检测所述终端拍摄的图像中是否存在灯光区域;A detection unit, used to detect whether there is a light area in the image captured by the terminal when the terminal is in a night scene shooting mode;

第一确定单元,用于当所述终端拍摄的图像中存在灯光区域时,在所述终端采集的图像序列中确定第一图像,所述第一图像中的灯光区域的邻近区域出现过曝;A first determining unit is configured to, when there is a light area in the image captured by the terminal, determine a first image in the image sequence collected by the terminal, in which an area adjacent to the light area in the first image is overexposed;

第二确定单元,用于根据所述第一图像在所述图像序列中确定第二图像和第三图像,所述第一图像的采集时刻位于所述第二图像的采集时刻与所述第三图像的采集时刻之间,所述第二图像以及所述第三图像中的灯光区域的邻近区域的过曝程度小于所述第一图像中的灯光区域邻近区域的过曝程度;a second determining unit, configured to determine a second image and a third image in the image sequence according to the first image, wherein a capture time of the first image is between a capture time of the second image and a capture time of the third image, and an overexposure degree of an area adjacent to the light area in the second image and the third image is smaller than an overexposure degree of an area adjacent to the light area in the first image;

图像生成单元,还用于根据所述第一图像、所述第二图像和所述第三图像生成目标图像,所述目标图像用于替换所述第一图像,所述目标图像的灯光区域的邻近区域的过曝程度小于所述第一图像的灯光区域的邻近区域的过曝程度;The image generating unit is further used to generate a target image according to the first image, the second image and the third image, wherein the target image is used to replace the first image, and the overexposure degree of the neighboring area of the light area of the target image is smaller than the overexposure degree of the neighboring area of the light area of the first image;

视频生成单元,还用于基于所述目标图像,生成视频。The video generation unit is further used to generate a video based on the target image.

在一种可能的实现方式中,还包括:控制单元;In a possible implementation, the device further includes: a control unit;

所述控制单元用于:当环境光的光照度小于第一预设阈值时,控制所述终端进入夜景拍摄模式;或,当获取到用于触发进入夜景拍摄模式的指令时,控制所述终端进入夜景拍摄模式。The control unit is used to: when the illumination of the ambient light is less than a first preset threshold, control the terminal to enter a night scene shooting mode; or, when an instruction for triggering entering a night scene shooting mode is obtained, control the terminal to enter a night scene shooting mode.

在一种可能的实现方式中,所述终端采集所述第一图像时的抖动位移大于第二预设阈值。In a possible implementation manner, a jitter displacement when the terminal captures the first image is greater than a second preset threshold.

在一种可能的实现方式中,所述第一图像中目标像素的个数与第一图像的像素总个数的比值在预设范围内,所述目标像素为所述第一图像中的灯光区域内的像素。In a possible implementation manner, a ratio of the number of target pixels in the first image to the total number of pixels in the first image is within a preset range, and the target pixels are pixels in a light area in the first image.

在一种可能的实现方式中,所述第二确定单元用于:分别确定所述多个图像中每个图像的稳定值,所述稳定值为所述图像的抖动值与所述图像和所述第一图像之间的采集时间差之和的倒数;确定所述多个图像中稳定值最大的图像为所述第二图像;根据所述第二图像的采集时刻,在所述多个图像中确定所述第三图像。In a possible implementation, the second determination unit is used to: separately determine a stability value of each of the multiple images, where the stability value is the inverse of the sum of a jitter value of the image and an acquisition time difference between the image and the first image; determine the image with the largest stability value among the multiple images as the second image; and determine the third image among the multiple images based on the acquisition time of the second image.

在一种可能的实现方式中,所述第二确定单元用于:根据所述第二图像的采集时刻,在所述多个图像中确定一个或多个图像,所述第一图像的采集时刻位于所述第二图像的采集时刻与所述一个或多个图像的采集时刻之间;在所述一个或多个图像中确定稳定值最大的图像为所述第三图像。In a possible implementation, the second determination unit is used to: determine one or more images from the multiple images based on the acquisition time of the second image, the acquisition time of the first image is between the acquisition time of the second image and the acquisition time of the one or more images; and determine the image with the largest stability value from the one or more images as the third image.

在一种可能的实现方式中,所述图像生成单元用于:将所述第二图像划分为多个图像块;根据所述第一图像和所述第三图像确定所述多个图像块分别对应的运动矢量;根据所述多个图像块分别对应的运动矢量以及所述多个图像块,生成所述目标图像。In a possible implementation, the image generation unit is used to: divide the second image into multiple image blocks; determine the motion vectors corresponding to the multiple image blocks respectively according to the first image and the third image; and generate the target image according to the motion vectors corresponding to the multiple image blocks respectively and the multiple image blocks.

在一种可能的实现方式中,所述图像生成单元用于:获取第一图像块对应的多个候选运动矢量,所述多个图像块包括所述第一图像块;根据所述第一图像块的位置,确定所述多个候选运动矢量中每个候选运动矢量对应的第二图像块和第三图像块,所述第一图像包括所述第二图像块,所述第三图像包括所述第三图像块;根据所述第一图像块、所述第二图像块和所述第三图像块,确定所述每个候选运动矢量对应的目标误差值,所述目标误差值是基于所述第一图像块与所述第二图像块之间的误差值以及所述第一图像块与所述第三图像块之间的误差值得到的;根据所述每个候选运动矢量对应的目标误差值,在所述多个候选运动矢量中确定目标误差值最小的运动矢量为所述第一图像块对应的运动矢量。In a possible implementation, the image generation unit is used to: obtain multiple candidate motion vectors corresponding to a first image block, the multiple image blocks including the first image block; determine, according to the position of the first image block, a second image block and a third image block corresponding to each of the multiple candidate motion vectors, the first image including the second image block, and the third image including the third image block; determine, according to the first image block, the second image block, and the third image block, a target error value corresponding to each candidate motion vector, the target error value being obtained based on an error value between the first image block and the second image block and an error value between the first image block and the third image block; and, according to the target error value corresponding to each candidate motion vector, determine, among the multiple candidate motion vectors, a motion vector with a minimum target error value as the motion vector corresponding to the first image block.

在一种可能的实现方式中,所述多个候选运动矢量,包括:一个或多个预设运动矢量、随机生成的一个或多个运动矢量和/或与所述第一图像块相邻的图像块对应的运动矢量。In a possible implementation manner, the multiple candidate motion vectors include: one or more preset motion vectors, one or more randomly generated motion vectors and/or motion vectors corresponding to an image block adjacent to the first image block.

在一种可能的实现方式中,所述图像生成单元用于:若所述目标图像中存在无法基于所述多个图像块生成图像的区域,则对所述第三图像进行划分,得到所述第三图像的多个图像块;根据所述第一图像和所述第二图像确定所述第三图像的多个图像块分别对应的运动矢量;根据所述第三图像的多个图像块对应的运动矢量以及所述第三图像的多个图像块,更新所述目标图像,得到新的目标图像,所述新的目标图像用于替换所述第一图像。In a possible implementation, the image generation unit is used to: if there is an area in the target image where an image cannot be generated based on the multiple image blocks, divide the third image to obtain multiple image blocks of the third image; determine motion vectors corresponding to the multiple image blocks of the third image according to the first image and the second image; update the target image according to the motion vectors corresponding to the multiple image blocks of the third image and the multiple image blocks of the third image to obtain a new target image, and the new target image is used to replace the first image.

本申请第三方面提供一种视频处理装置,该视频处理装置包括:处理器、非易失性存储器和易失性存储器;其中,非易失性存储器或易失性存储器中存储有计算机可读指令;处理器读取计算机可读指令以使视频处理装置实现如第一方面中的任意一种实现方式的方法。The third aspect of the present application provides a video processing device, which includes: a processor, a non-volatile memory and a volatile memory; wherein computer-readable instructions are stored in the non-volatile memory or the volatile memory; the processor reads the computer-readable instructions to enable the video processing device to implement a method such as any one of the implementation methods in the first aspect.

本申请第四方面提供一种终端设备,所述终端设备处理器、存储器、显示屏、摄像头和总线,其中:所述处理器、所述显示屏、所述摄像头和所述存储器通过所述总线连接;所述存储器,用于存放计算机程序和所述摄像头采集的图像;所述处理器,用于控制所述显示屏,还用于控制所述存储器,获取所述存储器上所存放的图像并执行所述存储器上所存放的程序,以执行以下的步骤:当终端处于夜景拍摄模式时,检测所述终端拍摄的图像中是否存在灯光区域;当所述终端拍摄的图像中存在灯光区域时,在所述终端采集的图像序列中确定第一图像,所述第一图像中的灯光区域的邻近区域出现过曝;根据所述第一图像在所述图像序列中确定第二图像和第三图像,所述第一图像的采集时刻位于所述第二图像的采集时刻与所述第三图像的采集时刻之间,所述第二图像以及所述第三图像中的灯光区域的邻近区域的过曝程度小于所述第一图像中的灯光区域邻近区域的过曝程度;根据所述第一图像、所述第二图像和所述第三图像生成目标图像,所述目标图像用于替换所述第一图像,所述目标图像的灯光区域的邻近区域的过曝程度小于所述第一图像的灯光区域的邻近区域的过曝程度;基于所述目标图像,生成视频。According to a fourth aspect of the present application, there is provided a terminal device, comprising a processor, a memory, a display screen, a camera and a bus, wherein: the processor, the display screen, the camera and the memory are connected via the bus; the memory is used to store computer programs and images captured by the camera; the processor is used to control the display screen and the memory, obtain the images stored in the memory and execute the programs stored in the memory to perform the following steps: when the terminal is in a night scene shooting mode, detect whether there is a light area in the image captured by the terminal; when there is a light area in the image captured by the terminal, determine a first image in the image sequence captured by the terminal, and the first image in the image sequence captured by the terminal. An area adjacent to a light area in an image is overexposed; a second image and a third image are determined in the image sequence based on the first image, the acquisition time of the first image is between the acquisition time of the second image and the acquisition time of the third image, and the degree of overexposure of areas adjacent to the light area in the second image and the third image is less than the degree of overexposure of areas adjacent to the light area in the first image; a target image is generated based on the first image, the second image and the third image, the target image is used to replace the first image, and the degree of overexposure of areas adjacent to the light area in the target image is less than the degree of overexposure of areas adjacent to the light area in the first image; and a video is generated based on the target image.

在一种可能的实现方式中,所述处理器还用于:当环境光的光照度小于第一预设阈值时,所述终端进入夜景拍摄模式;或,当所述终端获取到用于触发进入夜景拍摄模式的指令时,所述终端进入夜景拍摄模式。In one possible implementation, the processor is also used to: when the illumination of the ambient light is less than a first preset threshold, the terminal enters a night scene shooting mode; or, when the terminal obtains an instruction for triggering entry into the night scene shooting mode, the terminal enters the night scene shooting mode.

在一种可能的实现方式中,所述终端采集所述第一图像时的抖动位移大于第二预设阈值。In a possible implementation manner, a jitter displacement when the terminal captures the first image is greater than a second preset threshold.

在一种可能的实现方式中,所述第一图像中目标像素的个数与第一图像的像素总个数的比值在预设范围内,所述目标像素为所述第一图像中的灯光区域内的像素。In a possible implementation manner, a ratio of the number of target pixels in the first image to the total number of pixels in the first image is within a preset range, and the target pixels are pixels in a light area in the first image.

在一种可能的实现方式中,所述处理器还用于:分别确定所述多个图像中每个图像的稳定值,所述稳定值为所述图像的抖动值与所述图像和所述第一图像之间的采集时间差之和的倒数;确定所述多个图像中稳定值最大的图像为所述第二图像;根据所述第二图像的采集时刻,在所述多个图像中确定所述第三图像。In a possible implementation, the processor is also used to: separately determine a stability value of each of the multiple images, where the stability value is the inverse of the sum of the jitter value of the image and the acquisition time difference between the image and the first image; determine the image with the largest stability value among the multiple images as the second image; and determine the third image among the multiple images based on the acquisition time of the second image.

在一种可能的实现方式中,所述处理器还用于:根据所述第二图像的采集时刻,在所述多个图像中确定一个或多个图像,所述第一图像的采集时刻位于所述第二图像的采集时刻与所述一个或多个图像的采集时刻之间;在所述一个或多个图像中确定稳定值最大的图像为所述第三图像。In a possible implementation, the processor is further used to: determine one or more images from the multiple images based on the acquisition time of the second image, the acquisition time of the first image is between the acquisition time of the second image and the acquisition time of the one or more images; and determine the image with the largest stability value from the one or more images as the third image.

在一种可能的实现方式中,所述处理器还用于:将所述第二图像划分为多个图像块;根据所述第一图像和所述第三图像确定所述多个图像块分别对应的运动矢量;根据所述多个图像块分别对应的运动矢量以及所述多个图像块,生成所述目标图像。In a possible implementation, the processor is further used to: divide the second image into multiple image blocks; determine the motion vectors corresponding to the multiple image blocks respectively according to the first image and the third image; and generate the target image according to the motion vectors corresponding to the multiple image blocks respectively and the multiple image blocks.

在一种可能的实现方式中,所述处理器还用于:获取第一图像块对应的多个候选运动矢量,所述多个图像块包括所述第一图像块;根据所述第一图像块的位置,确定所述多个候选运动矢量中每个候选运动矢量对应的第二图像块和第三图像块,所述第一图像包括所述第二图像块,所述第三图像包括所述第三图像块;根据所述第一图像块、所述第二图像块和所述第三图像块,确定所述每个候选运动矢量对应的目标误差值,所述目标误差值是基于所述第一图像块与所述第二图像块之间的误差值以及所述第一图像块与所述第三图像块之间的误差值得到的;根据所述每个候选运动矢量对应的目标误差值,在所述多个候选运动矢量中确定目标误差值最小的运动矢量为所述第一图像块对应的运动矢量。In a possible implementation, the processor is further used to: obtain multiple candidate motion vectors corresponding to a first image block, the multiple image blocks including the first image block; determine, based on the position of the first image block, a second image block and a third image block corresponding to each of the multiple candidate motion vectors, the first image including the second image block, and the third image including the third image block; determine, based on the first image block, the second image block, and the third image block, a target error value corresponding to each candidate motion vector, the target error value being obtained based on an error value between the first image block and the second image block and an error value between the first image block and the third image block; and, based on the target error value corresponding to each candidate motion vector, determine, among the multiple candidate motion vectors, a motion vector with a minimum target error value as the motion vector corresponding to the first image block.

在一种可能的实现方式中,所述多个候选运动矢量,包括:一个或多个预设运动矢量、随机生成的一个或多个运动矢量和/或与所述第一图像块相邻的图像块对应的运动矢量。In a possible implementation manner, the multiple candidate motion vectors include: one or more preset motion vectors, one or more randomly generated motion vectors and/or motion vectors corresponding to an image block adjacent to the first image block.

在一种可能的实现方式中,所述处理器还用于:若所述目标图像中存在无法基于所述多个图像块生成图像的区域,则对所述第三图像进行划分,得到所述第三图像的多个图像块;根据所述第一图像和所述第二图像确定所述第三图像的多个图像块分别对应的运动矢量;根据所述第三图像的多个图像块对应的运动矢量以及所述第三图像的多个图像块,更新所述目标图像,得到新的目标图像,所述新的目标图像用于替换所述第一图像。In a possible implementation, the processor is further used to: if there is an area in the target image where an image cannot be generated based on the multiple image blocks, divide the third image to obtain multiple image blocks of the third image; determine the motion vectors corresponding to the multiple image blocks of the third image according to the first image and the second image; and update the target image according to the motion vectors corresponding to the multiple image blocks of the third image and the multiple image blocks of the third image to obtain a new target image, and the new target image is used to replace the first image.

本申请第五方面提供一种计算机可读存储介质,计算机可读存储介质中存储有计算机程序,当其在计算机上运行时,使得计算机执行如第一方面中的任意一种实现方式的方法。A fifth aspect of the present application provides a computer-readable storage medium, in which a computer program is stored. When the computer-readable storage medium is run on a computer, the computer executes a method as in any one of the implementation modes of the first aspect.

本申请第六方面提供一种计算机程序产品,当其在计算机上运行时,使得计算机执行如第一方面中的任意一种实现方式的方法。A sixth aspect of the present application provides a computer program product, which, when executed on a computer, enables the computer to execute a method as in any one of the implementation modes of the first aspect.

本申请第七方面提供一种芯片,包括一个或多个处理器。处理器中的部分或全部用于读取并执行存储器中存储的计算机程序,以执行上述任一方面任意可能的实现方式中的方法。In a seventh aspect, the present application provides a chip, comprising one or more processors, wherein some or all of the processors are used to read and execute a computer program stored in a memory to execute the method in any possible implementation of any of the above aspects.

可选地,该芯片该包括存储器,该存储器与该处理器通过电路或电线与存储器连接。可选地,该芯片还包括通信接口,处理器与该通信接口连接。通信接口用于接收需要处理的数据和/或信息,处理器从该通信接口获取该数据和/或信息,并对该数据和/或信息进行处理,并通过该通信接口输出处理结果。该通信接口可以是输入输出接口。本申请提供的方法可以由一个芯片实现,也可以由多个芯片协同实现。Optionally, the chip includes a memory, and the memory is connected to the processor through a circuit or wire. Optionally, the chip also includes a communication interface, and the processor is connected to the communication interface. The communication interface is used to receive data and/or information to be processed, and the processor obtains the data and/or information from the communication interface, processes the data and/or information, and outputs the processing results through the communication interface. The communication interface can be an input and output interface. The method provided in the present application can be implemented by one chip, or by multiple chips in collaboration.

附图说明BRIEF DESCRIPTION OF THE DRAWINGS

图1a为本申请实施例提供的震颤图像以及用于替换震颤图像的图像之间的对比示意图;FIG1a is a schematic diagram showing a comparison between a tremor image and an image used to replace the tremor image provided by an embodiment of the present application;

图1b为本申请实施例提供的另一种震颤图像以及用于替换震颤图像的图像之间的对比示意图;FIG1b is a schematic diagram showing a comparison between another tremor image and an image used to replace the tremor image provided in an embodiment of the present application;

图2a为本申请实施例提供的终端设备的结构示意图;FIG2a is a schematic diagram of the structure of a terminal device provided in an embodiment of the present application;

图2b是本申请实施例提供的终端100的软件结构框图;FIG2b is a software structure block diagram of the terminal 100 provided in an embodiment of the present application;

图3为本申请实施例提供的一种视频处理方法的流程示意图;FIG3 is a flow chart of a video processing method provided in an embodiment of the present application;

图4为本申请实施例提供的一种MEMC方法的示意图;FIG4 is a schematic diagram of a MEMC method provided in an embodiment of the present application;

图5为本申请实施例提供的一种MEMC方法的另一示意图;FIG5 is another schematic diagram of a MEMC method provided in an embodiment of the present application;

图6为本申请实施例提供的一种基于候选运动矢量确定图像块的示意图;FIG6 is a schematic diagram of determining an image block based on a candidate motion vector provided by an embodiment of the present application;

图7为本申请实施例提供的一种生成目标图像的示意图;FIG7 is a schematic diagram of generating a target image provided by an embodiment of the present application;

图8为本申请实施例提供的另一种生成目标图像的示意图;FIG8 is a schematic diagram of another method for generating a target image provided by an embodiment of the present application;

图9为本申请实施例提供的一种视频处理方法的应用架构示意图;FIG9 is a schematic diagram of an application architecture of a video processing method provided in an embodiment of the present application;

图10为本申请实施例提供的一种替换震颤图像的流程示意图;FIG10 is a schematic diagram of a process of replacing a tremor image provided by an embodiment of the present application;

图11为本申请实施例提供的一种替换震颤图像的另一个流程示意图;FIG11 is another schematic diagram of a process of replacing a tremor image provided by an embodiment of the present application;

图12为本申请实施例提供的另一种视频处理方法的流程示意图;FIG12 is a schematic diagram of a flow chart of another video processing method provided in an embodiment of the present application;

图13为本申请实施例提供的一种终端1300的结构示意图;FIG13 is a schematic diagram of the structure of a terminal 1300 provided in an embodiment of the present application;

图14为本申请实施例提供的一种计算机程序产品1400的结构示意图。FIG. 14 is a schematic diagram of the structure of a computer program product 1400 provided in an embodiment of the present application.

具体实施方式DETAILED DESCRIPTION

下面结合附图,对本申请的实施例进行描述,显然,所描述的实施例仅仅是本申请一部分的实施例,而不是全部的实施例。本领域普通技术人员可知,随着技术的发展和新场景的出现,本申请实施例提供的技术方案对于类似的技术问题,同样适用。The following describes the embodiments of the present application in conjunction with the accompanying drawings. Obviously, the described embodiments are only embodiments of a part of the present application, rather than all embodiments. It is known to those skilled in the art that with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.

本申请的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的实施例能够以除了在这里图示或描述的内容以外的顺序实施。此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含,例如,包含了一系列步骤或模块的过程、方法、系统、产品或设备不必限于清楚地列出的那些步骤或模块,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或模块。在本申请中出现的对步骤进行的命名或者编号,并不意味着必须按照命名或者编号所指示的时间/逻辑先后顺序执行方法流程中的步骤,已经命名或者编号的流程步骤可以根据要实现的技术目的变更执行次序,只要能达到相同或者相类似的技术效果即可。The terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments described here can be implemented in an order other than that illustrated or described here. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or modules is not necessarily limited to those steps or modules clearly listed, but may include other steps or modules that are not clearly listed or inherent to these processes, methods, products or devices. The naming or numbering of steps in this application does not mean that the steps in the method flow must be executed in the time/logical sequence indicated by the naming or numbering. The process steps that have been named or numbered can change the execution order according to the technical purpose to be achieved, as long as the same or similar technical effects can be achieved.

长期以来,智能手机等便携式终端设备拍摄视频时的镜头抖动问题一直是生成高质量视频的最大难点之一。由于便携式终端比较轻便,用户通常会在使用便携式终端拍摄视频的同时进行移动,导致便携式终端拍摄得到的视频画面不稳定。在用户的移动过程中,便携式终端的镜头会发生抖动,从而导致视频画面中的灯光区域被更大区域的感光元件感应到,出现视频画面中的灯光区域不正常外扩的现象。For a long time, the lens shake problem when shooting videos with portable terminal devices such as smartphones has been one of the biggest difficulties in generating high-quality videos. Since portable terminals are relatively light, users usually move while shooting videos with portable terminals, resulting in unstable video images taken by portable terminals. During the user's movement, the lens of the portable terminal will shake, causing the light area in the video image to be sensed by the photosensitive element in a larger area, resulting in the abnormal expansion of the light area in the video image.

在用户的移动过程中,便携式终端的镜头通常会发生不同程度的抖动,因此便携式终端拍摄得到的视频中的部分视频帧的灯光区域不正常外扩,视频中的另一部分视频帧的灯光区域则正常显示。在用户观看视频的过程中,灯光区域不正常外扩的视频帧以及灯光区域正常显示的视频帧交替出现,容易给观看视频的用户带来主观上的震颤感,影响了用户的体验。其中,这种画面中的灯光区域不正常外扩的视频帧可以称为震颤图像。During the user's movement, the lens of the portable terminal usually shakes to varying degrees, so the light area of some video frames in the video captured by the portable terminal expands abnormally, while the light area of another part of the video frames in the video is displayed normally. During the user's video viewing, video frames with abnormally expanded light areas and video frames with normal light areas appear alternately, which can easily give the user a subjective sense of tremor and affect the user's experience. Among them, the video frame with abnormally expanded light areas in the picture can be called a tremor image.

目前,便携式终端中所配置的电子图像防抖(Electronic Image Stabilization,EIS)技术通过对视频画面进行旋转、平移以及矫正等处理,使视频画面中的物体仍然能够处于稳定的位置中。然而,现有的EIS技术无法处理视频画面中灯光区域不正常外扩的问题。基于EIS技术,视频中的灯光区域在稳定帧和抖动帧中的显示位置是稳定的,但抖动帧中仍然会出现灯光区域不正常外扩的现象。At present, the electronic image stabilization (EIS) technology configured in portable terminals can rotate, translate and correct the video image to keep the objects in the video image in a stable position. However, the existing EIS technology cannot handle the problem of abnormal expansion of the light area in the video image. Based on the EIS technology, the display position of the light area in the video is stable in the stable frame and the shaking frame, but the phenomenon of abnormal expansion of the light area still occurs in the shaking frame.

有鉴于此,本申请实施例提供了一种视频处理方法,通过确定视频中的图像的抖动值,来定位视频中的震颤图像。然后,将震颤图像前后的图像作为参考图像,并基于震颤图像以及参考图像来求取参考图像中的图像块之间的相对位移。最终,基于参考图像中的图像块以及图像块对应的相对位移来生成用于替换震颤图像的目标图像。通过本方案,能够将视频中的震颤图像替换为正常显示的图像,从而解决由镜头抖动所引起的视频画面中的灯光区域不正常外扩的问题。In view of this, an embodiment of the present application provides a video processing method, which locates a trembling image in a video by determining the jitter value of an image in the video. Then, the images before and after the trembling image are used as reference images, and the relative displacement between image blocks in the reference image is obtained based on the trembling image and the reference image. Finally, a target image for replacing the trembling image is generated based on the image blocks in the reference image and the relative displacement corresponding to the image blocks. Through this solution, the trembling image in the video can be replaced with a normally displayed image, thereby solving the problem of abnormal expansion of the light area in the video screen caused by lens shaking.

可以参阅图1a和图1b,图1a为本申请实施例提供的震颤图像以及用于替换震颤图像的图像之间的对比示意图;图1b为本申请实施例提供的另一种震颤图像以及用于替换震颤图像的图像之间的对比示意图。Please refer to Figures 1a and 1b, Figure 1a is a schematic diagram of the comparison between the tremor image provided in an embodiment of the present application and an image used to replace the tremor image; Figure 1b is a schematic diagram of the comparison between another tremor image provided in an embodiment of the present application and an image used to replace the tremor image.

如图1a所示,图1a中的震颤图像1是在室外场景下所拍摄得到的图像。由图1a可以看出,震颤图像1中的灯光区域,即大楼的窗户所在的区域,出现了明显的外扩现象。在基于本申请实施例提供的方法对震颤图像1进行处理后,得到用于替换该震颤图像1的稳定图像1,该稳定图像1中的灯光区域正常显示。As shown in FIG. 1a, the trembling image 1 in FIG. 1a is an image captured in an outdoor scene. As can be seen from FIG. 1a, the light area in the trembling image 1, that is, the area where the windows of the building are located, has an obvious outward expansion phenomenon. After the trembling image 1 is processed by the method provided in the embodiment of the present application, a stable image 1 is obtained to replace the trembling image 1, and the light area in the stable image 1 is displayed normally.

如图1b所示,图1b中的震颤图像2是在室内场景下所拍摄得到的图像。由图1b可以看出,震颤图像2中的灯光区域,即室内天花板上的灯具所在的区域,出现了明显的外扩现象。在对震颤图像2进行处理后,得到用于替换该震颤图像2的稳定图像2,该稳定图像2中的灯光区域正常显示。As shown in FIG1b, the trembling image 2 in FIG1b is an image captured in an indoor scene. As can be seen from FIG1b, the light area in the trembling image 2, that is, the area where the lamps on the indoor ceiling are located, has an obvious outward expansion phenomenon. After processing the trembling image 2, a stable image 2 is obtained to replace the trembling image 2, and the light area in the stable image 2 is displayed normally.

本申请实施例所提供的视频处理方法可以应用于具有视频采集功能的终端上。该终端又称之为用户设备(user equipment,UE)、移动台(mobile station,MS)、移动终端(mobile terminal,MT)等,是一种安装有能够拍摄视频的终端的设备,且能够对拍摄得到的视频进行处理,从而输出稳定显示的视频。例如,具有拍摄功能的手持式设备、监控摄像机等。The video processing method provided in the embodiment of the present application can be applied to a terminal with a video acquisition function. The terminal is also called user equipment (UE), mobile station (MS), mobile terminal (MT), etc., which is a device equipped with a terminal capable of shooting video, and can process the captured video to output a stable displayed video. For example, a handheld device with a shooting function, a surveillance camera, etc.

目前,一些终端的举例为:手机(mobile phone)、平板电脑、笔记本电脑、掌上电脑、监控摄像机、移动互联网设备(mobile internet device,MID)、可穿戴设备,虚拟现实(virtual reality,VR)设备、增强现实(augmented reality,AR)设备、工业控制(industrial control)中的无线终端、无人驾驶(self driving)中的无线终端、远程手术(remote medical surgery)中的无线终端、智能电网(smart grid)中的无线终端、运输安全(transportation safety)中的无线终端、智慧城市(smart city)中的无线终端、智慧家庭(smart home)中的无线终端等。At present, some examples of terminals are: mobile phones, tablet computers, laptops, PDAs, surveillance cameras, mobile internet devices (MID), wearable devices, virtual reality (VR) devices, augmented reality (AR) devices, wireless terminals in industrial control, wireless terminals in self driving, wireless terminals in remote medical surgery, wireless terminals in smart grids, wireless terminals in transportation safety, wireless terminals in smart cities, wireless terminals in smart homes, etc.

终端中的图像采集装置用于将光信号转换为电信号,以生成图像信号。图像采集装置例如可以为图像传感器,图像传感器例如可以为电荷耦合器件(Charge CoupledDevice,CCD)或者互补金属氧化物半导体(Complementary Metal Oxide Semiconductor,CMOS)。The image acquisition device in the terminal is used to convert the optical signal into an electrical signal to generate an image signal. The image acquisition device may be, for example, an image sensor, which may be, for example, a charge coupled device (CCD) or a complementary metal oxide semiconductor (CMOS).

为便于理解,下面将对本申请实施例提供的终端100的结构进行示例说明。参见图2a,图2a为本申请实施例提供的终端设备的结构示意图。For ease of understanding, the structure of the terminal 100 provided in the embodiment of the present application is described below by way of example. Referring to Fig. 2a, Fig. 2a is a schematic diagram of the structure of the terminal device provided in the embodiment of the present application.

如图2a所示,终端100可以包括处理器110,外部存储器接口120,内部存储器121,通用串行总线(universal serial bus,USB)接口130,充电管理模块140,电源管理模块141,电池142,天线1,天线2,移动通信模块150,无线通信模块160,音频模块170,扬声器170A,受话器170B,麦克风170C,耳机接口170D,传感器模块180,按键190,马达191,指示器192,摄像头193,显示屏194,以及用户标识模块(subscriber identification module,SIM)卡接口195等。其中传感器模块180可以包括压力传感器180A,陀螺仪传感器180B,气压传感器180C,磁传感器180D,加速度传感器180E,距离传感器180F,接近光传感器180G,指纹传感器180H,温度传感器180J,触摸传感器180K,环境光传感器180L,骨传导传感器180M等。As shown in Figure 2a, the terminal 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.

可以理解的是,本发明实施例示意的结构并不构成对终端100的具体限定。在本申请另一些实施例中,终端100可以包括比图示更多或更少的部件,或者组合某些部件,或者拆分某些部件,或者不同的部件布置。图示的部件可以以硬件,软件或软件和硬件的组合实现。It is to be understood that the structure illustrated in the embodiment of the present invention does not constitute a specific limitation on the terminal 100. In other embodiments of the present application, the terminal 100 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

处理器110可以包括一个或多个处理单元,例如:处理器110可以包括应用处理器(application processor,AP),调制解调处理器,图形处理器(graphics processingunit,GPU),图像信号处理器(image signal processor,ISP),控制器,视频编解码器,数字信号处理器(digital signal processor,DSP),基带处理器,和/或神经网络处理器(neural-network processing unit,NPU)等。其中,不同的处理单元可以是独立的器件,也可以集成在一个或多个处理器中。The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and/or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.

控制器可以根据指令操作码和时序信号,产生操作控制信号,完成取指令和执行指令的控制。The controller can generate operation control signals according to the instruction operation code and timing signal to complete the control of instruction fetching and execution.

处理器110中还可以设置存储器,用于存储指令和数据。在一些实施例中,处理器110中的存储器为高速缓冲存储器。该存储器可以保存处理器110刚用过或循环使用的指令或数据。如果处理器110需要再次使用该指令或数据,可从所述存储器中直接调用。避免了重复存取,减少了处理器110的等待时间,因而提高了系统的效率。The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.

在一些实施例中,处理器110可以包括一个或多个接口。接口可以包括集成电路(inter-integrated circuit,I2C)接口,集成电路内置音频(inter-integrated circuitsound,I2S)接口,脉冲编码调制(pulse code modulation,PCM)接口,通用异步收发传输器(universal asynchronous receiver/transmitter,UART)接口,移动产业处理器接口(mobile industry processor interface,MIPI),通用输入输出(general-purposeinput/output,GPIO)接口,用户标识模块(subscriber identity module,SIM)接口,和/或通用串行总线(universal serial bus,USB)接口等。In some embodiments, the processor 110 may include one or more interfaces. The interface may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver/transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input/output (GPIO) interface, a subscriber identity module (SIM) interface, and/or a universal serial bus (USB) interface, etc.

I2C接口是一种双向同步串行总线,包括一根串行数据线(serial data line,SDA)和一根串行时钟线(derail clock line,SCL)。在一些实施例中,处理器110可以包含多组I2C总线。处理器110可以通过不同的I2C总线接口分别耦合触摸传感器180K,充电器,闪光灯,摄像头193等。例如:处理器110可以通过I2C接口耦合触摸传感器180K,使处理器110与触摸传感器180K通过I2C总线接口通信,实现终端100的触摸功能。The I2C interface is a bidirectional synchronous serial bus, including a serial data line (SDA) and a serial clock line (SCL). In some embodiments, the processor 110 may include multiple groups of I2C buses. The processor 110 may be coupled to the touch sensor 180K, the charger, the flash, the camera 193, etc. through different I2C bus interfaces. For example: the processor 110 may be coupled to the touch sensor 180K through the I2C interface, so that the processor 110 communicates with the touch sensor 180K through the I2C bus interface, thereby realizing the touch function of the terminal 100.

I2S接口可以用于音频通信。在一些实施例中,处理器110可以包含多组I2S总线。处理器110可以通过I2S总线与音频模块170耦合,实现处理器110与音频模块170之间的通信。在一些实施例中,音频模块170可以通过I2S接口向无线通信模块160传递音频信号,实现通过蓝牙耳机接听电话的功能。The I2S interface can be used for audio communication. In some embodiments, the processor 110 can include multiple I2S buses. The processor 110 can be coupled to the audio module 170 via the I2S bus to achieve communication between the processor 110 and the audio module 170. In some embodiments, the audio module 170 can transmit an audio signal to the wireless communication module 160 via the I2S interface to achieve the function of answering a call through a Bluetooth headset.

PCM接口也可以用于音频通信,将模拟信号抽样,量化和编码。在一些实施例中,音频模块170与无线通信模块160可以通过PCM总线接口耦合。在一些实施例中,音频模块170也可以通过PCM接口向无线通信模块160传递音频信号,实现通过蓝牙耳机接听电话的功能。所述I2S接口和所述PCM接口都可以用于音频通信。The PCM interface can also be used for audio communication, sampling, quantizing and encoding analog signals. In some embodiments, the audio module 170 and the wireless communication module 160 can be coupled via a PCM bus interface. In some embodiments, the audio module 170 can also transmit audio signals to the wireless communication module 160 via the PCM interface to realize the function of answering calls via a Bluetooth headset. Both the I2S interface and the PCM interface can be used for audio communication.

UART接口是一种通用串行数据总线,用于异步通信。该总线可以为双向通信总线。它将要传输的数据在串行通信与并行通信之间转换。在一些实施例中,UART接口通常被用于连接处理器110与无线通信模块160。例如:处理器110通过UART接口与无线通信模块160中的蓝牙模块通信,实现蓝牙功能。在一些实施例中,音频模块170可以通过UART接口向无线通信模块160传递音频信号,实现通过蓝牙耳机播放音乐的功能。The UART interface is a universal serial data bus for asynchronous communication. The bus can be a bidirectional communication bus. It converts the data to be transmitted between serial communication and parallel communication. In some embodiments, the UART interface is generally used to connect the processor 110 and the wireless communication module 160. For example, the processor 110 communicates with the Bluetooth module in the wireless communication module 160 through the UART interface to implement the Bluetooth function. In some embodiments, the audio module 170 can transmit an audio signal to the wireless communication module 160 through the UART interface to implement the function of playing music through a Bluetooth headset.

MIPI接口可以被用于连接处理器110与显示屏194,摄像头193等外围器件。MIPI接口包括摄像头串行接口(camera serial interface,CSI),显示屏串行接口(displayserial interface,DSI)等。在一些实施例中,处理器110和摄像头193通过CSI接口通信,实现终端100的拍摄功能。处理器110和显示屏194通过DSI接口通信,实现终端100的显示功能。The MIPI interface can be used to connect the processor 110 with peripheral devices such as the display screen 194 and the camera 193. The MIPI interface includes a camera serial interface (CSI), a display serial interface (DSI), etc. In some embodiments, the processor 110 and the camera 193 communicate via the CSI interface to implement the shooting function of the terminal 100. The processor 110 and the display screen 194 communicate via the DSI interface to implement the display function of the terminal 100.

GPIO接口可以通过软件配置。GPIO接口可以被配置为控制信号,也可被配置为数据信号。在一些实施例中,GPIO接口可以用于连接处理器110与摄像头193,显示屏194,无线通信模块160,音频模块170,传感器模块180等。GPIO接口还可以被配置为I2C接口,I2S接口,UART接口,MIPI接口等。The GPIO interface can be configured by software. The GPIO interface can be configured as a control signal or as a data signal. In some embodiments, the GPIO interface can be used to connect the processor 110 with the camera 193, the display 194, the wireless communication module 160, the audio module 170, the sensor module 180, etc. The GPIO interface can also be configured as an I2C interface, an I2S interface, a UART interface, a MIPI interface, etc.

USB接口130是符合USB标准规范的接口,具体可以是Mini USB接口,Micro USB接口,USB Type C接口等。USB接口130可以用于连接充电器为终端100充电,也可以用于终端100与外围设备之间传输数据。也可以用于连接耳机,通过耳机播放音频。该接口还可以用于连接其他电子设备,例如AR设备等。The USB interface 130 is an interface that complies with the USB standard specification, and specifically can be a Mini USB interface, a Micro USB interface, a USB Type C interface, etc. The USB interface 130 can be used to connect a charger to charge the terminal 100, and can also be used to transmit data between the terminal 100 and peripheral devices. It can also be used to connect headphones to play audio through the headphones. The interface can also be used to connect other electronic devices, such as AR devices, etc.

可以理解的是,本发明实施例示意的各模块间的接口连接关系,只是示意性说明,并不构成对终端100的结构限定。在本申请另一些实施例中,终端100也可以采用上述实施例中不同的接口连接方式,或多种接口连接方式的组合。It is understandable that the interface connection relationship between the modules illustrated in the embodiment of the present invention is only a schematic illustration and does not constitute a structural limitation on the terminal 100. In other embodiments of the present application, the terminal 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.

充电管理模块140用于从充电器接收充电输入。The charging management module 140 is used to receive charging input from a charger.

电源管理模块141用于连接电池142,充电管理模块140与处理器110。The power management module 141 is used to connect the battery 142 , the charging management module 140 and the processor 110 .

终端100的无线通信功能可以通过天线1,天线2,移动通信模块150,无线通信模块160,调制解调处理器以及基带处理器等实现。The wireless communication function of the terminal 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.

天线1和天线2用于发射和接收电磁波信号。终端100中的每个天线可用于覆盖单个或多个通信频带。不同的天线还可以复用,以提高天线的利用率。例如:可以将天线1复用为无线局域网的分集天线。在另外一些实施例中,天线可以和调谐开关结合使用。Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in terminal 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve the utilization of the antennas. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In some other embodiments, the antenna can be used in combination with a tuning switch.

移动通信模块150可以提供应用在终端100上的包括2G/3G/4G/5G等无线通信的解决方案。移动通信模块150可以包括至少一个滤波器,开关,功率放大器,低噪声放大器(lownoise amplifier,LNA)等。移动通信模块150可以由天线1接收电磁波,并对接收的电磁波进行滤波,放大等处理,传送至调制解调处理器进行解调。移动通信模块150还可以对经调制解调处理器调制后的信号放大,经天线1转为电磁波辐射出去。在一些实施例中,移动通信模块150的至少部分功能模块可以被设置于处理器110中。在一些实施例中,移动通信模块150的至少部分功能模块可以与处理器110的至少部分模块被设置在同一个器件中。The mobile communication module 150 can provide solutions for wireless communications including 2G/3G/4G/5G applied on the terminal 100. The mobile communication module 150 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves from the antenna 1, and filter, amplify, and process the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves for radiation through the antenna 1. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the processor 110. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the same device as at least some of the modules of the processor 110.

调制解调处理器可以包括调制器和解调器。其中,调制器用于将待发送的低频基带信号调制成中高频信号。解调器用于将接收的电磁波信号解调为低频基带信号。随后解调器将解调得到的低频基带信号传送至基带处理器处理。低频基带信号经基带处理器处理后,被传递给应用处理器。应用处理器通过音频设备(不限于扬声器170A,受话器170B等)输出声音信号,或通过显示屏194显示图像或视频。在一些实施例中,调制解调处理器可以是独立的器件。在另一些实施例中,调制解调处理器可以独立于处理器110,与移动通信模块150或其他功能模块设置在同一个器件中。The modem processor may include a modulator and a demodulator. Among them, the modulator is used to modulate the low-frequency baseband signal to be sent into a medium-high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After the low-frequency baseband signal is processed by the baseband processor, it is passed to the application processor. The application processor outputs a sound signal through an audio device (not limited to a speaker 170A, a receiver 170B, etc.), or displays an image or video through a display screen 194. In some embodiments, the modem processor may be an independent device. In other embodiments, the modem processor may be independent of the processor 110 and be set in the same device as the mobile communication module 150 or other functional modules.

无线通信模块160可以提供应用在终端100上的包括无线局域网(wireless localarea networks,WLAN)(如无线保真(wireless fidelity,Wi-Fi)网络),蓝牙(bluetooth,BT),全球导航卫星系统(global navigation satellite system,GNSS),调频(frequencymodulation,FM),近距离无线通信技术(near field communication,NFC),红外技术(infrared,IR)等无线通信的解决方案。无线通信模块160可以是集成至少一个通信处理模块的一个或多个器件。无线通信模块160经由天线2接收电磁波,将电磁波信号调频以及滤波处理,将处理后的信号发送到处理器110。无线通信模块160还可以从处理器110接收待发送的信号,对其进行调频,放大,经天线2转为电磁波辐射出去。The wireless communication module 160 can provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc., which are applied to the terminal 100. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, modulates the frequency of the electromagnetic wave signal and performs filtering, and sends the processed signal to the processor 110. The wireless communication module 160 can also receive the signal to be sent from the processor 110, modulate the frequency of it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.

在一些实施例中,终端100的天线1和移动通信模块150耦合,天线2和无线通信模块160耦合,使得终端100可以通过无线通信技术与网络以及其他设备通信。所述无线通信技术可以包括全球移动通讯系统(global system for mobile communications,GSM),通用分组无线服务(general packet radio service,GPRS),码分多址接入(code divisionmultiple access,CDMA),宽带码分多址(wideband code division multiple access,WCDMA),时分码分多址(time-division code division multiple access,TD-SCDMA),长期演进(long term evolution,LTE),BT,GNSS,WLAN,NFC,FM,和/或IR技术等。所述GNSS可以包括全球卫星定位系统(global positioning system,GPS),全球导航卫星系统(globalnavigation satellite system,GLONASS),北斗卫星导航系统(beidou navigationsatellite system,BDS),准天顶卫星系统(quasi-zenith satellite system,QZSS)和/或星基增强系统(satellite based augmentation systems,SBAS)。In some embodiments, the antenna 1 of the terminal 100 is coupled to the mobile communication module 150, and the antenna 2 is coupled to the wireless communication module 160, so that the terminal 100 can communicate with the network and other devices through wireless communication technology. The wireless communication technology may include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), wideband code division multiple access (WCDMA), time-division code division multiple access (TD-SCDMA), long term evolution (LTE), BT, GNSS, WLAN, NFC, FM, and/or IR technology, etc. The GNSS may include a global positioning system (GPS), a global navigation satellite system (GLONASS), a Beidou navigation satellite system (BDS), a quasi-zenith satellite system (QZSS) and/or a satellite based augmentation system (SBAS).

终端100通过GPU,显示屏194,以及应用处理器等实现显示功能。GPU为图像处理的微处理器,连接显示屏194和应用处理器。GPU用于执行数学和几何计算,用于图形渲染。处理器110可包括一个或多个GPU,其执行程序指令以生成或改变显示信息。The terminal 100 implements the display function through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs that execute program instructions to generate or change display information.

显示屏194用于显示图像,视频等。显示屏194包括显示面板。显示面板可以采用液晶显示屏(liquid crystal display,LCD),有机发光二极管(organic light-emittingdiode,OLED),有源矩阵有机发光二极体或主动矩阵有机发光二极体(active-matrixorganic light emitting diode的,AMOLED),柔性发光二极管(flex light-emittingdiode,FLED),Miniled,MicroLed,Micro-oLed,量子点发光二极管(quantum dot lightemitting diodes,QLED)等。在一些实施例中,终端100可以包括1个或N个显示屏194,N为大于1的正整数。The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the terminal 100 may include 1 or N display screens 194, where N is a positive integer greater than 1.

具体的,显示屏194可以显示本实施例中的目标界面。Specifically, the display screen 194 can display the target interface in this embodiment.

终端100可以通过ISP,摄像头193,视频编解码器,GPU,显示屏194以及应用处理器等实现拍摄功能。ISP用于处理摄像头193反馈的数据。摄像头193用于捕获静态图像或视频。The terminal 100 can realize the shooting function through the ISP, the camera 193, the video codec, the GPU, the display screen 194 and the application processor. The ISP is used to process the data fed back by the camera 193. The camera 193 is used to capture a still image or a video.

视频编解码器用于对数字视频压缩或解压缩。终端100可以支持一种或多种视频编解码器。这样,终端100可以播放或录制多种编码格式的视频,例如:动态图像专家组(moving picture experts group,MPEG)1,MPEG2,MPEG3,MPEG4等。Video codecs are used to compress or decompress digital videos. Terminal 100 may support one or more video codecs. Thus, terminal 100 may play or record videos in various coding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.

外部存储器接口120可以用于连接外部存储卡,例如Micro SD卡,实现扩展终端100的存储能力。外部存储卡通过外部存储器接口120与处理器110通信,实现数据存储功能。例如将音乐,视频等文件保存在外部存储卡中。The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the terminal 100. The external memory card communicates with the processor 110 through the external memory interface 120 to implement a data storage function, such as storing music, video and other files in the external memory card.

内部存储器121可以用于存储计算机可执行程序代码,所述可执行程序代码包括指令。内部存储器121可以包括存储程序区和存储数据区。其中,存储程序区可存储操作系统,至少一个功能所需的应用程序(比如声音播放功能,图像播放功能等)等。存储数据区可存储终端100使用过程中所创建的数据(比如音频数据,电话本等)等。此外,内部存储器121可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件,闪存器件,通用闪存存储器(universal flash storage,UFS)等。处理器110通过运行存储在内部存储器121的指令,和/或存储在设置于处理器中的存储器的指令,执行终端100的各种功能应用以及数据处理。The internal memory 121 can be used to store computer executable program codes, which include instructions. The internal memory 121 may include a program storage area and a data storage area. Among them, the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc. The data storage area may store data created during the use of the terminal 100 (such as audio data, a phone book, etc.), etc. In addition, the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc. The processor 110 executes various functional applications and data processing of the terminal 100 by running instructions stored in the internal memory 121 and/or instructions stored in a memory provided in the processor.

终端100可以通过音频模块170,扬声器170A,受话器170B,麦克风170C,耳机接口170D,以及应用处理器等实现音频功能。例如音乐播放,录音等。The terminal 100 can implement audio functions such as music playing and recording through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the earphone interface 170D, and the application processor.

音频模块170用于将数字音频信息转换成模拟音频信号输出,也用于将模拟音频输入转换为数字音频信号。音频模块170还可以用于对音频信号编码和解码。在一些实施例中,音频模块170可以设置于处理器110中,或将音频模块170的部分功能模块设置于处理器110中。The audio module 170 is used to convert digital audio information into analog audio signal output, and is also used to convert analog audio input into digital audio signals. The audio module 170 can also be used to encode and decode audio signals. In some embodiments, the audio module 170 can be arranged in the processor 110, or some functional modules of the audio module 170 can be arranged in the processor 110.

扬声器170A,也称“喇叭”,用于将音频电信号转换为声音信号。终端100可以通过扬声器170A收听音乐,或收听免提通话。受话器170B,也称“听筒”,用于将音频电信号转换成声音信号。麦克风170C,也称“话筒”,“传声器”,用于将声音信号转换为电信号。耳机接口170D用于连接有线耳机。The speaker 170A, also called a "speaker", is used to convert an audio electrical signal into a sound signal. The terminal 100 can listen to music or listen to a hands-free call through the speaker 170A. The receiver 170B, also called a "handset", is used to convert an audio electrical signal into a sound signal. The microphone 170C, also called a "microphone" or "microphone", is used to convert a sound signal into an electrical signal. The headphone jack 170D is used to connect a wired headphone.

压力传感器180A用于感受压力信号,可以将压力信号转换成电信号。The pressure sensor 180A is used to sense pressure signals and convert the pressure signals into electrical signals.

陀螺仪传感器180B可以用于确定终端100的运动姿态。The gyro sensor 180B may be used to determine a motion posture of the terminal 100 .

气压传感器180C用于测量气压。The air pressure sensor 180C is used to measure air pressure.

磁传感器180D包括霍尔传感器。The magnetic sensor 180D includes a Hall sensor.

加速度传感器180E可检测终端100在各个方向上(一般为三轴)加速度的大小。The acceleration sensor 180E can detect the magnitude of the acceleration of the terminal 100 in various directions (generally three axes).

距离传感器180F,用于测量距离。The distance sensor 180F is used to measure the distance.

接近光传感器180G可以包括例如发光二极管(LED)和光检测器,例如光电二极管。The proximity light sensor 180G may include, for example, a light emitting diode (LED) and a light detector, such as a photodiode.

环境光传感器180L用于感知环境光亮度。The ambient light sensor 180L is used to sense the brightness of ambient light.

指纹传感器180H用于采集指纹。The fingerprint sensor 180H is used to collect fingerprints.

温度传感器180J用于检测温度。The temperature sensor 180J is used to detect the temperature.

触摸传感器180K,也称“触控器件”。触摸传感器180K可以设置于显示屏194,由触摸传感器180K与显示屏194组成触摸屏,也称“触控屏”。触摸传感器180K用于检测作用于其上或附近的触摸操作。触摸传感器可以将检测到的触摸操作传递给应用处理器,以确定触摸事件类型。可以通过显示屏194提供与触摸操作相关的视觉输出。在另一些实施例中,触摸传感器180K也可以设置于终端100的表面,与显示屏194所处的位置不同。The touch sensor 180K is also called a "touch control device". The touch sensor 180K can be set on the display screen 194, and the touch sensor 180K and the display screen 194 form a touch screen, also called a "touch control screen". The touch sensor 180K is used to detect touch operations acting on or near it. The touch sensor can pass the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through the display screen 194. In other embodiments, the touch sensor 180K can also be set on the surface of the terminal 100, which is different from the position of the display screen 194.

骨传导传感器180M可以获取振动信号。Bone conduction sensor 180M can obtain vibration signals.

按键190包括开机键,音量键等。按键190可以是机械按键。也可以是触摸式按键。终端100可以接收按键输入,产生与终端100的用户设置以及功能控制有关的键信号输入。The key 190 includes a power key, a volume key, etc. The key 190 may be a mechanical key or a touch key. The terminal 100 may receive key input and generate key signal input related to user settings and function control of the terminal 100.

马达191可以产生振动提示。Motor 191 can generate vibration prompts.

指示器192可以是指示灯,可以用于指示充电状态,电量变化,也可以用于指示消息,未接来电,通知等。Indicator 192 may be an indicator light, which may be used to indicate charging status, power changes, messages, missed calls, notifications, etc.

SIM卡接口195用于连接SIM卡。The SIM card interface 195 is used to connect a SIM card.

终端100的软件系统可以采用分层架构,事件驱动架构,微核架构,微服务架构,或云架构。本发明实施例以分层架构的Android系统为例,示例性说明终端100的软件结构。The software system of the terminal 100 may adopt a layered architecture, an event-driven architecture, a micro-kernel architecture, a micro-service architecture, or a cloud architecture. In the embodiment of the present invention, the Android system of the layered architecture is taken as an example to exemplify the software structure of the terminal 100.

图2b为本申请实施例提供的终端100的软件结构框图。FIG. 2 b is a software structure block diagram of the terminal 100 provided in an embodiment of the present application.

分层架构将软件分成若干个层,每一层都有清晰的角色和分工。层与层之间通过软件接口通信。在一些实施例中,将Android系统分为四层,从上至下分别为应用程序层,应用程序框架层,安卓运行时(Android runtime)和系统库,以及内核层。The layered architecture divides the software into several layers, each with clear roles and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom, namely, the application layer, the application framework layer, the Android runtime and system library, and the kernel layer.

应用程序层可以包括一系列应用程序包。The application layer can include a series of application packages.

如图2b所示,应用程序包可以包括相机,图库,日历,通话,地图,导航,WLAN,蓝牙,音乐,视频,短信息等应用程序。As shown in FIG. 2 b , the application package may include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message, etc.

应用程序框架层为应用程序层的应用程序提供应用编程接口(applicationprogramming interface,API)和编程框架。应用程序框架层包括一些预先定义的函数。The application framework layer provides an application programming interface (API) and a programming framework for the applications in the application layer. The application framework layer includes some predefined functions.

如图2b所示,应用程序框架层可以包括窗口管理器,内容提供器,视图系统,电话管理器,资源管理器,通知管理器等。As shown in FIG. 2 b , the application framework layer may include a window manager, a content provider, a view system, a telephony manager, a resource manager, a notification manager, and the like.

窗口管理器用于管理窗口程序。窗口管理器可以获取显示屏大小,判断是否有状态栏,锁定屏幕,截取屏幕等。The window manager is used to manage window programs. The window manager can obtain the display screen size, determine whether there is a status bar, lock the screen, capture the screen, etc.

内容提供器用来存放和获取数据,并使这些数据可以被应用程序访问。所述数据可以包括视频,图像,音频,拨打和接听的电话,浏览历史和书签,电话簿等。Content providers are used to store and retrieve data and make it accessible to applications. The data may include videos, images, audio, calls made and received, browsing history and bookmarks, phone books, etc.

视图系统包括可视控件,例如显示文字的控件,显示图片的控件等。视图系统可用于构建应用程序。显示界面可以由一个或多个视图组成的。例如,包括短信通知图标的显示界面,可以包括显示文字的视图以及显示图片的视图。The view system includes visual controls, such as controls for displaying text, controls for displaying images, etc. The view system can be used to build applications. A display interface can be composed of one or more views. For example, a display interface including a text notification icon can include a view for displaying text and a view for displaying images.

电话管理器用于提供终端100的通信功能。例如通话状态的管理(包括接通,挂断等)。The phone manager is used to provide communication functions of the terminal 100, such as management of call status (including connection, disconnection, etc.).

资源管理器为应用程序提供各种资源,比如本地化字符串,图标,图片,布局文件,视频文件等等。The resource manager provides various resources for applications, such as localized strings, icons, images, layout files, video files, and so on.

通知管理器使应用程序可以在状态栏中显示通知信息,可以用于传达告知类型的消息,可以短暂停留后自动消失,无需用户交互。比如通知管理器被用于告知下载完成,消息提醒等。通知管理器还可以是以图表或者滚动条文本形式出现在系统顶部状态栏的通知,例如后台运行的应用程序的通知,还可以是以对话窗口形式出现在屏幕上的通知。例如在状态栏提示文本信息,发出提示音,电子设备振动,指示灯闪烁等。The notification manager enables applications to display notification information in the status bar. It can be used to convey notification-type messages and can disappear automatically after a short stay without user interaction. For example, the notification manager is used to notify download completion, message reminders, etc. The notification manager can also be a notification that appears in the system top status bar in the form of a chart or scroll bar text, such as notifications of applications running in the background, or a notification that appears on the screen in the form of a dialog window. For example, a text message is displayed in the status bar, a prompt sound is emitted, an electronic device vibrates, an indicator light flashes, etc.

Android Runtime包括核心库和虚拟机。Android runtime负责安卓系统的调度和管理。Android Runtime includes core libraries and virtual machines. Android runtime is responsible for scheduling and management of the Android system.

核心库包含两部分:一部分是java语言需要调用的功能函数,另一部分是安卓的核心库。The core library consists of two parts: one part is the function that needs to be called by the Java language, and the other part is the Android core library.

应用程序层和应用程序框架层运行在虚拟机中。虚拟机将应用程序层和应用程序框架层的java文件执行为二进制文件。虚拟机用于执行对象生命周期的管理,堆栈管理,线程管理,安全和异常的管理,以及垃圾回收等功能。The application layer and the application framework layer run in a virtual machine. The virtual machine executes the Java files of the application layer and the application framework layer as binary files. The virtual machine is used to perform functions such as object life cycle management, stack management, thread management, security and exception management, and garbage collection.

系统库可以包括多个功能模块。例如:表面管理器(surface manager),媒体库(Media Libraries),三维图形处理库(例如:OpenGL ES),2D图形引擎(例如:SGL)等。The system library may include multiple functional modules, such as surface manager, media library, 3D graphics processing library (such as OpenGL ES), 2D graphics engine (such as SGL), etc.

表面管理器用于对显示子系统进行管理,并且为多个应用程序提供了2D和3D图层的融合。The surface manager is used to manage the display subsystem and provide the fusion of 2D and 3D layers for multiple applications.

媒体库支持多种常用的音频,视频格式回放和录制,以及静态图像文件等。媒体库可以支持多种音视频编码格式,例如:MPEG4,H.264,MP3,AAC,AMR,JPG,PNG等。The media library supports playback and recording of a variety of commonly used audio and video formats, as well as static image files, etc. The media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.

三维图形处理库用于实现三维图形绘图,图像渲染,合成,和图层处理等。The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.

2D图形引擎是2D绘图的绘图引擎。A 2D graphics engine is a drawing engine for 2D drawings.

内核层是硬件和软件之间的层。内核层至少包含显示驱动,摄像头驱动,音频驱动,传感器驱动。The kernel layer is the layer between hardware and software. The kernel layer contains at least display driver, camera driver, audio driver, and sensor driver.

下面结合视频播放场景,示例性说明终端100软件以及硬件的工作流程。The following is an illustrative description of the software and hardware workflow of the terminal 100 in conjunction with a video playback scenario.

当触摸传感器180K接收到触摸操作,相应的硬件中断被发给内核层。内核层将触摸操作加工成原始输入事件(包括触摸坐标,触摸操作的时间戳等信息)。原始输入事件被存储在内核层。应用程序框架层从内核层获取原始输入事件,识别该输入事件所对应的控件。以该触摸操作是触摸单击操作,以该单击操作所对应的控件为视频播放相关应用图标的控件为例,视频播放应用调用应用框架层的接口,启动视频播放应用,进而通过调用内核层在视频播放应用的视频播放界面播放视频,例如可以播放自由视点视频。When the touch sensor 180K receives a touch operation, the corresponding hardware interrupt is sent to the kernel layer. The kernel layer processes the touch operation into raw input events (including touch coordinates, timestamp of the touch operation and other information). The raw input events are stored in the kernel layer. The application framework layer obtains the raw input events from the kernel layer and identifies the controls corresponding to the input events. For example, if the touch operation is a touch single-click operation and the control corresponding to the single-click operation is a control of a video playback-related application icon, the video playback application calls the interface of the application framework layer to start the video playback application, and then plays the video in the video playback interface of the video playback application by calling the kernel layer, for example, a free viewpoint video can be played.

以上介绍了本申请实施例所提供的视频处理方法的应用场景,以下将详细介绍该视频处理方法的执行过程。The above introduces the application scenario of the video processing method provided in the embodiment of the present application. The following will introduce the execution process of the video processing method in detail.

可以参阅图3,图3为本申请实施例提供的一种视频处理方法的流程示意图。如图3所示,该视频处理方法包括以下的步骤301-步骤304。Please refer to Figure 3, which is a schematic flow chart of a video processing method provided by an embodiment of the present application. As shown in Figure 3, the video processing method includes the following steps 301-304.

步骤301,获取多个图像。Step 301, acquiring multiple images.

在本实施例中,所述多个图像可以是视频中的多个连续的图像。终端可以通过多种方式来获取所述多个图像。In this embodiment, the multiple images may be multiple continuous images in a video. The terminal may obtain the multiple images in multiple ways.

在一种可能的方式中,终端可以是以固定的帧率拍摄视频,从而获取一段时间内拍摄得到的多个图像。例如,在终端以30Hz的帧率拍摄视频时,所述多个图像可以是终端在1秒内所拍摄得到的30个图像。In one possible manner, the terminal may shoot a video at a fixed frame rate to obtain multiple images shot within a period of time. For example, when the terminal shoots a video at a frame rate of 30 Hz, the multiple images may be 30 images shot by the terminal within 1 second.

在另一种可能的方式中,终端可以是接收其他终端所发送的多个图像,所述多个图像是由其他终端拍摄得到的。简单来说,其他终端以固定的帧率进行视频的拍摄,并在拍摄得到多个图像后,将所述多个图像发送给本实施例中的终端,由本实施例中的终端对所述多个图像进行处理。In another possible manner, the terminal may receive multiple images sent by other terminals, where the multiple images are captured by other terminals. In short, the other terminals capture video at a fixed frame rate, and after capturing multiple images, the multiple images are sent to the terminal in this embodiment, which processes the multiple images.

步骤302,确定所述多个图像中的第一图像,所述第一图像的抖动值大于或等于第二预设阈值,所述抖动值为终端采集所述第一图像时的抖动位移。Step 302: determine a first image among the multiple images, wherein a jitter value of the first image is greater than or equal to a second preset threshold, and the jitter value is a jitter displacement when the terminal captures the first image.

本实施例中,终端通过确定所述多个图像中的每个图像的抖动值,来确定所述多个图像中的震颤图像。当所述多个图像中的任意一个图像的抖动值小于第二预设阈值时,则确定该图像不是震颤图像;当所述多个图像中的某一个图像的抖动值大于或等于第二预设阈值时,则确定该图像为震颤图像。其中,图像的抖动值是指终端在采集该图像时的抖动位移。第二预设阈值可以为300-400,例如第二预设阈值具体为360。In this embodiment, the terminal determines the trembling image in the multiple images by determining the jitter value of each image in the multiple images. When the jitter value of any one of the multiple images is less than the second preset threshold, it is determined that the image is not a trembling image; when the jitter value of one of the multiple images is greater than or equal to the second preset threshold, it is determined that the image is a trembling image. The jitter value of the image refers to the jitter displacement of the terminal when acquiring the image. The second preset threshold can be 300-400, for example, the second preset threshold is specifically 360.

在一个可能的实施例中,终端可以获取记录了终端在采集第一图像时的运动情况的传感器数据,并且基于传感器数据计算得到第一图像的抖动值。In a possible embodiment, the terminal may obtain sensor data recording a movement condition of the terminal when capturing the first image, and calculate a jitter value of the first image based on the sensor data.

示例性地,终端根据所述第一图像的曝光时间,获取所述第一图像对应的传感器数据,所述传感器数据用于记录所述终端在所述第一图像的曝光时间内的运动情况。例如,所述传感器数据可以为陀螺仪数据,即通过陀螺仪采集得到的数据。其中,陀螺仪是一种角运动检测装置,通过陀螺仪采集得到的陀螺仪数据记录了所述终端在所述第一图像的曝光时间内的角速度。此外,所述传感器数据也可以是通过其他的传感器所采集得到的数据,所述其他的传感器可以记录了所述终端在所述第一图像的曝光时间内的角速度或者角加速度。然后,终端根据所述传感器数据确定所述第一图像的抖动值,即确定终端在第一图像的曝光期间所发生的抖动位移。Exemplarily, the terminal obtains sensor data corresponding to the first image according to the exposure time of the first image, and the sensor data is used to record the movement of the terminal during the exposure time of the first image. For example, the sensor data may be gyroscope data, that is, data collected by a gyroscope. Among them, the gyroscope is an angular motion detection device, and the gyroscope data collected by the gyroscope records the angular velocity of the terminal during the exposure time of the first image. In addition, the sensor data may also be data collected by other sensors, and the other sensors may record the angular velocity or angular acceleration of the terminal during the exposure time of the first image. Then, the terminal determines the jitter value of the first image according to the sensor data, that is, determines the jitter displacement of the terminal during the exposure of the first image.

例如,在所述传感器数据为陀螺仪数据的情况下,终端可以获取到在第一图像曝光期间内的多个时刻的陀螺仪数据,每个陀螺仪数据都记录了终端在某一时刻下的三维转动角速度。因此,终端可以基于第一图像曝光期间内的多个陀螺仪数据以及相邻的两个陀螺仪数据之间的时间间隔,计算终端在相邻的两个采集时刻之间的角位移。最后,终端基于计算得到的多个角位移,确定终端在第一图像的曝光期间所发生的抖动位移。For example, when the sensor data is gyroscope data, the terminal can obtain gyroscope data at multiple moments during the exposure of the first image, and each gyroscope data records the three-dimensional rotation angular velocity of the terminal at a certain moment. Therefore, the terminal can calculate the angular displacement of the terminal between two adjacent acquisition moments based on the multiple gyroscope data during the exposure of the first image and the time interval between two adjacent gyroscope data. Finally, the terminal determines the jitter displacement of the terminal during the exposure of the first image based on the calculated multiple angular displacements.

基于上述的方法,终端可以获取到所述多个图像中的每个图像的抖动值,从而确定抖动值大于或等于第二预设阈值的第一图像。Based on the above method, the terminal can obtain the jitter value of each image in the multiple images, thereby determining the first image whose jitter value is greater than or equal to the second preset threshold.

在本实施例中,除了通过传感器数据来计算图像的抖动值之外,终端还可以是通过其他的方式来获取图像的抖动值。In this embodiment, in addition to calculating the jitter value of the image through sensor data, the terminal may also obtain the jitter value of the image through other methods.

在一种可能的实现方式中,终端可以计算图像的对比度值,并根据图像的对比度值确定图像的抖动值。In a possible implementation manner, the terminal may calculate a contrast value of the image, and determine a jitter value of the image according to the contrast value of the image.

具体来说,对于所述多个图像,终端可以计算所述多个图像中的每个图像的对比度值,进而基于每个图像的对比度值确定每个图像的抖动值。其中,终端可以是基于图像的感兴趣区域中的像素的亮度值,来计算图像的对比度值。具体地,终端可以先确定图像中的感兴趣区域,该感兴趣区域例如可以为位于图像中心的特定范围的区域。比如,该感兴趣区域为图像中心的12*12个像素所在的区域。然后,终端计算该感兴趣区域中的所有像素的亮度值,并且确定该感兴趣区域中亮度最高的像素以及亮度最低的像素。最后,终端计算亮度最高的像素的亮度值与亮度最低的像素的亮度值之间的比值,即终端计算最高亮度值与最低亮度值之间的比值,从而得到图像的对比度值。Specifically, for the multiple images, the terminal can calculate the contrast value of each image in the multiple images, and then determine the jitter value of each image based on the contrast value of each image. Among them, the terminal can calculate the contrast value of the image based on the brightness value of the pixels in the region of interest of the image. Specifically, the terminal can first determine the region of interest in the image, and the region of interest can be, for example, a region of a specific range located in the center of the image. For example, the region of interest is the region where 12*12 pixels in the center of the image are located. Then, the terminal calculates the brightness values of all pixels in the region of interest, and determines the pixel with the highest brightness and the pixel with the lowest brightness in the region of interest. Finally, the terminal calculates the ratio between the brightness value of the pixel with the highest brightness and the brightness value of the pixel with the lowest brightness, that is, the terminal calculates the ratio between the highest brightness value and the lowest brightness value, thereby obtaining the contrast value of the image.

在计算得到图像的对比度值之后,终端进一步根据图像的对比度值确定图像的抖动值。其中,图像的抖动值与图像的对比度值具有负相关的关系。即图像的对比度值越大,则图像的抖动值越小;图像的对比度值越小,图像的抖动值则越大。示例性地,可以定义图像的抖动值与图像的对比度值之间的乘积为一个特定的正数,因此终端可以通过将该正数除以图像的对比度值,来确定图像的抖动值。例如,假设图像的对比度值为C,则终端可以计算得到图像的抖动值为1/C。After calculating the contrast value of the image, the terminal further determines the jitter value of the image according to the contrast value of the image. Among them, the jitter value of the image is negatively correlated with the contrast value of the image. That is, the larger the contrast value of the image, the smaller the jitter value of the image; the smaller the contrast value of the image, the larger the jitter value of the image. Exemplarily, the product of the jitter value of the image and the contrast value of the image can be defined as a specific positive number, so the terminal can determine the jitter value of the image by dividing the positive number by the contrast value of the image. For example, assuming that the contrast value of the image is C, the terminal can calculate the jitter value of the image as 1/C.

在另一种可能的实现方式中,终端可以基于预先训练好的神经网络来确定图像的抖动值。In another possible implementation manner, the terminal may determine the jitter value of the image based on a pre-trained neural network.

示例性地,终端可以获取预先基于大量标注有抖动值的图像训练好的神经网络,该神经网络用于预测图像的抖动值。然后,终端将所述多个图像输入到该神经网络中,得到神经网络所输出的抖动值,从而确定所述多个图像中的每个图像的抖动值。其中,该神经网络是基于预先准备好的训练数据训练得到的。该训练数据包括在终端发生抖动的情况下所拍摄的大量图像,这些图像中的灯光区域均存在不正常外扩的现象。此外,这些图像上均标注有图像对应的抖动值。在获取到训练数据后,即可根据现有的神经网络训练方法训练该神经网络,最终得到训练好的神经网络。Exemplarily, the terminal can obtain a neural network that has been pre-trained based on a large number of images marked with jitter values, and the neural network is used to predict the jitter value of the image. Then, the terminal inputs the multiple images into the neural network to obtain the jitter value output by the neural network, thereby determining the jitter value of each of the multiple images. Among them, the neural network is trained based on pre-prepared training data. The training data includes a large number of images taken when the terminal is jittering, and the light areas in these images all have abnormal outward expansion. In addition, these images are marked with the jitter values corresponding to the images. After obtaining the training data, the neural network can be trained according to the existing neural network training method, and finally a trained neural network is obtained.

基于上述的两种实现方式,终端能够在无法获取到终端在采集图像时对应的传感器数据的情况下,有效地判断图像是否为震颤图像。Based on the above two implementation methods, the terminal can effectively determine whether the image is a tremor image when the terminal cannot obtain the corresponding sensor data when collecting the image.

在一个可能的实施例中,终端还可以确定所述多个图像是否存在局部灯光区域。只有在某一个图像存在局部灯光区域且该图像的抖动值大于或等于第二预设阈值时,终端将该图像确定为震颤图像。In a possible embodiment, the terminal may further determine whether there is a local light area in the multiple images. Only when a certain image has a local light area and the jitter value of the image is greater than or equal to a second preset threshold, the terminal determines the image as a trembling image.

本实施例中,灯光区域内的像素的亮度值均大于特定阈值,且灯光区域内的像素的亮度值与灯光区域的相邻区域的像素的亮度值之间的差异值大于预设设定的差值。其中,上述的特定阈值的取值可以为180-230,例如特定阈值具体为224;预先设定的差值的取值可以为25-50,例如预设设定的差值为32。例如,当终端检测到图像中存在有某一个区域内的像素的亮度值均大于224,且该区域内的像素的亮度值与相邻区域的像素的亮度值之间的差异值大于32,则终端可以确定该区域为灯光区域。其中,灯光区域的相邻区域可以是由与灯光区域内的像素相邻的像素所构成,即灯光区域的相邻区域内的像素与灯光区域内的像素相邻。In this embodiment, the brightness values of the pixels in the light area are all greater than a specific threshold, and the difference between the brightness values of the pixels in the light area and the brightness values of the pixels in the adjacent area of the light area is greater than a preset difference. The value of the above-mentioned specific threshold can be 180-230, for example, the specific threshold is specifically 224; the value of the preset difference can be 25-50, for example, the preset difference is 32. For example, when the terminal detects that the brightness values of the pixels in a certain area of the image are all greater than 224, and the difference between the brightness values of the pixels in the area and the brightness values of the pixels in the adjacent area is greater than 32, the terminal can determine that the area is a light area. The adjacent area of the light area can be composed of pixels adjacent to the pixels in the light area, that is, the pixels in the adjacent area of the light area are adjacent to the pixels in the light area.

示例性地,终端可以确定所述多个图像中的每个图像中目标像素的个数,所述目标像素是指灯光区域内的像素。然后,终端获取每个图像中目标像素的个数与图像的像素总个数的比值,并判断该比值是否在预设范围内。如果图像中目标像素的个数与图像的像素总个数的比值在预设范围内,则终端确定该图像中存在局部灯光区域;如果图像中目标像素的个数与图像的像素总个数的比值不在预设范围内,则终端确定该图像中不存在局部灯光区域。Exemplarily, the terminal may determine the number of target pixels in each of the multiple images, where the target pixels refer to pixels in the light area. Then, the terminal obtains the ratio of the number of target pixels in each image to the total number of pixels in the image, and determines whether the ratio is within a preset range. If the ratio of the number of target pixels in the image to the total number of pixels in the image is within the preset range, the terminal determines that there is a local light area in the image; if the ratio of the number of target pixels in the image to the total number of pixels in the image is not within the preset range, the terminal determines that there is no local light area in the image.

也就是说,被确定为震颤图像的第一图像的抖动值大于或等于第二预设阈值,且所述第一图像中目标像素的个数与像素总个数的比值在预设范围内,所述目标像素为灯光区域的像素。That is, the jitter value of the first image determined as a trembling image is greater than or equal to a second preset threshold, and the ratio of the number of target pixels to the total number of pixels in the first image is within a preset range, and the target pixels are pixels in the light area.

示例性地,以图像的颜色空间的格式为YUV格式为例,图像中的像素的Y值即为像素的亮度值。在图像中,像素的Y值的取值范围0-255,Y值越大,则像素的亮度值越大。假设上述的特定阈值为224,预先设定的差值为32,预设范围为2%-20%。那么,终端可以先确定图像中目标像素的个数,然后终端确定目标像素与图像的像素总个数的比值。其中,目标像素的Y值大于或等于240,且目标像素的亮度值与灯光区域的邻近区域的像素的亮度值的差异值大于或等于32。如果目标像素与图像的像素总个数的比值在2%-20%之内,则确定该图像存在局部灯光区域。可以理解的是,上述的阈值、差值以及预设范围可以根据实际需要进行调整,本实施例并不对阈值、差值以及预设范围的具体取值进行限定。Exemplarily, taking the YUV format as an example, the Y value of a pixel in the image is the brightness value of the pixel. In the image, the Y value of a pixel ranges from 0 to 255, and the larger the Y value, the larger the brightness value of the pixel. Assume that the above-mentioned specific threshold is 224, the preset difference is 32, and the preset range is 2%-20%. Then, the terminal can first determine the number of target pixels in the image, and then the terminal determines the ratio of the target pixel to the total number of pixels in the image. Among them, the Y value of the target pixel is greater than or equal to 240, and the difference between the brightness value of the target pixel and the brightness value of the pixel in the adjacent area of the light area is greater than or equal to 32. If the ratio of the target pixel to the total number of pixels in the image is within 2%-20%, it is determined that the image has a local light area. It can be understood that the above-mentioned threshold, difference and preset range can be adjusted according to actual needs, and this embodiment does not limit the specific values of the threshold, difference and preset range.

步骤303,根据所述第一图像在所述多个图像中确定第二图像和第三图像。Step 303: Determine a second image and a third image from the multiple images according to the first image.

在本实施例中,所述第一图像的采集时刻位于所述第二图像的采集时刻与所述第三图像的采集时刻之间。也就是说,在终端获取的所述多个图像中,所述第一图像并非是所述多个图像中的第一个图像,所述第一图像也不是所述多个图像中的最后一个图像。其中,所述多个图像是按采集时刻的先后顺序排列的,所述多个图像中的第一个图像是指所述多个图像中最早采集的图像,所述多个图像中的最后一个图像是指所述多个图像中最晚采集的图像。In this embodiment, the acquisition time of the first image is between the acquisition time of the second image and the acquisition time of the third image. That is, among the multiple images acquired by the terminal, the first image is not the first image among the multiple images, and the first image is not the last image among the multiple images. Among them, the multiple images are arranged in the order of acquisition time, the first image among the multiple images refers to the earliest acquired image among the multiple images, and the last image among the multiple images refers to the latest acquired image among the multiple images.

此外,在所述第二图像和所述第三图像中,至少有一个图像的抖动值小于所述第一图像的抖动值。由于所述第二图像和所述第三图像是用于作为参考图像来生成替换第一图像的目标图像,因此需要保证所述第二图像和所述第三图像的图像质量,以便于能够生成灯光区域正常显示的目标图像。In addition, the jitter value of at least one of the second image and the third image is smaller than the jitter value of the first image. Since the second image and the third image are used as reference images to generate a target image that replaces the first image, the image quality of the second image and the third image needs to be guaranteed so as to generate a target image in which the light area is normally displayed.

在一种可能的实现方式中,终端可以是以所述第一图像为中心,在位于第一图像前后的N个图像中确定第二图像和第三图像。示例性地,终端可以在前述的多个图像中获取采集时刻位于第一图像之前的k个图像以及采集时刻位于第一图像之后的k个图像,并且在获取到的2k个图像中确定第二图像和第三图像。其中,k为大于或等于1的整数,例如k可以为1、2或3。由于所述第一图像的采集时刻位于所述第二图像的采集时刻与所述第三图像的采集时刻之间,因此,终端可以是在采集时刻位于第一图像之前的k个图像中确定第二图像,然后在采集时刻位于第一图像之后的k个图像确定第三图像。或者,终端可以是在采集时刻位于第一图像之前的k个图像中确定第三图像,然后在采集时刻位于第一图像之后的k个图像确定第二图像。In a possible implementation, the terminal may be centered on the first image and determine the second image and the third image from N images located before and after the first image. Exemplarily, the terminal may obtain k images located before the first image at the acquisition time and k images located after the first image at the acquisition time from the aforementioned multiple images, and determine the second image and the third image from the acquired 2k images. Wherein, k is an integer greater than or equal to 1, for example, k may be 1, 2 or 3. Since the acquisition time of the first image is between the acquisition time of the second image and the acquisition time of the third image, the terminal may determine the second image from the k images located before the first image at the acquisition time, and then determine the third image from the k images located after the first image at the acquisition time. Alternatively, the terminal may determine the third image from the k images located before the first image at the acquisition time, and then determine the second image from the k images located after the first image at the acquisition time.

例如,假设第一图像为图像t,则终端可以获取图像t-k至图像t-1以及图像t+1至图像t+k,并且在图像t-k至图像t-1以及图像t+1至图像t+k中确定第二图像和第三图像。然后,终端可以在图像t-k至图像t-1中确定第二图像,并在图像t+1至图像t+k中确定第三图像。或者,终端可以在图像t-k至图像t-1中确定第三图像,并在图像t+1至图像t+k中确定第二图像。For example, assuming that the first image is image t, the terminal can obtain images t-k to image t-1 and images t+1 to image t+k, and determine the second image and the third image in images t-k to image t-1 and images t+1 to image t+k. Then, the terminal can determine the second image in images t-k to image t-1, and determine the third image in images t+1 to image t+k. Alternatively, the terminal can determine the third image in images t-k to image t-1, and determine the second image in images t+1 to image t+k.

可选的,为了尽可能地生成更高质量的目标图像,终端可以在多个图像中选择对生成高质量目标图像的稳定值更大的图像作为第二图像和第三图像。Optionally, in order to generate a target image with higher quality as much as possible, the terminal may select images with greater stability values for generating a high-quality target image from multiple images as the second image and the third image.

示例性地,终端分别确定所述多个图像中每个图像的稳定值,所述稳定值为所述图像的抖动值与所述图像和所述第一图像之间的采集时间差之和的倒数。其中,图像的稳定值与该图像的抖动值以及该图像与第一图像之间的采集时间差呈负相关的关系。也就是说,图像的抖动值越大,则该图像的稳定值越小;图像与第一图像之间的采集时间差越大,则该图像的稳定值越小。简单来说,终端需要尽可能地选择抖动值小且靠近第一图像的图像作为第二图像和第三图像。Exemplarily, the terminal determines the stability value of each of the multiple images respectively, and the stability value is the inverse of the sum of the jitter value of the image and the acquisition time difference between the image and the first image. Among them, the stability value of the image is negatively correlated with the jitter value of the image and the acquisition time difference between the image and the first image. In other words, the larger the jitter value of the image, the smaller the stability value of the image; the larger the acquisition time difference between the image and the first image, the smaller the stability value of the image. In short, the terminal needs to select images with small jitter values and close to the first image as the second image and the third image as much as possible.

然后,终端确定所述多个图像中稳定值最大的图像为所述第二图像,并根据所述第二图像的采集时刻,在所述多个图像中确定所述第三图像,以使得所述第一图像的采集时刻位于所述第二图像的采集时刻与所述第三图像的采集时刻之间。具体地,终端可以根据所述第二图像的采集时刻,在所述多个图像中确定一个或多个图像,所述第一图像的采集时刻位于所述第二图像的采集时刻与所述一个或多个图像的采集时刻之间;然后,终端在所述一个或多个图像中确定稳定值最大的图像为所述第三图像。基于上述的方式所确定的第二图像的稳定值大于第三图像,因此第二图像可以认为是用于生成目标图像的主参考图像,第三图像则可以认为是用于生成目标图像的次参考图像。Then, the terminal determines that the image with the largest stability value among the multiple images is the second image, and determines the third image among the multiple images according to the acquisition time of the second image, so that the acquisition time of the first image is between the acquisition time of the second image and the acquisition time of the third image. Specifically, the terminal can determine one or more images among the multiple images according to the acquisition time of the second image, and the acquisition time of the first image is between the acquisition time of the second image and the acquisition time of the one or more images; then, the terminal determines that the image with the largest stability value among the one or more images is the third image. Based on the stability value of the second image determined in the above manner is greater than that of the third image, so the second image can be considered as the main reference image for generating the target image, and the third image can be considered as the secondary reference image for generating the target image.

此外,终端也可以是分别确定位于第一图像前后的N个图像中每个图像的稳定值,并确定所述N个图像中稳定值最大的图像为所述第二图像。也就是说,终端以第一图像为中心,确定特定范围内的图像的稳定值,并将稳定值最大的图像确定为第二图像。最后,再基于第二图像确定第三图像。In addition, the terminal may also determine the stability value of each of the N images located before and after the first image, and determine the image with the largest stability value among the N images as the second image. That is, the terminal determines the stability values of images within a specific range with the first image as the center, and determines the image with the largest stability value as the second image. Finally, the third image is determined based on the second image.

例如,假设第一图像为图像t,终端在图像t-k至图像t-1以及图像t+1至图像t+k中确定第二图像和第三图像。此外,假设图像t-k至图像t-1以及图像t+1至图像t+k中的任意一个图像p的稳定值为H,图像p的抖动值为pd。那么,稳定值H具体为:H=1/(pd+100*|p-t|)。可以看出,图像p的抖动值越大,则该图像p的稳定值越小;图像p与第一图像之间的采集时间差越大,则该图像p的稳定值越小。For example, assuming that the first image is image t, the terminal determines the second image and the third image from images tk to image t-1 and images t+1 to image t+k. In addition, assuming that the stability value of any image p from images tk to image t-1 and images t+1 to image t+k is H, and the jitter value of image p is p d . Then, the stability value H is specifically: H = 1/(p d +100*|pt|). It can be seen that the larger the jitter value of image p, the smaller the stability value of image p; the larger the acquisition time difference between image p and the first image, the smaller the stability value of image p.

这样,终端可以分别计算图像t-k至图像t-1以及图像t+1至图像t+k的稳定值H,并且在图像t-k至图像t-1以及图像t+1至图像t+k中选取稳定值H最大的一个图像作为第二图像。如果第二图像是图像t-k至图像t-1中的一个图像,则终端继续在图像t+1至图像t+k中选取稳定值H最大的一个图像作为第三图像。如果第二图像是图像t+1至图像t+k中的一个图像,则终端继续在图像t-k至图像t-1中选取稳定值H最大的一个图像作为第三图像。In this way, the terminal can calculate the stability values H of images t-k to t-1 and images t+1 to t+k respectively, and select an image with the largest stability value H from images t-k to t-1 and images t+1 to t+k as the second image. If the second image is one of images t-k to t-1, the terminal continues to select an image with the largest stability value H from images t+1 to t+k as the third image. If the second image is one of images t+1 to t+k, the terminal continues to select an image with the largest stability value H from images t-k to t-1 as the third image.

步骤304,根据所述第一图像、所述第二图像和所述第三图像生成目标图像。Step 304: Generate a target image according to the first image, the second image and the third image.

本实施例中,所述目标图像用于替换所述第一图像。终端在生成所述目标图像后,可以将所述多个图像中的所述第一图像替换为所述目标图像,得到新的多个图像,并输出所述新的多个图像。In this embodiment, the target image is used to replace the first image. After generating the target image, the terminal may replace the first image in the multiple images with the target image to obtain a new multiple images, and output the new multiple images.

其中,所述第一图像和所述第三图像用于确定所述第二图像中的图像块对应的运动矢量,所述运动矢量用于表示所述第三图像中的图像块与所述第二图像中的图像块之间的相对位移,所述目标图像是基于所述第二图像中的图像块以及所述运动矢量得到的。Among them, the first image and the third image are used to determine the motion vector corresponding to the image block in the second image, the motion vector is used to represent the relative displacement between the image block in the third image and the image block in the second image, and the target image is obtained based on the image block in the second image and the motion vector.

具体地,终端可以将所述第二图像划分为多个图像块,并根据所述第一图像和所述第三图像确定所述多个图像块分别对应的运动矢量,以使得所述多个图像块中的每个图像块基于该图像块对应的运动矢量都能够在第一图像和第三图像中找到匹配的图像块。也就是说,对于第二图像中的每个图像块来说,基于该图像块的运动矢量能够在第一图像和第三图像找到对应的图像块,且第一图像和第三图像中对应的图像块均与该第二图像中的图像块匹配。即,第一图像中对应的图像块与第二图像中的图像块相似,且第三图像中对应的图像块也与该第二图像中的图像块相似。最后,终端根据所述多个图像块分别对应的运动矢量以及所述多个图像块,生成所述目标图像。Specifically, the terminal may divide the second image into a plurality of image blocks, and determine the motion vectors corresponding to the plurality of image blocks respectively according to the first image and the third image, so that each of the plurality of image blocks can find a matching image block in the first image and the third image based on the motion vector corresponding to the image block. That is, for each image block in the second image, the corresponding image block can be found in the first image and the third image based on the motion vector of the image block, and the corresponding image blocks in the first image and the third image are matched with the image block in the second image. That is, the corresponding image block in the first image is similar to the image block in the second image, and the corresponding image block in the third image is also similar to the image block in the second image. Finally, the terminal generates the target image according to the motion vectors corresponding to the plurality of image blocks respectively and the plurality of image blocks.

本实施例中,通过确定视频中的图像的抖动值,来定位视频中的震颤图像。然后,将震颤图像前后的图像作为参考图像,并基于震颤图像以及参考图像来求取参考图像中的图像块之间的相对位移。最终,基于参考图像中的图像块以及图像块对应的相对位移来生成用于替换震颤图像的目标图像。通过本方案,能够将视频中的震颤图像替换为正常显示的图像,从而解决由镜头抖动所引起的视频画面中的灯光区域不正常外扩的问题。In this embodiment, the shaking image in the video is located by determining the shaking value of the image in the video. Then, the images before and after the shaking image are used as reference images, and the relative displacement between the image blocks in the reference image is obtained based on the shaking image and the reference image. Finally, a target image for replacing the shaking image is generated based on the image blocks in the reference image and the relative displacement corresponding to the image blocks. Through this solution, the shaking image in the video can be replaced with a normally displayed image, thereby solving the problem of abnormal expansion of the light area in the video screen caused by lens shaking.

为了便于理解以上所述的终端确定第二图像中的图像块对应的运动矢量的过程,以下先简单介绍相关技术中的运动估计与运动补偿(Motion Estimate and MotionCompensation,MEMC)方法。In order to facilitate understanding of the above-mentioned process of the terminal determining the motion vector corresponding to the image block in the second image, the motion estimation and motion compensation (MEMC) method in the related art is briefly introduced below.

MEMC方法是目前一种用于防抖动或帧率转换的技术,MEMC方法通过估算图像中连续运动的物体的运动轨迹,得到图像中的多个图像块的运动矢量。然后,再结合图像块和得到的运动矢量,插值得到中间图像,从而提高视频帧率或改善视频播放时的抖动拖尾等问题。The MEMC method is a technology currently used for anti-shake or frame rate conversion. The MEMC method estimates the motion trajectory of continuously moving objects in the image and obtains the motion vectors of multiple image blocks in the image. Then, the image blocks and the obtained motion vectors are combined to interpolate the intermediate image, thereby increasing the video frame rate or improving the jitter and tailing problems during video playback.

可以参阅图4,图4为本申请实施例提供的一种MEMC方法的示意图。如图4所示,图像1和图像2为连续的两个图像,图像1为先采集的图像,图像2为后采集的图像,图像3则是基于图像1和图像2插值得到的图像。Please refer to Figure 4, which is a schematic diagram of a MEMC method provided in an embodiment of the present application. As shown in Figure 4, Image 1 and Image 2 are two consecutive images, Image 1 is the image collected first, Image 2 is the image collected later, and Image 3 is an image obtained by interpolation based on Image 1 and Image 2.

在终端执行MEMC的过程中,终端对图像1和图像2分别执行分块操作,得到图像1中的多个图像块以及图像2中的多个图像块,每个图像块的大小一般为8*8个像素或者16*16个像素。对于图像1中的每个图像块,终端在图像2中查找与图像1中的图像块最为相似的图像块,即查找图像2中与图像1中的图像块匹配的图像块。例如,如图4所示,图像2中的图像块B与图像1中的图像块A最为相似,因此可以确定图像块B与图像块A匹配。基于图像块B与图像块A,可以确定图像块A对应的运动矢量,该运动矢量即为图像块B与图像块A之间的相对位移。也就是说,图像块A基于该运动矢量进行移动后,图像块A即可移动至图像块B所在的位置。这样一来,在确定了图像1中的每个图像块在图像2中匹配的图像块之后,即可得到图像1中的每个图像块对应的运动矢量。以上求取图像块对应的运动矢量的过程即为MEMC方法中的运动估计部分。During the process of executing MEMC in the terminal, the terminal performs block operations on image 1 and image 2 respectively, and obtains multiple image blocks in image 1 and multiple image blocks in image 2, and the size of each image block is generally 8*8 pixels or 16*16 pixels. For each image block in image 1, the terminal searches for the image block in image 2 that is most similar to the image block in image 1, that is, searches for the image block in image 2 that matches the image block in image 1. For example, as shown in FIG4, image block B in image 2 is most similar to image block A in image 1, so it can be determined that image block B matches image block A. Based on image block B and image block A, the motion vector corresponding to image block A can be determined, and the motion vector is the relative displacement between image block B and image block A. In other words, after image block A moves based on the motion vector, image block A can move to the position where image block B is located. In this way, after determining the image block that matches each image block in image 1 in image 2, the motion vector corresponding to each image block in image 1 can be obtained. The above process of obtaining the motion vector corresponding to the image block is the motion estimation part in the MEMC method.

在得到图像1中的每个图像块对应的运动矢量之后,终端则可以基于每个图像块对应的运动矢量,将图像1中的每个图像块按照对应的运动矢量的一半进行移动,最终得到图像3。例如,如图4所示,图像1中的图像块A按照运动矢量的一半进行移动后,图像块移动至图像3中的位置P,位置P实际上位于图像块A所在位置以及图像块B所在位置的中间。以上基于运动矢量生成图像的过程即为MEMC方法中的运动补偿部分。After obtaining the motion vector corresponding to each image block in image 1, the terminal can move each image block in image 1 according to half of the corresponding motion vector based on the motion vector corresponding to each image block, and finally obtain image 3. For example, as shown in Figure 4, after image block A in image 1 is moved according to half of the motion vector, the image block moves to position P in image 3, and position P is actually located in the middle of the position of image block A and the position of image block B. The above process of generating images based on motion vectors is the motion compensation part in the MEMC method.

然而,上述的MEMC方法也有不足之处。由于MEMC方法中是基于最为相似的原则来查找匹配的图像块,因此当查找的图像中存在多个相似度接近的图像块时,则容易得到错误的运动矢量,从而导致最终生成的图像中出现明显的错误。However, the above-mentioned MEMC method also has its shortcomings. Since the MEMC method searches for matching image blocks based on the most similar principle, when there are multiple image blocks with close similarity in the searched image, it is easy to obtain an erroneous motion vector, which leads to obvious errors in the final generated image.

可以参阅图5,图5为本申请实施例提供的一种MEMC方法的另一示意图。如图5所示,假设图像2中还包括图像块B’,且图像块B’与图像块A相似。也就是说,对于图像块A而言,图像2中的图像块B以及图像块B’均与图像块A相似。在这种情况下,在基于图像块A对应的运动矢量生成图像3时,图像块A有可能被移动至图像3中的位置P或者位置P’。假设实际上图像2中与图像块A匹配的图像块为图像块B,那么图像块A最终出现位置P’时,则导致图像3中出现明显的错误。Please refer to Figure 5, which is another schematic diagram of a MEMC method provided in an embodiment of the present application. As shown in Figure 5, it is assumed that image 2 also includes image block B', and image block B' is similar to image block A. That is to say, for image block A, image block B and image block B' in image 2 are similar to image block A. In this case, when image 3 is generated based on the motion vector corresponding to image block A, image block A may be moved to position P or position P' in image 3. Assuming that the image block that actually matches image block A in image 2 is image block B, then when image block A finally appears in position P', it will cause obvious errors in image 3.

有鉴于此,本申请实施例在相关技术的MEMC方法的基础上,还引入了原图像,基于原图像来进一步确定图像块的运动矢量,从而保证生成的目标图像的质量。In view of this, the embodiment of the present application introduces an original image based on the MEMC method of the related art, and further determines the motion vector of the image block based on the original image, thereby ensuring the quality of the generated target image.

具体来说,在本实施例中,终端在求取第二图像中的图像块对应的运动矢量的过程中,终端是基于第三图像和第一图像来共同确定第二图像中的图像块对应的运动矢量,以使得第二图像中的每个图像块基于该图像块对应的运动矢量都能够在第一图像和第三图像中找到匹配的图像块。这样一来,终端则可以确保得到的运动矢量是准确的。Specifically, in this embodiment, in the process of obtaining the motion vector corresponding to the image block in the second image, the terminal jointly determines the motion vector corresponding to the image block in the second image based on the third image and the first image, so that each image block in the second image can find a matching image block in the first image and the third image based on the motion vector corresponding to the image block. In this way, the terminal can ensure that the obtained motion vector is accurate.

以图5为例,在确定图像2中的图像块B以及图像块B’均与图像块A相似的情况下,基于图像块B以及图像块B’确定位于图像1和图像2之间的原图像上的位置P和位置P’。然后,获取原图像中位于位置P的图像块P以及位于位置P’的图像块P’,再求取图像块A与图像块P以及图像块P’之间的相似度。最终,结合图像块A与图像块B和图像块B’之间的相似度,以及图像块A与图像块P和图像块P’之间的相似度,确定图像A的运动矢量。这样一来,基于最终求得的运动矢量移动图像块A,能够使得图像块A被移动至正确的位置P上。Taking Figure 5 as an example, when it is determined that image block B and image block B' in image 2 are similar to image block A, position P and position P' on the original image between image 1 and image 2 are determined based on image block B and image block B'. Then, image block P at position P and image block P' at position P' in the original image are obtained, and the similarity between image block A and image block P and image block P' is calculated. Finally, the motion vector of image A is determined by combining the similarity between image block A and image block B and image block B', as well as the similarity between image block A and image block P and image block P'. In this way, moving image block A based on the final motion vector can move image block A to the correct position P.

为便于理解,以下将详细介绍本实施例中终端根据第一图像和第三图像确定第二图像中的多个图像块分别对应的运动矢量的过程。For ease of understanding, the process in which the terminal determines motion vectors corresponding to multiple image blocks in the second image respectively according to the first image and the third image in this embodiment will be described in detail below.

在一种可能的实现方式中,对于第二图像中的多个图像块,终端逐个求取所述多个图像块中的每一个图像块对应的运动矢量。以下将以终端求取所述多个图像块中的一个图像块对应的运动矢量的过程为例,说明终端如何确定第二图像中的多个图像块分别对应的运动矢量。In a possible implementation, for multiple image blocks in the second image, the terminal obtains the motion vector corresponding to each of the multiple image blocks one by one. The following takes the process of the terminal obtaining the motion vector corresponding to one of the multiple image blocks as an example to illustrate how the terminal determines the motion vectors corresponding to the multiple image blocks in the second image.

首先,终端获取第一图像块对应的多个候选运动矢量。其中,所述第二图像中的多个图像块包括所述第一图像块,所述第一图像块可以为所述多个图像块中的任意一个图像块。可选的,所述多个候选运动矢量包括:一个或多个预设运动矢量、随机生成的一个或多个运动矢量和/或与所述第一图像块相邻的图像块对应的运动矢量。First, the terminal obtains multiple candidate motion vectors corresponding to the first image block. The multiple image blocks in the second image include the first image block, and the first image block can be any one of the multiple image blocks. Optionally, the multiple candidate motion vectors include: one or more preset motion vectors, one or more randomly generated motion vectors and/or motion vectors corresponding to image blocks adjacent to the first image block.

可以理解的是,由于第二图像与第三图像是采集时刻相近的两个图像,因此第二图像中的物体相对于第三图像的位移较小,从而可以认为第二图像中的图像块对应的运动矢量是在预设范围内的。这样一来,终端可以获取一个或多个预设运动矢量,并将这些预设运动矢量作为候选运动矢量。简单来说,假设第二图像中的物体在第二图像与第三图像的采集间隙发生了位移,但是由于第二图像与第三图像之间的采集时刻很相近,因此可以认为第二图像中的物体所发生的位移量是在一定范围内的。例如,预设运动矢量可以包括(0,-1)、(-1,0)、(-1,-1)、(-1,1)、(1,-1)、(0,0)、(0,1)、(1,0)以及(1,1),即认为第二图像中的图像块发生的位移量在1个像素以内。It can be understood that, since the second image and the third image are two images captured at similar times, the displacement of the object in the second image relative to the third image is small, so that it can be considered that the motion vector corresponding to the image block in the second image is within a preset range. In this way, the terminal can obtain one or more preset motion vectors and use these preset motion vectors as candidate motion vectors. In simple terms, it is assumed that the object in the second image is displaced during the acquisition gap between the second image and the third image, but since the acquisition time between the second image and the third image is very close, it can be considered that the displacement of the object in the second image is within a certain range. For example, the preset motion vectors may include (0, -1), (-1, 0), (-1, -1), (-1, 1), (1, -1), (0, 0), (0, 1), (1, 0) and (1, 1), that is, it is considered that the displacement of the image block in the second image is within 1 pixel.

此外,为了尽可能地保证能够获取到第一图像块实际对应的运动矢量,还可以随机生成一个或多个运动矢量或者选取第一图像块相邻的图像块对应的运动矢量来作为候选运动矢量,从而避免候选运动矢量的取值范围过于局限。由于第一图像块与第一图像块相邻的图像块有较大几率是表示同一个物体的不同部分,因此第一图像块与第一图像块相邻的图像块所对应的运动矢量很有可能是相同的。因此,选取第一图像块相邻的图像块对应的运动矢量来作为候选运动矢量,则能够保证候选运动矢量的全面性。示例性地,在终端是按照从左到右以及从上到下的顺序来求取图像块对应的运动矢量的情况下,那么与第一图像块相邻的图像块则为位于第一图像块的左上方、上方、右上方以及左方的四个图像块。在终端是按照其他的顺序来求取图像块对应的运动矢量的情况下,那么与第一图像块相邻的图像块则可以为位于第一图像块的其他方位的图像块,本实施例并不对与第一图像块相邻的图像块所在的位置做具体限定。In addition, in order to ensure that the motion vector actually corresponding to the first image block can be obtained as much as possible, one or more motion vectors can be randomly generated or the motion vector corresponding to the image block adjacent to the first image block can be selected as the candidate motion vector, so as to avoid the value range of the candidate motion vector being too limited. Since the first image block and the image block adjacent to the first image block have a greater probability of representing different parts of the same object, the motion vectors corresponding to the first image block and the image block adjacent to the first image block are likely to be the same. Therefore, selecting the motion vector corresponding to the image block adjacent to the first image block as the candidate motion vector can ensure the comprehensiveness of the candidate motion vector. Exemplarily, when the terminal obtains the motion vector corresponding to the image block in the order from left to right and from top to bottom, the image blocks adjacent to the first image block are the four image blocks located at the upper left, upper, upper right and left of the first image block. When the terminal obtains the motion vector corresponding to the image block in other orders, the image block adjacent to the first image block can be an image block located in other positions of the first image block. This embodiment does not specifically limit the position of the image block adjacent to the first image block.

在获取得到多个候选运动矢量后,终端可以根据所述第一图像块的位置,确定所述多个候选运动矢量中每个候选运动矢量对应的第二图像块和第三图像块,所述第一图像包括所述第二图像块,所述第三图像包括所述第三图像块。由于候选运动矢量是表示第三图像中的图像块与第二图像中的图像块之间的相对位移,因此终端可以基于第一图像块在第二图像中的位置以及候选运动矢量确定第一图像中的第二图像块以及第三图像中的第三图像块。示例性地,可以参阅图6,图6为本申请实施例提供的一种基于候选运动矢量确定图像块的示意图。如图6所示,假设第二图像为第一图像的前一个图像,第三图像为第一图像的后一个图像,第二图像中的第一图像块所在的位置的坐标为(0,0),第一图像块对应的候选运动矢量为(2,-2)。那么,基于第一图像块对应的候选运动矢量,可以求得第三图像中的第三图像块所在位置的坐标为(2,-2),第一图像中的第二图像块所在位置的坐标为(1,-1)。After obtaining multiple candidate motion vectors, the terminal can determine the second image block and the third image block corresponding to each candidate motion vector in the multiple candidate motion vectors according to the position of the first image block, the first image includes the second image block, and the third image includes the third image block. Since the candidate motion vector represents the relative displacement between the image block in the third image and the image block in the second image, the terminal can determine the second image block in the first image and the third image block in the third image based on the position of the first image block in the second image and the candidate motion vector. Exemplarily, please refer to Figure 6, which is a schematic diagram of determining an image block based on a candidate motion vector provided in an embodiment of the present application. As shown in Figure 6, assuming that the second image is the previous image of the first image, the third image is the next image of the first image, the coordinates of the position of the first image block in the second image are (0,0), and the candidate motion vector corresponding to the first image block is (2,-2). Then, based on the candidate motion vector corresponding to the first image block, the coordinates of the position of the third image block in the third image can be obtained as (2,-2), and the coordinates of the position of the second image block in the first image are (1,-1).

其次,终端根据所述第一图像块、所述第二图像块和所述第三图像块,确定所述每个候选运动矢量对应的目标误差值,所述目标误差值是基于所述第一图像块与所述第二图像块之间的误差值以及所述第一图像块与所述第三图像块之间的误差值得到的。其中,两个图像块之间的误差值表示两个图像块之间的差异,误差值越大,则两个图像块之间的差异越大。例如,在基于候选运动矢量确定第一图像块对应的第二图像块和第三图像块之后,终端可以基于绝对误差和(Sum of Absolute Difference,SAD)算法求取第一图像块与第二图像块之间的误差值以及第一图像块与第三图像块之间的误差值。然后,终端再基于第一图像块与第二图像块之间的误差值以及第一图像块与第三图像块之间的误差值确定目标误差值。例如将第一图像块与第二图像块之间的误差值以及第一图像块与第三图像块之间的误差值相加,以得到目标误差值。Secondly, the terminal determines the target error value corresponding to each candidate motion vector according to the first image block, the second image block and the third image block, and the target error value is obtained based on the error value between the first image block and the second image block and the error value between the first image block and the third image block. Among them, the error value between the two image blocks represents the difference between the two image blocks, and the larger the error value, the larger the difference between the two image blocks. For example, after determining the second image block and the third image block corresponding to the first image block based on the candidate motion vector, the terminal can obtain the error value between the first image block and the second image block and the error value between the first image block and the third image block based on the Sum of Absolute Difference (SAD) algorithm. Then, the terminal determines the target error value based on the error value between the first image block and the second image block and the error value between the first image block and the third image block. For example, the error value between the first image block and the second image block and the error value between the first image block and the third image block are added to obtain the target error value.

最后,终端根据所述每个候选运动矢量对应的目标误差值,在所述多个候选运动矢量中确定目标误差值最小的运动矢量为所述第一图像块对应的运动矢量。Finally, the terminal determines, according to the target error value corresponding to each candidate motion vector, a motion vector with the smallest target error value among the multiple candidate motion vectors as the motion vector corresponding to the first image block.

以上为终端求取第二图像中的第一图像块的运动矢量的过程,在实际应用中,终端可以基于以上的流程求取第二图像中的每个图像块对应的运动矢量,最终得到第二图像中的多个图像块对应的运动矢量。The above is the process of the terminal obtaining the motion vector of the first image block in the second image. In actual applications, the terminal can obtain the motion vector corresponding to each image block in the second image based on the above process, and finally obtain the motion vectors corresponding to multiple image blocks in the second image.

在实际应用中,由于第二图像中包括大量的图像块,而第二图像中的部分图像块可能会由于无法在第三图像中找到匹配的图像块,而无法确定对应的运动矢量。又或者,第二图像中的部分图像块基于对应的运动矢量进行移动后,可能会移动到相同的位置上。这样一来,在基于第二图像中的多个图像块生成目标图像的过程中,所生成的目标图像中可能会存在无法基于所述多个图像块生成图像的区域。这些无法生成图像的区域则可以称为空洞区域。In practical applications, since the second image includes a large number of image blocks, some of the image blocks in the second image may not be able to determine the corresponding motion vectors because they cannot find matching image blocks in the third image. Alternatively, some of the image blocks in the second image may move to the same position after being moved based on the corresponding motion vectors. In this way, in the process of generating a target image based on multiple image blocks in the second image, there may be areas in the generated target image where images cannot be generated based on the multiple image blocks. These areas where images cannot be generated can be called hole areas.

示例性地,可以参阅图7,图7为本申请实施例提供的一种生成目标图像的示意图。如图7所示,第二图像中位置(1,1)的图像块显示的是一个人物,第二图像中位置(2,1)的图像块显示的是一个路障,第二图像中位置(3,1)的图像块显示的是一个箱子。第一图像中位置(1,1)的图像块显示的是一个消防栓,第一图像中位置(2,1)的图像块显示的是一个人物,第一图像中位置(3,1)的图像块显示的是一个箱子。第三图像中位置(1,1)的图像块显示的是一个消防栓,第三图像中位置(2,1)的图像块显示的是一个路障,第二图像中位置(3,1)的图像块显示的是一个人物。Exemplarily, please refer to Figure 7, which is a schematic diagram of generating a target image provided by an embodiment of the present application. As shown in Figure 7, the image block at position (1, 1) in the second image shows a person, the image block at position (2, 1) in the second image shows a roadblock, and the image block at position (3, 1) in the second image shows a box. The image block at position (1, 1) in the first image shows a fire hydrant, the image block at position (2, 1) in the first image shows a person, and the image block at position (3, 1) in the first image shows a box. The image block at position (1, 1) in the third image shows a fire hydrant, the image block at position (2, 1) in the third image shows a roadblock, and the image block at position (3, 1) in the second image shows a person.

在图7中,基于第一图像和第三图像求取第二图像中的图像块所对应的运动矢量时,第二图像中位置(1,1)的图像块1对应的运动矢量为(2,0),第二图像中位置(2,1)的图像块2对应的运动矢量为(0,0),第二图像中位置(3,1)的图像块3对应的运动矢量为(0,0)。基于上述求取到的运动矢量,第二图像中的图像块1移动到了目标图像中的位置(2,1),图像块2也移动到目标图像中的位置(2,1),图像块3移动到目标图像中的位置(3,1)。最终,目标图像中的位置(1,1)没有能够显示的图像,即位置(1,1)为空洞区域。In FIG7 , when the motion vectors corresponding to the image blocks in the second image are obtained based on the first image and the third image, the motion vector corresponding to the image block 1 at position (1, 1) in the second image is (2, 0), the motion vector corresponding to the image block 2 at position (2, 1) in the second image is (0, 0), and the motion vector corresponding to the image block 3 at position (3, 1) in the second image is (0, 0). Based on the motion vectors obtained above, the image block 1 in the second image moves to position (2, 1) in the target image, the image block 2 also moves to position (2, 1) in the target image, and the image block 3 moves to position (3, 1) in the target image. Finally, there is no image that can be displayed at position (1, 1) in the target image, that is, position (1, 1) is a hole area.

本实施例中,在求得第二图像中的多个图像块对应的运动矢量后,终端可以基于每个图像块对应的运动矢量确定该图像块在目标图像中对应的位置。如果第二图像中不同的图像块在目标图像中具有相同的位置,则终端需要在这多个不同的图像块中确定一个显示于目标图像上的图像块。例如,在图7中,第二图像中的图像块1和图像块2都需要移动至目标图像中的位置(2,1),即图像块1和图像块2在目标图像中对应的位置均为(2,1)。In this embodiment, after obtaining the motion vectors corresponding to the multiple image blocks in the second image, the terminal can determine the corresponding position of the image block in the target image based on the motion vector corresponding to each image block. If different image blocks in the second image have the same position in the target image, the terminal needs to determine an image block displayed on the target image from the multiple different image blocks. For example, in FIG7 , both image block 1 and image block 2 in the second image need to be moved to position (2, 1) in the target image, that is, the corresponding positions of image block 1 and image block 2 in the target image are both (2, 1).

具体地,终端在确定第二图像中的多个不同的图像块在目标图像中对应的位置相同后,终端分别获取该多个不同的图像块对应的运动矢量的目标误差值。由上述的实施例可知,第二图像中的每个图像块的运动矢量的目标误差值,是基于该图像块与第一图像中对应位置的图像块之间的误差值以及该图像块与第三图像中对应位置的图像块之间的误差值得到的。最后,终端在多个不同的图像块中确定目标误差值最小的一个图像块,并将这个目标误差值最小的图像块显示于目标图像上。Specifically, after the terminal determines that the corresponding positions of multiple different image blocks in the second image are the same in the target image, the terminal respectively obtains the target error values of the motion vectors corresponding to the multiple different image blocks. It can be seen from the above embodiment that the target error value of the motion vector of each image block in the second image is obtained based on the error value between the image block and the image block at the corresponding position in the first image and the error value between the image block and the image block at the corresponding position in the third image. Finally, the terminal determines an image block with the smallest target error value among the multiple different image blocks, and displays the image block with the smallest target error value on the target image.

示例性地,对于图7中的图像块1和图像块2,图像块1对应的运动矢量的目标误差值是基于图像块1与第一图像中位置为(2,1)的图像块之间的误差值以及图像块1与第三图像中位置为(3,1)的图像块得到的;图像块2对应的运动矢量的目标误差值是基于图像块2与第一图像中位置为(2,1)的图像块之间的误差值以及图像块2与第三图像中位置为(3,1)的图像块得到的。显然,图像块1对应的运动矢量的目标误差值要小于图像块2对应的运动矢量的目标误差值。因此,目标图像中位置(2,1)最终显示的第二图像中的图像块1。Exemplarily, for the image block 1 and the image block 2 in FIG. 7 , the target error value of the motion vector corresponding to the image block 1 is obtained based on the error value between the image block 1 and the image block at position (2,1) in the first image and the image block 1 and the image block at position (3,1) in the third image; the target error value of the motion vector corresponding to the image block 2 is obtained based on the error value between the image block 2 and the image block at position (2,1) in the first image and the image block 2 and the image block at position (3,1) in the third image. Obviously, the target error value of the motion vector corresponding to the image block 1 is smaller than the target error value of the motion vector corresponding to the image block 2. Therefore, the image block 1 in the second image at position (2,1) in the target image is finally displayed.

为了消除目标图像中的空洞区域,本实施例中基于第一图像和第二图像确定第三图像中的多个图像块对应的运动矢量,并根据第三图像中的多个图像块对应的运动矢量更新目标图像,最终得到更新后的目标图像。In order to eliminate the hole areas in the target image, in this embodiment, motion vectors corresponding to multiple image blocks in the third image are determined based on the first image and the second image, and the target image is updated according to the motion vectors corresponding to the multiple image blocks in the third image, and finally an updated target image is obtained.

示例性地,在终端基于第二图像的多个图像块生成目标图像之后,若所述目标图像中存在无法基于所述多个图像块生成图像的区域,则终端对所述第三图像进行划分,得到所述第三图像的多个图像块。Exemplarily, after the terminal generates a target image based on multiple image blocks of the second image, if there are areas in the target image where an image cannot be generated based on the multiple image blocks, the terminal divides the third image to obtain multiple image blocks of the third image.

然后,终端根据所述第一图像和所述第二图像确定所述第三图像的多个图像块分别对应的运动矢量。其中,终端确定所述第三图像的多个图像块分别对应的运动矢量的过程与上述终端确定第二图像的多个图像块对应的运动矢量的过程类似,具体可以参考上述实施例的描述,在此不再赘述。Then, the terminal determines the motion vectors corresponding to the multiple image blocks of the third image respectively according to the first image and the second image. The process of the terminal determining the motion vectors corresponding to the multiple image blocks of the third image respectively is similar to the process of the terminal determining the motion vectors corresponding to the multiple image blocks of the second image. For details, please refer to the description of the above embodiment, which will not be repeated here.

最后,终端根据所述第三图像的多个图像块对应的运动矢量以及所述第三图像的多个图像块,更新所述目标图像,得到新的目标图像,所述新的目标图像用于替换所述第一图像。其中,终端更新所述目标图像是指终端根据第三图像的多个图像块对应的运动矢量,将所述第三图像中的图像块移动至目标图像中的空洞区域,从而实现空洞区域的填充。对于目标图像中已经存在有图像的区域,则不再更新这些已经存在有图像的区域。Finally, the terminal updates the target image according to the motion vectors corresponding to the multiple image blocks of the third image and the multiple image blocks of the third image, and obtains a new target image, and the new target image is used to replace the first image. The terminal updates the target image means that the terminal moves the image blocks in the third image to the hole area in the target image according to the motion vectors corresponding to the multiple image blocks of the third image, thereby filling the hole area. For areas in the target image where images already exist, these areas where images already exist are no longer updated.

示例性地,可以参阅图8,图8为本申请实施例提供的另一种生成目标图像的示意图。其中,图8是在图7所示实施例的基础上,基于第三图像中的图像块对应的运动矢量对目标图像进行更新,得到更新后的目标图像。For example, please refer to Figure 8, which is a schematic diagram of another method for generating a target image provided by an embodiment of the present application. Figure 8 is based on the embodiment shown in Figure 7, and updates the target image based on the motion vector corresponding to the image block in the third image to obtain an updated target image.

在图8中,基于第一图像和第三图像求取第二图像中的图像块所对应的运动矢量时,第三图像中位置(1,1)的图像块1’对应的运动矢量为(0,0),第三图像中位置(2,1)的图像块2’对应的运动矢量为(0,0),第三图像中位置(3,1)的图像块3’对应的运动矢量为(-2,0)。In Figure 8, when the motion vector corresponding to the image block in the second image is obtained based on the first image and the third image, the motion vector corresponding to the image block 1' at the position (1, 1) in the third image is (0, 0), the motion vector corresponding to the image block 2' at the position (2, 1) in the third image is (0, 0), and the motion vector corresponding to the image block 3' at the position (3, 1) in the third image is (-2, 0).

基于上述求取到的运动矢量,第二图像中的图像块1’需要移动至目标图像中的位置(1,1),图像块2’需要移动到目标图像中的位置(2,1),图像块3’需要移动到目标图像中的位置(2,1)。由于生成的目标图像中的空洞区域的位置为(1,1),因此只需要基于运动矢量将第二图像中的图像块1’需要移动至目标图像中的位置(1,1),即可完成对目标目标图像的更新,得到更新后的目标图像。由图8可以看出,更新后的目标图像完成了对空洞区域的填充,且更新后的目标图像能够稳定显示第一图像中所包括的内容。Based on the motion vector obtained above, the image block 1' in the second image needs to be moved to the position (1, 1) in the target image, the image block 2' needs to be moved to the position (2, 1) in the target image, and the image block 3' needs to be moved to the position (2, 1) in the target image. Since the position of the hole area in the generated target image is (1, 1), it is only necessary to move the image block 1' in the second image to the position (1, 1) in the target image based on the motion vector to complete the update of the target image and obtain the updated target image. As can be seen from Figure 8, the updated target image completes the filling of the hole area, and the updated target image can stably display the content included in the first image.

为便于理解,以下将结合具体例子详细介绍本实施例的视频处理方法。For ease of understanding, the video processing method of this embodiment will be described in detail below with reference to specific examples.

可以参阅图9,图9为本申请实施例提供的一种视频处理方法的应用架构示意图。如图9所示,终端包括图像采集装置、陀螺仪、图像信号处理(Image Signal Processing,ISP)模块和显示组件。ISP模块包括震颤判断单元和解震颤单元。可选的,ISP模块还包括EIS单元。其中,图像采集装置将采集得到的多个图像传输给EIS单元,由EIS单元对所述多个图像执行防抖操作。震颤判断单元获取EIS单元输出的多个图像,并判断所述多个图像中是否存在震颤图像,最终由解震颤单元生成用于替换震颤图像的目标图像。解震颤单元将多个图像中的震颤图像替换为目标图像后,将替换目标图像后的多个图像输出至显示组件,由显示组件显示替换目标图像后的多个图像。Please refer to Figure 9, which is a schematic diagram of the application architecture of a video processing method provided in an embodiment of the present application. As shown in Figure 9, the terminal includes an image acquisition device, a gyroscope, an image signal processing (Image Signal Processing, ISP) module and a display component. The ISP module includes a tremor judgment unit and a de-tremor unit. Optionally, the ISP module also includes an EIS unit. Among them, the image acquisition device transmits the multiple images acquired to the EIS unit, and the EIS unit performs an anti-shake operation on the multiple images. The tremor judgment unit obtains the multiple images output by the EIS unit, and determines whether there is a tremor image in the multiple images, and finally the de-tremor unit generates a target image for replacing the tremor image. After the de-tremor unit replaces the tremor image in the multiple images with the target image, the multiple images after the target image is replaced are output to the display component, and the display component displays the multiple images after the target image is replaced.

可以参阅图10和图11,图10为本申请实施例提供的一种替换震颤图像的流程示意图,图11为本申请实施例提供的一种替换震颤图像的另一个流程示意图。图10所示的视频处理方法包括以下的步骤1001至步骤1006。Please refer to Figures 10 and 11, Figure 10 is a schematic diagram of a process of replacing a trembling image provided by an embodiment of the present application, and Figure 11 is another schematic diagram of a process of replacing a trembling image provided by an embodiment of the present application. The video processing method shown in Figure 10 includes the following steps 1001 to 1006.

步骤1001,获取多个图像,并判断多个图像中的图像t是否存在局部灯光区域。Step 1001, acquiring multiple images, and determining whether image t among the multiple images has a local light area.

在终端的图像采集装置采集到图像之后,震颤判断单元可以获取到多个图像,该多个图像可以是经过EIS单元执行防抖处理的。震颤判断单元逐一判断该多个图像中的图像是否为震颤图像。After the image acquisition device of the terminal acquires the image, the shake determination unit may acquire multiple images, which may be anti-shake processed by the EIS unit. The shake determination unit determines whether the images in the multiple images are shaken images one by one.

示例性地,震颤判断单元先判断多个图像中的图像t是否存在局部灯光区域。以图像的颜色空间的格式为YUV格式为例,终端可以先确定图像t中位于灯光区域的目标像素的个数,然后终端确定目标像素与图像t的像素总个数的比值。如果目标像素与图像的像素总个数的比值在2%-20%之内,则确定该图像存在局部灯光区域。在终端的具体实现过程中,终端可以设定变量total和变量light的初始值均为0。对于图像t中的每一个像素p,变量total的值加1;如果像素p位于灯光区域内,则light也加1。在图像t中的所有像素都被遍历后,计算r=light/total。如果r在2%-20%之内,则认为图像t存在局部灯光区域;如果r不在2%-20%之内,则认为图像t不存在局部灯光区域,即图像t不是震颤图像。Exemplarily, the tremor determination unit first determines whether there is a local light area in image t among the multiple images. Taking the YUV format of the color space of the image as an example, the terminal can first determine the number of target pixels in the light area in image t, and then the terminal determines the ratio of the target pixels to the total number of pixels in image t. If the ratio of the target pixels to the total number of pixels in the image is within 2%-20%, it is determined that there is a local light area in the image. In the specific implementation process of the terminal, the terminal can set the initial values of the variables total and light to be 0. For each pixel p in image t, the value of the variable total is increased by 1; if the pixel p is located in the light area, light is also increased by 1. After all pixels in image t are traversed, r=light/total is calculated. If r is within 2%-20%, it is considered that there is a local light area in image t; if r is not within 2%-20%, it is considered that there is no local light area in image t, that is, image t is not a tremor image.

步骤1002,判断图像t的抖动值是否大于或等于第二预设阈值。Step 1002: determine whether the jitter value of the image t is greater than or equal to a second preset threshold.

在确定图像t中存在局部灯光区域之后,震颤判断单元进一步判断图像t的抖动值是否大于或等于第二预设阈值,以确定图像t是否为震颤图像。其中,第二预设阈值例如可以为360。After determining that there is a local light area in the image t, the tremor determination unit further determines whether the jitter value of the image t is greater than or equal to a second preset threshold value to determine whether the image t is a tremor image. The second preset threshold value may be 360, for example.

如果图像t的抖动值大于或等于第二预设阈值,则可以确定图像t为震颤图像;如果图像t的抖动值小于第二预设阈值,则可以确定图像t不是震颤图像。If the jitter value of image t is greater than or equal to the second preset threshold, it can be determined that image t is a trembling image; if the jitter value of image t is less than the second preset threshold, it can be determined that image t is not a trembling image.

本实施例中,震颤判断单元可以获取终端中的陀螺仪所采集的陀螺仪数据,并基于陀螺仪数据来确定图像t的抖动值。In this embodiment, the shake determination unit may obtain gyroscope data collected by a gyroscope in the terminal, and determine the shake value of the image t based on the gyroscope data.

首先,根据图像t的采集时间戳信息获取对应的陀螺仪数据。如果陀螺仪数据的采样率f小于事先设定的阈值fs,则基于上采样算法对陀螺仪数据执行上采样,以使得陀螺仪数据能够大于或等于阈值fs。其中,阈值fs例如可以为1000Hz,在实际应用中也可以根据需要调整该阈值fs。用于对陀螺仪数据执行上采样的上采样算法可以采用现有的任意一种采样算法,例如三次卷积插值(cubic convolution interpolation)算法。简单来说,如果f<fs,则选取一个新的采样率f’≥fs,f’例如为f的整数倍;然后,执行上采样算法使采样率f上升至f’。First, the corresponding gyroscope data is obtained according to the acquisition timestamp information of the image t. If the sampling rate f of the gyroscope data is less than the preset threshold value fs, the gyroscope data is upsampled based on the upsampling algorithm so that the gyroscope data can be greater than or equal to the threshold value fs. Among them, the threshold value fs can be 1000Hz, for example, and the threshold value fs can also be adjusted as needed in practical applications. The upsampling algorithm used to upsample the gyroscope data can adopt any existing sampling algorithm, such as the cubic convolution interpolation algorithm. Simply put, if f<fs, a new sampling rate f'≥fs is selected, and f' is, for example, an integer multiple of f; then, the upsampling algorithm is executed to increase the sampling rate f to f'.

其中,陀螺仪数据采集的是三个维度上的角速度,以下分别以x、y、z来表示陀螺仪在不同维度上所采集到的角速度。具体地,陀螺仪数据的一个示例可以参阅表1。The gyroscope data collects angular velocities in three dimensions, and the angular velocities collected by the gyroscope in different dimensions are respectively represented by x, y, and z. Specifically, an example of gyroscope data can be found in Table 1.

表1Table 1

编号serial number 时间time xx yy zz 0(start)0(start) t0t0 -- -- -- 11 t1t1 x1x1 y1y1 z1z1 22 t2t2 x2x2 y2y2 z2z2 33 t3t3 x3x3 y3y3 z3z3 34(end)34(end) t4t4 x34x34 y34y34 z34z34

在表1中,start是指当前图像开始曝光的时间,end是指当前图像结束曝光的时间。In Table 1, start refers to the time when the current image starts to be exposed, and end refers to the time when the current image ends to be exposed.

由于x1、y1、z1等数据表示的是角速度,因此可以近似计算时间t[i]到t[i+1]的角位移是s[i]=((t[i+1]-t[i])*x[i],(t[i+1]-t[i])*y[i],(t[i+1]-t[i])*z[i])。这个公式包括t33到t34的角位移。特殊地,t0到t1的角位移,可以用编号为1的陀螺仪数据近似得到,即s[0]=((t[1]–t[0])*x[1],(t[1]-t[0])*y[1],(t[1]-t[0])*z[1])。Since the data x1, y1, z1, etc. represent angular velocity, the angular displacement from time t[i] to t[i+1] can be approximately calculated as s[i] = ((t[i+1]-t[i])*x[i], (t[i+1]-t[i])*y[i], (t[i+1]-t[i])*z[i]). This formula includes the angular displacement from t33 to t34. In particular, the angular displacement from t0 to t1 can be approximated using the gyroscope data numbered 1, i.e., s[0] = ((t[1]–t[0])*x[1], (t[1]-t[0])*y[1], (t[1]-t[0])*z[1]).

基于角位移s[i],能够累加算出t1、t2、…、t34等时刻的陀螺仪位置。具体地,t0位置l[0]为(0,0,0);因此,基于上述的陀螺仪数据,可以得到陀螺仪分别在各个维度上的35个位置数据。Based on the angular displacement s[i], the gyroscope positions at times t1, t2, ..., t34 can be accumulated and calculated. Specifically, the t0 position l[0] is (0,0,0); Therefore, based on the above gyroscope data, 35 position data of the gyroscope in each dimension can be obtained.

对于x轴上的35个位置数据,取35个位置数据中值最大的位置数据和值最小的位置数据,相减后再取平方,得到x轴结果。类似地,基于y轴上的35个位置数据以及z轴上的35个位置数据求取得到y轴结果和z轴结果。最后,求取x轴结果、y轴结果和z轴结果之间的和,并求取得到的和的方根,得到图像的抖动值。For the 35 position data on the x-axis, take the position data with the largest value and the position data with the smallest value among the 35 position data, subtract them and then square them to get the x-axis result. Similarly, based on the 35 position data on the y-axis and the 35 position data on the z-axis, the y-axis result and the z-axis result are obtained. Finally, the sum of the x-axis result, the y-axis result and the z-axis result is calculated, and the square root of the sum is calculated to get the image jitter value.

此外,除了通过求取35个位置数据中值最大的位置数据和值最小的位置数据之间的差值来获得x轴结果之外,也可以是通过求取35个位置数据之间的方差来获得x轴结果。类似地,通过求取y轴上的35个位置数据之间的方差以及z轴上的35个位置数据之间的方差来得到y轴结果和z轴结果。最后,求取x轴结果、y轴结果和z轴结果之间的和,并求取得到的和的方根,得到图像的抖动值。In addition, in addition to obtaining the x-axis result by calculating the difference between the position data with the largest value and the position data with the smallest value among the 35 position data, the x-axis result can also be obtained by calculating the variance between the 35 position data. Similarly, the y-axis result and the z-axis result are obtained by calculating the variance between the 35 position data on the y-axis and the variance between the 35 position data on the z-axis. Finally, the sum of the x-axis result, the y-axis result and the z-axis result is calculated, and the square root of the sum is calculated to obtain the image jitter value.

可选的,在一些情况下,当终端发生低频抖动时,终端拍摄得到的图像会发生模糊,但图像中可能不会出现灯光区域不正常外扩的现象;当终端发生高频且大幅度的抖动时,终端所拍摄得到的图像则会出现灯光区域不正常外扩的现象。基于此,在基于陀螺仪数据求取图像的抖动值的过程中,还可以求取陀螺仪数据对应的频谱信息,并基于频谱信息确定图像的抖动值。Optionally, in some cases, when the terminal experiences low-frequency jitter, the image captured by the terminal will be blurred, but the phenomenon of abnormal expansion of the light area may not appear in the image; when the terminal experiences high-frequency and large-amplitude jitter, the image captured by the terminal will show abnormal expansion of the light area. Based on this, in the process of obtaining the jitter value of the image based on the gyroscope data, the spectrum information corresponding to the gyroscope data can also be obtained, and the jitter value of the image can be determined based on the spectrum information.

示例性地,对于表1中的数据,分别在x轴、y轴以及z轴的维度上做一次傅里叶变换,得到频谱图。例如,可以基于以下的公式1来求取x轴上的傅里叶变换结果。For example, for the data in Table 1, a Fourier transform is performed on the dimensions of the x-axis, the y-axis, and the z-axis to obtain a spectrum diagram. For example, the Fourier transform result on the x-axis can be obtained based on the following formula 1.

其中,Xk为傅里叶变换结果,k={0,1,2,3…,34},x[n]表示x轴上的陀螺仪数据,N为35。Wherein, Xk is the Fourier transform result, k={0,1,2,3…,34}, x[n] represents the gyroscope data on the x-axis, and N is 35.

假设w=|X0|/sigma(|Xi|),w表示x轴陀螺仪数据中最低频信息的占比,sigma()表示求和操作。在得到上述的x轴结果之后,将x轴结果与(1-w)相乘,得到更新后的x轴结果。以此类推,以类似的方式求取得到更新后的y轴和更新后的z轴结果。最后,求取更新后的x轴结果、y轴结果和z轴结果之间的和,并求取得到的和的方根,得到图像的抖动值。Assume w = |X 0 |/sigma(|X i |), w represents the proportion of the lowest frequency information in the x-axis gyroscope data, and sigma() represents the summation operation. After obtaining the above x-axis result, multiply the x-axis result by (1-w) to obtain the updated x-axis result. Similarly, the updated y-axis and z-axis results are obtained in a similar manner. Finally, the sum of the updated x-axis result, y-axis result, and z-axis result is obtained, and the square root of the sum is obtained to obtain the image jitter value.

步骤1003,获取图像t-k至图像t+k的抖动值。Step 1003, obtaining the jitter value from image t-k to image t+k.

在确定图像t为震颤图像的情况下,震颤判断单元则将图像t送入至解震颤单元。此外,震颤判断单元获取图像t-k至图像t+k的抖动值,并将图像t-k至图像t+k的抖动值输入至解震颤单元。其中,图像t-k至图像t的抖动值可以是在获取图像t的抖动值之前则获取到的。When determining that image t is a trembling image, the trembling judgment unit sends image t to the de-trembling unit. In addition, the trembling judgment unit obtains the jitter values of image t-k to image t+k, and inputs the jitter values of image t-k to image t+k to the de-trembling unit. The jitter values of image t-k to image t may be obtained before obtaining the jitter value of image t.

本实施例中,震颤判断单元获取图像t-k至图像t+k的抖动值的方式与获取图像t的抖动值的方式类似,在此不再赘述。In this embodiment, the manner in which the shake determination unit acquires the shake values of the image t-k to the image t+k is similar to the manner in which the shake value of the image t is acquired, and will not be described in detail herein.

步骤1004,根据图像t-k至图像t+k的抖动值,确定主参考图像M和次参考图像m。Step 1004: Determine a primary reference image M and a secondary reference image m according to the jitter values from image t-k to image t+k.

在获得图像t-k至图像t+k的抖动值之后,终端在图像t-k至图像t-1以及图像t+1至图像t+k中确定主参考图像M和次参考图像m。此外,假设图像t-k至图像t-1以及图像t+1至图像t+k中的任意一个图像p的稳定值为H,图像p的抖动值为pd。那么,稳定值H具体为:H=1/(pd+100*|p-t|)。可以看出,图像p的抖动值越大,则该图像p的稳定值越小;图像p与图像t相隔得越远,则该图像p的稳定值越小。After obtaining the jitter values of images tk to t+k, the terminal determines the primary reference image M and the secondary reference image m in images tk to t-1 and images t+1 to t+k. In addition, it is assumed that the stability value of any image p from images tk to t-1 and images t+1 to t+k is H, and the jitter value of image p is p d . Then, the stability value H is specifically: H=1/(p d +100*|pt|). It can be seen that the larger the jitter value of image p, the smaller the stability value of image p; the farther the image p is from image t, the smaller the stability value of image p.

这样,终端可以分别计算图像t-k至图像t-1以及图像t+1至图像t+k的稳定值H,并且在图像t-k至图像t-1以及图像t+1至图像t+k中选取稳定值H最大的一个图像作为主参考图像M。如果主参考图像M是图像t-k至图像t-1中的一个图像,则终端继续在图像t+1至图像t+k中选取稳定值H最大的一个图像作为次参考图像m。如果主参考图像M是图像t+1至图像t+k中的一个图像,则终端继续在图像t-k至图像t-1中选取稳定值H最大的一个图像作为次参考图像m。In this way, the terminal can calculate the stability values H of images t-k to t-1 and images t+1 to t+k respectively, and select an image with the largest stability value H from images t-k to t-1 and images t+1 to t+k as the main reference image M. If the main reference image M is an image from images t-k to t-1, the terminal continues to select an image with the largest stability value H from images t+1 to t+k as the secondary reference image m. If the main reference image M is an image from images t+1 to t+k, the terminal continues to select an image with the largest stability value H from images t-k to t-1 as the secondary reference image m.

此外,解震颤单元还可以定义一个算法帮助值Q,算法帮助值Q与主参考图像M的稳定值H1以及次参考图像m的稳定值H2正相关。该算法帮助值Q表示基于主参考图像M和次参考图像m对于生成稳定显示的目标图像的帮助值。例如,可以定义Q=(2*H1+H2)/3。在此基础上,可以事先设定一个帮助值阈值,若算法帮助值Q低于该帮助值阈值,则可以判断基于主参考图像和次参考图像也较难使图像t变得更为稳定。例如,在图像t附近的主参考图像和次参考图像也都是震颤图像的情况下,主参考图像和次参考图像也无法使得图像t变得更为稳定。因此,在算法帮助值Q低于帮助值阈值的情况下,解震颤单元可以结束对图像t的处理,即不再生成用于替换图像t的目标图像。In addition, the de-shaking unit may also define an algorithm help value Q, which is positively correlated with the stability value H1 of the main reference image M and the stability value H2 of the secondary reference image m. The algorithm help value Q represents the help value for generating a target image with stable display based on the main reference image M and the secondary reference image m. For example, Q = (2*H1+H2)/3 may be defined. On this basis, a help value threshold may be set in advance. If the algorithm help value Q is lower than the help value threshold, it may be determined that it is difficult to make the image t more stable based on the main reference image and the secondary reference image. For example, when the main reference image and the secondary reference image near the image t are also shaky images, the main reference image and the secondary reference image cannot make the image t more stable. Therefore, when the algorithm help value Q is lower than the help value threshold, the de-shaking unit may end the processing of the image t, that is, no longer generate a target image for replacing the image t.

步骤1005,根据主参考图像M、次参考图像m和图像t生成目标图像。Step 1005 , generating a target image according to the primary reference image M, the secondary reference image m and the image t.

本实施例中,通过将主参考图像M、次参考图像m划分为多个图像块,来生成用于替换图像t的目标图像。由于在主参考图像M、次参考图像m分辨率较高的情况下,对主参考图像M、次参考图像m进行图像块的划分,并求取图像块的运动矢量需要耗费过高的算力,因此本实施例中可以采用金字塔下采样方法来求取主参考图像M、次参考图像m中的图像块的运动矢量。In this embodiment, the target image for replacing the image t is generated by dividing the primary reference image M and the secondary reference image m into a plurality of image blocks. Since when the primary reference image M and the secondary reference image m have high resolutions, dividing the primary reference image M and the secondary reference image m into image blocks and obtaining motion vectors of the image blocks requires excessive computing power, a pyramid downsampling method may be used in this embodiment to obtain motion vectors of image blocks in the primary reference image M and the secondary reference image m.

具体地,首先对主参考图像M和次参考图像m执行金字塔下采样,得到主参考图像M和次参考图像m对应的多层下采样图像。例如,在主参考图像M的分辨率为1920*1080的情况下,可以主参考图像M执行4次下采样,得到主参考图像M对应的四层下采样图像。该四层下采样图像的分辨率例如可以为:480*270、120*68、60*34以及30*17。对于主参考图像M和次参考图像m,从分辨率最小的图层开始,直至原图所在层,获取每一层的主参考图像Mx的图像块的运动矢量。其中,主参考图像Mx表示主参考图像M在任意一层所对应的图像。Specifically, firstly, pyramid downsampling is performed on the main reference image M and the secondary reference image m to obtain multi-layer downsampled images corresponding to the main reference image M and the secondary reference image m. For example, when the resolution of the main reference image M is 1920*1080, the main reference image M can be downsampled 4 times to obtain four layers of downsampled images corresponding to the main reference image M. The resolutions of the four layers of downsampled images can be, for example, 480*270, 120*68, 60*34, and 30*17. For the main reference image M and the secondary reference image m, starting from the layer with the smallest resolution to the layer where the original image is located, the motion vector of the image block of the main reference image Mx of each layer is obtained. Among them, the main reference image Mx represents the image corresponding to the main reference image M at any layer.

首先,对于当前层的主参考图像Mx,按照特定的大小(例如8*8个像素)对该主参考图像Mx进行划分,得到主参考图像Mx中的多个图像块。First, for a main reference image Mx of the current layer, the main reference image Mx is divided according to a specific size (for example, 8*8 pixels) to obtain a plurality of image blocks in the main reference image Mx.

如果主参考图像Mx为分辨率最小的一层的图像,则对于主参考图像Mx中的图像块q,可以确定图像块q的候选运动矢量为预设候选运动矢量。例如,预设运动矢量可以包括(0,-1)、(-1,0)、(-1,-1)、(-1,1)、(1,-1)、(0,0)、(0,1)、(1,0)以及(1,1)。如果主参考图像Mx不是分辨率最小的一层的图像,则对于主参考图像Mx中的图像块q,可以确定图像块q的候选运动矢量包括:图像块q在上一层图像中对应的图像块的运动矢量、与图像块q相邻的图像块的运动矢量以及随机生成的运动矢量。If the main reference image Mx is an image of a layer with the smallest resolution, then for the image block q in the main reference image Mx, the candidate motion vector of the image block q can be determined to be a preset candidate motion vector. For example, the preset motion vector may include (0, -1), (-1, 0), (-1, -1), (-1, 1), (1, -1), (0, 0), (0, 1), (1, 0), and (1, 1). If the main reference image Mx is not an image of a layer with the smallest resolution, then for the image block q in the main reference image Mx, the candidate motion vector of the image block q can be determined to include: the motion vector of the image block corresponding to the image block q in the previous layer of the image, the motion vector of the image block adjacent to the image block q, and a randomly generated motion vector.

对于图像块q的所有候选运动矢量,计算该图像块q根据候选运动矢量映射到次参考图像mx和图像t中的位置。具体地,图像块q根据候选运动矢量vec映射到图像t上时,需要将候选运动矢量根据M、m、t的取值按比例缩放为vec’=((t-M)/(m-M))*vec)。在得到次参考图像mx中与图像块q对应的图像块q1以及图像t中与图像块q对应的图像块q2后,分别计算图像块q与图像块q1以及图像块q2的误差值。示例性地,可以基于多种算法来计算图像块之间的误差值,例如SAD算法。最终,假设图像块q与图像块q1之间的误差值为SAD1,图像块q与图像块q2的误差值为SAD2,对两个误差值加权求和得到候选运动矢量的误差值D。其中,两个误差值的权重可任意设定,例如可令D=SAD1+αSAD2,α=1/2。For all candidate motion vectors of image block q, calculate the position of image block q mapped to the secondary reference image mx and image t according to the candidate motion vector. Specifically, when image block q is mapped to image t according to the candidate motion vector vec, the candidate motion vector needs to be scaled to vec’=((t-M)/(m-M))*vec according to the values of M, m, and t. After obtaining the image block q1 corresponding to image block q in the secondary reference image mx and the image block q2 corresponding to image block q in image t, calculate the error values between image block q and image block q1 and image block q2 respectively. Exemplarily, the error values between image blocks can be calculated based on a variety of algorithms, such as the SAD algorithm. Finally, assuming that the error value between image block q and image block q1 is SAD1, and the error value between image block q and image block q2 is SAD2, the error value D of the candidate motion vector is obtained by weighted summing of the two error values. Among them, the weights of the two error values can be set arbitrarily, for example, D=SAD1+αSAD2, α=1/2.

在求取得到图像块q的所有候选运动矢量对应的误差值D后,选取误差值D最小的候选运动矢量作为图像块q在当前金字塔层的运动矢量。最终,通过重复上述的过程,可以计算得到主参考图像Mx中的所有图像块的运动矢量。After obtaining the error values D corresponding to all candidate motion vectors of the image block q, the candidate motion vector with the smallest error value D is selected as the motion vector of the image block q in the current pyramid layer. Finally, by repeating the above process, the motion vectors of all image blocks in the main reference image Mx can be calculated.

此外,在求取得到主参考图像M的原图所在层的运动矢量之后,可以对主参考图像M的运动矢量进行平滑修正,以消除个别明显不合理的运动矢量。例如,对于主参考图像中的某一个图像块,该图像块的运动矢量与该图像块相邻的其他图像块的运动矢量差异过大时,则消除该图像块的运动矢量。In addition, after obtaining the motion vector of the layer where the original image of the main reference image M is located, the motion vector of the main reference image M can be smoothed and corrected to eliminate individual obviously unreasonable motion vectors. For example, for a certain image block in the main reference image, if the motion vector of the image block is too different from the motion vectors of other image blocks adjacent to the image block, the motion vector of the image block is eliminated.

在得到主参考图像M中的每个图像块的运动矢量之后,假设待生成的目标图像为图像t’,可以基于主参考图像M中的每个图像块的运动矢量,根据换算比例转换为由图像t’指向主参考图像M的运动矢量vec’=(-(t-M)/(m-M))*vec。After obtaining the motion vector of each image block in the main reference image M, assuming that the target image to be generated is image t’, the motion vector of each image block in the main reference image M can be converted into a motion vector vec’=(-(t-M)/(m-M))*vec pointing from image t’ to the main reference image M according to the conversion ratio.

这样一来,如果图像t’中存在图像块不具有指向主参考图像M的运动矢量,则说明该图像块属于空洞区域,从而可以对该图像块进行空洞区域标记。In this way, if there is an image block in the image t' that does not have a motion vector pointing to the main reference image M, it means that the image block belongs to a hole area, so the image block can be marked as a hole area.

在标记了图像t’中的空洞区域之后,可以根据主参考图像M中的图像块对图像t’中非空洞区域的图像块进行填充,得到仍包括有空洞区域的图像t’。After marking the hole area in the image t’, the image blocks in the non-hole area in the image t’ can be filled according to the image blocks in the main reference image M to obtain the image t’ still including the hole area.

值得注意的是,在根据主参考图像M中的图像块对图像t’中非空洞区域的图像块进行填充的过程中,如果主参考图像M中存在多个不同的图像块指向图像t’中的同一个图像块,则终端根据这多个不同的图像块的运动矢量的误差值D,在这多个不同的图像块中选出误差值D最小的图像块,并将该误差值D最小的图像块填充至图像t’。It is worth noting that in the process of filling the image blocks in the non-hole area of image t’ according to the image blocks in the main reference image M, if there are multiple different image blocks in the main reference image M pointing to the same image block in image t’, the terminal selects the image block with the smallest error value D from the multiple different image blocks according to the error value D of the motion vectors of the multiple different image blocks, and fills the image block with the smallest error value D into image t’.

此外,解震颤单元可以求取次参考图像m中的每个图像块对应的运动矢量,并根据次参考图像m中的图像块对图像t’中的空洞区域进行填充,得到最终的目标图像t’。In addition, the de-shaking unit can obtain the motion vector corresponding to each image block in the secondary reference image m, and fill the hole area in the image t' according to the image blocks in the secondary reference image m to obtain the final target image t'.

步骤1006,将图像t替换为目标图像。Step 1006, replacing image t with the target image.

最后,在基于主参考图像M、次参考图像m和图像t得到目标图像之后,则将图像t替换为目标图像。Finally, after the target image is obtained based on the primary reference image M, the secondary reference image m and the image t, the image t is replaced with the target image.

类似地,对于终端采集得到的多个图像,均可以基于上述的步骤1001-步骤1006,确定多个图像中的震颤图像,并将多个图像中的震颤图像替换为所生成的稳定图像,最终输出替换了稳定图像后的多个图像。Similarly, for multiple images captured by the terminal, based on the above steps 1001 to 1006, the tremor images in the multiple images can be determined, and the tremor images in the multiple images can be replaced with the generated stable images, and finally the multiple images after the stable images are replaced are output.

以上实施例介绍了终端在视频拍摄过程中,对视频进行处理的过程。以下将介绍终端在处于夜景拍摄模式时,对视频进行处理的过程。可以参阅图12,图12为本实施例所提供的另一种视频处理方法的流程示意图,该视频处理方法包括以下的流程。The above embodiments introduce the process of processing a video by a terminal during video shooting. The following will introduce the process of processing a video when the terminal is in night scene shooting mode. Please refer to Figure 12, which is a flow chart of another video processing method provided by this embodiment, and the video processing method includes the following process.

步骤1201,当终端处于夜景拍摄模式时,检测所述终端拍摄的图像中是否存在灯光区域。Step 1201: When the terminal is in a night scene shooting mode, detect whether there is a light area in the image shot by the terminal.

其中,终端可以通过检测拍摄的图像中的像素的亮度值,来判断图像中是否存在灯光区域。具体地,灯光区域内的像素的亮度值均大于特定阈值,且灯光区域内的像素的亮度值与灯光区域的相邻区域的像素的亮度值之间的差异值大于预设设定的差值。其中,上述的特定阈值的取值可以为180-230,例如特定阈值具体为224;预先设定的差值的取值可以为25-50,例如预设设定的差值为32。例如,当终端检测到图像中存在有某一个区域内的像素的亮度值均大于224,且该区域内的像素的亮度值与相邻区域的像素的亮度值之间的差异值大于32,则终端可以确定该区域为灯光区域。其中,灯光区域的相邻区域可以是由与灯光区域内的像素相邻的像素所构成,即灯光区域的相邻区域内的像素与灯光区域内的像素相邻。The terminal can determine whether there is a light area in the image by detecting the brightness values of pixels in the captured image. Specifically, the brightness values of the pixels in the light area are all greater than a specific threshold, and the difference between the brightness values of the pixels in the light area and the brightness values of the pixels in the adjacent area of the light area is greater than a preset difference. The value of the above-mentioned specific threshold can be 180-230, for example, the specific threshold is specifically 224; the value of the preset difference can be 25-50, for example, the preset difference is 32. For example, when the terminal detects that the brightness values of the pixels in a certain area in the image are all greater than 224, and the difference between the brightness values of the pixels in the area and the brightness values of the pixels in the adjacent area is greater than 32, the terminal can determine that the area is a light area. The adjacent area of the light area can be composed of pixels adjacent to the pixels in the light area, that is, the pixels in the adjacent area of the light area are adjacent to the pixels in the light area.

此外,在终端确定图像中存在灯光区域之后,终端还可以根据位于灯光区域内的像素的坐标,确定图像中的灯光区域的位置。其中,图像中的灯光区域的位置可以是以灯光区域的边界的像素的坐标来确定,即由灯光区域的边界的像素所包围的区域即为灯光区域。终端可以通过记录灯光区域的边界的像素的坐标或者是灯光区域内的所有像素的坐标,来确定灯光区域的位置。In addition, after the terminal determines that there is a light area in the image, the terminal can also determine the position of the light area in the image according to the coordinates of the pixels located in the light area. The position of the light area in the image can be determined by the coordinates of the pixels at the boundary of the light area, that is, the area surrounded by the pixels at the boundary of the light area is the light area. The terminal can determine the position of the light area by recording the coordinates of the pixels at the boundary of the light area or the coordinates of all pixels in the light area.

步骤1202,当所述终端拍摄的图像中存在灯光区域时,终端在采集的图像序列中确定第一图像,所述第一图像中的灯光区域的邻近区域出现过曝。Step 1202: When there is a light area in the image captured by the terminal, the terminal determines a first image in the acquired image sequence, and an area adjacent to the light area in the first image is overexposed.

所述第一图像中的灯光区域的邻近区域出现过曝是指该邻近区域中的像素的亮度值过高。第一图像中的灯光区域的邻近区域出现过曝的原因是终端在采集第一图像的时候发生了抖动位移,使得终端中对应于邻近区域的感光元件同样感应到了灯光区域内的光线,最终导致第一图像中的灯光区域的邻近区域出现过曝。The overexposure of the adjacent area of the light area in the first image means that the brightness value of the pixels in the adjacent area is too high. The reason why the adjacent area of the light area in the first image is overexposed is that the terminal has a jitter displacement when capturing the first image, so that the photosensitive element corresponding to the adjacent area in the terminal also senses the light in the light area, which ultimately causes the adjacent area of the light area in the first image to be overexposed.

步骤1203,终端根据所述第一图像在所述图像序列中确定第二图像和第三图像。Step 1203: The terminal determines a second image and a third image in the image sequence according to the first image.

所述第一图像的采集时刻位于所述第二图像的采集时刻与所述第三图像的采集时刻之间,所述第二图像以及所述第三图像中的灯光区域的邻近区域的过曝程度小于所述第一图像中的灯光区域邻近区域的过曝程度。其中,第二图像以及第三图像中的灯光区域与第一图像中的灯光区域具有对应关系,即第二图像以及第三图像中的灯光区域与第一图像中的灯光区域表示的是相同的画面内容。例如,第二图像和第三图像中的灯光区域表示的是某一个路灯的发光区域;第一图像中的灯光区域也是表示同一个路灯的发光区域。The acquisition time of the first image is between the acquisition time of the second image and the acquisition time of the third image, and the overexposure degree of the adjacent area of the light area in the second image and the third image is less than the overexposure degree of the adjacent area of the light area in the first image. The light areas in the second image and the third image correspond to the light areas in the first image, that is, the light areas in the second image and the third image represent the same picture content as the light areas in the first image. For example, the light areas in the second image and the third image represent the luminous area of a street lamp; the light area in the first image also represents the luminous area of the same street lamp.

具体地,第二图像以及所述第三图像中的灯光区域的邻近区域的过曝程度小于所述第一图像中的灯光区域邻近区域的过曝程度可以是指:第二图像以及所述第三图像中的灯光区域的邻近区域中发生过曝的区域的面积小于第一图像中的灯光区域的邻近区域中发生过曝的区域的面积;或者,第二图像以及所述第三图像中的灯光区域的邻近区域中发生过曝的像素的亮度值小于第一图像中的灯光区域的邻近区域中发生过曝的像素的亮度值。可选的,第二图像以及所述第三图像中的灯光区域的邻近区域中发生过曝的区域的面积可以为0,即第二图像和第三图像中的灯光区域的邻近区域并没有发生过曝。总的来说,相对于第一图像,第二图像和第三图像是终端在抖动位移较小或者是没有发生抖动位移的情况下采集的,因此第二图像以及所述第三图像中的灯光区域的邻近区域的过曝程度小于所述第一图像中的灯光区域邻近区域的过曝程度。Specifically, the overexposure degree of the adjacent areas of the light area in the second image and the third image is smaller than the overexposure degree of the adjacent areas of the light area in the first image, which may mean: the area of the overexposed area in the adjacent areas of the light area in the second image and the third image is smaller than the area of the overexposed area in the adjacent areas of the light area in the first image; or, the brightness value of the overexposed pixel in the adjacent areas of the light area in the second image and the third image is smaller than the brightness value of the overexposed pixel in the adjacent areas of the light area in the first image. Optionally, the area of the overexposed area in the adjacent areas of the light area in the second image and the third image may be 0, that is, the adjacent areas of the light area in the second image and the third image are not overexposed. In general, compared with the first image, the second image and the third image are collected by the terminal under the condition of small jitter displacement or no jitter displacement, so the overexposure degree of the adjacent areas of the light area in the second image and the third image is smaller than the overexposure degree of the adjacent areas of the light area in the first image.

步骤1204,终端根据所述第一图像、所述第二图像和所述第三图像生成目标图像,所述目标图像用于替换所述第一图像,所述目标图像的灯光区域的邻近区域的过曝程度小于所述第一图像的灯光区域的邻近区域的过曝程度。其中,第二图像和第三图像用于作为参考图像来生成替换第一图像的目标图像,以使得生成的目标图像的灯光区域的邻近区域的过曝程度小于所述第一图像的灯光区域的邻近区域的过曝程度。Step 1204: The terminal generates a target image based on the first image, the second image, and the third image, the target image being used to replace the first image, and the overexposure degree of the area adjacent to the light area of the target image being smaller than the overexposure degree of the area adjacent to the light area of the first image. The second image and the third image are used as reference images to generate a target image that replaces the first image, so that the overexposure degree of the area adjacent to the light area of the generated target image is smaller than the overexposure degree of the area adjacent to the light area of the first image.

步骤1205,终端基于所述目标图像,生成视频。具体地,终端可以是将采集得到的图像序列中的第一图像替换为目标图像,从而生成视频。Step 1205: The terminal generates a video based on the target image. Specifically, the terminal may replace the first image in the acquired image sequence with the target image, thereby generating a video.

本实施例中,通过在夜景拍摄模式下定位灯光区域的邻近区域出现过曝的震颤图像,将震颤图像前后的图像作为参考图像,并基于震颤图像以及参考图像来生成用于替换震颤图像的目标图像。通过本方案,能够将视频中的震颤图像替换为正常显示的图像,从而解决由镜头抖动所引起的视频画面中的光亮部分灯光区域不正常外扩的问题。In this embodiment, by locating the overexposed trembling image in the vicinity of the light area in the night scene shooting mode, the images before and after the trembling image are used as reference images, and a target image for replacing the trembling image is generated based on the trembling image and the reference image. Through this solution, the trembling image in the video can be replaced with a normally displayed image, thereby solving the problem of abnormal expansion of the bright part of the light area in the video screen caused by lens shaking.

可选的,本实施例所提供的方法还包括:当环境光的光照度小于第一预设阈值时,所述终端进入夜景拍摄模式。示例性地,第一预设阈值的取值可以为30-60,例如第一预设阈值为50。终端在拍摄的过程中,可以检测环境光的光照度,环境光的光照度小于50时,终端则进入夜景拍摄模式。或,当所述终端获取到用于触发进入夜景拍摄模式的指令时,所述终端进入夜景拍摄模式。例如,在用户操作终端进行拍摄的过程中,用户可以通过触控终端屏幕的方式,向终端下发进入夜景拍摄模式的指令;这样一来,当终端获取到用于触发进入夜景拍摄模式的指令时,终端则进入夜景拍摄模式。Optionally, the method provided in this embodiment also includes: when the illumination of the ambient light is less than a first preset threshold, the terminal enters a night scene shooting mode. Exemplarily, the value of the first preset threshold can be 30-60, for example, the first preset threshold is 50. During the shooting process, the terminal can detect the illumination of the ambient light, and when the illumination of the ambient light is less than 50, the terminal enters the night scene shooting mode. Or, when the terminal obtains an instruction for triggering entry into the night scene shooting mode, the terminal enters the night scene shooting mode. For example, in the process of the user operating the terminal to shoot, the user can send an instruction to the terminal to enter the night scene shooting mode by touching the terminal screen; in this way, when the terminal obtains an instruction for triggering entry into the night scene shooting mode, the terminal enters the night scene shooting mode.

此外,终端还可以是根据拍摄过程中的预览图像的画面内容和/或预览图像各区域的环境亮度值,来确定当前拍摄场景是否为夜景场景,从而确定是否进入夜景拍摄模式。例如,当预览图像的画面内容包括夜晚天空或者夜景灯源等内容时,终端可以确定当前拍摄场景为夜景场景,从而进入夜景拍摄模式;或者,当预览图像的各区域中的环境亮度值符合夜景环境下图像的亮度分布特性时,终端可以确定当前拍摄场景为夜景场景,从而进入夜景拍摄模式。In addition, the terminal can also determine whether the current shooting scene is a night scene according to the picture content of the preview image during shooting and/or the ambient brightness value of each area of the preview image, thereby determining whether to enter the night scene shooting mode. For example, when the picture content of the preview image includes the night sky or night scene light source, the terminal can determine that the current shooting scene is a night scene, thereby entering the night scene shooting mode; or, when the ambient brightness value of each area of the preview image meets the brightness distribution characteristics of the image in the night scene environment, the terminal can determine that the current shooting scene is a night scene, thereby entering the night scene shooting mode.

可选的,所述终端采集所述第一图像时的抖动位移大于第二预设阈值。其中,第二预设阈值可以为300-400,例如第二预设阈值具体为360。所述终端采集所述第一图像时的抖动位移可以称为第一图像的抖动值。所述终端可以是通过在图像序列中确定图像的抖动值是否大于或等于第二预设阈值,来确定图像序列中的第一图像。Optionally, the jitter displacement when the terminal acquires the first image is greater than a second preset threshold. The second preset threshold may be 300-400, for example, the second preset threshold is specifically 360. The jitter displacement when the terminal acquires the first image may be referred to as a jitter value of the first image. The terminal may determine the first image in the image sequence by determining whether the jitter value of the image in the image sequence is greater than or equal to the second preset threshold.

在一些可能的实现方式中,终端可以获取记录了终端在采集第一图像时的运动情况的传感器数据,并且基于传感器数据计算得到第一图像的抖动值。终端也可以是计算图像的对比度值,并根据图像的对比度值来确定图像的抖动值,即图像的对比度值越小,则图像的抖动值越大。此外,终端还可以基于预先训练好的神经网络来确定图像的抖动值。具体地,终端确定第一图像的抖动值的方式可以参考上述的实施例,在此不再赘述。In some possible implementations, the terminal may obtain sensor data that records the movement of the terminal when capturing the first image, and calculate the jitter value of the first image based on the sensor data. The terminal may also calculate the contrast value of the image, and determine the jitter value of the image based on the contrast value of the image, that is, the smaller the contrast value of the image, the greater the jitter value of the image. In addition, the terminal may also determine the jitter value of the image based on a pre-trained neural network. Specifically, the manner in which the terminal determines the jitter value of the first image can refer to the above-mentioned embodiment, which will not be repeated here.

在一种可能的实现方式中,终端还可以确定所述多个图像是否存在局部灯光区域。只有在某一个图像存在局部灯光区域且该图像的抖动值大于或等于第二预设阈值时,终端将该图像确定为震颤图像。其中,第一图像中存在局部灯光区域,所述第一图像中目标像素的个数与第一图像的像素总个数的比值在预设范围内,所述目标像素为所述第一图像中的灯光区域内的像素。示例性地,终端可以确定所述多个图像中的每个图像中目标像素的个数,所述目标像素是指灯光区域内的像素,其中灯光区域的定义可以参考上述的描述。然后,终端获取每个图像中目标像素的个数与图像的像素总个数的比值,并判断该比值是否在预设范围内。如果图像中目标像素的个数与图像的像素总个数的比值在预设范围内,则终端确定该图像中存在局部灯光区域;如果图像中目标像素的个数与图像的像素总个数的比值不在预设范围内,则终端确定该图像中不存在局部灯光区域。In a possible implementation, the terminal may also determine whether there is a local light area in the multiple images. Only when a certain image has a local light area and the jitter value of the image is greater than or equal to a second preset threshold value, the terminal determines the image as a trembling image. Wherein, there is a local light area in the first image, and the ratio of the number of target pixels in the first image to the total number of pixels in the first image is within a preset range, and the target pixel is a pixel in the light area in the first image. Exemplarily, the terminal may determine the number of target pixels in each of the multiple images, and the target pixel refers to a pixel in the light area, wherein the definition of the light area may refer to the above description. Then, the terminal obtains the ratio of the number of target pixels in each image to the total number of pixels in the image, and determines whether the ratio is within a preset range. If the ratio of the number of target pixels in the image to the total number of pixels in the image is within the preset range, the terminal determines that there is a local light area in the image; if the ratio of the number of target pixels in the image to the total number of pixels in the image is not within the preset range, the terminal determines that there is no local light area in the image.

此外,终端基于第一图像在图像序列中确定第二图像和第三图像的方式也与上述的实施例类似,在此不再赘述。In addition, the manner in which the terminal determines the second image and the third image in the image sequence based on the first image is also similar to the above-mentioned embodiment, and will not be described in detail herein.

在图1a至图12所对应的实施例的基础上,为了更好的实施本申请实施例的上述方案,下面还提供用于实施上述方案的相关设备。On the basis of the embodiments corresponding to FIG. 1a to FIG. 12 , in order to better implement the above-mentioned solutions of the embodiments of the present application, related devices for implementing the above-mentioned solutions are also provided below.

具体可以参阅图13,图13为本申请实施例提供的一种终端1300的结构示意图,该终端1300包括:For details, please refer to FIG. 13 , which is a schematic diagram of the structure of a terminal 1300 provided in an embodiment of the present application. The terminal 1300 includes:

检测单元1301,用于当终端处于夜景拍摄模式时,检测所述终端拍摄的图像中是否存在灯光区域;The detection unit 1301 is used to detect whether there is a light area in the image captured by the terminal when the terminal is in a night scene shooting mode;

第一确定单元1302,用于当所述终端拍摄的图像中存在灯光区域时,在所述终端采集的图像序列中确定第一图像,所述第一图像中的灯光区域的邻近区域出现过曝;A first determining unit 1302 is configured to, when there is a light area in the image captured by the terminal, determine a first image in the image sequence collected by the terminal, in which an area adjacent to the light area in the first image is overexposed;

第二确定单元1303,用于根据所述第一图像在所述图像序列中确定第二图像和第三图像,所述第一图像的采集时刻位于所述第二图像的采集时刻与所述第三图像的采集时刻之间,所述第二图像以及所述第三图像中的灯光区域的邻近区域的过曝程度小于所述第一图像中的灯光区域邻近区域的过曝程度;A second determining unit 1303 is configured to determine a second image and a third image in the image sequence according to the first image, wherein a capture time of the first image is between a capture time of the second image and a capture time of the third image, and an overexposure degree of an area adjacent to the light area in the second image and the third image is less than an overexposure degree of an area adjacent to the light area in the first image;

图像生成单元1304,还用于根据所述第一图像、所述第二图像和所述第三图像生成目标图像,所述目标图像用于替换所述第一图像,所述目标图像的灯光区域的邻近区域的过曝程度小于所述第一图像的灯光区域的邻近区域的过曝程度;The image generating unit 1304 is further configured to generate a target image according to the first image, the second image, and the third image, wherein the target image is used to replace the first image, and the overexposure degree of the neighboring area of the light area of the target image is smaller than the overexposure degree of the neighboring area of the light area of the first image;

视频生成单元1305,还用于基于所述目标图像,生成视频。The video generating unit 1305 is further configured to generate a video based on the target image.

在一种可能的实现方式中,还包括:控制单元1306;In a possible implementation, it further includes: a control unit 1306;

所述控制单元1306用于:当环境光的光照度小于第一预设阈值时,控制所述终端进入夜景拍摄模式;或,当获取到用于触发进入夜景拍摄模式的指令时,控制所述终端进入夜景拍摄模式。The control unit 1306 is used to: when the illumination of the ambient light is less than a first preset threshold, control the terminal to enter the night scene shooting mode; or, when an instruction for triggering entering the night scene shooting mode is obtained, control the terminal to enter the night scene shooting mode.

在一种可能的实现方式中,所述终端采集所述第一图像时的抖动位移大于第二预设阈值。In a possible implementation manner, a jitter displacement when the terminal captures the first image is greater than a second preset threshold.

在一种可能的实现方式中,所述第一图像中目标像素的个数与第一图像的像素总个数的比值在预设范围内,所述目标像素为所述第一图像中的灯光区域内的像素。In a possible implementation manner, a ratio of the number of target pixels in the first image to the total number of pixels in the first image is within a preset range, and the target pixels are pixels in a light area in the first image.

在一种可能的实现方式中,所述第二确定单元1303用于:分别确定所述多个图像中每个图像的稳定值,所述稳定值为所述图像的抖动值与所述图像和所述第一图像之间的采集时间差之和的倒数;确定所述多个图像中稳定值最大的图像为所述第二图像;根据所述第二图像的采集时刻,在所述多个图像中确定所述第三图像。In a possible implementation, the second determination unit 1303 is used to: respectively determine a stability value of each of the multiple images, where the stability value is the reciprocal of the sum of a jitter value of the image and an acquisition time difference between the image and the first image; determine the image with the largest stability value among the multiple images as the second image; and determine the third image among the multiple images based on the acquisition time of the second image.

在一种可能的实现方式中,所述第二确定单元1303用于:根据所述第二图像的采集时刻,在所述多个图像中确定一个或多个图像,所述第一图像的采集时刻位于所述第二图像的采集时刻与所述一个或多个图像的采集时刻之间;在所述一个或多个图像中确定稳定值最大的图像为所述第三图像。In a possible implementation, the second determination unit 1303 is used to: determine one or more images from the multiple images based on the acquisition time of the second image, the acquisition time of the first image is between the acquisition time of the second image and the acquisition time of the one or more images; and determine the image with the largest stability value from the one or more images as the third image.

在一种可能的实现方式中,所述图像生成单元1304用于:将所述第二图像划分为多个图像块;根据所述第一图像和所述第三图像确定所述多个图像块分别对应的运动矢量;根据所述多个图像块分别对应的运动矢量以及所述多个图像块,生成所述目标图像。In a possible implementation, the image generation unit 1304 is used to: divide the second image into multiple image blocks; determine the motion vectors corresponding to the multiple image blocks respectively according to the first image and the third image; and generate the target image according to the motion vectors corresponding to the multiple image blocks respectively and the multiple image blocks.

在一种可能的实现方式中,所述图像生成单元1304用于:获取第一图像块对应的多个候选运动矢量,所述多个图像块包括所述第一图像块;根据所述第一图像块的位置,确定所述多个候选运动矢量中每个候选运动矢量对应的第二图像块和第三图像块,所述第一图像包括所述第二图像块,所述第三图像包括所述第三图像块;根据所述第一图像块、所述第二图像块和所述第三图像块,确定所述每个候选运动矢量对应的目标误差值,所述目标误差值是基于所述第一图像块与所述第二图像块之间的误差值以及所述第一图像块与所述第三图像块之间的误差值得到的;根据所述每个候选运动矢量对应的目标误差值,在所述多个候选运动矢量中确定目标误差值最小的运动矢量为所述第一图像块对应的运动矢量。In a possible implementation, the image generation unit 1304 is used to: obtain multiple candidate motion vectors corresponding to a first image block, the multiple image blocks including the first image block; determine, according to the position of the first image block, a second image block and a third image block corresponding to each of the multiple candidate motion vectors, the first image including the second image block, and the third image including the third image block; determine, according to the first image block, the second image block, and the third image block, a target error value corresponding to each candidate motion vector, the target error value being obtained based on an error value between the first image block and the second image block and an error value between the first image block and the third image block; and, according to the target error value corresponding to each candidate motion vector, determine, among the multiple candidate motion vectors, a motion vector with a minimum target error value as the motion vector corresponding to the first image block.

在一种可能的实现方式中,所述多个候选运动矢量,包括:一个或多个预设运动矢量、随机生成的一个或多个运动矢量和/或与所述第一图像块相邻的图像块对应的运动矢量。In a possible implementation manner, the multiple candidate motion vectors include: one or more preset motion vectors, one or more randomly generated motion vectors and/or motion vectors corresponding to an image block adjacent to the first image block.

在一种可能的实现方式中,所述图像生成单元1304用于:若所述目标图像中存在无法基于所述多个图像块生成图像的区域,则对所述第三图像进行划分,得到所述第三图像的多个图像块;根据所述第一图像和所述第二图像确定所述第三图像的多个图像块分别对应的运动矢量;根据所述第三图像的多个图像块对应的运动矢量以及所述第三图像的多个图像块,更新所述目标图像,得到新的目标图像,所述新的目标图像用于替换所述第一图像。In a possible implementation, the image generation unit 1304 is used to: if there is an area in the target image where an image cannot be generated based on the multiple image blocks, divide the third image to obtain multiple image blocks of the third image; determine the motion vectors corresponding to the multiple image blocks of the third image according to the first image and the second image; update the target image according to the motion vectors corresponding to the multiple image blocks of the third image and the multiple image blocks of the third image to obtain a new target image, and the new target image is used to replace the first image.

本申请实施例提供的视频处理方法具体可以由终端中的芯片来执行,该芯片包括:处理单元和通信单元,处理单元例如可以是处理器,通信单元例如可以是输入/输出接口、管脚或电路等。该处理单元可执行存储单元存储的计算机执行指令,以使服务器内的芯片执行上述图1a至图11所示实施例描述的视频处理方法。可选的,存储单元为芯片内的存储单元,如寄存器、缓存等,存储单元还可以是无线接入设备端内的位于芯片外部的存储单元,如只读存储器(read-only memory,ROM)或可存储静态信息和指令的其他类型的静态存储设备,随机存取存储器(random access memory,RAM)等。The video processing method provided in the embodiment of the present application can be specifically executed by a chip in a terminal, and the chip includes: a processing unit and a communication unit, the processing unit can be, for example, a processor, and the communication unit can be, for example, an input/output interface, a pin or a circuit, etc. The processing unit can execute the computer execution instructions stored in the storage unit, so that the chip in the server executes the video processing method described in the embodiments shown in Figures 1a to 11 above. Optionally, the storage unit is a storage unit in the chip, such as a register, a cache, etc. The storage unit can also be a storage unit located outside the chip in the wireless access device, such as a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, a random access memory (RAM), etc.

参照图14,本申请还提供了一种计算机程序产品,在一些实施例中,上述图3所公开的方法可以实施为以机器可读格式被编码在计算机可读存储介质上的或者被编码在其它非瞬时性介质或者制品上的计算机程序指令。Referring to Figure 14, the present application also provides a computer program product. In some embodiments, the method disclosed in Figure 3 above can be implemented as computer program instructions encoded in a machine-readable format on a computer-readable storage medium or encoded on other non-transitory media or products.

图14示意性地示出根据这里展示的至少一些实施例而布置的示例计算机程序产品的概念性局部视图,示例计算机程序产品包括用于在计算设备上执行计算机进程的计算机程序。14 schematically illustrates a conceptual partial view of an example computer program product including a computer program for executing a computer process on a computing device, arranged in accordance with at least some embodiments presented herein.

在一个实施例中,计算机程序产品1400是使用信号承载介质1401来提供的。信号承载介质1401可以包括一个或多个程序指令1402,其当被一个或多个处理器运行时可以提供以上针对图2描述的功能或者部分功能。因此,例如,参考图3中所示的实施例,步骤301-306的一个或多个特征可以由与信号承载介质1401相关联的一个或多个指令来承担。此外,图14中的程序指令1402也描述示例指令。In one embodiment, computer program product 1400 is provided using signal bearing medium 1401. Signal bearing medium 1401 may include one or more program instructions 1402, which when executed by one or more processors may provide the functionality or portions of the functionality described above with respect to FIG. 2. Thus, for example, with reference to the embodiment shown in FIG. 3, one or more features of steps 301-306 may be undertaken by one or more instructions associated with signal bearing medium 1401. In addition, program instructions 1402 in FIG. 14 also describe example instructions.

在一些示例中,信号承载介质1401可以包含计算机可读介质1403,诸如但不限于,硬盘驱动器、紧密盘(CD)、数字视频光盘(DVD)、数字磁带、存储器、ROM或RAM等等。In some examples, the signal bearing medium 1401 may include a computer readable medium 1403 such as, but not limited to, a hard drive, a compact disk (CD), a digital video disk (DVD), a digital tape, a memory, a ROM or RAM, and the like.

在一些实施方式中,信号承载介质1401可以包含计算机可记录介质1404,诸如但不限于,存储器、读/写(R/W)CD、R/W DVD、等等。在一些实施方式中,信号承载介质1401可以包含通信介质1405,诸如但不限于,数字和/或模拟通信介质(例如,光纤电缆、波导、有线通信链路、无线通信链路、等等)。因此,例如,信号承载介质1401可以由无线形式的通信介质1405(例如,遵守IEEE 802.14标准或者其它传输协议的无线通信介质)来传达。In some embodiments, the signal bearing medium 1401 may include a computer recordable medium 1404, such as, but not limited to, a memory, a read/write (R/W) CD, a R/W DVD, etc. In some embodiments, the signal bearing medium 1401 may include a communication medium 1405, such as, but not limited to, a digital and/or analog communication medium (e.g., a fiber optic cable, a waveguide, a wired communication link, a wireless communication link, etc.). Thus, for example, the signal bearing medium 1401 may be communicated by a wireless form of the communication medium 1405 (e.g., a wireless communication medium that complies with the IEEE 802.14 standard or other transmission protocol).

一个或多个程序指令1402可以是,例如,计算机可执行指令或者逻辑实施指令。在一些示例中,计算设备的计算设备可以被配置为,响应于通过计算机可读介质1403、计算机可记录介质1404、和/或通信介质1405中的一个或多个传达到计算设备的程序指令1402,提供各种操作、功能、或者动作。The one or more program instructions 1402 may be, for example, computer executable instructions or logic implementation instructions. In some examples, the computing device of the computing device may be configured to provide various operations, functions, or actions in response to the program instructions 1402 communicated to the computing device via one or more of the computer readable medium 1403, the computer recordable medium 1404, and/or the communication medium 1405.

应该理解,这里描述的布置仅仅是用于示例的目的。因而,本领域技术人员将理解,其它布置和其它元素(例如,机器、接口、功能、顺序、和功能组等等)能够被取而代之地使用,并且一些元素可以根据所期望的结果而一并省略。另外,所描述的元素中的许多是可以被实现为离散的或者分布式的组件的、或者以任何适当的组合和位置来结合其它组件实施的功能实体。It should be understood that the arrangement described here is only for illustrative purposes. Thus, it will be appreciated by those skilled in the art that other arrangements and other elements (e.g., machines, interfaces, functions, sequences, and functional groups, etc.) can be used instead, and some elements can be omitted together according to the desired result. In addition, many of the described elements can be implemented as discrete or distributed components, or in any appropriate combination and position to combine other components to implement functional entities.

所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统,装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

在本申请所提供的几个实施例中,应该理解到,所揭露的系统,装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.

所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器、随机存取存储器、磁碟或者光盘等各种可以存储程序代码的介质。If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory, a random access memory, a magnetic disk or an optical disk.

Claims (24)

1. A video processing method, applied to video capturing, the method comprising:
when a terminal is in a night scene shooting mode, detecting whether a lamplight area exists in an image shot by the terminal;
when a lamplight area exists in an image shot by the terminal, determining a first image in an image sequence acquired by the terminal, wherein the adjacent area of the lamplight area in the first image is overexposed;
Determining a second image and a third image in the image sequence according to the first image, wherein the acquisition time of the first image is between the acquisition time of the second image and the acquisition time of the third image, and the overexposure degree of the adjacent areas of the light areas in the second image and the third image is smaller than that of the adjacent areas of the light areas in the first image; wherein, the lamplight areas in the second image and the third image have a corresponding relation with the lamplight areas in the first image;
Generating a target image according to the first image, the second image and the third image, wherein the target image is used for replacing the first image, and the overexposure degree of the adjacent area of the lamplight area of the target image is smaller than that of the adjacent area of the lamplight area of the first image;
based on the target image, a video is generated.
2. The method according to claim 1, wherein the method further comprises:
When the illuminance of the ambient light is smaller than a first preset threshold value, the terminal enters a night scene shooting mode;
or when the terminal acquires an instruction for triggering to enter a night scene shooting mode, the terminal enters the night scene shooting mode.
3. A method according to claim 1 or 2, wherein the jitter displacement of the terminal when acquiring the first image is larger than a second preset threshold.
4. A method according to claim 3, wherein the ratio of the number of target pixels in the first image to the total number of pixels in the first image is within a predetermined range, the target pixels being pixels in a light area in the first image.
5. The method according to any of claims 1-2, wherein said determining a second image and a third image in said sequence of images from said first image comprises:
determining a stable value of each image in the image sequence, wherein the stable value is the inverse of the sum of the jitter value of the image and the acquisition time difference between the image and the first image;
determining an image with the largest stable value in the image sequence as the second image;
and determining the third image in the image sequence according to the acquisition time of the second image.
6. The method of claim 5, wherein determining the third image in the image sequence based on the time of acquisition of the second image comprises:
Determining one or more images in the image sequence according to the acquisition time of the second image, wherein the acquisition time of the first image is between the acquisition time of the second image and the acquisition time of the one or more images;
And determining an image with the largest stable value from the one or more images as the third image.
7. The method of any of claims 1-2, wherein the generating a target image from the first image, the second image, and the third image comprises:
Dividing the second image into a plurality of image blocks;
determining motion vectors respectively corresponding to the image blocks according to the first image and the third image;
And generating the target image according to the motion vectors respectively corresponding to the image blocks and the image blocks.
8. The method of claim 7, wherein determining motion vectors for the respective ones of the plurality of image blocks from the first image and the third image comprises:
Acquiring a plurality of candidate motion vectors corresponding to a first image block, wherein the plurality of image blocks comprise the first image block;
Determining a second image block and a third image block corresponding to each candidate motion vector in the plurality of candidate motion vectors according to the position of the first image block, wherein the first image comprises the second image block, and the third image comprises the third image block;
Determining a target error value corresponding to each candidate motion vector according to the first image block, the second image block and the third image block, wherein the target error value is obtained based on an error value between the first image block and the second image block and an error value between the first image block and the third image block;
And determining a motion vector with the minimum target error value from the plurality of candidate motion vectors as the motion vector corresponding to the first image block according to the target error value corresponding to each candidate motion vector.
9. The method of claim 8, wherein the plurality of candidate motion vectors comprises: one or more preset motion vectors, one or more motion vectors generated randomly, and/or motion vectors corresponding to image blocks adjacent to the first image block.
10. The method of claim 7, wherein the method further comprises:
if the target image has an area which cannot generate an image based on the plurality of image blocks, dividing the third image to obtain the plurality of image blocks of the third image;
Determining motion vectors respectively corresponding to a plurality of image blocks of the third image according to the first image and the second image;
And updating the target image according to the motion vectors corresponding to the image blocks of the third image and the image blocks of the third image to obtain a new target image, wherein the new target image is used for replacing the first image.
11. A video processing apparatus comprising a memory and a processor; the memory stores code, the processor being configured to execute the code, when executed, the video processing apparatus performing the method of any of claims 1 to 10.
12. A video processing apparatus, comprising:
the detection unit is used for detecting whether a light area exists in an image shot by the terminal when the terminal is in a night scene shooting mode;
the first determining unit is used for determining a first image in an image sequence acquired by the terminal when a lamplight area exists in the image shot by the terminal, and overexposure occurs in an adjacent area of the lamplight area in the first image;
A second determining unit, configured to determine a second image and a third image in the image sequence according to the first image, where an acquisition time of the first image is located between an acquisition time of the second image and an acquisition time of the third image, and an overexposure degree of a neighboring area of a light area in the second image and the third image is smaller than an overexposure degree of a neighboring area of the light area in the first image; wherein, the lamplight areas in the second image and the third image have a corresponding relation with the lamplight areas in the first image;
the image generation unit is further used for generating a target image according to the first image, the second image and the third image, wherein the target image is used for replacing the first image, and the overexposure degree of the adjacent area of the lamplight area of the target image is smaller than that of the adjacent area of the lamplight area of the first image;
and the video generating unit is also used for generating a video based on the target image.
13. The apparatus as recited in claim 12, further comprising: a control unit;
The control unit is used for: when the illuminance of the ambient light is smaller than a first preset threshold value, controlling the terminal to enter a night scene shooting mode; or when an instruction for triggering to enter the night scene shooting mode is acquired, controlling the terminal to enter the night scene shooting mode.
14. The apparatus according to claim 12 or 13, wherein the jitter displacement of the terminal when acquiring the first image is larger than a second preset threshold.
15. The apparatus of claim 14, wherein a ratio of a number of target pixels in the first image to a total number of pixels in the first image is within a preset range, the target pixels being pixels in a light area in the first image.
16. The apparatus according to any of the claims 12-13, wherein the second determining unit is further configured to: determining a stable value of each image in the image sequence, wherein the stable value is the inverse of the sum of the jitter value of the image and the acquisition time difference between the image and the first image; determining an image with the largest stable value in the image sequence as the second image; and determining the third image in the image sequence according to the acquisition time of the second image.
17. The apparatus of claim 16, wherein the second determining unit is configured to: determining one or more images in the image sequence according to the acquisition time of the second image, wherein the acquisition time of the first image is between the acquisition time of the second image and the acquisition time of the one or more images; and determining an image with the largest stable value from the one or more images as the third image.
18. The apparatus according to any one of claims 12-13, wherein the image generation unit is configured to: dividing the second image into a plurality of image blocks; determining motion vectors respectively corresponding to the image blocks according to the first image and the third image; and generating the target image according to the motion vectors respectively corresponding to the image blocks and the image blocks.
19. The apparatus of claim 18, wherein the image generation unit is configured to: acquiring a plurality of candidate motion vectors corresponding to a first image block, wherein the plurality of image blocks comprise the first image block; determining a second image block and a third image block corresponding to each candidate motion vector in the plurality of candidate motion vectors according to the position of the first image block, wherein the first image comprises the second image block, and the third image comprises the third image block; determining a target error value corresponding to each candidate motion vector according to the first image block, the second image block and the third image block, wherein the target error value is obtained based on an error value between the first image block and the second image block and an error value between the first image block and the third image block; and determining a motion vector with the minimum target error value from the plurality of candidate motion vectors as the motion vector corresponding to the first image block according to the target error value corresponding to each candidate motion vector.
20. The apparatus of claim 19, wherein the plurality of candidate motion vectors comprises: one or more preset motion vectors, one or more motion vectors generated randomly, and/or motion vectors corresponding to image blocks adjacent to the first image block.
21. The apparatus of claim 18, wherein the image generation unit is configured to: if the target image has an area which cannot generate an image based on the plurality of image blocks, dividing the third image to obtain the plurality of image blocks of the third image; determining motion vectors respectively corresponding to a plurality of image blocks of the third image according to the first image and the second image; and updating the target image according to the motion vectors corresponding to the image blocks of the third image and the image blocks of the third image to obtain a new target image, wherein the new target image is used for replacing the first image.
22. A terminal device, comprising a processor, a memory, a display screen, a camera, and a bus, wherein:
the processor, the display screen, the camera and the memory are connected through the bus;
the memory is used for storing a computer program and images acquired by the camera;
The processor is configured to control the memory, acquire a computer program stored on the memory and execute the program stored on the memory, and control the display screen to implement the method of any one of claims 1 to 10.
23. A computer readable storage medium comprising a program which, when run on a computer, causes the computer to perform the method of any one of claims 1 to 10.
24. A computer program product comprising instructions which, when run on a terminal, cause the terminal to perform the method of any of claims 1 to 10.
CN202110454370.2A 2021-04-26 2021-04-26 Video processing method and related device Active CN115334228B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN202110454370.2A CN115334228B (en) 2021-04-26 2021-04-26 Video processing method and related device
PCT/CN2022/087554 WO2022228196A1 (en) 2021-04-26 2022-04-19 Video processing method and related apparatus

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110454370.2A CN115334228B (en) 2021-04-26 2021-04-26 Video processing method and related device

Publications (2)

Publication Number Publication Date
CN115334228A CN115334228A (en) 2022-11-11
CN115334228B true CN115334228B (en) 2024-08-20

Family

ID=83846658

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110454370.2A Active CN115334228B (en) 2021-04-26 2021-04-26 Video processing method and related device

Country Status (2)

Country Link
CN (1) CN115334228B (en)
WO (1) WO2022228196A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118587415B (en) * 2024-05-22 2025-01-24 广州新华学院 A video target detection and tracking method and system based on artificial intelligence

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101098411A (en) * 2006-06-09 2008-01-02 三星电子株式会社 Image processing method and device for contrast enhancement
CN106851121A (en) * 2017-01-05 2017-06-13 广东欧珀移动通信有限公司 Control method and control device

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7636486B2 (en) * 2004-11-10 2009-12-22 Fotonation Ireland Ltd. Method of determining PSF using multiple instances of a nominally similar scene
US8204330B2 (en) * 2009-06-29 2012-06-19 DigitalOptics Corporation Europe Limited Adaptive PSF estimation technique using a sharp preview and a blurred image
CN104243844A (en) * 2013-06-06 2014-12-24 富士通株式会社 Image processor, image processing method and electronic equipment
CN104867111B (en) * 2015-03-27 2017-08-25 北京理工大学 A kind of blind deblurring method of non-homogeneous video based on piecemeal fuzzy core collection
CN105976332B (en) * 2016-05-03 2019-03-01 北京大学深圳研究生院 Image deblurring method based on bright fringes information in image
US10869645B2 (en) * 2016-06-14 2020-12-22 Stryker European Operations Limited Methods and systems for adaptive imaging for low light signal enhancement in medical visualization
CN107809582A (en) * 2017-10-12 2018-03-16 广东欧珀移动通信有限公司 Image processing method, electronic device and computer readable storage medium
CN108933897B (en) * 2018-07-27 2020-10-16 南昌黑鲨科技有限公司 Motion detection method and device based on image sequence
CN110971822A (en) * 2019-11-29 2020-04-07 Oppo广东移动通信有限公司 Image processing method, apparatus, terminal device, and computer-readable storage medium

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101098411A (en) * 2006-06-09 2008-01-02 三星电子株式会社 Image processing method and device for contrast enhancement
CN106851121A (en) * 2017-01-05 2017-06-13 广东欧珀移动通信有限公司 Control method and control device

Also Published As

Publication number Publication date
CN115334228A (en) 2022-11-11
WO2022228196A1 (en) 2022-11-03

Similar Documents

Publication Publication Date Title
KR102221023B1 (en) Electronic device and method for processing image
CN115473957B (en) Image processing method and electronic device
CN109559270B (en) Image processing method and electronic equipment
WO2021204103A1 (en) Picture preview method, electronic device, and storage medium
CN114596819A (en) Brightness adjustment method and related device
CN113572948B (en) Video processing method and video processing device
CN115334228B (en) Video processing method and related device
CN115359105A (en) Depth of field extended image generation method, device and storage medium
WO2025044350A1 (en) Image display method and electronic device
CN115150542A (en) Video anti-shake method and related equipment
CN114793283A (en) Image encoding method, image decoding method, terminal device, and readable storage medium
EP4529197A1 (en) Display method and related apparatus
CN116723410B (en) Method and device for adjusting frame interval
CN115437601B (en) Image sorting method, electronic device, program product and medium
CN116700578B (en) Layer synthesis method, electronic device and storage medium
WO2022170866A1 (en) Data transmission method and apparatus, and storage medium
CN116263971B (en) Image frame prediction method, electronic device and computer readable storage medium
CN113891008B (en) Exposure intensity adjusting method and related equipment
CN117917683A (en) Image rendering method and device
CN116347217A (en) Image processing method, device and storage medium
CN114630152A (en) Parameter transmission method, device and storage medium for image processor
CN116744118B (en) Method and device for determining shooting parameters
CN117082295B (en) Image stream processing method, equipment and storage medium
CN118446882B (en) Picture background and text color adaptation method and related device
CN116095512B (en) Photographing method of terminal equipment and related device

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
GR01 Patent grant
GR01 Patent grant