A scene image text generation method and device, electronic equipment and storage medium

By generating an RGB background image library and a font library, and combining them with a corpus information set, and randomly selecting text, background images, and fonts, the problem of obtaining text data samples in Internet scenarios is solved, enabling the rapid generation of diverse image text data and improving the generalization ability of OCR text recognition.

CN114863410BActive Publication Date: 2025-11-04SHIQU INTERACTIVE (BEIJING) TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202210416414.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-20
Publication Date
2025-11-04
Estimated Expiration
2042-04-20

AI Technical Summary

Technical Problem

Existing technologies require significant manpower and resources to acquire text data samples from online images in internet scenarios. Furthermore, the complexity of the background and the characteristics of artistic fonts result in low efficiency in data acquisition and annotation, making it difficult to meet the need for rapid and accurate extraction of text information.

Method used

By collecting text information from beauty scenarios, an RGB background image library and a font library are generated. Combined with the corpus information set, text, background images, and fonts are randomly selected to generate a scene image text dataset, including difference judgment and replacement character processing to meet specific character requirements.

Benefits of technology

It can quickly generate large amounts of image and text data with diverse backgrounds and fonts, reducing the difficulty of data acquisition and annotation, improving the generalization ability of OCR text recognition, reducing manual annotation, and meeting training and testing needs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114863410B_ABST
    Figure CN114863410B_ABST
Patent Text Reader

Abstract

The application provides a scene image text generation method and device, electronic equipment and a storage medium, which quickly generate a large number of scene image texts through corpus information of an image text data set, a background image library and a font library. Not only can the data acquisition and labeling difficulty be reduced, but also images with background diversity and font diversity can be quickly acquired, which is convenient for researchers to perform model training and testing, and is not subject to objective reasons such as a small amount of training data and a long labeling period, so that the generalization capability of OCR text recognition is improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computers, in particular to a scene image text generation method and device, electronic equipment and storage medium. BACKGROUND

[0002] With the rapid development of social media, e-commerce, short video, live broadcast and other media, a large amount of data content is generated every day, especially the current video live selling and short video shopping are in full swing. Compared with text information, visual marketing based on pictures and videos has more communication strength. How to quickly and accurately extract text information from massive picture or video data and analyze brand attributes has become one of the important tasks. The current common method mainly uses general text recognition technology to identify the artistic font or background complex text content of the network picture in the Internet scene, so as to facilitate users to extract the text information, and then use NLP technology to analyze and process the text information to obtain brand related content information. Using the above method, a large amount of scene image text data samples need to be obtained for training and testing to achieve ideal results. The network pictures in the Internet scene have the characteristics of complex background, occlusion and artistic font. In order to obtain a sufficient number of samples, the researchers often need to spend a lot of manpower and material resources to obtain and label data, which wastes a lot of time and effort. Therefore, how to more efficiently obtain the scene image text data samples needed for training and testing is a problem to be solved at present. SUMMARY

[0003] In order to improve the above problems, the present application provides a scene image text generation method, device, electronic equipment and storage medium.

[0004] The first aspect of the embodiment of the present application provides a scene image text generation method, which comprises:

[0005] Collecting text information of a makeup scene, filtering the collected text information by taking each makeup brand name as a keyword to obtain a corpus information set; the corpus information set comprises first corpus information and second corpus information, taking text information containing a makeup brand name as the first corpus information, and taking text information not containing a makeup brand name as the second corpus information;

[0006] Generating RGB background images of different colors using OpenCV to obtain a background image library;

[0007] Collecting open source, free or public fonts in an Internet scene to obtain a font library, and counting support characters of each font to obtain a support character list and number;

[0008] Combine the corpus information set, the background image library and the font library to generate an image text data set; the image text data set includes a plurality of scene image texts, and each scene image text is generated in the following manner:

[0009] Randomly select a piece of text information from the first corpus information as content information for generating an image text;

[0010] Randomly select an image from the background image library as a background image for generating an image text;

[0011] Randomly select a font from the font library;

[0012] Integrate the selected content information, background image and font to obtain a scene image text.

[0013] Optionally, after the step of randomly selecting a font from the font library, the method further comprises:

