Disclosure of Invention
In view of the above, embodiments of the present invention provide a method, an apparatus, an electronic device, and a storage medium for adding characters to a picture, so as to solve the above problems.
In a first aspect, an embodiment of the present invention provides a method for adding characters to a picture, including:
acquiring a picture to be processed;
determining a fillable region in the picture;
acquiring the background color of the fillable area;
determining character colors of characters to be filled based on the background colors;
characters are added in the fillable area based on the character colors.
Optionally, the determining the fillable area in the picture includes:
identifying each element information included in the picture based on an image identification algorithm;
determining an element blank area in the picture based on the element information;
and taking the element blank area as the fillable area.
Optionally, the determining the character color of the character to be filled based on the background color includes:
acquiring a color comparison list; the color comparison list comprises a first color and a first complementary color corresponding to the first color;
determining the character color based on the background color and the color comparison list; wherein the character color is a complementary color of the background color.
Optionally, after adding a character in the fillable area based on the character color, the method further comprises:
determining whether character input is completed;
after the character input is completed, determining whether the size of the area where the character is located is larger than that of the fillable area;
and if the size of the area where the character is located is larger than the fillable area, adjusting the sizes of all the characters in the area where the character is located so as to reduce the size of the area where the character is located.
Optionally, after identifying the respective element information included in the picture based on the image identification technology, the method further includes:
determining style attribute information of the picture according to the obtained element information;
determining a character style of the character to be filled based on the style attribute information;
the adding characters in the fillable area based on the character colors includes:
characters are added in the fillable area based on the character colors and the character styles.
In a second aspect, an embodiment of the present invention provides a device for adding characters to a picture, where the device includes:
the image acquisition module is used for acquiring an image to be processed;
the region determining module is used for determining a fillable region in the picture;
the color acquisition module is used for acquiring the background color of the fillable area;
a color determining module for determining character colors of characters to be filled based on the background color;
and the character adding module is used for adding characters in the fillable area based on the character colors.
Optionally, the area determining module is configured to identify each element information included in the picture based on an image identification algorithm; determining an element blank area in the picture based on the element information; and taking the element blank area as the fillable area.
Optionally, the color determining module is configured to obtain a color comparison list; the color comparison list comprises a first color and a first complementary color corresponding to the first color; determining the character color based on the background color and the color comparison list; wherein the character color is a complementary color of the background color.
Optionally, the apparatus further includes:
an input determining module for determining whether character input is completed;
the region judging module is used for determining whether the size of the region where the character is located is larger than the fillable region after the character is input;
and the character adjusting module is used for adjusting the sizes of all the characters in the area where the characters are located if the size of the area where the characters are located is larger than the fillable area so as to reduce the size of the area where the characters are located.
Optionally, the apparatus further includes:
the style determining module is used for determining style attribute information of the picture according to the obtained element information after identifying the element information included in the picture based on the image identification technology; determining a character style of the character to be filled based on the style attribute information;
the character adding module is further configured to add a character in the fillable area based on the character color and the character style.
In a third aspect, an embodiment of the present invention provides an electronic device, including: the device comprises a shell, a processor, a memory, a circuit board and a power circuit, wherein the circuit board is arranged in a space surrounded by the shell, and the processor and the memory are arranged on the circuit board; a power supply circuit for supplying power to each circuit or device of the electronic apparatus; the memory is used for storing executable program codes; the processor executes a program corresponding to the executable program code by reading the executable program code stored in the memory for performing any of the methods described above.
In a fourth aspect, embodiments of the present invention also provide a computer-readable storage medium storing one or more programs executable by one or more processors to implement any of the methods described above.
The embodiment of the invention provides a method and a device for adding characters in a picture, electronic equipment and a storage medium. The method comprises the following steps: acquiring a picture to be processed; determining a fillable region in the picture; acquiring the background color of the fillable area; determining character colors of characters to be filled based on the background colors; characters are added in the fillable area based on the character colors. That is, the device may automatically determine the area where the user can fill in the text and determine the color of the text based on the background color of the area. Therefore, the user only needs to input corresponding characters, the characters of the characters and the colors of the characters are automatically set to be satisfactory to the user, the user does not need to manually adjust again, the operation of the user is greatly simplified, the use experience of the user is improved, and the interestingness of the picture is improved.
Detailed Description
Embodiments of the present invention will be described in detail below with reference to the accompanying drawings.
It should be understood that the described embodiments are merely some, but not all, embodiments of the invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
In the embodiment of the present invention, the device is typically connected to a server, and the device may be a device of a user terminal, for example: a user's Mobile Phone, personal computer (Personal Computer, PC), tablet PC (Tablet Personal Computer, tablet PC), or electronic translation device, etc., to which embodiments of the present invention are not limited.
In a first aspect, referring to fig. 1 of the specification, an embodiment of the present invention provides a method for adding characters to a picture, where the method includes:
s101: acquiring a picture to be processed;
in the embodiment of the present invention, the picture to be processed may be a picture already stored in the device by the user, or may be a picture downloaded by the user in the internet, or may be a screenshot taken by the user in the video through the photographing device, which is not limited in the embodiment of the present invention.
In the embodiment of the present invention, the color of the picture may be color or black and white, which is not limited in the embodiment of the present invention.
S102: determining a fillable region in the picture;
in the embodiment of the invention, the fillable area is an area allowing a user to display text information.
Optionally, in an embodiment of the present invention, the determining a fillable area in the picture includes: identifying each element information included in the picture based on an image identification technology; determining an element blank area in the picture based on the element information; and taking the element blank area as the fillable area.
In the embodiment of the invention, the element information in the picture can be different objects in the picture, or can be different characters in the picture, or can be different animals in the picture, or can be different sceneries in the picture, and the like. For example, there are articles such as a table, a chair, a cup on the table, etc. in the picture, and each of the articles can be used as different element information in the picture. For another example, a picture includes a man and a woman, and then each person can be used as different element information in the picture. For another example, where a dog and a cat are included in a picture, each animal may be treated as different elemental information in the picture. Of course, if the picture includes objects, figures, animals, etc., the information may be different elements in the picture. Those skilled in the art may set different elements according to actual requirements, and the embodiment of the present invention is not limited thereto.
In the embodiment of the present invention, the image recognition algorithm may be, for example, an image recognition algorithm for AI (Artificial Intelligenc, artificial intelligence) object recognition, or other image recognition algorithms capable of distinguishing different elements, which is not limited in the embodiment of the present invention.
In the embodiment of the invention, after each piece of element information is determined, the device can mark the position including the element information in the picture, the corresponding unlabeled part in the whole picture is the element blank area, and the element blank area is used as the fillable area.
In the embodiment of the invention, the element information can be set in a self-defined manner, for example, if the image is a photograph of a wild person, the user can set the person, the object and the animal as elements, so that the scenery of the background is a blank area of the elements correspondingly and can be used as a fillable area of the photograph. For another example, if it is simply a photograph of a point of interest, the user may set a landscape as an element, and the crowd may be the fillable area accordingly. The specific element definition can be defined according to the user, or can be set by the developer in advance and set as a corresponding model for the user to select, and the embodiment of the invention is not limited to this.
S103: acquiring the background color of the fillable area;
in the embodiment of the invention, the identification of the background color can be realized through a corresponding image identification algorithm, and the implementation modes are more, but the embodiment of the invention is not limited to the above.
S104: determining character colors of characters to be filled based on the background colors;
optionally, in an embodiment of the present invention, the determining a character color of the character to be filled based on the background color includes: acquiring a color comparison list; the color comparison list comprises a first color and a first complementary color corresponding to the first color; determining the character color based on the background color and the color comparison list; wherein the character color is a complementary color of the background color.
In the embodiment of the invention, the color comparison list can be set by user definition, can be preset by an App developer, or can be a set of the two. For example, in one possible implementation, an App developer may preset a color control list, and then the user may adjust itself as needed. I.e., the manner in which the color control list is set, embodiments of the present invention are not limited in this regard.
In the embodiment of the invention, a plurality of different colors can be stored in the color comparison list, and complementary colors corresponding to each color are stored in a combined mode. Due to the continuous progress of color theory, different color comparison lists can be set according to different theories, or alternatively, the embodiment of the invention is not limited to this.
For example, using an RGB additive color model or a CMY subtractive color model, a list of possible color controls, such as table one:
background color
|
Complementary colors
|
Red color
|
Cyan color
|
Green colour
|
Magenta color
|
......
|
......
|
Blue color
|
Yellow colour |
List one
For another example, according to the conventional RYB color model, a list of possible color controls is shown in Table II:
background color
|
Complementary colors
|
Red color
|
Green colour
|
Yellow colour
|
Purple color
|
......
|
......
|
Blue color
|
Orange (tangerine) color |
Watch II
S105: characters are added in the fillable area based on the character colors.
In the embodiment of the invention, the added characters can be English, chinese or characters of other countries, and the embodiment of the invention is not limited to the English, chinese or characters.
Optionally, in an embodiment of the present invention, after adding a character in the fillable area based on the character color, the method further includes: determining whether character input is completed; after the character input is completed, determining whether the size of the area where the character is located is larger than that of the fillable area; and if the size of the area where the character is located is larger than the fillable area, adjusting the sizes of all the characters in the area where the character is located so as to reduce the size of the area where the character is located.
In the embodiment of the invention, after the character is input, the size of the area where the character is located can be determined, if the size of the area where the character is located is larger than the fillable area, that is, the input characters are extremely likely to exceed the fillable area, so that the display effect of other areas of the picture can be influenced, at the moment, fonts of all the characters in the area where the character is located can be reduced, the area where the whole character is located is further reduced, and therefore, all the characters can be completely displayed in the fillable area, and meanwhile, the display effect of the picture cannot be influenced.
Optionally, in an embodiment of the present invention, after the identifying, based on an image identification technology, each element information included in the picture, the method further includes: determining style attribute information of the picture according to the obtained element information; determining a character style of the character to be filled based on the style attribute information; the adding characters in the fillable area based on the character colors includes: characters are added in the fillable area based on the character colors and the character styles.
In the embodiment of the invention, the style attribute information may be information representing the style of the element culture, for example, if the element is a sculpture of the sun, the style attribute may be determined to be greek style or ancient roman style. According to the style attribute information, searching a character style similar to the Greek style in a character style library, so that when a user inputs a character, the character style is adjusted to be similar to the Greek style, the consistency of elements in a picture and the style of the character input by the user is ensured, and the user experience is improved.
In the embodiment of the invention, the device can automatically determine the area where the user can fill in the text, and determine the color of the text according to the background color of the area. Therefore, the user only needs to input corresponding characters, and the filling area of the characters and the color of the characters are automatically set to be satisfactory to the user, so that the user does not need to manually adjust again, the operation of the user is greatly simplified, the use experience of the user is improved, and the interestingness of the picture is increased.
In a second aspect, referring to fig. 2 of the specification, an embodiment of the present invention provides a device 20 for adding characters to a picture, where the device 20 includes:
a picture acquisition module 201, configured to acquire a picture to be processed;
a region determining module 202, configured to determine a fillable region in the picture;
a color acquisition module 203, configured to acquire a background color of the fillable area;
a color determination module 204 for determining a character color of a character to be filled based on the background color;
a character adding module 205, configured to add characters in the fillable area based on the character colors.
Optionally, the area determining module 202 is further configured to identify, based on an image identification technology, each element information included in the picture; determining an element blank area in the picture based on the element information; and taking the element blank area as the fillable area.
Optionally, the color determining module 204 is further configured to obtain a color comparison list; the color comparison list comprises a first color and a first complementary color corresponding to the first color; determining the character color based on the background color and the color comparison list; wherein the color to be filled is a complementary color of the background color.
Optionally, the apparatus 20 further includes: an input determining module for determining whether character input is completed; the region judging module is used for determining whether the size of the region where the character is located is larger than the fillable region after the character is input; and the character adjusting module is used for adjusting the sizes of all the characters in the area where the characters are located if the size of the area where the characters are located is larger than the fillable area so as to reduce the size of the area where the characters are located.
Optionally, the apparatus 20 further includes: the style determining module is used for determining style attribute information of the picture according to the obtained element information after identifying the element information included in the picture based on the image identification technology; determining a character style of the character to be filled based on the style attribute information; the character adding module is further configured to add a character in the fillable area based on the character color and the character style.
In the embodiment of the present invention, the usage of the device 20 is similar to the method described above, and the embodiment of the present invention will not be repeated here.
In a third aspect, an embodiment of the present invention provides an electronic device, including: the device comprises a shell, a processor, a memory, a circuit board and a power circuit, wherein the circuit board is arranged in a space surrounded by the shell, and the processor and the memory are arranged on the circuit board; a power supply circuit for supplying power to each circuit or device of the electronic apparatus; the memory is used for storing executable program codes; the processor executes a program corresponding to the executable program code by reading the executable program code stored in the memory for performing any of the methods described above.
An embodiment of the present invention further provides an electronic device, please refer to fig. 3, fig. 3 is a schematic structural diagram of an embodiment of the electronic device of the present invention, and a flow of the embodiment shown in fig. 1 or 2 of the present invention may be implemented, as shown in fig. 3, where the electronic device may include: the processor 32 and the memory 33 are arranged on the circuit board 34, wherein the circuit board 34 is arranged in a space surrounded by the shell 31; a power supply circuit 35 for supplying power to the respective circuits or devices of the above-described electronic apparatus; the memory 33 is for storing executable program code; the processor 32 runs a program corresponding to the executable program code by reading the executable program code stored in the memory 33 for performing the method described in any of the method embodiments described above.
The specific implementation of the above steps by the processor 32 and the further implementation of the steps by the processor 32 through the execution of executable program codes may be referred to in the description of the embodiment of fig. 1 or 2 of the present invention, and will not be described herein.
The electronic device exists in a variety of forms including, but not limited to:
(1) A mobile communication device: such devices are characterized by mobile communication capabilities and are primarily aimed at providing voice, data communications. Such terminals include: smart phones (e.g., iPhone), multimedia phones, functional phones, and low-end phones, etc.
(2) Ultra mobile personal computer device: such devices are in the category of personal computers, having computing and processing functions, and generally also having mobile internet access characteristics. Such terminals include: PDA, MID, and UMPC devices, etc., such as iPad.
(3) Portable entertainment device: such devices may display and play multimedia content. The device comprises: audio, video players (e.g., iPod), palm game consoles, electronic books, and smart toys and portable car navigation devices.
(4) And (3) a server: the configuration of the server includes a processor, a hard disk, a memory, a system bus, and the like, and the server is similar to a general computer architecture, but is required to provide highly reliable services, and thus has high requirements in terms of processing capacity, stability, reliability, security, scalability, manageability, and the like.
(5) Other electronic devices with data interaction functions.
Embodiments of the present invention also provide a computer readable storage medium having stored therein a computer program which, when executed by a processor, implements the method steps of any of the method embodiments described above.
Embodiments of the present invention also provide an application program that is executed to implement the method provided by any of the method embodiments of the present invention.
It is noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises an element.
In this specification, each embodiment is described in a related manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments. In particular, for the device embodiments, since they are substantially similar to the method embodiments, the description is relatively simple, and reference is made to the description of the method embodiments in part. For convenience of description, the above apparatus is described as being functionally divided into various units/modules, respectively. Of course, the functions of the various elements/modules may be implemented in the same piece or pieces of software and/or hardware when implementing the present invention.
Those skilled in the art will appreciate that implementing all or part of the above-described methods in accordance with the embodiments may be accomplished by way of a computer program stored on a computer readable storage medium, which when executed may comprise the steps of the embodiments of the methods described above. The storage medium may be a magnetic disk, an optical disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), or the like.
The foregoing is merely illustrative of the present invention, and the present invention is not limited thereto, and any changes or substitutions easily contemplated by those skilled in the art within the scope of the present invention should be included in the present invention. Therefore, the protection scope of the invention is subject to the protection scope of the claims.