WO2023045641A1 - 图像裁剪方法、装置、计算机设备及存储介质 - Google Patents

图像裁剪方法、装置、计算机设备及存储介质 Download PDF

Info

Publication number
WO2023045641A1
WO2023045641A1 PCT/CN2022/113325 CN2022113325W WO2023045641A1 WO 2023045641 A1 WO2023045641 A1 WO 2023045641A1 CN 2022113325 W CN2022113325 W CN 2022113325W WO 2023045641 A1 WO2023045641 A1 WO 2023045641A1
Authority
WO
WIPO (PCT)
Prior art keywords
image
frame
target
exclusion
area
Prior art date
Application number
PCT/CN2022/113325
Other languages
English (en)
French (fr)
Inventor
汤泽胜
司建锋
Original Assignee
腾讯科技(深圳)有限公司
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 腾讯科技(深圳)有限公司 filed Critical 腾讯科技(深圳)有限公司
Publication of WO2023045641A1 publication Critical patent/WO2023045641A1/zh
Priority to US18/219,943 priority Critical patent/US20230351604A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • G06T11/60Editing figures and text; Combining figures or text
    • 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/12Edge-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/20Analysis of motion
    • G06T7/246Analysis of motion using feature-based methods, e.g. the tracking of corners or segments
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V20/00Scenes; Scene-specific elements
    • G06V20/20Scenes; Scene-specific elements in augmented reality scenes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V40/00Recognition of biometric, human-related or animal-related patterns in image or video data
    • G06V40/10Human or animal bodies, e.g. vehicle occupants or pedestrians; Body parts, e.g. hands
    • G06V40/107Static hand or arm
    • G06V40/11Hand-related biometrics; Hand pose recognition
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V40/00Recognition of biometric, human-related or animal-related patterns in image or video data
    • G06V40/10Human or animal bodies, e.g. vehicle occupants or pedestrians; Body parts, e.g. hands
    • G06V40/16Human faces, e.g. facial parts, sketches or expressions
    • G06V40/161Detection; Localisation; Normalisation
    • G06V40/165Detection; Localisation; Normalisation using facial parts and geometric relationships
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V40/00Recognition of biometric, human-related or animal-related patterns in image or video data
    • G06V40/20Movements or behaviour, e.g. gesture recognition
    • G06V40/28Recognition of hand or arm movements, e.g. recognition of deaf sign language
    • 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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/30Subject of image; Context of image processing
    • G06T2207/30176Document
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/30Subject of image; Context of image processing
    • G06T2207/30196Human being; Person
    • G06T2207/30201Face
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/30Subject of image; Context of image processing
    • G06T2207/30204Marker
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V2201/00Indexing scheme relating to image or video recognition or understanding
    • G06V2201/07Target detection

