CN112132836A - Video image clipping method and device, electronic equipment and storage medium - Google Patents

Video image clipping method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN112132836A
CN112132836A CN202010817691.XA CN202010817691A CN112132836A CN 112132836 A CN112132836 A CN 112132836A CN 202010817691 A CN202010817691 A CN 202010817691A CN 112132836 A CN112132836 A CN 112132836A
Authority
CN
China
Prior art keywords
cut
video image
area
range
target object
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010817691.XA
Other languages
Chinese (zh)
Inventor
樊刚
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China Mobile Communications Group Co Ltd
MIGU Culture Technology Co Ltd
Original Assignee
China Mobile Communications Group Co Ltd
MIGU Culture Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by China Mobile Communications Group Co Ltd, MIGU Culture Technology Co Ltd filed Critical China Mobile Communications Group Co Ltd
Priority to CN202010817691.XA priority Critical patent/CN112132836A/en
Publication of CN112132836A publication Critical patent/CN112132836A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/11Region-based segmentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/13Edge detection
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/70Determining position or orientation of objects or cameras
    • G06T7/73Determining position or orientation of objects or cameras using feature-based methods
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10016Video; Image sequence
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20112Image segmentation details
    • G06T2207/20132Image cropping

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Image Processing (AREA)
  • Editing Of Facsimile Originals (AREA)

Abstract

The embodiment of the invention provides a video image cutting method, a video image cutting device, electronic equipment and a storage medium; the method comprises the following steps: determining the position of a target object for the selected target video image; the target object is an object to be included in the target video image after being cut; determining the range of a region to be cut in the currently selected target video image according to the position of the target object; determining the edge pixel point coordinates of the area to be cut according to the range of the area to be cut; and cutting the area to be cut according to the edge pixel point coordinates of the area to be cut to obtain a cut video image. According to the video image clipping method, the video image clipping device, the electronic device and the storage medium, the range of the area to be clipped is determined through the identification of the target object in the target video image, so that the target object is in a relatively fixed position in the video image obtained after clipping, and the situation that the clipped video image is blank is avoided.

Description