[0014] According to the characters of the selected content information, the pixel difference value between the font color of each character and the color of the selected background image is calculated in sequence and accumulated to obtain a sum value of the difference value;

[0015] It is judged whether the sum value is greater than a preset threshold value, if yes, the current font is selected as a candidate font, and if no, the selection of the font is re-performed;

[0016] When the selected content information contains a character that is not supported by the selected font, a pre-set substitute character is used to replace the unsupported character.

[0017] Optionally, the method further comprises:

[0018] Receive an external input generation control instruction, the generation control instruction including a scene image text number, a character generation number, a specific character content and a specific character number.

[0019] Optionally, the method comprises:

[0020] When selecting the content information, if the number of specific characters corresponding to the specific character content in the first corpus information is less than the specific character number, the selection of the content information is performed from the second corpus information;

[0021] When the total number of generated specific characters reaches the specific character number, the specific character is no longer generated;

[0022] When the total number of generated characters reaches the character generation number, the generation is no longer continued;

[0023] When the number of generated scene image texts reaches the scene image text number, the generation is no longer continued.

[0024] In a second aspect, the present application provides a scene image text generation device, the device comprising:

[0025] A corpus information generation unit is configured to collect text information of a makeup scene, filter the collected text information by taking each makeup brand name as a keyword, and obtain a corpus information set; the corpus information set comprises first corpus information and second corpus information; the text information containing a makeup brand name is taken as the first corpus information, and the text information not containing a makeup brand name is taken as the second corpus information;

[0026] An image library generation unit is configured to generate RGB background images of different colors using OpenCV, and obtain a background image library;

[0027] A font library generation unit is configured to collect open source, free or public fonts in an Internet scene, obtain a font library, and count support characters of each font to obtain a support character list and a number;

[0028] A scene image text generation unit is configured to generate an image text data set in combination with the corpus information set, the background image library and the font library;

[0029] The image text data set comprises a plurality of scene image texts, and the scene image text generation unit comprises:

[0030] A text information selection subunit is configured to randomly select a piece of text information from the first corpus information as content information of a generated image text;

[0031] A background image selection subunit is configured to randomly select an image from the background image library as a background image of a generated image text;

[0032] A font selection subunit is configured to randomly select a font from the font library;

[0033] A comprehensive generation subunit is configured to comprehensively generate the selected content information, background image and font to obtain a scene image text.

[0034] Optionally, the font selection subunit is further configured to:

[0035] Calculate pixel difference values of each character font color and the color of the selected background image according to the characters of the selected content information, and accumulate the difference values to obtain a sum value of the difference values;

[0036] Determine whether the sum value is greater than a preset threshold value; if yes, select the current font as a candidate font; and if no, reselect the font;

[0037] The comprehensive generation subunit is further configured to:

[0038] When the selected content information contains a character that is not supported by the selected font, a preset alternative character is used to replace the unsupported character.

[0039] Optionally, the apparatus further comprises:

[0040] The control instruction receiving unit is configured to receive an externally input generation control instruction, the generation control instruction including a scene image text number, a character generation number, a specific character content, and a specific character number.

[0041] Optionally, the text information selecting subunit is further configured to:

[0042] When the number of specific characters corresponding to the specific character content in the first corpus information is less than the specific character number, the content information is selected from the second corpus information.

[0043] The comprehensive generation subunit is further configured to:

[0044] When the total number of generated specific characters reaches the specific character number, the specific character is no longer generated.

[0045] When the total number of generated characters reaches the character generation number, the generation is no longer continued.

[0046] When the number of generated scene image texts reaches the scene image text number, the generation is no longer continued.

[0047] A third aspect of the embodiment of the application provides an electronic device, characterized by comprising:

[0048] one or more processors; a memory; one or more application programs, wherein the one or more application programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs are configured to execute the method according to the first aspect.

[0049] A fourth aspect of the embodiment of the application provides a computer readable storage medium, characterized by comprising a program code, wherein the program code is stored in the computer readable storage medium and can be called and executed by a processor to execute the method according to the first aspect.