Definitions

  • the embodiments of the present application relate to the field of computer technologies, and in particular to an image cropping method, device, computer equipment, and storage medium.
  • Embodiments of the present application provide an image cropping method, device, computer equipment, and storage medium, which can improve the effect of image cropping.
  • the technical solution includes the following aspects.
  • an image cropping method is provided, the method is executed by a computer device, and the method includes:
  • the second type of object is an object that does not need to be retained;
  • the object area including the first object box and excluding the exclusion box
  • the first image is cropped to obtain a second image that includes the first target frame and does not include the exclusion frame.
  • an image cropping device comprising:
  • An object frame determining module configured to determine the object frame where each object in the first image is located
  • the target frame and exclusion frame determination module is configured to determine the object frame where the object belonging to the first type is located as the first target frame, and determine the object frame where the object belonging to the second type is located as the exclusion frame, and the object frame of the first type
  • the object is an object that needs to be kept, and the second type of object is an object that does not need to be kept;
  • a target area determination module configured to determine a target area in the first image, the target area includes the first target frame and does not include the exclusion frame;
  • a clipping module configured to clip the first image based on the target area to obtain a second image that includes the first target frame and does not include the exclusion frame.
  • a computer device in another aspect, includes a processor and a memory, at least one computer program is stored in the memory, the at least one computer program is loaded and executed by the processor, so that all The computer device implements the operations performed in the image cropping method described in the above aspects.
  • a non-volatile computer-readable storage medium wherein at least one computer program is stored in the non-volatile computer-readable storage medium, and the at least one computer program is loaded and executed by a processor, To make the computer implement the operations performed in the image cropping method as described in the above aspects.
  • a computer program product or computer program includes computer program code, the computer program code is stored in a non-volatile computer-readable storage medium, the processing of the computer device
  • the processor reads the computer program code from a non-volatile computer-readable storage medium, and the processor executes the computer program code, so that the computer device implements the operations performed in the image cropping method as described in the above aspect.
  • the method, device, computer equipment, and storage medium provided by the embodiments of the present application divide the objects in the first image into objects that need to be kept and objects that do not need to be kept, and determine the first target frame and the exclusion frame. Mark the areas where the reserved objects and objects that do not need to be retained are located. Since the target area in the first image includes the first target frame and does not include the exclusion frame, based on the target area, the first image is cropped, and the first image can be obtained including the first A second image of a target box that does not include exclusion boxes. Among them, using the first target frame and the exclusion frame to mark the areas where the objects to be kept and the objects not to be kept in the image are located is beneficial to quickly identify the target area, thereby improving the speed of image cropping.
  • this image cropping method ensures that the second image includes key information that needs attention , and does not include interference information that does not need attention, thereby improving the effect of image cropping.
  • FIG. 1 is a schematic diagram of an implementation environment provided by an embodiment of the present application.
  • FIG. 2 is a flow chart of an image cropping method provided in an embodiment of the present application.
  • FIG. 3 is a flow chart of an image cropping method provided in an embodiment of the present application.
  • Fig. 4 is a schematic diagram of an image segmentation method provided by an embodiment of the present application.
  • Fig. 5 is a schematic diagram of another image segmentation method provided by the embodiment of the present application.
  • Fig. 6 is a schematic diagram of another image segmentation method provided by the embodiment of the present application.
  • Fig. 7 is a schematic diagram of another image segmentation method provided by the embodiment of the present application.
  • FIG. 8 is a schematic diagram of an image cropping method provided by an embodiment of the present application.
  • FIG. 9 is a flow chart of an image cropping method provided in an embodiment of the present application.
  • FIG. 10 is a flow chart of an image cropping method provided in an embodiment of the present application.
  • FIG. 11 is a flow chart of another image cropping method provided by an embodiment of the present application.
  • FIG. 12 is a schematic structural diagram of an image cropping device provided in an embodiment of the present application.
  • FIG. 13 is a schematic structural diagram of another image cropping device provided by an embodiment of the present application.
  • FIG. 14 is a schematic structural diagram of a terminal provided in an embodiment of the present application.
  • FIG. 15 is a schematic structural diagram of a server provided by an embodiment of the present application.
  • first means “first”, “second” and the like used in this application may be used to describe various concepts herein, but unless otherwise specified, these concepts are not limited by these terms. These terms are only used to distinguish one concept from another. For example, a first video could be termed a second video, and, similarly, a second video could be termed a first video, without departing from the scope of the present application.
  • At least one refers to one or more than one.
  • at least one exclusion box may be any integer number of exclusion boxes greater than or equal to one, such as one exclusion box, two exclusion boxes, or three exclusion boxes.
  • a plurality refers to two or more, for example, a plurality of exclusion boxes may be any integer number of exclusion boxes greater than or equal to two, such as two exclusion boxes, three exclusion boxes, or the like.
  • Each refers to each of at least one, for example, each exclusion box refers to each exclusion box in multiple exclusion boxes, if the multiple exclusion boxes are 3 exclusion boxes, then each exclusion box refers to 3 Each exclude box in the exclude box.
  • FIG. 1 is a schematic diagram of an implementation environment provided by an embodiment of the present application.
  • the implementation environment includes: a server 101 and a terminal 102 .
  • the server 101 is configured to crop the image, and provide the cropped image to the terminal 102 .
  • the terminal 102 is used to share a video, and before sharing the video, request the server 101 to set a cover for the video, and the server 101 is used to crop the image associated with the video, thereby determining the cropped image as the cover of the video, and providing to terminal 102.
  • the terminal 102 can also be used to crop the image.
  • the terminal 102 crops the image associated with the video, so as to determine the cropped image as the cover of the video.
  • the server 101 is an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network Services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network, content distribution network), and cloud servers for basic cloud computing services such as big data and artificial intelligence platforms.
  • the terminal 102 is a smart phone, a tablet computer, a notebook computer, a desktop computer, a smart speaker, a smart watch, a smart TV, a smart vehicle terminal, etc., but is not limited thereto.
  • the server 101 and the terminal 102 may be connected directly or indirectly through wired or wireless communication, which is not limited in this application.
  • a target application provided by the server 101 is installed on the terminal 102, and the terminal 102 can implement functions such as video editing or video playing through the target application.
  • the target application is a target application in the operating system of the terminal 102, or a target application provided by a third party.
  • the target application is a video sharing application, and the video sharing application has a video sharing function.
  • the video sharing application can also have other functions, such as a review function, a shopping function, a navigation function, a game function, and the like.
  • FIG. 2 is a flow chart of an image cropping method provided by an embodiment of the present application.
  • the execution subject of the embodiment of the present application is a computer device, referring to FIG. 2 , the method includes the following steps 201 to 204.
  • the computer device determines an object frame where each object in the first image is located.
  • the computer device acquires a first image, where the first image is an image to be cropped.
  • the first image includes multiple objects, and the objects may be any type of objects, for example, the objects are people, objects, text, or watermarks.
  • the computer device determines the object frame where each object in the first image is located, the object frame is used to represent the position of the object, and the area framed by the object frame is the area where the object is located.
  • the computer device determines an object frame where objects belonging to the first type are located as a first target frame, and determines an object frame where objects belonging to the second type are located as an excluded frame.
  • the plurality of objects in the first image includes objects belonging to the first type and objects belonging to the second type.
  • the objects belonging to the first type are the objects that need to be kept, that is, the objects that need to be kept when cropping the first image, and the objects of the first type are key information that need to be paid attention to in the first image.
  • Objects belonging to the second type are objects that do not need to be kept, that is, objects that do not need to be kept when cropping the first image, and the objects of the second type are interference information that does not need to be paid attention to in the first image.
  • the computer device determines the object frame where the object belonging to the first type is located as the first target frame, so as to indicate that the area framed by the first target frame is an area to be reserved.
  • the computer device determines the object frame where the object belonging to the second type is located as the exclusion frame, so as to indicate that the area framed by the exclusion frame is an area that does not need to be reserved.
  • the computer device marks the regions that need to be preserved and the regions that do not need to be preserved in the first image.
  • the computer device determines a target area in the first image, where the target area includes the first target frame and does not include the exclusion frame.
  • the computer device determines the first target frame and the exclusion frame in the first image, according to the first target frame and the exclusion frame, determine the target area in the first image that includes the first target frame and does not include the exclusion frame, then the target Objects that need to be kept are included in the area, and objects that are not to be kept are excluded.
  • the cropped image includes objects that need to be kept and excludes objects that do not need to be kept.
  • the computer device crops the first image based on the target area to obtain a second image that includes the first target frame and does not include the exclusion frame.
  • the target area includes the first target frame and does not include the exclusion frame
  • the computer device determines the target area in the first image, based on the target area
  • the first image is cropped to obtain a second image including the first target frame . Since the cropping is performed based on the target area, and the target area does not include the exclusion frame, the second image obtained by cropping also does not include the exclusion frame.
  • the second image includes the area framed by the first target frame and does not include the area framed by the exclusion frame. Therefore, the second image includes objects that need to be kept and does not include objects that do not need to be kept.
  • the number of at least one of the first object frame and the exclusion frame is multiple, and the second image includes the first object frame and does not include the exclusion frame means that the second image includes at least one first object frame And do not include any exclude boxes.
  • the embodiment of the present application is described by taking the execution subject as a computer device as an example.
  • the computer device is a server in the implementation environment shown in FIG. 1 above.
  • the computer device is a terminal in the implementation environment shown in FIG. 1 above.
  • the method provided in the embodiment of the present application divides the objects in the first image into objects that need to be kept and objects that do not need to be kept, and by determining the first target frame and exclusion box, the objects that need to be kept and those that do not need to be kept
  • the area where the object is located is marked. Since the target area in the first image includes the first target frame and does not include the exclusion frame, then based on the target area, the first image is cropped, and the first target frame is included and the exclusion frame is not included. of the second image. Among them, using the first target frame and the exclusion frame to mark the areas where the objects to be kept and the objects not to be kept in the image are located is beneficial to quickly identify the target area, thereby improving the speed of image cropping.
  • this image cropping method ensures that the second image includes key information that needs attention , and does not include interference information that does not need attention, thereby improving the effect of image cropping.
  • FIG. 3 is a flow chart of an image cropping method provided by an embodiment of the present application.
  • the execution body of the embodiment of the present application is a computer device. Referring to FIG. 3 , the method includes the following steps 301 to 305 .
  • a computer device determines an object frame where each object in a first image is located.
  • the computer device acquires the first image to be cropped, and identifies multiple objects in the first image, thereby determining the object frame where each object in the first image is located, the object frame is used to represent the position of the object, and the object framed by the object frame
  • the area of is the area where the object is located.
  • the object frame is a rectangular border, or may also be a border of other shapes.
  • the computer device determines an object frame where each object in the first image is located, including at least one of the following items.
  • the face frame is the object frame where the face is located, and the area framed by the face frame is the area where the face is located.
  • a face recognition model is stored in the computer device, and the face recognition model is invoked to perform face recognition on the first image to obtain a face frame where the face in the first image is located.
  • the object frame is the object frame where the object is located, and the area framed by the object frame is the area where the object is located.
  • an object recognition model is stored in the computer device, and the object recognition model is called to perform object recognition on the first image to obtain an object frame where the object in the first image is located.
  • the object recognition model can recognize various objects, such as vehicles, trees, buildings, furniture or animals.
  • the text box is the object box where the text is located, and the framed area of the text box is the area where the text is located.
  • a text recognition model is stored in the computer device, and the text recognition model is invoked to perform text recognition on the first image to obtain a text box where the text in the first image is located.
  • the first image is a video frame
  • the text in the first image is subtitles in the video frame.
  • the watermark frame is the object frame where the watermark is located, and the area framed by the watermark frame is the area where the watermark is located.
  • a watermark recognition model is stored in the computer device, and the watermark recognition model is called to perform watermark recognition on the first image to obtain a watermark frame where the watermark in the first image is located.
  • the watermark in the first image is a Logo (sign) etc. added to the first image.
  • each recognition model in the above-mentioned face recognition model, object recognition model, text recognition model and watermark recognition model can be any kind of neural network model, and the structures of different recognition models can be the same or different. , which is not limited in this embodiment of the present application.
  • the face recognition model, object recognition model, text recognition model and watermark recognition model can be obtained through supervised training, for example, according to the human face image and the face frame labeling results in the human face image, the human face recognition model can be obtained through supervised training.
  • Face recognition model according to the object image and the object frame labeling results in the object image, the object recognition model is obtained through supervised training; according to the text image and the text frame labeling results in the text image, the text recognition model is obtained through supervised training; according to the watermark image and The result of the watermark box annotation in the watermark image, and the watermark recognition model is obtained through supervised training.
  • the computer device performs object recognition on the first image to obtain the object frame where each object in the first image is located, and the computer device expands the size of the object frame by a third multiple, so as to ensure that the objects in the object frame The object is complete, avoiding the situation that the object in the object frame is incomplete due to the wrong recognition result.
  • expanding the third multiple refers to expanding the third multiple on the original basis, for example, the third multiple is 10%, and the size of the object frame is 100, then after expanding by 10%, the size of the object frame is 110.
  • enlarging the size of the object frame by a third multiple refers to enlarging the width and height of the object frame by a third multiple, respectively.
  • the third multiple is preset by the computer device.
  • the computer device determines the position information of each object frame in the first image in the first image, and stores the position information of the object frame, so that the subsequent location information in the first image Determine the object frame.
  • the computer device determines an object frame where objects belonging to the first type are located as a first target frame, and determines an object frame where objects belonging to the second type are located as an excluded frame.
  • the computer device classifies the plurality of objects in the first image into objects belonging to a first type and objects belonging to a second type.
  • the objects belonging to the first type are the objects that need to be kept, that is, the key information that needs to be paid attention to in the first image.
  • Objects belonging to the second type are objects that do not need to be kept, that is, interference information that does not need attention in the first image. Therefore, the computer device determines the object frame where the object belonging to the first type is located as the first target frame, and determines the object frame where the object belonging to the second type is located as the exclusion frame, so that the area that needs to be preserved and the unused area in the first image are determined. Areas to be preserved are marked.
  • the computer device uses the first marking method to mark the object frame where the object belonging to the first type is located to obtain the first target frame, and uses the second marking method to mark the object frame where the object belonging to the second type is located. Mark the object frame and get the exclusion frame.
  • the first marking mode is different from the second marking mode. Therefore, the computer device can subsequently determine which object frames in the image belong to the first target frame and which object frames belong to the excluded frame by identifying the marking method of the object frame, so that the first target frame and the excluded frame in the image are distinguish.
  • the first marking method refers to setting the edge line of the object frame to a first color
  • the second identification method refers to setting the edge line of the object frame to a second color
  • the first color is different from the second color
  • the first marking method refers to setting the edge line of the object frame to a first size
  • the second marking method refers to setting the edge line of the object frame to a second size, and the first size is different from the second size.
  • the first marking method refers to setting the object frame into a first shape
  • the second marking method refers to setting the object frame into a second shape
  • the first shape is different from the second shape
  • the first marking method refers to setting the edge line of the object frame to the first style
  • the second marking method refers to setting the edge line of the object frame to the second style
  • the first style is different from the second style , such as solid lines for the first style, dashed lines for the second style, etc.
  • the first marking manner and the second marking manner described above are only exemplary examples, and the embodiments of the present application are not limited thereto. In some embodiments, the first marking manner and the second marking manner may be other situations, as long as the first marking manner is different from the second marking manner.
  • the first marking method may also refer to setting the edge line of the object frame to the first color, first size and first style, and setting the object frame to the first shape; the second marking method may also be Refers to setting the edge line of the object frame to the second color, second size, and second style, and setting the object frame to the second shape.
  • the computer device can distinguish the target frame and the exclusion frame in the image by identifying the marking method of the object frame , so as to realize the automatic recognition of the target frame and the exclusion frame, which is beneficial to improve the recognition speed of the target frame and the exclusion frame.
  • the computer device subsequently crops the image based on the positions of the first target frame and the exclusion frame. Since the time spent in identifying the target frame and the exclusion frame has been shortened, the overall speed of image cropping can also be improved.
  • the computer device determines the object frame where the object belonging to the first type is located as the first target frame, including at least one of the following (1) and (2).
  • the object frame in the first image includes the face frame where the face is located, and the face is the key information that needs to be paid attention to, so the face is an object that needs to be kept, and the face belongs to the first type of object, so the computer equipment will use the face
  • the face frame where it is located is determined as the first target frame.
  • the object frame in the first image includes the object frame where the object is located, and the object is key information that needs attention, so the object is an object that needs to be kept, and the object belongs to the first type of object, so the computer device determines the object frame where the object is located as The first target box.
  • the computer device determines the object frame to which the object belonging to the second type belongs as the exclusion frame, including at least one of the following (3) and (4).
  • the object frame in the first image includes the text box where the text is located.
  • the text is noise information that does not need to be paid attention to, so the text is an object that does not need to be kept. OK to exclude box.
  • the object frame in the first image includes the watermark frame where the watermark is located.
  • the watermark is interference information that does not need to be paid attention to, so the watermark is an object that does not need to be kept. OK to exclude box.
  • the above-mentioned manner of determining the first target frame and the excluded frame is only an example, and the embodiment of the present application is not limited thereto.
  • the manner of determining the first target frame and the excluded frame can also be flexibly adjusted according to actual application scenarios. For example, if the actual application scenario is a scene that requires attention to text and watermarks, but not to human faces and objects, then the text box where the text is located and the watermark box where the watermark is located can be determined as the first target frame, and the human face The face frame where the object is located and the object frame where the object is located are determined as exclusion frames.
  • configuration information is stored in the computer device, the configuration information includes the first type and the second type, and the computer device compares the type of the object in the first image with the first type and the second type in the configuration information comparison, so as to determine which objects in the first image belong to the first type of objects and which objects belong to the second type of objects.
  • the configuration information is set in the computer equipment by the research and development personnel. By modifying the configuration information, the computer device can flexibly control which objects are kept and which objects are not kept in the cropped image.
  • the computer device enlarges the size of each first target frame by a first factor to obtain a plurality of second target frames when multiple first target frames have been determined, and for each For the second target frame, in the case that the second target frame intersects with other second target frames, merge the second target frame and other second target frames into a third target frame. Where any two second target frames intersect means that there is an intersection point between the two target frames.
  • the first multiple is preset by the computer device. For example, the first multiple is 20%, and the computer device enlarges the size of each first target frame by 20%.
  • the computer device expands the size of each first target frame by the first factor to obtain multiple second target frames. If a certain second target frame intersects with other second target frames, it indicates that the second target frame Objects in the target frame are relatively close to objects in the other second target frame. Considering that if the positions of two objects belonging to the first type are very close, the first image is cropped only based on the first target frame or the second target frame corresponding to one of the objects, which may cause the cropped image to include other Partial information about an object. Therefore, the computer device merges the second object frame and the other second object frames into a third object frame, which includes a plurality of objects that are relatively close, so the subsequent object frame can be based on the third object frame. The first image is cropped, so as to avoid incomplete information in the cropped image.
  • the computer device merges the second target frame A and the second target frame B into a third target frame. For example, if the second object frame A intersects both the second object frame B and the second object frame C, then the computer device merges the second object frame A, the second object frame B, and the second object frame C into a third object frame . For example, if the second object frame A does not intersect with any other second object frame, then the second object frame A remains independent and does not need to be merged with other second object frames.
  • the first target frame is a human face frame
  • the second target frame obtained by expanding the first target frame includes a human face.
  • the computer device crops the first image directly based on any one of the first target frames where the two faces are located, the cropped image is likely to include part of the information of the other face, resulting in information in the image having incomplete. Therefore, the computer device merges the two second target frames into a third target frame, which includes two human faces, and subsequently crops the first image based on the third target frame, and then crops the obtained image includes two faces.
  • the computer device determines multiple candidate regions in the first image based on the positions of the exclusion frames.
  • the computer device determines in the first image a plurality of candidate regions that do not include the exclusion frame based on the position of the exclusion frame, and then does not include objects that do not need to be retained in each of the determined candidate regions objects, which is convenient for subsequently cropping an image from the first image based on the candidate region, and the image does not include these objects that do not need to be preserved.
  • the computer device determines, among the edge lines of the exclusion frame, a target edge line that does not overlap with each edge line of the first image.
  • the computer device determines the straight line where the target edge line is located, and determines the area outside the straight line in the first image as the candidate area, and the outer side of the straight line refers to a side away from the exclusion frame.
  • the edge line of the excluded frame does not overlap with the edge line of the first image means that the edge line of the excluded frame and the edge line of the first image are not on a straight line. If an edge line of the exclusion box overlaps with an edge line of the first image, the area outside the straight line where the edge line is located is the area outside the first image, that is, in the first image, the edge line There is no candidate area outside the straight line where it is located.
  • an edge line of the exclusion box does not overlap with each edge line of the first image, there is an area in the first image outside the straight line where the edge line is located, so the area in the first image where the edge line is located can be The area outside the straight line is determined as the candidate area, and the candidate area determined by this method does not include the exclusion box.
  • the exclusion frame is a rectangular frame, and the exclusion frame includes a left edge line, a right edge line, an upper edge line and a lower edge line.
  • the target edge line may include at least one of a left edge line, a right edge line, an upper edge line, and a lower edge line of the exclusion box.
  • the computer device determines the candidate area based on the target edge line, including at least one of the following items.
  • the target edge line includes the left edge line of the exclusion frame, determine a first straight line where the target edge line is located, and determine an area on the left side of the first straight line in the first image as a candidate area.
  • the computer device determines the area on the left side of the first straight line in the first image as the candidate area.
  • the target edge line includes the right edge line of the exclusion frame, determine a second straight line where the target edge line is located, and determine an area on the right side of the second straight line in the first image as a candidate area.
  • the computer device determines the area on the right side of the second straight line in the first image as the candidate area.
  • the target edge line includes the upper edge line of the exclusion frame, determine a third straight line where the target edge line is located, and determine an area above the third straight line in the first image as a candidate area.
  • the computer device determines the region located above the third straight line in the first image as the candidate region.
  • the target edge line includes the lower edge line of the exclusion frame, determine the fourth straight line where the target edge line is located, and determine the area below the fourth straight line in the first image as the candidate area.
  • the computer device determines an area located below the fourth straight line in the first image as a candidate area.
  • the number of target edge lines in the exclusion frame that do not overlap with each edge line of the first image may be 4, 3, 2 or 1.
  • the candidate areas determined by the computer equipment include the following four situations.
  • FIG. 4 is a schematic diagram of an image segmentation method provided by an embodiment of the present application.
  • FIG. 4 includes a first image 401, the first image 401 includes an exclusion box 402 , the exclusion box 402 is in the middle area of the first image 401 , and the four edge lines of the exclusion box 402 do not overlap with the edge lines of the first image 401 .
  • the computer device determines the area on the left side of the straight line where the left edge line of the excluded frame 402 is located as the candidate area 403, and determines the area on the right side of the straight line where the right edge line of the excluded frame 402 is located as For the candidate area 404 , determine the area above the straight line where the upper edge line of the excluded frame 402 is located as the candidate area 405 , and determine the area below the straight line where the lower edge line of the excluded frame 402 is located as the candidate area 406 .
  • the shaded part represents the candidate region.
  • the computer device can determine four candidate regions in the first image, and the four candidate regions may intersect each other.
  • FIG. 5 is a schematic diagram of another image segmentation method provided by the present application.
  • 5 includes a first image 501, the first image 501 includes an exclusion box 502, the exclusion box 502 is in the edge area of the first image 501, and the upper edge line of the exclusion box 502 overlaps with the upper edge line of the first image 501 , the other three edge lines of the exclusion frame 502 do not overlap with the edge lines of the first image 501 .
  • the computer device determines the area on the left side of the straight line where the left edge line of the exclusion box 502 is located as the candidate area 503, and determines the area on the right side of the line where the right edge line of the exclusion box 502 is located as In the candidate area 504 , the area below the straight line where the lower edge line of the exclusion frame 502 is located is determined as the candidate area 505 .
  • the shaded part represents the candidate region.
  • the computer device can determine three candidate regions in the first image, and the three candidate regions may intersect each other.
  • FIG. 6 is a schematic diagram of another image segmentation method provided by the present application.
  • 6 includes a first image 601, the first image 601 includes an exclusion box 602, the exclusion box 602 is on the corner of the first image 601, the upper edge line and the left edge line of the exclusion box 602 are consistent with the first image 601
  • the computer device determines the area below the straight line where the lower edge line of the excluded frame 602 is located as the candidate area 603, and determines the area on the right side of the straight line where the right edge line of the excluded frame 602 is located as Candidate area 604 .
  • the shaded part represents the candidate region.
  • the computer device can determine two candidate regions in the first image, and the two candidate regions may intersect each other.
  • FIG. 7 is a schematic diagram of another image segmentation method provided by the present application.
  • 7 includes a first image 701
  • the first image 701 includes an exclusion box 702
  • the left edge line, right edge line and lower edge line of the exclusion box 702 overlap with the edge line of the first image 701, the exclusion box 702
  • the upper edge line of and the edge line of the first image 701 do not overlap.
  • the computer device determines the area above the straight line where the upper edge line of the exclusion frame 702 is located as the candidate area 703 .
  • the shaded part represents the candidate region.
  • the computer device can specify one candidate region in the first image.
  • the area in the first image is divided, so as to determine the candidate area not including the exclusion frame in the first image, the method
  • the logic is simple and easy to implement, which is conducive to improving the speed of image cropping.
  • the number of exclusion frames is multiple, and the computer device determines multiple candidate regions in the first image based on the positions of the exclusion frames, including: determining the first image based on the position of the first exclusion frames The first candidate area in the first candidate area does not include the first exclusion box, and the first exclusion box is any exclusion box in the plurality of exclusion boxes; in response to the first candidate area including the second exclusion box, based on the second The position of the exclusion box is to determine the second candidate area in the first candidate area, the second exclusion box is not included in the second candidate area, and the second exclusion box is any exclusion box in the plurality of exclusion boxes except the first exclusion box ; In response to the fact that the second candidate area does not include any exclusion box, take the second candidate area as the candidate area to be determined.
  • the first candidate area in response to the fact that the first candidate area does not include any exclusion box, the first candidate area is used as the candidate area to be determined.
  • the third candidate area in response to the second candidate area including the third exclusion box, based on the position of the third exclusion box, determine the third candidate area in the second candidate area, the third candidate area does not include the third exclusion box, the third The exclusion box is any exclusion box except the first exclusion box and the second exclusion box in the plurality of exclusion boxes; in response to the third candidate area not including any exclusion box, the third candidate area is used as the candidate area to be determined , in response to the third candidate area including the fourth exclusion box, based on the position of the fourth exclusion box, determine the fourth candidate area in the third candidate area, the fourth candidate area does not include the fourth exclusion box, the fourth exclusion box is Any one of the multiple exclusion boxes except the first exclusion box, the second exclusion box and the third exclusion box. And so on, until a candidate region that does not include any exclusion box is obtained.
  • the first exclusion frame determines the first candidate area in the first image, the first exclusion frame is not included in the first candidate area, and the first exclusion frame is any exclusion frame in the plurality of exclusion frames
  • determine the second candidate area in the first candidate area, the second candidate area does not include the second exclusion box, until each of the obtained candidate areas does not include any exclusion box.
  • the computer device randomly determines a first exclusion frame among the plurality of exclusion frames, and based on the position of the first exclusion frame, in the first image A first candidate region not including the first exclusion box is determined.
  • the first candidate area includes the second exclusion box, based on the position of the second exclusion box, determine the second candidate area that does not include the second exclusion box in the first candidate area, until each of the obtained candidate areas None of the exclude boxes are included.
  • the number of first candidate regions determined by the computer device is multiple. For each first candidate area, the computer device judges whether the first candidate area includes an exclusion box, if the first candidate area does not include an exclusion box, then there is no need to continue processing the first candidate area, the first candidate area directly as a complete candidate region.
  • the computer device determines a second candidate area that does not include the exclusion box in the first candidate area based on the position of any exclusion box in the first candidate area, and then the computer device Continue to judge whether the obtained second candidate area also includes an exclusion frame, if the exclusion frame is not included, the second candidate area is directly regarded as a complete candidate area, and if the exclusion frame is included, continue to process the second candidate area until the Each candidate region of does not include the exclusion box, and multiple candidate regions that do not include the exclusion box are obtained.
  • the number of first candidate regions determined by the computer device is multiple.
  • the computer device deletes first candidate regions whose size is smaller than a first threshold from the determined plurality of first candidate regions.
  • the subsequent step of determining candidate regions is performed based on the undeleted first candidate regions.
  • the second candidate region in the non-deletion first candidate region is determined based on the position of the second exclusion frame.
  • the non-deleted first candidate region is used as the candidate region to be determined.
  • the candidate area is an area that does not include an exclusion frame, and the target area including the target frame will be determined based on the candidate area, so as to crop the first image based on the target area. If the size of the candidate area is too small, then The possibility of determining the target area in the candidate area is small, so deleting the first candidate area whose size is smaller than the first threshold can reduce the invalid operation in which the target area is not determined in the first candidate area, thereby improving the operation efficiency. , if the size of the candidate area is too small, it may also affect the effect of subsequent image cropping, so deleting the first candidate area whose size is smaller than the first threshold can ensure that the size of the first candidate area is large enough, which is conducive to ensuring image cropping Effect.
  • the above embodiment only takes the first candidate area as an example for illustration, but in fact, each time the computer device determines a candidate area, it may first determine whether the size of the candidate area is smaller than the first threshold, and if it is smaller than the first threshold If the threshold value is higher than the first threshold value, the candidate area is deleted, and if it is not less than the first threshold value, the candidate area is retained, and subsequent operations are continued.
  • the computer device establishes a spatial coordinate system corresponding to the first image, and determines the coordinates of each excluded frame according to the spatial coordinate system and the positions of the excluded frame and the first target frame in the first image Information, according to the coordinate information of the excluded frame, determine the coordinate information of multiple candidate regions in the first image, and then perform the following steps 304-305 based on the coordinate information of the candidate regions. For example, the computer device determines the vertex at the lower left corner in the first image as the origin of the space coordinate system.
  • the computer device determines a target area including the first target frame among the plurality of candidate areas.
  • a target region including the first object frame is determined. Since the candidate region does not include the exclusion frame, the target area includes the first object frame and does not include the exclusion frame.
  • the computer device judges whether the candidate area includes the first target frame, if the candidate area includes the first target frame, then the candidate area is determined as the target area, if the candidate area does not include the first target frame, then This candidate area is not the target area.
  • the candidate area includes the first object frame means that the candidate area includes the complete first object frame, and if the candidate area only includes a partial area of the first object frame, it is considered that the candidate area does not include the first object frame.
  • the computer device determines, among the multiple candidate areas, multiple candidate target areas including the first target frame, and among the multiple candidate target areas, determines the target area with the largest area.
  • the computer device realizes determining the target area in the first image in the first image, and the target area includes the first target frame and does not include the exclusion frame.
  • the computer device expands the size of each first target frame by a first factor to obtain a plurality of second target frames when multiple first target frames have been determined , for each second object frame, if the second object frame intersects with other second object frames, merge the second object frame and other second object frames into a third object frame. Then, in the first image, the computer device determines the area that includes the third target frame and does not include the exclusion frame as the target area, and in the first image, includes the first target frame corresponding to the remaining second target frame, and The area not including the exclusion box is determined as the target area.
  • the remaining second target frame refers to the second target frame that has not been merged
  • the first target frame corresponding to the second target frame refers to the first target frame obtained by enlarging the second target frame by the first multiple.
  • the cropping target of the computer device is the combined third target frame and the first target frame before the expansion of the second target frame that has not been combined.
  • the above step 304 is replaced by: the computer device determines, among the multiple candidate areas, the candidate area including the third target frame as the target area, and determines the candidate area that includes the remaining second target frame corresponding to the first target frame The candidate area is determined as the target area.
  • the target area including the third target frame and the target area including the first target frame may be the same candidate area or different candidate areas.
  • the computer device determines a target area that includes at least one first target frame and does not include an exclusion frame in the first image.
  • the computer device determines a target area that includes the first target frame and does not include excluded frames in the first image.
  • the target areas determined by different first target frames may be the same area or different areas. Therefore, the computer device can determine at least one target area, and each target area may include one first target frame, or may include multiple first target frames.
  • the above step 304 is replaced by: the computer device determines a target area including at least one first target frame among multiple candidate areas.
  • the number of the first target frame is multiple, and the computer device determines that the face frame is included in the first image and does not Include the target area for the exclude box.
  • the face frame is an object frame including a face.
  • the human face is an object worthy of more attention, that is, an object that needs to be preserved more. Therefore, in the case that the first target frame includes the human face target frame, the computer device preferentially determines the target area including the human face in the case that the first image includes the human face frame.
  • the first target frame can be divided into two types: face frame and object frame. The target area of the frame, if there is no face frame, determine the target area including the object frame.
  • the above step 304 is replaced by: in the case that the multiple first target frames include the human face frame, the computer device determines the target area including the human face frame among the multiple candidate areas.
  • step 303-step 304 of the embodiment of the present application provides an area division strategy, based on the positions of the exclusion frame and the first target frame in the first image, it is possible to divide the region that does not include the exclusion frame and includes the first object frame in the first image.
  • a target area of a target frame the method is simple in logic and easy to implement.
  • the embodiment of the present application is only described by taking the determination of a target area including the first target frame among multiple candidate areas as an example. In another embodiment, if each candidate area does not include the first target frame, it is determined that the cropping of the first image fails.
  • the computer device crops the first image based on the target area to obtain a second image that includes the first target frame and does not include the exclusion frame.
  • the second image obtained by cropping also does not include the exclusion frame. That is, the second image includes the area framed by the first target frame and does not include the area framed by the exclusion frame. Therefore, the second image includes objects that need to be kept and does not include objects that do not need to be kept.
  • the computer device crops the first image based on the target area to obtain a second image that includes the first target frame but does not include the exclusion frame, and whose aspect ratio is the target aspect ratio.
  • the computer device crops the first image based on the target area to obtain a second image with an aspect ratio equal to the target aspect ratio, and the cropped second image includes the first target frame.
  • the image is cropped to fit the target aspect ratio.
  • the target aspect ratio is preset by the computer device, or the target aspect ratio is sent to the computer device by other devices to request the computer device to crop images conforming to the target aspect ratio.
  • the target aspect ratio is 1:3 etc.
  • the computer device crops the second image whose aspect ratio is the target aspect ratio, including: the computer device expands at least one of the width or height of the first target frame to obtain a fourth target frame, so that the fourth The aspect ratio of the target frame is the target aspect ratio; keep the center point of the fourth target frame unchanged, and expand the size of the fourth target frame until it is enlarged by the second multiple or any edge line of the enlarged fourth target frame is in line with the target The edge lines of the regions overlap to obtain a fifth target frame; the fifth target frame is cropped from the first image, and the cropped fifth target frame is determined as the second image.
  • the computer device first expands at least one of the width or height of the first target frame, so that the aspect ratio of the expanded fourth target frame is the target aspect ratio, thereby cropping an image with the target aspect ratio .
  • the fourth target frame is located in the target area, and the target area includes the fourth target frame and excludes the exclusion frame.
  • the size of the fourth target frame may be smaller, if the fourth target frame is directly cropped from the first image, and the cropped fourth target frame is determined as the second image, the size of the second image will also be relatively small, This results in poor image cropping, so the computer device enlarges the fourth target frame.
  • the computer equipment is limited to the second multiple, and enlarges the fourth target frame until the second multiple is enlarged to obtain the fifth target frame.
  • the computer device expands the fourth target frame within the limit of the target area until any edge line of the enlarged fourth target frame overlaps with any edge line of the target area , to get the fifth target box.
  • Computer equipment is limited to both the second multiple and the target area to avoid both of the above problems.
  • the computer device judges whether the second multiple is enlarged, and judges whether any edge line of the expanded fourth target frame overlaps with any edge line of the target area.
  • the computer device stops expanding and obtains the fifth target frame. That is, in the process of enlarging the fourth target frame, if the magnification factor reaches the second multiple, the expansion is stopped, or if any edge line of the expanded fourth target frame overlaps with any edge line of the target area , the expansion also stops.
  • Fig. 8 is a schematic diagram of an image cropping method provided by an embodiment of the present application.
  • Fig. 8 includes a target area 801 and a first target frame 802.
  • the computer device expands the height of the first target frame 802 to obtain an aspect ratio of the target width and height Compared with the fourth target frame 803, the computer device expands the size of the fourth target frame 803 in equal proportion to obtain the fifth target frame.
  • the fifth target frame includes the following two situations.
  • the first situation as shown in the schematic diagram in the lower left corner of FIG. 8 , during the process of expanding the size of the fourth target frame 803 by the computer device, if before the edge line of the expanded fourth target frame overlaps with the edge line of the target area, If the second factor is enlarged, the computer device stops the enlargement to obtain the fifth target frame 804, and the aspect ratio of the fifth target frame 804 is the target aspect ratio.
  • the second case as shown in the lower right corner of Figure 8, in the process of enlarging the size of the fourth target frame 803 by the computer device, if before enlarging the second multiple, the lower edge line of the enlarged fourth target frame is in line with the target If the lower edge lines of the regions overlap, the computer device stops enlarging to obtain the fifth target frame 805, and the aspect ratio of the fifth target frame 805 is the target aspect ratio.
  • the above step 305 of the embodiment of the present application provides an image cropping strategy.
  • the second image including the first target frame and excluding the exclusion frame can be cropped from the first image, and the width and height can also be cropped.
  • the operation is simple, and the flexibility of image cropping is improved.
  • the computer equipment uses the method provided by the embodiment of the present application and the method provided by related technologies to perform image cropping, and the cropped image is manually evaluated to judge the cropping effect, the cropping effect Bad images can be classified as badcase (bad example), and the experimental results show that compared with related technologies, the badcase rate of the method provided by the embodiment of the present application is lower than 15%, while the badcase rate of the method provided by the related technology is about 60%. %, that is to say, the method provided by the embodiment of the present application obviously improves the effect of image cropping.
  • badcase needs to be manually processed, which consumes a lot of manpower and time costs. Therefore, by reducing the badcase rate, the method provided in the embodiment of the present application can significantly improve the efficiency of the drawing process and reduce manpower and time costs.
  • the embodiment of the present application is described by taking the execution subject as a computer device as an example.
  • the computer device is a server in the implementation environment shown in FIG. 1 above.
  • the computer device is a terminal in the implementation environment shown in FIG. 1 above.
  • the method provided in the embodiment of the present application divides the objects in the first image into objects that need to be kept and objects that do not need to be kept, and by determining the first target frame and exclusion box, the objects that need to be kept and those that do not need to be kept
  • the area where the object is located is marked. Since the target area in the first image includes the first target frame and does not include the exclusion frame, then based on the target area, the first image is cropped, and the first target frame is included and the exclusion frame is not included. of the second image. Among them, using the first target frame and the exclusion frame to mark the areas where the objects to be kept and the objects not to be kept in the image are located is beneficial to quickly identify the target area, thereby improving the speed of image cropping.
  • this image cropping method ensures that the second image includes key information that needs attention , and does not include interference information that does not need attention, thereby improving the effect of image cropping.
  • each first target frame is enlarged by the first multiple to obtain multiple second target frames. If a certain second target frame intersects with other second target frames, it means that the object in the second target frame is not related to The objects in the other second target frame are relatively close, so the computer device merges the second target frame and the other second target frame into a third target frame, and the third target frame includes objects that are relatively close Therefore, the first image can be cropped based on the third target frame, so as to avoid incomplete information in the cropped image.
  • the region in the first image is divided, so as to determine the candidate area not including the exclusion frame in the first image.
  • the candidate area is an area that does not include an exclusion frame
  • the target area including the target frame will be determined based on the candidate area, so as to crop the first image based on the target area, so the first candidate area whose size is smaller than the first threshold is deleted, It is possible to reduce invalid operations in which the target area is not determined in the first candidate area, thereby improving operation efficiency.
  • deleting the first candidate region whose size is smaller than the first threshold can ensure that the size of the candidate region is large enough, which is beneficial to ensure the effect of image cropping.
  • FIG. 9 is a flow chart of an image cropping method provided by an embodiment of the present application.
  • the execution subject of the embodiment of the present application is a computer device. Referring to FIG. 9 , the method includes the following steps 901 to 907 .
  • the computer device acquires a plurality of related images corresponding to the first video in response to a cover setting request.
  • the cover setting request is used to request the computer device to set a cover for the first video, so the computer device obtains a plurality of associated images corresponding to the first video in response to the cover setting request, and the associated images are used to display the content of the first video, so Subsequently, the cover of the first video may be determined based on the multiple associated images.
  • the cover page setting request is sent by other devices, for example, the computer device is a server in the implementation environment of Figure 1 above, and the other device is a terminal in the implementation environment of Figure 1 above, the cover page The setup request is sent by the terminal to the server.
  • the cover page setting request is directly obtained by a computer device, for example, the computer device is a terminal in the implementation environment of FIG. 1 above, and the terminal can directly obtain the cover page setting request.
  • the computer device in response to the cover setting request, acquires the candidate cover and the video identifier carried in the cover setting request.
  • the computer device acquires at least one video frame corresponding to the video identifier from the video frame database, and determines the candidate cover and the at least one video frame as associated images corresponding to the first video.
  • the cover setting request carries an alternative cover and a video identifier, where the video identifier indicates the first video, for example, the video identifier is the name or number of the first video.
  • the alternative cover can display the content of the first video, and the alternative cover is used to set the cover of the first video, for example, the alternative cover is a cover uploaded by a user.
  • the video frame database is used to store video frames of any video, and each video frame corresponds to the video ID of the video where the video frame is located, and the video frame database stores video frames of the first video. Since the video ID in the cover setting request indicates the first video, the computer device acquires at least one video frame corresponding to the video ID in the video frame database, and the at least one video frame is the video frame of the first video, so the at least One video frame can display the content of the first video.
  • the computer device determines the candidate cover and the at least one video frame as associated images corresponding to the first video, so as to subsequently set a cover for the first video based on the determined plurality of associated images.
  • the manner of obtaining the associated image corresponding to the first video may also be: the computer device responds to the cover setting request, and obtains the video ID carried in the cover setting request, and the computer device obtains at least the video ID corresponding to the video frame database.
  • the computer device performs sharpness recognition on multiple associated images respectively to obtain the sharpness of each associated image, and among the multiple associated images, determine an image with a sharpness greater than a fourth threshold as the first image.
  • the plurality of associated images are used to set the cover of the first video. Considering that if the definition of the associated images is not high enough, the cover of the first video will be relatively blurred, resulting in the effect of the cover of the first video not being good enough. Therefore, the computer device first Sharpness identification is performed on multiple associated images to obtain the definition of each associated image. For each associated image, if the definition of the associated image is greater than the fourth threshold, it means that the associated image is clear enough, and the computer device determines the associated image as the first image; if the definition of the associated image is not greater than the fourth threshold , indicating that the associated image is not clear enough, and the computer device discards the associated image. Therefore, the computer device can filter the multiple associated images based on the sharpness, so as to obtain the first image whose sharpness is greater than the fourth threshold. Optionally, the fourth threshold is preset by the computer device.
  • a sharpness identification model is stored in the computer device, and the sharpness identification model is used to identify the sharpness of an image. Based on the sharpness recognition model, the computer device performs sharpness recognition on multiple associated images to obtain the sharpness of each associated image.
  • the structure of the sharpness recognition model may be any kind of neural network model, which is not limited in this embodiment of the present application.
  • the sharpness recognition model can be obtained through supervised training, for example, according to the sample image and the sharpness label corresponding to the sample image, the sharpness recognition model can be obtained through supervised training.
  • the computer device uses the first value and the second value to indicate the definition of the associated image, the first value indicates that the definition of the associated image is low, and the second value indicates that the definition of the associated image is high. For example, if the first value is 0 and the second value is 1, then the computer device determines the associated image whose resolution is the second value as the first image.
  • the computer device realizes acquiring the first image in response to the cover setting request for the first video, and the first image is used to display the content of the first video.
  • the computer device may acquire the first image in other ways. For example, if the first image is carried in the cover setting request, the computer device may directly acquire the first image in the cover setting request.
  • the computer device determines an object frame where each object in the first image is located.
  • the computer device determines the object frame where the object belonging to the first type is located as the first target frame, and determines the object frame where the object belonging to the second type is located as the exclusion frame.
  • the computer device determines a target area in the first image, where the target area includes the first target frame and does not include the exclusion frame.
  • the computer device crops the first image based on the target area, to obtain a second image that includes the first target frame and does not include the exclusion frame.
  • the above steps 903 to 906 are only described by taking the processing of a first image to obtain a second image as an example.
  • the computer device determines a plurality of first images, and then the computer device executes the above steps 903 to 906 on at least one first image according to the arrangement sequence of the plurality of first images.
  • the computer device For any first image in the plurality of first images, the computer device performs a cropping process on the first image, and if the second image is successfully cropped out of the first image, there is no need for other first images after the first image An image is cropped. If the second image is not cropped from the first image, the computer device continues to crop other first images following the first image until the second image is successfully cropped.
  • the computer device preferentially crops the alternative cover.
  • the second image is not cropped out of the first image.
  • it cannot be determined in the first image that includes the first target frame and does not include the exclusion frame. target area.
  • the second image including the first target frame and not including the exclusion frame cannot be cropped from the first image.
  • the computer device may set a plurality of covers with different aspect ratios for the first video. Then the computer device determines a plurality of different target aspect ratios, and then the computer device executes the above-mentioned steps 903 to 906 on the plurality of first images according to the sequence of arrangement of the plurality of first images, and obtains the aspect ratios of the plurality of target images respectively. aspect ratio of the second image.
  • the process of obtaining the second image in the above step 903-step 906 is the same as the process of obtaining the second image in the above step 301-step 305, and will not be repeated here.
  • the computer device determines the second image as the cover of the first video, or adjusts the second image to the target size, and determines the adjusted second image as the cover of the first video.
  • the second image includes objects that need to be kept and does not include objects that do not need to be kept, and the computer device determines that the second image is the cover of the first video, then the cover of the first video includes key information that needs to be paid attention to, and does not include
  • the disturbing information that does not need attention increases the information volume of the key information of the video cover, and at the same time reduces the information volume of the disturbing information of the video cover, thereby improving the display effect of the video cover.
  • the computer device first adjusts the second image to the target size, and the adjusted second image It is determined as the cover of the first video, so that the cover of the first video is adapted to the cover display area.
  • the target size may be larger or smaller than the size of the second image.
  • the computer device expands the second image to the target size, and the enlarged second image is determined as the cover of the first video; if the target size is smaller than the size of the second image, Then the computer device reduces the second image to the target size, and determines the reduced second image as the cover of the first video.
  • the aspect ratio of the cover display area is the target aspect ratio
  • the computer device cuts out the second image whose aspect ratio is the target aspect ratio from the first image in the above step 903-step 906, Then, in the step 907 , the computer device proportionally adjusts (for example, enlarges or reduces) the second image with the target aspect ratio to the target size, and obtains the adjusted (for example, enlarges or reduces) the second image.
  • the target size is different from the size of the second image.
  • the target size may also be the same as the size of the second image, in which case the computer device determines the second image as the cover of the first video.
  • the computer device divides the second image into multiple image regions; for each image region, determine the difference parameter between the brightness of multiple pixels in the image region; based on the multiple image regions Respectively corresponding difference parameters, determine the quantity of the difference parameters not less than the second threshold; in the case that the quantity is greater than the third threshold, the second image is determined to be the cover of the first video, or the second image is adjusted (such as, zoom in or zoom out) to the target size, and determine the adjusted (eg zoom in or zoom out) second image as the cover of the first video.
  • the second threshold and the third threshold are preset by the computer device.
  • the difference parameter between the luminances indicates the degree of difference between the luminances, and the smaller the difference parameter, the more similar the multiple luminances are, and the larger the difference parameter, it means the difference between the multiple luminances. The greater the difference.
  • the difference parameter is the variance or standard deviation among multiple luminances.
  • the brightness is used to represent the brightness of the color of the pixel.
  • the brightness is a parameter corresponding to the V (brightness) channel in the HSV (Hue-Aturation-Value, Hue-Saturation-Brightness) color space.
  • the difference parameter between the brightness of multiple pixels in the image area is smaller than the second threshold, indicating that the colors between the multiple pixels in the image area are close, then the image area can be approximately considered as Solid color area.
  • the number of difference parameters not smaller than the second threshold is not greater than the third threshold, it means that the number of difference parameters smaller than the second threshold is large, that is, in the second image If the number of solid-color areas in the image is large, the amount of information in the second image is small. If the cover of the first video is determined based on the second image, the amount of information in the determined cover is small, and the display effect of the cover of the video is not good. good.
  • the computer device determines the cover of the first video based on the second image.
  • the difference parameters respectively corresponding to any image area refer to difference parameters between the brightness of multiple pixel points in the any image area.
  • the second image is screened based on the difference parameters between the brightness of each pixel in the second image, the second image with less information is discarded, and the second image with larger information is discarded.
  • the image is used to determine the cover of the first video, so as to ensure that the amount of information on the cover of the first video is large enough to improve the display effect of the cover of the first video.
  • FIG. 10 is a flow chart of another image cropping method provided by the embodiment of the present application. Referring to FIG. 10 , the method includes the following steps 1001 to 1004 .
  • a computer device acquires an associated image corresponding to a first video.
  • the associated image includes an alternative cover of the first video and a video frame of the first video.
  • the computer device For each associated image, the computer device performs face recognition, object recognition, text recognition, watermark identification, and definition identification on the associated image to determine the face frame, object frame, text frame, and watermark in the associated image frame, and the clarity of the associated image.
  • the computer device discards associated images whose resolution is not greater than the fourth threshold, determines the face frames and object frames in the remaining associated images as target frames that need to be kept, and determines the text frame and watermark frame as unnecessary Reserved exclude boxes.
  • the computer device executes an area division policy and an image cropping policy on the remaining associated images.
  • the region division strategy is the method in the above step 303-step 304
  • the image cropping strategy is the method in the above step 305.
  • the computer device outputs an image obtained by clipping the associated image.
  • the image is clipped as the cover of the video by executing the area division strategy and the image clipping strategy on the image by computer equipment, which significantly improves the efficiency of the cover clipping process and reduces labor costs and time costs.
  • the embodiment of the present application is described by taking the execution subject as a computer device as an example.
  • the computer device is a server in the implementation environment shown in FIG. 1 above.
  • the computer device is a terminal in the implementation environment shown in FIG. 1 above.
  • the method provided in the embodiment of the present application divides the objects in the first image into objects that need to be kept and objects that do not need to be kept, and by determining the first target frame and exclusion box, the objects that need to be kept and those that do not need to be kept
  • the area where the object is located is marked. Since the target area in the first image includes the first target frame and does not include the exclusion frame, then based on the target area, the first image is cropped, and the first target frame is included and the exclusion frame is not included. of the second image. Among them, using the first target frame and the exclusion frame to mark the areas where the objects to be kept and the objects not to be kept in the image are located is beneficial to quickly identify the target area, thereby improving the speed of image cropping.
  • this image cropping method ensures that the second image includes key information that needs attention , and does not include interference information that does not need attention, thereby improving the effect of image cropping.
  • the embodiment of the present application provides a method for cropping a video cover. Since the second image includes objects that need to be kept and does not include objects that do not need to be kept, the computer device determines the cover of the first video based on the second image, Then the cover of the first video includes the key information that needs to be paid attention to, and does not include the disturbing information that does not need to pay attention to, which improves the information volume of the key information of the video cover, and reduces the information volume of the disturbing information of the video cover, thereby improving The display effect of the video cover.
  • the multiple associated images are screened, so as to obtain the first image whose sharpness is greater than the fourth threshold. Since the first image is used to set the cover of the first video, by ensuring the clarity of the first image, the clarity of the cover of the first video can be guaranteed, thereby improving the cover display effect of the first video.
  • the second image is screened, the second image with less information is discarded, and the first image is determined based on the second image with larger information.
  • the cover of the video so as to ensure that the amount of information on the cover of the first video is large enough to improve the display effect of the cover of the first video.
  • FIG. 11 is a flowchart of an image cropping method provided by an embodiment of the present application. Referring to FIG. 11 , the method includes the following steps 1101 to 1105 .
  • the user terminal When detecting a cover setting request for a video, the user terminal acquires the video ID of the video and an alternative cover uploaded by the user, and sends a cover setting request carrying the video ID and the alternative cover to the server.
  • the cover page setting request is triggered by a cover page setting operation performed by the user in the user terminal.
  • the server In response to the cover setting request sent by the user terminal, the server acquires the candidate cover and the video ID in the cover setting request, and acquires multiple video frames corresponding to the video ID from the video frame database.
  • the server screens the images whose resolution is greater than the fourth threshold from the candidate cover and multiple video frames, and determines the screened image as the first image.
  • the server uses the image cropping method provided in the embodiment of FIG. 3 to crop a plurality of first images to obtain second images of different sizes, and determine the second images of different sizes as the cover of the video respectively.
  • the server respectively publishes the videos whose covers are second images of different sizes.
  • the cover setting request sent by the terminal is also used to request to release the video with the cover set, so the computer device determines the second images of different sizes as the cover of the video respectively, and releases the video whose cover is the second image of different sizes.
  • the server adopts the method provided by the embodiment in Figure 3 above, Automatically cut out covers of different sizes for the video, which can improve the cover display effect of the video and save manpower consumption.
  • the image cropping method provided in the foregoing embodiments may also be applied in other scenarios.
  • the image cropping method provided in the above embodiment is used to crop multiple images of different sizes into the same size.
  • an image is cropped to a size that meets requirements, etc.
  • the embodiment of the present application does not limit the application scenarios of the image cropping method.
  • FIG. 12 is a schematic structural diagram of an image cropping device provided by an embodiment of the present application. Referring to Figure 12, the device includes:
  • An object frame determining module 1201, configured to determine the object frame where each object in the first image is located;
  • a target frame and exclusion frame determining module 1202 configured to determine the object frame where the object belonging to the first type is located as the first target frame, and determine the object frame where the object belonging to the second type is located as the exclusion frame, and the object frame of the first type Objects that need to be retained, and objects of the second type are objects that do not need to be retained;
  • a target area determination module 1203, configured to determine a target area in the first image, where the target area includes the first target frame and does not include an exclusion frame;
  • a cropping module 1204 configured to crop the first image based on the target area to obtain a second image including the first target frame and excluding the exclusion frame.
  • the image cropping device provided in the embodiment of the present application divides the objects in the first image into objects that need to be kept and objects that do not need to be kept, and by determining the first target frame and the exclusion The area where the reserved object is located is marked. Since the target area in the first image includes the first target frame and does not include the exclusion frame, then based on the target area, the first image is cropped to obtain the first target frame and does not include Exclude the second image of the box. Among them, using the first target frame and the exclusion frame to mark the areas where the objects to be kept and the objects not to be kept in the image are located is beneficial to quickly identify the target area, thereby improving the speed of image cropping.
  • this image cropping method ensures that the second image includes key information that needs attention , and does not include interference information that does not need attention, thereby improving the effect of image cropping.
  • the target area determination module 1203 includes:
  • a candidate region determining unit 1213 configured to determine a plurality of candidate regions in the first image based on the position of the exclusion frame, and each candidate region does not include the exclusion frame;
  • the target area determining unit 1223 is configured to determine a target area including the first target frame among the plurality of candidate areas.
  • the candidate region determining unit 1213 is configured to:
  • the candidate region determining unit 1213 is configured to perform at least one of the following:
  • the target edge line includes the left edge line of the exclusion frame, determine the first straight line where the target edge line is located, and determine the area on the left side of the first straight line in the first image as a candidate area;
  • the target edge line includes the right edge line of the exclusion frame, determine the second straight line where the target edge line is located, and determine the area on the right side of the second straight line in the first image as a candidate area;
  • the target edge line includes the upper edge line of the exclusion frame, determine the third straight line where the target edge line is located, and determine the area on the upper side of the third straight line in the first image as a candidate area;
  • a fourth straight line where the target edge line is located is determined, and an area located below the fourth straight line in the first image is determined as a candidate area.
  • the number of excluded frames is multiple, and the candidate region determining unit 1213 is configured to:
  • the first exclusion frame Based on the position of the first exclusion frame, determine the first candidate area in the first image, the first exclusion frame is not included in the first candidate area, and the first exclusion frame is any exclusion frame in the plurality of exclusion frames;
  • the second candidate area In response to the first candidate area including the second exclusion box, based on the position of the second exclusion box, determine the second candidate area in the first candidate area, the second candidate area does not include the second exclusion box, and the second exclusion box is more than Any exclusion box in the first exclusion box except the first exclusion box;
  • the second candidate area In response to the fact that the second candidate area does not include any exclusion box, the second candidate area is used as a candidate area.
  • the device further includes:
  • An area deletion module 1205, configured to delete a first candidate area whose size is smaller than a first threshold from the determined plurality of first candidate areas;
  • the candidate region determining unit 1213 is configured to determine a second candidate region in the non-deleted first candidate region based on the position of the second excluded frame in response to the non-deleted first candidate region including the second excluded frame.
  • the object frame determination module 1201 is configured to perform at least one of the following:
  • the target frame and exclusion frame determination module 1202 is configured to perform at least one of the following:
  • the object frame where the object is located is determined as the first target frame.
  • the target frame and exclusion frame determination module 1202 is configured to perform at least one of the following:
  • the device further includes:
  • An expansion module 1206, configured to expand the size of each first target frame by a first factor to obtain multiple second target frames when multiple first target frames have been determined;
  • the merging module 1207 is configured to, for each second object frame, merge the second object frame and other second object frames into a third object frame when the second object frame intersects with other second object frames;
  • the first determining unit 1233 is configured to determine, in the first image, an area including the third target frame and not including the exclusion frame as the target area;
  • the second determination unit 1243 is configured to determine, in the first image, an area that includes the first target frame corresponding to the remaining second target frame and does not include the exclusion frame as the target area, and the remaining second target frame is no The second target box for merging.
  • the target area determination module 1203 includes:
  • the third determining unit 1253 is configured to determine, in the first image, a target area that includes at least one first target frame and does not include an exclusion frame.
  • the target area determination module 1203 includes:
  • the fourth determining unit 1263 is configured to determine, in the first image, a target area that includes a human face frame and does not include an exclusion frame when a plurality of first target frames include a human face frame.
  • the clipping module 1204 includes:
  • the cropping unit 1214 is configured to crop the first image based on the target area to obtain a second image that includes the first target frame but does not include the exclusion frame, and whose aspect ratio is the target aspect ratio.
  • the clipping unit 1214 is configured to:
  • the fifth target frame is cropped from the first image, and the cropped fifth target frame is determined as the second image.
  • the device further includes:
  • An image acquisition module 1208, configured to acquire a first image in response to a cover setting request for the first video, where the first image is used to display the content of the first video;
  • the cover determining module 1209 is configured to determine the second image as the cover of the first video, or adjust the second image to the target size, and determine the adjusted second image as the cover of the first video.
  • the cover page determination module 1209 includes:
  • an area segmentation unit 1219 configured to segment the second image into multiple image areas
  • a difference parameter determining unit 1229 configured to, for each image region, determine a difference parameter between the brightness of multiple pixels in the image region
  • a quantity determination unit 1239 configured to determine the quantity of difference parameters not less than the second threshold based on the difference parameters respectively corresponding to the plurality of image regions;
  • the cover determining unit 1249 is configured to determine the second image as the cover of the first video when the number is greater than the third threshold, or adjust the second image to the target size, and determine the adjusted second image as the cover of the first video.
  • the cover of a video is configured to determine the second image as the cover of the first video when the number is greater than the third threshold, or adjust the second image to the target size, and determine the adjusted second image as the cover of the first video.
  • the image acquisition module 1208 includes:
  • An associated image acquisition unit 1218 configured to acquire a plurality of associated images corresponding to the first video in response to the cover setting request, and the associated images are used to display the content of the first video;
  • the sharpness identification unit 1228 is configured to respectively perform sharpness identification on a plurality of associated images to obtain the definition of each associated image;
  • the image determining unit 1238 is configured to determine, among the plurality of associated images, an image whose resolution is greater than a fourth threshold as the first image.
  • the associated image acquisition unit 1218 is configured to:
  • At least one video frame corresponding to the video identifier is acquired;
  • the candidate cover and at least one video frame are determined as associated images corresponding to the first video.
  • the image cropping device provided in the above-mentioned embodiment performs image cropping
  • the division of the above-mentioned functional modules is used as an example for illustration.
  • the above-mentioned function allocation can be completed by different functional modules according to needs. That is, the internal structure of the computer device is divided into different functional modules to complete all or part of the functions described above.
  • the image cropping device and the image cropping method embodiments provided in the above embodiments belong to the same concept, and the specific implementation process thereof is detailed in the method embodiments, and will not be repeated here.
  • the embodiment of the present application also provides a computer device, the computer device includes a processor and a memory, at least one computer program is stored in the memory, and the at least one computer program is loaded and executed by the processor, so that the computer device implements the above embodiments The operations performed in the image cropping method of the .
  • the computer device is provided as a terminal, for example, the terminal is a smart phone, a tablet computer, a notebook computer, a desktop computer, a smart speaker, a smart watch, a smart TV, a smart vehicle terminal, and the like.
  • Fig. 14 shows a schematic structural diagram of a terminal 1400 provided by an exemplary embodiment of the present application.
  • the terminal 1400 includes: a processor 1401 and a memory 1402 .
  • the processor 1401 may include one or more processing cores, such as a 4-core processor, an 8-core processor, and the like.
  • Processor 1401 can be realized by at least one hardware form in DSP (Digital Signal Processing, digital signal processing), FPGA (Field Programmable Gate Array, field programmable gate array), PLA (Programmable Logic Array, programmable logic array) .
  • the processor 1401 can also include a main processor and a coprocessor, the main processor is a processor for processing data in the wake-up state, also called CPU (Central Processing Unit, central processing unit); the coprocessor is Low-power processor for processing data in standby state.
  • the processor 1401 may be integrated with a GPU (Graphics Processing Unit, image processing interactor), and the GPU is used for rendering and drawing the content that needs to be displayed on the display screen.
  • the processor 1401 may also include an AI (Artificial Intelligence, artificial intelligence) processor, where the AI processor is used to process computing operations related to machine learning.
  • AI Artificial Intelligence, artificial intelligence
  • Memory 1402 may include one or more computer-readable storage media, which may be non-transitory.
  • the memory 1402 may also include high-speed random access memory, and non-volatile memory, such as one or more magnetic disk storage devices and flash memory storage devices.
  • non-transitory computer-readable storage medium in the memory 1402 is used to store at least one computer program, and the at least one computer program is used to be possessed by the processor 1401 to implement the methods provided by the method embodiments in this application. Image cropping method.
  • the terminal 1400 may optionally further include: a peripheral device interface 1403 and at least one peripheral device.
  • the processor 1401, the memory 1402, and the peripheral device interface 1403 may be connected through buses or signal lines.
  • Each peripheral device can be connected to the peripheral device interface 1403 through a bus, a signal line or a circuit board.
  • the peripheral device includes: at least one of a radio frequency circuit 1404 , a display screen 1405 and a camera assembly 1406 .
  • the peripheral device interface 1403 may be used to connect at least one peripheral device related to I/O (Input/Output, input/output) to the processor 1401 and the memory 1402 .
  • the processor 1401, memory 1402 and peripheral device interface 1403 are integrated on the same chip or circuit board; in some other embodiments, any one of the processor 1401, memory 1402 and peripheral device interface 1403 or The two can be implemented on a separate chip or circuit board, which is not limited in this embodiment.
  • the radio frequency circuit 1404 is used to receive and transmit RF (Radio Frequency, radio frequency) signals, also called electromagnetic signals.
  • the radio frequency circuit 1404 communicates with the communication network and other communication devices through electromagnetic signals.
  • the radio frequency circuit 1404 converts electrical signals into electromagnetic signals for transmission, or converts received electromagnetic signals into electrical signals.
  • the radio frequency circuit 1404 includes: an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a subscriber identity module card, and the like.
  • the radio frequency circuit 1404 can communicate with other devices through at least one wireless communication protocol.
  • the wireless communication protocol includes but is not limited to: metropolitan area network, mobile communication networks of various generations (2G, 3G, 4G and 5G), wireless local area network and/or WiFi (Wireless Fidelity, wireless fidelity) network.
  • the radio frequency circuit 1404 may also include circuits related to NFC (Near Field Communication, short-range wireless communication), which is not limited in this application.
  • the display screen 1405 is used to display a UI (User Interface, user interface).
  • the UI can include graphics, text, icons, video, and any combination thereof.
  • the display screen 1405 also has the ability to collect touch signals on or above the surface of the display screen 1405 .
  • the touch signal can be input to the processor 1401 as a control signal for processing.
  • the display screen 1405 can also be used to provide virtual buttons and/or virtual keyboards, also called soft buttons and/or soft keyboards.
  • the display screen 1405 may be a flexible display screen, which is arranged on a curved surface or a folded surface of the terminal 1400 . Even, the display screen 1405 can also be set as a non-rectangular irregular figure, that is, a special-shaped screen.
  • the display screen 1405 can be made of LCD (Liquid Crystal Display, liquid crystal display), OLED (Organic Light-Emitting Diode, organic light-emitting diode) and other materials.
  • the camera assembly 1406 is used to capture images or video.
  • the camera component 1406 includes a front camera and a rear camera.
  • the front camera is set on the front panel of the terminal 1400
  • the rear camera is set on the back of the terminal 1400 .
  • there are at least two rear cameras which are any one of the main camera, depth-of-field camera, wide-angle camera, and telephoto camera, so as to realize the fusion of the main camera and the depth-of-field camera to realize the background blur function.
  • camera assembly 1406 may also include a flash.
  • the flash can be a single-color temperature flash or a dual-color temperature flash. Dual color temperature flash refers to the combination of warm light flash and cold light flash, which can be used for light compensation under different color temperatures.
  • FIG. 14 does not limit the terminal 1400, and may include more or less components than shown in the figure, or combine certain components, or adopt different component arrangements.
  • FIG. 15 is a schematic structural diagram of a server provided by an embodiment of the present application.
  • the server 1500 may have relatively large differences due to different configurations or performances, and may include one or more than one processor (Central Processing Units, CPU) 1501 and one Or more than one memory 1502, wherein at least one computer program is stored in the memory 1502, and the at least one computer program is loaded and executed by the processor 1501 to implement the image cropping method provided by the above method embodiments.
  • the server may also have components such as a wired or wireless network interface, a keyboard, and an input and output interface for input and output, and the server may also include other components for realizing device functions, which will not be repeated here.
  • the embodiment of the present application also provides a non-volatile computer-readable storage medium, at least one computer program is stored in the non-volatile computer-readable storage medium, and the at least one computer program is loaded and executed by a processor to The computer is made to implement the operations performed in the image cropping method of the above-mentioned embodiment.
  • the embodiment of the present application also provides a computer program product or computer program, the computer program product or computer program includes computer program code, the computer program code is stored in a non-volatile computer-readable storage medium, and the processor of the computer device operates from the non-volatile
  • the volatile computer-readable storage medium reads the computer program code, and the processor executes the computer program code, so that the computer device implements the operations performed in the image cropping method of the above-mentioned embodiments.
  • the computer programs involved in the embodiments of the present application can be deployed and executed on one computer device, or executed on multiple computer devices at one location, or distributed in multiple locations and communicated Executed on multiple computer devices interconnected by the network, multiple computer devices distributed in multiple locations and interconnected through a communication network can form a blockchain system.
  • the steps for realizing the above-mentioned embodiments can be completed by hardware, and can also be completed by instructing related hardware through a program, and the program can be stored in a non-volatile computer-readable storage
  • the storage medium mentioned above may be a read-only memory, a magnetic disk or an optical disk, and the like.

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Multimedia (AREA)
  • Health & Medical Sciences (AREA)
  • Human Computer Interaction (AREA)
  • Oral & Maxillofacial Surgery (AREA)
  • General Health & Medical Sciences (AREA)
  • Geometry (AREA)
  • Psychiatry (AREA)
  • Social Psychology (AREA)
  • Image Processing (AREA)