Video image clipping method and device, electronic equipment and storage medium
Technical Field
The present invention relates to the field of video technologies, and in particular, to a method and an apparatus for clipping a video image, an electronic device, and a storage medium.
Background
When processing an image, it is generally necessary to perform an operation of adjusting the size of the image, such as enlarging the image, reducing the image, and cropping the image.
When an image is cropped, a pixel loss problem occurs, which results in a reduction in the resolution of the cropped image.
The bilinear interpolation algorithm and the Lanzcos interpolation algorithm are proposed by those skilled in the art for the problems encountered in image cropping. The bilinear interpolation algorithm can cut the image according to the coordinates of the designated pixel points, and the Lanzcos interpolation algorithm can perform pixel compensation on the static image. The size of the single-frame image can be changed while the resolution of the single-frame image is maintained by combining a bilinear interpolation algorithm and a Lanzcos interpolation algorithm.
These two types of algorithms cannot be applied directly to video images. The video image is an image extracted from a video. Since objects (such as people, articles, backgrounds, etc.) in a video are usually dynamically changing, the position of the object is different in each image area in each frame of video image. The algorithm in the prior art can only clip a fixed image area, and if the algorithm is applied to a video image, a blank situation occurs in the clipped video image.
Disclosure of Invention
To solve the problems in the prior art, embodiments of the present invention provide a method and an apparatus for adjusting a video image size, an electronic device, and a storage medium.
An embodiment of a first aspect of the present invention provides a video image cropping method, including:
determining the position of a target object for the selected target video image; the target object is an object to be included in the target video image after being cut;
determining the range of a region to be cut in the currently selected target video image according to the position of the target object;
determining the coordinates of edge pixel points of the area to be cut according to the range of the area to be cut;
and cutting the area to be cut according to the edge pixel point coordinates of the area to be cut to obtain a cut video image.
In the above technical solution, after the step of clipping the region to be clipped according to the edge pixel point coordinates of the region to be clipped to obtain the clipped video image, the method further includes:
and supplementing pixel points for the cut video image.
In the above technical solution, before the step of determining the position of the target object for the target video image, the method further includes:
acquiring a set of target video images according to the target video;
sequentially selecting target video images from the set of target video images;
correspondingly, after the step of supplementing pixel points to the cropped video image, the method further comprises:
sequencing the cut video images according to the sequence of the corresponding target video images in the set of the target video images;
and obtaining the cut video according to the sequenced cut video images.
In the above technical solution, the determining the range of the region to be clipped according to the position of the target object includes:
determining the range of the region to be cut according to the position of the target object and the preset initial range of the region to be cut; the initial range of the area to be cut comprises the size and the initial position of the area to be cut.
In the above technical solution, the determining the range of the region to be clipped according to the position of the target object and a preset initial range of the region to be clipped includes:
comparing the position of the target object with a preset initial range of a region to be cut;
when the position of the target object is within the initial range of the area to be cut, determining the range of the area to be cut according to the initial range of the area to be cut;
when the position of the target object is not in the initial range of the area to be cut, adjusting the first range of the area to be cut until the adjusted first range of the area to be cut contains the position of the target object; determining the range of the area to be cut according to the adjusted first range of the area to be cut; the first range of the area to be cut is a temporary range in the adjustment process of the area to be cut.
In the above technical solution, the determining the position of the target object for the target video image includes:
identifying characteristic information of candidate target objects in the target video image;
and when the characteristic information of the candidate target object accords with the preset characteristic information of the target object, determining the position of the candidate target object in the target video image as the position of the target object.
In the above technical solution, the determining the coordinates of the edge pixel points of the region to be clipped according to the range of the region to be clipped includes:
determining pixel points to be interpolated according to the range of the area to be cut;
and carrying out interpolation processing on the pixel points to be interpolated to obtain the edge pixel point coordinates of the region to be cut.
The embodiment of the second aspect of the present invention provides a video image cropping device, including:
the target object position determining module is used for determining the position of a target object for the selected target video image; the target object is an object to be included in the target video image after being cut;
the area range determining module is used for determining the range of the area to be cut in the currently selected target video image according to the position of the target object;
the pixel point coordinate determination module is used for determining the edge pixel point coordinate of the area to be cut according to the range of the area to be cut;
the cutting module is used for cutting the area to be cut according to the edge pixel point coordinates of the area to be cut to obtain a cut video image;
and the supplementary pixel point module is used for supplementing pixel points for the cut video image.
In a third embodiment of the present invention, an electronic device is provided, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and when the processor executes the computer program, the processor implements the steps of the video image cropping method according to the first embodiment of the present invention.
A fourth aspect of the present invention provides a non-transitory computer readable storage medium, on which a computer program is stored, which when executed by a processor implements the steps of the video image cropping method according to the first aspect of the present invention.
According to the video image clipping method, the video image clipping device, the electronic device and the storage medium, the range of the area to be clipped is determined through the identification of the target object in the target video image, so that the target object is in a relatively fixed position in the video image obtained after clipping, and the situation that the clipped video image is blank is avoided.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and those skilled in the art can also obtain other drawings according to the drawings without creative efforts.
FIG. 1 is a diagram illustrating a video image cropping method according to an embodiment of the present invention;
fig. 2 is a schematic diagram of a target video image and a rectangular cropping frame in the video image cropping method according to the embodiment of the present invention;
FIG. 3 is a schematic diagram of a bilinear difference algorithm;
FIG. 4 is a diagram illustrating an apparatus for cropping a video image according to an embodiment of the present invention;
fig. 5 is a schematic physical structure diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Fig. 1 is a schematic diagram of a video image cropping method according to an embodiment of the present invention, and as shown in fig. 1, the video image cropping method according to the embodiment of the present invention includes:
step 101, determining the position of a target object for a target video image.
In the embodiment of the present invention, the video image refers to a complete image extracted from a video. As is common knowledge of those skilled in the art, according to the video coding standard in the prior art, information of some pictures needs to be obtained depending on other pictures. For example, in the gop (group of picture) of h.264 coding, a key frame I and a prediction frame P, B are included. When a P frame is parsed, an I frame is required as a reference frame, and when a B frame is parsed, a previous I or P frame and a subsequent P frame are required as reference frames. The video images referred to in the embodiments of the present invention all refer to complete images that have been parsed from the video.
The target video image refers to a video image to be cropped.
The target object is an object to be included in the target video image after being cropped. For example, the target video image includes a specific character, and the specific character is a target object if the specific character is required to be retained during cropping. The target object may be various types of objects such as animals, plants, buildings, landscapes, and the like, in addition to the human.
Specifically, determining the position of the target object for the target video image may further include:
identifying characteristic information of candidate target objects in the target video image;
and when the characteristic information of the candidate target object accords with the preset characteristic information of the target object, determining the position of the candidate target object in the target video image as the position of the target object.
Take the target object as actor a as an example. Actor a is the leading actor in a video, and when the video image in the video is cut, actor B, actor C and the like which simultaneously appear in the video are required to be shielded by taking actor a as the focus.
Then the facial features of actor a may be pre-stored when determining the position of actor a in the target video image. Then, a face recognition algorithm is adopted to recognize the face features (namely the feature information of the candidate target object) from the target video image. The recognized facial features are compared with the prestored facial features of the actor a, and once the two facial features match, the position of the recognized facial features is the position of the actor a in the target video image.
The face recognition algorithm involved in the above process can adopt a face recognition algorithm in the prior art, in particular a face recognition algorithm based on an AI technology, such as Rainbow ArcSoft, AI face recognition products of science and technology fly, and the like.
And step 102, determining the range of the region to be cut in the currently selected target video image according to the position of the target object.
In the embodiment of the present invention, the region to be cropped refers to a region to be cropped in the target video image. As will be understood by those skilled in the art, when a video image is cropped, the cropped image is necessarily smaller than the image before cropping, and therefore, an area to be cropped needs to be set in the target video image. Since the target video image is an image extracted from a video and the position of the target object in different video images of the same video is likely to be different, in order to ensure that the region to be cropped is focused on the target object, the range of the region to be cropped needs to be determined for the currently selected target video image in this step.
The area to be cut is generally rectangular. For the convenience of identification, the region to be cropped can be represented by means of a crop box. The target video image area within the cropping frame is the area to be cropped. Fig. 2 is a schematic diagram of a target video image and a rectangular crop box, wherein a in the diagram represents the target video image, B in the diagram represents the rectangular crop box, and four vertices of the rectangular crop box can be labeled as p1, p2, p3 and p4 in order of upper left, upper right, lower left and lower right, as shown in fig. 2. When the region to be cropped is rectangular, the range of the region to be cropped in the target video image can be known by the coordinates of the four vertices p1, p2, p3 and p4 of the rectangle in the target video image, and conversely, the coordinates of the four vertices p1, p2, p3 and p4 in the target video image can also be known once the range of the region to be cropped in the target video image is set.
The range of the region to be cropped refers to which part of the target video image belongs to the region to be cropped. The range of the area to be cut comprises two contents, namely the size of the area to be cut, such as the length and the width of the area to be cut; and the second is the position of the region to be cropped in the target video image, such as the middle, the left side, the right side, and the like of the target video image.
In the embodiment of the present invention, determining the range of the region to be clipped according to the position of the target object includes:
and determining the range of the region to be cut according to the position of the target object and the preset initial range of the region to be cut.
In the embodiment of the present invention, the initial range of the region to be clipped is set in advance. For example, when the region to be clipped is rectangular, coordinates of four vertices p1, p2, p3, p4 of the rectangle in the target video image are set in advance. The size and initial position of the region to be trimmed can be determined by setting the initial range of the region to be trimmed in advance. In the following steps, the position of the region to be cropped in the target video image may vary, but the size generally remains the same.
The initial position of the region to be cropped may be located at the middle position, the left position, the right position, or the like of the target video image. In the embodiments of the present invention, this is not limited. In other embodiments of the present invention, a setting process of an initial range of a region to be clipped will be described.
It should be noted that, when the initial range of the region to be clipped is preset, the initial range is realized by setting the pixel distance between the edge pixel point in the region to be clipped and the designated pixel point in the target video image.
For example, for a rectangular region to be clipped, the edge pixel points used for positioning include vertex p1 in the upper left corner, vertex p2 in the upper right corner, vertex p3 in the lower left corner, and vertex p4 in the lower right corner. The abscissa dx of the vertex p1 is the pixel distance between the left side of the crop box and the left side of the target video image, and the ordinate dy is the pixel distance between the upper side of the crop box and the upper side of the target video image. The abscissa dx of the vertex p2 is the pixel distance between the right side of the crop box and the left side of the target video image, and the ordinate dy is the pixel distance between the upper side of the crop box and the upper side of the target video image. The abscissa dx of the vertex p3 is the pixel distance between the left side of the crop box and the left side of the target video image, and the ordinate dy is the pixel distance between the lower side of the crop box and the upper side of the target video image. The abscissa dx of the vertex p4 is the pixel distance between the right side of the crop box and the left side of the target video image, and the ordinate dy is the pixel distance between the lower side of the crop box and the upper side of the target video image.
In the embodiment of the present invention, the coordinates are obtained by establishing a coordinate system with the target video image as a reference, for example, by using the uppermost pixel point on the left side of the target video image as the origin of the coordinate system, using the length of the target video image as the X axis, and using the width of the target video image as the Y axis.
By setting the values of the abscissa and the ordinate for the vertices p1, p2, p3, p4, respectively, the initial range of the region to be cut can be set.
Specifically, determining the range of the region to be clipped according to the position of the target object and a preset initial range of the region to be clipped further includes:
comparing the position of the target object with a preset initial range of a region to be cut;
when the position of the target object is within the initial range of the area to be cut, determining the range of the area to be cut according to the initial range of the area to be cut;
when the position of the target object is not in the initial range of the area to be cut, adjusting the first range of the area to be cut until the adjusted first range of the area to be cut contains the position of the target object; and determining the range of the area to be cut according to the adjusted first range of the area to be cut. The first range of the area to be cut is a temporary range in the adjustment process of the area to be cut.
In the previous step, the position of the target object in the target video image has been obtained. In this step, the position of the target object is compared with the initial range of the region to be clipped, which has been set in advance. During comparison, the region to be cropped can be regarded as a crop box, the initial position of the crop box is determined according to the initial range of the region to be cropped, and whether the position of the target object is within the initial range of the region to be cropped can be determined according to whether the target object is within the crop box. If so, the initial range of the crop box can be determined as the range of the crop box; the initial range of the crop box may also be slightly adjusted, for example, the position of the target object is in the middle of the crop box, and the adjusted crop box is determined as the range of the crop box. If not, the range of the to-be-clipped frame can be adjusted step by step, and if the clipping frame is supposed to be initially located at the leftmost side of the target video object, the clipping frame can be shifted rightward by a plurality of pixel points (for example, 100 pixel points) once, then whether the target object is in the clipping frame is judged, if not, the target object continues to be shifted rightward by the plurality of pixel points until the current range of the clipping frame is taken as the final range of the to-be-determined clipping frame after the target object is in the clipping frame.
It should be noted that the preset initial range of the region to be cropped is realized by setting the pixel distance between the edge pixel point in the region to be cropped and the designated pixel point in the target video image. In this step, the range of the region to be cropped may also be adjusted by adjusting the pixel distance between the edge pixel point in the region to be cropped and the designated pixel point in the target video image. For example, for a rectangular region to be clipped, the range of the rectangular region to be clipped is adjusted by adjusting the values of the abscissa and ordinate of the vertices p1, p2, p3, p4, thereby obtaining the final range of the region to be clipped.
And 103, determining the edge pixel point coordinates of the area to be cut according to the range of the area to be cut.
In the previous step, the extent of the region to be cropped has been obtained. When the range of the region to be cut is determined, the pixel distance between the edge pixel point in the region to be cut and the designated pixel point in the target video image is depended on, and the coordinate values of the designated pixel point in different target video images are not necessarily consistent, so that the edge pixel point coordinate of the region to be cut needs to be determined in the step.
In the embodiment of the invention, the coordinates of the edge pixel points of the region to be cropped can be determined by adopting an interpolation method. Specifically, the method comprises the following steps:
determining pixel points to be interpolated according to the final range of the region to be cut;
and carrying out interpolation processing on the pixel points to be interpolated to obtain the edge pixel point coordinates of the region to be cut.
FIG. 3 is a schematic diagram of a bilinear difference algorithm. As shown in fig. 3, when the bilinear interpolation algorithm is adopted, the designated pixel points in the target video image include a vertex p (x0, y0) at the upper left corner, a vertex p (x1, y0) at the upper right corner, a vertex p (x0, y1) at the lower left corner, and a vertex p (x1, y1) at the lower right corner of the target video image.
The coordinates of the edge pixel points of the region to be cropped can be calculated by the following formula:
p(x’,y’)=dx*dy*p(x0,y0)+(1–dx)*dy*p(x1,y0)+dx*(1–dy)* p(x0,y1)+(1–dx)*(1–dy)*p(x1,y1)。
when the edge pixel point of the region to be cut is the vertex p1 of the upper left corner of the region to be cut, dx in the formula is the pixel distance between the left side of the cutting frame and the left side of the target video image, and dy is the pixel distance between the upper side of the cutting frame and the upper side of the target video image. When the edge pixel point of the region to be cropped is the vertex p2 of the upper right corner of the region to be cropped, dx in the formula is the pixel distance between the right side of the cropping frame and the left side of the target video image, and dy is the pixel distance between the upper side of the cropping frame and the upper side of the target video image. When the edge pixel point of the region to be cropped is the vertex p3 of the lower left corner of the region to be cropped, dx in the formula is the pixel distance between the left side of the cropping frame and the left side of the target video image, and dy is the pixel distance between the lower side of the cropping frame and the upper side of the target video image. When the edge pixel point of the region to be clipped is the vertex p4 of the lower right corner of the region to be clipped, dx in the formula is the pixel distance between the right side of the clipping frame and the left side of the target video image, and the ordinate dy is the pixel distance between the lower side of the clipping frame and the upper side of the target video image.
The step is not limited to the bilinear interpolation algorithm, and a seamcarding algorithm, an image structure-based transformation algorithm, a convolution algorithm and the like in the prior art can be adopted.
And step 104, cutting the area to be cut according to the edge pixel point coordinates of the area to be cut to obtain a cut video image.
After the edge pixel point coordinates of the area to be cut are obtained, the area to be cut can be cut according to the edge pixel point coordinates. For example, if the region to be cropped is rectangular, after the vertex p1 at the upper left corner, the vertex p2 at the upper right corner, the vertex p3 at the lower left corner, and the vertex p4 at the lower right corner are obtained, the target video image may be cropped according to the coordinates of these vertices, so as to obtain a cropped video image.
How to implement image cropping is common knowledge of those skilled in the art and is therefore not repeated here.
The video image clipping method provided by the embodiment of the invention determines the range of the region to be clipped through the identification of the target object in the target video image, so that the target object is in a relatively fixed position in the video image obtained after clipping, and the situation that the clipped video image is blank is avoided.
Based on any of the above embodiments, in an embodiment of the present invention, after step 104, the method further includes:
and supplementing pixel points for the cut video image.
When the target video image is cut, the problem of pixel loss may occur, which may cause image blurring and distortion. Therefore, pixels need to be supplemented to the cut video image, the pixel loss is reduced, and the resolution is guaranteed to be unchanged.
In the embodiment of the invention, pixels are supplemented for the cut video image through a symmetrical change Lanzcos algorithm.
Assuming that the cut video image is a matrix N, carrying out weighted summation on pixel points p (i, j) in the matrix N to generate a new pixel point coordinate p (x ', y' 0), wherein in the weighting process, weighting coefficients L (x) and L (y) are required to be multiplied respectively in the horizontal axis direction and the vertical axis direction for summation, the weighting coefficient of the horizontal axis is L (x), and the weighting coefficient of the vertical axis is L (y).
The summation formula is as follows:
Figure 1
wherein, the weighting coefficient L (x) is calculated according to the following formula, i is the coordinate value of the horizontal axis of the original pixel point, and a is the offset of the compensation pixel point:
Figure BDA0002633314190000102
wherein, the weighting coefficient L (y) is calculated according to the following formula, j is the vertical axis coordinate value of the original pixel point:
Figure BDA0002633314190000103
in other embodiments of the present invention, other algorithms may also be used to supplement the pixels to the clipped video image, such as a nearest interpolation algorithm, a cubic convolution interpolation algorithm, and the like.
According to the video image clipping method provided by the embodiment of the invention, the pixel points are supplemented for the clipped video image, so that the pixel loss condition in the clipping process can be reduced, and the resolution of the clipped image is ensured to be kept unchanged or not to be obviously reduced.
Based on any one of the above embodiments, in an embodiment of the present invention, before the step of determining the position of the target object for the target video image, the method further includes:
acquiring a set of target video images according to the target video;
sequentially selecting target video images from the set of target video images;
correspondingly, after the step of supplementing pixel points to the cropped video image, the method further comprises:
sequencing the cut video images according to the sequence of the corresponding target video images in the set of the target video images;
and obtaining the cut video according to the sequenced cut video images.
In the embodiment of the present invention, the target video refers to a video that needs to be cropped from an image in the video.
The target video image set can be obtained by performing frame extraction operation on the target video. The frame extraction operation for the target video is common knowledge of those skilled in the art, and therefore, the detailed implementation process of the frame extraction operation is not described in detail.
The frame images in the target video image set are sequentially arranged according to the playing time sequence of the video. When the target video image is selected, the target video image can be selected in sequence according to the playing time sequence of the video. And executing the steps for the selected target video image to obtain the clipped video image.
And sequencing the cut video images according to the sequence of the corresponding target video images in the set of the target video images, so as to obtain the sequenced cut video images. The sequence of the cut video images is consistent with the playing time sequence of the video, so the images can be combined into a video file and then coded to obtain the cut video. For example, the plurality of cropped video images are merged using the open source tool ffmpeg.
According to the video image clipping method provided by the embodiment of the invention, the clipped video can be obtained by clipping the video image in the target video, and the target object is in a relatively fixed position in the clipped video, so that the situation that the clipped video is blank is avoided.
Based on any one of the above embodiments, in an embodiment of the present invention, before step 101, the method further includes:
setting the initial range of the area to be cut.
The area to be cropped determines the size of the cropped video image and the position of the cropped video image in the target video image. Therefore, when setting the initial range of the region to be cut, it is necessary to set the size and the initial position thereof.
The size of the area to be cut does not change in the subsequent steps, and the position of the area to be cut may be adjusted in the subsequent steps.
For example, in a target video with a video display format of 1080p, the size value of the video image is 1920 × 1080, and the size of the region to be cropped may be 960 × 1080 as required for cropping in the middle half and keeping the height unchanged. The initial position of the region to be cropped may be a middle position, a left position, a right position, or the like of the target video image.
The video image clipping method provided by the embodiment of the invention determines the size and the initial position of the region to be clipped by setting the initial range for the region to be clipped, thereby providing conditions for subsequent operation.
Based on any of the above embodiments, fig. 4 is a schematic diagram of a video image cropping device according to an embodiment of the present invention, and as shown in fig. 4, the video image cropping device according to the embodiment of the present invention includes:
a target object position determining module 401, configured to determine a position of a target object for the selected target video image; the target object is an object to be included in the target video image after being cut;
a to-be-clipped region range determining module 402, configured to determine a range of the to-be-clipped region according to the position of the target object;
a pixel point coordinate determining module 403, configured to determine, according to the range of the region to be cropped, an edge pixel point coordinate of the region to be cropped in the currently selected target video image;
and the cutting module 404 is configured to cut the area to be cut according to the edge pixel point coordinates of the area to be cut, so as to obtain a cut video image.
The video image clipping device provided by the embodiment of the invention determines the range of the region to be clipped through the identification of the target object in the target video image, so that the target object is in a relatively fixed position in the video image obtained after clipping, and the situation that the clipped video image is blank is avoided.
Fig. 5 is a schematic physical structure diagram of an electronic device according to an embodiment of the present invention, and as shown in fig. 5, the electronic device may include: a processor (processor)510, a communication Interface (Communications Interface)520, a memory (memory)530 and a communication bus 540, wherein the processor 510, the communication Interface 520 and the memory 530 communicate with each other via the communication bus 540. Processor 510 may call logic instructions in memory 530 to perform the following method: determining the position of a target object for the selected target video image; the target object is an object to be included in the target video image after being cut; determining the range of a region to be cut in the currently selected target video image according to the position of the target object; determining the coordinates of edge pixel points of the area to be cut according to the range of the area to be cut; and cutting the area to be cut according to the edge pixel point coordinates of the area to be cut to obtain a cut video image.
It should be noted that, when being implemented specifically, the electronic device in this embodiment may be a server, a PC, or other devices, as long as the structure includes the processor 510, the communication interface 520, the memory 530, and the communication bus 540 shown in fig. 5, where the processor 510, the communication interface 520, and the memory 530 complete mutual communication through the communication bus 540, and the processor 510 may call the logic instructions in the memory 530 to execute the above method. The embodiment does not limit the specific implementation form of the electronic device.
Furthermore, the logic instructions in the memory 530 may be implemented in the form of software functional units and stored in a computer readable storage medium when the software functional units are sold or used as independent products. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
Further, embodiments of the present invention disclose a computer program product comprising a computer program stored on a non-transitory computer-readable storage medium, the computer program comprising program instructions, which when executed by a computer, the computer is capable of performing the methods provided by the above-mentioned method embodiments, for example, comprising: determining the position of a target object for the selected target video image; the target object is an object to be included in the target video image after being cut; determining the range of a region to be cut in the currently selected target video image according to the position of the target object; determining the coordinates of edge pixel points of the area to be cut according to the range of the area to be cut; and cutting the area to be cut according to the edge pixel point coordinates of the area to be cut to obtain a cut video image.
In another aspect, an embodiment of the present invention further provides a non-transitory computer-readable storage medium, on which a computer program is stored, where the computer program is implemented by a processor to perform the method provided by the foregoing embodiments, for example, including: determining the position of a target object for the selected target video image; the target object is an object to be included in the target video image after being cut; determining the range of a region to be cut in the currently selected target video image according to the position of the target object; determining the coordinates of edge pixel points of the area to be cut according to the range of the area to be cut; and cutting the area to be cut according to the edge pixel point coordinates of the area to be cut to obtain a cut video image.
The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware. With this understanding in mind, the above-described technical solutions may be embodied in the form of a software product, which can be stored in a computer-readable storage medium such as ROM/RAM, magnetic disk, optical disk, etc., and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the methods described in the embodiments or some parts of the embodiments.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (10)

