Disclosure of Invention
In view of the above, embodiments of the present invention provide a method and an apparatus for adding characters to a picture, an electronic device, and a storage medium, 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 area in the picture;
acquiring the background color of the fillable area;
determining the character color of the character to be filled based on the background color;
adding characters in the fillable areas 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 to the background color.
Optionally, after adding a character in the fillable area based on the character color, the method further includes:
determining whether the character input is completed;
after the character is input, determining whether the size of the area where the character is located is larger than the fillable area;
if the size of the area where the characters are located is larger than the fillable area, adjusting the sizes of all the characters in the area where the characters are located so as to reduce the size of the area where the characters are located.
Optionally, after identifying each piece of 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 the 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 color comprises:
adding characters in the fillable area based on the character colors and the character styles.
In a second aspect, an embodiment of the present invention provides an apparatus for adding characters to a picture, where the apparatus includes:
the image acquisition module is used for acquiring an image to be processed;
the area determining module is used for determining a fillable area in the picture;
the color obtaining module is used for obtaining the background color of the fillable area;
the color determining module is used for determining the character color of the character 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 region determining module is configured to identify, based on an image identification algorithm, each piece of 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 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 to the background color.
Optionally, the apparatus further comprises:
an input determining module for determining whether the character input is completed;
the area judgment module is used for determining whether the size of the area where the character is located is larger than the fillable area or not after the character input is finished;
and the character adjusting module is used for adjusting the sizes of all characters in the area where the characters are located so as to reduce the size of the area where the characters are located if the size of the area where the characters are located is larger than the fillable area.
Optionally, the apparatus further comprises:
the style determining module is used for determining style attribute information of the picture according to the obtained element information after the element information included in the picture is identified based on the image identification technology; determining the character style of the character to be filled based on the style attribute information;
the character adding module is further configured to add characters in the fillable area based on the character colors and the character styles.
In a third aspect, an embodiment of the present invention provides an electronic device, where the electronic device includes: 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 enclosed 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, which are 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 area in the picture; acquiring the background color of the fillable area; determining the character color of the character to be filled based on the background color; adding characters in the fillable areas 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 for the user, manual adjustment of the user is not needed, the operation of the user is greatly simplified, the user experience is improved, and the interestingness of pictures is increased.
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 only some embodiments of the invention, and not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In the embodiment of the present invention, the device is generally connected to a server for use, and the device may be a device of a user terminal, for example: a Mobile Phone (Mobile Phone), a Personal Computer (PC), a Tablet PC, an electronic translator, etc. of the user, which are not limited in the embodiments of the present invention.
In a first aspect, referring to fig. 1 of the specification, an embodiment of the present invention provides a method for adding characters in a picture, where the method includes:
s101: acquiring a picture to be processed;
in this embodiment of the present invention, the picture to be processed may be a picture that has been stored in the device by the user, or may be a picture downloaded by the user in the internet, or may be a screenshot of the user captured in a video by the shooting device, and the like.
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 area 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 the 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 present invention, the element information in the picture may be different objects in the picture, or may be different people in the picture, or may be different animals in the picture, or may be different landscapes in the picture, and the like. For example, there are tables, chairs, cups on tables, etc. in the picture, each of the above-mentioned objects can be used as different element information in the picture. For another example, if a man or a woman is included in the picture, each person can be used as different element information in the picture. For another example, where a dog and a cat are included in the picture, each animal may be considered as a different element of information in the picture. Of course, if the picture includes objects, people, animals, etc., all can be different element information in the picture. Those skilled in the art can set different elements according to actual requirements, and the embodiments of the present invention are not limited to these.
In the embodiment of the present invention, the image recognition algorithm may be, for example, an image recognition algorithm for AI (Artificial intelligence) article recognition, or another image recognition algorithm capable of distinguishing different elements, which is not limited in the embodiment of the present invention.
In the embodiment of the present invention, after determining each piece of element information, the device may mark a position of the picture including the piece of element information, where an unmarked portion of the corresponding whole picture is an element blank area, and use the element blank area as a fillable area.
In the embodiment of the present invention, the element information can be set by a user, for example, if the picture is a picture of a person in the field, the user can set the person, the object, and the animal as elements, so that the scenery of the background is correspondingly a blank area of the element, and can be used as a fillable area of the picture. For another example, if only photos of scenic spots and historical sites are available, the user can set the scenery as an element, and the crowd can be used as a fillable area accordingly. The specific element definition can be defined by the user, or can be set by the developer in advance, and set as the corresponding model for the user to select.
S103: acquiring the background color of the fillable area;
in the embodiment of the present invention, the identification of the background color may be implemented by a corresponding image identification algorithm, and the implementation manner is many, which is not limited in the embodiment of the present invention.
S104: determining the character color of the character to be filled based on the background color;
optionally, in the embodiment of the present invention, 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 to the background color.
In the embodiment of the invention, the color comparison list can be set by a user in a self-defined way, can also be preset by App developers, or can also be a set of the color comparison list and the App developers. For example, one possible implementation is that App developers can preset a color comparison list, and then users can adjust the color comparison list according to needs. I.e. the setting mode of the color comparison list, which is not limited in the embodiment of the present invention.
In the embodiment of the invention, a plurality of different colors can be stored in the color comparison list, and the complementary color corresponding to each color is stored in a combined manner. Due to the continuous progress of the color theory, different color comparison lists can be set for different theories, or one color comparison list can be set alternatively, which is not limited by the embodiment of the invention.
For example, using the RGB additive color model or CMY subtractive color model, a list of possible color comparisons, as shown in Table one:
background color
|
Complementary colors
|
Red colour
|
Cyan color
|
Green colour
|
Magenta color
|
......
|
......
|
Blue color
|
Yellow colour |
Watch 1
For another example, according to the conventional RYB color model, a possible color comparison list is shown in Table two:
backgroundColor(s)
|
Complementary colors
|
Red colour
|
Green colour
|
Yellow colour
|
Purple color
|
......
|
......
|
Blue color
|
Orange (orange) color |
Watch two
S105: adding characters in the fillable areas based on the character colors.
In the embodiment of the present invention, the added characters may be english, chinese, or characters of other countries, which is not limited in the embodiment of the present invention.
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 the character input is completed; after the character is input, determining whether the size of the area where the character is located is larger than the fillable area; if the size of the area where the characters are located is larger than the fillable area, adjusting the sizes of all the characters in the area where the characters are located so as to reduce the size of the area where the characters are located.
In the embodiment of the invention, after the character input is finished, 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, the input character can greatly exceed the fillable area, so that the display effect of other areas of the picture can be influenced, at the moment, the fonts of all characters in the area where the character is located can be reduced, and further, the area where the whole character is located is reduced, so that all characters can be completely displayed in the fillable area, and the display effect of the picture can not be influenced.
Optionally, in this embodiment of the present invention, after identifying, based on an image identification technology, each piece of element information included in the picture, the method further includes: determining style attribute information of the picture according to the obtained element information; determining the 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 color comprises: adding characters in the fillable area based on the character colors and the character styles.
In the embodiment of the present invention, the style attribute information may be information representing the cultural style of the element, for example, if the element is a sculpture of the god of sun, the style attribute may be determined to be a greek style, or an ancient roman style. According to the style attribute information, the character style similar to the Greek style is searched in the character style library, so that when a user inputs characters, the character style is adjusted to be similar to the Greek style, consistency of elements in the picture and the style of the characters input by the user is ensured, and user experience is improved.
In the embodiment of the invention, the equipment can automatically determine the area in which the user can fill the characters, and determine the color of the characters according to the background color of the area. Therefore, the user only needs to input corresponding characters, the filling areas of the characters and the colors of the characters are automatically set to be satisfactory for the user, manual adjustment by the user is not needed, the operation of the user is greatly simplified, the user experience is improved, and the interestingness of pictures is increased.
In a second aspect, referring to fig. 2 of the specification, an embodiment of the present invention provides an apparatus 20 for adding characters to pictures, where the apparatus 20 includes:
a picture obtaining module 201, configured to obtain a picture to be processed;
a region determining module 202, configured to determine a fillable region in the picture;
a color obtaining module 203, configured to obtain a background color of the fillable area;
a color determining module 204, configured to determine a character color of the character to be filled based on the background color;
a character adding module 205, configured to add characters in the fillable areas based on the character colors.
Optionally, the region determining module 202 is further configured to identify, based on an image identification technology, each piece of 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 comprises: an input determining module for determining whether the character input is completed; the area judgment module is used for determining whether the size of the area where the character is located is larger than the fillable area or not after the character input is finished; and the character adjusting module is used for adjusting the sizes of all characters in the area where the characters are located so as to reduce the size of the area where the characters are located if the size of the area where the characters are located is larger than the fillable area.
Optionally, the apparatus 20 further comprises: the style determining module is used for determining style attribute information of the picture according to the obtained element information after the element information included in the picture is identified based on the image identification technology; determining the character style of the character to be filled based on the style attribute information; the character adding module is further configured to add characters in the fillable area based on the character colors and the character styles.
In the embodiment of the present invention, the using manner of the apparatus 20 is similar to that of the foregoing method, and further description thereof is omitted.
In a third aspect, an embodiment of the present invention provides an electronic device, where the electronic device includes: 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 enclosed 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.
Referring to fig. 3, fig. 3 is a schematic structural diagram of an embodiment of the electronic device of the present invention, which can implement the process of the embodiment shown in fig. 1 or 2 of the present invention, and as shown in fig. 3, the electronic device may include: the device comprises a shell 31, a processor 32, a memory 33, a circuit board 34 and a power circuit 35, wherein the circuit board 34 is arranged inside a space enclosed by the shell 31, and the processor 32 and the memory 33 are arranged on the circuit board 34; a power supply circuit 35 for supplying power to each circuit or device of the electronic apparatus; the memory 33 is used for storing executable program codes; the processor 32 executes a program corresponding to the executable program code by reading the executable program code stored in the memory 33 for performing the method according to any of the method embodiments described above.
The specific execution process of the above steps by the processor 32 and the steps further executed by the processor 32 by running the executable program code may refer to the description of the embodiment shown in fig. 1 or 2 of the present invention, and are not described herein again.
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 communications capabilities and are primarily targeted at providing voice, data communications. Such terminals include: smart phones (e.g., iphones), multimedia phones, functional phones, and low-end phones, among others.
(2) Ultra mobile personal computer device: the equipment belongs to the category of personal computers, has calculation and processing functions and generally has the characteristic of mobile internet access. Such terminals include: PDA, MID, and UMPC devices, etc., such as ipads.
(3) A portable entertainment device: such devices can display and play multimedia content. This type of device comprises: audio, video players (e.g., ipods), handheld game consoles, electronic books, and smart toys and portable car navigation devices.
(4) A server: the device for providing the computing service comprises a processor, a hard disk, a memory, a system bus and the like, and the server is similar to a general computer architecture, but has higher requirements on processing capacity, stability, reliability, safety, expandability, manageability and the like because of the need of providing high-reliability service.
(5) And other electronic equipment with data interaction function.
The embodiment of the present invention further provides a computer-readable storage medium, in which a computer program is stored, and the computer program, when executed by a processor, implements the method steps described in any of the above method embodiments.
Embodiments of the invention also provide an application program, which is executed to implement the method provided by any one of the method embodiments of the invention.
It is noted that, herein, relational terms such as first and second, and the like may be 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. Also, 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. The term "comprising", without further limitation, means that the element so defined is not excluded from the group consisting of additional identical elements in the process, method, article, or apparatus that comprises the element.
All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, as for the apparatus embodiment, since it is substantially similar to the method embodiment, the description is relatively simple, and for the relevant points, reference may be made to the partial description of the method embodiment. For convenience of description, the above devices are described separately in terms of functional division into various units/modules. Of course, the functionality of the units/modules may be implemented in one or more software and/or hardware implementations of the invention.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by a computer program, which can be stored in a computer-readable storage medium, and when executed, can include the processes 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 (RAM), or the like.
The above description is only for the specific embodiment of the present invention, but the scope of the present invention is not limited thereto, and any changes or substitutions that can be easily conceived by those skilled in the art within the technical scope of the present invention are included in the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.