Video cutting method, device, electronic device, server and storage medium

Calculate pixel motion information from multi-frame images in the video to determine the target area and cropping line, which solves the problem of high computational complexity in video cropping in the existing technology, achieves efficient video cropping, and retains the moving target region in the video.

CN113269790BActive Publication Date: 2024-09-06BEIJING DAJIA INTERNET INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110324925.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-03-26
Publication Date
2024-09-06
Estimated Expiration
2041-03-26

AI Technical Summary

Technical Problem

The existing technology relies on deep learning neural network models during video cropping, which results in high computational complexity, consumes a large amount of computing resources, and is slow.

Method used

By extracting multiple frames of images in the video, calculating pixel motion information, determining the target area and cropping line, and then cropping the video. The area occupied by the target area in the cropped video exceeds the threshold, and the moving target area in the video is retained.

Benefits of technology

It reduces the computational complexity, improves the processing efficiency, does not rely on annotated sample data, can quickly shorten the processing time, and is suitable for video cropping.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113269790B
    Figure CN113269790B
Patent Text Reader

Abstract

The present disclosure discloses a video cropping method, device, electronic device, server and storage medium, which belongs to the field of image processing technology. The video cropping method includes extracting multiple frames of images in a video; determining pixel motion information in an image area of ​​the video based on the multiple frames of images; determining a target area in the image area based on the pixel motion information, wherein the target area is a distribution area of ​​target pixels in the image area, and the target pixels are pixels whose motion speed exceeds a first threshold; for at least one frame of image in the video, determining a cropping line in other areas of the image area except the target area; cropping the video through the cropping line to obtain a target video, and the target video at least includes the target area. The video cropping method, device, electronic device, server and storage medium provided by the present disclosure are adopted to at least solve the problem of high computational complexity when the neural network model is used to crop video images in the prior art.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the technical field of image processing, and in particular to a video cropping method, device, electronic device, server and storage medium. Background Art

[0002] Currently, when cropping images in a video, cropping is usually performed based on the detection results of objects in each video frame or the segmentation results of the content. When detecting objects or segmenting content, it is necessary to process them through a neural network model based on deep learning. Since the computational complexity of the neural network model is high, it will consume a lot of computing resources and the computing speed is also relatively slow. Summary of the invention

[0003] The purpose of the embodiments of the present disclosure is to provide a video cropping method, device, electronic device, server and storage medium to at least solve the problem of high computational complexity when cropping video images using a neural network model in the prior art.

[0004] The technical solution of the present disclosure is as follows:

[0005] According to a first aspect of an embodiment of the present disclosure, a video cropping method is provided, which may include:

[0006] Extract multiple frames of images from the video;

[0007] Determine pixel motion information in an image region of a video according to the multiple frames of images, wherein the pixel motion information is used to represent the motion speed of multiple pixels in two frames of images;

[0008] Determine a target area in the image area according to the pixel motion information, wherein the target area is a distribution area of ​​target pixels in the image area, and the target pixels are pixels whose motion speed exceeds a first threshold;

[0009] For at least one frame of the video, a cropping line is determined in other areas of the image area except the target area;

[0010] The video is cropped using the cropping line to obtain a target video, so that the area occupied by the target region in the target video exceeds a second threshold.

[0011] In one embodiment, extracting multiple frames of images from a video includes: extracting n consecutive frames of images from the video, where n is an integer greater than 1;

[0012] According to multiple frames of images, pixel motion information in an image area of ​​a video is determined, including: for every two adjacent frames of n frames of images, optical flows of multiple pixel points in the image area are calculated to obtain n-1 frames of optical flow fields, wherein the optical flow fields are used to represent pixel motion information.

[0013] Based on this, in one embodiment, before calculating the optical flow of multiple pixels in the image area for every two adjacent images in the n frames of images to obtain the n-1 frame of optical flow field, the method further includes:

[0014] Convert n frames of images into grayscale images to obtain n frames of grayscale images;

[0015] Accordingly, for every two adjacent frames in the n frames, the optical flow of multiple pixels in the image area is calculated to obtain the n-1 frame optical flow field, which specifically includes:

[0016] For every two adjacent frames of n frames of grayscale images, the optical flow of multiple pixels in the image area is calculated to obtain an n-1 frame optical flow field.

[0017] Based on this, in one embodiment, the optical flow field is used to represent the motion speed of each pixel in two adjacent frames of images among a plurality of pixels, and the target area is determined in the image area according to the pixel motion information, including:

[0018] In each frame of the optical flow field, determine the target pixel in the image area;

[0019] Synthesize the distribution of target pixels in the n-1 frames of optical flow field to obtain a synthetic distribution of target pixels in the image area;

[0020] According to the composite distribution of the target pixels in the image region, a target region is determined in the image region.

[0021] Based on this, in one of the embodiments, determining the target area in the image area according to the composite distribution of the target pixels in the image area includes:

[0022] According to the synthetic distribution of the target pixels in the image area, the image area is segmented by a preset image area segmentation method to divide the image area into at least two areas;

[0023] Among the multiple regions, a region where the density of target pixels exceeds a third threshold is determined to obtain a target region, wherein the density is used to represent a ratio of the number of target pixels to the number of pixels in the corresponding region.

[0024] In one of the embodiments, for at least one frame of an image in a video, determining a cropping line in other regions of the image region except a target region includes:

[0025] Extract m frames of images from the video;

[0026] For each of the m frames, a Hough line detection algorithm is used to detect Hough lines in other areas outside the target area.

[0027] Generate a cropping line based on the Hough straight line detected from the m-frame image.

[0028] Based on this, in one embodiment, generating a cropping line according to the Hough straight line detected from the m frames of images includes:

[0029] Compare the Hough lines detected in the m-frame images to determine the lines with overlapping positions in the m-frame images;

[0030] The cropping lines are determined based on the overlapping straight lines.

[0031] Optionally, in another embodiment, generating a cropping line according to the Hough straight line detected from the m frames of images includes:

[0032] Get the parameters of each detected Hough line;

[0033] Select the Hough line whose parameters are within the preset parameter range to obtain the target Hough line;

[0034] Determine the cropping line based on the target Hough line.

[0035] According to a second aspect of an embodiment of the present disclosure, a video cropping device is provided, which may include:

[0036] A first extraction module is configured to extract multiple frames of images from a video;

[0037] A pixel motion information determination module is configured to determine pixel motion information in an image region of a video based on multiple frames of images, wherein the pixel motion information is used to represent a motion speed of multiple pixels in two frames of images;

[0038] A target region determination module is configured to determine a target region in the image region according to pixel motion information, wherein the target region is a distribution region of target pixels in the image region, and the target pixels are pixels whose motion speed exceeds a first threshold;

[0039] A cropping line determination module is configured to determine a cropping line in other areas of the image area except the target area for at least one frame of the image in the video;

[0040] The cropping module is configured to crop the video through the cropping line to obtain the target video, so that the area occupied by the target area in the target video exceeds a second threshold.

[0041] In one embodiment, the first extraction module includes: a second extraction module configured to extract n consecutive frames of images in the video, where n is an integer greater than 1;

[0042] The pixel motion information determination module includes: a first calculation module, which is configured to calculate the optical flow of multiple pixel points in the image area for every two adjacent frames of n frames of images to obtain n-1 frames of optical flow fields, wherein the optical flow field is used to represent pixel motion information.

[0043] In one embodiment, the device further comprises:

[0044] A conversion module is configured to convert the n frames of images into grayscale images before calculating the optical flows of a plurality of pixels in the image region for every two adjacent frames of the n frames of images to obtain n-1 frames of optical flow fields, thereby obtaining n frames of grayscale images;

[0045] Accordingly, the first calculation module specifically includes:

[0046] The second calculation module is configured to calculate the optical flow of multiple pixels in the image area for every two adjacent frames of the n frames of grayscale images to obtain an n-1 frame of optical flow field.

[0047] In one embodiment, the optical flow field is used to represent the movement speed of each pixel in two adjacent frames of images among a plurality of pixels, and the target area determination module includes:

[0048] A target pixel determination module is configured to determine a target pixel in an image region in each frame of the optical flow field after obtaining n-1 frames of the optical flow field;

[0049] A synthesis module is configured to synthesize the distribution of target pixels in the n-1 frames of optical flow fields to obtain a synthetic distribution of target pixels in the image area;

[0050] The target region determination submodule is configured to determine the target region in the image region according to the synthetic distribution of the target pixels in the image region.

[0051] In one embodiment, the target area determination submodule includes:

[0052] A segmentation module is configured to perform region segmentation on the image region by a preset image region segmentation method according to the synthetic distribution of target pixels in the image region, so as to divide the image region into at least two regions;

[0053] The region determination submodule is configured to determine, among multiple regions, a region where the density of target pixels exceeds a third threshold to obtain a target region, wherein the density is used to represent the ratio of the number of target pixels to the number of pixels in the corresponding region.

[0054] In one embodiment, the cutting line determination module includes:

[0055] A third extraction module is configured to extract m frames of images from the video;

[0056] The detection module is configured to detect Hough lines in other areas outside the target area by using a Hough line detection algorithm for each of the m frames of images;

[0057] The generation module is configured to generate a cropping line according to the Hough straight line detected from the m frames of images.

[0058] In one embodiment, the generating module includes:

[0059] A comparison module is configured to compare the Hough lines detected between every two frames of the m frames of images to determine the overlapping lines between every two frames of the m frames of images;

[0060] The first cutting line determination submodule is configured to determine the cutting line according to the straight lines with overlapping positions.

[0061] In one embodiment, the generating module includes:

[0062] An acquisition module is configured to acquire parameters of each detected Hough line;

[0063] A selection module is configured to select a Hough line with parameters within a preset parameter range to obtain a target Hough line;

[0064] The second cropping line determination submodule is configured to determine the cropping line according to the target Hough line.

[0065] According to a third aspect of an embodiment of the present disclosure, a server is provided, which may include:

[0066] processor;

[0067] a memory for storing processor-executable instructions;

[0068] The processor is configured to execute instructions to implement the video cropping method as shown in any one of the embodiments of the first aspect.

[0069] According to a fourth aspect of an embodiment of the present disclosure, an electronic device is provided, which may include:

[0070] processor;

[0071] a memory for storing instructions executable by the processor;

[0072] The processor is configured to execute the instructions to implement the video cropping method as shown in any one of the embodiments of the first aspect.

[0073] According to a fourth aspect of an embodiment of the present disclosure, a storage medium is provided. When instructions in the storage medium are executed by a processor of a video cropping device or a server, the video cropping device or the server implements a video cropping method as shown in any one of the embodiments of the first aspect.

[0074] According to a fifth aspect of an embodiment of the present disclosure, a computer program product is provided, which includes a computer program stored in a readable storage medium, and at least one processor of a device reads and executes the computer program from the storage medium, so that the device executes the video cropping method shown in any one of the embodiments of the first aspect.

[0075] The technical solution provided by the embodiments of the present disclosure brings at least the following beneficial effects:

[0076] The disclosed embodiment determines pixel motion information in an image area of ​​a video based on multiple frames of images extracted from the video, and uses a pixel motion speed exceeding a first threshold as a basis for dividing the image area of ​​the video into a target area, and then determines a cropping line outside the target area to crop the video. The cropped video includes the target area, so that the area in the video where there is a moving target can be retained, thereby retaining some useful image areas in the video. Compared with the solution of cropping videos based on deep learning, the disclosed embodiment has lower computational complexity and does not rely on labeled sample data. It only needs to compare images of different frames in the video to calculate pixel motion information, thereby determining the area that needs to be retained for cropping. Therefore, the processing efficiency is high and the processing time can be shortened.

[0077] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0078] The drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute improper limitations on the present disclosure.

[0079] Figure 1 is a flow chart of a video cropping method according to an exemplary embodiment;

[0080] Figure 2 is a flow chart of another video cropping method according to an exemplary embodiment;

[0081] Figure 3 is a diagram showing an application scenario of a video cropping method according to an exemplary embodiment;

[0082] Figure 4 is a schematic diagram of an application scenario of another video cropping method according to an exemplary embodiment;

[0083] Figure 5 is a flow chart of another video cropping method according to an exemplary embodiment;

[0084] Figure 6 is a structural block diagram of a video cropping device according to an exemplary embodiment;

[0085] Figure 7 It is a structural block diagram of a computing device according to an exemplary embodiment. DETAILED DESCRIPTION

[0086] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings.

[0087] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure 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 interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.

[0088] The video cropping method provided in the present disclosure can be executed by an electronic device, wherein the electronic device can be a mobile phone, a tablet computer, an all-in-one device with communication functions, or a device simulated by a virtual machine or a simulator, or a laptop computer, a server, a workstation and other devices with computing capabilities, wherein the server can be a cloud server or a server cluster and other devices with storage and computing functions.

[0089] Figure 1 A flowchart of an optional embodiment of the video cropping method provided in the embodiment of the present disclosure is shown as follows: Figure 1 As shown, the video cropping method provided in this embodiment may include the following steps:

[0090] Step 101: extract multiple frames of images from a video.

[0091] The disclosed embodiment is used to crop the image area of ​​a video, so it is sufficient to process the image frames in the video, and the audio information in the video is not processed. The video in step 101 refers to the video to be cropped, and the video includes multiple frames of ordered images. Some image frames are extracted from the image sequence to perform step 102.

[0092] As an optional embodiment, continuous n frames of images may be extracted, where n is an integer greater than 1. For example, if the video to be cropped includes 200 frames of images, the images of the 50th to 60th frames of the video may be extracted. Since the video is continuous, extracting multiple continuous frames of images in the video may help the next step of obtaining pixel motion information in multiple frames of images, and the obtained pixel motion information may more accurately reflect the motion of the pixels.

[0093] Step 102: Determine pixel motion information in an image region of a video based on multiple frames of images.

[0094] The image resolution of all image frames in the video is the same. Specifically, in each frame of the video, the number of pixels in each row is the same, and the number of pixels in each column is the same. The image area of ​​the video refers to the entire display area of ​​the image in the video.

[0095] Pixel motion information is used to indicate the movement speed of multiple pixels in two frames of images. In the image, the movement of an object is represented by the movement of pixels, wherein the object can be an actual object existing in space, such as an object appearing in a video captured by a camera, or a virtual object, for example, a produced animation, or text, special effects animation, etc. added to a captured photo. Whether it is a virtual object or a real object, the change in the pixel value of the corresponding pixel of the object between different frames of images can be used to represent the motion information of the corresponding pixel. As an optional embodiment, the pixel motion information can be determined by two adjacent frames of images. In addition, the multiple pixels can be all pixels in the image area, or they can also be part of the pixels in the image area.

