CN111832269B - Self-adaptive user head portrait filling method and system - Google Patents

Self-adaptive user head portrait filling method and system Download PDF

Info

Publication number
CN111832269B
CN111832269B CN202010991569.4A CN202010991569A CN111832269B CN 111832269 B CN111832269 B CN 111832269B CN 202010991569 A CN202010991569 A CN 202010991569A CN 111832269 B CN111832269 B CN 111832269B
Authority
CN
China
Prior art keywords
picture
user
head portrait
filling
avatar
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
CN202010991569.4A
Other languages
Chinese (zh)
Other versions
CN111832269A (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.)
Hunan Weichu Youcai Education Technology Co ltd
Original Assignee
Hunan Weichu Youcai Education Technology 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 Hunan Weichu Youcai Education Technology Co ltd filed Critical Hunan Weichu Youcai Education Technology Co ltd
Priority to CN202010991569.4A priority Critical patent/CN111832269B/en
Publication of CN111832269A publication Critical patent/CN111832269A/en
Application granted granted Critical
Publication of CN111832269B publication Critical patent/CN111832269B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/166Editing, e.g. inserting or deleting
    • G06F40/174Form filling; Merging
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/103Formatting, i.e. changing of presentation of documents
    • G06F40/106Display of layout of documents; Previewing

Abstract

The invention provides a self-adaptive user head portrait filling method and a self-adaptive user head portrait filling system. If the user head portrait address is not empty, judging whether a picture is cached or not, if so, filling the user head portrait by adopting the cached picture, if not, requesting the picture of the user head portrait address, if the request fails, judging whether a user name parameter is transmitted, if so, generating a character picture based on the user name parameter and filling the user head portrait by adopting the character picture, and if not, filling the user head portrait by adopting a default head portrait picture; and if the request is successful, caching the requested picture into the memory. And if the user head portrait address is empty, judging whether the user name returned by the interface is empty, if the user head portrait address is empty, filling the user head portrait by adopting a default head portrait picture, and if the user head portrait address is not empty, filling the user head portrait by adopting a character picture. The invention realizes the self-adaptive filling of the user head portrait and improves the user experience.

Description

