Face centering display method and device, electronic equipment and computer storage medium
By obtaining parameters from images on social media platforms and performing facial recognition, the array of face rectangles and the coordinates of the center point are determined, solving the problem of faces not being centered in images and improving the user experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HUNAN HAPPLY SUNSHINE INTERACTIVE ENTERTAINMENT MEDIA CO LTD
- Filing Date
- 2022-11-08
- Publication Date
- 2026-05-08
AI Technical Summary
On social media platforms, faces in photos are not centered, resulting in poor aesthetics, and there are also issues with slow network loading or failure to load when clicking to view the original image.
By obtaining the parameters of the target image, face recognition is performed to determine the face rectangle array and center point coordinates. The face is then displayed in the center using the default center display rectangle parameters.
It enables centered display of faces in images on social media platforms, avoiding poor user experience such as slow network loading and loading failures when clicking on an image to view the original image.
Smart Images

Figure CN115905748B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a method, apparatus, electronic device, and computer storage medium for centering a face display. Background Technology
[0002] With the development of the internet, more and more users prefer to share and express themselves through social media platforms by posting updates, comments, blogs, and other information. To facilitate users' browsing and clicking on content of interest, social media platforms often design relatively uniform page templates to display content.
[0003] Currently, in related technologies, image processing often involves centering and cropping. However, if the main subject of the image is a human face, due to the diversity of shooting methods and techniques, the face is not always centered, resulting in an incomplete face that greatly affects aesthetics. Summary of the Invention
[0004] In view of this, this application provides a method, apparatus, electronic device, and computer storage medium for centering facial images, which solves the problem of centering facial images on social media platforms and avoids poor user experience such as slow network loading and loading failure caused by secondary requests to view the original image.
[0005] The first aspect of this application provides a method for centering a face, including:
[0006] Obtain the parameters of the target image; wherein the parameters of the target image include the height and width of the target image;
[0007] Based on the parameters of the target image, determine the parameters of the default centered display rectangle;
[0008] Face recognition is performed on the human figure in the target image to obtain a face rectangle array; wherein, the face rectangle array is composed of the upper left corner ordinate, the upper left corner abscissa, the face frame width, and the face frame height;
[0009] Based on the array of face rectangles, determine the coordinates of the face center point;
[0010] The face rectangle parameters are determined based on the coordinates of the face center point, the coordinates of the target image center point, and the default center-display rectangle parameters.
[0011] Based on the predetermined display area, the parameters of the target image, and the parameters of the face rectangle, the face is displayed in the center.
[0012] Optionally, determining the parameters of the default centered display rectangle based on the parameters of the target image includes:
[0013] Take the minimum value between the height and width of the target image as the target side length;
[0014] The parameters for the default centered display rectangle are determined based on the height, width, and side length of the target image.
[0015] Optionally, if the number of elements in the face rectangle array is greater than 0, determining the coordinates of the face center point based on the face rectangle array includes:
[0016] Summing the top-left corner ordinate of the face bounding box and half the width of the face bounding box, and dividing by the number of elements in the face rectangle array, yields the ordinate of the face center point.
[0017] Summing the x-coordinate of the top-left corner of the face bounding box and half the height of the face bounding box, and dividing by the number of elements in the face rectangle array, yields the x-coordinate of the face center point.
[0018] Optionally, determining the face rectangle parameters based on the face center point coordinates, the target image center point coordinates, and the default centered display rectangle parameters includes:
[0019] The location of the face center point in the target image is determined by comparing the coordinates of the face center point with the coordinates of the center point of the target image.
[0020] Based on the location of the face center point coordinates in the target image, the face rectangle parameters are calculated using the face center point coordinates, the parameters of the target image, and the parameters of the default centered display rectangle.
[0021] Optionally, the step of centering the face display based on the predetermined display area, the parameters of the target image, and the face rectangle parameters includes:
[0022] The predetermined display area is filled according to the aspect ratio of the target image;
[0023] The rectangle ratio is determined based on the face rectangle parameters and the target image parameters;
[0024] The image is moved to the predetermined display area according to the rectangle ratio to achieve centered display of the face.
[0025] Optionally, the top-left corner ordinate, top-left corner abscissa, face frame width, and face frame height are all positive integers, separated by commas.
[0026] A second aspect of this application provides a face-centered display device, comprising:
[0027] An acquisition unit is used to acquire parameters of a target image; wherein the parameters of the target image include the height and width of the target image;
[0028] The first determining unit is used to determine the parameters of the default centered display rectangle based on the parameters of the target image;
[0029] A face recognition unit is used to perform face recognition on the human image in the target image to obtain a face rectangle array; wherein, the face rectangle array is composed of the upper left corner ordinate, the upper left corner abscissa, the face frame width, and the face frame height;
[0030] The second determining unit is used to determine the coordinates of the center point of the face based on the face rectangle array;
[0031] The third determining unit is used to determine the face rectangle parameters based on the coordinates of the face center point, the coordinates of the center point of the target image, and the default center-display rectangle parameters.
[0032] The centering display unit is used to center the face display according to the predetermined display area, the parameters of the target image, and the parameters of the face rectangle.
[0033] Optionally, the first determining unit includes:
[0034] The side length determination unit is used to take the minimum value between the height and width of the target image as the target side length;
[0035] The first determining subunit is used to determine the parameters of the default centered display rectangle based on the height and width of the target image and the side length of the target.
[0036] Optionally, if the number of elements in the face rectangle array is greater than 0, the second determining unit includes:
[0037] The vertical coordinate determination unit is used to sum the vertical coordinate of the upper left corner of the face frame and half the width of the face frame, and divide by the number of elements in the face rectangle array to obtain the vertical coordinate of the face center point.
[0038] The x-coordinate determination unit is used to sum the x-coordinate of the upper left corner of the face frame and half the height of the face frame, and divide by the number of elements in the face rectangle array to obtain the x-coordinate of the face center point.
[0039] Optionally, the third determining unit includes:
[0040] The comparison unit is used to compare the coordinates of the face center point with the coordinates of the center point of the target image to determine the location of the face center point in the target image.
[0041] The calculation unit is used to calculate the face rectangle parameters based on the coordinates of the face center point in the target image, using the face center point coordinates, the parameters of the target image, and the parameters of the default centered display rectangle.
[0042] Optionally, the centered display unit includes:
[0043] The fourth determining unit is used to fill the predetermined display area according to the aspect ratio of the target image;
[0044] The fifth determining unit is used to determine the rectangle ratio based on the face rectangle parameters and the parameters of the target image;
[0045] The centering display subunit is used to move the image to the predetermined display area according to the rectangle ratio, thereby completing the centering display of the face.
[0046] Optionally, the top-left corner ordinate, top-left corner abscissa, face frame width, and face frame height are all positive integers, separated by commas.
[0047] A third aspect of this application provides an electronic device, comprising:
[0048] One or more processors;
[0049] A storage device on which one or more programs are stored;
[0050] When the one or more programs are executed by the one or more processors, the one or more processors implement the face centering display method as described in any one of the first aspects.
[0051] The fourth aspect of this application provides a computer storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the face centering display method as described in any one of the first aspects.
[0052] As can be seen from the above solutions, this application provides a method, apparatus, electronic device, and computer storage medium for centering a face. The method includes: acquiring parameters of a target image; wherein the parameters of the target image include the height and width of the target image; determining default centering rectangle parameters based on the parameters of the target image; then, performing face recognition on the portrait in the target image to obtain a face rectangle array; wherein the face rectangle array is composed of the upper left corner ordinate, upper left corner abscissa, face frame width, and face frame height; subsequently, determining the coordinates of the face center point based on the face rectangle array; then, determining the face rectangle parameters based on the face center point coordinates, the center point coordinates of the target image, and the default centering rectangle parameters; finally, completing the centering display of the face based on a predetermined display area, the parameters of the target image, and the face rectangle parameters. This solves the problem of centering faces in images on social media platforms, avoiding the poor user experience caused by slow network loading and loading failures due to secondary requests to view the original image. Attached Figure Description
[0053] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0054] Figure 1 A detailed flowchart of a face-centered display method provided in this application embodiment;
[0055] Figure 2 A detailed flowchart of a method for determining the parameters of a default centered display rectangle, provided in another embodiment of this application;
[0056] Figure 3 A schematic diagram of a system display area provided in another embodiment of this application;
[0057] Figure 4 A detailed flowchart of a method for determining the coordinates of a face center point is provided in another embodiment of this application;
[0058] Figure 5 A detailed flowchart of a method for determining face rectangle parameters provided in another embodiment of this application;
[0059] Figure 6 A flowchart illustrating a method for centering a face in another embodiment of this application;
[0060] Figure 7 A schematic diagram of a face-centered display device provided in another embodiment of this application;
[0061] Figure 8 This is a schematic diagram of an electronic device for implementing a method for centering a face, as provided in another embodiment of this application. Detailed Implementation
[0062] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0063] It should be noted that the concepts of "first," "second," etc., mentioned in this application are used only to distinguish different devices, modules, or units, and are not intended to limit the order of functions performed by these devices, modules, or units or their interdependencies. The terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0064] This application provides a method for centering a face display, such as... Figure 1 As shown, the specific steps include:
[0065] S101. Obtain the parameters of the target image.
[0066] The parameters of the target image include its height and width.
[0067] In the specific implementation of this application, the width (w) and height (h) of the target image A can be obtained by inputting the target image URL. This is denoted as A(w, h), such as (1200, 799).
[0068] S102. Determine the parameters of the default centered display rectangle based on the parameters of the target image.
[0069] Optionally, in another embodiment of this application, one implementation of step S102 is as follows: Figure 2 As shown, it includes:
[0070] S201. Take the minimum value between the height and width of the target image as the target side length.
[0071] S202. Determine the parameters of the default centered display rectangle based on the height, width, and side length of the target image.
[0072] Continuing with the example above, the width (w) and height (h) of the target image (A) are taken as the minimum value of the width and height as the target side length As.
[0073] If A(w)>A(h), P(x, y, w, h) = P((A(w)-A(h)) / 2, 0, As, As); otherwise, P(x, y, w, h) = P((0, A(w)-A(h)) / 2, As, As). like Figure 3 As shown, by default, the largest square with side length As will be cropped. The rectangle parameter result, denoted as B(x, y, w, h), is displayed in the center by default.
[0074] S103. Perform face recognition on the portrait in the target image to obtain a rectangular array of faces.
[0075] The face rectangle array consists of the top-left corner ordinate, the top-left corner abscissa, the face frame width, and the face frame height.
[0076] Furthermore, in practical applications, the top-left corner ordinate, top-left corner abscissa, face frame width, and face frame height are all positive integers, separated by commas.
[0077] For example: F(x, y, w, h) represents the top-left corner ordinate (x), top-left corner abscissa (y), face frame width (w), and face frame height (h), respectively. For example: 70, 80, 100, 100.
[0078] S104. Determine the coordinates of the center point of the face based on the face rectangle array.
[0079] In the specific implementation of this application, if the number of elements in the face rectangle array is greater than 0, the default centered display rectangle parameter can be used directly. If the number of elements in the face rectangle array is greater than 0, one implementation of step S104 is as follows: Figure 4 As shown, it includes:
[0080] S401. Sum the ordinate of the top left corner of the face frame and half the width of the face frame, and divide by the number of elements in the face rectangle array to obtain the ordinate of the face center point.
[0081] S402. Sum the x-coordinate of the top left corner of the face frame and half the height of the face frame, and divide by the number of elements in the face rectangle array to obtain the x-coordinate of the face center point.
[0082] Specifically, the formula for calculating the coordinates C(x, y) of the center point of the face can be as follows:
[0083] C(x,y)=(SUM(F(x)+F(w) / 2) / size, SUM(F(y)+F(h) / 2) / size).
[0084] It is understandable that, in the specific implementation of this application, the N face rectangles with the largest area can be selected from multiple faces to calculate the coordinates of the face center point.
[0085] N is preset by technical personnel or authorized staff, and is not specified here.
[0086] S105. Determine the face rectangle parameters based on the coordinates of the face center point, the coordinates of the target image center point, and the default center-aligned display rectangle parameters.
[0087] Optionally, in another embodiment of this application, one implementation of step S105 is as follows: Figure 5 As shown, it includes:
[0088] S501. By comparing the coordinates of the face center point with the coordinates of the center point of the target image, determine the location of the face center point in the target image.
[0089] Specifically, the orientation is calculated using the center point coordinates C(x, y) of the face and compared with the center point coordinates A(x, y) = A((w) / 2, (h) / 2) of the target image. D(x, y) = D(C(x) - A(x), C(y) - A(y)). If D(x) <= 0 and D(y) <= 0, the face is in the upper left; if D(x) <= 0 and D(y) = 0, the face is in the upper right, and so on. This yields possible orientations: upper left, upper right, lower left, and lower right.
[0090] S502. Based on the location of the face center point coordinates in the target image, calculate the face rectangle parameters using the face center point coordinates, the parameters of the target image, and the default center-display rectangle parameters.
[0091] Specifically, if the target image A(w) > A(h) (i.e., the horizontal image), and if the orientation is top left or bottom left, then by default P(x, y, w, h) = P(0, B(y), B(w), B(h)). If C(x) > A(h) / 2, then P(x) = C(x) - A(h) / 2. If the orientation is top right or bottom right, then by default P(x, y, w, h) = P(B(x), A(w) - A(h) / 2, B(w), B(h)), indicating that the rightmost position is displayed. If T = O(w) - C(x) > O(h) / 2, then P(x) = O(w) - O(h) - T.
[0092] If the original image A(w) <= A(h) (vertical image), and the orientation is top left or top right, then by default P(x, y, w, h) = P(B(x), 0, B(w), B(h)). If C(y) > A(w) / 2, then P(y) = C(y) - A(w) / 2. If the orientation is bottom left or bottom right, then by default P(x, y, w, h) = P(B(x), A(h) - A(w) / 2, B(w), B(h)), indicating that it is displayed at the bottom. If T = O(h) - C(y) > O(w) / 2, then P(y) = O(h) - O(w) - T. The result of the face rectangle parameters is denoted as: P(x, y, w, h). For example: 401, 0, 799, 799.
[0093] S106. Based on the predetermined display area, the parameters of the target image, and the parameters of the face rectangle, complete the centering display of the face.
[0094] Optionally, in another embodiment of this application, one implementation of step S106 is as follows: Figure 6 As shown, it includes:
[0095] S601. Fill the predetermined display area according to the aspect ratio of the target image.
[0096] The pre-defined display area is selected by the user.
[0097] S602. Determine the rectangle ratio based on the face rectangle parameters and the target image parameters.
[0098] Specifically, the rectangle ratio R(x, y, w, h) can be calculated based on the following consensus:
[0099] R(x, y, w, h) = (P(x) / A(w), P(y) / A(h), P(w) / A(w), P(h) / A(h)).
[0100] For example: (0.33416666666666667, 0, 0.6658333333333334, 1).
[0101] S603. Move the image to the predetermined display area according to the rectangle ratio to achieve centered display of the face.
[0102] As can be seen from the above scheme, this application provides a method for centering a face: obtaining parameters of the target image; wherein, the parameters of the target image include the height and width of the target image; determining the default centering rectangle parameters based on the parameters of the target image; then, performing face recognition on the portrait in the target image to obtain a face rectangle array; wherein, the face rectangle array consists of the upper left corner ordinate, upper left corner abscissa, face frame width, and face frame height; the upper left corner ordinate, upper left corner abscissa, face frame width, and face frame height are all positive integers and separated by commas; then, determining the face center point coordinates based on the face rectangle array; further, determining the face rectangle parameters based on the face center point coordinates, the center point coordinates of the target image, and the default centering rectangle parameters; finally, completing the centering display of the face based on the pre-determined display area, the parameters of the target image, and the face rectangle parameters. This solves the problem of centering faces in images on social media platforms, avoiding the poor user experience caused by slow network loading and loading failures due to secondary requests to view the original image.
[0103] Another embodiment of this application provides a face-centered display device, such as... Figure 7 As shown, it specifically includes:
[0104] The acquisition unit 701 is used to acquire parameters of the target image.
[0105] The parameters of the target image include its height and width.
[0106] The first determining unit 702 is used to determine the parameters of the default centered display rectangle based on the parameters of the target image.
[0107] Optionally, in another embodiment of this application, one implementation of the first determining unit 702 includes:
[0108] The side length determination unit is used to take the minimum value between the height and width of the target image as the target side length.
[0109] The first determining sub-unit is used to determine the parameters of the default centered display rectangle based on the height, width, and side length of the target image.
[0110] For details on the specific working process of the units disclosed in the above embodiments of this application, please refer to the corresponding method embodiments, such as... Figure 2 As shown, it will not be elaborated further here.
[0111] The face recognition unit 703 is used to perform face recognition on the human image in the target image and obtain a rectangular array of faces.
[0112] The face rectangle array consists of the top-left corner ordinate, the top-left corner abscissa, the face frame width, and the face frame height.
[0113] Furthermore, in practical applications, the top-left corner ordinate, top-left corner abscissa, face frame width, and face frame height are all positive integers, separated by commas.
[0114] The second determining unit 704 is used to determine the coordinates of the center point of the face based on the face rectangle array.
[0115] Optionally, in another embodiment of this application, if the number of elements in the face rectangle array is greater than 0, then one implementation of the second determining unit 704 includes:
[0116] The vertical coordinate determination unit is used to sum the vertical coordinate of the upper left corner of the face frame and half the width of the face frame, and divide by the number of elements in the face rectangle array to obtain the vertical coordinate of the face center point.
[0117] The x-coordinate determination unit is used to sum the x-coordinate of the upper left corner of the face frame and half the height of the face frame, and divide by the number of elements in the face rectangle array to obtain the x-coordinate of the face center point.
[0118] For details on the specific working process of the units disclosed in the above embodiments of this application, please refer to the corresponding method embodiments, such as... Figure 4 As shown, it will not be elaborated further here.
[0119] The third determining unit 705 is used to determine the face rectangle parameters based on the coordinates of the face center point, the coordinates of the target image center point, and the default center-display rectangle parameters.
[0120] Optionally, in another embodiment of this application, one implementation of the third determining unit 705 includes:
[0121] The comparison unit is used to compare the center point coordinates of the face with the center point coordinates of the target image to determine the location of the face center point in the target image.
[0122] The calculation unit is used to calculate the face rectangle parameters based on the coordinates of the face center point in the target image, using the face center point coordinates, the parameters of the target image, and the parameters of the default centered display rectangle.
[0123] For details on the specific working process of the units disclosed in the above embodiments of this application, please refer to the corresponding method embodiments, such as... Figure 5 As shown, it will not be elaborated further here.
[0124] The centering display unit 706 is used to center the face display according to the predetermined display area, the parameters of the target image and the face rectangle parameters.
[0125] For details on the specific working process of the units disclosed in the above embodiments of this application, please refer to the corresponding method embodiments, such as... Figure 1 As shown, it will not be elaborated further here.
[0126] Optionally, in another embodiment of this application, one implementation of the centered display unit 706 includes:
[0127] The fourth determining unit is used to fill the predetermined display area according to the aspect ratio of the target image.
[0128] The fifth determining unit is used to determine the rectangle ratio based on the face rectangle parameters and the target image parameters.
[0129] The center-display sub-unit is used to move the image to a predetermined display area according to the rectangle ratio, thus centering the face.
[0130] For details on the specific working process of the units disclosed in the above embodiments of this application, please refer to the corresponding method embodiments, such as... Figure 6 As shown, it will not be elaborated further here.
[0131] As can be seen from the above scheme, this application provides a face-centered display device: the acquisition unit 701 acquires the parameters of the target image; wherein, the parameters of the target image include the height and width of the target image; the first determining unit 702 determines the default centering display rectangle parameters according to the parameters of the target image; then, the face recognition unit 703 performs face recognition on the portrait in the target image to obtain a face rectangle array; wherein, the face rectangle array is composed of the upper left corner ordinate, the upper left corner abscissa, the face frame width, and the face frame height; the upper left corner ordinate, the upper left corner abscissa, the face frame width, and the face frame height are all positive integers and separated by commas; then, the second determining unit 704 determines the face center point coordinates according to the face rectangle array; the third determining unit 705 determines the face rectangle parameters according to the face center point coordinates, the center point coordinates of the target image, and the default centering display rectangle parameters; finally, the centering display unit 706 completes the face-centered display according to the pre-determined display area, the target image parameters, and the face rectangle parameters. This solves the problem of centering faces in images on social media platforms, avoiding slow network loading and loading failures caused by secondary requests to view the original image.
[0132] Another embodiment of this application provides an electronic device, such as... Figure 8 As shown, it includes:
[0133] One or more processors 801.
[0134] Storage device 802, on which one or more programs are stored.
[0135] When the one or more programs are executed by the one or more processors 801, the one or more processors 801 implement the face centering display method as described in any of the above embodiments.
[0136] Another embodiment of this application provides a computer storage medium storing a computer program thereon, wherein when the computer program is executed by a processor, it implements the face centering display method as described in any of the above embodiments.
[0137] In the context of this application, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. Machine-readable media can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0138] It should be noted that the computer-readable medium described above in this application can be a computer-readable signal medium, a computer-readable storage medium, or any combination of the two. A computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this application, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this application, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.
[0139] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device.
[0140] Another embodiment of this application provides a computer program product, which, when executed, is used to perform the transaction information processing method described above.
[0141] Specifically, according to embodiments of this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this application include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from a storage device, or installed from a ROM. When the computer program is executed by a processing device, it performs the functions defined in the methods of the embodiments of this application.
[0142] Although the subject matter has been described using language specific to structural features and / or methodological logic, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. Rather, the specific features and actions described above are merely illustrative examples of implementing the claims.
[0143] While several specific implementation details are included in the foregoing discussion, these should not be construed as limiting the scope of this application. Certain features described in the context of individual embodiments may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented individually or in any suitable sub-combination in multiple embodiments.
[0144] The above description is merely a preferred embodiment of this application and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of this application is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described application concept. For example, technical solutions formed by substituting the above-described features with (but not limited to) technical features with similar functions claimed in this application.
Claims
1. A method for centering a face, characterized in that, include: Obtain the parameters of the target image; wherein the parameters of the target image include the height and width of the target image; Based on the parameters of the target image, the parameters of the default centered display rectangle are determined; the parameters of the default centered display rectangle are used to perform default centered cropping when there is no face in the target image; Face recognition is performed on the human figure in the target image to obtain a face rectangle array; wherein, the face rectangle array is composed of the upper left corner ordinate, the upper left corner abscissa, the face frame width, and the face frame height; Based on the array of face rectangles, determine the coordinates of the face center point; The location of the face center point in the target image is determined by comparing the coordinates of the face center point with the coordinates of the center point of the target image. Based on the location of the face center point coordinates in the target image, the face rectangle parameters are calculated using the face center point coordinates, the parameters of the target image, and the default center-display rectangle parameters. Fill the predetermined display area according to the aspect ratio of the target image; The rectangle ratio is determined based on the face rectangle parameters and the target image parameters; The image is moved to a predetermined display area according to the rectangle ratio to center the face; the predetermined display area is selected by the user.
2. The face-centered display method according to claim 1, characterized in that, The step of determining the parameters of the default centered display rectangle based on the parameters of the target image includes: Take the minimum value between the height and width of the target image as the target side length; The parameters for the default centered display rectangle are determined based on the height, width, and side length of the target image.
3. The face-centered display method according to claim 1, characterized in that, If the number of elements in the face rectangle array is greater than 0, determining the coordinates of the face center point based on the face rectangle array includes: Summing the top-left corner ordinate of the face bounding box and half the width of the face bounding box, and dividing by the number of elements in the face rectangle array, yields the ordinate of the face center point. Summing the x-coordinate of the top-left corner of the face bounding box and half the height of the face bounding box, and dividing by the number of elements in the face rectangle array, yields the x-coordinate of the face center point.
4. The face-centered display method according to claim 1, characterized in that, The top-left corner ordinate, top-left corner abscissa, face frame width, and face frame height are all positive integers, separated by commas.
5. A face-centered display device, characterized in that, include: An acquisition unit is used to acquire parameters of a target image; wherein the parameters of the target image include the height and width of the target image; The first determining unit is used to determine the default centering display rectangle parameters based on the parameters of the target image; the default centering display rectangle parameters are used to perform default centering cropping when there is no face in the target image; A face recognition unit is used to perform face recognition on the human image in the target image to obtain a face rectangle array; wherein, the face rectangle array is composed of the upper left corner ordinate, the upper left corner abscissa, the face frame width, and the face frame height; the upper left corner ordinate, the upper left corner abscissa, the face frame width, and the face frame height are all positive integers and are separated by commas; The second determining unit is used to determine the coordinates of the center point of the face based on the face rectangle array; The third determining unit is used to compare the center point coordinates of the face with the center point coordinates of the target image to determine the location of the face center point coordinates in the target image; and to calculate the face rectangle parameters based on the location of the face center point coordinates in the target image, using the face center point coordinates, the parameters of the target image, and the parameters of the default centered display rectangle. The centering display unit is used to fill a predetermined display area according to the aspect ratio of the target image; determine the rectangle ratio based on the face rectangle parameters and the parameters of the target image; move the image to the predetermined display area according to the rectangle ratio to complete the centering display of the face; the predetermined display area is selected by the user.
6. The face centering display device according to claim 5, characterized in that, The first determining unit includes: The side length determination unit is used to take the minimum value between the height and width of the target image as the target side length; The first determining subunit is used to determine the parameters of the default centered display rectangle based on the height and width of the target image and the side length of the target.
7. An electronic device, characterized in that, include: One or more processors; A storage device on which one or more programs are stored; When the one or more programs are executed by the one or more processors, the one or more processors implement the face centering display method as described in any one of claims 1 to 4.
8. A computer storage medium, characterized in that, It stores a computer program, wherein the computer program, when executed by a processor, implements the face centering display method as described in any one of claims 1 to 4.
Citation Information
Patent Citations
Video call processing method and system
CN114845077A