[0096] When determining the pixel motion information of multiple pixels in two frames of images, an optional implementation is to directly subtract the pixel values ​​of two pixels at the same position in the two frames of images. In this way, the computational efficiency of the step of calculating the pixel motion information can be improved and the computational intensity can be reduced. Specifically, each frame of image can be regarded as a matrix of pixels. Since the image resolution of all image frames in the video is the same, the matrix size of all image frames in the video is also the same. For example, they are all matrices of 1280×720 pixels. Then, when subtracting two image frames, they can be regarded as two pixel matrices for subtraction, and subtraction is performed on the elements at the same position in the two matrices (each element is used to represent the corresponding pixel). Then, the result obtained by subtraction is used to represent the pixel motion information.

[0097] For two pixels at the same position in two images, the corresponding pixel values ​​are subtracted when subtracting. In the video, all image frames represent the pixel value of each pixel in each frame of the image in the same color mode. Depending on the color mode, the pixel value can be expressed in different recording methods. For example, in the RGB color mode, the pixel value of each pixel includes the values ​​of the three primary colors of red (R), green (G), and blue (B). The strength of the corresponding primary color is represented by the value, and the color displayed by the pixel is the superposition of the three primary colors according to the corresponding intensity; or, in the grayscale mode, the pixel value of each pixel can use only one value to represent the grayscale strength information. For example, the pixel value can be any integer between 0 and 255 (including the end value), 255 represents white, and 0 represents black. When a pixel value is represented by multiple numerical values, subtracting the pixel values ​​of two pixels means subtracting the numerical values ​​of the same components to obtain the numerical value. For example, in the RGB color mode, the pixel value of the pixel at the first position in the first image (the first pixel) is (15, 100, 70), and the pixel value of the pixel at the first position in the second image (that is, the same position as the first pixel in the first image) (the second pixel) is (30, 90, 65). Then the difference obtained by subtracting the first pixel from the second pixel is (-15, 10, 5). An optional example is that the relative movement of the pixel at the first position in the first image relative to the pixel at the first position in the second image is represented by this difference to reduce the computational pressure.

[0098] Optionally, in another embodiment, the pixel motion information can also be obtained by calculating the optical flow through an optical flow field algorithm. The basic principle of the optical flow field algorithm is to use the changes in the pixels in the image sequence in the time domain and the correlation between adjacent frames to find the correspondence between the pixels in adjacent frames, that is, for the adjacent first frame image and the second frame image, a pixel point in the first frame image corresponds to which pixel point in the next frame image; then, after determining the correspondence, the motion information of the pixels between the two adjacent frames of images can be calculated. Depending on the specific calculation principle, the optical flow field algorithm may include a gradient-based method, a matching-based method, an energy-based method, a phase-based method, and the like.

[0099] The pixel motion information can be determined by the optical flow field algorithm. One example is that the direct result calculated by the optical flow field algorithm is the optical flow field. The optical flow field is a two-dimensional vector field. For the optical flow field obtained by calculating the first frame image to the second frame image by the optical flow field algorithm, the element of each coordinate position in the optical flow field is a two-dimensional optical flow vector, corresponding to the pixel at the corresponding coordinate position in the first frame image, which can be used to represent the movement speed (including size and direction) of the corresponding pixel from the first frame image to the second frame image in two dimensions, and the two dimensions represent the movement speed in the x-axis direction and the y-axis direction on the image plane, respectively. In other words, when the time interval between two adjacent frames of images is the unit time of the motion speed, the vector size and direction of the optical flow vector are the same as the size and direction of the displacement vector of the pixel point at the corresponding position in the two adjacent frames of images.

[0100] Since the optical flow algorithm can find the corresponding relationship between the pixels of two frames of images, that is, it can find the position of the same pixel between the two frames of images, it can determine the movement of the same pixel with a corresponding relationship between the two frames of images. Therefore, it can be seen that by calculating the optical flow field with the optical flow algorithm to represent the pixel motion information, the relative motion information of the pixels of the two frames of images can be described more accurately.

[0101] Optionally, when calculating the optical flow field, the image represented by the non-grayscale mode can be converted into a grayscale image first, so as to determine the optical flow vector according to the instantaneous rate of change of the grayscale value (the pixel value of each pixel in the grayscale image). Since the pixel value in the grayscale image is a one-dimensional value, compared with an image using a vector with more dimensions to represent the pixel value, calculating the optical flow vector through the grayscale image can reduce the amount of calculation and the complexity of the operation.

[0102] Specifically, when executing step 101 to extract multiple frames of images in the video, specifically, n consecutive frames of images can be extracted from the video, where n is an integer greater than 1. Correspondingly, when executing step 102 to determine the pixel motion information in the image area of ​​the video based on the multiple frames of images, the optical flow of multiple pixels in the image area can be calculated for every two adjacent frames in the n frames of images to obtain n-1 frames of optical flow field, where the optical flow field is used to represent the pixel motion information.

[0103] Further, such as Figure 2 As shown, in an example of an embodiment of the present disclosure, before calculating the optical flow of multiple pixels in the image area for every two adjacent images in n frames of images to obtain n-1 frames of optical flow fields, the method may also include step 1021: converting the n frames of images into grayscale images to obtain n frames of grayscale images.

[0104] Accordingly, when calculating the optical flow of multiple pixels in the image region for every two adjacent images in the n-frame images to obtain the n-1 frame optical flow field, it can be specifically implemented by executing step 1022, step 1022: for every two adjacent images in the n-frame grayscale images, calculating the optical flow of multiple pixels in the image region to obtain the n-1 frame optical flow field. That is, one frame of optical flow field can be obtained for every two adjacent grayscale images, and accordingly, n-1 frame of optical flow field can be obtained through n-frame images.

[0105] Step 103: determining a target area in the image area according to the pixel motion information.

[0106] The target area is the distribution area of ​​the target pixels in the image area, and the target pixels are pixels whose motion speed exceeds the first threshold value. It should be noted that the target area is an area including the target pixels, and is the area where the target pixels are distributed. In some optional examples, in addition to the target pixels, the target area may also include other pixels whose motion speed does not exceed the first threshold value. In other optional examples, other areas in the image area except the target area may also include some target pixels in addition to other pixels except the target pixels. The division of the specific target area can be determined according to a preset division method. For example, the distribution density of the target pixels can be determined by presetting specified conditions, and the area with dense distribution of target pixels can be used as the target area.

[0107] In order to make the video cropping more accurate, in one of the embodiments, a dense optical flow field can be calculated by a dense tracking optical flow field algorithm. Dense tracking is an image registration method that performs point-by-point matching on an image or a specified area. This method calculates the offset of all points on the image to form a dense optical flow field. Through this dense optical flow field, pixel-level image registration can be performed. Depending on the density of two-dimensional vectors in the optical flow field, the optical flow field algorithm may include dense tracking and sparse tracking. Sparse tracking does not perform point-by-point calculations on each pixel of the image. A set of points can be specified in the image for tracking. This set of points preferably has some obvious characteristics, such as Harris corners, etc. Although the computational overhead of sparse tracking is smaller than that of dense tracking, the result of dense tracking is more accurate. The embodiment of the present disclosure takes the calculation of dense optical flow by a dense tracking optical flow field algorithm as an example to illustrate an optional specific implementation process of step 103.