Self-adaptive user head portrait filling method and system
Technical Field
The invention relates to the technical field of image processing, in particular to a method and a system for filling a self-adaptive user head portrait.
Background
With the development and popularization of the internet, users use various application programs App every day. In general, when registering a user as a certain App, it is necessary to set information such as a nickname, a head portrait, a mail address, and hobbies. Taking an instant messaging App as an example, when a new user registers, the new user needs to fill in the basic information of the new user and upload a user head portrait representing the virtual image of the new user. The user head portrait not only can play a role in identifying the user, but also can display the online or offline state of the user.
When setting up the head portrait, the user needs to browse the pictures in the photo album one by one, and find out the pictures suitable for making the head portrait according to the preference of the user. However, if the number of pictures stored in the album is large, the user takes a lot of time to search, and the searched pictures may not be set as the avatar due to an oversize or an unsatisfactory format; and if the user does not want to set the head portrait due to the complicated operation process, the discordant default head portrait has no diversity and can reduce the enjoyment of the user in using the APP.
Therefore, the cumbersome process of setting up the avatar affects the user experience.
Disclosure of Invention
In order to solve at least one technical problem, the invention provides an adaptive user avatar filling method and system.
In order to achieve the above object, a first aspect of the present invention provides an adaptive user avatar filling method, including:
step 1, judging whether a user head portrait address returned by an interface is empty, if not, entering step 2, and if so, entering step 7;
step 2, judging whether a picture is stored in a cache or not, if so, filling the head portrait of the user by using the picture in the cache, and if not, entering step 3;
step 3, requesting a picture of the head portrait address of the user, entering step 4 if the request fails, and entering step 5 if the request succeeds;
step 4, judging whether a user name parameter is transmitted, if a user name is available, entering step 6, and if no user name is available, entering step 8;
step 5, caching the pictures which are successfully requested in the memory by adopting a picture caching method, and returning to the step 2;
step 6, generating a corresponding character picture based on the user name parameters and by combining with a head portrait picture generation algorithm, and filling the head portrait of the user by adopting the generated character picture;
step 7, judging whether the user name returned by the interface is empty, if so, entering step 8, and if not, returning to step 6;
and 8, filling the head portrait of the user by adopting a default head portrait picture.
Further, the avatar image generation algorithm in step 6 specifically includes:
step 6-1, defining several colors as randomly used ground colors, carrying out hash calculation on a character string of a user name parameter to obtain a corresponding hash value, and dividing the hash value by an absolute value obtained by the balance of the number of the colors to determine the color corresponding to the character string;
6-2, drawing a pure color picture corresponding to the color;
and 6-3, drawing a text to be displayed in the center of the pure color picture, wherein the text to be displayed follows the screening rule of the displayed text.
Further, the step 6-3 specifically includes:
when a text needing to be displayed is drawn in a pure-color picture, 2D image rendering is carried out by UIGramics, a UIGraphic BeginImageContextWithOptions function is called to obtain a graphic context for processing the picture, the graphic context is utilized to carry out text drawing on the pure-color picture and generate a character picture;
and after the drawing operation is finished, calling a UIGraphicsEndImageContext function to close the graphic context.
Further, the screening rule of the display text is specifically characterized in that:
if the character string of the user name parameter contains letters, the first two characters in the character string are taken for display;
if the character string of the user name parameter does not contain letters, if the length of the character string is 1, one character is taken for display; if the length of the character string is 2, two characters are taken for display; if the length of the character string is 3 or 4, the last two characters are taken out for display; and if the length of the character string exceeds 4, taking the first two characters for display.
Further, the picture caching method in step 5 specifically includes:
step 5-1, loading pictures through UIImageView + WebCache class, displaying a default picture placeholdImage at an entrance setImageWithURL in options, and then processing the pictures according to the URL by an SDWebImageManager class;
step 5-2, entering a downloadWithURL of delegat: options: userInfo in the SDWebImageManager class, and searching whether the picture has downloaded a queryDiskCacheForKey of delegat: userInfo from a cache by an SDImageCache class;
step 5-3, whether a picture exists is searched from a memory cache, if the picture cache exists in the memory, the SDImageCacheDelegate calls back the ImageCache, wherein the rdFindeImage is forKey, and userInfo is in an SDWebImageManager class;
step 5-4, the SDWebImageManageRegelate calls back the webImageManager that didFinishWithImage is in UIImageView + WebCache class to wait for the front end to display the picture;
step 5-5, if the picture cache does not exist in the memory, generating 'NSoperation' to be added into the task queue, and starting to search whether the picture is cached from the hard disk;
5-6, trying to read the picture file under the hard disk cache directory according to the MD5 value Key of the URL;
and 5-7, if the picture is read from the hard disk, adding the picture into a memory cache, and sending a direct File image, a forKey and a userInfo from the SDImageDecheDelegate to the UIImageView + Webcache class to wait for the front-end to display the picture.
Further, after the above steps 5-6, the method further comprises:
step 5-8, if the picture can not be read from the hard disk cache directory, the picture does not exist in the internal memory and the hard disk cache, and the picture is required to be downloaded, and the picture cache is called back to the universal file format key and the userInfo;
step 5-9, sharing or regenerating a downloader SDWebImageDownloader and starting to download the picture;
step 5-10, after the picture is downloaded completely, the picture is delivered to an SDWebImageDecoder for picture decoding processing, and the image Decoder recalls the direct FinishDecodingImage and userInfo to the SDWebImageDownloader to declare that the decoding is completed;
5-11, calling back the image Downloader and the didFinishWithimage to the SDWebImageManager to inform the completion of the downloading of the image;
step 5-12, all downloadDelegates are informed of the completion of downloading, and the download is called back to a required place to display pictures;
and 5-13, storing the pictures into an SDImageCache class to wait for the front-end display of the pictures, and simultaneously storing the pictures in a memory cache and a hard disk cache respectively.
Further, step 8 specifically includes:
estimating the favorite range of the user based on the information content filled in during the registration of the user;
traversing the preference range of the user through all default avatar pictures in the default avatar picture library, and selecting the default avatar picture closest to the preference range of the user from the library;
and filling the head portrait of the user by adopting the selected default head portrait picture.
Further, the step 2 specifically includes:
presetting that a user head portrait filling area is square, a picture is rectangular, comparing the size of the picture with the size of the user head portrait filling area, and if the size of the short edge of the picture is larger than the size of the side of the user head portrait filling area, reducing the picture until the size of the short edge of the picture is equal to the size of the side of the user head portrait filling area; if the short side size of the picture is smaller than the side size of the user head portrait filling area, the picture is enlarged until the short side size of the picture is equal to the side size of the user head portrait filling area;
respectively corresponding two long edges of the picture to two opposite edges of a user head portrait filling area, carrying out image recognition on the picture, and marking each area in the picture according to a preset classification label;
and according to the priorities of different classification labels, cutting the picture along the direction vertical to the long edge of the picture until the size of the cut residual picture is adapted to the head portrait filling area of the user.
The second aspect of the present invention is also directed to an adaptive user avatar filling system, including: a memory and a processor, wherein the memory includes a program of an adaptive user avatar filling method, and the program of the adaptive user avatar filling method when executed by the processor implements the steps of the adaptive user avatar filling method as described above.
The third aspect of the present invention further provides a computer-readable storage medium, which includes a program of an adaptive user avatar filling method, and when the program of the adaptive user avatar filling method is executed by a processor, the steps of the adaptive user avatar filling method are implemented.
The invention can realize the self-adaptive filling of the user head portrait, replaces the traditional manual filling mode of the user, reduces the complexity of setting the user head portrait and further improves the experience of the user.
Additional aspects and advantages of the invention will be set forth in part in the description which follows and, in part, will be obvious from the description, or may be learned by practice of the invention.
Drawings
FIG. 1 is a flow chart illustrating an adaptive user avatar filling method of the present invention;
FIG. 2 is a block diagram of an adaptive user avatar stuffing system of the present invention.
Detailed Description
In order that the above objects, features and advantages of the present invention can be more clearly understood, a more particular description of the invention will be rendered by reference to the appended drawings. It should be noted that the embodiments and features of the embodiments of the present application may be combined with each other without conflict.
In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present invention, however, the present invention may be practiced in other ways than those specifically described herein, and therefore the scope of the present invention is not limited by the specific embodiments disclosed below.
FIG. 1 is a flow chart illustrating an adaptive user avatar filling method of the present invention.
As shown in fig. 1, a first aspect of the present invention provides an adaptive user avatar filling method, where the method includes:
step 1, judging whether a user head portrait address returned by an interface is empty, if not, entering step 2, and if so, entering step 7;
step 2, judging whether a picture is stored in a cache or not, if so, filling the head portrait of the user by using the picture in the cache, and if not, entering step 3;
step 3, requesting a picture of the head portrait address of the user, entering step 4 if the request fails, and entering step 5 if the request succeeds;
step 4, judging whether a user name parameter is transmitted, if a user name is available, entering step 6, and if no user name is available, entering step 8;
step 5, caching the pictures which are successfully requested in the memory by adopting a picture caching method, and returning to the step 2;
step 6, generating a corresponding character picture based on the user name parameters and by combining with a head portrait picture generation algorithm, and filling the head portrait of the user by adopting the generated character picture;
step 7, judging whether the user name returned by the interface is empty, if so, entering step 8, and if not, returning to step 6;
and 8, filling the head portrait of the user by adopting a default head portrait picture.
It should be noted that the present invention mainly uses three data: a user avatar address, a user name parameter and a default avatar picture;
user head portrait address: the user head portrait address returned by the interface;
user name parameters: the user name returned by the interface;
default avatar picture: the head image is recognized by default.
According to an embodiment of the present invention, the avatar picture generation algorithm of step 6 specifically includes:
step 6-1, defining several colors as randomly used ground colors, carrying out hash calculation on a character string of a user name parameter to obtain a corresponding hash value, and dividing the hash value by an absolute value obtained by the balance of the number of the colors to determine the color corresponding to the character string;
6-2, drawing a pure color picture corresponding to the color;
and 6-3, drawing a text to be displayed in the center of the pure color picture, wherein the text to be displayed follows the screening rule of the displayed text.
According to an embodiment of the present invention, the step 6-3 specifically includes:
when a text needing to be displayed is drawn in a pure-color picture, 2D image rendering is carried out by UIGramics, a UIGraphic BeginImageContextWithOptions function is called to obtain a graphic context for processing the picture, the graphic context is utilized to carry out text drawing on the pure-color picture and generate a character picture;
and after the drawing operation is finished, calling a UIGraphicsEndImageContext function to close the graphic context.
According to the embodiment of the invention, the screening rule of the display text is characterized in that:
if the character string of the user name parameter contains letters, the first two characters in the character string are taken for display;
if the character string of the user name parameter does not contain letters, if the length of the character string is 1, one character is taken for display; if the length of the character string is 2, two characters are taken for display; if the length of the character string is 3 or 4, the last two characters are taken out for display; and if the length of the character string exceeds 4, taking the first two characters for display.
According to an embodiment of the present invention, the picture caching method in step 5 specifically includes:
step 5-1, loading pictures through UIImageView + WebCache class, displaying a default picture placeholdImage at an entrance setImageWithURL in options, and then processing the pictures according to the URL by an SDWebImageManager class;
step 5-2, entering a downloadWithURL of delegat: options: userInfo in the SDWebImageManager class, and searching whether the picture has downloaded a queryDiskCacheForKey of delegat: userInfo from a cache by an SDImageCache class;
step 5-3, whether a picture exists is searched from a memory cache, if the picture cache exists in the memory, the SDImageCacheDelegate calls back the ImageCache, wherein the rdFindeImage is forKey, and userInfo is in an SDWebImageManager class;
step 5-4, the SDWebImageManageRegelate calls back the webImageManager that didFinishWithImage is in UIImageView + WebCache class to wait for the front end to display the picture;
step 5-5, if the picture cache does not exist in the memory, generating 'NSoperation' to be added into the task queue, and starting to search whether the picture is cached from the hard disk;
5-6, trying to read the picture file under the hard disk cache directory according to the MD5 value Key of the URL;
and 5-7, if the picture is read from the hard disk, adding the picture into a memory cache, and sending a direct File image, a forKey and a userInfo from the SDImageDecheDelegate to the UIImageView + Webcache class to wait for the front-end to display the picture.
It should be noted that, since the above-mentioned step 5-6 is performed in NSoperation, the result callback notifyDelegate is performed back to the main thread. In the above step 5-7, if the free memory is too small, the memory cache may be cleared first, and then the picture is added to the memory cache.
According to an embodiment of the present invention, after the above-mentioned steps 5-6, the method further comprises:
step 5-8, if the picture can not be read from the hard disk cache directory, the picture does not exist in the internal memory and the hard disk cache, and the picture is required to be downloaded, and the picture cache is called back to the universal file format key and the userInfo;
step 5-9, sharing or regenerating a downloader SDWebImageDownloader and starting to download the picture;
step 5-10, after the picture is downloaded completely, the picture is delivered to an SDWebImageDecoder for picture decoding processing, and the image Decoder recalls the direct FinishDecodingImage and userInfo to the SDWebImageDownloader to declare that the decoding is completed;
5-11, calling back the image Downloader and the didFinishWithimage to the SDWebImageManager to inform the completion of the downloading of the image;
step 5-12, all downloadDelegates are informed of the completion of downloading, and the download is called back to a required place to display pictures;
and 5-13, storing the pictures into an SDImageCache class to wait for the front-end display of the pictures, and simultaneously storing the pictures in a memory cache and a hard disk cache respectively.
It should be noted that the picture downloading of the present invention can be performed by nservlconnection, and the related pointer delete is implemented to determine the states of the picture downloading, the downloading completion, the downloading failure, and the like. And in the connection, didReceiveData, the effect of loading according to the downloading progress of the picture is realized by using ImageIO. And (4) connecting DidFinishLoading, namely after the data is downloaded, delivering the data to an SDWebImageDecoder for picture decoding processing. The picture decoding process is completed in one NSOperationQueue and does not slow down the main thread UI. If the downloaded pictures need to be processed for the second time, the processing is preferably finished at the moment, and the processing efficiency can be effectively improved. In the main thread notifyDelegateOnMainThreadWithInfo, the decoding completion imageDecoder is declared, the DFinishDecodingImage, userInfo, and the call is returned to the SDWebImageDownloader. The image download loader, didFinishWithImage, and the callback informs the SDWebImagemanager that the picture download is completed. And informing all downloadDelegates of finishing downloading, and calling back to the required place to display the picture. And storing the picture in an SDImageCache, and simultaneously storing the memory cache and the hard disk cache. Writing files to the hard disk is also done with a separate NSoperation, avoiding dragging the main thread. The SDImageCache registers some message notifications during initialization, clears memory picture cache when a memory warns or falls back to a background, and clears expired pictures when application is finished.
It should be noted that the image Cache of the present invention adopts a Memory and Disk dual Cache mechanism, that is, a second level Cache. Caching the picture in the internal memory after the first request is carried out for loading the picture, encrypting the URL of the picture through MD5, and storing the picture in the hard disk by taking the value after the encryption as a key. When the picture is loaded again, the picture is firstly searched in the memory cache, if the picture cannot be found in the memory, the picture is searched in the default hard disk, and if the picture cannot be found, the picture is requested to be loaded again.
The invention preferably adopts an SDWebImage picture caching frame which provides a UIImageView + WebCache classification of UIImageView and is used for loading and caching picture resources transmitted through HTTP. The functions of cache management, asynchronous downloading, cache verification and the like are provided. It can be understood that the SDWebImage picture caching frame includes, in addition to the top UIImageView + WebCache class, a middle SDWebImageManager class, and a bottom SDImageCache class and an SDWebImageDownloader downloader.
The UIImageView + WebCache class at the uppermost layer can provide the following methods for loading network pictures and other operations:
sd_setImageWithURL:
sd_setImageWithURL: completed:
sd_setImageWithURL: placeholderImage:
sd_setImageWithURL: placeholderImage: completed:
sd_setImageWithURL: placeholderImage: options:。
according to an embodiment of the present invention, step 8 specifically includes:
estimating the favorite range of the user based on the information content filled in during the registration of the user;
traversing the preference range of the user through all default avatar pictures in the default avatar picture library, and selecting the default avatar picture closest to the preference range of the user from the library;
and filling the head portrait of the user by adopting the selected default head portrait picture.
It can be understood that the invention can prepare various types of default avatar pictures in advance, such as default avatar pictures of scenic class, default avatar pictures of animal class, default avatar pictures of people and stars class, etc.; at the early stage, when the user registers an account, the user may be required to fill out preference information in the corresponding field, such as: the favorite color, favorite characters, favorite animals and the like of the user are set, the favorite range of the user can be estimated according to the information filled in by the user, and the corresponding default head portrait picture is adapted according to the favorite range of the user, so that the head portrait picture suitable for the user can be conveniently and adaptively selected, and the experience of the user is effectively enhanced.
Meanwhile, the invention is provided with a plurality of default head portrait pictures for selection, thereby avoiding the possibility of consistent head portraits of different users to a certain extent and further enhancing the identification degrees of different users.
According to an embodiment of the present invention, step 2 specifically includes:
presetting that a user head portrait filling area is square, a picture is rectangular, comparing the size of the picture with the size of the user head portrait filling area, and if the size of the short edge of the picture is larger than the size of the side of the user head portrait filling area, reducing the picture until the size of the short edge of the picture is equal to the size of the side of the user head portrait filling area; if the short side size of the picture is smaller than the side size of the user head portrait filling area, the picture is enlarged until the short side size of the picture is equal to the side size of the user head portrait filling area;
respectively corresponding two long edges of the picture to two opposite edges of a user head portrait filling area, carrying out image recognition on the picture, and marking each area in the picture according to a preset classification label;
and according to the priorities of different classification labels, cutting the picture along the direction vertical to the long edge of the picture until the size of the cut residual picture is adapted to the head portrait filling area of the user.
Specifically, when the picture is a person, the picture may be classified and labeled at various positions in the picture, such as the head, the upper body of the person, the lower body of the person, the ground, and the like. When the picture is cut, the region with the classification label as the ground can be cut out preferentially, if the cut picture can not be matched with the head portrait filling region of the user, the region with the classification label as the lower half of the person can be cut out continuously until the size of the picture left after cutting is matched with the head portrait filling region of the user. The invention can adapt the pictures with various sizes to the user head portrait filling area, and can ensure that the filled user head portrait picture keeps the same focus point as the original picture, thereby avoiding damaging the characteristics and aesthetic feeling of the original picture.
FIG. 2 is a block diagram of an adaptive user avatar stuffing system of the present invention.
As shown in fig. 2, the second aspect of the present invention further provides an adaptive user avatar filling system, which includes: a memory and a processor, wherein the memory includes a program of an adaptive user avatar filling method, and the program of the adaptive user avatar filling method when executed by the processor implements the steps of the adaptive user avatar filling method as described above.
The third aspect of the present invention further provides a computer-readable storage medium, which includes a program of an adaptive user avatar filling method, and when the program of the adaptive user avatar filling method is executed by a processor, the steps of the adaptive user avatar filling method are implemented.
The invention can realize the self-adaptive filling of the user head portrait, replaces the traditional manual filling mode of the user, reduces the complexity of setting the user head portrait and further improves the experience of the user.
In the several embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. The above-described device embodiments are merely illustrative, for example, the division of the unit is only a logical functional division, and there may be other division ways in actual implementation, such as: multiple units or components may be combined, or may be integrated into another system, or some features may be omitted, or not implemented. In addition, the coupling, direct coupling or communication connection between the components shown or discussed may be through some interfaces, and the indirect coupling or communication connection between the devices or units may be electrical, mechanical or other forms.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units; can be located in one place or distributed on a plurality of network units; some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, all the functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may be separately regarded as one unit, or two or more units may be integrated into one unit; the integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional unit.
Those of ordinary skill in the art will understand that: all or part of the steps for realizing the method embodiments can be completed by hardware related to program instructions, the program can be stored in a computer readable storage medium, and the program executes the steps comprising the method embodiments when executed; and the aforementioned storage medium includes: a mobile storage device, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
Alternatively, the integrated unit of the present invention may be stored in a computer-readable storage medium if it is implemented in the form of a software functional module and sold or used as a separate product. Based on such understanding, the technical solutions of the embodiments of the present invention may be essentially implemented or a part contributing to the prior art may be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the methods described in the embodiments of the present invention. And the aforementioned storage medium includes: a removable storage device, a ROM, a RAM, a magnetic or optical disk, or various other media that can store program code.
The above description is only for the specific embodiments of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present invention, and all the changes or substitutions should be covered within the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the appended claims.

