Image splicing method and device, computer equipment, storage medium and program product
By automatically positioning and adjusting the target face area, the problem of cropping face area in image stitching is solved based on the template face area in the stitching template image, and the stitching efficiency and accuracy are improved.
Patent Information
- Application Number
- CN202411156500.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-22
- Publication Date
- 2024-11-08
AI Technical Summary
During the image stitching process, users need to frequently manually adjust the position of the target face area to ensure that it is fully presented in the stitching image, resulting in low stitching efficiency.
By obtaining the target image to be stitched, the template face area in the stitching template image is determined, and the target face area is automatically positioned and adjusted according to the positions of these template face areas to generate the target stitching image.
The target face area is automatically positioned without frequent manual operations by users, which significantly improves the efficiency of image stitching and ensures that the target face area is fully presented in the stitching image.
Smart Images

Figure CN118918020A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to an image stitching method, device, computer equipment, storage medium and program product. Background Art
[0002] With the widespread application of terminal devices, users' demand for image processing is becoming more and more extensive. In terminal devices, users usually perform image processing through image processing software. The image processing software can provide a variety of image processing functions. For example, a jigsaw function can be provided. Users can use the jigsaw function to stitch multiple target images to generate a stitched image. In some scenarios, when stitching multiple target images into a stitched image, if the multiple target images include a target person image, the target face area in the target person image will be cropped in the stitched image, which is inconsistent with the user's desire to fully present the target face area in the stitched image. In order to achieve the purpose of fully presenting the target face area in the stitched image, the prior art usually requires the user to manually adjust the position of the target person image in the canvas of the jigsaw function to adjust the position of the target face area.
[0003] However, the method in which the user manually adjusts the position of the target person image in the canvas of the puzzle function requires the user to frequently perform manual operations, resulting in low stitching efficiency. Summary of the invention
[0004] Based on this, it is necessary to provide an image stitching method, device, computer equipment, storage medium and program product that can improve the efficiency of image stitching in response to the above technical problems.
[0005] In a first aspect, the present application provides an image stitching method, comprising:
[0006] Acquire a plurality of target images to be stitched, wherein the plurality of target images include at least one target person image, and the target person image includes a target face region;
[0007] Determine a spliced template image obtained by splicing a plurality of template images, wherein the spliced template image includes at least one template face region;
[0008] Determining a template face region that matches each of the target face regions;
[0009] According to the position of the template face region matched by each target face region in the stitching template image, locate the position of each target face region in the canvas for stitching the image;
[0010] According to the position of each target face region located in the canvas, the multiple target images are spliced together to generate a target spliced image.
[0011] In a second aspect, the present application also provides an image stitching device, comprising:
[0012] An acquisition module, used for acquiring a plurality of target images to be spliced, wherein the plurality of target images include at least one target person image, and the target person image includes a target face area;
[0013] A positioning module, used to determine a spliced template image obtained by splicing multiple template images, wherein the spliced template image includes at least one template face area; determine a template face area that matches each of the target face areas respectively; and locate the position of each of the target face areas in the canvas used for splicing images according to the position of the template face area that matches each of the target face areas in the spliced template image;
[0014] The stitching module is used to stitch the multiple target images according to the position of each target face area located in the canvas to generate a target stitching image.
[0015] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0016] Acquire a plurality of target images to be stitched, wherein the plurality of target images include at least one target person image, and the target person image includes a target face region;
[0017] Determine a spliced template image obtained by splicing a plurality of template images, wherein the spliced template image includes at least one template face region;
[0018] Determining a template face region that matches each of the target face regions;
[0019] According to the position of the template face region matched by each target face region in the stitching template image, locate the position of each target face region in the canvas for stitching the image;
[0020] According to the position of each target face region located in the canvas, the multiple target images are spliced together to generate a target spliced image.
[0021] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the following steps are implemented:
[0022] Acquire a plurality of target images to be stitched, wherein the plurality of target images include at least one target person image, and the target person image includes a target face region;
[0023] Determine a spliced template image obtained by splicing a plurality of template images, wherein the spliced template image includes at least one template face region;
[0024] Determining a template face region that matches each of the target face regions;
[0025] According to the position of the template face region matched by each target face region in the stitching template image, locate the position of each target face region in the canvas for stitching the image;
[0026] According to the position of each target face region located in the canvas, the multiple target images are spliced together to generate a target spliced image.
[0027] In a fifth aspect, the present application further provides a computer program product, including a computer program, which implements the following steps when executed by a processor:
[0028] Acquire a plurality of target images to be stitched, wherein the plurality of target images include at least one target person image, and the target person image includes a target face region;
[0029] Determine a spliced template image obtained by splicing a plurality of template images, wherein the spliced template image includes at least one template face region;
[0030] Determining a template face region that matches each of the target face regions;
[0031] According to the position of the template face region matched by each target face region in the stitching template image, locate the position of each target face region in the canvas for stitching the image;
[0032] According to the position of each target face region located in the canvas, the multiple target images are spliced together to generate a target spliced image.
[0033] The above-mentioned image stitching method, device, computer equipment, storage medium and program product, since the stitching template image contains at least one template face area, that is, at least one template face area is presented in the stitching template image, determine the template face area that matches each target face area respectively, locate the position of each target face area in the canvas according to the position of the template face area matching each target face area in the stitching template image, and stitch the multiple target images according to the position of each target face area located in the canvas to generate a target stitching image. In this way, each target face area can also be presented in the generated target stitching image, and the position of each target face area in the canvas is automatically located without the need for frequent manual operations by the user, and the stitching efficiency is high. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0035] FIG1 is a schematic diagram of a flow chart of an image stitching method in one embodiment;
[0036] FIG2 is a schematic diagram of a flow chart of image stitching steps in one embodiment;
[0037] FIG3 is a schematic diagram of an interface showing a template selection area in one embodiment;
[0038] FIG4 (a) is a schematic diagram showing an example of image stitching effect comparison in one embodiment;
[0039] FIG4( b ) is another exemplary schematic diagram of image stitching effect comparison in one embodiment;
[0040] FIG4( c ) is another exemplary schematic diagram of image stitching effect comparison in one embodiment;
[0041] FIG5 is a structural block diagram of an image stitching device in one embodiment;
[0042] FIG. 6 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0043] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0044] In one embodiment, as shown in FIG1 , an image stitching method is provided. This embodiment is illustrated by applying the method to a computer device. The computer device may be a terminal or a server. It is understandable that the method may also be applied to a system including a terminal and a server, and implemented through the interaction between the terminal and the server. The terminal may be a personal computer, a laptop, a smart phone, a tablet computer or other. The server may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services. In this embodiment, the method includes the following steps:
[0045] Step 102 , obtaining a plurality of target images to be spliced, wherein the plurality of target images include at least one target person image, and the target person image includes a target face region.
[0046] Among them, the target image is the image to be spliced. The multiple target images are at least two target images. The target person image refers to the target image containing the person area. The person area can be a face area, or it can be the entire person area with a face area. The target face area refers to the area formed by the face in the target person image. At least one target person image is one or more target person images. The multiple target images can all be target person images, that is, each target image is a target person image. The multiple target images can also include at least one target person image and at least one non-person image. The non-person image refers to an image that does not contain a face area, such as a landscape image, an object image or others.
[0047] In one embodiment, the computer device may obtain a plurality of target images to be stitched in response to an image stitching trigger operation. The image stitching trigger operation is an operation of performing image stitching after being triggered. The image stitching trigger operation may specifically be a trigger operation of a puzzle trigger control in an image selection interface of a puzzle function in an image processing software. A puzzle trigger control is such as a "start puzzle" control. A user may select at least two target images from a pre-stored image set in the image selection interface. The pre-stored image set may be a set formed by images in an album or an image folder.
[0048] Step 104 , determining a spliced template image obtained by splicing a plurality of template images, wherein the spliced template image includes at least one template face region.
[0049] Among them, the template image is a pre-configured image used for splicing to form a spliced template image. The spliced template image is a pre-configured image used to indicate the splicing effect obtained by splicing multiple template images. The spliced template image can be obtained by splicing multiple template images according to the splicing template. The splicing template can also be called a splicing material or a splicing recipe, which can indicate the style of the canvas used for splicing images. The style of the canvas can specifically include the size of the canvas, the style of multiple canvas sub-areas in the canvas, the background part other than the multiple canvas sub-areas, and the style of the canvas sub-area such as the shape and size of the canvas sub-area.
[0050] The template face region is a region formed by a face in the spliced template image. The at least one template face region may be one or more than one template face regions. The number of the at least one template face region may be the same as the number of the target face regions included in the at least one target person image, or may be greater than the number of the target face regions included in the at least one target person image. Step 104 may be performed before step 102, may be performed after step 102, or may be performed simultaneously with step 102.
[0051] In one embodiment, the computer device may display a plurality of preconfigured stitching template images, and in response to a template selection operation, determine a stitching template image selected from the plurality of preconfigured stitching template images and obtained by stitching a plurality of template images.
[0052] In one embodiment, after determining the stitched template image, the computer device may obtain information pre-configured for the stitched template image for identifying at least one template face region in the stitched template image to determine at least one template face region in the stitched template image.
[0053] In one embodiment, the multiple template images spliced by the spliced template image can be changed through configuration. In this embodiment, the computer device can perform face recognition on the spliced template image after determining the spliced template image, and identify at least one template face area in the spliced template image. In this embodiment, the template face area is identified after the spliced template image is determined, and there is no need to pre-store information related to the template face area of the spliced template image. Even if the operator changes the template image in the multiple template images through configuration, there is no need to change the information related to the template face area after the change, thereby reducing operation and maintenance costs.
[0054] Step 106: Determine a template face region that matches each target face region.
[0055] In one embodiment, the computer device may randomly determine, for each target face region, a template face region that matches the target face region from at least one template face region.
[0056] In one embodiment, before step 106, the computer device may fill multiple target images into the canvas according to a default filling method. In step 106, the computer device may determine the template face area that matches each target face area respectively based on the relative position of the target face area in each target person image relative to the canvas and the distance between the relative position of each template face area relative to the stitched template image.
[0057] Step 108 , locating the position of each target face region in the canvas for stitching the image according to the position of the template face region matched by each target face region in the stitching template image.
[0058] The canvas is an area corresponding to the stitching template image and used for stitching images.
[0059] In one embodiment, the computer device may determine the canvas corresponding to the stitching template image after executing step 104, and display the determined canvas. The computer device may also display the canvas corresponding to the default stitching template image before or after executing step 102, and display the canvas corresponding to the stitching template image after executing step 104. The default stitching template image may be the first stitching template image in the preconfigured stitching template library or a specified stitching template image.
[0060] In one embodiment, a computer device may obtain the relative position of each template face area relative to the stitched template image, and determine the relative position of the template face area matching each target face area relative to the stitched template image as the relative position of the target face area relative to the canvas used for stitching the image, so as to locate the position of each target face area in the canvas.
[0061] Among them, the relative position of each template face area relative to the spliced template image represents the relative position value obtained after normalizing the absolute position of each template face area in the spliced template image. Normalizing the absolute position of each template face area in the spliced template image may be to calculate the ratio between the absolute position of each template face area in the spliced template image and the size of the spliced template image. The ratio value may be expressed as a percentage value. The size of the spliced template image may include the width and height of the spliced template image. In the case where the image reference point of the spliced template image is used as the coordinate origin, the absolute position of each template face area in the spliced template image may include the pixel coordinate values of the representative point of each template face area in the width direction and the height direction of the spliced template image. The representative point of the template face area may be the center point of the template face area, or a point related to the facial features, such as the center point of the nose in the template face area, the center point of the line between the eyes in the template face area, or others. The image reference point may be the upper left corner of the image, the center point of the image, the lower left corner of the image, or others.
[0062] The relative position of each template face area relative to the stitched template image may include the relative position value of each template face area in the width direction of the stitched template image and the relative position value in the height direction of the stitched template image. The relative position value of each template face area in the width direction of the stitched template image may be the ratio value between the pixel coordinate value of each template face area in the width direction of the stitched template image and the width of the stitched template image. The relative position value of each template face area in the height direction of the stitched template image may be the ratio value between the pixel coordinate value of each template face area in the height direction of the stitched template image and the height of the stitched template image.
[0063] The relative position of the target face area relative to the canvas used for stitching images represents the relative position value obtained after normalizing the absolute position of the target face area in the canvas. Normalizing the absolute position of the target face area in the canvas may be calculating the ratio between the absolute position of the target face area in the canvas and the size of the canvas. The size of the canvas may include the width and height of the canvas. In the case where the canvas reference point corresponding to the image reference point in the canvas is used as the coordinate origin, the absolute position of the target face area in the canvas may include the pixel coordinate values of the representative point of the target face area in the width direction and the height direction of the canvas respectively. The representative point of the target face area may be the center point of the target face area, or a point related to the facial features, such as the center point of the nose in the target face area, the center point of the line between the eyes in the target face area, or others. The canvas reference point may be the upper left corner of the canvas, the center point of the canvas, the lower right corner of the canvas, or others.
[0064] The relative position of the target face area relative to the canvas may include a relative value of the position of the target face area in the width direction of the canvas and a relative value of the position of the target face area in the height direction of the canvas. The relative value of the position of the target face area in the width direction of the canvas may be a ratio value between the pixel coordinate value of the target face area in the width direction of the canvas and the width of the canvas. The relative value of the position of the target face area in the height direction of the canvas may be a ratio value between the pixel coordinate value of the target face area in the height direction of the canvas and the height of the canvas.
[0065] In one embodiment, a computer device may obtain the absolute position of each template face area in the stitched template image, and obtain the size of the stitched template image and the size of the canvas used to stitch the image, and map the absolute position of each template face area in the stitched template image to the absolute position in the canvas corresponding to each template face area based on the size of the stitched template image and the size of the canvas, and determine the absolute position in the canvas corresponding to the template face area that matches each target face area as the absolute position of the target face area in the canvas, so as to locate the position of each target face area in the canvas.
[0066] In one embodiment, the above-mentioned step of mapping the absolute position of each template face area in the stitched template image to the absolute position in the canvas corresponding to each template face area according to the size of the stitched template image and the size of the canvas includes: the computer device can determine the relative position of each template face area with respect to the stitched template image according to the size of the stitched template image and the absolute position of each template face area in the stitched template image, and determine the absolute position in the canvas corresponding to each template face area according to the size of the canvas and the relative position of each template face area with respect to the stitched template image.
[0067] Step 110 , stitching together a plurality of target images according to the position of each target face region located in the canvas to generate a target stitched image.
[0068] In one embodiment, a computer device may splice multiple target images in a canvas according to the position of each target facial area in the canvas, so that the position of each target facial area in the canvas after splicing is the position of each target facial area in the canvas, and generate a target spliced image based on the canvas after splicing.
[0069] In one embodiment, the computer device may specify the relative size of each target face area in the canvas according to the relative size of the template face area matched by each target face area in the stitched template image, and stitch multiple target images according to the position of each target face area in the canvas and the relative size specified by each target face area in the canvas to generate a target stitched image. The relative size of the template face area in the stitched template image represents the ratio between the preset type size of the template face area and the preset type size of the stitched template image. The ratio value may be a percentage value. The preset type size of the target face area in the canvas represents the ratio between the preset type size of the target face area and the preset type size of the canvas. The preset type size may be a width, a height, or an area value.
[0070] In one embodiment, the computer device may splice multiple target images according to the face orientation of the template face area matched by each target face area in the spliced template image, specify the face orientation of each target face area in the canvas, and generate a target spliced image according to the position of each target face area in the canvas and the face orientation of each target face area in the canvas. The face orientation of the template face area in the spliced template image is whether the template face area is horizontal or vertical in the spliced template image, and the face orientation of the target face area in the canvas is consistent with the face orientation of the matched template face area in the spliced template image.
[0071] In the above-mentioned image stitching method, since the stitching template image contains at least one template face area, that is, at least one template face area is presented in the stitching template image, the template face areas that match each target face area are determined, and the position of each target face area in the canvas is located according to the position of the template face area that matches each target face area in the stitching template image. According to the position of each target face area located in the canvas, multiple target images are stitched to generate a target stitching image. In this way, each target face area can also be presented in the generated target stitching image, and the position of each target face area in the canvas is automatically located without the need for frequent manual operations by the user, and the stitching efficiency is high.
[0072] In an exemplary embodiment, the canvas includes multiple canvas sub-regions corresponding to multiple template images one by one; the above-mentioned image stitching method also includes the following steps: filling multiple target images into respectively matched canvas sub-regions, wherein the canvas sub-region matched by each target person image is the canvas sub-region corresponding to the template image where the template face region matching the included target face region is located; the above-mentioned step 110 also includes the following steps: adjusting each target person image relative to the filled canvas sub-region according to the position of each target face region in the canvas; and stitching the multiple canvas sub-regions after adjusting the target person images to generate a target stitched image.
[0073] The multiple canvas sub-areas corresponding to the multiple template images refer to the multiple canvas sub-areas corresponding to the layout information of the multiple template images in the spliced template image. The layout information may include the relative position of the area used to display each template image in the spliced template image relative to the spliced template image, the shape of each area, and the size of each area. It can be understood that the image filled in the canvas sub-area can be adjusted, such as changing the image, moving the image, scaling the image, rotating the image, or other adjustments.
[0074] In this embodiment, multiple target images are filled into their respective matching canvas sub-areas, creating conditions for stitching multiple target images; the canvas sub-area matched by each target person image is the canvas sub-area corresponding to the template image where the template face area matching the contained target face area is located, and according to the position of each target face area in the canvas, each target person image is adjusted relative to the filled canvas sub-area, so that the target face area can be automatically adjusted to a position where it can be displayed normally, thereby, in the target stitched image generated by stitching together multiple canvas sub-areas after adjusting the target person images, each target face area can be presented normally.
[0075] In one embodiment, the computer device may fill multiple target images into multiple canvas sub-areas according to a default filling method, and execute step 106. When there is no target face area that is not filled into the matched canvas sub-area, each target person image is adjusted relative to the filled canvas sub-area according to the position of each target face area in the canvas; based on the multiple canvas sub-areas after the target person images are adjusted, a target stitched image is generated by splicing.
[0076] In one embodiment, the computer device may fill multiple target images into multiple canvas sub-areas according to a default filling method, and in response to turning on the face adjustment switch, execute step 106, and when there is no target face area that is not filled into the matched canvas sub-area, adjust each target person image relative to the filled canvas sub-area according to the position of each target face area in the canvas. The face adjustment switch may be a switch control displayed in the interface where the canvas is located, and is used to switch between multiple canvas sub-areas filled in a default manner and multiple canvas sub-areas after adjusting the target person images.
[0077] In one embodiment, after adjusting each target person image relative to the filled canvas sub-area, the computer device may fill the multiple target images into the multiple canvas sub-areas according to the default filling mode in response to the closing operation of the face adjustment switch. In this embodiment, through the face adjustment switch, the user can conveniently compare the effect under the default filling mode and the effect after adjusting the target face area, and select which effect by himself through the face adjustment switch, thereby improving the flexibility of the puzzle function.
[0078] In an exemplary embodiment, the step of filling multiple target images into respective matching canvas sub-regions includes: filling multiple target images into multiple canvas sub-regions according to a default filling method; when there is a situation where the target face region is not filled into the matched canvas sub-region, adjusting at least a portion of the target images filled into the multiple canvas sub-regions so that each target person image is filled into the matched canvas sub-region.
[0079] The default filling method is to fill in a manner that matches the target image with the canvas sub-area. Specifically, multiple canvas sub-areas can be allocated to multiple target images according to the default allocation method, and the default filling method can be at least one of the three processes of aligning the center point of each target image with the center point of the allocated canvas sub-area, adapting the size of each target image to the size of the allocated canvas sub-area, and adapting the direction of each target image to the direction of the allocated canvas sub-area. Adapting the size of each target image to the size of the allocated canvas sub-area can be to reduce or enlarge each target image so that the height of each target image is the same as the height of the allocated canvas sub-area, or to make the width of each target image the same as the width of the allocated canvas sub-area.
[0080] The default allocation method may be a method of randomly allocating multiple canvas sub-areas to multiple target images, or may be a method of allocating each canvas sub-area in multiple canvas sub-areas with a preset order to a target image in the same sorting position in multiple target images with a user-selected order. The user-selected order refers to the order in which multiple target images are arranged when a user selects multiple target images.
[0081] At least a portion of the target image includes a target person image where the target face area is not filled into the matched canvas sub-area, and a target image that is filled into the canvas sub-area matched by the target person image after being filled in accordance with the default filling method. For example, after being filled in accordance with the default filling method, the target person image A, the target person image B, and the target non-person image C among the three target images can be filled into canvas sub-area A, canvas sub-area B, and canvas sub-area C, respectively, wherein the target person image A matches the canvas sub-area C. Then, since after being filled in accordance with the default filling method, the target person image A is filled into canvas sub-area A and is not filled into the matched canvas sub-area C, therefore, at least a portion of the target image includes the target person image A and also includes the target non-person image C that is filled into canvas sub-area C after being filled in accordance with the default filling method.
[0082] In this embodiment, multiple target images are first filled into multiple canvas sub-areas according to the default filling method. When there is a situation where the target face area is not filled into the matched canvas sub-area, at least a part of the target images filled into the multiple canvas sub-areas are adjusted so that each target person image is filled into the matched canvas sub-area. Combined with the subsequent step of adjusting each target person image relative to the filled canvas sub-area according to the position of each target face area in the canvas, the user can compare the effect under the default filling method and the effect after adjusting the target face area.
[0083] In one embodiment, the computer device may fill multiple target images into multiple canvas sub-areas according to a default filling method and execute step 106. When there is a situation where the target face area is not filled into the matched canvas sub-area, at least a portion of the target images filled into the multiple canvas sub-areas are adjusted so that each target person image is filled into the matched canvas sub-area.
[0084] In one embodiment, the multiple target images include at least one target person image and at least one target non-person image. In this embodiment, when there is a situation where the target face area is not filled into the matched canvas sub-area, the first canvas sub-area to which the target face area that is not filled into the matched canvas sub-area is filled under the default filling mode is determined, and the second canvas sub-area matched by the target face area that is not filled into the matched canvas sub-area is determined, and the target non-person image that is filled into the second canvas sub-area under the default filling mode is determined, and the target person image where the target face area that is not filled into the matched canvas sub-area is located is refilled into the second canvas sub-area, and the target non-person image is refilled into the first canvas sub-area.
[0085] In an exemplary embodiment, step 106 includes: for each target person image filled in accordance with the default filling method, determining the relative position of the target face area in each target person image relative to the canvas, and obtaining the first relative position of the target face area; for each template face area in the spliced template image, determining the relative position of each template face area relative to the spliced template image, and obtaining the second relative position of the template face area; and determining the template face area that matches each target face area respectively based on the distance between the first relative position and the second relative position.
[0086] The first relative position may include the relative value of the position of the target face area in the width direction of the canvas and the relative value of the position in the height direction of the canvas after filling in the default filling mode. In some scenarios, under the default filling mode, part of the target face area may be cropped and not fully displayed in the canvas. The first relative position may be a simulated value. For example, if the upper left corner of the canvas is used as the coordinate origin, the first relative position of the center point of the target face area may be (50%, -10%), indicating that the center point of the target face area is actually outside the range of the canvas, and -10% is a simulated value simulating the center point of the target face area in the plane where the canvas is located.
[0087] The second relative position may include a relative value of the position of the template face area in the width direction of the stitched template image and a relative value of the position in the height direction of the stitched template image. The distance between the first relative position and the second relative position may be a Euclidean distance or a Manhattan distance calculated with the first relative position as one coordinate point and the second relative position as another coordinate point.
[0088] In this embodiment, the first relative position of the target face area and the second relative position of the template face area are both relative positions. Therefore, the first relative position and the second relative position are under the same standard. Even if the sizes of the canvas and the spliced template image are different, the distance between the target face area and the template face area can be compared. Therefore, based on the distance between the first relative position and the second relative position, the template face area that matches each target face area can be quickly determined, thereby improving the matching efficiency.
[0089] In one embodiment, when the number of at least one target person image is at least two and the number of at least one template face area is at least two, the above-mentioned step of determining the template face area that matches each target face area respectively based on the distance between the first relative position and the second relative position includes: the computer device can determine the priority order of at least two target face areas according to a preset strategy; in accordance with the priority order, for each target face area in turn, from the template face areas that have not been matched among the at least two template face areas, determine the template face area that matches the target face area based on the distance between the first relative position of the target face area and the second relative position of the template face areas that have not been matched.
[0090] In an exemplary embodiment, when the number of at least one target person image is at least two, the number of at least one template face area is at least two; the above-mentioned step of determining the template face area that matches each target face area respectively based on the distance between the first relative position and the second relative position includes: determining the priority order of at least two target face areas according to a preset strategy; according to the priority order, for each target face area in turn, from the template face areas that have not yet been matched among the at least two template face areas, selecting the template face area with the second relative position closest to the first relative position of the target face area as the template face area that matches the target face area.
[0091] Among them, the preset strategy is a strategy related to the preset priority order. The preset strategy can be that after the default filling method is filled, the smaller the preset type size of the target face area in the canvas is, the higher the priority of the target face area. In this strategy, after the default filling method is filled, if the preset type size of the target face area in the canvas is smaller, it means that the first relative position determined for the target face area is more accurate. In this way, the priority order can be characterized by the order from high to low accuracy of the first relative position, which can ensure a high overall matching accuracy to a certain extent. The preset type size can be height, width or area occupied.
[0092] The preset strategy can be that after the default filling method is filled, the smaller the preset type size of the canvas sub-area in the canvas, the higher the priority of the target face area filled into the canvas sub-area. In this strategy, after the default filling method is filled, if the preset type size of the canvas sub-area in the canvas is smaller, it can represent to a certain extent that the target face area filled into the canvas sub-area occupies a smaller area in the canvas, and furthermore, it can be known that the first relative position determined for the target face area filled into the canvas sub-area is more accurate. In this way, the priority order can be represented in the order of the first relative position accuracy from high to low, which can ensure the overall matching accuracy to a certain extent. Moreover, the preset type size of the canvas sub-area can be pre-configured, and there is no need to perform additional calculation of the preset type size of the target face area, which can reduce the amount of calculation.
[0093] The preset strategy may be that the higher the user selection order of the target person image, the higher the priority of the target face area contained in the target person image. The user selection order refers to the arrangement order of multiple target images when the user selects multiple target images. In this strategy, the higher the user selection order, the higher the user's attention to the target person image to a certain extent, and the target face area contained in the target person image is matched first, which can meet the user's intention.
[0094] In this embodiment, according to a preset strategy, a priority order of at least two target face areas is determined, and according to the priority order, for each target face area, a matching template face area is determined from at least two template face areas that have not been matched, so that the target face area with a high priority can be matched first; moreover, a template face area having a second relative position closest to the first relative position of the target face area is selected as the template face area that matches the target face area, so that when the position of the target face area is subsequently adjusted according to the positioning of the target face area in the canvas, the moving distance of the target face area is small, which can reduce the consumption of computing resources and facilitate the user to compare the effects before and after the adjustment.
[0095] In one embodiment, the computer device may select, in order of priority, for a target face region ranked first, a template face region having a second relative position closest to the first relative position of the target face region from at least two template face regions as a template face region that matches the target face region; and for each target face region ranked second and above, select, from at least two template face regions that have not yet been matched, a template face region having a second relative position closest to the first relative position of the target face region as a template face region that matches the target face region.
[0096] In an exemplary embodiment, the above-mentioned step of determining the relative position of the target face area in each target person image with respect to the canvas for each target person image filled in accordance with the default filling method, and obtaining the first relative position of the target face area includes: determining the absolute position of the center point of the target face area in each target person image in the canvas for each target person image filled in accordance with the default filling method; mapping the absolute position of the center of the target face area in each target person image in the canvas according to the size of the canvas to the relative position of the target face area in each target person image with respect to the canvas, and obtaining the first relative position of the target face area.
[0097] In an exemplary embodiment, the above-mentioned step of determining the relative position of each template face area in the stitched template image relative to the stitched template image to obtain the second relative position of the template face area includes: performing face recognition on the stitched template image to determine the absolute position of the center point of each template face area in the stitched template image in the stitched template image; for each template face area in the stitched template image, mapping the absolute position of the center point of each template face area in the stitched template image to the relative position of each template face area relative to the stitched template image according to the size of the stitched template image, to obtain the second relative position of the template face area.
[0098] Wherein, face recognition is performed on the spliced template image, each template face region in the spliced template image can be identified, and the absolute position of the center point of each template face region in the spliced template image can be identified.
[0099] In this embodiment, face recognition is performed on the spliced template image to determine the absolute position of the center point of each template face area in the spliced template image, and then the absolute position can be mapped to a relative position according to the size of the spliced template to obtain the second relative position of the template face area. This eliminates the need to pre-store the position information of each template face area in the spliced template image. Even if the operator changes the template image in multiple template images through configuration, there is no need to change the position information of the template face area after the change, thereby reducing operation and maintenance costs.
[0100] In an exemplary embodiment, referring to the schematic flow chart of image stitching steps as shown in FIG. 2 , the above-mentioned image stitching method may specifically include the following steps.
[0101] The computer device can obtain multiple target images to be spliced (multiple original images to be puzzled) selected by the user; display a template selection area, in which multiple pre-configured splicing template images are displayed; in response to the template selection operation, determine a splicing template image selected from multiple pre-configured splicing template images and obtained by splicing multiple template images. Among them, the multiple target images include at least two target person images, and the target person images include target face areas. The interface schematic diagram showing the template selection area can be shown in Figure 3, and the splicing template image can also be called a preview image of a puzzle template or a thumbnail of a puzzle template. A puzzle template can also be called a puzzle material or a puzzle recipe.
[0102] The computer device can display a canvas corresponding to the spliced template image, and the canvas contains multiple canvas sub-areas corresponding to multiple template images one by one. The computer device can allocate multiple canvas sub-areas to multiple target images according to the default allocation method, and fill the multiple target images into the respective allocated canvas sub-areas according to the default filling method (generating the initial effect). Among them, the default filling method can be a method of aligning the center point of each target image with the center point of the allocated canvas sub-area, adapting the size of each target image to the size of the allocated canvas sub-area, and adapting the direction of each target image to the direction of the allocated canvas sub-area. Among them, the position of the target face area in the target person image is not necessarily related to the center point of the target person image, resulting in the target face area being cropped and unable to be presented normally and completely after filling according to the default filling method. The existing technology requires the user to manually operate the target person image in the canvas, which is cumbersome and has low image splicing efficiency.
[0103] The computer device can perform face recognition on the spliced template image, identify at least two template face areas in the spliced template image, and determine, for each template face area, the relative position of the center point of each template face area relative to the spliced template image, and the relative size of each template face area relative to the spliced template image, to obtain a second relative position and a second relative size of the template face area.
[0104] The computer device can perform face recognition for each target person image, determine the relative position of the center point in the target face area in the target person image relative to the target person image, and obtain the third relative position of the target face area. The third relative position may include the relative position value of the target face area in the width direction of the target person image and the relative position value in the height direction of the target person image. The relative position value of the target face area in the width direction of the target person image may be the ratio value between the pixel coordinate value of the center point in the target face area in the width direction of the target person image and the width of the target person image. The relative position value of the target face area in the height direction of the target person image may be the ratio value between the pixel coordinate value of the center point in the target face area in the height direction of the target person image and the height of the target person image. The ratio value may be a percentage value.
[0105] The computer device may determine, for each target person image filled in accordance with the default filling method, the relative position of the center point of the target face area in each target person image relative to the canvas according to the third relative position of the target face area, and obtain the first relative position of the target face area. The third relative position of the target face area may be a relative position with the center point of the target person image as the origin of the coordinates. Since the center point of the target person image is aligned with the center point of the canvas sub-area in the default filling method, the relative position of the center point of the target face area relative to the canvas may be inferred.
[0106] The order of the areas currently filled into the canvas sub-areas of at least two target face areas is determined as the priority order of the at least two target face areas (sorted by the displayable area from small to large); according to the priority order, for each target face area in turn, from the at least two template face areas that have not been matched, select the template face area with the second relative position closest to the first relative position of the target face area as the template face area that matches the target face area (the face with the shortest distance is selected as the original image of the current user).
[0107] When there is a situation where the target face area is not filled into the matched canvas sub-area, the computer device may adjust at least a portion of the target images filled into the multiple canvas sub-areas so that each target person image is filled into the matched canvas sub-area.
[0108] When there is no situation where the target face area is not filled into the matched canvas sub-area, the computer device can locate the position of each target face area in the canvas used for stitching the image according to the position of the template face area matched by each target face area in the stitching template image; specifically, the computer device uses the second relative position of the template face area matched by each target face area in the stitching template image as the position of each target face area in the canvas.
[0109] The computer device can specify the relative size of the template face area matched by each target face area in the spliced template image as the relative size of each target face area in the canvas; and specify the face orientation of the template face area matched by each target face area in the spliced template image as the face orientation of each target face area in the canvas.
[0110] The computer device can adjust each target person image relative to the filled canvas sub-area according to the position of each target face area in the canvas, the relative size of each target face area in the canvas, and the face orientation of each target face area in the canvas (the effect after adjustment); based on the multiple canvas sub-areas after the target person images are adjusted, the target spliced image is generated. Wherein, when adjusting each target person image relative to the filled canvas sub-area, the target person image can be moved relative to the filled canvas sub-area so that the center point of the target face area in the target person image reaches the position where the target face area is located in the canvas; the target person image can be reduced or enlarged relative to the filled canvas sub-area so that the target face area in the target person image reaches the specified relative size relative to the canvas.
[0111] See FIG4 (a) for an example schematic diagram of image stitching effect comparison. FIG4 (a) includes a stitching image on the left, a stitching image in the middle, and a stitching image on the right, a total of three stitching images. Among them, the stitching image on the left of FIG4 (a) is an example of a stitching template image; the stitching image in the middle of FIG4 (a) is an example of filling two target images into two canvas sub-areas of the canvas corresponding to the stitching template image according to the default filling method. It can be seen that in the stitching image in the middle of FIG4 (a), there is a situation where the face is cropped and not presented normally and completely, and there is also a situation where the face is too small and the display effect is not good; the stitching image on the right of FIG4 (a) is an example of the target stitching image obtained after adjustment. It can be seen that the target stitching image obtained after adjustment can normally present the face.
[0112] Another example schematic diagram of the image stitching effect comparison is shown in FIG4 (b), which includes a stitching image on the left, a stitching image in the middle, and a stitching image on the right, a total of three stitching images. Among them, the stitching image on the left side of FIG4 (b) is another example of a stitching template image; the stitching image in the middle of FIG4 (b) is an example of filling two target images into two canvas sub-areas of the canvas corresponding to the stitching template image according to the default filling method; the stitching image on the right side of FIG4 (b) is an example of the target stitching image obtained after adjustment.
[0113] As shown in FIG4 (c), there is another example schematic diagram of the image stitching effect comparison. FIG4 (c) includes a stitching image on the left, a stitching image in the middle, and a stitching image on the right, a total of three stitching images. Among them, the stitching image on the left side of FIG4 (c) is an example of another stitching template image; the stitching image in the middle of FIG4 (c) is an example of filling six target images into six canvas sub-areas of the canvas corresponding to the stitching template image according to the default filling method; the stitching image on the right side of FIG4 (c) is an example of the target stitching image obtained after adjustment.
[0114] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0115] Based on the same inventive concept, the embodiment of the present application also provides an image stitching device for implementing the above-mentioned image stitching method. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above-mentioned method, so the specific limitations in one or more image stitching device embodiments provided below can refer to the limitations on the image stitching method above, and will not be repeated here.
[0116] In an exemplary embodiment, as shown in FIG5 , an image stitching device 500 is provided, comprising: an acquisition module 510 , a positioning module 520 and a stitching module 530 , wherein:
[0117] The acquisition module 510 is used to acquire a plurality of target images to be spliced, wherein the plurality of target images include at least one target person image, and the target person image includes a target face region.
[0118] The positioning module 520 is used to determine a stitched template image obtained by stitching multiple template images, where the stitched template image includes at least one template face area; determine the template face areas that match each target face area respectively; and locate the position of each target face area in the canvas used for stitching the image according to the position of the template face area that matches each target face area in the stitched template image.
[0119] The stitching module 530 is used to stitch multiple target images according to the position of each target face area in the canvas to generate a target stitched image.
[0120] In one embodiment, the canvas includes multiple canvas sub-areas corresponding to multiple template images one by one, and the stitching module 530 is further used to fill multiple target images into respectively matched canvas sub-areas, wherein the canvas sub-area matched by each target person image is the canvas sub-area corresponding to the template image where the template face area matching the included target face area is located; according to the position of each target face area in the canvas, each target person image is adjusted relative to the filled canvas sub-area; based on the multiple canvas sub-areas after the target person images are adjusted, a target stitched image is generated by stitching.
[0121] In one embodiment, the stitching module 530 is also used to fill multiple target images into multiple canvas sub-areas according to a default filling method; when there is a situation where the target face area is not filled into the matched canvas sub-area, adjust at least a part of the target images filled into the multiple canvas sub-areas so that each target person image is filled into the matched canvas sub-area.
[0122] In one embodiment, the positioning module 520 is also used to determine, for each target person image filled in a default filling manner, the relative position of the target face area in each target person image relative to the canvas, and obtain the first relative position of the target face area; for each template face area in the spliced template image, determine the relative position of each template face area relative to the spliced template image, and obtain the second relative position of the template face area; and determine the template face area that matches each target face area respectively based on the distance between the first relative position and the second relative position.
[0123] In one embodiment, when the number of at least one target person image is at least two, the number of at least one template face area is at least two; the positioning module 520 is also used to determine the priority order of at least two target face areas according to a preset strategy; according to the priority order, for each target face area in turn, from the template face areas that have not yet been matched among the at least two template face areas, select the template face area with the second relative position closest to the first relative position of the target face area as the template face area that matches the target face area.
[0124] In one embodiment, the positioning module 520 is also used to perform face recognition on the stitched template image to determine the absolute position of the center point of each template face area in the stitched template image; for each template face area in the stitched template image, based on the size of the stitched template image, the absolute position of the center point of each template face area in the stitched template image is mapped to the relative position of each template face area relative to the stitched template image to obtain the second relative position of the template face area.
[0125] Each module in the above-mentioned image stitching device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute the operations corresponding to each module.
[0126] In an exemplary embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be shown in FIG6. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit, and an input device. The processor, the memory, and the input / output interface are connected via a system bus, and the communication interface, the display unit, and the input device are connected to the system bus via the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner may be implemented through WIFI, a mobile cellular network, near field communication (NFC) or other technologies. When the computer program is executed by the processor, an image stitching method is implemented. The display unit of the computer device is used to form a visually visible picture, which may be a display screen, a projection device, or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device shell, or an external keyboard, touchpad or mouse.
[0127] Those skilled in the art will understand that the structure shown in FIG. 6 is merely a block diagram of a partial structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.
[0128] In one embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above method embodiments when executing the computer program.
[0129] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.
[0130] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.
[0131] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.
[0132] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.
[0133] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0134] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. An image stitching method, characterized in that: The method comprises: Acquire a plurality of target images to be stitched, wherein the plurality of target images include at least one target person image, and the target person image includes a target face region; Determine a spliced template image obtained by splicing a plurality of template images, wherein the spliced template image includes at least one template face region; Determining a template face region that matches each of the target face regions; According to the position of the template face region matched by each target face region in the stitching template image, locate the position of each target face region in the canvas for stitching the image; According to the position of each target face region located in the canvas, the multiple target images are spliced together to generate a target spliced image.
2. The method according to claim 1, characterized in that: The canvas includes a plurality of canvas sub-areas corresponding to the plurality of template images one by one; the method further includes: Filling the multiple target images into the respective matched canvas sub-areas, wherein the canvas sub-area matched by each target person image is the canvas sub-area corresponding to the template image where the template face area matching the contained target face area is located; The step of stitching the multiple target images according to the position of each target face region in the canvas to generate a target stitched image includes: According to the position of each target face region located in the canvas, adjusting each target person image relative to the filled canvas sub-region; Based on the multiple canvas sub-regions after adjusting the target person image, a target stitched image is generated by stitching.
3. The method according to claim 2, characterized in that Filling the multiple target images into respective matching canvas sub-areas includes: Filling the plurality of target images into the plurality of canvas sub-areas in a default filling manner; When there is a situation where the target face area is not filled into the matched canvas sub-area, at least a portion of the target images filled into the multiple canvas sub-areas are adjusted so that each of the target person images is filled into the matched canvas sub-area.
4. The method according to claim 3, characterized in that The determining of the template face region that matches each of the target face regions comprises: For each target person image filled in a default filling manner, determine the relative position of the target face region in each target person image relative to the canvas, and obtain a first relative position of the target face region; For each template face region in the spliced template image, determine the relative position of each template face region relative to the spliced template image to obtain a second relative position of the template face region; A template face region that matches each of the target face regions is determined according to the distance between the first relative position and the second relative position.
5. The method according to claim 4, characterized in that When the number of the at least one target person image is at least two, and the number of the at least one template face region is at least two; determining the template face region that matches each of the target face regions according to the distance between the first relative position and the second relative position, comprises: Determining the priority order of at least two target face regions according to a preset strategy; According to the priority order, for each target face area in turn, from at least two of the template face areas that have not yet been matched, select a template face area with a second relative position closest to the first relative position of the target face area as the template face area that matches the target face area.
6. The method according to claim 4, characterized in that The step of determining, for each template face region in the spliced template image, a relative position of each template face region relative to the spliced template image to obtain a second relative position of the template face region includes: Performing face recognition on the spliced template image to determine the absolute position of the center point of each template face region in the spliced template image in the spliced template image; For each template face area in the stitched template image, according to the size of the stitched template image, the absolute position of the center point of each template face area in the stitched template image is mapped to the relative position of each template face area relative to the stitched template image, so as to obtain the second relative position of the template face area.
7. An image stitching device, characterized in that: The device comprises: An acquisition module, used for acquiring a plurality of target images to be spliced, wherein the plurality of target images include at least one target person image, and the target person image includes a target face area; A positioning module, used to determine a spliced template image obtained by splicing multiple template images, wherein the spliced template image includes at least one template face area; determine a template face area that matches each of the target face areas respectively; and locate the position of each of the target face areas in the canvas used for splicing images according to the position of the template face area that matches each of the target face areas in the spliced template image; The stitching module is used to stitch the multiple target images according to the position of each target face area located in the canvas to generate a target stitching image.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