[0050] In summary, the present application provides a scene image text generation method and device, electronic equipment and storage medium, which quickly generates a large number of scene image texts through corpus information of an image text data set, a background image library and a font library. Not only can the data acquisition and labeling difficulty be reduced, but also the background diversity and font diversity images can be quickly acquired, which is convenient for researchers to perform model training and testing without being subject to objective reasons such as less training data and long labeling period. The present application is an important source of OCR text detection and recognition task training data set acquisition, has the characteristics of background and font diversity, can make up for the shortage of image text training data set, thereby reducing manual labeling, and can increase the diversity of image text data set, thereby improving the generalization ability of OCR text recognition. BRIEF DESCRIPTION OF DRAWINGS

[0051] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings needed to be used in the embodiments. It should be understood that the following drawings only show some of the embodiments of the present application, and therefore should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can also be obtained without creative labor on the basis of these drawings.

[0052] Figure 1 The application scenario diagram of the scene image text generation method and device of the embodiments of the present application;

[0053] Figure 2 The method flowchart of the scene image text generation method of the embodiments of the present application;

[0054] Figure 3 The method flowchart of the scene image text generation method of the embodiments of the present application;

[0055] Figure 4 The method flowchart of the scene image text generation method of the embodiments of the present application;

[0056] Figure 5 The function module block diagram of the scene image text data generation device of the embodiments of the present application;

[0057] Figure 6 The structural block diagram of the electronic equipment for executing the scene image text generation method according to the embodiments of the present application.

[0058] Figure 7 The structural block diagram of the computer readable storage medium for saving or carrying the program code for implementing the scene image text generation method according to the embodiments of the present application.

[0059] Icon:

[0060] Cloud server 100; user client 200; corpus information generation unit 110; image library generation unit 120; font library generation unit 130; scene image text generation unit 140; control instruction receiving unit 150; text information selection subunit 141; background image selection subunit 142; font selection subunit 143; comprehensive generation subunit 144; electronic device 300; processor 310; memory 320; computer readable storage medium 400; program code 410. DETAILED DESCRIPTION

[0061] With the rapid development of social media, e-commerce, short video, live broadcast and other media, a large amount of data content is generated every day, especially the current video live selling and short video shopping are in full swing. Compared with text information, visual marketing based on pictures and videos has more communication strength. How to quickly and accurately extract text information from a large amount of picture or video data and analyze brand attributes has become one of the important tasks. The common way at present is to use general text recognition technology to identify artistic fonts or background complex text content of network pictures in Internet scenes, so as to facilitate users to extract text information, and then use NLP technology to analyze and process the text information to obtain brand related content information. Using the above method, a large number of scene image text data samples need to be obtained for training and testing to achieve ideal results. However, network pictures in Internet scenes have the characteristics of complex background, occlusion and artistic fonts. In order to obtain a sufficient number of samples, researchers often need to spend a lot of manpower and material resources to obtain and label data, which wastes a lot of time and effort. Therefore, how to more efficiently obtain the scene image text data samples needed for training and testing is a problem to be solved at present

[0062] Therefore, the designer of the present application designs a scene image text generation method, device, electronic device and storage medium, which quickly generates a large number of scene image texts through corpus information of image text data set, background image library and font library. Not only can it reduce the difficulty of data acquisition and labeling, but also can quickly obtain images with background diversity and font diversity, which is convenient for researchers to model training and testing, without being subject to the objective reasons of less training data and long labeling period, thereby improving the generalization ability of OCR text recognition.

[0063] In order to make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be described clearly and completely below in combination with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various different configurations.

[0064] Therefore, the following detailed description of the embodiments of the application provided in the drawings is not intended to limit the scope of the application claimed, but merely represents selected embodiments of the application. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in the application without creative labor fall within the scope of the application.

[0065] It should be noted that similar reference numbers and letters represent similar items in the following drawings, and therefore, once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings.

[0066] In the description of the application, it should be noted that the terms "top", "bottom", "inner", "outer" and the like indicate the orientation or positional relationship based on the orientation or positional relationship shown in the drawings, or the orientation or positional relationship in which the product of the application is usually placed, and are only for the convenience of describing the application and simplifying the description, and therefore cannot be understood as indicating or implying that the device or element must have a particular orientation, be constructed and operated in a particular orientation, and therefore cannot be understood as limiting the application. In addition, the terms "first", "second" and the like are only used to distinguish the description and cannot be understood as indicating or implying relative importance.