Claims (8)

1. An adaptive user avatar filling method, the method comprising:
step 1, judging whether a user head portrait address returned by an interface is empty, if not, entering step 2, and if so, entering step 7;
step 2, judging whether a picture is stored in a cache or not, if so, filling the head portrait of the user by using the picture in the cache, and if not, entering step 3;
step 3, requesting a picture of the head portrait address of the user, entering step 4 if the request fails, and entering step 5 if the request succeeds;
step 4, judging whether a user name parameter is transmitted, if a user name is available, entering step 6, and if no user name is available, entering step 8;
step 5, caching the pictures which are successfully requested in the memory by adopting a picture caching method, and returning to the step 2;
step 6, generating a corresponding character picture based on the user name parameters and by combining with a head portrait picture generation algorithm, and filling the head portrait of the user by adopting the generated character picture; the avatar picture generation algorithm of step 6 specifically includes:
step 6-1, defining several colors as randomly used ground colors, carrying out hash calculation on a character string of a user name parameter to obtain a corresponding hash value, and dividing the hash value by an absolute value obtained by the balance of the number of the colors to determine the color corresponding to the character string;
6-2, drawing a pure color picture corresponding to the color;
6-3, drawing a text to be displayed in the center of the pure color picture, specifically, when the text to be displayed is drawn in the pure color picture, performing 2D image rendering by using UIGramics, calling a UIGraphic BeginImageContextWithOptions function to obtain a graphic context for processing the picture, and performing text drawing on the pure color picture by using the graphic context to generate a character picture; after the drawing operation is finished, calling a UIGraphics EndImagecontext function to close the graphic context, wherein the text to be displayed follows the screening rule of the displayed text;
step 7, judging whether the user name returned by the interface is empty, if so, entering step 8, and if not, returning to step 6;
and 8, filling the head portrait of the user by adopting a default head portrait picture.
2. The adaptive user avatar filling method of claim 1, wherein the filtering rules for the displayed text are characterized in particular by:
if the character string of the user name parameter contains letters, the first two characters in the character string are taken for display;
if the character string of the user name parameter does not contain letters, if the length of the character string is 1, one character is taken for display; if the length of the character string is 2, two characters are taken for display; if the length of the character string is 3 or 4, the last two characters are taken out for display; and if the length of the character string exceeds 4, taking the first two characters for display.
3. The adaptive user avatar filling method according to claim 1, wherein the picture caching method of step 5 specifically comprises:
step 5-1, loading pictures through UIImageView + WebCache class, displaying a default picture placeholdImage at an entrance setImageWithURL in options, and then processing the pictures according to the URL by an SDWebImageManager class;
step 5-2, entering a downloadWithURL of delegat: options: userInfo in the SDWebImageManager class, and searching whether the picture has downloaded a queryDiskCacheForKey of delegat: userInfo from a cache by an SDImageCache class;
step 5-3, whether a picture exists is searched from a memory cache, if the picture cache exists in the memory, the SDImageCacheDelegate calls back the ImageCache, wherein the rdFindeImage is forKey, and userInfo is in an SDWebImageManager class;
step 5-4, the SDWebImageManageRegelate calls back the webImageManager that didFinishWithImage is in UIImageView + WebCache class to wait for the front end to display the picture;
step 5-5, if the picture cache does not exist in the memory, generating 'NSoperation' to be added into the task queue, and starting to search whether the picture is cached from the hard disk;
5-6, trying to read the picture file under the hard disk cache directory according to the MD5 value Key of the URL;
and 5-7, if the picture is read from the hard disk, adding the picture into a memory cache, and sending a direct File image, a forKey and a userInfo from the SDImageDecheDelegate to the UIImageView + Webcache class to wait for the front-end to display the picture.
4. The adaptive user avatar filling method of claim 3, further comprising, after said steps 5-6:
step 5-8, if the picture can not be read from the hard disk cache directory, the picture does not exist in the internal memory and the hard disk cache, and the picture is required to be downloaded, and the picture cache is called back to the universal file format key and the userInfo;
step 5-9, sharing or regenerating a downloader SDWebImageDownloader and starting to download the picture;
step 5-10, after the picture is downloaded completely, the picture is delivered to an SDWebImageDecoder for picture decoding processing, and the ImageDecoder, namely a did FinisherDecodingImage, and userInfo callback is delivered to the SDWebImageDownloader to declare that the decoding is completed;
5-11, calling back the image Downloader and the didFinishWithimage to the SDWebImageManager to inform the completion of the downloading of the image;
step 5-12, notifying all downloadDelegates of completion of downloading, and calling back to a required place to display pictures;
and 5-13, storing the pictures into an SDImageCache class to wait for the front-end display of the pictures, and simultaneously storing the pictures in a memory cache and a hard disk cache respectively.
5. The method for filling in an adaptive user avatar according to claim 1, wherein the step 8 specifically comprises:
estimating the favorite range of the user based on the information content filled in during the registration of the user;
traversing the preference range of the user through all default avatar pictures in the default avatar picture library, and selecting the default avatar picture closest to the preference range of the user from the library;
and filling the head portrait of the user by adopting the selected default head portrait picture.
6. The method for filling in an adaptive user avatar according to claim 1, wherein the step 2 specifically comprises:
presetting that a user head portrait filling area is square, a picture is rectangular, comparing the size of the picture with the size of the user head portrait filling area, and if the size of the short edge of the picture is larger than the size of the side of the user head portrait filling area, reducing the picture until the size of the short edge of the picture is equal to the size of the side of the user head portrait filling area; if the short side size of the picture is smaller than the side size of the user head portrait filling area, the picture is enlarged until the short side size of the picture is equal to the side size of the user head portrait filling area;
respectively corresponding two long edges of the picture to two opposite edges of a user head portrait filling area, carrying out image recognition on the picture, and marking each area in the picture according to a preset classification label;
and according to the priorities of different classification labels, cutting the picture along the direction vertical to the long edge of the picture until the size of the cut residual picture is adapted to the head portrait filling area of the user.
7. An adaptive user avatar stuffing system, said adaptive user avatar stuffing system comprising: a memory and a processor, the memory including an adaptive user avatar filling method program, the adaptive user avatar filling method program when executed by the processor implementing the steps of the adaptive user avatar filling method of any of claims 1 to 6.
8. A computer-readable storage medium, characterized in that the computer-readable storage medium comprises a program of an adaptive user avatar filling method, which when executed by a processor, performs the steps of an adaptive user avatar filling method as claimed in any one of claims 1 to 6.
CN202010991569.4A 2020-09-21 2020-09-21 Self-adaptive user head portrait filling method and system Active CN111832269B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010991569.4A CN111832269B (en) 2020-09-21 2020-09-21 Self-adaptive user head portrait filling method and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010991569.4A CN111832269B (en) 2020-09-21 2020-09-21 Self-adaptive user head portrait filling method and system