[0108] When the optical flow field is used to represent the motion speed of each pixel in two adjacent frames of images, that is, when the optical flow field is a dense optical flow field, step 103 determines the target area in the image area according to the pixel motion information, which may include the following steps 1031 to 1033:

[0109] Step 1031, after obtaining n-1 frames of optical flow fields, determine the target pixel in the image area in each frame of the optical flow field.

[0110] According to the definition of the target pixel, the target pixel is screened in the image area by whether the motion speed exceeds the first threshold. Since the optical flow field includes a two-dimensional vector for representing the motion speed in the x-axis direction and the y-axis direction, the first threshold can be a numerical value, and the same numerical value is set for both directions. Specifically, for the optical flow at the coordinate position of a pixel in a frame of the optical flow field, if the magnitude of the motion speed vector in the x-axis direction exceeds the first threshold, and the magnitude of the motion speed vector in the y-axis direction exceeds the first threshold, then the pixel position is determined to be the target pixel. It should be noted that for each frame of the optical flow field, the target pixels distributed in the frame can be obtained. For n-1 frames of the optical flow field, the target pixels distributed in each frame can be obtained respectively.

[0111] Step 1032, synthesize the distribution of target pixels in the n-1 frame optical flow field to obtain a synthesized distribution of target pixels in the image area.

[0112] In order to more accurately determine the area with relatively violent motion in the video according to the distribution of target pixels, the distribution of target pixels in the n-1 frame may be superimposed to synthesize the target pixels appearing in the n-1 frame in the image area.

[0113] In an optional example, each pixel position in the image area can be represented by a numerical value to represent the number of times the target pixel appears at the pixel position in the n-1 frame optical flow field. For example, if a pixel position (x1, y1) is judged as a target pixel in p (p≤n-1) frames of optical flow field, the numerical value of the pixel position can be p. By analogy, the number of times the target pixel appears in the n-1 frame optical flow field for all pixel positions in the image area can be obtained, so that the synthetic distribution of the target pixels is described by this matrix. Alternatively, in another optional example, the number of occurrences of the target pixel may not be counted, and only a binary judgment is made on whether a coordinate position has appeared in the n-1 frame optical flow field. If it has appeared, it is marked as 1, and if it has not appeared, it is marked as 0. The synthetic distribution of the target pixel is described by this binary matrix with elements of 0 or 1.

[0114] Step 1033, determining a target area in the image area according to the synthetic distribution of the target pixels in the image area.

[0115] After determining the synthetic distribution of the target pixels according to the n-1 frame optical flow field, the target area can be determined in the image area.

[0116] When determining the target area, the image area can be divided by different division methods. In an optional embodiment, step 1033 determines the target area in the image area according to the synthetic distribution of the target pixels in the image area, which can include the following steps 1331 to 1332:

[0117] Step 1331 , according to the synthetic distribution of target pixels in the image region, perform region segmentation on the image region by using a preset image region segmentation method, so as to divide the image region into at least two regions.

[0118] The preset image segmentation method is used to segment the image region into at least two mutually non-intersecting regions. The target number of regions segmented by the preset image segmentation method may be a specified number, or may be to minimize the number of regions obtained by segmentation.

[0119] In an optional implementation, the goal of the preset image segmentation method may be to make the distribution of target pixels in each region reach a certain density. The preset image segmentation method may include a threshold-based segmentation method, a region-based segmentation method, an edge-based segmentation method, and a segmentation method based on a specific theory.

[0120] For example, a region-based segmentation method may be used, and the region-based segmentation method may be further subdivided into a region growing-based method or a region splitting and merging-based method. The following takes region growing as an example to illustrate the process of segmenting image regions.

[0121] First, a random pixel is selected in the image area as the first seed pixel. If the first seed pixel is the target pixel, the first seed pixel is used as the starting point of the first region growth, and within the first range centered on the first seed pixel (such as a 5×5 area), the following conditions are used to determine whether to grow: if there are target pixels exceeding the fourth threshold (such as 2), the specified range is divided into the first region; otherwise, the growth of the first seed pixel is stopped.

[0122] Next, each pixel newly divided into the first region is used as a new seed pixel, and the judgment is continued according to the above conditions, and the iteration is repeated until there is no seed pixel that meets the above conditions. At this point, the growth of the first region is completed.

[0123] After the first region is grown, a pixel is randomly selected from the region other than the first region in the image region as the second seed pixel. If the second seed pixel is the target pixel, the second seed pixel is used as the starting point for the growth of the second region, and the second region continues to grow according to a growth process similar to that of the first region. If the second seed pixel is not the target pixel, the judgment condition can be changed to: within a second range (for example, within an area of ​​7×7) centered on the second seed pixel, if there are target pixels exceeding a fifth threshold (for example, 10), the growth is stopped; otherwise, the second range is divided into the second region, and each pixel within the second range is used as a new seed pixel, and the judgment logic of the growth is continued.

[0124] By the above method, after all the image regions are grown, the segmentation result of the image region can be obtained, and the image region is divided into at least two regions.

[0125] Step 1332: Determine, among the multiple regions, a region where the density of the target pixel exceeds a third threshold value to obtain the target region.

[0126] Density is used to represent the ratio of the number of target pixels to the number of pixels in the corresponding area. Among multiple areas, the area where the density of target pixels exceeds the third threshold is determined. The third threshold can be pre-specified, or multiple areas can be sorted according to the density, and the first q areas are selected as target areas, where q is a pre-specified positive integer, at least greater than or equal to 1 and less than or equal to the number of areas after the image area is segmented. The target area is the area to be retained. Usually, the valid information in the video is moving. Therefore, the area to be retained is determined in the image area based on the motion speed information. Compared with methods based on deep learning, the calculation complexity is lower and the calculation speed is faster while meeting a certain accuracy.

[0127] Step 104 : for at least one frame of image in the video, determine a cropping line in other areas of the image area except the target area.

[0128] Since the target area is the area to be retained, the cropping line can be determined in other areas outside the target area. An optional implementation is to use the set of target pixel locations as the target area. In this way, other areas other than the target area refer to the set of pixel locations other than the target pixel in the image area. In this case, other areas may include scattered target pixels. For example, Figure 3 As shown, in the image area 301 of the video, there are target areas 302 and 303, as well as several identified target pixels. Another optional implementation is to obtain the target area after segmenting the image area through steps 1331 to 1332, thereby obtaining a more continuous target area than directly using the set of target pixel locations as the target area.

[0129] The cropping line is determined in other areas of the image area except the target area. An optional implementation is to detect straight lines in other areas. Since the detected straight lines may include interference lines, different screening conditions can be set according to different targets of the cropped video to determine the cropping line in the detected straight lines. The straight line detection method can use the Hough Line Detection method or the Level-Line Field (LSD) line detection method.

[0130] Taking the Hough line detection method as an example, step 104 determines a cropping line in other areas of the image area except the target area for at least one frame of the video, including:

[0131] Step 1041, extracting m frames of images from the video;

[0132] It should be noted that the step of extracting m frames of images may be a step independent of step 101, that is, the extracted m frames of images are not identical to the multiple frames of images extracted in step 101. In addition, the extracted m frames of images may also be discontinuous. Of course, as an optional implementation, the extracted m frames of images may be the same images as the images extracted in step 101, and in this case, step 1041 may be deleted, which may facilitate processing and reduce the complexity of the operation process.