Abstract

图像裁剪方法、装置、计算机设备及存储介质,属于计算机技术领域。该方法包括:确定第一图像中的每个对象所在的对象框(201);将属于第一类型的对象所在的对象框确定为第一目标框,将属于第二类型的对象所在的对象框确定为排除框,第一类型的对象为需要保留的对象,第二类型的对象为不需要保留的对象(202);确定第一图像中的目标区域,目标区域包括第一目标框且不包括排除框(203);基于目标区域,对第一图像进行裁剪,得到包括第一目标框且不包括排除框的第二图像(204)。采用上述方法、装置、计算机设备及存储介质,能够提高图像裁剪的效果和图像裁剪的速度。

Description

图像裁剪方法、装置、计算机设备及存储介质
本申请要求于2021年09月27日提交的申请号为202111137663.4、发明名称为“图像裁剪方法、装置、计算机设备及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请实施例涉及计算机技术领域,特别涉及一种图像裁剪方法、装置、计算机设备及存储介质。
背景技术
随着计算机技术的快速发展,在各个领域中对图像进行裁剪的需求也越来越强。相关技术中,通常会采用居中裁剪的方式,也即是将图像中的边缘区域裁剪掉,保留图像的中间区域。但是,裁剪得到的图像中会存在关键信息不完整的问题,或者包括了较多的干扰信息,因此图像裁剪的效果不佳。
发明内容
本申请实施例提供了一种图像裁剪方法、装置、计算机设备及存储介质,能够提高图像裁剪的效果。所述技术方案包括如下方面。
一方面,提供了一种图像裁剪方法,所述方法由计算机设备执行,所述方法包括:
确定第一图像中的每个对象所在的对象框;
将属于第一类型的对象所在的对象框确定为第一目标框,将属于第二类型的对象所在的对象框确定为排除框,所述第一类型的对象为需要保留的对象,所述第二类型的对象为不需要保留的对象;
确定所述第一图像中的目标区域,所述目标区域包括所述第一目标框且不包括所述排除框;
基于所述目标区域,对所述第一图像进行裁剪,得到包括所述第一目标框且不包括所述排除框的第二图像。
另一方面,提供了一种图像裁剪装置,所述装置包括:
对象框确定模块,用于确定第一图像中的每个对象所在的对象框;
目标框和排除框确定模块,用于将属于第一类型的对象所在的对象框确定为第一目标框,将属于第二类型的对象所在的对象框确定为排除框,所述第一类型的对象为需要保留的对象,所述第二类型的对象为不需要保留的对象;
目标区域确定模块,用于确定所述第一图像中的目标区域,所述目标区域包括所述第一目标框且不包括所述排除框;
裁剪模块,用于基于所述目标区域,对所述第一图像进行裁剪,得到包括所述第一目标框且不包括所述排除框的第二图像。
另一方面,提供了一种计算机设备,所述计算机设备包括处理器和存储器,所述存储器中存储有至少一条计算机程序,所述至少一条计算机程序由所述处理器加载并执行,以使所述计算机设备实现如上述方面所述的图像裁剪方法中所执行的操作。
另一方面,提供了一种非易失性计算机可读存储介质,所述非易失性计算机可读存储介 质中存储有至少一条计算机程序,所述至少一条计算机程序由处理器加载并执行,以使计算机实现如上述方面所述的图像裁剪方法中所执行的操作。
另一方面,提供了一种计算机程序产品或计算机程序,所述计算机程序产品或计算机程序包括计算机程序代码,所述计算机程序代码存储在非易失性计算机可读存储介质中,计算机设备的处理器从非易失性计算机可读存储介质读取所述计算机程序代码,处理器执行所述计算机程序代码,使得所述计算机设备实现如上述方面所述的图像裁剪方法中所执行的操作。
本申请实施例提供的方法、装置、计算机设备及存储介质,将第一图像中的对象划分为需要保留的对象和不需要保留的对象,并通过确定第一目标框和排除框,来将需要保留的对象和不需要保留的对象所在的区域进行标记,由于第一图像中的目标区域包括第一目标框且不包括排除框,则基于目标区域,对第一图像进行裁剪,能够得到包括第一目标框且不包括排除框的第二图像。其中,利用第一目标框和排除框来标记图像中需要保留的对象和不需要保留的对象所在的区域,有利于快速识别出目标区域,从而提高了图像裁剪的速度。并且,需要保留的对象可视为需要关注的关键信息,不需要保留的对象可视为不需要关注的干扰信息,因此,此种图像裁剪方法保证了该第二图像中包括需要关注的关键信息,且不包括不需要关注的干扰信息,从而提高了图像裁剪的效果。
附图说明
图1是本申请实施例提供的一种实施环境的示意图;
图2是本申请实施例提供的一种图像裁剪方法的流程图;
图3是本申请实施例提供的一种图像裁剪方法的流程图;
图4是本申请实施例提供的一种图像分割方法的示意图;
图5是本申请实施例提供的另一种图像分割方法的示意图;
图6是本申请实施例提供的另一种图像分割方法的示意图;
图7是本申请实施例提供的另一种图像分割方法的示意图;
图8是本申请实施例提供的一种图像裁剪方法的示意图;
图9是本申请实施例提供的一种图像裁剪方法的流程图;
图10是本申请实施例提供的一种图像裁剪方法的流程图;
图11是本申请实施例提供的另一种图像裁剪方法的流程图;
图12是本申请实施例提供的一种图像裁剪装置的结构示意图;
图13是本申请实施例提供的另一种图像裁剪装置的结构示意图;
图14是本申请实施例提供的一种终端的结构示意图;
图15是本申请实施例提供的一种服务器的结构示意图。
具体实施方式
为使本申请实施例的目的、技术方案和优点更加清楚,下面将结合附图对本申请实施方式作进一步地详细描述。
可以理解,本申请所使用的术语“第一”、“第二”等可在本文中用于描述各种概念,但除非特别说明,这些概念不受这些术语限制。这些术语仅用于将一个概念与另一个概念区分。举例来说,在不脱离本申请的范围的情况下,可以将第一视频称为第二视频,且类似地,可将第二视频称为第一视频。
至少一个是指一个或者一个以上,例如,至少一个排除框可以是一个排除框、两个排除框、三个排除框等任一大于等于一的整数个排除框。多个是指两个或者两个以上,例如,多个排除框可以是两个排除框、三个排除框等任一大于等于二的整数个排除框。每个是指至少一个中的每一个,例如,每个排除框是指多个排除框中的每一个排除框,若多个排除框为3 个排除框,则每个排除框是指3个排除框中的每一个排除框。
图1是本申请实施例提供的一种实施环境的示意图,参见图1,该实施环境包括:服务器101和终端102。服务器101用于对图像进行裁剪,将裁剪后的图像提供给终端102。例如,终端102用于分享视频,在分享视频之前,请求服务器101为视频设置封面,服务器101用于对该视频关联的图像进行裁剪,从而将裁剪得到的图像确定为该视频的封面,并提供给终端102。在一些实施例中,终端102也可以用于对图像进行裁剪,例如,终端102在分享视频之前,对视频关联的图像进行裁剪,从而将裁剪得到的图像确定为该视频的封面。
在一种可能实现方式中,服务器101是独立的物理服务器,或者是多个物理服务器构成的服务器集群或者分布式系统,或者是提供云服务、云数据库、云计算、云函数、云存储、网络服务、云通信、中间件服务、域名服务、安全服务、CDN(Content Delivery Network,内容分发网络)、以及大数据和人工智能平台等基础云计算服务的云服务器。终端102是智能手机、平板电脑、笔记本电脑、台式计算机、智能音箱、智能手表、智能电视、智能车载终端等,但并不局限于此。服务器101以及终端102可以通过有线或无线通信方式进行直接或间接地连接,本申请在此不做限制。
在另一种可能实现方式中,终端102上安装由服务器101提供服务的目标应用,终端102能够通过该目标应用实现例如视频编辑或者视频播放等功能。可选地,目标应用为终端102操作系统中的目标应用,或者为第三方提供的目标应用。例如,目标应用为视频分享应用,该视频分享应用具有视频分享的功能,当然,该视频分享应用还能够具有其他功能,例如,点评功能、购物功能、导航功能、游戏功能等。
图2是本申请实施例提供的一种图像裁剪方法的流程图。本申请实施例的执行主体为计算机设备,参见图2,该方法包括以下步骤201至步骤204。
201、计算机设备确定第一图像中的每个对象所在的对象框。
计算机设备获取第一图像,该第一图像为待裁剪的图像。其中,第一图像中包括多个对象,该对象可以为任意类型的对象,例如该对象为人物、物体、文本或者水印等。计算机设备确定该第一图像中的每个对象所在的对象框,该对象框用于表示对象的位置,对象框所框出的区域即为对象所在的区域。
202、计算机设备将属于第一类型的对象所在的对象框确定为第一目标框,将属于第二类型的对象所在的对象框确定为排除框。
第一图像中的多个对象包括属于第一类型的对象和属于第二类型的对象。其中,属于第一类型的对象为需要保留的对象,也即是对第一图像进行裁剪需要保留的对象,该第一类型的对象为第一图像中需要关注的关键信息。属于第二类型的对象为不需要保留的对象,也即是对第一图像进行裁剪不需要保留的对象,该第二类型的对象为第一图像中不需要关注的干扰信息。
因此,计算机设备将属于第一类型的对象所在的对象框确定为第一目标框,以表示第一目标框所框出的区域为需要保留的区域。计算机设备将属于第二类型的对象所在的对象框确定为排除框,以表示排除框所框出的区域为不需要保留的区域。计算机设备通过确定第一目标框和排除框,从而将第一图像中需要保留的区域和不需要保留的区域标记出来。
203、计算机设备确定第一图像中的目标区域,目标区域包括第一目标框且不包括排除框。
计算机设备确定第一图像中的第一目标框和排除框后,根据该第一目标框和排除框,在第一图像中确定包括第一目标框且不包括排除框的目标区域,则该目标区域中包括需要保留的对象,且不包括不需要保留的对象。通过确定此种目标区域,能够便于对第一图像进行裁剪,裁剪出的图像中包括需要保留的对象且不包括不需要保留的对象。
204、计算机设备基于目标区域,对第一图像进行裁剪,得到包括第一目标框且不包括排除框的第二图像。
由于目标区域中包括第一目标框且不包括排除框,因此计算机设备在第一图像中确定目标区域后,基于该目标区域,对第一图像进行裁剪,得到包括第一目标框的第二图像。由于是基于目标区域进行裁剪的,而目标区域中不包括排除框,因此裁剪得到的该第二图像中也不包括排除框。
也即是,第二图像中包括第一目标框所框出的区域,不包括排除框所框出的区域,因此该第二图像中包括需要保留的对象,且不包括不需要保留的对象。
在示例性实施例中,第一目标框和排除框中的至少一项的数量为多个,第二图像包括第一目标框且不包括排除框是指第二图像包括至少一个第一目标框且不包括任一排除框。
需要说明的是,本申请实施例以执行主体为计算机设备为例进行说明。在一种可能实现方式中,该计算机设备为上述图1所示的实施环境中的服务器。在另一种可能实现方式中,该计算机设备为上述图1所示的实施环境中的终端。
本申请实施例提供的方法,将第一图像中的对象划分为需要保留的对象和不需要保留的对象,并通过确定第一目标框和排除框,来将需要保留的对象和不需要保留的对象所在的区域进行标记,由于第一图像中的目标区域包括第一目标框且不包括排除框,则基于目标区域,对第一图像进行裁剪,能够得到包括第一目标框且不包括排除框的第二图像。其中,利用第一目标框和排除框来标记图像中需要保留的对象和不需要保留的对象所在的区域,有利于快速识别出目标区域,从而提高了图像裁剪的速度。并且,需要保留的对象可视为需要关注的关键信息,不需要保留的对象可视为不需要关注的干扰信息,因此,此种图像裁剪方法保证了该第二图像中包括需要关注的关键信息,且不包括不需要关注的干扰信息,从而提高了图像裁剪的效果。
图3是本申请实施例提供的一种图像裁剪方法的流程图。本申请实施例的执行主体为计算机设备,参见图3,该方法包括以下步骤301至步骤305。
301、计算机设备确定第一图像中的每个对象所在的对象框。
计算机设备获取待裁剪的第一图像,识别第一图像中的多个对象,从而确定第一图像中的每个对象所在的对象框,该对象框用于表示对象的位置,对象框所框出的区域即为对象所在的区域。例如,该对象框为矩形边框,或者还可以为其他形状的边框。
在一种可能实现方式中,计算机设备确定第一图像中的每个对象所在的对象框,包括以下至少一项。
(1)对第一图像进行人脸识别,得到第一图像中的人脸框。
该人脸框为人脸所在的对象框,人脸框所框出的区域为人脸所在的区域。可选地,计算机设备中存储有人脸识别模型,调用人脸识别模型,对第一图像进行人脸识别,得到第一图像中的人脸所在的人脸框。
(2)对第一图像进行物体识别,得到第一图像中的物体框。
该物体框为物体所在的对象框,物体框所框出的区域为物体所在的区域。可选地,计算机设备中存储有物体识别模型,调用物体识别模型,对第一图像进行物体识别,得到第一图像中的物体所在的物体框。其中,该物体识别模型能够识别多种物体,例如车辆、树木、建筑、家具或者动物等。
(3)对第一图像进行文本识别,得到第一图像中的文本框。
该文本框为文本所在的对象框,文本框所框出的区域为文本所在的区域。可选地,计算机设备中存储有文本识别模型,调用文本识别模型,对第一图像进行文本识别,得到第一图像中的文本所在的文本框。例如,第一图像为视频帧,该第一图像中的文本为视频帧中的字幕等。
(4)对第一图像进行水印识别,得到第一图像中的水印框。
该水印框为水印所在的对象框,水印框所框出的区域为水印所在的区域。可选地,计算机设备中存储有水印识别模型,调用水印识别模型,对第一图像进行水印识别,得到第一图 像中的水印所在的水印框。例如,第一图像中的水印为添加在第一图像中的Logo(标志)等。
示例性地,上述人脸识别模型、物体识别模型、文本识别模型和水印识别模型中的每个识别模型的结构均可以为任一种神经网络模型,不同识别模型的结构可以相同,也可以不同,本申请实施例对此不加以限定。示例性地,人脸识别模型、物体识别模型、文本识别模型和水印识别模型均可以通过监督训练得到,例如,根据人脸图像和人脸图像中的人脸框标注结果,通过监督训练得到人脸识别模型;根据物体图像和物体图像中的物体框标注结果,通过监督训练得到物体识别模型;根据文本图像和文本图像中的文本框标注结果,通过监督训练得到文本识别模型;根据水印图像和水印图像中的水印框标注结果,通过监督训练得到水印识别模型。
在另一种可能实现方式中,计算机设备对第一图像进行对象识别,得到第一图像中的每个对象所在的对象框,计算机设备将对象框的尺寸扩大第三倍数,从而保证对象框中的对象是完整的,避免由于识别结果有误,导致对象框中的对象不完整的情况。其中,扩大第三倍数是指在原来的基础上,扩大第三倍数,例如第三倍数为10%,对象框的尺寸为100,则扩大10%后,对象框的尺寸为110。可选地,将对象框的尺寸扩大第三倍数是指,分别将对象框的宽度和高度扩大第三倍数。可选地,该第三倍数是计算机设备预先设置的。
在另一种可能实现方式中,计算机设备确定第一图像中的每个对象框在该第一图像中的位置信息,将对象框的位置信息存储下来,以便后续根据位置信息在第一图像中确定对象框。
302、计算机设备将属于第一类型的对象所在的对象框确定为第一目标框,将属于第二类型的对象所在的对象框确定为排除框。
计算机设备将第一图像中的多个对象分为属于第一类型的对象和属于第二类型的对象。其中,属于第一类型的对象为需要保留的对象,也即是第一图像中需要关注的关键信息。属于第二类型的对象为不需要保留的对象,也即是第一图像中不需要关注的干扰信息。因此,计算机设备将属于第一类型的对象所在的对象框确定为第一目标框,将属于第二类型的对象所在的对象框确定为排除框,从而将第一图像中需要保留的区域和不需要保留的区域标记出来。
在一种可能实现方式中,计算机设备采用第一标记方式,对属于第一类型的对象所在的对象框进行标记,得到第一目标框,采用第二标记方式,对属于第二类型的对象所在的对象框进行标记,得到排除框。其中,第一标记方式与第二标记方式不同。因此,计算机设备后续能够通过对对象框的标记方式进行识别,来确定图像中的哪些对象框属于第一目标框,哪些对象框属于排除框,从而对图像中的第一目标框和排除框加以区分。
可选地,第一标记方式是指将对象框的边缘线设置为第一颜色,第二标识方式是指将对象框的边缘线设置为第二颜色,第一颜色与第二颜色不同,例如第一颜色为红色,第二颜色为蓝色。可选地,第一标记方式是指将对象框的边缘线设置为第一尺寸,第二标记方式是指将对象框的边缘线设置为第二尺寸,第一尺寸与第二尺寸不同。可选地,第一标记方式是指将对象框设置为第一形状,第二标记方式是指将对象框设置为第二形状,第一形状与第二形状不同,例如第一形状为圆形,第二形状为方形。可选地,第一标记方式是指将对象框的边缘线设置为第一样式,第二标记方式是指将对象框的边缘线设置为第二样式,第一样式与第二样式不同,例如第一样式为实线,第二样式为虚线等。
需要说明的是,以上所述第一标记方式和第二标记方式仅为示例性举例,本申请实施例并不局限于此。在一些实施例中,第一标记方式和第二标记方式还可以为其他情况,只要保证第一标记方式与第二标记方式不同即可。示例性地,第一标记方式还可以是指将对象框的边缘线设置为第一颜色、第一尺寸和第一样式,且将对象框设置为第一形状;第二标记方式还可以是指将对象框的边缘线设置为第二颜色、第二尺寸和第二样式,且将对象框设置为第二形状。
本申请实施例中,由于目标框和排除框是采用不同的标记方式对对象框进行标记得到的,因此计算机设备能够通过对对象框的标记方式进行识别,来区分图像中的目标框和排除框, 从而实现了对目标框和排除框的自动识别,有利于提高对目标框和排除框的识别速度。计算机设备后续基于第一目标框和排除框的位置来对图像进行裁剪,由于已经缩短了识别目标框和排除框所花费的时间,因此也能够提高图像裁剪的整体速度。
在一种可能实现方式中,计算机设备将属于第一类型的对象所在的对象框确定为第一目标框,包括以下(1)和(2)中的至少一项。
(1)将人脸所在的人脸框确定为第一目标框。
第一图像中的对象框包括人脸所在的人脸框,人脸为需要关注的关键信息,因此该人脸为需要保留的对象,人脸属于第一类型的对象,因此计算机设备将人脸所在的人脸框确定为第一目标框。
(2)将物体所在的物体框确定为第一目标框。
第一图像中的对象框包括物体所在的物体框,物体为需要关注的关键信息,因此该物体为需要保留的对象,物体属于第一类型的对象,因此计算机设备将物体所在的物体框确定为第一目标框。
在一种可能实现方式中,计算机设备将属于第二类型的对象所属在的对象框确定为排除框,包括以下(3)和(4)中的至少一项。
(3)将文本所在的文本框确定为排除框。
第一图像中的对象框包括文本所在的文本框,文本为不需要关注的干扰信息,因此该文本为不需要保留的对象,文本属于第二类型的对象,因此计算机设备将文本所在的文本框确定为排除框。
(4)将水印所在的水印框确定为排除框。
第一图像中的对象框包括水印所在的水印框,水印为不需要关注的干扰信息,因此该水印为不需要保留的对象,水印属于第二类型的对象,因此计算机设备将水印所在的水印框确定为排除框。
需要说明的是,以上所述确定第一目标框和排除框的方式仅为示例性举例,本申请实施例并不局限于此。在一些实施例中,确定第一目标框和排除框的方式还可以根据实际的应用场景灵活调整。示例性地,若实际的应用场景为需要关注文本和水印,不需要关注人脸和物体的场景,则可以将文本所在的文本框以及水印所在的水印框确定为第一目标框,将人脸所在的人脸框和物体所在的物体框确定为排除框。
可选地,计算机设备中存储有配置信息,该配置信息包括第一类型和第二类型,计算机设备将第一图像中的对象所属的类型与该配置信息中的第一类型和第二类型进行对比,从而确定第一图像中的哪些对象属于第一类型的对象,哪些对象属于第二类型的对象。例如,该配置信息是由研发人员在计算机设备中设置的。计算机设备通过修改配置信息,能够灵活控制裁剪后的图像中保留的对象以及不保留的对象。
在另一种可能实现方式中,计算机设备在已确定多个第一目标框的情况下,将每个第一目标框的尺寸扩大第一倍数,得到多个第二目标框,对于每个第二目标框,在第二目标框与其他第二目标框相交的情况下,将第二目标框与其他第二目标框合并为一个第三目标框。其中,任两个第二目标框相交是指,这两个目标框存在交点。可选地,该第一倍数是计算机设备预先设置的。例如,该第一倍数为20%,计算机设备将每个第一目标框的尺寸扩大20%。
本申请实施例中,计算机设备将每个第一目标框的尺寸扩大第一倍数,得到多个第二目标框,如果某一个第二目标框与其他第二目标框相交,则说明该第二目标框中的对象与该其他第二目标框中的对象离得比较近。考虑到如果两个属于第一类型的对象的位置离得很近,仅基于其中一个对象对应的第一目标框或者第二目标框对第一图像进行裁剪,可能导致裁剪得到的图像中包括另一个对象的部分信息。因此计算机设备将该第二目标框与该其他第二目标框合并为一个第三目标框,该第三目标框中包括离得比较近的多个对象,因此后续可以基于该第三目标框对第一图像进行裁剪,从而避免裁剪得到的图像中的信息有残缺。
例如,第二目标框A与第二目标框B相交,则计算机设备将第二目标框A和第二目标框 B合并为一个第三目标框。例如,第二目标框A与第二目标框B和第二目标框C都相交,则计算机设备将第二目标框A、第二目标框B和第二目标框C合并为一个第三目标框。例如,第二目标框A没有与任何其他第二目标框相交,则第二目标框A保持独立,无需与其他第二目标框合并。
例如,第一目标框为人脸框,扩大第一目标框所得到的第二目标框中包括人脸。以两个第二目标框相交为例,如果第二目标框与其他第二目标框相交,则说明这两个第二目标框中的人脸离得很近。如果计算机设备直接基于这两个人脸所在的第一目标框中的任一个,对第一图像进行裁剪,则裁剪得到的图像中很可能包括另一个人脸的部分信息,导致图像中的信息有残缺。因此,计算机设备将这两个第二目标框合并为一个第三目标框,该第三目标框中包括两个人脸,后续基于该第三目标框对第一图像进行裁剪,则裁剪得到的图像中包括两个人脸。
303、计算机设备基于排除框的位置,确定第一图像中的多个候选区域。
由于排除框中包括不需要保留的对象,因此计算机设备基于排除框的位置,在第一图像中确定不包括排除框的多个候选区域,则确定的每个候选区域中不包括不需要保留的对象,便于后续基于候选区域从第一图像中裁剪出图像,该图像不包括这些不需要保留的对象。
在一种可能实现方式中,计算机设备在排除框的边缘线中,确定与第一图像的每个边缘线没有重叠的目标边缘线。计算机设备确定目标边缘线所在的直线,将第一图像中位于直线外侧的区域确定为候选区域,直线外侧是指远离排除框的一侧。
其中,排除框的边缘线与第一图像的边缘线没有重叠是指,排除框的边缘线与第一图像的边缘线没有在一条直线上。如果排除框的某一个边缘线与第一图像的某一个边缘线重叠,则该边缘线所在的直线外侧的区域为第一图像之外的区域,也即是在第一图像中,该边缘线所在的直线外侧不存在候选区域。如果排除框的某一个边缘线与第一图像的每个边缘线都不重叠,则该边缘线所在的直线外侧存在第一图像中的区域,因此可以将该第一图像中位于该边缘线所在的直线外侧的区域确定为候选区域,采用此方法所确定的候选区域中不包括排除框。
可选地,排除框为矩形边框,则该排除框包括左边缘线、右边缘线、上边缘线和下边缘线。目标边缘线可能包括排除框的左边缘线、右边缘线、上边缘线和下边缘线中的至少一种。计算机设备基于目标边缘线,确定候选区域,包括以下至少一项。
(1)在目标边缘线包括排除框的左边缘线的情况下,确定目标边缘线所在的第一直线,将第一图像中位于第一直线左侧的区域确定为候选区域。
在目标边缘线包括排除框的左边缘线的情况下,左边缘线的左侧是远离排除框的一侧,因此该左边缘线所在的第一直线外侧,是指该第一直线的左侧。因此,计算机设备将第一图像中位于第一直线左侧的区域确定为候选区域。
(2)在目标边缘线包括排除框的右边缘线的情况下,确定目标边缘线所在的第二直线,将第一图像中位于第二直线右侧的区域确定为候选区域。
在目标边缘线包括排除框的右边缘线的情况下,右边缘线的右侧是远离排除框的一侧,因此该右边缘线所在的第二直线外侧,是指该第二直线的右侧。因此,计算机设备将第一图像中位于第二直线右侧的区域确定为候选区域。
(3)在目标边缘线包括排除框的上边缘线的情况下,确定目标边缘线所在的第三直线,将第一图像中位于第三直线上侧的区域确定为候选区域。
在目标边缘线包括排除框的上边缘线的情况下,上边缘线的上侧是远离排除框的一侧,因此该上边缘线所在的第三直线外侧,是指该第三直线的上侧。因此,计算机设备将第一图像中位于第三直线上侧的区域确定为候选区域。
(4)在目标边缘线包括排除框的下边缘线的情况下,确定目标边缘线所在的第四直线,将第一图像中位于第四直线下侧的区域确定为候选区域。
在目标边缘线包括排除框的下边缘线的情况下,下边缘线的下侧是远离排除框的一侧, 因此该下边缘线所在的第四直线外侧,是指该第四直线的下侧。因此,计算机设备将第一图像中位于第四直线下侧的区域确定为候选区域。
可选地,在排除框为矩形边框的情况下,该排除框中与第一图像的每个边缘线没有重叠的目标边缘线的个数可以为4个、3个、2个或者1个。则计算机设备确定的候选区域包括以下4种情况。
(1)在目标边缘线的个数为4个的情况下,参见图4,图4是本申请实施例提供的一种图像分割方法的示意图,图4中包括第一图像401,第一图像401中包括排除框402,该排除框402在第一图像401的中间区域,该排除框402的4个边缘线均与第一图像401的边缘线没有重叠。则计算机设备在第一图像401中,将该排除框402的左边缘线所在的直线左侧的区域确定为候选区域403,将该排除框402的右边缘线所在的直线右侧的区域确定为候选区域404,将该排除框402的上边缘线所在的直线上侧的区域确定为候选区域405,将该排除框402的下边缘线所在的直线下侧的区域确定为候选区域406。其中,阴影部分表示候选区域。
因此,在目标边缘线的个数为4个的情况下,计算机设备能够在第一图像中确定4个候选区域,且4个候选区域之间可以相交。
(2)在目标边缘线的个数为3个的情况下,参见图5,图5是本申请提供的另一种图像分割方法的示意图。图5中包括第一图像501,第一图像501中包括排除框502,该排除框502在第一图像501的边缘区域,该排除框502的上边缘线与第一图像501的上边缘线重叠,该排除框502的其他3个边缘线均与第一图像501的边缘线没有重叠。则计算机设备在第一图像501中,将该排除框502的左边缘线所在的直线左侧的区域确定为候选区域503,将该排除框502的右边缘线所在的直线右侧的区域确定为候选区域504,将该排除框502的下边缘线所在的直线下侧的区域确定为候选区域505。其中,阴影部分表示候选区域。
因此,在目标边缘线的个数为3个的情况下,计算机设备能够在第一图像中确定3个候选区域,且3个候选区域之间可以相交。
(3)在目标边缘线的个数为2个的情况下,参见图6,图6是本申请提供的另一种图像分割方法的示意图。图6中包括第一图像601,第一图像601中包括排除框602,该排除框602在第一图像601的角上,该排除框602的上边缘线和左边缘线与第一图像601的边缘线重叠,该排除框602的右边缘线和下边缘线与第一图像601的边缘线没有重叠。则计算机设备在第一图像601中,将该排除框602的下边缘线所在的直线下侧的区域确定为候选区域603,将该排除框602的右边缘线所在的直线右侧的区域确定为候选区域604。其中,阴影部分表示候选区域。
因此,在目标边缘线的个数为2个的情况下,计算机设备能够在第一图像中确定2个候选区域,且2个候选区域之间可以相交。
(4)在目标边缘线的个数为1个的情况下,参见图7,图7是本申请提供的另一种图像分割方法的示意图。图7中包括第一图像701,第一图像701中包括排除框702,该排除框702的左边缘线、右边缘线和下边缘线均与第一图像701的边缘线重叠,该排除框702的上边缘线与第一图像701的边缘线没有重叠。则计算机设备在第一图像701中,将该排除框702的上边缘线所在的直线上侧的区域确定为候选区域703。其中,阴影部分表示候选区域。
因此,在目标边缘线的个数为1个的情况下,计算机设备能够在第一图像中确定1个候选区域。
本申请实施例中,基于排除框的边缘线与第一图像的边缘线的位置,对第一图像中的区域进行划分,从而在第一图像中确定出不包括排除框的候选区域,该方法逻辑简单,便于实现,有利于提高图像裁剪的速度。
在另一种可能实现方式中,排除框的数量为多个,计算机设备基于排除框的位置,确定第一图像中的多个候选区域,包括:基于第一排除框的位置,确定第一图像中的第一候选区域,第一候选区域中不包括第一排除框,第一排除框为多个排除框中的任一排除框;响应于第一候选区域包括第二排除框,基于第二排除框的位置,确定第一候选区域中的第二候选区 域,第二候选区域中不包括第二排除框,第二排除框为多个排除框中除第一排除框外的任一排除框;响应于第二候选区域不包括任一排除框,将第二候选区域作为所需确定的候选区域。
示例性地,响应于第一候选区域不包括任一排除框,将第一候选区域作为所需确定的候选区域。
示例性地,响应于第二候选区域包括第三排除框,基于第三排除框的位置,确定第二候选区域中的第三候选区域,第三候选区域中不包括第三排除框,第三排除框为多个排除框中除第一排除框和第二排除框外的任一排除框;响应于第三候选区域不包括任一排除框,将第三候选区域作为所需确定的候选区域,响应于第三候选区域包括第四排除框,基于第四排除框的位置,确定第三候选区域中的第四候选区域,第四候选区域中不包括第四排除框,第四排除框为多个排除框中除第一排除框、第二排除框和第三排除框外的任一排除框。以此类推,直至得到不包括任一排除框的候选区域。
也就是说,基于第一排除框的位置,确定第一图像中的第一候选区域,第一候选区域中不包括第一排除框,第一排除框为多个排除框中的任一排除框,基于第二排除框的位置,确定第一候选区域中的第二候选区域,第二候选区域中不包括第二排除框,直至得到的每个候选区域中均不包括任一排除框。
也即是,在第一图像中包括多个排除框的情况下,计算机设备在多个排除框中,随机确定一个第一排除框,并基于该第一排除框的位置,在第一图像中确定不包括第一排除框的第一候选区域。在第一候选区域包括第二排除框的情况下,基于第二排除框的位置,在第一候选区域中确定不包括该第二排除框的第二候选区域,直至得到的每个候选区域中均不包括任一排除框。
例如,计算机设备确定的第一候选区域的数量为多个。对于每个第一候选区域,计算机设备判断该第一候选区域中是否包括排除框,如果第一候选区域中不包括排除框,则无需继续对该第一候选区域进行处理,该第一候选区域直接作为一个完整的候选区域。如果第一候选区域中还包括排除框,则计算机设备基于第一候选区域中的任一排除框的位置,在第一候选区域中,确定不包括该排除框的第二候选区域,然后计算机设备继续判断得到的第二候选区域中是否还包括排除框,如果不包括排除框则直接将第二候选区域作为一个完整的候选区域,如果包括排除框则继续对第二候选区域进行处理,直至得到的每个候选区域均不包括排除框,得到多个不包括排除框的候选区域。
可选地,计算机设备确定的第一候选区域的数量为多个。计算机设备从所确定的多个第一候选区域中,将尺寸小于第一阈值的第一候选区域删除。此种情况下,基于未删除的第一候选区域执行后续确定候选区域的步骤。示例性地,响应于未删除的第一候选区域包括第二排除框,基于第二排除框的位置,确定未删除的第一候选区域中的第二候选区域。响应于未删除的第一候选区域不包括任一排除框,将未删除的第一候选区域作为所需确定的候选区域。
本申请实施例中,候选区域为不包括排除框的区域,后续会基于候选区域确定包括目标框的目标区域,以便基于目标区域对第一图像进行裁剪,如果候选区域的尺寸太小,则在候选区域中确定出目标区域的可能性较小,因此将尺寸小于第一阈值的第一候选区域删除,能够减少在第一候选区域中未确定出目标区域的无效操作,从而提高操作效率,另外,如果候选区域的尺寸太小,还可能会影响后续进行图像裁剪的效果,因此将尺寸小于第一阈值的第一候选区域删除,能够保证第一候选区域的尺寸足够大,有利于保证图像裁剪的效果。
需要说明的是,上述实施例仅以第一候选区域为例进行说明,而实际上,计算机设备每确定出一个候选区域,都可以先确定该候选区域的尺寸是否小于第一阈值,如果小于第一阈值则删除该候选区域,如果不小于第一阈值则保留该候选区域,继续执行后续的操作。
在另一种可能实现方式中,计算机设备建立第一图像对应的空间坐标系,根据该空间坐标系,以及排除框和第一目标框在第一图像中的位置,确定每个排除框的坐标信息,根据排除框的坐标信息,在第一图像中确定多个候选区域的坐标信息,后续基于候选区域的坐标信息,来执行下述步骤304-步骤305。例如,计算机设备将第一图像中左下角的顶点,确定为空 间坐标系的原点。
304、计算机设备在多个候选区域中,确定包括第一目标框的目标区域。
计算机设备确定出多个候选区域后,在多个候选区域中,确定包括第一目标框的目标区域,由于候选区域不包括排除框,因此该目标区域包括第一目标框且不包括排除框。
对于每个候选区域,计算机设备判断该候选区域中是否包括第一目标框,如果候选区域包括第一目标框,则将该候选区域确定为目标区域,如果候选区域不包括第一目标框,则该候选区域不是目标区域。其中,候选区域包括第一目标框是指,候选区域中包括完整的第一目标框,如果候选区域中仅包括第一目标框的部分区域,则认为该候选区域中不包括第一目标框。
在一种可能实现方式中,计算机设备在多个候选区域中,确定出包括第一目标框的多个候选目标区域,在多个候选目标区域中,确定面积最大的目标区域。
计算机设备通过上述步骤303-步骤304,实现了在第一图像中,确定第一图像中的目标区域,目标区域包括第一目标框且不包括排除框。
在一种可能实现方式中,在上述步骤302中,计算机设备在已确定多个第一目标框的情况下,将每个第一目标框的尺寸扩大第一倍数,得到多个第二目标框,对于每个第二目标框,在第二目标框与其他第二目标框相交的情况下,将第二目标框与其他第二目标框合并为一个第三目标框。则计算机设备在第一图像中,将包括第三目标框且不包括排除框的区域,确定为目标区域,在第一图像中,将包括剩余的第二目标框对应的第一目标框、且不包括排除框的区域,确定为目标区域。
其中,剩余的第二目标框是指没有进行合并的第二目标框,第二目标框对应的第一目标框是指,扩大第一倍数后得到该第二目标框的第一目标框。计算机设备的裁剪目标为合并得到的第三目标框,以及没有进行合并的第二目标框在扩大之前的第一目标框。
可选地,上述步骤304被替换为:计算机设备在多个候选区域中,将包括第三目标框的候选区域,确定为目标区域,将包括剩余的第二目标框对应的第一目标框的候选区域,确定为目标区域。其中,包括第三目标框的目标区域和包括该第一目标框的目标区域,可以为同一个候选区域,也可以为不同的候选区域。
在另一种可能实现方式中,第一目标框的数量为多个,计算机设备在第一图像中,确定包括至少一个第一目标框、且不包括排除框的目标区域。
也即是,对于每个第一目标框,计算机设备在第一图像中,确定包括该第一目标框、且不包括排除框的目标区域。不同第一目标框所确定出的目标区域,可以为相同的区域,也可以为不同的区域。因此,计算机设备能够确定出至少一个目标区域,每个目标区域可以包括一个第一目标框,也可以包括多个第一目标框。
可选地,上述步骤304被替换为:计算机设备在多个候选区域中,确定包括至少一个第一目标框的目标区域。
在另一种可能实现方式中,第一目标框的数量为多个,计算机设备在多个第一目标框中包括人脸框的情况下,在第一图像中,确定包括人脸框且不包括排除框的目标区域。
其中,人脸框是包括人脸的对象框。对于第一图像中各种类型的对象来说,相比于其他类型的对象,人脸是更为值得关注的对象,也即是更需要保留的对象。因此,在第一目标框包括人脸目标框的情况下,计算机设备在第一图像中包括人脸框的情况下,优先确定包括人脸的目标区域。例如,第一目标框可以分为人脸框和物体框两种类型,计算机设备先判断第一图像的多个第一目标框中是否存在人脸框,如果存在人脸框,则确定包括人脸框的目标区域,如果不存在人脸框,则确定包括物体框的目标区域。
可选地,上述步骤304被替换为:在多个第一目标框中包括人脸框的情况下,计算机设备在多个候选区域中,确定包括人脸框的目标区域。
本申请实施例的上述步骤303-步骤304提供了一种区域划分策略,基于排除框和第一目标框在第一图像中的位置,能够在第一图像中划分出不包括排除框且包括第一目标框的目标 区域,该方法逻辑简单,便于实现。
需要说明的是,本申请实施例仅以在多个候选区域中,确定出包括第一目标框的目标区域为例进行说明。在另一实施例中,如果每个候选区域均不包括第一目标框,则确定第一图像裁剪失败。
305、计算机设备基于目标区域,对第一图像进行裁剪,得到包括第一目标框且不包括排除框的第二图像。
由于是基于目标区域进行裁剪的,而目标区域中不包括排除框,因此裁剪得到的该第二图像中也不包括排除框。也即是,第二图像中包括第一目标框所框出的区域,不包括排除框所框出的区域,因此该第二图像中包括需要保留的对象,且不包括不需要保留的对象。
在一种可能实现方式中,计算机设备基于目标区域,对第一图像进行裁剪,得到包括第一目标框、不包括排除框、且宽高比为目标宽高比的第二图像。
计算机设备基于该目标区域,对第一图像进行裁剪,得到宽高比为该目标宽高比的第二图像,且裁剪得到的第二图像中包括第一目标框,此种方式能够在第一图像中裁剪出符合目标宽高比的图像。可选地,该目标宽高比为计算机设备预先设置的,或者该目标宽高比为其他设备发送给该计算机设备,以请求该计算机设备裁剪符合目标宽高比的图像。例如,该目标宽高比为1:3等。
可选地,计算机设备裁剪得到宽高比为目标宽高比的第二图像,包括:计算机设备扩大第一目标框的宽度或者高度中的至少一项,得到第四目标框,以使第四目标框的宽高比为目标宽高比;保持第四目标框的中心点不变,扩大第四目标框的尺寸,直至扩大第二倍数或者扩大后第四目标框的任一边缘线与目标区域的边缘线重叠,得到第五目标框;从第一图像中裁剪第五目标框,将裁剪出的第五目标框确定为第二图像。
计算机设备先对第一目标框的宽度或者高度中的至少一项进行扩大,以使扩大后得到的第四目标框的宽高比为该目标宽高比,从而裁剪出目标宽高比的图像。其中,该第四目标框位于目标区域中,目标区域包括该第四目标框且不包括排除框。考虑到第四目标框的尺寸可能较小,如果直接从第一图像中裁剪第四目标框,将裁剪出的第四目标框确定为第二图像,该第二图像的尺寸也会比较小,导致图像裁剪的效果不佳,因此计算机设备扩大该第四目标框。
考虑到如果第四目标框扩大倍数较大,则扩大后得到的第五目标框的尺寸会比较大,从而第五目标框中的对象所占的面积比例较少,难以凸显该对象,导致图像裁剪的效果不佳,因此计算机设备以第二倍数为限,扩大第四目标框,直至扩大第二倍数,得到第五目标框。另外,考虑到目标区域之外可能存在排除框,因此计算机设备以目标区域为限,扩大第四目标框,直至扩大后的第四目标框的任一边缘线与目标区域的任一边缘线重叠,得到第五目标框。
计算机设备同时以第二倍数和目标区域为限,以避免上述两个问题。计算机设备在扩大第四目标框的过程中,判断是否扩大了第二倍数,以及判断扩大后的第四目标框的任一边缘线是否与目标区域的任一边缘线重叠,以上两个判断条件只要满足其中一个,则计算机设备停止继续扩大,得到第五目标框。也即是,在扩大第四目标框的过程中,如果扩大倍数达到了第二倍数,则停止扩大,或者如果扩大后的第四目标框的任一边缘线与目标区域的任一边缘线重叠,则也停止扩大。
图8是本申请实施例提供的一种图像裁剪方法的示意图,图8中包括目标区域801和第一目标框802,计算机设备扩大第一目标框802的高度,得到宽高比为目标宽高比的第四目标框803,计算机设备等比例扩大第四目标框803的尺寸,得到第五目标框。其中,该第五目标框包括以下两种情况。
第一种情况:如图8的左下角的示意图,计算机设备在扩大第四目标框803的尺寸的过程中,如果在扩大后的第四目标框的边缘线与目标区域的边缘线重叠之前,扩大了第二倍数,则计算机设备停止扩大,得到第五目标框804,该第五目标框804的宽高比为该目标宽高比。
第二种情况:如图8的右下角的示意图,计算机设备在扩大第四目标框803的尺寸的过程中,如果在扩大第二倍数之前,扩大后的第四目标框的下边缘线与目标区域的下边缘线重叠,则计算机设备停止扩大,得到第五目标框805,该第五目标框805的宽高比为该目标宽高比。
本申请实施例的上述步骤305提供了一种图像裁剪策略,基于目标区域,能够在第一图像中裁剪出包括第一目标框且不包括排除框的第二图像,并且还能够裁剪出宽高比为目标宽高比的第二图像,操作简便,且提高了图像裁剪的灵活性。
为了对本申请实施例提供的图像裁剪方法进行评估,计算机设备采用本申请实施例提供的方法以及相关技术提供的方法进行图像裁剪,裁剪得到的图像经由人工评定,来判断裁图效果,裁图效果不好的图像可以归为badcase(坏例),实验结果表明,相比于相关技术,本申请实施例提供的方法的badcase率低于15%,而相关技术提供的方法的badcase率约为60%,也就是说,本申请实施例提供的方法明显提高了图像裁剪的效果。此外,badcase需要人工进行处理,耗费大量的人力和时间成本,因此,通过降低badcase率,本申请实施例提供的方法能够显著提升裁图流程的效率,降低人力和时间成本。
需要说明的是,本申请实施例以执行主体为计算机设备为例进行说明。在一种可能实现方式中,该计算机设备为上述图1所示的实施环境中的服务器。在另一种可能实现方式中,该计算机设备为上述图1所示的实施环境中的终端。
本申请实施例提供的方法,将第一图像中的对象划分为需要保留的对象和不需要保留的对象,并通过确定第一目标框和排除框,来将需要保留的对象和不需要保留的对象所在的区域进行标记,由于第一图像中的目标区域包括第一目标框且不包括排除框,则基于目标区域,对第一图像进行裁剪,能够得到包括第一目标框且不包括排除框的第二图像。其中,利用第一目标框和排除框来标记图像中需要保留的对象和不需要保留的对象所在的区域,有利于快速识别出目标区域,从而提高了图像裁剪的速度。并且,需要保留的对象可视为需要关注的关键信息,不需要保留的对象可视为不需要关注的干扰信息,因此,此种图像裁剪方法保证了该第二图像中包括需要关注的关键信息,且不包括不需要关注的干扰信息,从而提高了图像裁剪的效果。
并且,将每个第一目标框的尺寸扩大第一倍数,得到多个第二目标框,如果某一个第二目标框与其他第二目标框相交,则说明该第二目标框中的对象与该其他第二目标框中的对象离得比较近,因此计算机设备将该第二目标框与该其他第二目标框合并为一个第三目标框,该第三目标框中包括离得比较近的多个对象,因此后续可以基于该第三目标框对第一图像进行裁剪,从而避免裁剪得到的图像中的信息有残缺。
并且,基于排除框的边缘线与第一图像的边缘线的位置,对第一图像中的区域进行划分,从而在第一图像中确定出不包括排除框的候选区域,该方法逻辑简单,便于实现,有利于提高图像裁剪的速度。
并且,候选区域为不包括排除框的区域,后续会基于候选区域确定包括目标框的目标区域,以便基于目标区域对第一图像进行裁剪,因此将尺寸小于第一阈值的第一候选区域删除,能够减少在第一候选区域中未确定出目标区域的无效操作,从而提高操作效率。另外,将尺寸小于第一阈值的第一候选区域删除,能够保证候选区域的尺寸足够大,有利于保证图像裁剪的效果。
图9是本申请实施例提供的一种图像裁剪方法的流程图。本申请实施例的执行主体为计算机设备。参见图9,该方法包括以下步骤901至步骤907。
901、计算机设备响应于封面设置请求,获取第一视频对应的多个关联图像。
封面设置请求用于请求计算机设备为第一视频设置封面,因此计算机设备响应于该封面设置请求,获取该第一视频对应的多个关联图像,该关联图像用于展示第一视频的内容,因此后续可以基于该多个关联图像来确定第一视频的封面。在一种可能实现方式中,该封面设 置请求是由其他设备发送的,例如该计算机设备是上述图1的实施环境中的服务器,该其他设备是上述图1的实施环境中的终端,该封面设置请求是由终端发送给服务器的。在另一种可能实现方式中,该封面设置请求是计算机设备直接获取的,例如,该计算机设备是上述图1的实施环境中的终端,该终端可以直接获取封面设置请求。
在一种可能实现方式中,计算机设备响应于封面设置请求,获取封面设置请求中携带的备选封面和视频标识。计算机设备在视频帧数据库中,获取视频标识对应的至少一个视频帧,将该备选封面和该至少一个视频帧确定为第一视频对应的关联图像。
其中,该封面设置请求携带有备选封面和视频标识,该视频标识指示第一视频,例如该视频标识为第一视频的名称或者编号等。备选封面能够展示第一视频的内容,该备选封面用于设置第一视频的封面,例如备选封面为用户上传的封面。
其中,视频帧数据库用于存储任一视频的视频帧,每个视频帧与该视频帧所在视频的视频标识对应,该视频帧数据库中存储有第一视频的视频帧。由于封面设置请求中的视频标识指示第一视频,因此计算机设备在视频帧数据库中,获取该视频标识对应的至少一个视频帧,该至少一个视频帧即为第一视频的视频帧,因此该至少一个视频帧能够展示第一视频的内容。
因此,计算机设备将备选封面和该至少一个视频帧确定为第一视频对应的关联图像,以便后续基于确定的多个关联图像,来为第一视频设置封面。
以上所述获取第一视频对应的关联图像的方式仅为示例性举例,本申请实施例并不局限于此。示例性地,获取第一视频对应的关联图像的方式还可以为:计算机设备响应于封面设置请求,获取封面设置请求中携带的视频标识,计算机设备在视频帧数据库中,获取视频标识对应的至少一个视频帧,将该至少一个视频帧确定为第一视频对应的关联图像。
902、计算机设备分别对多个关联图像进行清晰度识别,得到每个关联图像的清晰度,在多个关联图像中,将清晰度大于第四阈值的图像确定为第一图像。
该多个关联图像用于设置第一视频的封面,考虑到如果关联图像的清晰度不够高,第一视频的封面会比较模糊,导致第一视频的封面效果不够好,因此,计算机设备先对多个关联图像进行清晰度识别,得到每个关联图像的清晰度。对于每个关联图像,如果该关联图像的清晰度大于第四阈值,说明该关联图像足够清晰,则计算机设备将该关联图像确定为第一图像,如果该关联图像的清晰度不大于第四阈值,说明该关联图像不够清晰,则计算机设备将该关联图像舍弃。因此,计算机设备能够基于清晰度,对多个关联图像进行筛选,从而得到清晰度大于第四阈值的第一图像。可选地,该第四阈值是由计算机设备预先设置的。
在一种可能实现方式中,计算机设备中存储有清晰度识别模型,该清晰度识别模型用于识别图像的清晰度。计算机设备基于该清晰度识别模型,对多个关联图像进行清晰度识别,得到每个关联图像的清晰度。示例性地,清晰度识别模型的结构可以为任一种神经网络模型,本申请实施例对此不加以限定。清晰度识别模型可以通过监督训练得到,例如,根据样本图像和样本图像对应的清晰度标签,通过监督训练得到清晰度识别模型。
可选地,计算机设备采用第一数值和第二数值来表示关联图像的清晰度,第一数值表示关联图像的清晰度低,第二数值表示关联图像的清晰度高。例如第一数值为0,第二数值为1,则计算机设备将清晰度为第二数值的关联图像确定为第一图像。
计算机设备通过执行上述步骤901-步骤902,实现了响应于对第一视频的封面设置请求,获取第一图像,该第一图像用于展示第一视频的内容。除此之外,计算机设备还可以采用其他方式获取第一图像,例如,封面设置请求中携带该第一图像,则计算机设备直接在封面设置请求中获取该第一图像即可。
903、计算机设备确定第一图像中的每个对象所在的对象框。
904、计算机设备将属于第一类型的对象所在的对象框确定为第一目标框,将属于第二类型的对象所在的对象框确定为排除框。
905、计算机设备确定第一图像中的目标区域,目标区域包括第一目标框且不包括排除框。
906、计算机设备基于目标区域,对第一图像进行裁剪,得到包括第一目标框且不包括排 除框的第二图像。
需要说明的是,上述步骤903-步骤906仅以对一个第一图像进行处理,得到一个第二图像为例进行说明。在另一实施例中,在上述步骤902中,计算机设备确定出多个第一图像,则计算机设备按照多个第一图像的排列顺序,对至少一个第一图像执行上述步骤903-步骤906。
对于多个第一图像中的任意一个第一图像,计算机设备对该第一图像执行裁剪过程,如果在第一图像中成功裁剪出第二图像,则无需再对该第一图像之后的其他第一图像进行裁剪。如果在该第一图像中没有裁剪出第二图像,则计算机设备继续对该第一图像之后的其他第一图像进行裁剪,直至成功裁剪出第二图像。可选地,在第一图像中包括备选封面的情况下,计算机设备优先对该备选封面进行裁剪。
示例性地,在第一图像中没有裁剪出第二图像包括多种情况,例如在对第一图像执行上述步骤905时,无法在第一图像中确定包括第一目标框且不包括排除框的目标区域。或者在对第一图像执行上述步骤906时,无法在第一图像中裁剪出包括第一目标框且不包括排除框的第二图像等。
示例性地,计算机设备可以为第一视频设置多个不同宽高比的封面。则计算机设备确定多个不同的目标宽高比,则计算机设备按照多个第一图像的排列顺序,对多个第一图像执行上述步骤903-步骤906,得到宽高比分别为该多个目标宽高比的第二图像。
除此之外,上述步骤903-步骤906中得到第二图像的过程与上述步骤301-步骤305中得到第二图像的过程同理,在此不再赘述。
907、计算机设备将第二图像确定为第一视频的封面,或者,将第二图像调整至目标尺寸,将调整后的第二图像确定为第一视频的封面。
第二图像中包括需要保留的对象且不包括不需要保留的对象,计算机设备将该第二图像确定为第一视频的封面,则第一视频的封面中包括需要关注的关键信息,且不包括不需要关注的干扰信息,提高了视频封面的关键信息的信息量,同时降低了视频封面的干扰信息的信息量,从而提高了视频封面的展示效果。
另外,如果第一视频的封面具有尺寸要求,例如第一视频的封面需要在目标尺寸的封面展示区域中展示,则计算机设备先将第二图像调整至该目标尺寸,将调整后的第二图像确定为第一视频的封面,以使第一视频的封面与封面展示区域适配。示例性地,目标尺寸可能比第二图像的尺寸大,也可能比第二图像的尺寸小。若目标尺寸比第二图像的尺寸大,则计算机设备将第二图像扩大至该目标尺寸,将扩大后的第二图像确定为第一视频的封面;若目标尺寸比第二图像的尺寸小,则计算机设备将第二图像缩小至该目标尺寸,将缩小后的第二图像确定为第一视频的封面。
可选地,封面展示区域的宽高比为目标宽高比,则计算机设备在上述步骤903-步骤906中,在第一图像中裁剪出宽高比为该目标宽高比的第二图像,则计算机设备在该步骤907中,将该目标宽高比的第二图像,等比例调整(如,放大或缩小)至目标尺寸,得到调整(如,放大或缩小)后的第二图像。
需要说明的是,本申请实施例以目标尺寸与第二图像的尺寸不同为例进行说明。在一些实施例中,目标尺寸也可能与第二图像的尺寸相同,此种情况下,计算机设备将第二图像确定为第一视频的封面。
在一种可能实现方式中,计算机设备将第二图像分割成多个图像区域;对于每个图像区域,确定图像区域中的多个像素点的明亮度之间的差异参数;基于多个图像区域分别对应的差异参数,确定不小于第二阈值的差异参数的数量;在数量大于第三阈值的情况下,将第二图像确定为第一视频的封面,或者,将第二图像调整(如,放大或缩小)至目标尺寸,将调整(如,放大或缩小)后的第二图像确定为第一视频的封面。可选地,该第二阈值和第三阈值是由计算机设备预先设置的。
其中,明亮度之间的差异参数表示明亮度之间的差异程度,该差异参数越小,表示该多个明亮度之间越相似,该差异参数越大,表示该多个明亮度之间的差异越大。例如,该差异 参数为多个明亮度之间的方差或者标准差等。示例性地,该明亮度用于表示像素点的颜色明亮的程度。例如,该明亮度为HSV(Hue-Aturation-Value,色调-饱和度-明亮度)颜色空间中V(明亮度)通道所对应的参数。
示例性地,图像区域中的多个像素点的明亮度之间的差异参数小于第二阈值,说明该图像区域中的多个像素点之间的颜色接近,则可以将该图像区域近似认为是纯色区域。如果在多个图像区域分别对应的差异参数中,不小于第二阈值的差异参数的数量不大于第三阈值,则说明小于第二阈值的差异参数的数量较多,也即是第二图像中的纯色区域的数量较多,则该第二图像的信息量较少,如果基于该第二图像来确定第一视频的封面,则确定出的封面的信息量较少,视频的封面展示效果不好。因此,如果不小于第二阈值的差异参数的数量大于第三阈值,则说明不小于第二阈值的差异参数的数量较多,也即是该第二图像中的纯色区域的数量较少,则该第二图像的信息量足够多,因此计算机设备基于该第二图像来确定第一视频的封面。示例性地,任一图像区域分别对应的差异参数是指该任一图像区域中的多个像素点的明亮度之间的差异参数。
本申请实施例中,基于第二图像中各个像素点的明亮度之间的差异参数,来对第二图像进行筛选,将信息量较少的第二图像舍弃,基于信息量较大的第二图像来确定第一视频的封面,从而保证第一视频的封面的信息量足够大,能够提高第一视频的封面展示效果。
图10是本申请实施例提供的另一种图像裁剪方法的流程图,参见图10,该方法包括以下步骤1001至步骤1004。
1001、计算机设备获取第一视频对应的关联图像。
其中该关联图像包括第一视频的备选封面以及第一视频的视频帧。
1002、对于每个关联图像,计算机设备分别对该关联图像进行人脸识别、物体识别、文本识别、水印识别和清晰度识别,来确定关联图像中的人脸框、物体框、文本框和水印框,以及关联图像的清晰度。
示例性地,计算机设备将清晰度不大于第四阈值的关联图像舍弃,将剩余的关联图像中的人脸框和物体框确定为需要保留的目标框,将文本框和水印框确定为不需要保留的排除框。
1003、计算机设备对剩余的关联图像执行区域划分策略和图像裁剪策略。
其中,区域划分策略即为上述步骤303-步骤304中的方法,图像裁剪策略即为上述步骤305中的方法。
1004、计算机设备输出对关联图像进行裁剪所得到的图像。
本申请实施例,通过计算机设备对图像执行区域划分策略和图像裁剪策略,来裁剪图像作为视频的封面,显著提升封面裁剪流程的效率,降低了人工成本和时间成本。
需要说明的是,本申请实施例以执行主体为计算机设备为例进行说明。在一种可能实现方式中,该计算机设备为上述图1所示的实施环境中的服务器。在另一种可能实现方式中,该计算机设备为上述图1所示的实施环境中的终端。
本申请实施例提供的方法,将第一图像中的对象划分为需要保留的对象和不需要保留的对象,并通过确定第一目标框和排除框,来将需要保留的对象和不需要保留的对象所在的区域进行标记,由于第一图像中的目标区域包括第一目标框且不包括排除框,则基于目标区域,对第一图像进行裁剪,能够得到包括第一目标框且不包括排除框的第二图像。其中,利用第一目标框和排除框来标记图像中需要保留的对象和不需要保留的对象所在的区域,有利于快速识别出目标区域,从而提高了图像裁剪的速度。并且,需要保留的对象可视为需要关注的关键信息,不需要保留的对象可视为不需要关注的干扰信息,因此,此种图像裁剪方法保证了该第二图像中包括需要关注的关键信息,且不包括不需要关注的干扰信息,从而提高了图像裁剪的效果。
并且,本申请实施例提供了一种裁剪视频封面的方法,由于第二图像中包括需要保留的对象且不包括不需要保留的对象,因此计算机设备基于该第二图像确定第一视频的封面,则第一视频的封面中包括需要关注的关键信息,且不包括不需要关注的干扰信息,提高了视频 封面的关键信息的信息量,同时降低了视频封面的干扰信息的信息量,从而提高了视频封面的展示效果。
并且,基于清晰度,对多个关联图像进行筛选,从而得到清晰度大于第四阈值的第一图像。由于第一图像用于设置第一视频的封面,因此通过保证第一图像的清晰度,能够保证第一视频的封面的清晰度,从而提高第一视频的封面展示效果。
并且,基于第二图像中各个像素点的明亮度之间的差异参数,对第二图像进行筛选,将信息量较少的第二图像舍弃,基于信息量较大的第二图像来确定第一视频的封面,从而保证第一视频的封面的信息量足够大,能够提高第一视频的封面展示效果。
上述实施例可应用于需要进行图像裁剪的任意场景中。例如,在视频分享领域,终端请求服务器为视频设置封面,则服务器可以对与视频内容有关的图像进行裁剪,将裁剪得到的图像确定为视频的封面。图11是本申请实施例提供的一种图像裁剪方法的流程图,参见图11,该方法包括以下步骤1101至步骤1105。
1101、用户终端在检测到对视频的封面设置请求的情况下,获取该视频的视频标识以及用户上传的备选封面,向服务器发送携带该视频标识和备选封面的封面设置请求。
其中,该封面设置请求是由用户在用户终端中执行的封面设置操作触发的。
1102、服务器响应于用户终端发送的封面设置请求,获取封面设置请求中的备选封面和视频标识,在视频帧数据库中获取该视频标识对应的多个视频帧。
1103、服务器在备选封面和多个视频帧中筛选清晰度大于第四阈值的图像,将筛选出来的图像确定为第一图像。
1104、服务器采用上述图3的实施例提供的图像裁剪方法,对多个第一图像进行裁剪,得到不同尺寸的第二图像,将不同尺寸的第二图像分别确定为该视频的封面。
1105、服务器分别发布封面为不同尺寸的第二图像的该视频。
其中,终端发送的封面设置请求还用于请求发布设置好封面的视频,因此计算机设备将不同尺寸的第二图像分别确定为视频的封面后,发布封面为不同尺寸的第二图像的该视频。
在视频分享的场景下,用户终端在发布视频时,不会为视频准备合适的封面,而在不同的分发场景下需要使用不同尺寸的封面,因此服务器采用上述图3的实施例提供的方法,自动为视频裁剪出不同尺寸的封面,能够提高视频的封面展示效果,节省了人力消耗。
除了在视频分享领域为视频裁剪封面之外,还可以在其他场景中应用上述实施例提供的图像裁剪方法。例如在需要对不同尺寸的图像进行集中处理时,采用上述实施例提供的图像裁剪方法,将多个不同尺寸的图像裁剪为相同的尺寸等。例如在图像分享领域中,将图像裁剪为符合要求的尺寸等,本申请实施例对图像裁剪方法的应用场景不做限定。
图12是本申请实施例提供的一种图像裁剪装置的结构示意图。参见图12,该装置包括:
对象框确定模块1201,用于确定第一图像中的每个对象所在的对象框;
目标框和排除框确定模块1202,用于将属于第一类型的对象所在的对象框确定为第一目标框,将属于第二类型的对象所在的对象框确定为排除框,第一类型的对象为需要保留的对象,第二类型的对象为不需要保留的对象;
目标区域确定模块1203,用于确定第一图像中的目标区域,目标区域包括第一目标框且不包括排除框;
裁剪模块1204,用于基于目标区域,对第一图像进行裁剪,得到包括第一目标框且不包括排除框的第二图像。
本申请实施例提供的图像裁剪装置,将第一图像中的对象划分为需要保留的对象和不需要保留的对象,并通过确定第一目标框和排除框,来将需要保留的对象和不需要保留的对象所在的区域进行标记,由于第一图像中的目标区域包括第一目标框且不包括排除框,则基于目标区域,对第一图像进行裁剪,能够得到包括第一目标框且不包括排除框的第二图像。其 中,利用第一目标框和排除框来标记图像中需要保留的对象和不需要保留的对象所在的区域,有利于快速识别出目标区域,从而提高了图像裁剪的速度。并且,需要保留的对象可视为需要关注的关键信息,不需要保留的对象可视为不需要关注的干扰信息,因此,此种图像裁剪方法保证了该第二图像中包括需要关注的关键信息,且不包括不需要关注的干扰信息,从而提高了图像裁剪的效果。
可选地,参见图13,目标区域确定模块1203,包括:
候选区域确定单元1213,用于基于排除框的位置,确定第一图像中的多个候选区域,每个候选区域中不包括排除框;
目标区域确定单元1223,用于在多个候选区域中,确定包括第一目标框的目标区域。
可选地,参见图13,候选区域确定单元1213,用于:
在排除框的边缘线中,确定与第一图像的每个边缘线没有重叠的目标边缘线;
确定目标边缘线所在的直线,将第一图像中位于直线外侧的区域确定为候选区域,直线外侧是指远离排除框的一侧。
可选地,参见图13,候选区域确定单元1213,用于执行以下至少一项:
在目标边缘线包括排除框的左边缘线的情况下,确定目标边缘线所在的第一直线,将第一图像中位于第一直线左侧的区域确定为候选区域;
在目标边缘线包括排除框的右边缘线的情况下,确定目标边缘线所在的第二直线,将第一图像中位于第二直线右侧的区域确定为候选区域;
在目标边缘线包括排除框的上边缘线的情况下,确定目标边缘线所在的第三直线,将第一图像中位于第三直线上侧的区域确定为候选区域;
在目标边缘线包括排除框的下边缘线的情况下,确定目标边缘线所在的第四直线,将第一图像中位于第四直线下侧的区域确定为候选区域。
可选地,参见图13,排除框的数量为多个,候选区域确定单元1213,用于:
基于第一排除框的位置,确定第一图像中的第一候选区域,第一候选区域中不包括第一排除框,第一排除框为多个排除框中的任一排除框;
响应于第一候选区域包括第二排除框,基于第二排除框的位置,确定第一候选区域中的第二候选区域,第二候选区域中不包括第二排除框,第二排除框为多个排除框中除第一排除框外的任一排除框;
响应于第二候选区域不包括任一排除框,将第二候选区域作为候选区域。
可选地,参见图13,装置还包括:
区域删除模块1205,用于从所确定的多个第一候选区域中,将尺寸小于第一阈值的第一候选区域删除;
所述候选区域确定单元1213,用于响应于未删除的第一候选区域包括第二排除框,基于第二排除框的位置,确定未删除的第一候选区域中的第二候选区域。
可选地,参见图13,对象框确定模块1201,用于执行以下至少一项:
对第一图像进行人脸识别,得到第一图像中的人脸框;
对第一图像进行物体识别,得到第一图像中的物体框;
对第一图像进行文本识别,得到第一图像中的文本框;
对第一图像进行水印识别,得到第一图像中的水印框。
可选地,参见图13,目标框和排除框确定模块1202,用于执行以下至少一项:
将人脸所在的人脸框确定为第一目标框;
将物体所在的物体框确定为第一目标框。
可选地,参见图13,目标框和排除框确定模块1202,用于执行以下至少一项:
将文本所在的文本框确定为排除框;
将水印所在的水印框确定为排除框。
可选地,参见图13,装置还包括:
扩大模块1206,用于在已确定多个第一目标框的情况下,将每个第一目标框的尺寸扩大第一倍数,得到多个第二目标框;
合并模块1207,用于对于每个第二目标框,在第二目标框与其他第二目标框相交的情况下,将第二目标框与其他第二目标框合并为一个第三目标框;
目标区域确定模块1203,包括:
第一确定单元1233,用于在第一图像中,将包括第三目标框且不包括排除框的区域,确定为目标区域;
第二确定单元1243,用于在第一图像中,将包括剩余的第二目标框对应的第一目标框、且不包括排除框的区域,确定为目标区域,剩余的第二目标框为没有进行合并的第二目标框。
可选地,参见图13,第一目标框的数量为多个,目标区域确定模块1203,包括:
第三确定单元1253,用于在第一图像中,确定包括至少一个第一目标框、且不包括排除框的目标区域。
可选地,参见图13,第一目标框的数量为多个,目标区域确定模块1203,包括:
第四确定单元1263,用于在多个第一目标框中包括人脸框的情况下,在第一图像中,确定包括人脸框且不包括排除框的目标区域。
可选地,参见图13,裁剪模块1204,包括:
裁剪单元1214,用于基于目标区域,对第一图像进行裁剪,得到包括第一目标框、不包括排除框、且宽高比为目标宽高比的第二图像。
可选地,参见图13,裁剪单元1214,用于:
扩大第一目标框的宽度或者高度中的至少一项,得到第四目标框,以使第四目标框的宽高比为目标宽高比;
保持第四目标框的中心点不变,扩大第四目标框的尺寸,直至扩大第二倍数或者扩大后第四目标框的任一边缘线与目标区域的边缘线重叠,得到第五目标框;
从第一图像中裁剪第五目标框,将裁剪出的第五目标框确定为第二图像。
可选地,参见图13,装置还包括:
图像获取模块1208,用于响应于对第一视频的封面设置请求,获取第一图像,第一图像用于展示第一视频的内容;
封面确定模块1209,用于将第二图像确定为第一视频的封面,或者,将第二图像调整至目标尺寸,将调整后的第二图像确定为第一视频的封面。
可选地,参见图13,封面确定模块1209,包括:
区域分割单元1219,用于将第二图像分割成多个图像区域;
差异参数确定单元1229,用于对于每个图像区域,确定图像区域中的多个像素点的明亮度之间的差异参数;
数量确定单元1239,用于基于多个图像区域分别对应的差异参数,确定不小于第二阈值的差异参数的数量;
封面确定单元1249,用于在数量大于第三阈值的情况下,将第二图像确定为第一视频的封面,或者,将第二图像调整至目标尺寸,将调整后的第二图像确定为第一视频的封面。
可选地,参见图13,图像获取模块1208,包括:
关联图像获取单元1218,用于响应于封面设置请求,获取第一视频对应的多个关联图像,关联图像用于展示第一视频的内容;
清晰度识别单元1228,用于分别对多个关联图像进行清晰度识别,得到每个关联图像的清晰度;
图像确定单元1238,用于在多个关联图像中,将清晰度大于第四阈值的图像确定为第一图像。
可选地,参见图13,关联图像获取单元1218,用于:
响应于封面设置请求,获取封面设置请求中携带的备选封面和视频标识,视频标识指示 第一视频;
在视频帧数据库中,获取视频标识对应的至少一个视频帧;
将备选封面和至少一个视频帧确定为第一视频对应的关联图像。
需要说明的是:上述实施例提供的图像裁剪装置在进行图像裁剪时,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将计算机设备的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。另外,上述实施例提供的图像裁剪装置与图像裁剪方法实施例属于同一构思,其具体实现过程详见方法实施例,这里不再赘述。
本申请实施例还提供了一种计算机设备,该计算机设备包括处理器和存储器,存储器中存储有至少一条计算机程序,该至少一条计算机程序由处理器加载并执行,以使计算机设备实现上述实施例的图像裁剪方法中所执行的操作。
可选地,该计算机设备提供为终端,例如该终端是智能手机、平板电脑、笔记本电脑、台式计算机、智能音箱、智能手表、智能电视、智能车载终端等。图14示出了本申请一个示例性实施例提供的终端1400的结构示意图。
终端1400包括有:处理器1401和存储器1402。
处理器1401可以包括一个或多个处理核心,比如4核心处理器、8核心处理器等。处理器1401可以采用DSP(Digital Signal Processing,数字信号处理)、FPGA(Field Programmable Gate Array,现场可编程门阵列)、PLA(Programmable Logic Array,可编程逻辑阵列)中的至少一种硬件形式来实现。处理器1401也可以包括主处理器和协处理器,主处理器是用于对在唤醒状态下的数据进行处理的处理器,也称CPU(Central Processing Unit,中央处理器);协处理器是用于对在待机状态下的数据进行处理的低功耗处理器。在一些实施例中,处理器1401可以集成有GPU(Graphics Processing Unit,图像处理的交互器),GPU用于负责显示屏所需要显示的内容的渲染和绘制。一些实施例中,处理器1401还可以包括AI(Artificial Intelligence,人工智能)处理器,该AI处理器用于处理有关机器学习的计算操作。
存储器1402可以包括一个或多个计算机可读存储介质,该计算机可读存储介质可以是非暂态的。存储器1402还可包括高速随机存取存储器,以及非易失性存储器,比如一个或多个磁盘存储设备、闪存存储设备。在一些实施例中,存储器1402中的非暂态的计算机可读存储介质用于存储至少一条计算机程序,该至少一条计算机程序用于被处理器1401所具有以实现本申请中方法实施例提供的图像裁剪方法。
在一些实施例中,终端1400还可选包括有:外围设备接口1403和至少一个外围设备。处理器1401、存储器1402和外围设备接口1403之间可以通过总线或信号线相连。各个外围设备可以通过总线、信号线或电路板与外围设备接口1403相连。可选地,外围设备包括:射频电路1404、显示屏1405和摄像头组件1406中的至少一种。
外围设备接口1403可被用于将I/O(Input/Output,输入/输出)相关的至少一个外围设备连接到处理器1401和存储器1402。在一些实施例中,处理器1401、存储器1402和外围设备接口1403被集成在同一芯片或电路板上;在一些其他实施例中,处理器1401、存储器1402和外围设备接口1403中的任意一个或两个可以在单独的芯片或电路板上实现,本实施例对此不加以限定。
射频电路1404用于接收和发射RF(Radio Frequency,射频)信号,也称电磁信号。射频电路1404通过电磁信号与通信网络以及其他通信设备进行通信。射频电路1404将电信号转换为电磁信号进行发送,或者,将接收到的电磁信号转换为电信号。可选地,射频电路1404包括:天线系统、RF收发器、一个或多个放大器、调谐器、振荡器、数字信号处理器、编解码芯片组、用户身份模块卡等等。射频电路1404可以通过至少一种无线通信协议来与其它设备进行通信。该无线通信协议包括但不限于:城域网、各代移动通信网络(2G、3G、4G及5G)、无线局域网和/或WiFi(Wireless Fidelity,无线保真)网络。在一些实施例中,射频电 路1404还可以包括NFC(Near Field Communication,近距离无线通信)有关的电路,本申请对此不加以限定。
显示屏1405用于显示UI(User Interface,用户界面)。该UI可以包括图形、文本、图标、视频及其它们的任意组合。当显示屏1405是触摸显示屏时,显示屏1405还具有采集在显示屏1405的表面或表面上方的触摸信号的能力。该触摸信号可以作为控制信号输入至处理器1401进行处理。此时,显示屏1405还可以用于提供虚拟按钮和/或虚拟键盘,也称软按钮和/或软键盘。在一些实施例中,显示屏1405可以为一个,设置在终端1400的前面板;在另一些实施例中,显示屏1405可以为至少两个,分别设置在终端1400的不同表面或呈折叠设计;在另一些实施例中,显示屏1405可以是柔性显示屏,设置在终端1400的弯曲表面上或折叠面上。甚至,显示屏1405还可以设置成非矩形的不规则图形,也即异形屏。显示屏1405可以采用LCD(Liquid Crystal Display,液晶显示屏)、OLED(Organic Light-Emitting Diode,有机发光二极管)等材质制备。
摄像头组件1406用于采集图像或视频。可选地,摄像头组件1406包括前置摄像头和后置摄像头。前置摄像头设置在终端1400的前面板,后置摄像头设置在终端1400的背面。在一些实施例中,后置摄像头为至少两个,分别为主摄像头、景深摄像头、广角摄像头、长焦摄像头中的任意一种,以实现主摄像头和景深摄像头融合实现背景虚化功能、主摄像头和广角摄像头融合实现全景拍摄以及VR(Virtual Reality,虚拟现实)拍摄功能或者其它融合拍摄功能。在一些实施例中,摄像头组件1406还可以包括闪光灯。闪光灯可以是单色温闪光灯,也可以是双色温闪光灯。双色温闪光灯是指暖光闪光灯和冷光闪光灯的组合,可以用于不同色温下的光线补偿。
本领域技术人员可以理解,图14中示出的结构并不构成对终端1400的限定,可以包括比图示更多或更少的组件,或者组合某些组件,或者采用不同的组件布置。
可选地,该计算机设备提供为服务器。图15是本申请实施例提供的一种服务器的结构示意图,该服务器1500可因配置或性能不同而产生比较大的差异,可以包括一个或一个以上处理器(Central Processing Units,CPU)1501和一个或一个以上的存储器1502,其中,所述存储器1502中存储有至少一条计算机程序,所述至少一条计算机程序由所述处理器1501加载并执行以实现上述各个方法实施例提供的图像裁剪方法。当然,该服务器还可以具有有线或无线网络接口、键盘以及输入输出接口等部件,以便进行输入输出,该服务器还可以包括其他用于实现设备功能的部件,在此不做赘述。
本申请实施例还提供了一种非易失性计算机可读存储介质,该非易失性计算机可读存储介质中存储有至少一条计算机程序,该至少一条计算机程序由处理器加载并执行,以使计算机实现上述实施例的图像裁剪方法中所执行的操作。
本申请实施例还提供了一种计算机程序产品或计算机程序,计算机程序产品或计算机程序包括计算机程序代码,计算机程序代码存储在非易失性计算机可读存储介质中,计算机设备的处理器从非易失性计算机可读存储介质读取计算机程序代码,处理器执行计算机程序代码,使得计算机设备实现如上述实施例的图像裁剪方法中所执行的操作。在一些实施例中,本申请实施例所涉及的计算机程序可被部署在一个计算机设备上执行,或者在位于一个地点的多个计算机设备上执行,又或者,在分布在多个地点且通过通信网络互连的多个计算机设备上执行,分布在多个地点且通过通信网络互连的多个计算机设备可以组成区块链系统。
本领域普通技术人员可以理解实现上述实施例的全部或部分步骤可以通过硬件来完成,也可以通过程序来指令相关的硬件完成,所述的程序可以存储于一种非易失性计算机可读存储介质中,上述提到的存储介质可以是只读存储器,磁盘或光盘等。
以上所述仅为本申请实施例的可选实施例,并不用以限制本申请实施例,凡在本申请实施例的原则之内,所作的任何修改、等同替换、改进等,均应包含在本申请的保护范围之内。