Publications (2)

Publication Number Publication Date
CN111832269A CN111832269A (en) 2020-10-27
CN111832269B true CN111832269B (en) 2020-12-08

Family

ID=72918493

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010991569.4A Active CN111832269B (en) 2020-09-21 2020-09-21 Self-adaptive user head portrait filling method and system

Country Status (1)

Country Link
CN (1) CN111832269B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112509090A (en) * 2020-12-07 2021-03-16 北京达佳互联信息技术有限公司 Method, device, storage medium and computer program product for generating identification
CN113885862A (en) * 2021-09-29 2022-01-04 武汉斗鱼鱼乐网络科技有限公司 Head photo frame multiplexing method, storage medium and electronic equipment

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111049735A (en) * 2019-12-23 2020-04-21 北京达佳互联信息技术有限公司 Group head portrait display method, device, equipment and storage medium

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP3869635B2 (en) * 2000-07-21 2007-01-17 セイコープレシジョン株式会社 Image processing apparatus, image processing method, recording medium, and print system
CN105117232A (en) * 2015-09-08 2015-12-02 北京乐动卓越科技有限公司 Method and system for generating text image on user interface
CN105512186A (en) * 2015-11-25 2016-04-20 用友网络科技股份有限公司 Contact photo generation method and generation device
CN106095472A (en) * 2016-08-23 2016-11-09 上海卓易科技股份有限公司 A kind of head portrait setting method and device
CN107659611B (en) * 2017-08-14 2020-11-06 北京五八信息技术有限公司 Big data-based user head portrait generation method, device and system

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111049735A (en) * 2019-12-23 2020-04-21 北京达佳互联信息技术有限公司 Group head portrait display method, device, equipment and storage medium