[0133] Step 1042 , for each of the m frames of images, a Hough line detection algorithm is used to detect Hough lines in other areas outside the target area.

[0134] The Hough line detection algorithm can detect straight lines in an image and determine the cropping line based on the detected straight lines. The straight lines that naturally appear in the image can be used as cropping lines to find a cropping line that better suits the characteristics of the video content.

[0135] Specifically, the Hough line detection algorithm can use different specific implementations, for example, detecting Hough lines based on a line coordinate parameter space, or detecting lines based on a polar coordinate parameter space. The detected Hough lines are described by the expression of the corresponding parameter space.

[0136] Step 1043: Generate a cropping line based on the Hough lines detected from the m frames of images.

[0137] After detecting the Hough lines of each frame in the m-frame image, a cropping line is generated according to the Hough lines detected in the m-frame image. An optional example is to use the Hough lines detected near the same position in the m-frame image as the cropping line. Another optional example is to select a Hough line that meets a preset condition from all the Hough lines, for example, to select a Hough line whose parameters are within a preset parameter range as the cropping line.

[0138] Based on this, an optional specific implementation is provided. Step 1043 generates a cropping line according to the Hough lines detected from the m frames of images, which may include the following steps:

[0139] Step 41, comparing the Hough lines detected between every two frames of the m frames of images to determine the overlapping lines between every two frames of the m frames of images;

[0140] Step 42, determining a cutting line according to the straight lines that overlap.

[0141] The overlapping straight lines are Hough lines that are close in position in at least two frames of images. Close in position means that the position difference meets a preset condition. Specifically, when the Hough lines are represented by parameters, the difference in the parameters of the overlapping straight lines is within a third range.

[0142] For example, the linear coordinate parameters of the first Hough line in the first frame image are (a1, b1), where a1 is the slope of the first Hough line and b1 is the intercept of the first Hough line, and the linear coordinate parameters of the second Hough line in the second frame image are (a2, b2), where a2 is the slope of the second Hough line and b2 is the intercept of the second Hough line. If |a1-a2| is less than the fifth threshold value, and |b1-b2| is less than the sixth threshold value, it can be considered that the first Hough line and the second Hough line are lines with overlapping positions in the two frames of images, that is, the two Hough lines are near the same position in the image area.

[0143] After all the overlapping straight lines in the m-frame images are determined, the overlapping straight lines can be divided into at least one group according to their positions, and each group of overlapping straight lines is near the same position. Then, for each group of overlapping straight lines, the parameters of all Hough lines in the group can be averaged, so that each group of straight lines can obtain the parameters of a straight line (that is, the cropping line), and there are several cropping lines for several groups of overlapping straight lines.

[0144] Optionally, in another specific embodiment, step 1043 generates a cropping line according to the Hough lines detected from the m frames of images, which may include the following steps:

[0145] Step 43, obtaining the parameters of each detected Hough line;

[0146] Step 44, selecting a Hough line whose parameters are within a preset parameter range to obtain a target Hough line;

[0147] Step 45, determining the cutting line according to the target Hough line.

[0148] In this case, since the preset parameter range is pre-set, the target Hough lines that meet the conditions can be directly screened out from the detected Hough lines. For example, if the goal is to obtain a rectangular video after cropping the original video, then the preset parameter range can be all Hough lines with a slope of 0 or 1, so that the image area of ​​the cropped video is a rectangle.

[0149] In this way, by determining the cropping line outside the target area, the accuracy of the cropping line can be improved. Moreover, since there is no need to perform calculations within the target area, the amount of calculations required to detect the cropping line can be reduced. The cropping line can be directly detected in other areas that move more smoothly than the target area, thereby improving the calculation speed and reducing the occupancy of the computing resources of the electronic device.

[0150] Step 105, cropping the video using the cropping line to obtain a target video.

[0151] The target video at least includes a portion of the target area. Furthermore, the area occupied by the target area in the target video exceeds a second threshold. This is because in some optional implementations, the edge of the target area may be an irregular shape, so that the calculated clipping line may intersect with the target area. Therefore, when clipping according to the clipping line, there may be a situation where the target area cannot be completely retained in the target video.

[0152] An optional example is that for two areas cut out by a cropping line, the area size of the target area contained in each of the two areas can be calculated respectively, and the part of the image area containing most of the target area is retained (which can be regarded as taking the area value of the area with a smaller area as the second threshold), and the part containing a small part of the target area is deleted. After cutting through all the cropping lines, the retained part of the image area is obtained. Furthermore, each frame of the video can be cropped according to the edge of the retained part to obtain the target video.

[0153] The disclosed embodiment determines the pixel motion information in the image area of ​​the video based on multiple frames of images extracted from the video, and uses the pixel motion speed exceeding the first threshold as the basis for dividing the target area in the image area of ​​the video, and then determines the cropping line outside the target area, and then crops the video. The cropped video includes the above-mentioned target area, so that the area where the moving target exists in the video can be retained, and the useful part of the image area in the video is retained. Compared with the solution of cropping the video based on deep learning, the computational complexity of the disclosed embodiment is low, and it does not rely on the labeled sample data. It only needs to compare the images of different frames in the video to calculate the pixel motion information, so as to determine the area that needs to be retained for cropping. Therefore, the processing efficiency is high and the time consumption of the processing process can be shortened. In addition, the disclosed embodiment can only extract a small number of partial image frames to determine the cropping position of the entire video, which reduces the operation combination for determining the cropping position and improves the efficiency of cropping the video.

[0154] Based on the video cropping method provided by the embodiment of the present disclosure, in an application scenario, a "three-segment" video can be cropped. Figure 4 Shown is an optional example, the characteristic of this video is that the image area 401 is a vertical rectangle, which is more suitable for the user's habit of watching on the mobile phone screen, and the video is divided into three parts (hereinafter referred to as segments) of upper, middle and lower. In the image area of ​​the video, the middle area 402 is usually used to show the content intended to be shown by the user who made the video, for example, dances, life fragments, etc. shot by the user, while the upper area 401 and the lower area 403 may be set by the user who made the video to configure the background picture with descriptive text; or, in other embodiments, it can also be the video content obtained by blurring the content of the middle area by blurring (such as Gaussian blur method) by the user who made the video. Therefore, the movement of the content object in the middle area of ​​this "three-segment" video is usually not obvious, while the movement of the content object in the middle area is relatively violent. In this application scenario, the goal of video cropping is to retain the middle area and delete the areas of the upper and lower sections, so that the video that is more suitable for vertical screen viewing becomes a video that is more suitable for horizontal screen viewing.

[0155] Taking the above application scenario as an example, a specific implementation of the embodiment of the present disclosure is described in detail, which may include: Figure 5 The following steps are shown:

[0156] Step 501: extract multiple consecutive frames of images from the video. For example, 10 frames of images in the middle of the video may be extracted.

[0157] Step 502, calculate the optical flow field of every two adjacent frames. The optical flow field can obtain an optical flow field with one frame less than the number of extracted image frames. For example, extracting 10 frames of images can obtain 9 frames of optical flow field. The optical flow field includes multiple two-dimensional vectors, each of which corresponds to a pixel at a corresponding coordinate position of the image area of ​​the video, and is used to represent the movement speed of the pixel at the corresponding coordinate position in the x-axis and y-axis directions respectively.