[0067] In the description of the application, it should also be noted that unless otherwise explicitly specified and limited, the terms "set", "mount", "connected", "connected" should be broadly understood, for example, it can be fixedly connected, or it can be detachably connected, or integrally connected; it can be mechanically connected, or it can be electrically connected; it can be directly connected, or it can be indirectly connected through an intermediate medium; it can be the communication inside two elements. For those of ordinary skill in the art, the specific meaning of the above terms in the application can be understood according to the specific circumstances.

[0068] It should be noted that the embodiments in the application and the features in the embodiments can be combined with each other without conflict.

[0069] Embodiments

[0070] Please refer to Figure 1 The application scenario diagram of the scene image text generation method and device provided in the embodiment is shown in the following figure.

[0071] As Figure 1As shown, the scene image text generation method and device provided by the present application can be applied to a cloud server 100, which is connected with a user client 200 through the Internet or other manners. When generating a scene image text, the cloud server 100 obtains a control instruction through the Internet or the user client 200, and sends the generated scene image text to the user client 200 or other places for storage. The database for saving corpus information, a background image library and a font library can be arranged in the cloud server 100, or in other devices or terminals connected with the cloud server 100.

[0072] It should be noted that the text content classification method and device provided by the present application can also be applied to local terminals other than the cloud server 100, such as a PC computer, a smart phone, a tablet computer or other devices with data processing and data interaction functions.

[0073] On the basis of the above, Figure 2 As shown, the scene image text generation method provided by an embodiment of the present application comprises the following steps.

[0074] In step S101, text information of a makeup scene is collected, and each makeup brand name is used as a keyword to filter the collected text information to obtain a corpus information set.

[0075] The corpus information set comprises first corpus information and second corpus information. The specific filtering method is that the text information containing the makeup brand name is used as the first corpus information, and the text information not containing the makeup brand name is used as the second corpus information. The makeup brand name can be pre-entered or updated at any time.

[0076] As a preferred embodiment, a list containing all makeup brand names is prepared in advance when collecting text information. If the text information contains the brand name in the list, the text information is reserved.

[0077] After filtering, the character frequency of the first corpus information and the second corpus information is counted to obtain the number of times of appearance of the character, and the line frequency of the line where the character is located is counted to obtain the number of lines of appearance of the character.

[0078] In step S102, different color RGB background images are generated using OpenCV to obtain a background image library.

[0079] The background image library is mainly generated by random color generation based on OpenCV to obtain an RGB background image. Each channel value of RGB is (0-255), and a certain color is within a certain range of RGB channel value (0-255). In the process of generating a background image, the user can select to generate a specific number of background images N in advance in order to reduce the generation of repeated background images. According to the value of N, the color diversity can be changed by setting a step S. That is, the color is composed of the pixel values of the three channels of RGB. First, a pixel value is randomly generated to generate a background color image, and then the pixel value is generated with a certain step to generate a color. A complete background color image can be generated by setting the size of the background image and the random background color pixel value generated by the user. Multiple background images are generated to form a background image library.

[0080] In step S103, open source, free or public fonts in the Internet scene are collected to obtain a font library. The supported characters of each font are counted to obtain a list of supported characters and numbers.

[0081] In the font library, the font corresponds to the sample data, and the character corresponds to the label. The number of all characters corresponding to the font is counted, and then a list containing the characters and the fonts in the font library is obtained.

[0082] In step S104, the image text data set is generated by combining the corpus information set, the background image library and the font library.

[0083] The image text data set includes multiple scene image texts. Each scene image text is generated by the method as shown in Figure 3

[0084] In step S201, a text information is randomly selected from the first corpus information as content information of the generated image text.

[0085] In step S202, an image is randomly selected from the background image library as the background image of the generated image text.

[0086] In step S203, a font is randomly selected from the font library.

[0087] In step S204, the selected content information, background image and font are integrated to obtain a scene image text.

[0088] Based on the above method, a large number of scene image texts meeting the requirements of algorithm training and testing can be generated by the corpus information set, the background image library and the font library. The scene image texts are combined into an image text data set and sent to users or researchers who need these data.

[0089] ​The scene image text generation method provided in the embodiment can quickly generate a large number of scene image texts through corpus information of an image text data set, a background image library and a font library. Not only can the difficulty of data acquisition and labeling be reduced, but also images with background diversity and font diversity can be quickly acquired, which facilitates model training and testing of R&D personnel and does not need to be subject to objective reasons such as less training data and long labeling period. The scheme is an important source of training data set acquisition of an OCR text detection and recognition task and has the characteristics of background and font diversity, can make up for the shortage of image text training data set and reduce manual labeling, and can increase the diversity of the image text data set and improve the generalization ability of OCR text recognition.

[0090] As shown in FIG. 1, the scene image text generation method of another embodiment of the present application comprises the following steps. Figure 4

[0091] Step S301, receiving an externally input generation control instruction; the generation control instruction comprises a scene image text number, a character generation number, specific character content and a specific character number.

[0092] In the generation process, the user can set the last generated image text number, the specific character content and the character generation number. When generating scene image texts, some users may have certain requirements for the generated content, such as the need to contain specific characters, and even further limit the number of specific characters, so that the corresponding generation control instruction can be sent to achieve this.

[0093] Step S302, judging whether the number of specific characters corresponding to the specific character content in the first corpus information is less than the specific character number, if not, executing step S303, and if yes, executing step 304.

[0094] Step S303, randomly selecting a piece of text information from the first corpus information as content information of the generated image text.

[0095] Step S304, selecting the content information from the second corpus information.

[0096] In the embodiment, when the text information containing specific characters in the first corpus information has been used up, but the requirement for the number of specific characters in the generation control instruction has not been met, the text information needs to be acquired from the second corpus information as the content information of the generated image text.

[0097] Step S305, randomly selecting an image from the background image library as a background image of the generated image text.

[0098] Step S306, randomly selecting a font from the font library.​

[0099] In the embodiment, each font, color, and supported number of characters can be different. After selecting a font, different effects can be generated due to different content information.

[0100] In step S307, pixel difference values between the color of each character of the selected content information and the color of the selected background image are calculated and accumulated to obtain a sum value of the difference values.

[0101] To avoid the situation that the font color is too close to the background image color, which leads to misrecognition or low recognition accuracy, the color of the character of the content information using the font is compared with the color of the background image. The above method can effectively calculate the similarity between the two. Based on the preset threshold, the situation can be effectively avoided.

[0102] In step S308, it is determined whether the sum value is greater than a preset threshold. If yes, step S309 is performed. If no, step S306 is performed again.

[0103] If the selected font causes the color of the character of the content information to be close to the background image, the selection needs to be returned to be performed again. If the similarity is low, the subsequent generation step is performed.

[0104] In step S309, the scene image text is obtained by comprehensively considering the selected content information, background image, and font.

[0105] When the font is comprehensively considered, the unsupported characters are also considered. If the content information includes unsupported characters of the selected font, the pre-set substitute character can be used to replace the unsupported character. The setting of the substitute character can be set according to the actual situation. Usually, a character with very low frequency of occurrence or no impact on other content is used. For example, # can be used as a substitute character.

[0106] Based on the content included in the generation control instruction, when the scene image text is generated, the corresponding termination condition needs to be determined. The termination condition is related to multiple aspects, and specifically includes:

[0107] When the total number of generated specific characters reaches the number of specific characters, the specific character is no longer generated. For the case of specific character requirement, it is determined whether the total number of generated specific characters meets the requirement.

[0108] When the total number of generated characters reaches the character generation number, the generation is no longer continued. When the number of generated character lines, i.e., the number of images, exceeds the set value, the line generation is no longer continued. When the number of generated scene image texts reaches the scene image text number, the generation is no longer continued. For the number of words, the number of character lines, and the number of scene image texts, there can be corresponding termination conditions, and the termination conditions are judged and corresponding generation control instructions are generated. When the termination condition is met, the corresponding content is stopped from being generated. When the total number of generated images exceeds the set value, the generation is exited.

[0109] In summary, the scene image text generation method provided in the embodiment can quickly generate a large number of scene image texts through corpus information of an image text data set, a background image library, and a font library. Not only can the difficulty of data acquisition and labeling be reduced, but also images with background diversity and font diversity can be quickly acquired, which facilitates model training and testing of R&D personnel and does not have to be subject to objective reasons such as a lack of training data and a long labeling period. The present solution is an important source of training data set acquisition for an OCR text detection and recognition task and has the characteristics of background and font diversity, which can not only make up for the lack of image text training data sets and thus reduce manual labeling, but also increase the diversity of image text data sets and thus improve the generalization ability of OCR text recognition.