Also Published As

Publication number Publication date
CN111832269A (en) 2020-10-27

Similar Documents

Publication Publication Date Title
JP6683387B2 (en) Resource sharing method, terminal, and storage medium
CN111832269B (en) Self-adaptive user head portrait filling method and system
ES2699406T3 (en) Apparatus and procedures for recovering / downloading content in a communication device
US9020183B2 (en) Tagging images with labels
CN109660446B (en) Voice broadcasting method and device of chat information, computer equipment and storage medium
US20060281511A1 (en) Device, method, and computer program product for customizing game functionality using images
CN115735229A (en) Updating avatar garments in messaging systems
EP2318911A1 (en) Image tagging user interface
US10863230B1 (en) Content stream overlay positioning
CN114329298B (en) Page presentation method and device, electronic equipment and storage medium
CN102682026A (en) Photo browsing method and client side
CN113407086B (en) Object dragging method, device and storage medium
CN107911700B (en) Virtualization-based hardware decoding method, decoding equipment and storage medium
CN111833234B (en) Image display method, image processing apparatus, and computer-readable storage medium
CN111538697A (en) Page turning processing method of electronic book, electronic equipment and computer storage medium
US9223782B2 (en) System for performing instructions that are dependent upon received media-based messages and associated methods and components
CN106844763B (en) A kind of method showed to the Internet media file formula of modifying and its device
CN110036356A (en) Image procossing in VR system
WO2013142402A1 (en) Graphical manipulation of digital images
KR20170055345A (en) Social Network Service and Program using Cartoon Image Extraction and Transformation system and method using image
WO2021147728A1 (en) Instant communication receiving method, device and apparatus
CN111107425B (en) Method, system, and storage medium for acquiring computing resources based on rendering component elements
CN108763255A (en) A kind of content share method, first terminal, second terminal and storage medium
US10586366B2 (en) System and method for display object bitmap caching
JP2004128649A (en) Portable information processor, computer systems, and their processing methods

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
PE01 Entry into force of the registration of the contract for pledge of patent right
PE01 Entry into force of the registration of the contract for pledge of patent right

Denomination of invention: An adaptive user avatar filling method and system

Effective date of registration: 20220119

Granted publication date: 20201208

Pledgee: Hunan Caixin technology microfinance Co.,Ltd.

Pledgor: HUNAN WEICHU YOUCAI EDUCATION TECHNOLOGY CO.,LTD.

Registration number: Y2022430000007