Disclosure of Invention
In view of the above, it is necessary to provide an imaging method of a virtual fitting and a virtual fitting apparatus.
In order to realize the purpose of the invention, the invention adopts the following technical scheme:
a method of imaging a virtual fit, comprising:
acquiring a first face picture of a light supplement lamp at a first brightness gear and a second face picture of the light supplement lamp at a second brightness gear; the brightness of the first brightness gear is greater than that of the second brightness gear;
respectively acquiring a first average brightness of the face in the first face picture and a second average brightness of the face in the second face picture;
and comparing the first average brightness and the second average brightness with preset values respectively, selecting the first face picture or the second face picture to generate an image, and adjusting the second brightness level.
In one embodiment, the step of respectively obtaining the first average luminance and the second average luminance includes:
judging whether the first face picture comprises a face or not;
if the first face picture comprises a face, acquiring the position of the face and key points in the face, and calculating the first average brightness;
if the first face picture does not include a face, setting the first average brightness to be zero or a negative value;
judging whether the second face picture comprises a face or not;
if the second face picture comprises a face, acquiring the position of the face and key points in the face, and calculating the second average brightness;
if the second face picture does not include a face, setting the second average brightness to be zero or a negative value;
wherein the key points include eyes, nose, mouth, and eyebrows in a human face.
In one embodiment, the RGB color model of the first face picture is converted into an LAB color model, and the luminances of the pixel points in the face region in the first face picture are added and averaged to obtain the first average luminance;
and converting the RGB color model of the second face picture into an LAB color model, adding the brightness of pixel points in the face region in the second face picture, and calculating an average value to obtain the second average brightness.
In one embodiment, the first average brightness and the second average brightness are analyzed and processed to form a digital code.
In one embodiment, when the first average brightness is greater than zero and the second average brightness is equal to or less than zero, the digital code is a first digital code;
when the first average brightness is equal to or less than zero and the second average brightness is greater than zero, selecting the digital code as a second digital code;
and when the first average brightness and the second average brightness are both larger than zero, respectively comparing the first average brightness and the second average brightness with preset values.
In one embodiment, when the first average luminance and the second average luminance are both greater than zero, the method comprises the steps of:
presetting a brightness range in which a human face can be normally displayed;
when the first average brightness is smaller than or equal to the maximum value of the brightness range, the second average brightness is smaller than the maximum value of the brightness range, and the first average brightness is larger than the second average brightness, the digital code is a third digital code;
when the first average brightness is larger than the maximum value of the brightness range, the second average brightness is larger than or equal to the maximum value of the brightness range, and the first average brightness is larger than the second average brightness, the digital code is a fourth digital code;
when the first average brightness is larger than the maximum value of the brightness range and the second average brightness is smaller than the minimum value of the brightness range, if the difference between the first average brightness and the maximum value is smaller than the difference between the second average brightness and the minimum value, the digital code is a fifth digital code; otherwise, the digital code is a sixth digital code.
In one embodiment, the method comprises the following steps:
when the digital codes are a first digital code, a third digital code and a fifth digital code, selecting the first face picture to generate an image, and enabling the second brightness gear to be shifted up by one gear;
when the digital code is a second digital code, selecting the second face picture to generate an image; if the second average brightness is smaller than the minimum value of the brightness range, the second brightness gear is shifted up by one gear; if the second average brightness is within the brightness range, maintaining the second brightness level; if the second average brightness is larger than the maximum value of the brightness range, the second brightness gear is adjusted downwards by one gear;
when the digital code is a fourth digital code, selecting the second face picture to generate an image, and adjusting the second brightness level by one level;
and when the digital code is a sixth digital code, selecting the second face picture to generate an image, and enabling the second brightness gear to be shifted up by one gear.
In one embodiment, the brightness of the second brightness step is zero in the initial step before the adjustment is made.
In one embodiment, the second brightness step is reset when the first average brightness is less than the second average brightness.
According to the imaging method of the virtual fitting, the face pictures at the first brightness level and the second brightness level are sequentially obtained, one face picture with better face display effect is selected according to the brightness analysis result of the face in the face picture, and the second brightness level of the light supplement lamp is adaptively adjusted, so that the face display effect in the face picture obtained at the low level of the light supplement lamp next time is better.
A virtual fitting apparatus, comprising:
the light supplement lamp is used for respectively projecting the light source of the first brightness gear and the light source of the second brightness gear;
the image acquisition module is used for acquiring a first face picture of the light supplement lamp in a first brightness gear and a second face picture of the light supplement lamp in a second brightness gear; the brightness of the first brightness gear is greater than that of the second brightness gear;
the image processing module is connected with the image acquisition module, and is used for respectively acquiring first average brightness of a face in the first face picture and second average brightness of the face in the second face picture, comparing the first average brightness and the second average brightness with preset values respectively, and selecting the first face picture or the second face picture;
the light supplement adjusting module is respectively connected with the light supplement lamp of the image processing module and is used for receiving processing data in the image processing module and adjusting the second brightness gear according to the processing data;
and the imaging display module is connected with the image processing module and used for receiving the first face picture or the second face picture, synthesizing the first face picture or the second face picture with a built-in clothing picture and then sending the synthesized image to a display window to generate an image.
The virtual fitting equipment sequentially acquires the face pictures at the first brightness level and the second brightness level, and adaptively adjusts the second brightness level of the light supplement lamp according to the brightness of the face in the face pictures, so that the display effect of the face in the face picture acquired at the next low level of the light supplement lamp is better; the device can respectively obtain the human faces in two brightness gears at one time, and the image processing module can select a picture with better brightness for imaging, so that the device can meet the requirements of people with different skin colors.
Detailed Description
To facilitate an understanding of the invention, the invention will now be described more fully with reference to the accompanying drawings. Preferred embodiments of the present invention are shown in the drawings. This invention may, however, be embodied in many different forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs. The terminology used in the description of the invention herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention.
Fig. 1 is a schematic flow chart of a virtual fitting imaging method according to an embodiment, which includes the following steps S100 to S300.
S100, a first face picture of the light supplement lamp in a first brightness gear and a second face picture of the light supplement lamp in a second brightness gear are obtained.
S200, respectively obtaining a first average brightness of the face in the first face picture and a second average brightness of the face in the second face picture.
S300, comparing the first average brightness and the second average brightness with preset values respectively, selecting a first face picture or a second face picture to generate an image, and adjusting a second brightness gear of the light supplement lamp.
After the second brightness step is adjusted in step S300, the second brightness step is used in step S100.
The brightness of the first brightness gear needs to be larger than that of the second brightness gear, and when the average brightness of the first face is smaller than or equal to that of the second face, the second brightness gear is abnormal, and the second brightness gear of the light supplement lamp needs to be reset.
The human face pictures at the first brightness gear and the second brightness gear are acquired in sequence, and the second brightness gear of the light supplement lamp is adaptively adjusted according to the brightness of the human face in the human face pictures, so that the display effect of the human face in the human face pictures acquired at the low gear of the light supplement lamp next time is better.
Fig. 2 is a flowchart illustrating the step S200 in fig. 1, and in one embodiment, the step of obtaining the first average brightness includes the following steps S210 to S230.
S210, judging whether the first face picture comprises a face or not, and if not, jumping to the step S230. As shown in fig. 3, when a certain key point is detected, the corresponding value is fed back to the control terminal to confirm which key point is specifically detected and which key point is not detected; different analysis processes can also be performed on different key points.
S220, obtaining the position of the face and key points in the face, and calculating first average brightness. Wherein, the key points in the human face can be identified and detected by a detector; the first average luminance is calculated by: and converting the RGB color model of the acquired face picture into an LAB color model, adding the brightness of the pixel points in the face region and calculating an average value to obtain a first average brightness.
The RGB color model is obtained by changing three color channels of red (R), green (G) and blue (B) and superimposing them with each other, and RGB is a color representing three channels of red, green and blue; according to the principle of three primary colors, the amount of light is expressed in units of primary color light, and any color light F can be formed by adding and mixing R, G, B three different color components in the RGB color space.
The LAB color model is composed of three elements, namely luminance (L) and a and b related to color. L represents luminance (luminescence), a represents a range from magenta to green, and b represents a range from yellow to blue. The value range of L is from 0 to 100, and when L is 50, the color is equivalent to 50% of black; the value range of a and b is from +127 to-128, wherein +127a is red, and gradually transits to-128 a to become green; in the same principle, +127b is yellow and-128 b is blue. All colors are composed by alternating changes of these three values. For example, a color block has a Lab value of L100, a 30, and b 0, and is pink.
And S230, setting the first average brightness to be zero or a negative value, and indicating that no human face is detected.
The step of obtaining the second average brightness is the same as the step of obtaining the first average brightness, and is not described herein again.
FIG. 4 is a schematic flow chart of step S300 of FIG. 1. in one embodiment, step S300 includes the following steps S301-S318.
S301, analyzing and processing the first average brightness L1 of the first face picture and the second average brightness L2 of the second face picture to form a digital code. Each digital code has a corresponding control instruction, and the control instruction can comprise a picture selecting instruction and a light supplementing lamp adjusting instruction.
S302, whether the first average brightness L1 is greater than zero and the second average brightness L2 is equal to or less than zero is judged, and if yes, the process goes to step S311.
S303, determining whether the first average brightness L1 is equal to or less than zero and the second average brightness L2 is greater than zero, if yes, jumping to step S312.
S304, judging whether the first average brightness L1 and the second average brightness L2 are both equal to or less than zero, if so, jumping to the step S319.
S305, presetting a brightness range in which the human face can be normally displayed, wherein the maximum value of the brightness range is Lmax, and the minimum value of the brightness range is Lmin.
S306, judging whether the first average brightness L1 is less than or equal to the maximum value Lmax of the brightness range, and the second average brightness L2 is less than the maximum value Lmax of the brightness range, if yes, jumping to the step S313.
S307, judging whether the first average brightness L1 is larger than the maximum value Lmax of the brightness range or not, and the second average brightness L2 is larger than or equal to the maximum value Lmax of the brightness range, if so, jumping to the step S314.
S308, judging whether the difference between the first average brightness L1 and the maximum value Lmax of the brightness range is smaller than the difference between the minimum value Lmin of the brightness range and the second average brightness L2, if so, jumping to the step S317.
S309, judging whether the difference between the first average brightness L1 and the maximum value Lmax of the brightness range is larger than or equal to the difference between the minimum value Lmin of the brightness range and the second average brightness L2, if yes, jumping to the step S318.
S310, setting the digital code as a seventh digital code, and jumping to the step S320.
S311, setting the digital code as a first digital code, and jumping to the step S320.
S312, setting the digital code as a second digital code, and jumping to the step S320.
S313, judging that the first average brightness L1 is greater than or equal to the second average brightness L2, if so, jumping to S315; if not, go to step S310.
S314, judging that the first average brightness L1 is greater than or equal to the second average brightness L2, if so, jumping to the step S316; if not, go to step S310.
S315, setting the digital code as a third digital code, and jumping to the step S320.
S316, setting the digital code as a fourth digital code, and jumping to the step S320.
S317, setting the digital code as a fifth digital code, and jumping to the step S320.
S318, setting the digital code as a sixth digital code, and jumping to the step S320.
And S319, setting the digital code to zero.
And S320, obtaining a corresponding face picture according to the digital code, and obtaining a corresponding instruction for adjusting a second brightness gear of the light supplement lamp. The digital code consists of four digits, and the first digit is the number of the digital code; the second bit is brightness; the third position is the selected face picture, 1 is the first face picture, and 2 is the second face picture; the fourth position is an adjusting instruction of the fill-in light, 1 is an up-shift instruction, 2 is a down-shift instruction, 3 is a further analyzing instruction, and 4 is a resetting instruction. Specifically, the first digital code is 1x11, the second digital code is 2x23, the third digital code is 3x11, the fourth digital code is 4x22, the fifth digital code is 5x11, the sixth digital code is 6x21, the seventh digital code is 7x04,
when the digital code is a first digital code, only the face is detected in the first face picture, and the face is not detected in the second face picture, and the first face picture is selected to generate an image; and if the human face is not detected in the second human face picture, the brightness of the human face obtained under the second brightness gear is too dark, so that the human face cannot be detected, and the second brightness gear is shifted up by one gear.
And when the digital code is a second digital code, only the face is detected in the second face picture and the face is not detected in the first face picture, selecting the second face picture to generate an image, and further analyzing the adjustment of the second brightness gear. Specifically, if the second average brightness is smaller than the minimum value of the brightness range, the second brightness gear is shifted up by one; if the second average brightness is within the brightness range, maintaining a second brightness gear; and if the second average brightness is larger than the maximum value of the brightness range, the second brightness gear is adjusted downwards by one gear.
When the digital code is a third digital code, the first face picture and the second face picture detect faces, and the two face pictures are not exposed, and the first face picture is selected to generate an image because the brightness of the face in the first face picture is greater than that of the face in the second face picture; and on the premise that the second brightness gear is not higher than the first brightness gear after being shifted up by one gear, the second brightness gear is shifted up by one gear.
When the digital code is a fourth digital code, the first face picture and the second face picture detect faces, the two face pictures are exposed, and the second face picture is selected to generate an image and the second brightness gear is shifted down by one gear because the brightness of the face in the first face picture is greater than that of the face in the second face picture.
When the digital code is a fifth digital code, the first face picture and the second face picture detect faces, the difference between the first average brightness and the maximum value of the brightness range is smaller than the difference between the second average brightness and the minimum value of the brightness range, and the first face picture is selected to generate an image; and on the premise that the second brightness gear is not higher than the first brightness gear after being shifted up by one gear, the second brightness gear is shifted up by one gear.
When the digital code is a sixth digital code, the first face picture and the second face picture detect faces, the difference between the first average brightness and the maximum value of the brightness range is larger than the difference between the second average brightness and the minimum value of the brightness range, and the second face picture is selected to generate an image; and on the premise that the second brightness gear is not higher than the first brightness gear after being shifted up by one gear, the second brightness gear is shifted up by one gear.
When the digital code is a seventh digital code, the first face picture and the second face picture detect faces, the brightness of the faces in the first face picture is smaller than or equal to that of the faces in the second face picture, and the data show that the second brightness gear is abnormal because the brightness of the second brightness gear needs to be smaller than that of the first brightness gear, and the second brightness gear is reset. Wherein, the brightness of the initial gear before the adjustment of the second brightness gear is zero.
According to the imaging method of the virtual fitting, the face pictures at the first brightness level and the second brightness level are sequentially obtained, one face picture with better face display effect is selected according to the brightness analysis result of the face in the face picture, and the second brightness level of the light supplement lamp is adaptively adjusted, so that the face display effect in the face picture obtained at the low level of the light supplement lamp next time is better.
Fig. 5 is a schematic circuit configuration diagram of a virtual fitting apparatus in an embodiment, the apparatus includes:
a fill-in light 510 for projecting a light source of a first brightness level and a light source of a second brightness level, respectively;
the image obtaining module 520 is configured to obtain a first face picture of the fill light 510 at a first brightness level and a second face picture of the fill light 510 at a second brightness level;
an image processing module 530, connected to the image obtaining module 520, configured to obtain a first average luminance of a face in the first face picture and a second average luminance of a face in the second face picture, respectively, compare the first average luminance and the second average luminance with preset values, and select the first face picture or the second face picture;
a light supplement adjusting module 540, respectively connected to the image processing module 530 and the light supplement lamp 510, for receiving the processing data in the image processing module and adjusting a second brightness level according to the processing data;
and the imaging display module 550 is connected to the image processing module 530, and is configured to receive the first face picture or the second face picture, synthesize the first face picture or the second face picture with a built-in clothing picture, and send the synthesized image to a display window to generate an image.
When the average brightness of the first face is smaller than or equal to the average brightness of the second face, the second brightness gear of the light supplement lamp needs to be reset.
In one embodiment, the virtual fitting apparatus further includes a control terminal 560, and the control terminal 560 is connected to the image processing module 530, the fill-in light adjusting module 540, and the imaging display module 550, respectively.
The image processing module 530 analyzes and processes the first average brightness of the face in the first face picture and the second average brightness of the face in the second face picture to form a digital code, and sends the digital code to the control terminal 560, each digital code has a corresponding control instruction in the control terminal 560, and the control instruction may include a picture selection instruction and a fill-in light adjustment instruction. The control terminal 560 finds a corresponding control instruction according to the digital code, and sends the control instruction to the supplementary lighting adjusting module 540 and the imaging display module 550 respectively, so as to adjust the second brightness level of the supplementary lighting lamp 510, and select a face picture to be synthesized with a built-in clothing picture and then send the synthesized picture to the display window to generate an image.
The step of obtaining the average brightness of the face in the face picture, the setting condition of the digital codes, and the adjustment instruction corresponding to each digital code have been described in the above embodiments, and are not described again.
The technical features of the embodiments described above may be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the embodiments described above are not described, but should be considered as being within the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present invention, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the inventive concept, which falls within the scope of the present invention. Therefore, the protection scope of the present patent shall be subject to the appended claims.