[0110] As shown in Figure 5 The scene image text generation device provided in the embodiment of the present application comprises:

[0111] The corpus information generation unit 110 is configured to collect text information of a makeup scene, filter the collected text information by taking each makeup brand name as a keyword, and obtain a corpus information set. The corpus information set comprises first corpus information and second corpus information. The text information containing the makeup brand name is taken as the first corpus information, and the text information not containing the makeup brand name is taken as the second corpus information.

[0112] The image library generation unit 120 is configured to generate RGB background images of different colors by using OpenCV and obtain a background image library.

[0113] The font library generation unit 130 is configured to collect open source, free, or public fonts in an Internet scene, obtain a font library, and count supported characters for each font to obtain a supported character list and a number.

[0114] The scene image text generation unit 140 is configured to generate an image text data set by combining the corpus information set, the background image library, and the font library.

[0115] The image text data set comprises a plurality of scene image texts, and the scene image text generation unit 140 comprises:

[0116] The text information selection sub-unit 141 is configured to randomly select a piece of text information from the first corpus information as content information for generating an image text.

[0117] The background image selection sub-unit 142 is configured to randomly select an image from the background image library as a background image for generating an image text.

[0118] The font selection sub-unit 143 is configured to randomly select a font from the font library.

[0119] The integrated generation sub-unit 144 is configured to integrate the selected content information, the background image and the font to obtain a scene image text.

[0120] As a preferred implementation of the embodiment, the font selection sub-unit 143 is further configured to:

[0121] calculate pixel difference values between a font color of each character of the selected content information and a color of the selected background image in sequence and accumulate the pixel difference values to obtain a sum value of the pixel difference values;

[0122] determine whether the sum value is greater than a preset threshold value, and if yes, select a current font as a candidate font, and if no, reselect the font;

[0123] The integrated generation sub-unit 144 is further configured to:

[0124] when the selected content information contains a character that is not supported by the selected font, replace the character that is not supported by the selected font with a preset alternative character.

[0125] As a preferred implementation of the embodiment, the device further comprises:

[0126] The control instruction receiving unit 150 is configured to receive an externally input generation control instruction, and the generation control instruction includes a scene image text number, a character generation number, a specific character content and a specific character number.

[0127] As a preferred implementation of the embodiment, the text information selection sub-unit 141 is further configured to:

[0128] when selecting the content information, if a number of specific characters corresponding to the specific character content in the first corpus information is less than the specific character number, select the content information from the second corpus information;

[0129] The integrated generation sub-unit 144 is further configured to:

[0130] when a total number of generated specific characters reaches the specific character number, the specific characters are no longer generated continuously;

[0131] When the total number of characters generated reaches the specified character generation limit, generation will cease.

[0132] When the number of generated scene image texts reaches the specified number, generation will stop.

[0133] The scene image text generation apparatus provided in this embodiment of the invention is used to implement the above-described scene image text generation method. Therefore, the specific implementation method is the same as the above method and will not be repeated here.

[0134] like Figure 6 The diagram shows a structural block diagram of an electronic device 300 provided in an embodiment of the present invention. This electronic device 300 can be a smartphone, tablet computer, e-reader, or other electronic device capable of running applications. The electronic device 300 in this application may include one or more of the following components: a processor 310, a memory 320, and one or more applications, wherein the one or more applications can be stored in the memory 320 and configured to be executed by one or more processors 310, and the one or more applications are configured to perform the methods described in the foregoing method embodiments.

[0135] Processor 310 may include one or more processing cores. Processor 310 connects to various parts within the electronic device 300 using various interfaces and lines, and performs various functions and processes data of the electronic device 300 by running or executing instructions, programs, code sets, or instruction sets stored in memory 320, and by calling data stored in memory 320. Optionally, processor 310 may be implemented using at least one hardware form of Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), or Programmable Logic Array (PLA). Processor 310 may integrate one or a combination of several of the following: Central Processing Unit (CPU), Graphics Processing Unit (GPU), and modem. The CPU primarily handles the operating system, user interface, and applications; the GPU is responsible for rendering and drawing the displayed content; and the modem handles wireless communication. It is understood that the modem may also not be integrated into processor 310 and may be implemented separately using a communication chip.

[0136] The memory 320 can include a random access memory (RAM) and can also include a read-only memory (ROM). The memory 320 can be used to store instructions, programs, codes, code sets, or instruction sets. The memory 320 can include a program storage area and a data storage area, where the program storage area can store instructions for implementing an operating system, instructions for implementing at least one function (such as a touch function, a sound playing function, an image playing function, etc.), instructions for implementing each of the following method embodiments, etc. The data storage area can also store data created by the terminal in use (such as a phone book, audio and video data, chat record data), etc.

[0137] As shown in Figure 7 A structural block diagram of a computer readable storage medium 400 provided by an embodiment of the present application is shown. The computer readable medium stores program codes 410, which can be invoked by a processor to execute the methods described in the above method embodiments.

[0138] The computer readable storage medium 400 can be an electronic storage such as a flash memory, an EEPROM (electrically erasable programmable read-only memory), an EPROM, a hard disk, or a ROM. Alternatively, the computer readable storage medium 400 includes a non-transitory computer readable medium. The computer readable storage medium 400 has a storage space for the program codes 410 for executing any of the above methods. These program codes 410 can be read from or written into one or more computer program products. The program codes 410 can be compressed in an appropriate form, for example.

[0139] To sum up, the present application provides a scene image text generation method and device, electronic equipment and storage medium, which quickly generates a large number of scene image texts through corpus information of an image text data set, a background image library and a font library. Not only can it reduce data acquisition and labeling difficulty, but also can quickly obtain images with background diversity and font diversity, which is convenient for researchers to train and test models without being subject to objective reasons such as lack of training data and long labeling period. The present application is an important source of OCR text detection and recognition task training data set acquisition, which has the characteristics of background and font diversity, can not only make up for the lack of image text training data set, thereby reducing manual labeling, but also increase the diversity of image text data set, thereby improving the generalization ability of OCR text recognition.

[0140] In several embodiments disclosed in the present application, it should be understood that the disclosed apparatus and method can also be implemented in other manners. The described apparatus embodiments are merely illustrative. For example, the flowchart and block diagram in the accompanying drawings show the possible implementation architecture, function and operation of the apparatus, method and computer program product according to the embodiments of the present application. In this regard, each block in the flowchart or block diagram can represent a module, a segment or a portion of code which comprises one or more executable instructions for implementing the specified logic function. It should also be noted that in some alternative implementations, the functions shown in the blocks can occur in a different order than that shown in the figure. For example, two blocks shown in succession can in fact be executed substantially concurrently or in the reverse order, depending on the functionality involved. It should also be noted that each block in the block diagrams and / or flowchart illustrations, and combinations of blocks in the block diagrams and / or flowchart illustrations, can be implemented by dedicated hardware-based systems which perform the specified functions or acts or can be implemented by a combination of dedicated hardware and computer instructions.

[0141] In addition, the various functional modules in the embodiments of the present application can be integrated together to form a separate part, or each module can exist independently, or two or more modules can be integrated to form a separate part.

[0142] If the functions are implemented in the form of software function modules and sold or used as an independent product, they can be stored in a computer readable storage medium. Based on this understanding, the technical solutions of the present application essentially or the part that makes a contribution to the prior art or the part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a number of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the embodiments of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disk, and various other media that can store program codes.

Claims

