Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are some embodiments of the present invention, but not all embodiments of the present invention. All other embodiments obtained based on the embodiments in the present invention are within the scope of the protection of the present invention.
The conventional Font recognition algorithm mainly comprises a feature extraction method, wherein shallow features of a Font picture to be recognized are extracted through conventional algorithms such as SIFT, wavelet multi-layer decomposition and the like, then the features are combined according to a certain rule, similarity matching calculation is carried out on the features and a feature library generated by a Font file (TTF for short), and finally a result with the maximum similarity value is selected as the name of the Font to be recognized. However, due to the fact that the conventional font recognition scheme is adopted, necessary image preprocessing (noise removal, deblurring, inclination correction and the like) is required for the font picture to be recognized, partial font features of the font picture to be recognized can be indirectly lost, recognition accuracy is low, names of fonts which are currently liked by a user cannot be recognized rapidly and accurately, and accordingly user experience is poor. In order to solve the technical problems, the invention provides a font identification method, a font identification device, font identification equipment and a computer readable storage medium.
It should be noted that the font identification method, apparatus, device and computer readable storage medium provided by the present invention can be applied to any font identification scene.
Fig. 1 is a diagram of a network architecture according to the present invention, and as shown in fig. 1, the network architecture according to the present invention at least includes a font recognition device 1 and a photographing module 2. The font recognition device 1 may be implemented by software and/or hardware, and may be written in C language, java, or the like when implemented in software. The photographing module 2 may be a camera provided in the user terminal or a separate camera or video camera, etc. The font recognition device 1 may be provided in the user terminal or may be a separate device, and accordingly, the photographing module 2 may be provided in the user terminal or may be a separate camera or video camera, etc., and the present invention is not limited thereto. It should be noted that, the font recognition device 1 may communicate with the shooting module 2 in a wired or wireless manner to implement data interaction, specifically, when the font recognition device 1 and the shooting module 2 are both disposed in the user terminal, they may communicate in a wired manner, and when they are not disposed in the same terminal, they may communicate in a wireless manner.
Fig. 2 is a flow chart of a font identification method according to a first embodiment of the present invention, and based on the above embodiment, the method includes:
and step 101, receiving the font image shot by the shooting module.
The execution main body of the embodiment is a font recognition device, and the font recognition device can communicate with the shooting module in a wired or wireless mode to realize data interaction. Specifically, when the user finds a favorite font, the user can shoot the font through a shooting module to obtain a font image of the font, and the font image is sent to the font identification device in a wired or wireless mode. Accordingly, the font recognition device may accept the font image transmitted from the photographing module.
As an implementation manner, the font image may be a screenshot of the font of the centering instrument when the user browses a certain interface through the user terminal, or may be a font image obtained in any other form, and the present invention is not limited herein.
Step 102, preprocessing the font image.
In the present embodiment, in order to improve the accuracy of font recognition, the font recognition device may perform preprocessing on the font image after receiving the font image, and obtain the processed font image.
And step 103, adding the preprocessed font image into a preset font identification model to obtain a font name corresponding to the font image.
In this embodiment, in order to realize the recognition of the font, a font recognition model may be preset, the font image may be preprocessed, and after the processed font image is obtained, the processed font image may be added to the font recognition model, so as to realize the recognition of the font of the user cardiometer, and obtain the name of the font. Accordingly, after the name of the font is obtained, the name of the font can be displayed on a display screen of the user terminal, and then the user can download, use and other operations on the font according to the name of the font.
It can be understood that after the preprocessed font image is obtained, on the one hand, the recognition of the font can be implemented by using a preset font recognition model as in the above embodiment, and in addition, the recognition of the font can also be implemented by using any other recognition method, which is not limited herein.
According to the font identification method provided by the embodiment, the font image shot by the shooting module is received; preprocessing the font file; and adding the preprocessed font image into a preset font identification model to obtain a font name corresponding to the font image. Therefore, the names of the fonts liked by the user can be rapidly acquired, so that the user downloads and uses the fonts according to the font names, and the user experience is improved.
Further, on the basis of any one of the foregoing embodiments, the method further includes:
receiving a font image shot by a shooting module;
preprocessing the font image;
training a preset model to be trained through preset font data to be trained to obtain a preset font identification model;
and adding the preprocessed font image into a preset font identification model to obtain a font name corresponding to the font image.
In this embodiment, in order to realize the recognition of the font, a font recognition model may be preset, the font image may be preprocessed, after the processed font image is obtained, the processed font image may be added to the font recognition model, so as to realize the recognition of the font of the user cardiometer, and obtain the name of the font. Specifically, in order to acquire a font recognition model, a to-be-processed model needs to be established first, a convolutional neural network mainly comprises a data layer, a convolutional layer, an activation layer, a pooling layer, a full-connection layer, a classification layer and the like, different layers are combined and connected according to recognition purposes and required precision, and finally a to-be-processed model with proper width is designed. Specifically, a data layer is firstly established, the sizes of all input pictures are converted into m×m, then, the admission blocks are sequentially designed, each admission block comprises a convolution layer, an activation layer, a normalization layer, a pooling layer and the like, finally, a full-connection layer is designed, N results are output, and the results are arranged in sequence from large to small. And adding the preprocessed font image into a preset font identification model to obtain a font name corresponding to the font image.
According to the font identification method, the preset model to be trained is trained through the preset font data to be trained, and the preset font identification model is obtained, so that a foundation is provided for subsequent font identification, and user experience can be improved.
Fig. 3 is a flow chart of a font identification method according to a second embodiment of the present invention, where on the basis of any one of the above embodiments, the method includes:
step 201, receiving a font image shot by a shooting module;
step 202, preprocessing the font image;
step 203, obtaining preset data to be processed, wherein the data to be processed is a black-and-white font image;
step 204, the data to be processed are randomly rendered into color image data;
step 205, dividing the color image data into a test set and a training set randomly;
step 206, marking the color image data in the test set and the training set respectively to obtain the font data to be trained;
step 207, training a preset model to be trained through preset font data to be trained to obtain the preset font identification model;
step 208, adding the preprocessed font image to a preset font recognition model to obtain a font name corresponding to the font image.
In this embodiment, in order to achieve training of the model to be trained, font data to be trained should be acquired first. Specifically, preset data to be processed is obtained, the data to be processed is a black-and-white font image, for example, the data to be processed can be a square home font library n-style ttf file to generate a single-character single-image black-and-white image. Further, in order to improve the recognition accuracy of the model, data augmentation may be performed on the data to be processed. The black and white image may be randomly rendered as a colored RGB image. Further, the color image data are randomly divided into a training set and a testing set, and the training set and the testing set are marked to obtain data to be trained. Therefore, the model to be trained can be trained according to the data to be trained in the training set, and the font recognition model is finally obtained through testing the data in the data to be trained in the testing set. Therefore, the font image currently shot by the shooting module can be identified according to the font identification model, and the name of the font is obtained. Accordingly, after the name of the font is obtained, the name of the font can be displayed on a display screen of the user terminal, and then the user can download, use and other operations on the font according to the name of the font.
According to the font identification method provided by the embodiment, the preset data to be processed is acquired, and the data to be processed is a black-and-white font image; randomly rendering the data to be processed into color image data; randomly dividing the color image data into a test set and a training set; and marking the color image data in the test set and the training set respectively to obtain the font data to be trained, so that the recognition accuracy of the model can be improved, and the user experience is further improved.
Further, on the basis of any one of the above embodiments, the method includes:
receiving a font image shot by a shooting module;
preprocessing the font image;
acquiring preset data to be processed, wherein the data to be processed is a black-and-white font image;
randomly rendering the data to be processed into color image data;
randomly dividing the color image data into a test set and a training set;
adding random noise and random ambiguity in the test set and the training set;
labeling the font names of the color image data aiming at each color image data in the test set and the training set;
training a preset model to be trained through preset font data to be trained to obtain a preset font identification model;
and adding the preprocessed font image into a preset font identification model to obtain a font name corresponding to the font image.
In this embodiment, after the color image data is randomly divided into the training set and the testing set, the training set and the testing set need to be labeled to obtain the data to be trained. Specifically, interference processing such as random blurring and random noise can be added to data to be trained in a training set and a testing set, and in addition, in order to enable a font recognition model to accurately realize font recognition, font names need to be marked on the data in the testing set and the training set. Specifically, for each color image data in the test set and the training set, a font name of the color image data is noted.
According to the font identification method provided by the embodiment, random noise and random blurring are added in the test set and the training set; and labeling the font names of the color image data aiming at each color image data in the test set and the training set, so that the font identification model can accurately identify the fonts, and the user experience is improved.
Further, on the basis of any one of the above embodiments, the method includes:
receiving a font image shot by a shooting module;
preprocessing the font image;
acquiring preset data to be processed, wherein the data to be processed is a black-and-white font image;
randomly rendering the data to be processed into color image data;
randomly dividing the color image data into a test set and a training set;
respectively labeling the color image data in the test set and the training set to obtain the font data to be trained;
training the model to be trained through the test set and the training set, and adjusting the hyper-parameters of the model to be trained until the model to be trained converges to obtain the font identification model;
and adding the preprocessed font image into a preset font identification model to obtain a font name corresponding to the font image.
In this embodiment, after the training set and the data in the test set are respectively labeled, the model to be trained may be trained by the training set and the test set. Specifically, the model to be trained can be trained according to the data to be trained in the training set, the data in the data to be trained in the testing set is tested, and the super parameters of the model to be trained are continuously adjusted according to the training result, wherein the super parameters include, but are not limited to, the learning rate, the learning strategy, the forgetting rate and the maximum iteration number until the model to be trained converges, and finally the font recognition model is obtained.
According to the font identification method provided by the embodiment, the model to be trained is trained through the test set and the training set, and the super parameters of the model to be trained are adjusted until the model to be trained converges, so that the font identification model is obtained, and the identification precision of the font identification model can be improved, and the user experience is further improved.
Further, on the basis of any one of the above embodiments, the method includes:
receiving a font image shot by a shooting module;
calculating a mean image of the font identification model;
subtracting the mean value image from the font image to obtain the preprocessed font image;
and adding the preprocessed font image into a preset font identification model to obtain a font name corresponding to the font image.
In this embodiment, a font image to be recognized sent by a shooting module is received, and in order to improve the efficiency and accuracy of font recognition, the font image needs to be preprocessed first. Specifically, a mean image of the font recognition model may be first determined, and a characteristic portion of the font image may be obtained by subtracting the mean image from the photographed font image, and the preprocessed font image may be recognized by a preset font recognition model to obtain a name of the font. Accordingly, after the name of the font is obtained, the name of the font can be displayed on a display screen of the user terminal, and then the user can download, use and other operations on the font according to the name of the font.
According to the font identification method provided by the embodiment, the mean image of the font identification model is calculated; subtracting the mean value image from the font image to obtain the preprocessed font image, so that the efficiency and the precision of font identification can be improved, and the user experience is further improved.
Fig. 4 is a schematic structural diagram of a font recognition device according to a third embodiment of the present invention, as shown in fig. 4, where the font recognition device includes:
a font image receiving module 31 for receiving the font image shot by the shooting module;
a preprocessing module 32, configured to preprocess the font file;
and the recognition module 33 is configured to add the preprocessed font image to a preset font recognition model, and obtain a font name corresponding to the font image.
In this embodiment, the font recognition device may communicate with the shooting module in a wired or wireless manner, so as to implement data interaction. Specifically, when the user finds a favorite font, the user can shoot the font through a shooting module to obtain a font image of the font, and the font image is sent to the font identification device in a wired or wireless mode. Accordingly, the font recognition device may accept the font image transmitted from the photographing module.
As an implementation manner, the font image may be a screenshot of the font of the centering instrument when the user browses a certain interface through the user terminal, or may be a font image obtained in any other form, and the present invention is not limited herein.
In order to improve the accuracy of the font recognition, the font recognition device may perform preprocessing on the font image after receiving the font image, to obtain a processed font image.
In order to realize the identification of the fonts, a font identification model can be preset, the font image is preprocessed, after the processed font image is obtained, the processed font image can be added into the font identification model, so that the identification of the fonts of the user cardiometer is realized, and the names of the fonts are obtained. Accordingly, after the name of the font is obtained, the name of the font can be displayed on a display screen of the user terminal, and then the user can download, use and other operations on the font according to the name of the font.
The font identification device provided by the embodiment receives the font image shot by the shooting module; preprocessing the font file; and adding the preprocessed font image into a preset font identification model to obtain a font name corresponding to the font image. Therefore, the names of the fonts liked by the user can be rapidly acquired, so that the user downloads and uses the fonts according to the font names, and the user experience is improved.
Further, on the basis of any one of the foregoing embodiments, the apparatus further includes:
the training module is used for training a preset model to be trained through preset font data to be trained to obtain the preset font identification model.
According to the font identification device provided by the embodiment, the preset model to be trained is trained through the preset font data to be trained, and the preset font identification model is obtained, so that a foundation is provided for subsequent font identification, and user experience can be improved.
Further, on the basis of any one of the foregoing embodiments, the apparatus further includes:
the device comprises a to-be-processed data acquisition module, a processing module and a processing module, wherein the to-be-processed data acquisition module is used for acquiring preset to-be-processed data, and the to-be-processed data is a black-and-white font image;
the rendering module is used for rendering the data to be processed into color image data randomly;
the classification module is used for randomly dividing the color image data into a test set and a training set;
and the labeling module is used for labeling the color image data in the test set and the training set respectively to obtain the font data to be trained.
According to the font identification device provided by the embodiment, the preset data to be processed is acquired, and the data to be processed is a black-and-white font image; randomly rendering the data to be processed into color image data; randomly dividing the color image data into a test set and a training set; and marking the color image data in the test set and the training set respectively to obtain the font data to be trained, so that the recognition accuracy of the model can be improved, and the user experience is further improved.
Further, on the basis of any one of the foregoing embodiments, the labeling module includes:
an adding unit, configured to add random noise and random ambiguity in the test set and the training set;
and the labeling unit is used for labeling the font names of the color image data aiming at each color image data in the test set and the training set.
According to the font identification device provided by the embodiment, random noise and random blurring are added in the test set and the training set; and labeling the font names of the color image data aiming at each color image data in the test set and the training set, so that the font identification model can accurately identify the fonts, and the user experience is improved.
Further, on the basis of any one of the foregoing embodiments, the training module includes:
and the training unit is used for training the model to be trained through the test set and the training set, and adjusting the hyper-parameters of the model to be trained until the model to be trained converges to obtain the font identification model.
According to the font identification device provided by the embodiment, the model to be trained is trained through the test set and the training set, and the super parameters of the model to be trained are adjusted until the model to be trained converges, so that the font identification model is obtained, and the identification precision of the font identification model can be improved, and the user experience is further improved.
Further, on the basis of any one of the foregoing embodiments, the preprocessing module includes:
a calculation unit for calculating a mean image of the font recognition model;
and the processing unit is used for subtracting the mean value image from the font image to obtain the preprocessed font image.
The font recognition device provided by the embodiment calculates the mean image of the font recognition model; subtracting the mean value image from the font image to obtain the preprocessed font image, so that the efficiency and the precision of font identification can be improved, and the user experience is further improved.
Fig. 5 is a schematic structural diagram of a font identifying device according to a fourth embodiment of the present invention, as shown in fig. 5, where the font identifying device includes:
a memory 41, a processor 42;
a memory 41; a memory 41 for storing instructions executable by the processor 42;
wherein the processor 42 is configured to perform a font recognition method as described above by the processor 42;
the font recognition device further comprises a communication interface 43.
Yet another embodiment of the present invention is to provide a computer-readable storage medium having stored therein computer-executable instructions for implementing a font recognition method as described above when executed by a processor.
It will be clear to those skilled in the art that, for convenience and brevity of description, reference may be made to the corresponding process in the foregoing method embodiment for the specific working process of the apparatus described above, which is not described herein again.
Those of ordinary skill in the art will appreciate that: all or part of the steps for implementing the method embodiments described above may be performed by hardware associated with program instructions. The foregoing program may be stored in a computer readable storage medium. The program, when executed, performs steps including the method embodiments described above; and the aforementioned storage medium includes: various media that can store program code, such as ROM, RAM, magnetic or optical disks.
Finally, it should be noted that: the above embodiments are only for illustrating the technical solution of the present invention, and not for limiting the same; although the invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some or all of the technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit of the invention.