CN114549694B - Certificate photo reloading method and system - Google Patents

Certificate photo reloading method and system Download PDF

Info

Publication number
CN114549694B
CN114549694B CN202111649284.3A CN202111649284A CN114549694B CN 114549694 B CN114549694 B CN 114549694B CN 202111649284 A CN202111649284 A CN 202111649284A CN 114549694 B CN114549694 B CN 114549694B
Authority
CN
China
Prior art keywords
image
replaced
clothing
points
neck
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202111649284.3A
Other languages
Chinese (zh)
Other versions
CN114549694A (en
Inventor
郭志强
魏延文
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Century Kaiyuan Zhiyin Internet Technology Group Co ltd
Original Assignee
Century Kaiyuan Zhiyin Internet Technology Group Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Century Kaiyuan Zhiyin Internet Technology Group Co ltd filed Critical Century Kaiyuan Zhiyin Internet Technology Group Co ltd
Priority to CN202111649284.3A priority Critical patent/CN114549694B/en
Publication of CN114549694A publication Critical patent/CN114549694A/en
Application granted granted Critical
Publication of CN114549694B publication Critical patent/CN114549694B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • G06T11/60Editing figures and text; Combining figures or text
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformations in the plane of the image
    • G06T3/04Context-preserving transformations, e.g. by using an importance map
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformations in the plane of the image
    • G06T3/40Scaling of whole images or parts thereof, e.g. expanding or contracting

Landscapes

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

Abstract

The invention provides a method and a system for changing and loading certificate photos, which belong to the field of changing and loading certificate photos, and can both: extracting a neck region of a portrait in a certificate photo image to be reloaded; performing key point detection on the extracted neck region to obtain two neck key points; selecting a garment to be replaced to obtain a garment image to be replaced and two collarband coordinate points; calculating a scaling factor of the clothing image to be replaced based on the neck key points and the collarband coordinate points; scaling the clothing image to be changed based on the scaling coefficient to obtain a target clothing image; calculating the position coordinates of the target clothing image in the coordinate system of the to-be-replaced photo image; and fusing the target clothing image with the certificate photo image to be reloaded according to the position coordinates to obtain the reloaded certificate photo image. The invention is used for realizing the intelligent replacement of the credentials, so that the credentials can be replaced without the help of image processing software or professional image processing knowledge.

Description

Certificate photo reloading method and system
Technical Field
The invention relates to the field of certificate photo reloading, in particular to a method and a system for certificate photo reloading.
Background
Credentials are photographs used on various credentials to indicate identity, and in addition to the basic facial features, credentials for different uses have different requirements on clothing.
Such as: standard credentials require that collar dark-colored clothing be worn, standard clothing not be worn, and braces-type clothing not be worn; common passports often require white clothing and use a light blue background color, with other colors being preferred for white background; the requirements for dressing are also different for different work sites on the job site.
However, temporarily taking a certificate photograph meeting the dressing requirement often results in repeated photographing and increased running times, and the process is complicated.
In order to meet the requirements of the credentials and the clothing in different scenes, the method realizes 'one-time acquisition and multiple-time multiplexing' and avoids repeated photographing, and the traditional method is to use image processing software (such as Photoshop) to perform professional operation on the credentials and the clothing replacement of the credentials. The method can be completed by professional staff, has higher requirements on professional technology, and can not realize certificate exchange by non-professional ordinary staff.
Disclosure of Invention
Aiming at the problems in the prior art, the invention provides a method and a system for changing the credentials, which are used for realizing the intelligent operation of changing the credentials, so that a user can realize changing the credentials without resorting to image processing software or professional image processing knowledge, thereby meeting the requirements of different occasions on the credentials, requiring no repeated photographing and multiplexing photographing for a plurality of times.
In a first aspect, the present invention provides a method for changing a certificate, comprising the steps of:
extracting a neck region of a portrait in a certificate photo image to be reloaded;
the extracted neck region is subjected to key point detection to obtain two key points of the neck region of the portrait in the certificate photo image to be reloaded, wherein the two key points are recorded as two neck key points, and the two neck key points are two connection points used for connecting the face region in the certificate photo image to be reloaded on the contour lines of the two side edges of the neck region of the portrait in the certificate photo image to be reloaded;
selecting a garment to be replaced, and obtaining a garment image to be replaced and two collarband coordinate points of the garment image to be replaced, wherein the garment image to be replaced is an image containing a transparent channel;
calculating the scaling factor of the clothing image to be replaced based on the two neck key points and the two collarband coordinate points;
scaling the clothing image to be changed based on the scaling coefficient to obtain a target clothing image;
calculating position coordinates of the target clothing image in the coordinate system of the to-be-replaced certificate photo image, corresponding to clothing in the to-be-replaced certificate photo image, in replacement;
and fusing the target clothing image with the certificate photo image to be reloaded according to the position coordinates to obtain the reloaded certificate photo image.
Further, the implementation method for detecting the key points of the neck region to obtain two neck key points comprises the following steps:
extracting the contour of the neck region to obtain the contour of the neck region;
obtaining an approximate contour of the neck region, wherein the number of vertexes on the approximate contour is less than that of vertexes on the contour of the neck region;
and extracting two points with minimum ordinate values from the approximate contour to serve as the two neck key points.
Further, the calculating the scaling factor of the clothing image to be replaced based on the two neck key points and the two collarband coordinate points comprises the following specific implementation steps:
calculating the linear distance between two neck key points, and recording as d1;
calculating the linear distance between two collarband coordinate points, and marking as d2;
and d1/d2 is calculated to obtain the zoom coefficient of the clothing image to be replaced.
Further, the calculating target clothing image replaces the position coordinates, corresponding to the clothing in the to-be-replaced certificate photograph image, in the coordinate system of the to-be-replaced certificate photograph image, and the specific implementation method is as follows:
converting two collarband coordinate points of the clothing image to be exchanged into two collarband coordinate points of the target clothing image, wherein under the condition that the target clothing image replaces the clothing in the clothing certificate image to be exchanged: the position coordinates corresponding to the two collarband coordinate points of the target clothing image in the coordinate system of the to-be-reloaded certificate photograph image are the position coordinates of the two neck key points in the to-be-reloaded certificate photograph image, the position coordinates corresponding to other pixel points on the target clothing image in the coordinate system of the to-be-reloaded certificate photograph image are obtained by sequentially calculating the coordinate positions of the two neck key points in the to-be-reloaded certificate photograph image according to the relative position relation between the other pixel points on the target clothing image and the two collarband coordinate points of the target clothing image.
Further, the certificate photo reloading method further comprises the following steps: judging whether the position coordinates of the target clothing image in the coordinate system of the to-be-replaced certificate photo image, corresponding to the clothing in the to-be-replaced certificate photo image, exceed the coordinate range of the to-be-replaced certificate photo image, and if so, overflowing the boundary of the target clothing image.
In a second aspect, the present invention also provides a credential changing system, comprising:
the neck region extraction unit is used for extracting the neck region of the portrait in the certificate photo image to be reloaded;
the neck key point extraction unit is used for detecting the key points of the extracted neck region to obtain two key points of the neck region of the portrait in the certificate photo image to be replaced, and marking the two key points as two neck key points, wherein the two neck key points are two connection points used for connecting the face region in the certificate photo image to be replaced on the edge contour lines of the two sides of the neck region of the portrait in the certificate photo image to be replaced;
the clothing model selection unit is used for selecting clothing to be replaced to obtain clothing images to be replaced and two collarband coordinate points of the clothing images to be replaced, wherein the clothing images to be replaced are images containing transparent channels;
the scaling factor calculating unit is used for calculating the scaling factor of the clothing image to be replaced based on the two neck key points and the two collarband coordinate points;
the target image acquisition unit is used for scaling the clothing image to be replaced based on the scaling coefficient to obtain a target clothing image;
the coordinate calculation unit is used for calculating the position coordinates of the target clothing image in the coordinate system of the to-be-replaced certificate photograph image, which correspond to the clothing in the to-be-replaced certificate photograph image;
and the reloading unit is used for fusing the target clothing image with the document image to be reloaded according to the position coordinates to obtain the reloaded document image.
Further, the neck key point extraction unit includes:
the contour extraction module is used for extracting the contour of the neck region to obtain the contour of the neck region;
the contour approximation module is used for acquiring an approximate contour of the neck region, and the number of vertexes on the approximate contour is smaller than that of vertexes on the contour of the neck region;
and the key point extraction module is used for extracting two points with minimum ordinate values from the approximate contour to serve as the two neck key points.
Further, the scaling factor calculation unit includes:
the first calculation module is used for calculating the linear distance between the two neck key points and marking the linear distance as d1;
the second calculation module is used for calculating the linear distance between the two collarband coordinate points and marking as d2;
and the third calculation module is used for calculating d1/d2 to obtain the scaling factor of the clothing image to be replaced.
Further, the coordinate calculation unit is configured to perform the steps of:
converting two collarband coordinate points of the clothing image to be exchanged into two collarband coordinate points of the target clothing image, wherein under the condition that the target clothing image replaces the clothing in the clothing certificate image to be exchanged: the position coordinates corresponding to the two collarband coordinate points of the target clothing image in the coordinate system of the to-be-reloaded certificate photograph image are the position coordinates of the two neck key points in the to-be-reloaded certificate photograph image, the position coordinates corresponding to other pixel points on the target clothing image in the coordinate system of the to-be-reloaded certificate photograph image are obtained by sequentially calculating the coordinate positions of the two neck key points in the to-be-reloaded certificate photograph image according to the relative position relation between the other pixel points on the target clothing image and the two collarband coordinate points of the target clothing image.
Further, the credential changing system also includes an overflow handling unit;
the overflow processing unit is used for judging whether the position coordinates of the target clothing image calculated by the coordinate calculation unit in the coordinate system of the to-be-replaced certificate photograph image, which correspond to the clothing in the to-be-replaced certificate photograph image, are beyond the coordinate range of the to-be-replaced certificate photograph image, and if so, performing overflow processing on the boundary of the target clothing image.
The invention has the beneficial effects that:
when the method and the system for changing the credentials are used, a user does not need to use image processing software or have professional image processing knowledge, and can realize automatic changing of the credentials to be changed by only inputting the credentials to be changed and selecting the clothing to be changed (namely, the clothing to be changed image), so that the requirements of different occasions on the credentials are met, repeated photographing, one-time photographing and multiple-time multiplexing are not needed, and the method and the system are more practical.
In addition, the invention has reliable design principle, simple structure and very wide application prospect.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings that are required to be used in the description of the embodiments or the prior art will be briefly described below, and it will be obvious to those skilled in the art that other drawings can be obtained from these drawings without inventive effort.
FIG. 1 is a schematic flow chart of a method of one embodiment of the invention.
Fig. 2 is a schematic structural view of an image of a garment to be exchanged according to the present invention.
Fig. 3 is another schematic structural view of the image of the garment to be exchanged according to the present invention.
Fig. 4 is another schematic structural view of the image of the garment to be exchanged according to the present invention.
Fig. 5 is another schematic view of the construction of the image of the garment to be exchanged according to the invention.
Fig. 6 is a schematic view of a position of the neck key point in the present invention.
Fig. 7 is a schematic block diagram of a system according to an embodiment of the present invention.
Fig. 8 is a schematic block diagram of a system according to another embodiment of the present invention.
Detailed Description
In order to make the technical solution of the present invention better understood by those skilled in the art, the technical solution of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are only some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the present invention without making any inventive effort, shall fall within the scope of the present invention.
FIG. 1 is a schematic flow chart diagram of a credential photo replacement method in accordance with one embodiment of the invention.
As shown in fig. 1, the credential photo replacement method 100 includes:
step 110, extracting a neck region of a portrait in the photo image to be reloaded.
In particular, a person skilled in the art can use the prior art to extract the neck region of the portrait in the image of the document to be reloaded.
Specifically, in this embodiment, the implementation steps of step 110 are:
step 1101, performing face analysis on the certificate photo image to be reloaded.
Face parsing is to perform semantic understanding on an image at a pixel level, and assign a pixel-level label to each semantic component of a face. In this embodiment, the semantic components include background, skin, left eyebrow, right eyebrow, left eye, right eye, glasses, left ear, right ear, earrings, nose, mouth, upper lip, lower lip, neck, necklace, clothing, hair, and hat.
Specifically, when the face analysis is performed on the to-be-replaced certificate photo image, the to-be-replaced certificate photo image is input into a face analysis network model (such as a unet model) based on deep learning to be analyzed, so that a semantic understanding image of the to-be-replaced certificate photo image is obtained, and the semantic understanding image refers to 19 semantic areas (namely numerical marks) of total 19 semantic areas, such as a background, skin, left eyebrow, right eyebrow, left eye, right eye, glasses, left ear, right ear, earring, nose, mouth, upper lip, lower lip, neck, necklace, clothes, hair, cap and the like, of the to-be-replaced certificate photo image by using 0-18 total 19 different integers.
Step 1102, extracting all parsed neck semantic areas according to the numerical marks of the neck semantic areas by face parsing, respectively corroding the extracted neck semantic areas by using a morphological algorithm, removing the influence of other semantic areas on the neck semantic areas, and obtaining a plurality of binarized neck semantic area images.
Step 1103, performing edge detection on each obtained binarized neck semantic region image, extracting the outline of the neck semantic region, then calculating the area corresponding to the neck semantic region according to the extracted outline, and then sorting the calculated areas to select the neck semantic region corresponding to the outline with the largest area value, wherein the neck semantic region is the neck region of the portrait in the certificate photo image to be reloaded finally extracted in step 110. This step helps to remove the small, non-neck, area of the island, which in turn helps to ensure that the subsequent reloading step proceeds smoothly.
And 120, performing key point detection on the extracted neck region to obtain two key points of the neck region of the portrait in the document photo image to be reloaded, and marking the two key points as two neck key points.
The two neck key points are two connection points used for connecting the face area in the certificate photo image to be replaced on the contour lines of the two side edges of the neck area of the portrait in the certificate photo image to be replaced, as shown in fig. 6.
Specifically, in fig. 6: the area denoted by reference numeral 300 represents a face in a certain to-be-reloaded photo image (i.e., a face area, the face of which facing vertically to the user is the face front), and the area denoted by reference numeral 400 represents a neck area in a corresponding to the to-be-reloaded photo image, and the two points denoted by reference numerals 500 and 600 are two neck key points of the certain to-be-reloaded photo image. In fact, as shown in fig. 6, the two neck key points in fig. 6 are actually the two top-most points on the contour lines of the two side edges of the neck region in the image of the document to be reloaded.
It should be noted that, in the present specification, each image of the certificate to be reloaded is a two-dimensional image.
As an exemplary embodiment of the invention, the specific implementation method for detecting the key points of the neck region to obtain two neck key points is as follows:
extracting the contour of the neck region to obtain the contour of the neck region;
obtaining an approximate contour of the neck region, wherein the number of vertexes on the approximate contour is less than that of vertexes on the contour of the neck region;
and extracting two points with minimum ordinate values from the approximate contour to serve as the two neck key points.
The above-mentioned obtaining the approximate contour of the neck region contour is to approximate the shape of the neck region contour to the similar contour with less top points. In this embodiment, the specific implementation method for obtaining the approximate contour of the neck region contour is as follows:
the circumference of the neck region is calculated, and the product (empirical value) of the circumference and a given decimal is used as an accuracy value, and the shape of the neck region contour is approximated to an approximation contour having a smaller number of vertices than the number of vertices on the neck region contour.
It should be noted that, those skilled in the art may also use any other related method in the prior art to obtain an approximate contour of the neck region contour.
And 130, selecting the clothing to be replaced, and obtaining an image of the clothing to be replaced and two collarband coordinate points of the image of the clothing to be replaced.
The clothing to be replaced is clothing to be replaced by the portrait in the photo image of the certificate to be replaced.
The clothing image to be replaced is the corresponding image of the clothing to be replaced, and the image is the png format image containing the transparent channel.
The clothing image to be replaced is a pre-prepared clothing template to be replaced for the user to select, the number of the clothing templates to be replaced is large (for example, 1 thousands of clothing templates can be provided, 1 ten thousand clothing templates can be provided, and other clothing templates can be provided), the top end of each clothing template to be replaced is provided with a collar for exposing the neck of a portrait, and two points (namely, two points for forming the top opening of the collar) at the top end of the clothing template to be replaced are two collar coordinate points of the clothing image to be replaced.
And selecting the clothing to be replaced, and determining an image of the clothing to be replaced corresponding to the selected clothing to be replaced. When the clothing image to be exchanged is determined, two corresponding collarband coordinate points are also determined. That is, after the garment to be exchanged is selected, the corresponding garment image to be exchanged and the corresponding two collarband coordinate points are determined, and the coordinate positions of the corresponding two collarband coordinate points in the coordinate system of the corresponding garment image to be exchanged are also determined.
To increase the application scope of users, the clothing to be replaced referred to in this specification may include different types of clothing such as men's clothing, women's clothing and children's clothing. In addition, the image of the clothing to be exchanged referred to in the present specification is derived from clothing in daily life, as shown in fig. 2 to 5. See fig. 2-5: wherein reference numerals 700, 800, 900 and 1000 each represent an image of a garment to be replaced; points indicated by reference numerals 701 and 702 are two collarband coordinate points of the clothing image to be exchanged shown in fig. 2; points indicated by reference numerals 801 and 802 are two collarband coordinate points of the clothing image to be exchanged shown in fig. 3; points indicated by reference numerals 901 and 902 are two collarband coordinate points of the clothing image to be exchanged shown in fig. 4; points indicated by reference numerals 1001 and 1002 are two collarband coordinate points of the clothing image to be exchanged shown in fig. 5. The portion indicated by reference numeral 703 in fig. 2 is a collar of the image of the garment to be replaced shown in fig. 2, for exposing the neck portion of the portrait in the image of the document to be replaced, and the collar of the image of the garment to be replaced shown in fig. 3 to 5 can refer to fig. 2.
And 140, calculating the scaling coefficient of the clothing image to be replaced based on the two neck key points and the two collarband coordinate points.
Specifically, the specific implementation method of the step 140 is as follows:
calculating a linear distance d1 between two neck key points;
calculating a linear distance d2 between two collarband coordinate points;
and d1/d2 is calculated to obtain the zoom coefficient of the clothing image to be replaced.
And (3) recording the scaling coefficient as eta, and then eta=d1/d 2.
And step 150, scaling the clothing image to be exchanged based on the scaling coefficient to obtain a target clothing image.
Step 160, calculating position coordinates in a coordinate system of the to-be-replaced certificate photograph image, corresponding to the clothing in the to-be-replaced certificate photograph image, replaced by the target clothing image.
The step 160 is to calculate the position coordinates of the target clothing image in the coordinate system of the to-be-replaced document image.
As an exemplary embodiment of the present invention, the calculating the position coordinates of the target clothing image in the coordinate system of the to-be-replaced certificate photograph image, which corresponds to the clothing in the to-be-replaced certificate photograph image, specifically includes:
converting two collarband coordinate points of the clothing image to be exchanged into two collarband coordinate points of the target clothing image, wherein under the condition that the target clothing image replaces the clothing in the clothing certificate image to be exchanged: the position coordinates corresponding to the two collarband coordinate points of the target clothing image in the coordinate system of the to-be-reloaded certificate photograph image are the position coordinates of the two neck key points in the to-be-reloaded certificate photograph image, the position coordinates corresponding to other pixel points on the target clothing image in the coordinate system of the to-be-reloaded certificate photograph image are obtained by sequentially calculating the coordinate positions of the two neck key points in the to-be-reloaded certificate photograph image according to the relative position relation between the other pixel points on the target clothing image and the two collarband coordinate points of the target clothing image.
And 170, fusing the target clothing image with the document photo image to be reloaded according to the position coordinates to obtain the reloaded document photo image.
Specifically, when the method is implemented, according to the position coordinates of the target clothing image in the coordinate system of the to-be-reloaded document photo image, which are calculated in step 160, the target clothing image and the to-be-reloaded document photo image are fused according to the transparent channel mask of the target clothing image, so as to obtain the reloaded document photo image.
Based on the method 100 for changing the credentials photo, firstly, extracting a neck region of a portrait in the credentials photo to be changed, then, detecting key points of the extracted neck region to obtain two neck key points of the neck region in the credentials photo to be changed, then, selecting a garment to be changed to obtain a garment image to be changed and two collarband coordinate points, then, calculating the scaling factor of the garment image to be changed based on the two neck key points and the two collarband coordinate points, and scaling the garment image to be changed to obtain a target garment image based on the calculated scaling factor, then, calculating the position coordinate of the target garment image in the coordinate system of the credentials photo to be changed, and finally, fusing the calculated position coordinate of the target garment image with the credentials photo to be changed, thereby obtaining the credentials photo after changing.
After the scaling factor of the clothing image to be replaced is obtained, the clothing image to be replaced is scaled according to the scaling factor, coordinate points of two necklines of the clothing image to be replaced are converted into coordinate points of two necklines of the scaled clothing image to be replaced, the coordinate positions of the two necklines of the scaled clothing image to be replaced are the coordinate positions of the two neck key points in the clothing photo image to be replaced, and coordinates of other pixel points of the scaled clothing image to be replaced are calculated in sequence relative to the coordinate positions of the two necklines of the scaled clothing image to be replaced in the clothing photo image to be replaced according to the relative position relation.
In addition, as an exemplary embodiment of the present invention, the credential changing method further includes, between step 160 and step 170: judging whether the position coordinates of the target clothing image in the coordinate system of the to-be-replaced certificate photo image, which correspond to the clothing in the to-be-replaced certificate photo image, are beyond the coordinate range of the to-be-replaced certificate photo image, if so, performing overflow treatment on the boundary of the target clothing image, and if not, not performing treatment on the boundary of the target clothing image.
It can be seen that the present invention requires overflow treatment of the boundary when the coordinate range of the converted garment exceeds the maximum and minimum ranges of the corresponding credential images. And particularly, when the boundary is required to be overflowed, a person skilled in the art can select any relevant boundary overflow processing method from the prior art according to actual conditions to realize the boundary overflow processing of the target clothing image.
As an exemplary embodiment of the present invention, the overflow treatment is performed on the boundary of the target clothing image, and the specific implementation steps include:
comparing the corresponding horizontal and vertical coordinate point of the upper left corner of the target clothing image in the coordinate system of the to-be-replaced certificate photograph image with the minimum value of the coordinate points on the to-be-replaced certificate photograph image, and if the corresponding horizontal and vertical coordinate point of the upper left corner of the target clothing image in the coordinate system of the to-be-replaced certificate photograph image is smaller than the minimum value of the coordinate points on the to-be-replaced certificate photograph image, the corresponding horizontal and vertical coordinate point of the upper left corner of the target clothing image in the coordinate system of the to-be-replaced certificate photograph image is the minimum value of the to-be-replaced certificate photograph image;
and comparing the corresponding horizontal and vertical coordinate point of the right lower corner of the target clothing image in the coordinate system of the to-be-replaced certificate photograph image with the maximum value of the coordinate points of the to-be-replaced certificate photograph image, and if the corresponding horizontal and vertical coordinate point of the right lower corner of the target clothing image in the coordinate system of the to-be-replaced certificate photograph image is larger than the maximum value of the coordinate points of the to-be-replaced certificate photograph image, taking the corresponding horizontal and vertical coordinate point of the right lower corner of the target clothing image in the coordinate system of the to-be-replaced certificate photograph image as the maximum value of the to-be-replaced certificate photograph image.
In this embodiment, the horizontal coordinate point of the upper left corner of the converted clothing image to be replaced is compared with the minimum value of the photo image (i.e. the photo image to be replaced), if the horizontal coordinate point of the upper left corner of the converted clothing image to be replaced is smaller than the minimum value of the photo image, the horizontal coordinate point of the upper left corner of the converted clothing image to be replaced is the minimum value of the photo image; and if the horizontal coordinate point of the lower right corner of the converted clothing image to be changed is larger than the maximum value of the credentials image, the horizontal coordinate point of the lower right corner of the converted clothing image to be changed is the maximum value of the credentials image. As shown in fig. 7, the credential changing system 200 includes:
a neck region extraction unit 201 for extracting a neck region of a portrait in a photo image to be reloaded;
the neck key point extraction unit 202 is configured to perform key point detection on the extracted neck region to obtain two key points of a neck region of a portrait in the to-be-reloaded document photo image, and record the two neck key points as two connection points on edge contour lines on two sides of the neck region of the portrait in the to-be-reloaded document photo image, where the two connection points are used for connecting the face region in the to-be-reloaded document photo image;
the clothing model to be replaced selecting unit 203 is configured to select clothing to be replaced, and obtain a clothing image to be replaced and two collarband coordinate points of the clothing image to be replaced, where the clothing image to be replaced is an image including a transparent channel;
a scaling factor calculating unit 204, configured to calculate a scaling factor of the clothing image to be replaced based on the two neck key points and the two collar coordinate points;
the target image obtaining unit 205 performs scaling on the clothing image to be exchanged based on the scaling coefficient to obtain a target clothing image;
the coordinate calculating unit 206 is configured to calculate a position coordinate in a coordinate system of the to-be-replaced certificate photograph image, where the position coordinate corresponds to the garment in the to-be-replaced certificate photograph image and is replaced by the target garment image;
and the reloading unit 207 is configured to fuse the target clothing image with the document image to be reloaded according to the position coordinates, so as to obtain a reloaded document image.
As an exemplary embodiment of the present invention, the neck key point extraction unit 202 includes:
the contour extraction module is used for extracting the contour of the neck region to obtain the contour of the neck region;
the contour approximation module is used for acquiring an approximate contour of the neck region, and the number of vertexes on the approximate contour is smaller than that of vertexes on the contour of the neck region;
and the key point extraction module is used for extracting two points with minimum ordinate values from the approximate contour to serve as the two neck key points.
As an exemplary embodiment of the present invention, the scaling factor calculating unit 204 includes:
the first calculation module is used for calculating the linear distance between the two neck key points and marking the linear distance as d1;
the second calculation module is used for calculating the linear distance between the two collarband coordinate points and marking as d2;
and the third calculation module is used for calculating d1/d2 to obtain the scaling factor of the clothing image to be replaced.
As an exemplary embodiment of the present invention, the coordinate calculation unit 206 is configured to perform the following steps:
converting two collarband coordinate points of the clothing image to be exchanged into two collarband coordinate points of the target clothing image, wherein under the condition that the target clothing image replaces the clothing in the clothing certificate image to be exchanged: the position coordinates corresponding to the two collarband coordinate points of the target clothing image in the coordinate system of the to-be-reloaded certificate photograph image are the position coordinates of the two neck key points in the to-be-reloaded certificate photograph image, the position coordinates corresponding to other pixel points on the target clothing image in the coordinate system of the to-be-reloaded certificate photograph image are obtained by sequentially calculating the coordinate positions of the two neck key points in the to-be-reloaded certificate photograph image according to the relative position relation between the other pixel points on the target clothing image and the two collarband coordinate points of the target clothing image.
As an exemplary embodiment of the present invention, the credential changing system 200 also includes an overflow handling unit 208, as shown in FIG. 8.
The overflow processing unit 208 is configured to determine whether the position coordinates of the target clothing image calculated by the coordinate calculating unit 206 in the coordinate system of the to-be-replaced certificate photograph image, which corresponds to the clothing in the to-be-replaced certificate photograph image, exceed the coordinate range of the to-be-replaced certificate photograph image, and if so, overflow the boundary of the target clothing image.
The same or similar parts between the various embodiments in this specification are referred to each other.
Although the present invention has been described in detail by way of preferred embodiments with reference to the accompanying drawings, the present invention is not limited thereto. Various equivalent modifications and substitutions may be made in the embodiments of the present invention by those skilled in the art without departing from the spirit and scope of the present invention, and it is intended that all such modifications and substitutions be within the scope of the present invention/be within the scope of the present invention as defined by the appended claims. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims (4)

1. A method of changing a document, comprising the steps of:
extracting a neck region of a portrait in a certificate photo image to be reloaded;
the extracted neck region is subjected to key point detection to obtain two key points of the neck region of the portrait in the certificate photo image to be reloaded, wherein the two key points are recorded as two neck key points, and the two neck key points are two connection points used for connecting the face region in the certificate photo image to be reloaded on the contour lines of the two side edges of the neck region of the portrait in the certificate photo image to be reloaded;
selecting a garment to be replaced, and obtaining a garment image to be replaced and two collarband coordinate points of the garment image to be replaced, wherein the garment image to be replaced is an image containing a transparent channel;
calculating the scaling factor of the clothing image to be replaced based on the two neck key points and the two collarband coordinate points; based on the two neck key points and the two collarband coordinate points, calculating the zoom coefficient of the clothing image to be exchanged, wherein the specific implementation method comprises the following steps: calculating the linear distance between two neck key points, and recording as d1; calculating the linear distance between two collarband coordinate points, and marking as d2; d1/d2 is calculated to obtain the zoom coefficient of the clothing image to be replaced;
scaling the clothing image to be changed based on the scaling coefficient to obtain a target clothing image;
calculating position coordinates of the target clothing image in the coordinate system of the to-be-replaced certificate photo image, corresponding to clothing in the to-be-replaced certificate photo image, in replacement; the method for realizing the position coordinate in the coordinate system of the to-be-replaced certificate photograph image, which corresponds to the clothing in the to-be-replaced certificate photograph image, is characterized by comprising the following steps of: converting two collarband coordinate points of the clothing image to be exchanged into two collarband coordinate points of the target clothing image, wherein under the condition that the target clothing image replaces the clothing in the clothing certificate image to be exchanged: the position coordinates corresponding to the two collarband coordinate points of the target clothing image in the coordinate system of the to-be-replaced certificate photograph image are the position coordinates of the two neck key points in the to-be-replaced certificate photograph image, the position coordinates corresponding to other pixel points on the target clothing image in the coordinate system of the to-be-replaced certificate photograph image are obtained by sequentially calculating the coordinate positions of the two neck key points in the to-be-replaced certificate photograph image according to the relative position relation between the other pixel points on the target clothing image and the two collarband coordinate points of the target clothing image;
fusing the target clothing image with the certificate photo image to be reloaded according to the position coordinates to obtain a reloaded certificate photo image;
the implementation method for detecting the key points of the neck region to obtain two neck key points comprises the following steps: extracting the contour of the neck region to obtain the contour of the neck region; obtaining an approximate contour of the neck region, wherein the number of vertexes on the approximate contour is less than that of vertexes on the contour of the neck region; and extracting two points with minimum ordinate values from the approximate contour to serve as the two neck key points.
2. The credential changing method of claim 1, further comprising: judging whether the position coordinates of the target clothing image in the coordinate system of the to-be-replaced certificate photo image, corresponding to the clothing in the to-be-replaced certificate photo image, exceed the coordinate range of the to-be-replaced certificate photo image, and if so, overflowing the boundary of the target clothing image.
3. A credential photo replacement system comprising:
the neck region extraction unit is used for extracting the neck region of the portrait in the certificate photo image to be reloaded;
the neck key point extraction unit is used for detecting the key points of the extracted neck region to obtain two key points of the neck region of the portrait in the certificate photo image to be replaced, and marking the two key points as two neck key points, wherein the two neck key points are two connection points used for connecting the face region in the certificate photo image to be replaced on the edge contour lines of the two sides of the neck region of the portrait in the certificate photo image to be replaced;
the clothing model selection unit is used for selecting clothing to be replaced to obtain clothing images to be replaced and two collarband coordinate points of the clothing images to be replaced, wherein the clothing images to be replaced are images containing transparent channels;
the scaling factor calculating unit is used for calculating the scaling factor of the clothing image to be replaced based on the two neck key points and the two collarband coordinate points;
the target image acquisition unit is used for scaling the clothing image to be replaced based on the scaling coefficient to obtain a target clothing image;
the coordinate calculation unit is used for calculating the position coordinates of the target clothing image in the coordinate system of the to-be-replaced certificate photograph image, which correspond to the clothing in the to-be-replaced certificate photograph image;
the reloading unit is used for fusing the target clothing image with the document image to be reloaded according to the position coordinates to obtain a reloaded document image;
the neck key point extraction unit includes:
the contour extraction module is used for extracting the contour of the neck region to obtain the contour of the neck region;
the contour approximation module is used for acquiring an approximate contour of the neck region, and the number of vertexes on the approximate contour is smaller than that of vertexes on the contour of the neck region;
the key point extraction module is used for extracting two points with minimum ordinate values from the approximate contour to serve as the two neck key points;
the scaling factor calculation unit includes:
the first calculation module is used for calculating the linear distance between the two neck key points and marking the linear distance as d1;
the second calculation module is used for calculating the linear distance between the two collarband coordinate points and marking as d2;
the third calculation module is used for calculating d1/d2 to obtain the scaling factor of the clothing image to be replaced;
the coordinate calculation unit is configured to perform the steps of:
converting two collarband coordinate points of the clothing image to be exchanged into two collarband coordinate points of the target clothing image, wherein under the condition that the target clothing image replaces the clothing in the clothing certificate image to be exchanged: the position coordinates corresponding to the two collarband coordinate points of the target clothing image in the coordinate system of the to-be-reloaded certificate photograph image are the position coordinates of the two neck key points in the to-be-reloaded certificate photograph image, the position coordinates corresponding to other pixel points on the target clothing image in the coordinate system of the to-be-reloaded certificate photograph image are obtained by sequentially calculating the coordinate positions of the two neck key points in the to-be-reloaded certificate photograph image according to the relative position relation between the other pixel points on the target clothing image and the two collarband coordinate points of the target clothing image.
4. The credential cartridge changer system of claim 3, further comprising an overflow handling unit;
the overflow processing unit is used for judging whether the position coordinates of the target clothing image calculated by the coordinate calculation unit in the coordinate system of the to-be-replaced certificate photograph image, which correspond to the clothing in the to-be-replaced certificate photograph image, are beyond the coordinate range of the to-be-replaced certificate photograph image, and if so, performing overflow processing on the boundary of the target clothing image.
CN202111649284.3A 2021-12-29 2021-12-29 Certificate photo reloading method and system Active CN114549694B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111649284.3A CN114549694B (en) 2021-12-29 2021-12-29 Certificate photo reloading method and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111649284.3A CN114549694B (en) 2021-12-29 2021-12-29 Certificate photo reloading method and system

Publications (2)

Publication Number Publication Date
CN114549694A CN114549694A (en) 2022-05-27
CN114549694B true CN114549694B (en) 2024-03-01

Family

ID=81669975

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111649284.3A Active CN114549694B (en) 2021-12-29 2021-12-29 Certificate photo reloading method and system

Country Status (1)

Country Link
CN (1) CN114549694B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117635763B (en) * 2023-11-28 2024-08-02 广州像素数据技术股份有限公司 Automatic reloading method, device, equipment and medium based on portrait component analysis

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103927724A (en) * 2014-04-30 2014-07-16 北京京东尚科信息技术有限公司 Method and device for processing coat image
CN106446819A (en) * 2016-09-20 2017-02-22 上海理工大学 Human security check image formation human silhouette object discerning method
KR101720016B1 (en) * 2015-10-16 2017-03-27 광운대학교 산학협력단 A clothing fitting system with a mirror display by using salient points and the method thereof
CN107230224A (en) * 2017-05-19 2017-10-03 深圳奥比中光科技有限公司 Three-dimensional virtual garment model production method and device
CN109035413A (en) * 2017-09-01 2018-12-18 深圳市云之梦科技有限公司 A kind of virtually trying method and system of anamorphose
CN112529670A (en) * 2021-02-07 2021-03-19 上海英立视电子有限公司 Virtual fitting method
CN112581564A (en) * 2020-12-24 2021-03-30 咪咕文化科技有限公司 Image generation method and device, electronic equipment and storage medium
CN112991494A (en) * 2021-01-28 2021-06-18 腾讯科技(深圳)有限公司 Image generation method and device, computer equipment and computer readable storage medium

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10373244B2 (en) * 2015-07-15 2019-08-06 Futurewei Technologies, Inc. System and method for virtual clothes fitting based on video augmented reality in mobile phone
US10962404B2 (en) * 2019-04-02 2021-03-30 Bodygram, Inc. Systems and methods for weight measurement from user photos using deep learning networks
CN111709874B (en) * 2020-06-16 2023-09-08 北京百度网讯科技有限公司 Image adjustment method, device, electronic equipment and storage medium

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103927724A (en) * 2014-04-30 2014-07-16 北京京东尚科信息技术有限公司 Method and device for processing coat image
KR101720016B1 (en) * 2015-10-16 2017-03-27 광운대학교 산학협력단 A clothing fitting system with a mirror display by using salient points and the method thereof
CN106446819A (en) * 2016-09-20 2017-02-22 上海理工大学 Human security check image formation human silhouette object discerning method
CN107230224A (en) * 2017-05-19 2017-10-03 深圳奥比中光科技有限公司 Three-dimensional virtual garment model production method and device
CN109035413A (en) * 2017-09-01 2018-12-18 深圳市云之梦科技有限公司 A kind of virtually trying method and system of anamorphose
CN112581564A (en) * 2020-12-24 2021-03-30 咪咕文化科技有限公司 Image generation method and device, electronic equipment and storage medium
CN112991494A (en) * 2021-01-28 2021-06-18 腾讯科技(深圳)有限公司 Image generation method and device, computer equipment and computer readable storage medium
CN112529670A (en) * 2021-02-07 2021-03-19 上海英立视电子有限公司 Virtual fitting method

Non-Patent Citations (6)

* Cited by examiner, † Cited by third party
Title
A Mixed Reality Virtaual Clothes Try-On System;Miaolong Yuan et al.;IEEE;第1958-1968页 *
冯斌等.信息隐藏与数字水印.北京:机械工业出版社,2021,第76-80页. *
刘军等.基于特征匹配的三维试衣效果.纺织学报.2009,(第01期),第128-132页. *
服饰智能适配系统的研究与应用;曾献辉;中国博士学位论文全文数据库 (工程科技Ⅰ辑);第B024-29页 *
虚拟试衣系统服装图像匹配算法研究;耿曼;钱国明;王宇;;计算机技术与发展(01);第132-135页 *
许明星等.基于图像的人体特征点提取与尺寸测量.计算机系统应用.2018,(第06期),第89-96页. *

Also Published As

Publication number Publication date
CN114549694A (en) 2022-05-27

Similar Documents

Publication Publication Date Title
CN103914699B (en) A kind of method of the image enhaucament of the automatic lip gloss based on color space
US8290279B2 (en) Method, a system, and a computer program product for processing images
CN105787878B (en) A kind of U.S. face processing method and processing device
CN104834898B (en) A kind of quality classification method of personage's photographs
CN105139404B (en) A kind of the license camera and shooting quality detection method of detectable shooting quality
CN111046763B (en) Portrait cartoon method and device
CN105046246A (en) Identification photo camera capable of performing human image posture photography prompting and human image posture detection method
CN107368806B (en) Image rectification method, image rectification device, computer-readable storage medium and computer equipment
CN104794693B (en) A kind of portrait optimization method of face key area automatic detection masking-out
JP2002175538A (en) Device and method for portrait generation, recording medium with portrait generating program recorded thereon, terminal for communication, and communication method by terminal for communication
US20180228426A1 (en) Image Processing System and Method
JP2007272435A (en) Face feature extraction device and face feature extraction method
CN113160036B (en) Face changing method for image keeping face shape unchanged
CN114549694B (en) Certificate photo reloading method and system
CN101493887A (en) Eyebrow image segmentation method based on semi-supervision learning and Hash index
EP4239573A1 (en) Method for detecting and segmenting the lip region
CN113033488A (en) Medical feature recognition method and device, electronic device and storage medium
JP4219521B2 (en) Matching method and apparatus, and recording medium
CN110648336B (en) Method and device for dividing tongue texture and tongue coating
CN104866826B (en) A kind of static sign Language Recognition Method based on KNN and pixel ratio Gradient Features
CN111259857A (en) Human face smile scoring method and human face emotion classification method
CN105580050A (en) Providing control points in images
CN114187309B (en) Hair segmentation method and system based on convolutional neural network
CN113763498B (en) Industrial manufacturing-oriented portrait simple drawing region self-adaptive color matching method and system
CN114511567A (en) Tongue body and tongue coating image identification and separation method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant