Disclosure of Invention
The application provides a text template generation method and device, which are used for solving the technical problems that in the prior art, text templates are dependent on manual setting, so that the text template generation efficiency is low and the attractiveness cannot be guaranteed.
An embodiment of an aspect of the present application provides a text template generating method, including the following steps: acquiring a reference picture containing text information; determining a target area where text content corresponding to the text information is located in the reference picture; and recognizing a text pattern corresponding to the text content in the target area, and generating a text template according to the text pattern.
According to the text template generation method, a reference picture containing text information is obtained, a target area where text content corresponding to the text information is located is determined in the reference picture, finally, text patterns corresponding to the text content in the target area are identified, and a text template is generated according to the text patterns. Therefore, the text template is automatically generated based on the provided reference picture, the generation efficiency of the text template is improved, the automatic generation of the text template is realized, and the attractiveness of the text template is ensured.
In addition, the text template generating method of the embodiment of the application further comprises the following additional technical characteristics:
in a possible implementation manner of the embodiment of the present application, in the reference picture, determining a target area where text content corresponding to the text information is located includes: dividing the reference picture into a plurality of candidate regions; extracting image features of each candidate region of the plurality of candidate regions; matching the image features of each candidate region with the text features of the text information, and determining target image features successfully matched; and determining the region where the target image features are located as the target region.
In one possible implementation manner of the embodiment of the present application, after the determining the target area where the text content corresponding to the text information is located, the method further includes: identifying text content in the target area; the generating the text template according to the text style comprises the following steps: adjusting the text content according to the text style; and generating the text template according to the adjusted text content.
In a possible implementation manner of the embodiment of the present application, the generating a text template according to the text style includes: determining style description information corresponding to the text style; and generating the text template according to the text style description information.
In one possible implementation manner of the embodiment of the present application, after the determining the target area where the text content corresponding to the text information is located, the method further includes: determining position information of the target region in the reference picture; after the text template is generated according to the text style, the method further comprises the following steps: the text templates are sent to a user, and a target text template selected by the user when editing a target picture is obtained; acquiring target text content input by a user aiming at the target text template; and adjusting the target text content according to the target text template, and displaying the adjusted target text content in the target picture according to the position information.
An embodiment of an aspect of the present application provides a text template generating device, including: the acquisition module is used for acquiring a reference picture containing text information; the determining module is used for determining a target area where the text content corresponding to the text information is located in the reference picture; and the template generation module is used for identifying the text style corresponding to the text content in the target area and generating a text template according to the text style.
The text template generating device acquires a reference picture containing text information, determines a target area where text content corresponding to the text information is located in the reference picture, and finally identifies a text pattern corresponding to the text content in the target area and generates a text template according to the text pattern. Therefore, the text template is automatically generated based on the provided reference picture, the generation efficiency of the text template is improved, the automatic generation of the text template is realized, and the attractiveness of the text template is ensured.
In addition, the text template generating device of the embodiment of the application further comprises the following additional technical characteristics:
in one possible implementation manner of the embodiment of the present application, the determining module includes: a dividing unit configured to divide the reference picture into a plurality of candidate regions; an extraction unit configured to extract an image feature of each of the plurality of candidate regions; the determining unit is used for matching the image characteristics of each candidate area with the character characteristics of the character information and determining target image characteristics successfully matched; the determining unit is further configured to determine an area where the target image feature is located as the target area.
In one possible implementation manner of the embodiment of the present application, the method further includes: the identification module is used for identifying the text content in the target area; the template generation module is specifically configured to: adjusting the text content according to the text style; and generating the text template according to the adjusted text content.
In one possible implementation manner of the embodiment of the present application, the template generating module is specifically configured to: determining style description information corresponding to the text style; and generating the text template according to the text style description information.
In one possible implementation manner of the embodiment of the present application, the template generating module is specifically configured to: determining position information of the target region in the reference picture; the acquisition module is also used for sending the text templates to a user and acquiring target text templates selected by the user when editing target pictures; the acquisition module is also used for acquiring target text content input by a user aiming at the target text template; the apparatus further comprises: and the display module is used for adjusting the target text content according to the target text template and displaying the adjusted target text content in the target picture according to the position information.
Another embodiment of the present application provides an electronic device, including a processor and a memory; wherein the processor executes a program corresponding to the executable program code by reading the executable program code stored in the memory, for implementing the text template generation method as described in the above embodiment.
Another embodiment of the present application proposes a non-transitory computer readable storage medium, on which a computer program is stored, which when executed by a processor, implements the text template generation method as described in the above embodiment.
Additional aspects and advantages of the application 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 application.
Detailed Description
Embodiments of the present application are described in detail below, examples of which are illustrated in the accompanying drawings, wherein the same or similar reference numerals refer to the same or similar elements or elements having the same or similar functions throughout. The embodiments described below by referring to the drawings are exemplary and intended for the purpose of explaining the present application and are not to be construed as limiting the present application.
Aiming at the technical problems that the current text template generation efficiency is low and the attractiveness is difficult to ensure in the background art, the application provides a novel text template generation method, in the method, text patterns contained in pictures are directly identified, text templates are automatically generated based on the identified text patterns, so that the text template generation efficiency is improved, and the attractiveness of the text templates is ensured if corresponding picture sources are screened, for example, the attractiveness of the obviously generated text templates is stronger when the poster pictures are taken as basic pictures generated by the text templates.
The text template generation method and device of the embodiment of the application are described below with reference to the accompanying drawings. .
Specifically, fig. 1 is a schematic flow chart of a text template generating method according to an embodiment of the present application.
As shown in fig. 1, the method includes:
step 101, obtaining a reference picture containing text information.
It should be noted that, in different application scenarios, the ways of acquiring the reference pictures containing the text information are different:
as a possible implementation manner, the user may automatically upload the picture of the favorite text content style according to the personal requirement, if the user wants to apply the text style, the picture is directly input as the reference picture in the embodiment. The user in this embodiment may be a technician, or may be a user who is editing a picture at present, and when the user is a user who is editing a picture at present, the embodiment may provide the user with a function service generated by personalizing a text template.
As another possible implementation manner, the user's text template generating instruction is obtained, where the instruction may include an image feature of the reference picture, and a certain number of pictures meeting the image are searched by self based on the image feature, for example, when the user's text template generating instruction is "find popular movie posters that contain text now", then in the current movie posters, a certain number of movie poster pictures may be obtained according to the heat as the reference picture in this embodiment. For example, when the user's text template generation instruction is "find some pictures with freshness and containing text", the pictures with freshness and containing text can be selected from the pictures with freshness and containing attribute as the reference pictures in the embodiment.
Step 102, in the reference picture, determining a target area where the text content corresponding to the text information is located.
And 103, identifying a text pattern corresponding to the text content in the target area, and generating a text template according to the text pattern.
It is to be understood that the style of the text information in the reference picture is a style that the user wants to apply, and thus, the text template may be generated based on the style corresponding to the text information.
Wherein the specific content contained in the character pattern relates to character information, and the specific content contained in the character pattern is the size of characters, the font of the characters, the format of the characters (whether thickening, tilting and the like), the color of the characters, the dynamic effect of the characters and the like
Specifically, in the reference picture, a target area where the text content corresponding to the text information is located is determined, that is, the target area where the text content is located is first selected by a frame, so that the text style of the text content is further identified based on the target area.
In the different application scenarios, the manner of determining the target area where the text content corresponding to the text information is located in the reference picture is different, and examples are as follows:
example one:
in this example, the reference picture is divided into a plurality of candidate regions, the image feature of each candidate region in the plurality of candidate regions is extracted, the image feature may include an image vector feature, and the like, the image feature of each candidate region is matched with the text feature of the text information, the target image feature successfully matched is determined, and the region where the target image feature is located is determined to be the target region.
It may also be appreciated that, as shown in fig. 2-1, in this example, the reference picture is first divided into a plurality of candidate regions, and then, a target region containing text information is screened out from the plurality of candidate regions, so that a style of the target text content is further extracted in the target region, instead of directly extracting features for the whole reference picture, so that the determining efficiency of the text style is greatly improved.
Example two:
in this example, the image feature of each pixel in the whole reference picture is directly extracted, and then the image feature of each pixel is matched with the text feature of the text information, and the region formed by the pixels where the successfully matched target pixel is located is used as the target region.
Example three:
in this example, as shown in fig. 2-2, the picture character recognition technology is used to recognize the characters in the whole picture, and further, the recognition function in the picture character recognition technology is monitored based on the hook function or the like, and since the picture character recognition technology needs to select one area in a frame to recognize the characters, the target area can be determined based on the frame selection position of the characters recognized by the recognition function.
Further, the text pattern corresponding to the text content in the target area is identified, for example, the shape feature, the size feature and the like of the text content in the target area can be identified to determine the information required pattern, and further, a text template is generated according to the text pattern, and the text template can be used for completing the input of the information.
In the actual implementation process, the manner of generating the text template according to the text style is also different, and the following is exemplified:
example one:
in this example, style description information corresponding to a text style may be determined, which describes the text style of the current text template in a text manner, for example, when the text template is a text template, as shown in fig. 3-1, the corresponding text template may be described by "Song Ti, small four, magic color", "regular script, small four, bold", and the like.
The text templates in this embodiment may be displayed in a list form as shown in fig. 3-1, and when the text templates are displayed in a list form, more text templates may be displayed by providing a slide menu, etc., and for example, as shown in fig. 3-2, corresponding description information may be added to different pattern templates. The corresponding text templates are generated so that the user can watch the corresponding templates, in this example, the corresponding text styles can be intuitively displayed by displaying the sample words corresponding to the style description information in the text templates, wherein the sample words can be set by the user or can be default words, for example, as shown in fig. 3-3, the sample words can be names of the users such as "small brightness" (the fantasy effect is not shown in the figure). By the method, the problem that the text template occupies more area because the text template directly displays the corresponding text content when the text content corresponding to the text style is longer is avoided.
Example two:
in this example, in order to improve the efficiency of generating the text template, text content in the target area may be identified, further, text content may be adjusted according to the text style, the text template may be generated according to the adjusted text content, and the text template itself may intuitively display specific text template content.
For example, when the picture of the text template is shown in the left diagram of fig. 4, the text template may be directly generated according to the text content in the corresponding format as shown in the right diagram of fig. 4.
Of course, the user may want to retain the text style of the text content in more reference pictures, for example, the user wants to retain the position information of the text content in the reference pictures, in this case, as shown in fig. 5, the position of the corresponding text content may be represented in the corresponding text template in the form of a thumbnail, or may not be intuitively represented, and the corresponding position information may be directly adapted only in a specific application.
Specifically, in one embodiment of the present application, position information, such as coordinate information, of a target area in a reference picture is determined, and then, after a text template is sent to a user, a target text template selected by the user when editing the target picture is obtained, target text content input by the user for the target text template is obtained, the target text content is adjusted according to the target text template, and the adjusted target text content is displayed in the target picture according to the position information. Therefore, the style of the text content in the reference picture is applied, and the requirement of a user is improved.
Based on the above embodiment, some users may have a requirement for fine adjustment of the effect generated by the text templates, so in the practical application process, the corresponding image editing platform provides an adjustment function for each text template, such as a position adjustment function, and displays the target text content according to the adjustment of the text templates by the users.
Of course, the automatic execution method of the text template can also be used in other template generation modes, for example, when the picture template is generated, specific contents included in the corresponding picture pattern are layout of the picture, a filter of the picture, brightness of the picture, size of the picture and the like, for example, in the actual execution process, the picture template can be displayed in a thumbnail sketch mode, as shown in fig. 3-4, when the picture pattern corresponding to the picture template is the picture layout, different layout main bodies can be embodied in a thumbnail mode, and each main body can be shown by corresponding shapes and characters so as to improve intuitiveness of the picture template.
In summary, the text template generation method of the embodiment of the application obtains a reference picture containing text information, determines a target area where text content corresponding to the text information is located in the reference picture, and finally identifies a text pattern corresponding to the text content in the target area and generates a text template according to the text pattern. Therefore, the text template is automatically generated based on the provided reference picture, the generation efficiency of the text template is improved, the automatic generation of the text template is realized, and the attractiveness of the text template is ensured.
In order to achieve the above embodiment, the present application further provides a text template generating device.
Fig. 6 is a schematic structural diagram of a text template generating device according to an embodiment of the present application.
As shown in fig. 6, the text template generating apparatus includes: the system comprises an acquisition module 10, a determination module 20 and a template generation module 30.
The acquiring module 10 is configured to acquire a reference picture containing text information.
The determining module 20 is configured to determine, in the reference picture, a target area where the text content corresponding to the text information is located.
The template generating module 30 is configured to identify a text style corresponding to the text content in the target area, and generate a text template according to the text style.
Further, in one possible implementation manner of the embodiment of the present application, as shown in fig. 7, the determining module 20 includes, on the basis of the description shown in fig. 6: a dividing unit 21, an extracting unit 22, and a determining unit 23.
Wherein the dividing unit 21 is configured to divide the reference picture into a plurality of candidate regions.
An extraction unit 22 for extracting an image feature of each of the plurality of candidate regions.
The determining unit 23 matches the image feature of each candidate region with the text feature of the text information, and determines the target image feature successfully matched.
In this embodiment, the determining unit 23 is further configured to determine an area where the target image feature is located as the target area.
In a possible implementation manner of the embodiment of the present application, as shown in fig. 8, on the basis of the embodiment shown in fig. 6, the apparatus further includes: an identification module 40.
Wherein, the recognition module 40 is used for recognizing the text content in the target area;
the template generating module 30 is specifically configured to:
adjusting the text content according to the text style;
and generating a text template according to the adjusted information.
In a possible implementation manner of the embodiment of the present application, as shown in fig. 8, on the basis of the embodiment shown in fig. 6, the apparatus further includes: the display module 50, in this embodiment, the template generating module 30 is specifically configured to:
determining position information of a target region in a reference picture;
the obtaining module 10 is further configured to send the text template to a user, and obtain a target text template selected by the user when editing the target picture;
the acquisition module 10 is further configured to acquire target text content input by a user in the target text template;
the display module 50 is configured to adjust the target text content according to the target text template, and display the adjusted target text content in the target picture according to the position information.
It should be noted that the foregoing explanation of the method embodiment is also applicable to the apparatus of this embodiment, and will not be repeated here.
In order to achieve the above embodiments, the embodiments of the present application further provide an electronic device, including a processor and a memory;
wherein the processor runs a program corresponding to the executable program code by reading the executable program code stored in the memory for implementing the text template generation method as described in the above embodiments.
Fig. 10 illustrates a block diagram of an exemplary electronic device suitable for use in implementing embodiments of the present application. The electronic device 120 shown in fig. 10 is only an example and should not be construed as limiting the functionality and scope of use of the embodiments herein.
As shown in fig. 10, the electronic device 120 is in the form of a general purpose computing device. Components of electronic device 120 may include, but are not limited to: one or more processors or processing units 160, a system memory 280, a bus 180 that connects the various system components, including the system memory 280 and the processing units 160.
Bus 180 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor, and a local bus using any of a variety of bus architectures. By way of example, and not limitation, such architectures include industry Standard architecture (Industry Standard Architecture; hereinafter ISA) bus, micro channel architecture (Micro Channel Architecture; hereinafter MAC) bus, enhanced ISA bus, video electronics standards Association (Video Electronics Standards Association; hereinafter VESA) local bus, and peripheral component interconnect (Peripheral Component Interconnection; hereinafter PCI) bus.
Electronic device 120 typically includes a variety of computer system readable media. Such media can be any available media that is accessible by electronic device 120 and includes both volatile and nonvolatile media, removable and non-removable media.
Memory 280 may include computer system readable media in the form of volatile memory, such as random access memory (Random Access Memory; hereinafter: RAM) 300 and/or cache memory 3200. Electronic device 120 may further include other removable/non-removable, volatile/nonvolatile computer system storage media. By way of example only, the storage system 3400 may be used to read from and write to a non-removable, non-volatile magnetic media (not shown in FIG. 10, commonly referred to as a "hard disk drive"). Although not shown in fig. 10, a magnetic disk drive for reading from and writing to a removable nonvolatile magnetic disk (e.g., a "floppy disk"), and an optical disk drive for reading from or writing to a removable nonvolatile optical disk (e.g., a compact disk read only memory (Compact Disc Read Only Memory; hereinafter CD-ROM), digital versatile read only optical disk (Digital Video Disc Read Only Memory; hereinafter DVD-ROM), or other optical media) may be provided. In such cases, each drive may be coupled to bus 180 through one or more data medium interfaces. Memory 280 may include at least one program product having a set (e.g., at least one) of program modules configured to carry out the functions of the embodiments of the present application.
A program/utility 400 having a set (at least one) of program modules 420 may be stored, for example, in memory 280, such program modules 420 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each or some combination of which may include an implementation of a network environment. Program modules 420 generally perform the functions and/or methods in the embodiments described herein.
The electronic device 120 may also communicate with one or more external devices 140 (e.g., keyboard, pointing device, display 240, etc.), one or more devices that enable a user to interact with the electronic device 120, and/or any devices (e.g., network card, modem, etc.) that enable the electronic device 120 to communicate with one or more other computing devices. Such communication may occur through an input/output (I/O) interface 220. Also, the electronic device 120 may communicate with one or more networks, such as a local area network (Local Area Network; hereinafter: LAN), a wide area network (Wide Area Network; hereinafter: WAN), and/or a public network, such as the Internet, via the network adapter 200. As shown, network adapter 200 communicates with other modules of electronic device 120 over bus 180. It should be appreciated that although not shown, other hardware and/or software modules may be used in connection with electronic device 120, including, but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, data backup storage systems, and the like.
The processing unit 160 executes various functional applications and data processing by running programs stored in the system memory 280, for example, implementing the methods mentioned in the foregoing embodiments.
In order to implement the above embodiment, the present application further proposes a non-transitory computer-readable storage medium, on which a computer program is stored, which when executed by a processor implements the text template generation method as described in the above embodiment.
In the description of the present specification, a description referring to terms "one embodiment," "some embodiments," "examples," "specific examples," or "some examples," etc., means that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the present application. In this specification, schematic representations of the above terms are not necessarily directed to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. Furthermore, the different embodiments or examples described in this specification and the features of the different embodiments or examples may be combined and combined by those skilled in the art without contradiction.
Furthermore, the terms "first," "second," and the like, are used for descriptive purposes only and are not to be construed as indicating or implying a relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defining "a first" or "a second" may explicitly or implicitly include at least one such feature. In the description of the present application, the meaning of "plurality" is at least two, such as two, three, etc., unless explicitly defined otherwise.
Any process or method descriptions in flow charts or otherwise described herein may be understood as representing modules, segments, or portions of code which include one or more executable instructions for implementing specific logical functions or steps of the process, and additional implementations are included within the scope of the preferred embodiment of the present application in which functions may be executed out of order from that shown or discussed, including substantially concurrently or in reverse order, depending on the functionality involved, as would be understood by those reasonably skilled in the art of the embodiments of the present application.
Logic and/or steps represented in the flowcharts or otherwise described herein, e.g., a ordered listing of executable instructions for implementing logical functions, can be embodied in any computer-readable medium for use by or in connection with an instruction execution system, apparatus, or device, such as a computer-based system, processor-containing system, or other system that can fetch the instructions from the instruction execution system, apparatus, or device and execute the instructions. For the purposes of this description, a "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transport the program for use by or in connection with the instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of the computer-readable medium would include the following: an electrical connection (electronic device) having one or more wires, a portable computer diskette (magnetic device), a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disc read-only memory (CDROM). In addition, the computer readable medium may even be paper or other suitable medium on which the program is printed, as the program may be electronically captured, via, for instance, optical scanning of the paper or other medium, then compiled, interpreted or otherwise processed in a suitable manner, if necessary, and then stored in a computer memory.
It is to be understood that portions of the present application may be implemented in hardware, software, firmware, or a combination thereof. In the above-described embodiments, the various steps or methods may be implemented in software or firmware stored in a memory and executed by a suitable instruction execution system. As with the other embodiments, if implemented in hardware, may be implemented using any one or combination of the following techniques, as is well known in the art: discrete logic circuits having logic gates for implementing logic functions on data signals, application specific integrated circuits having suitable combinational logic gates, programmable Gate Arrays (PGAs), field Programmable Gate Arrays (FPGAs), and the like.
Those of ordinary skill in the art will appreciate that all or a portion of the steps carried out in the method of the above-described embodiments may be implemented by a program to instruct related hardware, where the program may be stored in a computer readable storage medium, and where the program, when executed, includes one or a combination of the steps of the method embodiments.
In addition, each functional unit in each embodiment of the present application may be integrated in one processing module, or each unit may exist alone physically, or two or more units may be integrated in one module. The integrated modules may be implemented in hardware or in software functional modules. The integrated modules may also be stored in a computer readable storage medium if implemented in the form of software functional modules and sold or used as a stand-alone product.
The above-mentioned storage medium may be a read-only memory, a magnetic disk or an optical disk, or the like. Although embodiments of the present application have been shown and described above, it will be understood that the above embodiments are illustrative and not to be construed as limiting the application, and that variations, modifications, alternatives, and variations may be made to the above embodiments by one of ordinary skill in the art within the scope of the application.