Method, device, electronic device and storage medium for generating portrait business card
By using the pre-built portrait cutout model for portrait detection and segmentation, and automatically laying out the portrait area on the business card template, the problem of low efficiency and image damage in portrait business card generation is solved, and efficient and high-quality portrait business card generation is achieved.
Patent Information
- Application Number
- CN202111087077.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-16
- Publication Date
- 2024-08-27
- Estimated Expiration
- 2041-09-16
AI Technical Summary
In the process of making portrait business cards, users need to manually adjust the size of the photo to fit the business card template, which results in low efficiency, possible damage to the image, and deformation problems.
Use the pre-built portrait cutout model, connect end-to-end through the portrait detection network and segmentation network, detect and segment the portrait area, and layout the portrait area according to the business card template, realize automatic adjustment and layout, and generate a portrait business card.
It improves the efficiency of portrait business card generation, reduces manual operations, ensures the image quality and size consistency of portraits, and avoids deformation problems.
Smart Images

Figure CN113793406B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence, and in particular to a method, device, electronic device and storable medium for generating a portrait business card. Background Art
[0002] Currently, in the process of making a portrait business card, a user generally first selects a business card template, and then performs cutout and photo adjustment processing on the template photo to obtain a portrait business card.
[0003] However, in general, users not only need to find a place to place the photo in the business card template, but also there is a difference between the photo size provided by the business card template and the user's photo size. When adjusting the photo size, users often need to stretch the photo, causing the photo to deform and damaging the user's image. This process involves a lot of manual operations, resulting in low efficiency in generating portrait business cards. Summary of the invention
[0004] The present invention provides a method, device, electronic equipment and computer medium for generating a portrait business card, the main purpose of which is to improve the efficiency of generating a portrait business card.
[0005] To achieve the above object, the present invention provides a method for generating a portrait business card, comprising:
[0006] Obtain a user image to be identified, and perform a preprocessing operation on the user image to be identified to obtain a standard image;
[0007] Input the standard image into a pre-built portrait cutout model, and use the portrait detection network in the portrait cutout model to detect the standard image to obtain a portrait image, and then use the portrait segmentation network in the portrait cutout model to segment the portrait image to obtain a portrait area, wherein the portrait cutout model includes an end-to-end connection of a portrait detection network and a portrait segmentation network;
[0008] Obtaining a business card template and business card information, and determining whether a photo area in the business card template has a picture frame;
[0009] If the photo area in the business card template has a picture frame, the portrait area is arranged in the picture frame, and the business card information is arranged on the business card template to obtain a first portrait business card;
[0010] If the photo area in the business card template has no frame, the portrait area is laid out in the photo area, and the business card information is laid out in the business card template to obtain a second portrait business card.
[0011] Optionally, the detecting the standard image using a portrait detection network in the portrait cutout model to obtain a portrait image includes:
[0012] Using the convolutional layer in the portrait detection network to extract features from the standard image to obtain a feature image;
[0013] Using the pooling layer in the portrait detection network to perform a dimensionality reduction operation on the feature image to obtain a dimensionality reduced image;
[0014] Using the fully connected layer in the portrait detection network to fully connect the dimension reduction image to obtain a spliced portrait image;
[0015] The spliced portrait picture is outputted using the activation function in the portrait detection network to obtain a portrait picture.
[0016] Optionally, the using a portrait segmentation network in the portrait cutout model to segment the portrait image to obtain a portrait region includes:
[0017] Utilizing the hole convolution layer in the portrait segmentation network to extract features of the portrait image and perform feature fusion to obtain a fused portrait image;
[0018] Performing portrait segmentation on the fused portrait image using the pyramid pooling layer in the portrait segmentation network to obtain a segmented portrait image;
[0019] The segmented portrait image is input into the activation function in the portrait segmentation network to obtain the portrait region output by the activation function.
[0020] Optionally, if the photo area in the business card template has a picture frame, placing the portrait area in the picture frame includes:
[0021] If the photo area in the business card template has a frame, obtain the frame height, frame width and frame centerline of the frame;
[0022] The portrait area is scaled according to the picture frame height, the picture frame width and the picture frame center line, so that the portrait area height is consistent with the picture frame height, the portrait area width is consistent with the picture frame width, and the area center line is consistent with the picture frame center line, and the portrait area is arranged in the picture frame.
[0023] Optionally, if the photo area in the business card template has no picture frame, laying out the portrait area in the photo area includes:
[0024] If the photo area in the business card template has no picture frame, obtaining the top edge value coordinates and the bottom edge value coordinates of the photo area;
[0025] After aligning the top edge of the portrait area with the top edge of the photo area by using the top edge value coordinates, the scaling ratio of the portrait area is calculated, and the bottom edge value of the portrait area is calculated according to the scaling ratio and the bottom edge value, so that the portrait area is laid out in the photo area.
[0026] Optionally, the preprocessing operation on the to-be-identified user image to obtain a standard image includes:
[0027] Digitally process the user image to be identified to obtain a digital image;
[0028] Performing a histogram equalization operation on the digital image to obtain a balanced image;
[0029] Performing a sharpening and smoothing operation on the equalized image to obtain an enhanced image;
[0030] A normalization operation is performed on the enhanced image to obtain a standard image.
[0031] Optionally, the performing a normalization operation on the enhanced image to obtain a standard image includes:
[0032] Performing geometric normalization and grayscale normalization operations on the standard image to obtain a standard image.
[0033] In order to solve the above problem, the present invention also provides a device for generating a portrait business card, the device comprising:
[0034] A preprocessing operation module is used to obtain a user picture to be identified, and perform a preprocessing operation on the user picture to be identified to obtain a standard picture;
[0035] A model cutout module, used to input the standard image into a pre-built portrait cutout model, and use the portrait detection network in the portrait cutout model to detect the standard image to obtain a portrait image, and then use the portrait segmentation network in the portrait cutout model to segment the portrait image to obtain a portrait area, wherein the portrait cutout model includes an end-to-end connection of a portrait detection network and a portrait segmentation network;
[0036] A picture frame determination module, used to obtain a business card template and business card information, and determine whether a photo area in the business card template has a picture frame;
[0037] A first portrait business card generation module, configured to, if the photo area in the business card template has a picture frame, layout the portrait area in the picture frame, and layout the business card information on the business card template to obtain a first portrait business card;
[0038] The second portrait business card generation module is used to layout the portrait area in the photo area if there is no frame in the photo area in the business card template, and layout the business card information in the business card template to obtain a second portrait business card.
[0039] In order to solve the above problem, the present invention further provides an electronic device, the electronic device comprising:
[0040] a memory storing at least one computer program; and
[0041] The processor executes the computer program stored in the memory to implement the above-mentioned method for generating a portrait business card.
[0042] In order to solve the above problem, the present invention also provides a computer medium, in which at least one computer program is stored. The at least one computer program is executed by a processor in an electronic device to implement the above-mentioned method for generating a portrait business card.
[0043] In an embodiment of the present invention, firstly, a preprocessing operation is performed on the user image to be identified to obtain a standard image. After the preprocessing operation, the details in the standard image can be more prominent, the image can be clearer, and the image quality can be higher; secondly, the features of the standard image are detected using the portrait detection network in the pre-constructed portrait cutout model, and the detected portrait is cropped to obtain a portrait image; then, the portrait image is segmented using the portrait segmentation network in the portrait cutout model, and the detected portrait image is segmented, thereby realizing portrait cutout and obtaining a portrait area; finally, according to the business card template layout, the business card information input by the user and the portrait area are laid out in the photo area in the business card template to obtain a portrait business card, without the need for user adjustment, thereby improving the efficiency of portrait business card generation. Therefore, the portrait business card generation method, device, electronic device, and storable medium proposed in the embodiment of the present invention can improve the efficiency of portrait business card generation. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] Figure 1 A schematic diagram of a process for generating a portrait business card provided by an embodiment of the present invention;
[0045] Figure 2 A schematic diagram of modules of a device for generating a portrait business card provided by an embodiment of the present invention;
[0046] Figure 3 A schematic diagram of the internal structure of an electronic device for implementing a method for generating a portrait business card provided by an embodiment of the present invention;
[0047] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0048] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.
[0049] The embodiment of the present invention provides a method for generating a portrait business card. The execution subject of the portrait business card generation method includes but is not limited to at least one of the electronic devices such as a server and a terminal that can be configured to execute the method provided by the embodiment of the present application. In other words, the portrait business card generation method can be executed by software or hardware installed on a terminal device or a server device, and the software can be a blockchain platform. The server includes but is not limited to: a single server, a server cluster, a cloud server or a cloud server cluster, etc.
[0050] Reference Figure 1 FIG. 1 is a flow chart of a method for generating a portrait business card provided by an embodiment of the present invention. In the embodiment of the present invention, the method for generating a portrait business card includes:
[0051] S1. Obtain a user picture to be identified, and perform a preprocessing operation on the user picture to be identified to obtain a standard picture.
[0052] In the embodiment of the present invention, the user image to be identified is an image to be identified that includes a user portrait image. For example, the user image to be identified is an ID photo or a photo including a portrait taken by the user, and the user image to be identified can be obtained from a photo uploaded by the user.
[0053] In the embodiment of the present invention, by preprocessing the image, it is possible to avoid the shortcomings of grayscale, noise and insufficient contrast due to different acquisition environments (such as the degree of light illumination and the quality of equipment, etc.), and to avoid the problem of uncertain size and position of the portrait in the middle of the entire image due to different distances and focal lengths. Therefore, by preprocessing the image, the consistency of the size, position and quality of the portrait in the portrait image can be improved.
[0054] In detail, the preprocessing operation is performed on the user image to be identified to obtain a standard image, including:
[0055] Digitally process the user image to be identified to obtain a digital image;
[0056] Performing a histogram equalization operation on the digital image to obtain a balanced image;
[0057] Performing a sharpening and smoothing operation on the equalized image to obtain an enhanced image;
[0058] A normalization operation is performed on the enhanced image to obtain a standard image.
[0059] In the embodiment of the present invention, the digital processing is to perform grayscale sampling and quantization on the to-be-identified user image on an M x N dot matrix to obtain a digital image that can be processed by a computer.
[0060] In one embodiment of the present invention, performing the histogram equalization operation can convert the digital image into a balanced image having the same pixels at each gray level.
[0061] In an optional embodiment of the present invention, the LoG operator can be used to perform a sharpening operation on the equalized image to enhance the contour information in the image and highlight the detail changes of the image. However, the noise of the image after sharpening will be enhanced, so further smoothing processing is performed to eliminate the noise of the image without blurring the image contour or lines.
[0062] Preferably, the smoothing process may be performed by a median method.
[0063] In the embodiment of the present invention, the purpose of normalizing the enhanced image is to make the images taken under different conditions (such as light intensity, direction, distance, posture, etc.) consistent.
[0064] Furthermore, the normalizing operation is performed on the enhanced image to obtain a standard image, including:
[0065] Performing geometric normalization and grayscale normalization operations on the standard image to obtain a standard image.
[0066] In one embodiment of the present invention, the geometric normalization helps to correct the size difference and angle tilt caused by changes in imaging distance and changes in the posture of the portrait in the picture, and the grayscale normalization helps to compensate for the portrait in the picture obtained under different light intensities and light source directions.
[0067] S2. Input the standard image into a pre-built portrait cutout model, and use the portrait detection network in the portrait cutout model to detect the standard image to obtain a portrait image, and then use the portrait segmentation network in the portrait cutout model to segment the portrait image to obtain a portrait area, wherein the portrait cutout model includes an end-to-end connection between a portrait detection network and a portrait segmentation network.
[0068] In an embodiment of the present invention, the standard image is input into a pre-built portrait cutout model to obtain a portrait background that separates the background from the portrait, wherein the portrait cutout model includes an end-to-end connection of a portrait detection network and a portrait segmentation network.
[0069] In an embodiment of the present invention, the portrait image is a picture obtained by cutting out the portrait after the portrait detection network detects the portrait. The portrait detection network in the pre-built portrait cutout model is used to detect the standard picture to detect the portrait contour and obtain the detected portrait image, wherein the portrait detection network includes: a convolution layer, a pooling layer, a fully connected layer and an activation function.
[0070] In detail, the detecting the standard image using the portrait detection network in the portrait cutout model to obtain the portrait image includes:
[0071] Using the convolutional layer in the portrait detection network to extract features from the standard image to obtain a feature image;
[0072] Using the pooling layer in the portrait detection network to perform a dimensionality reduction operation on the feature image to obtain a dimensionality reduced image;
[0073] Using the fully connected layer in the portrait detection network to fully connect the dimension reduction image to obtain a spliced portrait image;
[0074] The spliced portrait picture is outputted using the activation function in the portrait detection network to obtain a portrait picture.
[0075] In the embodiment of the present invention, the feature extraction is to obtain a feature picture by calculating the pixel matrix of the standard picture.
[0076] In one embodiment of the present invention, the pooling operation performed on the standard image using the pooling layer is to divide the feature image into average regions, and take the average value of the sum of all pixel values in the region to replace the pixel value in the region, so that the features extracted from the feature image will not be lost and a dimensionality reduction operation is performed.
[0077] Preferably, the activation function may be a ReLU function, which may activate the spliced portrait image to obtain the final detected portrait image containing portrait feature information.
[0078] In an embodiment of the present invention, the segmentation network in the portrait cutout model is used to segment the detected portrait image, thereby realizing portrait cutout and obtaining a portrait area, wherein the portrait segmentation network includes: a hole convolution layer, a pyramid pooling layer and an activation function.
[0079] Furthermore, the use of the portrait segmentation network in the portrait cutout model to segment the portrait image to obtain the portrait area includes:
[0080] Utilizing the hole convolution layer in the portrait segmentation network to extract features of the portrait image and perform feature fusion to obtain a fused portrait image;
[0081] Performing portrait segmentation on the fused portrait image using the pyramid pooling layer in the portrait segmentation network to obtain a segmented portrait image;
[0082] The segmented portrait image is input into the activation function in the portrait segmentation network to obtain the portrait area output by the activation function.
[0083] In the embodiment of the present invention, the atrous convolution layer has more special holes than the general convolution layer, and has a wider field of view, so that more global information of the image can be grasped through feature fusion when the feature image is reduced by the same multiple.
[0084] In one embodiment of the present invention, the pyramid pooling layer replaces the general pooling layer so that no matter what the size of the image input to the portrait segmentation network is, a segmented image with the same size will be output.
[0085] Preferably, the activation function may be a Sigmoid function, which may activate the segmented portrait image to obtain a portrait region where the background and the portrait are separated.
[0086] S3. Obtain a business card template and business card information, and determine whether the photo area in the business card template has a picture frame.
[0087] In the embodiment of the present invention, the business card template mainly includes a photo area and a business card information area.
[0088] In this embodiment, the business card template can be obtained from a preset business card template library. Business card information refers to the user's self-introduction information, including the user's name, phone number, company, position, and company address, etc. The business card information can be input by the user to the website or directly obtained from the corporate website.
[0089] In the embodiment of the present invention, a boosted edge learning algorithm (Boosted Edge Learning BEL) may be used to determine whether the photo area in the business card template has a frame.
[0090] S4. If the photo area in the business card template has a picture frame, the portrait area is laid out in the picture frame, and the business card information is laid out on the business card template to obtain a first portrait business card.
[0091] Specifically, if the photo area in the business card template has a picture frame, placing the portrait area in the picture frame includes:
[0092] If the photo area in the business card template has a frame, obtain the frame height, frame width and frame centerline of the frame;
[0093] The portrait area is scaled according to the picture frame height, the picture frame width and the picture frame center line, so that the portrait area height is consistent with the picture frame height, the portrait area width is consistent with the picture frame width, and the area center line is consistent with the picture frame center line, and the portrait area is arranged in the picture frame.
[0094] In the embodiment of the present invention, the height of the portrait area after scaling is consistent with the height of the picture frame, and the scaling ratio ratio=picture frame height box_h / portrait area height fore_h is obtained, and the scaling ratio ratio is used to calculate the width of the portrait area and the width of the picture frame, and then the center line of the scaled portrait area is compared and aligned with the center line of the picture frame, so that the portrait area is centered in the picture frame.
[0095] In the embodiment of the present invention, the first portrait business card refers to a business card in which the photo area in the business card is a business card with a picture frame.
[0096] In an embodiment of the present invention, the business card information can be laid out on the business card template according to the business card template. If the business card information is too long, it is wrapped according to a preset number of lines and laid out in the picture frame according to the portrait area to generate a first portrait business card.
[0097] S5. If the photo area in the business card template has no frame, layout the portrait area in the photo area, and layout the business card information in the business card template to obtain a second portrait business card.
[0098] In the embodiment of the present invention, in order to make the portrait area layout in the business card template without visual "abruptness" or "hanging" feeling, a business card template without a picture frame in the photo area can be selected.
[0099] In detail, if the photo area in the business card template has no picture frame, placing the portrait area in the photo area includes:
[0100] If the photo area in the business card template has no picture frame, obtaining the top edge value coordinates and the bottom edge value coordinates of the photo area;
[0101] After aligning the top edge of the portrait area with the top edge of the photo area by using the top edge value coordinates, the scaling ratio of the portrait area is calculated, and the bottom edge value of the portrait area is calculated according to the scaling ratio and the bottom edge value, so that the portrait area is laid out in the photo area.
[0102] In the embodiment of the present invention, the scaling ratio of the portrait area may be calculated using cascading style sheets technology, and the portrait area may be scaled according to the scaling ratio to obtain the portrait area aligned with the top and bottom edges of the photo area.
[0103] In the embodiment of the present invention, the second portrait business card refers to a business card in which the photo area in the business card template is without a frame.
[0104] In an embodiment of the present invention, the business card information can be laid out on the business card template according to the business card template. If the business card information is too long, it can be wrapped according to a preset number of lines, and a second portrait business card can be generated in the photo area according to the portrait area layout.
[0105] In the embodiment of the present invention, firstly, a standard image is obtained by performing a preprocessing operation on the user image to be identified. After the preprocessing operation, the details in the standard image can be more prominent, the image can be clearer, and the image quality can be higher; secondly, the features of the standard image are detected by using the portrait detection network in the pre-constructed portrait cutout model, and the detected portrait is cropped to obtain a portrait image; then, the portrait image is segmented by using the portrait segmentation network in the portrait cutout model, and the detected portrait image is segmented, thereby realizing portrait cutout and obtaining a portrait area; finally, according to the business card template, the business card information input by the user is laid out and the portrait area is laid out in the photo area in the business card template, so as to obtain a portrait business card, without the need for user adjustment, thereby improving the efficiency of portrait business card generation. Therefore, the portrait business card generation method proposed in the embodiment of the present invention can improve the efficiency of portrait business card generation.
[0106] like Figure 2 FIG. 1 is a functional module diagram of the device for generating a portrait business card according to the present invention.
[0107] The portrait business card generating device 100 of the present invention can be installed in an electronic device. According to the functions to be implemented, the portrait business card generating device can include a pre-processing operation module 101, a model cutout module 102, a picture frame judgment module 103, a first portrait business card generating module 104, and a second portrait business card generating module 105. The modules described in the present invention can also be referred to as units, which refer to a series of computer program segments that can be executed by an electronic device processor and can complete fixed functions, and are stored in the memory of the electronic device.
[0108] In this embodiment, the functions of each module / unit are as follows:
[0109] The preprocessing operation module 101 is used to obtain a user picture to be identified, and perform a preprocessing operation on the user picture to be identified to obtain a standard picture.
[0110] In the embodiment of the present invention, the user image to be identified is an image to be identified that includes a user portrait image. For example, the user image to be identified is an ID photo or a photo including a portrait taken by the user, and the user image to be identified can be obtained from a photo uploaded by the user.
[0111] In the embodiment of the present invention, by preprocessing the image, it is possible to avoid the shortcomings of grayscale, noise and insufficient contrast due to different acquisition environments (such as the degree of light illumination and the quality of equipment, etc.), and to avoid the problem of uncertain size and position of the portrait in the middle of the entire image due to different distances and focal lengths. Therefore, by preprocessing the image, the consistency of the size, position and quality of the portrait in the portrait image can be improved.
[0112] In detail, the preprocessing operation module 101 performs a preprocessing operation on the to-be-identified user image to obtain a standard image by performing the following operations, including:
[0113] Digitally process the user image to be identified to obtain a digital image;
[0114] Performing a histogram equalization operation on the digital image to obtain a balanced image;
[0115] Performing a sharpening and smoothing operation on the equalized image to obtain an enhanced image;
[0116] A normalization operation is performed on the enhanced image to obtain a standard image.
[0117] In the embodiment of the present invention, the digital processing is to perform grayscale sampling and quantization on the to-be-identified user image on an M x N dot matrix to obtain a digital image that can be processed by a computer.
[0118] In one embodiment of the present invention, performing the histogram equalization operation can convert the digital image into a balanced image having the same pixels at each gray level.
[0119] In an optional embodiment of the present invention, the LoG operator can be used to perform a sharpening operation on the equalized image to enhance the contour information in the image and highlight the detail changes of the image. However, the noise of the image after sharpening will be enhanced, so further smoothing processing is performed to eliminate the noise of the image without blurring the image contour or lines.
[0120] Preferably, the smoothing process may be performed by a median method.
[0121] In the embodiment of the present invention, the purpose of normalizing the enhanced image is to make the images taken under different conditions (such as light intensity, direction, distance, posture, etc.) consistent.
[0122] Furthermore, the normalizing operation is performed on the enhanced image to obtain a standard image, including:
[0123] Performing geometric normalization and grayscale normalization operations on the standard image to obtain a standard image.
[0124] In one embodiment of the present invention, the geometric normalization helps to correct the size difference and angle tilt caused by changes in imaging distance and changes in the posture of the portrait in the picture, and the grayscale normalization helps to compensate for the portrait in the picture obtained under different light intensities and light source directions.
[0125] The model cutout module 102 is used to input the standard image into a pre-built portrait cutout model, and use the portrait detection network in the portrait cutout model to detect the standard image to obtain a portrait image, and then use the portrait segmentation network in the portrait cutout model to segment the portrait image to obtain a portrait area, wherein the portrait cutout model includes an end-to-end connection between a portrait detection network and a portrait segmentation network.
[0126] In an embodiment of the present invention, the standard image is input into a pre-built portrait cutout model to obtain a portrait background that separates the background from the portrait, wherein the portrait cutout model includes an end-to-end connection of a portrait detection network and a portrait segmentation network.
[0127] In an embodiment of the present invention, the portrait image is a picture obtained by cutting out the portrait after the portrait detection network detects the portrait. The portrait detection network in the pre-built portrait cutout model is used to detect the standard picture to detect the portrait contour and obtain the detected portrait image, wherein the portrait detection network includes: a convolution layer, a pooling layer, a fully connected layer and an activation function.
[0128] In detail, the model cutout module 102 detects the standard image using the portrait detection network in the portrait cutout model to obtain a portrait image by performing the following operations, including:
[0129] Using the convolutional layer in the portrait detection network to extract features from the standard image to obtain a feature image;
[0130] Using the pooling layer in the portrait detection network to perform a dimensionality reduction operation on the feature image to obtain a dimensionality reduced image;
[0131] Using the fully connected layer in the portrait detection network to fully connect the dimension reduction image to obtain a spliced portrait image;
[0132] The spliced portrait picture is outputted using the activation function in the portrait detection network to obtain a portrait picture.
[0133] In the embodiment of the present invention, the feature extraction is to obtain a feature picture by calculating the pixel matrix of the standard picture.
[0134] In one embodiment of the present invention, the pooling operation performed on the standard image using the pooling layer is to divide the feature image into average regions, and take the average value of the sum of all pixel values in the region to replace the pixel value in the region, so that the features extracted from the feature image will not be lost and a dimensionality reduction operation is performed.
[0135] Preferably, the activation function may be a ReLU function, which may activate the spliced portrait image to obtain the final detected portrait image containing portrait feature information.
[0136] In an embodiment of the present invention, the segmentation network in the portrait cutout model is used to segment the detected portrait image, thereby realizing portrait cutout and obtaining a portrait area, wherein the portrait segmentation network includes: a hole convolution layer, a pyramid pooling layer and an activation function.
[0137] Furthermore, the model cutout module 102 segments the portrait image using the portrait segmentation network in the portrait cutout model to obtain the portrait area by performing the following operations, including:
[0138] Utilizing the hole convolution layer in the portrait segmentation network to extract features of the portrait image and perform feature fusion to obtain a fused portrait image;
[0139] Performing portrait segmentation on the fused portrait image using the pyramid pooling layer in the portrait segmentation network to obtain a segmented portrait image;
[0140] The segmented portrait image is input into the activation function in the portrait segmentation network to obtain the portrait area output by the activation function.
[0141] In the embodiment of the present invention, the atrous convolution layer has more special holes than the general convolution layer, and has a wider field of view, so that more global information of the image can be grasped through feature fusion when the feature image is reduced by the same multiple.
[0142] In one embodiment of the present invention, the pyramid pooling layer replaces the general pooling layer so that no matter what the size of the image input to the portrait segmentation network is, a segmented image with the same size will be output.
[0143] Preferably, the activation function may be a Sigmoid function, which may activate the segmented portrait image to obtain a portrait region where the background and the portrait are separated.
[0144] The picture frame determination module 103 is used to obtain a business card template and business card information, and determine whether there is a picture frame in the photo area of the business card template.
[0145] In the embodiment of the present invention, the business card template mainly includes a photo area and a business card information area.
[0146] In this embodiment, the business card template can be obtained from a preset business card template library. Business card information refers to the user's self-introduction information, including the user's name, phone number, company, position, and company address, etc. The business card information can be input by the user to the website or directly obtained from the corporate website.
[0147] In the embodiment of the present invention, a boosted edge learning algorithm (Boosted Edge Learning BEL) may be used to determine whether the photo area in the business card template has a frame.
[0148] The first portrait business card generating module 104 is used to layout the portrait area in the frame if there is a frame in the photo area in the business card template, and layout the business card information on the business card template to obtain a first portrait business card.
[0149] In detail, the first portrait business card generating module 104 arranges the portrait area in the frame by performing the following operations if the photo area in the business card template has a frame, including:
[0150] If the photo area in the business card template has a frame, obtain the frame height, frame width and frame centerline of the frame;
[0151] The portrait area is scaled according to the picture frame height, the picture frame width and the picture frame center line, so that the portrait area height is consistent with the picture frame height, the portrait area width is consistent with the picture frame width, and the area center line is consistent with the picture frame center line, and the portrait area is arranged in the picture frame.
[0152] In the embodiment of the present invention, the height of the portrait area after scaling is consistent with the height of the picture frame, and the scaling ratio ratio=picture frame height box_h / portrait area height fore_h is obtained, and the scaling ratio ratio is used to calculate the width of the portrait area and the width of the picture frame, and then the center line of the scaled portrait area is compared and aligned with the center line of the picture frame, so that the portrait area is centered in the picture frame.
[0153] In the embodiment of the present invention, the first portrait business card refers to a business card in which the photo area in the business card is a business card with a picture frame.
[0154] In an embodiment of the present invention, the business card information can be laid out on the business card template according to the business card template. If the business card information is too long, it is wrapped according to a preset number of lines and laid out in the picture frame according to the portrait area to generate a first portrait business card.
[0155] The second portrait business card generating module 105 is used to layout the portrait area in the photo area if there is no frame in the photo area in the business card template, and layout the business card information in the business card template to obtain a second portrait business card.
[0156] In the embodiment of the present invention, in order to make the portrait area layout in the business card template without visual "abruptness" or "hanging" feeling, a business card template without a picture frame in the photo area can be selected.
[0157] In detail, if the photo area in the business card template has no picture frame, placing the portrait area in the photo area includes:
[0158] If the photo area in the business card template has no picture frame, obtaining the top edge value coordinates and the bottom edge value coordinates of the photo area;
[0159] After aligning the top edge of the portrait area with the top edge of the photo area by using the top edge value coordinates, the scaling ratio of the portrait area is calculated, and the bottom edge value of the portrait area is calculated according to the scaling ratio and the bottom edge value, so that the portrait area is laid out in the photo area.
[0160] In the embodiment of the present invention, the scaling ratio of the portrait area may be calculated using cascading style sheets technology, and the portrait area may be scaled according to the scaling ratio to obtain the portrait area aligned with the top and bottom edges of the photo area.
[0161] In the embodiment of the present invention, the second portrait business card refers to a business card in which the photo area in the business card template is without a frame.
[0162] In an embodiment of the present invention, the business card information can be laid out on the business card template according to the business card template. If the business card information is too long, it can be wrapped according to a preset number of lines, and a second portrait business card can be generated in the photo area according to the portrait area layout.
[0163] In the embodiment of the present invention, firstly, a preprocessing operation is performed on the user image to be identified to obtain a standard image. After the preprocessing operation, the details in the standard image can be more prominent, the image can be clearer, and the image quality can be higher; secondly, the features of the standard image are detected using the portrait detection network in the pre-constructed portrait cutout model, and the detected portrait is cropped to obtain a portrait image; then, the portrait image is segmented using the portrait segmentation network in the portrait cutout model, and the detected portrait image is segmented, thereby realizing portrait cutout and obtaining a portrait area; finally, according to the business card template, the business card information input by the user and the portrait area are laid out in the photo area in the business card template to obtain a portrait business card, without the need for user adjustment, thereby improving the efficiency of portrait business card generation. Therefore, the portrait business card generation device proposed in the embodiment of the present invention can improve the efficiency of portrait business card generation.
[0164] like Figure 3 FIG. 1 is a schematic diagram of the structure of an electronic device for implementing the method for generating a portrait business card according to the present invention.
[0165] The electronic device may include a processor 10, a memory 11, a communication bus 12 and a communication interface 13, and may also include a computer program stored in the memory 11 and executable on the processor 10, such as a portrait business card generation program.
[0166] Wherein, the memory 11 includes at least one type of medium, and the medium includes flash memory, mobile hard disk, multimedia card, card-type memory (for example: SD or DX memory, etc.), magnetic memory, local disk, optical disk, etc. The memory 11 may be an internal storage unit of an electronic device in some embodiments, such as a mobile hard disk of the electronic device. The memory 11 may also be an external storage device of an electronic device in other embodiments, such as a plug-in mobile hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device. Further, the memory 11 may also include both an internal storage unit of the electronic device and an external storage device. The memory 11 may not only be used to store application software and various types of data installed in the electronic device, such as the code of a portrait business card generation program, but also be used to temporarily store data that has been output or is to be output.
[0167] The processor 10 may be composed of an integrated circuit in some embodiments, for example, a single packaged integrated circuit, or a plurality of packaged integrated circuits with the same or different functions, including one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and combinations of various control chips, etc. The processor 10 is the control core (Control Unit) of the electronic device, and uses various interfaces and lines to connect various components of the entire electronic device, and executes or executes programs or modules (such as a portrait business card generation program, etc.) stored in the memory 11, and calls data stored in the memory 11 to execute various functions of the electronic device and process data.
[0168] The communication bus 12 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. The communication bus 12 is configured to realize connection and communication between the memory 11 and at least one processor 10, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0169] Figure 3 Only an electronic device with components is shown, and those skilled in the art will understand that Figure 3 The structure shown does not constitute a limitation on the electronic device, and may include fewer or more components than shown in the figure, or combine certain components, or arrange the components differently.
[0170] For example, although not shown, the electronic device may also include a power source (such as a battery) for supplying power to each component. Preferably, the power source may be logically connected to the at least one processor 10 through a power management device, so that the power management device can realize functions such as charging management, discharging management, and power consumption management. The power source may also include one or more DC or AC power sources, recharging devices, power failure detection circuits, power converters or inverters, power status indicators, and other arbitrary components. The electronic device may also include a variety of sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be repeated here.
[0171] Optionally, the communication interface 13 may include a wired interface and / or a wireless interface (such as a WI-FI interface, a Bluetooth interface, etc.), which is generally used to establish a communication connection between the electronic device and other electronic devices.
[0172] Optionally, the communication interface 13 may also include a user interface, which may be a display, an input unit (such as a keyboard), or a standard wired interface or a wireless interface. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, and an OLED (Organic Light-Emitting Diode) touch device. The display may also be appropriately referred to as a display screen or a display unit, which is used to display information processed in the electronic device and to display a visual user interface.
[0173] It should be understood that the embodiment is for illustration only and the scope of the patent application is not limited to this structure.
[0174] The portrait business card generation program stored in the memory 11 of the electronic device is a combination of multiple computer programs. When running in the processor 10, it can achieve:
[0175] Obtain a user image to be identified, and perform a preprocessing operation on the user image to be identified to obtain a standard image;
[0176] Input the standard image into a pre-built portrait cutout model, and use the portrait detection network in the portrait cutout model to detect the standard image to obtain a portrait image, and then use the portrait segmentation network in the portrait cutout model to segment the portrait image to obtain a portrait area, wherein the portrait cutout model includes an end-to-end connection of a portrait detection network and a portrait segmentation network;
[0177] Obtaining a business card template and business card information, and determining whether a photo area in the business card template has a picture frame;
[0178] If the photo area in the business card template has a picture frame, the portrait area is arranged in the picture frame, and the business card information is arranged on the business card template to obtain a first portrait business card;
[0179] If the photo area in the business card template has no frame, the portrait area is laid out in the photo area, and the business card information is laid out in the business card template to obtain a second portrait business card.
[0180] Specifically, the specific implementation method of the processor 10 for the above computer program can refer to Figure 1 The description of the relevant steps in the corresponding embodiments will not be repeated here.
[0181] Furthermore, if the module / unit integrated in the electronic device is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable medium. The computer-readable medium can be non-volatile or volatile. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM).
[0182] The embodiment of the present invention may further provide a computer medium, wherein the medium stores a computer program, and when the computer program is executed by a processor of an electronic device, the computer program may implement:
[0183] Obtain a user image to be identified, and perform a preprocessing operation on the user image to be identified to obtain a standard image;
[0184] Input the standard image into a pre-built portrait cutout model, and use the portrait detection network in the portrait cutout model to detect the standard image to obtain a portrait image, and then use the portrait segmentation network in the portrait cutout model to segment the portrait image to obtain a portrait area, wherein the portrait cutout model includes an end-to-end connection of a portrait detection network and a portrait segmentation network;
[0185] Obtaining a business card template and business card information, and determining whether a photo area in the business card template has a picture frame;
[0186] If the photo area in the business card template has a picture frame, the portrait area is arranged in the picture frame, and the business card information is arranged on the business card template to obtain a first portrait business card;
[0187] If the photo area in the business card template has no frame, the portrait area is laid out in the photo area, and the business card information is laid out in the business card template to obtain a second portrait business card.
[0188] Furthermore, the computer-usable medium may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function, etc.; the data storage area may store data created according to the use of the blockchain node, etc.
[0189] In the several embodiments provided by the present invention, it should be understood that the disclosed devices, apparatuses and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of the modules is only a logical function division, and there may be other division methods in actual implementation.
[0190] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0191] In addition, each functional module in each embodiment of the present invention may be integrated into one processing unit, each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional modules.
[0192] It is obvious to those skilled in the art that the present invention is not limited to the details of the above exemplary embodiments, and that the present invention can be implemented in other specific forms without departing from the spirit or essential characteristics of the present invention.
[0193] Therefore, no matter from which point of view, the embodiments should be regarded as illustrative and non-restrictive, and the scope of the present invention is limited by the appended claims rather than the above description, so it is intended that all changes falling within the meaning and scope of the equivalent elements of the claims are included in the present invention. Any attached figure mark in the claims should not be regarded as limiting the claims involved.
[0194] The blockchain referred to in this invention is a new application mode of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, platform product service layer, and application service layer.
[0195] In addition, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices stated in the system claim can also be implemented by one unit or device through software or hardware. The second and other words are used to indicate names, but not to indicate any particular order.
[0196] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solution of the present invention can be modified or replaced by equivalents without departing from the spirit and scope of the technical solution of the present invention.
Claims
1. A method for generating a portrait business card, characterized in that: The method comprises: Obtain a user image to be identified, and perform a preprocessing operation on the user image to be identified to obtain a standard image; The standard image is input into a pre-built portrait cutout model, and the portrait detection network in the portrait cutout model is used to detect the standard image, the convolution layer in the portrait detection network is used to extract features of the standard image to obtain a feature image, the pooling layer in the portrait detection network is used to reduce the dimension of the feature image to obtain a reduced dimension image, the fully connected layer in the portrait detection network is used to fully connect the reduced dimension image to obtain a spliced portrait image, and the activation function in the portrait detection network is used to output the spliced portrait image to obtain a portrait image. , then use the portrait segmentation network in the portrait cutout model to segment the portrait picture, use the hole convolution layer in the portrait segmentation network to extract the features of the portrait picture and perform feature fusion to obtain a fused portrait picture, use the pyramid pooling layer in the portrait segmentation network to perform portrait segmentation on the fused portrait picture to obtain a segmented portrait picture, input the segmented portrait picture into the activation function in the portrait segmentation network, and obtain the portrait region output by the activation function, wherein the portrait cutout model includes an end-to-end connection between a portrait detection network and a portrait segmentation network; Obtaining a business card template and business card information, and determining whether a photo area in the business card template has a picture frame; If the photo area in the business card template has a frame, obtain the frame height, frame width and frame midline of the frame, perform a scaling operation on the portrait area according to the frame height, frame width and frame midline, so that the portrait area height is consistent with the frame height, the portrait area width is consistent with the frame width, and the region midline is consistent with the frame midline, and the portrait area is laid out in the frame, and the business card information is laid out on the business card template to obtain a first portrait business card; If the photo area in the business card template has no frame, obtain the top edge value coordinates and the bottom edge value coordinates of the photo area, align the top edge of the portrait area with the top edge of the photo area by using the top edge value coordinates, calculate the scaling ratio of the portrait area, calculate the bottom edge value of the portrait area according to the scaling ratio and the bottom edge value, so that the portrait area is laid out in the photo area, and the business card information is laid out in the business card template. If the business card information exceeds the preset length, wrap it according to the preset specified number of lines to obtain a second portrait business card.
2. The method for generating a portrait business card according to claim 1, wherein: The preprocessing operation is performed on the user image to be identified to obtain a standard image, including: Digitally process the user image to be identified to obtain a digital image; Performing a histogram equalization operation on the digital image to obtain a balanced image; Performing a sharpening and smoothing operation on the equalized image to obtain an enhanced image; A normalization operation is performed on the enhanced image to obtain a standard image.
3. The method for generating a portrait business card according to claim 2, wherein: The step of performing a normalization operation on the enhanced image to obtain a standard image includes: Performing geometric normalization and grayscale normalization operations on the standard image to obtain a standard image.
4. A device for generating a portrait business card, characterized in that: include: A preprocessing operation module is used to obtain a user picture to be identified, and perform a preprocessing operation on the user picture to be identified to obtain a standard picture; The model cutout module is used to input the standard image into a pre-built portrait cutout model, and use the portrait detection network in the portrait cutout model to detect the standard image, use the convolution layer in the portrait detection network to extract features of the standard image to obtain a feature image, use the pooling layer in the portrait detection network to reduce the dimension of the feature image to obtain a reduced dimension image, use the fully connected layer in the portrait detection network to fully connect the reduced dimension image to obtain a spliced portrait image, and use the activation function in the portrait detection network to output the spliced portrait image to obtain A portrait picture, segmenting the portrait picture using a portrait segmentation network in the portrait cutout model, extracting features of the portrait picture using a hole convolution layer in the portrait segmentation network and performing feature fusion to obtain a fused portrait picture, performing portrait segmentation on the fused portrait picture using a pyramid pooling layer in the portrait segmentation network to obtain a segmented portrait picture, inputting the segmented portrait picture into an activation function in the portrait segmentation network to obtain a portrait region output by the activation function, wherein the portrait cutout model includes an end-to-end connection of a portrait detection network and a portrait segmentation network; A picture frame determination module, used to obtain a business card template and business card information, and determine whether a photo area in the business card template has a picture frame; A first portrait business card generation module is used for obtaining a frame height, a frame width and a frame midline of the frame if the photo area in the business card template has a frame, scaling the portrait area according to the frame height, the frame width and the frame midline so that the portrait area height is consistent with the frame height, the portrait area width is consistent with the frame width and the region midline is consistent with the frame midline, and the portrait area is laid out in the frame, and the business card information is laid out on the business card template to obtain a first portrait business card; The second portrait business card generation module is used to obtain the top edge value coordinates and the bottom edge value coordinates of the photo area if there is no picture frame in the photo area in the business card template, and after aligning the top edge of the portrait area with the top edge of the photo area by using the top edge value coordinates, calculate the scaling ratio of the portrait area, calculate the bottom edge value of the portrait area according to the scaling ratio and the bottom edge value, so that the portrait area is laid out in the photo area, and lay out the business card information in the business card template; if the business card information exceeds the preset length, wrap it according to the preset specified number of lines to obtain the second portrait business card.
5. An electronic device, characterized in that: The electronic device comprises: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores computer program instructions that can be executed by the at least one processor, and the computer program instructions are executed by the at least one processor so that the at least one processor can execute the method for generating a portrait business card according to any one of claims 1 to 3.
6. A computer medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method for generating a portrait business card according to any one of claims 1 to 3 is implemented.