1. A method for cropping a video image, comprising:
determining the position of a target object for the selected target video image; the target object is an object to be included in the target video image after being cut;
determining the range of a region to be cut in the currently selected target video image according to the position of the target object;
determining the coordinates of edge pixel points of the area to be cut according to the range of the area to be cut;
and cutting the area to be cut according to the edge pixel point coordinates of the area to be cut to obtain a cut video image.
2. The video image cropping method according to claim 1, wherein after the step of cropping the region to be cropped according to the edge pixel point coordinates of the region to be cropped to obtain a cropped video image, the method further comprises:
and supplementing pixel points for the cut video image.
3. A video image cropping method according to claim 2, characterized in that, before said step of determining the position of the target object for the target video image, the method further comprises:
acquiring a set of target video images according to the target video;
sequentially selecting target video images from the set of target video images;
correspondingly, after the step of supplementing pixel points to the cropped video image, the method further comprises:
sequencing the cut video images according to the sequence of the corresponding target video images in the set of the target video images;
and obtaining the cut video according to the sequenced cut video images.
4. The method according to claim 1, 2 or 3, wherein the determining the range of the region to be cropped according to the position of the target object comprises:
determining the range of the region to be cut according to the position of the target object and the preset initial range of the region to be cut; the initial range of the area to be cut comprises the size and the initial position of the area to be cut.
5. The video image cropping method according to claim 4, wherein the determining the range of the region to be cropped according to the position of the target object and a preset initial range of the region to be cropped comprises:
comparing the position of the target object with a preset initial range of a region to be cut;
when the position of the target object is within the initial range of the area to be cut, determining the range of the area to be cut according to the initial range of the area to be cut;
when the position of the target object is not in the initial range of the area to be cut, adjusting the first range of the area to be cut until the adjusted first range of the area to be cut contains the position of the target object; determining the range of the area to be cut according to the adjusted first range of the area to be cut; the first range of the area to be cut is a temporary range in the adjustment process of the area to be cut.
6. A method for cropping a video image according to claim 1, 2 or 3, wherein said determining the position of the target object for the target video image comprises:
identifying characteristic information of candidate target objects in the target video image;
and when the characteristic information of the candidate target object accords with the preset characteristic information of the target object, determining the position of the candidate target object in the target video image as the position of the target object.
7. The method for clipping video image according to claim 1, 2 or 3, wherein the determining the coordinates of the edge pixel points of the region to be clipped according to the range of the region to be clipped comprises:
determining pixel points to be interpolated according to the range of the area to be cut;
and carrying out interpolation processing on the pixel points to be interpolated to obtain the edge pixel point coordinates of the region to be cut.
8. A video image cropping device, comprising:
the target object position determining module is used for determining the position of a target object for the selected target video image; the target object is an object to be included in the target video image after being cut;
the area range determining module is used for determining the range of the area to be cut in the currently selected target video image according to the position of the target object;
the pixel point coordinate determination module is used for determining the edge pixel point coordinate of the area to be cut according to the range of the area to be cut;
and the cutting module is used for cutting the area to be cut according to the edge pixel point coordinates of the area to be cut to obtain a cut video image.
9. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the steps of the video image cropping method according to any one of claims 1 to 7 are implemented when the program is executed by the processor.
10. A non-transitory computer readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the video image cropping method according to any one of claims 1 to 7.
CN202010817691.XA 2020-08-14 2020-08-14 Video image clipping method and device, electronic equipment and storage medium Pending CN112132836A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010817691.XA CN112132836A (en) 2020-08-14 2020-08-14 Video image clipping method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010817691.XA CN112132836A (en) 2020-08-14 2020-08-14 Video image clipping method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN112132836A true CN112132836A (en) 2020-12-25

Family

ID=73851645

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010817691.XA Pending CN112132836A (en) 2020-08-14 2020-08-14 Video image clipping method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN112132836A (en)

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112700454A (en) * 2020-12-28 2021-04-23 北京达佳互联信息技术有限公司 Image cropping method and device, electronic equipment and storage medium
CN112995535A (en) * 2021-02-05 2021-06-18 北京百度网讯科技有限公司 Method, apparatus, device and storage medium for processing video
CN113269790A (en) * 2021-03-26 2021-08-17 北京达佳互联信息技术有限公司 Video clipping method and device, electronic equipment, server and storage medium
CN114092495A (en) * 2021-11-29 2022-02-25 阿里巴巴(中国)有限公司 Image display method, electronic device, storage medium, and program product
CN114257762A (en) * 2021-12-20 2022-03-29 咪咕音乐有限公司 Video conversion method, device, equipment and storage medium
CN116542987A (en) * 2023-04-19 2023-08-04 翼存(上海)智能科技有限公司 Image clipping method and device, electronic equipment and storage medium
CN117612046A (en) * 2024-01-23 2024-02-27 青岛云世纪信息科技有限公司 Method and system for realizing ground object identification of target area based on AI and GIS interaction
CN116542987B (en) * 2023-04-19 2024-06-04 翼存(上海)智能科技有限公司 Image clipping method and device, electronic equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110310414A1 (en) * 2010-06-21 2011-12-22 Sharp Kabushiki Kaisha Image processing apparatus, image reading apparatus, image forming apparatus, image processing method, and recording medium
CN110347877A (en) * 2019-06-27 2019-10-18 北京奇艺世纪科技有限公司 A kind of method for processing video frequency, device, electronic equipment and storage medium
CN110706150A (en) * 2019-07-12 2020-01-17 北京达佳互联信息技术有限公司 Image processing method, image processing device, electronic equipment and storage medium
CN111010590A (en) * 2018-10-08 2020-04-14 传线网络科技(上海)有限公司 Video clipping method and device
CN111031178A (en) * 2019-12-19 2020-04-17 维沃移动通信有限公司 Video stream clipping method and electronic equipment

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110310414A1 (en) * 2010-06-21 2011-12-22 Sharp Kabushiki Kaisha Image processing apparatus, image reading apparatus, image forming apparatus, image processing method, and recording medium
CN111010590A (en) * 2018-10-08 2020-04-14 传线网络科技(上海)有限公司 Video clipping method and device
CN110347877A (en) * 2019-06-27 2019-10-18 北京奇艺世纪科技有限公司 A kind of method for processing video frequency, device, electronic equipment and storage medium
CN110706150A (en) * 2019-07-12 2020-01-17 北京达佳互联信息技术有限公司 Image processing method, image processing device, electronic equipment and storage medium
CN111031178A (en) * 2019-12-19 2020-04-17 维沃移动通信有限公司 Video stream clipping method and electronic equipment