1. A method of generating text from a scene image, characterized by, The method comprises: Collecting text information of a makeup scene, filtering the collected text information by taking each makeup brand name as a keyword to obtain a corpus information set; the corpus information set comprises first corpus information and second corpus information, text information containing a makeup brand name is taken as the first corpus information, and text information not containing a makeup brand name is taken as the second corpus information; Generating RGB background images of different colors by using OpenCV to obtain a background image library; Collecting open source, free or public fonts in an Internet scene to obtain a font library, and counting supported characters of each font to obtain a supported character list and a number; Combining the corpus information set, the background image library and the font library to generate an image text data set; the image text data set comprises a plurality of scene image texts, and each scene image text is generated in the following manner: Randomly selecting a piece of text information from the first corpus information as content information of a generated image; Randomly selecting an image from the background image library as a background image of the generated image text; Randomly selecting a font from the font library; Integrating the selected content information, the background image and the font to obtain a scene image text. The method further comprises: Receiving an external inputted generation control instruction, the generation control instruction comprising a scene image text number, a character generation number, a specific character content and a specific character number; When selecting the content information, if the number of specific characters corresponding to the specific character content in the first corpus information is less than the specific character number, the selection of the content information is performed from the second corpus information; When the total number of generated specific characters reaches the specific character number, the specific characters are no longer generated; When the total number of generated characters reaches the character generation number, the generation is no longer continued; When the number of generated scene image texts reaches the scene image text number, the generation is no longer continued.

2. The scene image text generation method of claim 1, wherein, After the step of randomly selecting a font from the font library, the method further comprises: According to the characters of the selected content information, pixel difference values of each character font color and the color of the selected background image are calculated in sequence, and a sum value of the difference values is obtained by accumulation; It is judged whether the sum value is greater than a preset threshold value, if yes, the current font is selected as a candidate font, and if no, the selection of the font is re-performed; When the selected content information contains a character not supported by the selected font, a preset alternative character is used to replace the unsupported character.

3. A scene image text generation apparatus characterized by comprising: The device comprises: A corpus information generation unit configured to collect text information of a makeup scene, filter the collected text information by taking each makeup brand name as a keyword to obtain a corpus information set; the corpus information set comprises first corpus information and second corpus information, text information containing a makeup brand name is taken as the first corpus information, and text information not containing a makeup brand name is taken as the second corpus information; An image library generation unit configured to generate RGB background images of different colors by using OpenCV to obtain a background image library; The font library generating unit is configured to collect open source, free or public fonts in an Internet scenario, obtain a font library, and count supported characters of each font to obtain a supported character list and a number; The scene image text generating unit is configured to generate an image text dataset in combination with the corpus information set, the background image library and the font library; The image text dataset includes a plurality of scene image texts, and the scene image text generating unit includes: The text information selection subunit is configured to randomly select a piece of text information from the first corpus information as content information for generating an image text; The background image selection subunit is configured to randomly select an image from the background image library as a background image for generating an image text; The font selection subunit is configured to randomly select a font from the font library; The comprehensive generation subunit is configured to comprehensively generate the selected content information, the background image and the font to obtain a scene image text; The device further includes: The control instruction receiving unit is configured to receive an externally input generation control instruction, and the generation control instruction includes a number of scene image texts, a number of generated characters, specific character content and a number of specific characters; The text information selection subunit is further configured to: When selecting the content information, if a number of specific characters corresponding to the specific character content in the first corpus information is less than the number of specific characters, the content information is selected from the second corpus information; The comprehensive generation subunit is further configured to: When the total number of generated specific characters reaches the number of specific characters, the specific characters are no longer generated; When the total number of generated characters reaches the number of generated characters, the generation is no longer continued; When the number of generated scene image texts reaches the number of scene image texts, the generation is no longer continued.

4. The scene image text generating device according to claim 3, wherein The font selection subunit is further configured to: According to the characters of the selected content information, pixel difference values of font colors of each character and a color of the selected background image are sequentially calculated and accumulated to obtain a sum value of the difference values; It is judged whether the sum value is greater than a preset threshold value, if yes, the current font is selected as a candidate font, and if no, the selection of the font is re-performed; The comprehensive generation subunit is further configured to: When the selected content information contains a character that is not supported by the selected font, a pre-set substitute character is used to replace the unsupported character.

5. An electronic device, comprising: one or more processors; a memory; one or more application programs, wherein the one or more application programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs are configured to perform the method of any one of claims 1-2. The computer readable storage medium stores program codes, and the program codes can be invoked and executed by a processor to perform the method of any one of claims 1-2.

6. A computer-readable storage medium, characterized in that, ​

Citation Information

Patent Citations

  • Text information generation method and device, storage medium and equipment

    CN108363697A

  • Text style migration model training method and system and image generation method and system

    CN112418310A

  • Picture synthesis method and device and character recognition system

    CN112488114A