Claims (22)

  1. 一种图像裁剪方法,其中,所述方法由计算机设备执行,所述方法包括:
    确定第一图像中的每个对象所在的对象框;
    将属于第一类型的对象所在的对象框确定为第一目标框,将属于第二类型的对象所在的对象框确定为排除框,所述第一类型的对象为需要保留的对象,所述第二类型的对象为不需要保留的对象;
    确定所述第一图像中的目标区域,所述目标区域包括所述第一目标框且不包括所述排除框;
    基于所述目标区域,对所述第一图像进行裁剪,得到包括所述第一目标框且不包括所述排除框的第二图像。
  2. 根据权利要求1所述的方法,其中,所述确定所述第一图像中的目标区域,包括:
    基于所述排除框的位置,确定所述第一图像中的多个候选区域,每个所述候选区域中不包括所述排除框;
    在多个所述候选区域中,确定包括所述第一目标框的目标区域。
  3. 根据权利要求2所述的方法,其中,所述基于所述排除框的位置,确定所述第一图像中的多个候选区域,包括:
    在所述排除框的边缘线中,确定与所述第一图像的每个边缘线没有重叠的目标边缘线;
    确定所述目标边缘线所在的直线,将所述第一图像中位于所述直线外侧的区域确定为所述候选区域,所述直线外侧是指远离所述排除框的一侧。
  4. 根据权利要求3所述的方法,其中,所述确定所述目标边缘线所在的直线,将所述第一图像中位于所述直线外侧的区域确定为所述候选区域,包括以下至少一项:
    在所述目标边缘线包括所述排除框的左边缘线的情况下,确定所述目标边缘线所在的第一直线,将所述第一图像中位于所述第一直线左侧的区域确定为所述候选区域;
    在所述目标边缘线包括所述排除框的右边缘线的情况下,确定所述目标边缘线所在的第二直线,将所述第一图像中位于所述第二直线右侧的区域确定为所述候选区域;
    在所述目标边缘线包括所述排除框的上边缘线的情况下,确定所述目标边缘线所在的第三直线,将所述第一图像中位于所述第三直线上侧的区域确定为所述候选区域;
    在所述目标边缘线包括所述排除框的下边缘线的情况下,确定所述目标边缘线所在的第四直线,将所述第一图像中位于所述第四直线下侧的区域确定为所述候选区域。
  5. 根据权利要求2所述的方法,其中,所述排除框的数量为多个,所述基于所述排除框的位置,确定所述第一图像中的多个候选区域,包括:
    基于第一排除框的位置,确定所述第一图像中的第一候选区域,所述第一候选区域中不包括所述第一排除框,所述第一排除框为多个所述排除框中的任一排除框;
    响应于所述第一候选区域包括第二排除框,基于所述第二排除框的位置,确定所述第一候选区域中的第二候选区域,所述第二候选区域中不包括所述第二排除框,所述第二排除框为多个所述排除框中除所述第一排除框外的任一排除框;
    响应于所述第二候选区域不包括任一排除框,将所述第二候选区域作为所述候选区域。
  6. 根据权利要求5所述的方法,其中,所述第一候选区域的数量为多个,所述基于第一排除框的位置,确定所述第一图像中的第一候选区域之后,所述方法还包括:
    从所确定的多个所述第一候选区域中,将尺寸小于第一阈值的第一候选区域删除;
    所述响应于所述第一候选区域包括第二排除框,基于所述第二排除框的位置,确定所述第一候选区域中的第二候选区域,包括:
    响应于未删除的第一候选区域包括第二排除框,基于所述第二排除框的位置,确定所述未删除的第一候选区域中的第二候选区域。
  7. 根据权利要求1所述的方法,其中,所述确定第一图像中的每个对象所在的对象框,包 括以下至少一项:
    对所述第一图像进行人脸识别,得到所述第一图像中的人脸框;
    对所述第一图像进行物体识别,得到所述第一图像中的物体框;
    对所述第一图像进行文本识别,得到所述第一图像中的文本框;
    对所述第一图像进行水印识别,得到所述第一图像中的水印框。
  8. 根据权利要求1所述的方法,其中,所述将属于第一类型的对象所在的对象框确定为第一目标框,包括以下至少一项:
    将人脸所在的人脸框确定为所述第一目标框;
    将物体所在的物体框确定为所述第一目标框。
  9. 根据权利要求1所述的方法,其中,所述将属于第二类型的对象所在的对象框确定为排除框,包括以下至少一项:
    将文本所在的文本框确定为所述排除框;
    将水印所在的水印框确定为所述排除框。
  10. 根据权利要求1所述的方法,其中,所述方法还包括:
    在已确定多个所述第一目标框的情况下,将每个所述第一目标框的尺寸扩大第一倍数,得到多个第二目标框;
    对于每个所述第二目标框,在所述第二目标框与其他第二目标框相交的情况下,将所述第二目标框与所述其他第二目标框合并为一个第三目标框;
    所述确定所述第一图像中的目标区域,包括:
    在所述第一图像中,将包括所述第三目标框且不包括所述排除框的区域,确定为所述目标区域;
    在所述第一图像中,将包括剩余的第二目标框对应的第一目标框、且不包括所述排除框的区域,确定为所述目标区域,所述剩余的第二目标框为没有进行合并的第二目标框。
  11. 根据权利要求1所述的方法,其中,所述第一目标框的数量为多个,所述确定所述第一图像中的目标区域,包括:
    在所述第一图像中,确定包括至少一个所述第一目标框、且不包括所述排除框的所述目标区域。
  12. 根据权利要求1所述的方法,其中,所述第一目标框的数量为多个,所述确定所述第一图像中的目标区域,包括:
    在多个所述第一目标框中包括人脸框的情况下,在所述第一图像中,确定包括所述人脸框且不包括所述排除框的所述目标区域。
  13. 根据权利要求1所述的方法,其中,所述基于所述目标区域,对所述第一图像进行裁剪,得到包括所述第一目标框且不包括所述排除框的第二图像,包括:
    基于所述目标区域,对所述第一图像进行裁剪,得到包括所述第一目标框、不包括所述排除框、且宽高比为目标宽高比的所述第二图像。
  14. 根据权利要求13所述的方法,其中,所述基于所述目标区域,对所述第一图像进行裁剪,得到包括所述第一目标框、不包括所述排除框、且宽高比为目标宽高比的所述第二图像,包括:
    扩大所述第一目标框的宽度或者高度中的至少一项,得到第四目标框,以使所述第四目标框的宽高比为所述目标宽高比;
    保持所述第四目标框的中心点不变,扩大所述第四目标框的尺寸,直至扩大第二倍数或者扩大后所述第四目标框的任一边缘线与所述目标区域的边缘线重叠,得到第五目标框;
    从所述第一图像中裁剪所述第五目标框,将裁剪出的所述第五目标框确定为所述第二图像。
  15. 根据权利要求1-14任一项所述的方法,其中,所述确定第一图像中的每个对象所在的对象框之前,所述方法还包括:
    响应于对第一视频的封面设置请求,获取所述第一图像,所述第一图像用于展示所述第一视频的内容;
    所述基于所述目标区域,对所述第一图像进行裁剪,得到包括所述第一目标框且不包括所述排除框的第二图像之后,所述方法还包括:
    将所述第二图像确定为所述第一视频的封面,或者,将所述第二图像调整至目标尺寸,将调整后的所述第二图像确定为所述第一视频的封面。
  16. 根据权利要求15所述的方法,其中,所述将所述第二图像确定为所述第一视频的封面,或者,将所述第二图像调整至目标尺寸,将调整后的所述第二图像确定为所述第一视频的封面,包括:
    将所述第二图像分割成多个图像区域;
    对于每个所述图像区域,确定所述图像区域中的多个像素点的明亮度之间的差异参数;
    基于所述多个图像区域分别对应的差异参数,确定不小于第二阈值的差异参数的数量;
    在所述数量大于第三阈值的情况下,将所述第二图像确定为所述第一视频的封面,或者,将所述第二图像调整至所述目标尺寸,将调整后的所述第二图像确定为所述第一视频的封面。
  17. 根据权利要求15所述的方法,其中,所述响应于对第一视频的封面设置请求,获取所述第一图像,包括:
    响应于所述封面设置请求,获取所述第一视频对应的多个关联图像,所述关联图像用于展示所述第一视频的内容;
    分别对所述多个关联图像进行清晰度识别,得到每个关联图像的清晰度;
    在所述多个关联图像中,将清晰度大于第四阈值的图像确定为所述第一图像。
  18. 根据权利要求17所述的方法,其中,所述响应于所述封面设置请求,获取所述第一视频对应的多个关联图像,包括:
    响应于所述封面设置请求,获取所述封面设置请求中携带的备选封面和视频标识,所述视频标识指示所述第一视频;
    在视频帧数据库中,获取所述视频标识对应的至少一个视频帧;
    将所述备选封面和所述至少一个视频帧确定为所述第一视频对应的关联图像。
  19. 一种图像裁剪装置,其中,所述装置包括:
    对象框确定模块,用于确定第一图像中的每个对象所在的对象框;
    目标框和排除框确定模块,用于将属于第一类型的对象所在的对象框确定为第一目标框,将属于第二类型的对象所在的对象框确定为排除框,所述第一类型的对象为需要保留的对象,所述第二类型的对象为不需要保留的对象;
    目标区域确定模块,用于确定所述第一图像中的目标区域,所述目标区域包括所述第一目标框且不包括所述排除框;
    裁剪模块,用于基于所述目标区域,对所述第一图像进行裁剪,得到包括所述第一目标框且不包括所述排除框的第二图像。
  20. 一种计算机设备,其中,所述计算机设备包括处理器和存储器,所述存储器中存储有至少一条计算机程序,所述至少一条计算机程序由所述处理器加载并执行,以使所述计算机设备实现如权利要求1至18任一项所述的图像裁剪方法所执行的操作。
  21. 一种非易失性计算机可读存储介质,其中,所述非易失性计算机可读存储介质中存储有至少一条计算机程序,所述至少一条计算机程序由处理器加载并执行,以使计算机实现如权利要求1至18任一项所述的图像裁剪方法所执行的操作。
  22. 一种计算机程序产品,其中,所述计算机程序产品包括计算机程序代码,所述计算机程序代码存储在非易失性计算机可读存储介质中,计算机设备的处理器从所述非易失性计算机可读存储介质读取所述计算机程序代码,所述处理器执行所述计算机程序代码,使得所述计算机设备实现如权利要求1至18任一项所述的图像裁剪方法所执行的操作。