[0158] Step 503, according to the optical flow field, determine the target pixel in the image area of ​​the video. The target pixel is a pixel whose motion speed is greater than a first threshold. In an optional example, the first threshold can be set to 0. Depending on whether it is a target pixel, the image area of ​​the video can be divided into two areas: a first area and a second area. The first area is a set of coordinate positions of the target pixel, that is, the target area, and the second area is a set of pixel coordinate positions other than the target pixel, that is, other areas outside the target area.

[0159] Step 504 : In each frame of the image extracted in step 501 , detect Hough lines for other regions.

[0160] Step 505 , counting the positions of the Hough lines detected in the multiple frames of images, and determining the cropping line according to the statistical results.

[0161] Step 506, cropping the video using the cropping line to retain most of the target area to obtain the target video.

[0162] For the parts not described in detail in the specific embodiments of this application scenario, please refer to Figure 1 to Figure 3 The description of the illustrated embodiment will not be repeated here.

[0163] pass Figure 5 The video cropping method provided in the illustrated embodiment can crop the above-mentioned "three-segment" video by using the optical flow field to determine the area with more intense motion in the video, and use the Hough line detection algorithm to find the position of the dividing line that divides the video into multiple segments in the "three-segment" video in the image, so as to use the found qualified straight line to crop the video, divide the video into three segments, and retain the area with more intense motion in the "three-segment" video, thereby achieving the cropping purpose.

[0164] It should be noted that the application scenarios described in the above-mentioned embodiments of the present disclosure are intended to more clearly illustrate the technical solutions of the embodiments of the present disclosure, and do not constitute a limitation on the technical solutions provided by the embodiments of the present disclosure. Ordinary technicians in this field can know that with the emergence of new application scenarios, the technical solutions provided by the embodiments of the present disclosure are also applicable to similar technical problems.

[0165] Based on the same inventive concept, the present disclosure also provides a video cropping device. Figure 6 Provide detailed explanation.

[0166] Figure 6 The figure is a schematic structural diagram of a video cropping device according to an exemplary embodiment.

[0167] like Figure 6 As shown, the video cropping device 600 may specifically include:

[0168] A first extraction module 601 is configured to extract multiple frames of images from a video;

[0169] The pixel motion information determination module 602 is configured to determine the pixel motion information in the image area of ​​the video according to the multiple frames of images, wherein the pixel motion information is used to represent the motion speed of multiple pixels in two frames of images;

[0170] The target region determination module 603 is configured to determine the target region in the image region according to the pixel motion information, wherein the target region is a distribution region of target pixels in the image region, and the target pixels are pixels whose motion speed exceeds a first threshold;

[0171] The cropping line determination module 604 is configured to determine a cropping line in other regions of the image region except the target region for at least one frame of the image in the video;

[0172] The cropping module 605 is configured to crop the video using a cropping line to obtain a target video, so that the area occupied by the target region in the target video exceeds a second threshold.

[0173] In an optional embodiment, the first extraction module 601 includes: a second extraction module configured to extract n consecutive frames of images in the video, where n is an integer greater than 1;

[0174] The pixel motion information determination module 602 includes: a first calculation module, configured to calculate the optical flow of multiple pixels in the image area for every two adjacent frames of n frames of images to obtain an n-1 frame optical flow field, wherein the optical flow field is used to represent the pixel motion information.

[0175] Based on this, in an optional embodiment, the device may further include:

[0176] A conversion module is configured to convert the n frames of images into grayscale images before calculating the optical flows of a plurality of pixels in the image region for every two adjacent frames of the n frames of images to obtain n-1 frames of optical flow fields, thereby obtaining n frames of grayscale images;

[0177] Accordingly, the first calculation module may specifically include:

[0178] The second calculation module is configured to calculate the optical flow of multiple pixels in the image area for every two adjacent frames of the n frames of grayscale images to obtain an n-1 frame of optical flow field.

[0179] Optionally, in another embodiment, the optical flow field is used to represent the motion speed of each pixel in two adjacent frames of images among the multiple pixels, and the target area determination module 603 may include:

[0180] A target pixel determination module is configured to determine a target pixel in an image region in each frame of the optical flow field after obtaining n-1 frames of the optical flow field;

[0181] A synthesis module is configured to synthesize the distribution of target pixels in the n-1 frames of optical flow fields to obtain a synthetic distribution of target pixels in the image area;

[0182] The target region determination submodule is configured to determine the target region in the image region according to the synthetic distribution of the target pixels in the image region.

[0183] Furthermore, in an optional embodiment, the target area determination submodule may include:

[0184] A segmentation module is configured to perform region segmentation on the image region by a preset image region segmentation method according to the synthetic distribution of target pixels in the image region, so as to divide the image region into at least two regions;

[0185] The region determination submodule is configured to determine, among multiple regions, a region where the density of target pixels exceeds a third threshold to obtain a target region, wherein the density is used to represent the ratio of the number of target pixels to the number of pixels in the corresponding region.

[0186] In an optional embodiment, the cutting line determination module 604 may include:

[0187] A third extraction module is configured to extract m frames of images from the video;

[0188] The detection module is configured to detect Hough lines in other areas outside the target area by using a Hough line detection algorithm for each of the m frames of images;

[0189] The generation module is configured to generate a cropping line according to the Hough straight line detected from the m frames of images.

[0190] In an optional embodiment, the generation module may include:

[0191] A comparison module is configured to compare the Hough lines detected between every two frames of the m frames of images to determine the overlapping lines between every two frames of the m frames of images;

[0192] The first cutting line determination submodule is configured to determine the cutting line according to the straight lines with overlapping positions.

[0193] Optionally, in another embodiment, the generating module may include:

[0194] An acquisition module is configured to acquire parameters of each detected Hough line;

[0195] A selection module is configured to select a Hough line with parameters within a preset parameter range to obtain a target Hough line;

[0196] The second cropping line determination submodule is configured to determine the cropping line according to the target Hough line.

[0197] Therefore, according to the multiple frames of images extracted from the video, the pixel motion information in the image area of ​​the video is determined, and the pixel motion speed exceeding the first threshold is used as the basis for dividing the target area in the image area of ​​the video, and then the cropping line is determined outside the target area, and then the video is cropped. The cropped video includes the above-mentioned target area, so that the area where there is a moving target in the video can be retained, and the useful part of the image area in the video is retained. Compared with the solution of cropping videos based on deep learning, the computational complexity of the embodiment of the present disclosure is lower and does not rely on labeled sample data. It only needs to compare the images of different frames in the video to calculate the pixel motion information, so as to determine the area that needs to be retained for cropping. Therefore, the processing efficiency is high and the time consumed in the processing process can be shortened.

[0198] Based on the same inventive concept, the embodiment of the present disclosure further provides an electronic device, specifically combined with Figure 7 Provide detailed explanation.

[0199] Figure 7 It is a structural block diagram of a computing device according to an exemplary embodiment.

[0200] like Figure 7 As shown, the computing device can implement the exemplary hardware architecture of the computing device according to the video cropping method and the video cropping apparatus in the embodiments of the present disclosure. The computing device may refer to the electronic device and the server in the embodiments of the present disclosure.

[0201] The computing device may include a processor 1201 and a memory 1202 storing computer program instructions.

[0202] Specifically, the processor 1201 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.