Cited By (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112700454A (en) * 2020-12-28 2021-04-23 北京达佳互联信息技术有限公司 Image cropping method and device, electronic equipment and storage medium
CN112700454B (en) * 2020-12-28 2024-05-14 北京达佳互联信息技术有限公司 Image cropping method and device, electronic equipment and storage medium
CN112995535A (en) * 2021-02-05 2021-06-18 北京百度网讯科技有限公司 Method, apparatus, device and storage medium for processing video
CN113269790A (en) * 2021-03-26 2021-08-17 北京达佳互联信息技术有限公司 Video clipping method and device, electronic equipment, server and storage medium
CN114092495A (en) * 2021-11-29 2022-02-25 阿里巴巴(中国)有限公司 Image display method, electronic device, storage medium, and program product
CN114092495B (en) * 2021-11-29 2023-01-31 阿里巴巴(中国)有限公司 Image display method, electronic device and storage medium
CN114257762A (en) * 2021-12-20 2022-03-29 咪咕音乐有限公司 Video conversion method, device, equipment and storage medium
CN116542987A (en) * 2023-04-19 2023-08-04 翼存(上海)智能科技有限公司 Image clipping method and device, electronic equipment and storage medium
CN116542987B (en) * 2023-04-19 2024-06-04 翼存(上海)智能科技有限公司 Image clipping method and device, electronic equipment and storage medium
CN117612046A (en) * 2024-01-23 2024-02-27 青岛云世纪信息科技有限公司 Method and system for realizing ground object identification of target area based on AI and GIS interaction
CN117612046B (en) * 2024-01-23 2024-04-26 青岛云世纪信息科技有限公司 Method and system for realizing ground object identification of target area based on AI and GIS interaction

Similar Documents

Publication Publication Date Title
CN112132836A (en) Video image clipping method and device, electronic equipment and storage medium
WO2021088473A1 (en) Image super-resolution reconstruction method, image super-resolution reconstruction apparatus, and computer-readable storage medium
KR101036787B1 (en) Motion vector calculation method, hand-movement correction device using the method, imaging device, and motion picture generation device
US8175399B2 (en) Multiple-resolution image processing apparatus
JP4621733B2 (en) Method and system for viewing and enhancing images
US11039088B2 (en) Video processing method and apparatus based on augmented reality, and electronic device
US8059899B2 (en) Image processing apparatus, image processing method, and computer product
KR20090071624A (en) Image enhancement
CN112017222A (en) Video panorama stitching and three-dimensional fusion method and device
CN107646112B (en) Method for correcting eye image using machine learning and method for machine learning
CN111402354B (en) Color contrast enhancement drawing method, device and system suitable for optical transmission type head-mounted display
CN112801879A (en) Image super-resolution reconstruction method and device, electronic equipment and storage medium
US20220138906A1 (en) Image Processing Method, Apparatus, and Device
CN112929562B (en) Video jitter processing method, device, equipment and storage medium
US10354125B2 (en) Photograph processing method and system
JPH1063855A (en) Method for extracting picture area
CN113256484A (en) Method and device for stylizing image
CN113012051A (en) Image processing method, image processing device, electronic equipment and computer readable storage medium
CN111988597B (en) Virtual viewpoint synthesis method and device, electronic equipment and readable storage medium
CN111062975B (en) Method for accelerating real-time target detection of video frame based on perceptual hash algorithm
CN111836025B (en) Augmented reality projection guide system
US20240071036A1 (en) Method and apparatus for image preprocessing based on object of interest
US20070052859A1 (en) Method and decoder for composing a scene
CN112929628A (en) Virtual viewpoint synthesis method and device, electronic equipment and storage medium
CN117830085A (en) Video conversion method and 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