PCT/CN2022/113325 2021-09-27 2022-08-18 图像裁剪方法、装置、计算机设备及存储介质 WO2023045641A1 (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
US18/219,943 US20230351604A1 (en) 2021-09-27 2023-07-10 Image cutting method and apparatus, computer device, and storage medium

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202111137663.4 2021-09-27
CN202111137663.4A CN113570626B (zh) 2021-09-27 2021-09-27 图像裁剪方法、装置、计算机设备及存储介质

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US18/219,943 Continuation US20230351604A1 (en) 2021-09-27 2023-07-10 Image cutting method and apparatus, computer device, and storage medium

Publications (1)

Publication Number Publication Date
WO2023045641A1 true WO2023045641A1 (zh) 2023-03-30

Family

ID=78174814

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/113325 WO2023045641A1 (zh) 2021-09-27 2022-08-18 图像裁剪方法、装置、计算机设备及存储介质

Country Status (3)

Country Link
US (1) US20230351604A1 (zh)
CN (1) CN113570626B (zh)
WO (1) WO2023045641A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116543004A (zh) * 2023-07-05 2023-08-04 荣耀终端有限公司 图像裁切方法、装置、终端设备及计算机可读存储介质

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113570626B (zh) * 2021-09-27 2022-01-07 腾讯科技(深圳)有限公司 图像裁剪方法、装置、计算机设备及存储介质
CN114666649B (zh) * 2022-03-31 2024-03-01 北京奇艺世纪科技有限公司 字幕被裁视频的识别方法、装置、电子设备及存储介质
CN117177052B (zh) * 2023-11-03 2024-05-14 荣耀终端有限公司 图像获取方法、电子设备及计算机可读存储介质

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100329550A1 (en) * 2009-06-24 2010-12-30 Stephen Philip Cheatle Method for automatically cropping digital images
CN104504649A (zh) * 2014-12-30 2015-04-08 百度在线网络技术(北京)有限公司 图片的裁剪方法和装置
US10205835B1 (en) * 2016-10-10 2019-02-12 Walgreen Co. Photograph cropping using facial detection
CN110399848A (zh) * 2019-07-30 2019-11-01 北京字节跳动网络技术有限公司 视频封面生成方法、装置及电子设备
CN110706150A (zh) * 2019-07-12 2020-01-17 北京达佳互联信息技术有限公司 图像处理方法、装置、电子设备及存储介质
CN113570626A (zh) * 2021-09-27 2021-10-29 腾讯科技(深圳)有限公司 图像裁剪方法、装置、计算机设备及存储介质

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101833859B (zh) * 2010-05-14 2012-05-23 山东大学 基于虚拟线圈的自触发车牌识别方法
CN105488811B (zh) * 2015-11-23 2018-06-12 华中科技大学 一种基于深度梯度的目标跟踪方法与系统
US10282639B2 (en) * 2016-11-29 2019-05-07 Sap Se Object detection in image data using depth segmentation
US10755112B2 (en) * 2018-03-13 2020-08-25 Toyota Research Institute, Inc. Systems and methods for reducing data storage in machine learning
CN110349082B (zh) * 2019-06-28 2023-08-29 腾讯科技(深圳)有限公司 图像区域的裁剪方法和装置、存储介质及电子装置
CN112749690B (zh) * 2020-03-27 2023-09-12 腾讯科技(深圳)有限公司 一种文本检测方法、装置、电子设备和存储介质
CN112036345A (zh) * 2020-09-04 2020-12-04 京东方科技集团股份有限公司 目标场所人数的检测方法、推荐方法、检测系统及介质

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100329550A1 (en) * 2009-06-24 2010-12-30 Stephen Philip Cheatle Method for automatically cropping digital images
CN104504649A (zh) * 2014-12-30 2015-04-08 百度在线网络技术(北京)有限公司 图片的裁剪方法和装置
US10205835B1 (en) * 2016-10-10 2019-02-12 Walgreen Co. Photograph cropping using facial detection
CN110706150A (zh) * 2019-07-12 2020-01-17 北京达佳互联信息技术有限公司 图像处理方法、装置、电子设备及存储介质
CN110399848A (zh) * 2019-07-30 2019-11-01 北京字节跳动网络技术有限公司 视频封面生成方法、装置及电子设备
CN113570626A (zh) * 2021-09-27 2021-10-29 腾讯科技(深圳)有限公司 图像裁剪方法、装置、计算机设备及存储介质

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116543004A (zh) * 2023-07-05 2023-08-04 荣耀终端有限公司 图像裁切方法、装置、终端设备及计算机可读存储介质
CN116543004B (zh) * 2023-07-05 2024-04-19 荣耀终端有限公司 图像裁切方法、装置、终端设备及计算机可读存储介质

Also Published As

Publication number Publication date
CN113570626B (zh) 2022-01-07
CN113570626A (zh) 2021-10-29
US20230351604A1 (en) 2023-11-02

Similar Documents

Publication Publication Date Title
WO2023045641A1 (zh) 图像裁剪方法、装置、计算机设备及存储介质
CN106570110B (zh) 图像去重方法及装置
JP7226851B2 (ja) 画像処理の方法および装置並びにデバイス
EP4246447A2 (en) Method and device for dynamically displaying icon according to background image
WO2021036715A1 (zh) 一种图文融合方法、装置及电子设备
CN111612873A (zh) Gif图片生成方法、装置及电子设备
US9137461B2 (en) Real-time camera view through drawn region for image capture
WO2023151472A1 (zh) 图像显示方法、装置、终端及存储介质
US8830251B2 (en) Method and system for creating an image
EP3822757A1 (en) Method and apparatus for setting background of ui control
WO2023093438A1 (zh) 图像显示方法、装置、电子设备及计算机可读存储介质
CN110290426B (zh) 展示资源的方法、装置、设备及存储介质
WO2022242397A1 (zh) 一种图像处理方法、装置及计算机可读存储介质
CN105654451A (zh) 一种图像的处理方法和装置
CN115242983B (zh) 拍摄方法、电子设备及可读存储介质
CN111325220B (zh) 图像生成方法、装置、设备及存储介质
CN112437232A (zh) 拍摄方法、装置、电子设备及可读存储介质
CN113342247B (zh) 素材处理方法、装置、电子设备及存储介质
US20110058057A1 (en) Image capture device and method, image processing device and method, and program
US20230188830A1 (en) Image Color Retention Method and Device
WO2015096015A1 (zh) 一种照片显示方法及用户终端
CN115379208B (zh) 一种摄像头的测评方法及设备
WO2023066047A1 (zh) 一种识别图像中文本信息的方法、设备及系统
CN113393391B (zh) 图像增强方法、图像增强装置、电子设备和存储介质
WO2022160965A1 (zh) 一种视频处理方法及电子设备

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22871698

Country of ref document: EP

Kind code of ref document: A1