[0203] The memory 1202 may include a large capacity memory for information or instructions. By way of example and not limitation, the memory 1202 may include a hard disk drive (HDD), a floppy disk drive, a flash memory, an optical disk, a magneto-optical disk, a tape, or a universal serial bus (USB) drive, or a combination of two or more of these. Where appropriate, the memory 1202 may include a removable or non-removable (or fixed) medium. Where appropriate, the memory 1202 may be inside or outside the integrated gateway device. In a particular embodiment, the memory 1202 is a non-volatile solid-state memory. In a particular embodiment, the memory 1202 includes a read-only memory (ROM). Where appropriate, the ROM may be a mask-programmed ROM, a programmable ROM (PROM), an erasable PROM (EPROM), an electrically erasable PROM (EEPROM), an electrically rewritable ROM (EAROM), or a flash memory, or a combination of two or more of these.

[0204] The processor 1201 reads and executes the computer program instructions stored in the memory 1202 to perform the following steps:

[0205] Extract multiple frames of images from the video;

[0206] Determine pixel motion information in an image region of a video according to the multiple frames of images, wherein the pixel motion information is used to represent the motion speed of multiple pixels in two frames of images;

[0207] Determine a target area in the image area according to the pixel motion information, wherein the target area is a distribution area of ​​target pixels in the image area, and the target pixels are pixels whose motion speed exceeds a first threshold;

[0208] For at least one frame of the video, a cropping line is determined in other areas of the image area except the target area;

[0209] The video is cropped using the cropping line to obtain a target video, so that the area occupied by the target region in the target video exceeds a second threshold.

[0210] In one embodiment, when the processor 1201 executes the step of extracting multiple frames of images from a video, the step may include: extracting n consecutive frames of images from the video, where n is an integer greater than 1;

[0211] Processor 1201 determines pixel motion information in an image region of a video based on multiple frames of images, including: calculating the optical flow of multiple pixels in the image region for every two adjacent frames of n frames of images to obtain an n-1 frame optical flow field, wherein the optical flow field is used to represent pixel motion information.

[0212] Based on this, in one embodiment, before the processor 1201 calculates the optical flow of multiple pixels in the image area for every two adjacent frames in the n frames of images to obtain the n-1 frame of optical flow field, it may also perform the following steps:

[0213] Convert n frames of images into grayscale images to obtain n frames of grayscale images;

[0214] Accordingly, for every two adjacent frames in the n frames, the optical flow of multiple pixels in the image area is calculated to obtain the n-1 frame optical flow field, which specifically includes:

[0215] For every two adjacent frames of n frames of grayscale images, the optical flow of multiple pixels in the image area is calculated to obtain an n-1 frame optical flow field.

[0216] Based on this, in one embodiment, the optical flow field is used to represent the motion speed of each pixel in two adjacent frames of images among the multiple pixels, and when the processor 1201 performs the step of determining the target area in the image area according to the pixel motion information, it may include performing the following steps:

[0217] In each frame of the optical flow field, determine the target pixel in the image area;

[0218] Synthesize the distribution of target pixels in the n-1 frames of optical flow field to obtain a synthetic distribution of target pixels in the image area;

[0219] According to the composite distribution of the target pixels in the image region, a target region is determined in the image region.

[0220] Based on this, in one embodiment, when the processor 1201 performs the step of determining the target area in the image area according to the synthetic distribution of the target pixels in the image area, the step may include performing the following steps:

[0221] According to the synthetic distribution of the target pixels in the image area, the image area is segmented by a preset image area segmentation method to divide the image area into at least two areas;

[0222] Among the multiple regions, a region where the density of target pixels exceeds a third threshold is determined to obtain a target region, wherein the density is used to represent a ratio of the number of target pixels to the number of pixels in the corresponding region.

[0223] In one embodiment, when the processor 1201 performs the step of determining the cropping line in other areas of the image area except the target area for at least one frame of the video, the step may include performing the following steps:

[0224] Extract m frames of images from the video;

[0225] For each of the m frames, a Hough line detection algorithm is used to detect Hough lines in other areas outside the target area.

[0226] Generate a cropping line based on the Hough straight line detected from the m-frame image.

[0227] Based on this, in one embodiment, when the processor 1201 executes the step of generating a cropping line according to the Hough lines detected from the m frames of images, the step may include executing the following steps:

[0228] Compare the Hough lines detected in the m-frame images to determine the lines with overlapping positions in the m-frame images;

[0229] The cropping lines are determined based on the overlapping straight lines.

[0230] Optionally, in another embodiment, when the processor 1201 executes the step of generating a cropping line according to the Hough lines detected from the m frames of images, the step may include executing the following steps:

[0231] Get the parameters of each detected Hough line;

[0232] Select the Hough line whose parameters are within the preset parameter range to obtain the target Hough line;

[0233] Determine the cropping line based on the target Hough line.

[0234] Therefore, according to the multiple frames of images extracted from the video, the pixel motion information in the image area of ​​the video is determined, and the pixel motion speed exceeding the first threshold is used as the basis for dividing the target area in the image area of ​​the video, and then the cropping line is determined outside the target area, and then the video is cropped. The cropped video includes the above-mentioned target area, so that the area where there is a moving target in the video can be retained, and the useful part of the image area in the video is retained. Compared with the solution of cropping videos based on deep learning, the computational complexity of the embodiment of the present disclosure is lower and does not rely on labeled sample data. It only needs to compare the images of different frames in the video to calculate the pixel motion information, so as to determine the area that needs to be retained for cropping. Therefore, the processing efficiency is high and the time consumed in the processing process can be shortened.

[0235] In one example, the computing device may further include a transceiver 1203 and a bus 1204. Figure 7 As shown, the processor 1201, the memory 1202 and the transceiver 1203 are connected via a bus 1204 and communicate with each other.

[0236] Bus 1204 includes hardware, software or both.For example, but not limitation, bus may include accelerated graphics port (AGP) or other graphics bus, enhanced industrial standard architecture (EISA) bus, front side bus (FSB), hypertransport (HT) interconnection, industrial standard architecture (ISA) bus, infinite bandwidth interconnection, low pin count (LPC) bus, memory bus, micro channel architecture (MCA) bus, peripheral control interconnection (PCI) bus, PCI-Express (PCI-X) bus, serial advanced technology attachment (SATA) bus, video electronics standard association local (VLB) bus or other suitable bus or two or more of these combinations. In appropriate cases, bus 1003 may include one or more buses. Although the present application embodiment describes and shows a specific bus, the present application considers any suitable bus or interconnection.

[0237] The embodiment of the present disclosure further provides a computer storage medium, in which computer executable instructions are stored. The computer executable instructions are used to implement the video cropping method recorded in the embodiment of the present disclosure.

[0238] In some possible implementations, various aspects of the method provided by the present disclosure may also be implemented in the form of a program product, which includes a program code. When the program product is run on a computer device, the program code is used to enable the computer device to execute the steps of the method according to various exemplary implementations of the present disclosure described above in this specification. For example, the computer device may execute the video cropping method recorded in the embodiments of the present disclosure.

[0239] The program product may employ any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of readable storage media (a non-exhaustive list) include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.

[0240] The present disclosure is described with reference to flowcharts and / or block diagrams of methods, devices, and computer program products according to the present disclosure. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable video cropping device to produce a machine, so that the instructions executed by the processor of the computer or other programmable video cropping device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0241] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable video cropping device to operate in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0242] These computer program instructions may also be loaded onto a computer or other programmable video cropping device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, whereby the instructions executed on the computer or other programmable device provide for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0243] Obviously, those skilled in the art can make various changes and modifications to the present disclosure without departing from the spirit and scope of the present disclosure. Thus, if these modifications and variations of the present disclosure fall within the scope of the claims of the present disclosure and their equivalents, the present disclosure is also intended to include these modifications and variations.

Claims

1. A video cropping method, characterized in that: include: Extract multiple frames of images from the video; Determining pixel motion information in an image region of the video according to the multiple frames of images, wherein the pixel motion information is used to represent a motion speed of multiple pixels in two frames of images; Determine a target area in the image area according to the pixel motion information, wherein the target area is a distribution area of ​​target pixels in the image area, and the target pixels are pixels whose motion speed exceeds a first threshold; For at least one frame of the video, determining a cropping line in other areas of the image area except the target area; The video is cropped by the cropping line to obtain a target video, so that the area occupied by the target region in the target video exceeds a second threshold; Extracting multiple frames of images from a video, comprising: extracting n consecutive frames of images from the video, where n is an integer greater than 1; Determining the pixel motion information in the image area of ​​the video based on the multiple frames of images includes: for every two adjacent frames of the n frames of images, calculating the optical flow of multiple pixel points in the image area to obtain an n-1 frame optical flow field, wherein the optical flow field is used to represent the pixel motion information.

2. The method according to claim 1, characterized in that Before calculating the optical flows of a plurality of pixels in the image region for every two adjacent images in the n frames of images to obtain an n-1 frame of optical flow field, the method further includes: Convert the n frames of images into grayscale images to obtain n frames of grayscale images; Accordingly, for every two adjacent images in the n frames of images, calculating the optical flow of a plurality of pixels in the image region to obtain an n-1 frame of optical flow field specifically includes: For every two adjacent frames of the n frames of grayscale images, the optical flows of a plurality of pixels in the image region are calculated to obtain an n-1 frame of optical flow field.

3. The method according to claim 1, characterized in that The optical flow field is used to represent the motion speed of each pixel in the plurality of pixels in two adjacent frames of images, and determining the target area in the image area according to the pixel motion information includes: In each frame of the optical flow field, determining the target pixel in the image area; Synthesizing the distribution of the target pixels in the n-1 frames of optical flow fields to obtain a synthetic distribution of the target pixels in the image area; The target area is determined in the image area according to the composite distribution of the target pixels in the image area.

4. The method according to claim 3, characterized in that The determining the target area in the image area according to the synthetic distribution of the target pixels in the image area comprises: According to the synthetic distribution of the target pixels in the image area, performing region segmentation on the image area by a preset image region segmentation method, so as to divide the image area into at least two regions; Among the multiple regions, determine the region where the density of the target pixels exceeds a third threshold to obtain the target region, wherein the density is used to represent the ratio of the number of the target pixels to the number of pixels in the corresponding region.

5. The method according to claim 1, characterized in that The step of determining a cropping line in other regions of the image region except the target region for at least one frame of the video includes: Extracting m frames of images from the video; For each of the m frames of images, using a Hough line detection algorithm, Hough lines are detected in other areas outside the target area; The cropping line is generated according to the Hough lines detected from the m frames of images.

6. The method according to claim 5, characterized in that The step of generating the cropping line according to the Hough straight line detected from the m frames of images includes: Comparing the Hough lines detected in the m image frames to determine the lines with overlapping positions in the m image frames; The cutting line is determined according to the straight lines overlapping the positions.

7. The method according to claim 5, characterized in that The step of generating the cropping line according to the Hough straight line detected from the m frames of images includes: Obtaining the parameters of each of the detected Hough lines; Selecting a Hough line whose parameters are within a preset parameter range to obtain a target Hough line; The cutting line is determined according to the target Hough line.

8. A video cutting device, characterized in that: include: A first extraction module is configured to extract multiple frames of images from a video; a pixel motion information determination module, configured to determine pixel motion information in an image region of the video according to the multiple frames of images, wherein the pixel motion information is used to represent a motion speed of multiple pixels in two frames of images; a target area determination module, configured to determine a target area in the image area according to the pixel motion information, wherein the target area is a distribution area of ​​target pixels in the image area, and the target pixels are pixels whose motion speed exceeds a first threshold; A cropping line determination module is configured to determine a cropping line in other areas of the image area except the target area for at least one frame of the image in the video; a cropping module configured to crop the video along the cropping line to obtain a target video, so that an area occupied by the target region in the target video exceeds a second threshold; The first extraction module includes: a second extraction module configured to extract n consecutive frames of images from the video, wherein n is an integer greater than 1; The pixel motion information determination module includes: a first calculation module, configured to calculate the optical flow of multiple pixel points in the image area for every two adjacent frames of the n frames of images to obtain an n-1 frame optical flow field, wherein the optical flow field is used to represent the pixel motion information.

9. The device according to claim 8, characterized in that The device also includes: A conversion module is configured to convert the n frames of images into grayscale images to obtain n frames of grayscale images before calculating the optical flows of a plurality of pixels in an image region for every two adjacent frames of images in the n frames of images to obtain n-1 frames of optical flow fields; Accordingly, the first calculation module specifically includes: The second calculation module is configured to calculate the optical flow of a plurality of pixels in the image area for every two adjacent frames of the n frames of grayscale images, so as to obtain an optical flow field of n-1 frames.

10. The device according to claim 8, characterized in that The optical flow field is used to represent the movement speed of each pixel in the plurality of pixels in two adjacent frames of images, and the target area determination module includes: A target pixel determination module is configured to determine the target pixel in the image area in each frame of the optical flow field after obtaining n-1 frames of the optical flow field; A synthesis module is configured to synthesize the distribution of the target pixels in the n-1 frame optical flow field to obtain a synthetic distribution of the target pixels in the image area; The target region determination submodule is configured to determine the target region in the image region according to the synthetic distribution of the target pixels in the image region.

11. The device according to claim 10, characterized in that The target area determination submodule includes: a segmentation module configured to perform region segmentation on the image region by a preset image region segmentation device according to the synthetic distribution of the target pixels in the image region, so as to divide the image region into at least two regions; The area determination submodule is configured to determine, among the multiple areas, an area where the density of the target pixels exceeds a third threshold to obtain the target area, wherein the density is used to represent the ratio of the number of the target pixels to the number of pixels in the corresponding area.

12. The device according to claim 8, characterized in that The cutting line determination module comprises: A third extraction module is configured to extract m frames of images from the video; For each of the m frames of images, using a Hough line detection algorithm, Hough lines are detected in other areas outside the target area; The detection module is configured to generate the cropping line according to the Hough line detected from the m frames of images.

13. The device according to claim 12, characterized in that The generation module comprises: A comparison module is configured to compare the Hough lines detected in the m frames of images to determine the lines with overlapping positions in the m frames of images; The first cutting line determination submodule is configured to determine the cutting line according to the straight lines overlapping the positions.

14. The device according to claim 12, characterized in that The generation module comprises: An acquisition module, configured to acquire the parameters of each of the detected Hough lines; A selection module is configured to select a Hough line whose parameters are within a preset parameter range to obtain a target Hough line; The second cropping line determination submodule is configured to determine the cropping line according to the target Hough line.

15. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the video cropping method according to any one of claims 1 to 7.

16. A storage medium, characterized in that: When the instructions in the storage medium are executed by a processor of a video cropping device or a server, the video cropping device or the server implements the video cropping method according to any one of claims 1 to 7.

17. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instruction is executed by a processor, the video cropping method according to any one of claims 1 to 7 is implemented.