CN110633457A - Content replacement method and device, electronic equipment and readable storage medium - Google Patents

Content replacement method and device, electronic equipment and readable storage medium Download PDF

Info

Publication number
CN110633457A
CN110633457A CN201810651671.2A CN201810651671A CN110633457A CN 110633457 A CN110633457 A CN 110633457A CN 201810651671 A CN201810651671 A CN 201810651671A CN 110633457 A CN110633457 A CN 110633457A
Authority
CN
China
Prior art keywords
picture
character
target
recorded
recognition model
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201810651671.2A
Other languages
Chinese (zh)
Other versions
CN110633457B (en
Inventor
冷志峰
张作兵
刘浩丽
朱静
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Kingsoft Office Software Inc
Zhuhai Kingsoft Office Software Co Ltd
Guangzhou Jinshan Mobile Technology Co Ltd
Original Assignee
Beijing Kingsoft Office Software Inc
Zhuhai Kingsoft Office Software Co Ltd
Guangzhou Jinshan Mobile Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Kingsoft Office Software Inc, Zhuhai Kingsoft Office Software Co Ltd, Guangzhou Jinshan Mobile Technology Co Ltd filed Critical Beijing Kingsoft Office Software Inc
Priority to CN201810651671.2A priority Critical patent/CN110633457B/en
Publication of CN110633457A publication Critical patent/CN110633457A/en
Application granted granted Critical
Publication of CN110633457B publication Critical patent/CN110633457B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V30/00Character recognition; Recognising digital ink; Document-oriented image-based pattern recognition
    • G06V30/10Character recognition
    • G06V30/14Image acquisition
    • G06V30/148Segmentation of character regions
    • G06V30/153Segmentation of character regions using recognition of characters or words

Abstract

The embodiment of the invention provides a content replacement method and device, electronic equipment and a readable storage medium. The method comprises the following steps: receiving a content replacement instruction for a target picture in a document; the content replacement instruction at least carries: a first character to be replaced and a second character for replacing the first character; inputting the target picture into a picture character recognition model which is constructed in advance to obtain target characters recorded by the target picture and position area information of each target character; the picture character recognition model is used for: identifying characters recorded by the picture and position area information of each recorded character; judging whether a character matched with the first character exists in the target character or not; if the character exists, generating a sub-picture recorded with a second character; and covering the target area of the target picture by using the sub-picture. By applying the embodiment of the invention, the text content recorded by the picture in the document can be replaced, and the office experience of the user is improved.

Description

Content replacement method and device, electronic equipment and readable storage medium
Technical Field
The present invention relates to the field of document processing technologies, and in particular, to a content replacement method and apparatus, an electronic device, and a readable storage medium.
Background
Currently, during the office process, users often need to process various documents through office software. For example, documents such as word documents, PDF (Portable Document Format) documents, and PPT (PowerPoint) documents often need to be edited.
These documents often have some pictures stored therein, and some text is sometimes recorded in the pictures. For example, a picture in a document records the following text: and others. The inventor finds that when a user wants to replace the 'other' appearing in the document with the 'other' by using the replacement function of the office software, so that the words of the document are uniform, the office software cannot replace the 'other' recorded by the picture, and the office experience of the user is affected.
Disclosure of Invention
The embodiment of the invention aims to provide a content replacement method, a content replacement device, electronic equipment and a readable storage medium, so that the text content recorded by a picture can be replaced, and the office experience of a user is improved. The specific technical scheme is as follows:
in a first aspect, an embodiment of the present invention provides a content replacement method, where the method may include:
receiving a content replacement instruction for a target picture in a document; wherein, the content replacement instruction at least carries: a first character to be replaced and a second character for replacing the first character;
inputting the target picture into a picture character recognition model which is constructed in advance to obtain target characters recorded by the target picture and position area information of each target character; the picture character recognition model is used for: identifying characters recorded by the picture and position area information of each recorded character;
judging whether a character matched with the first character exists in the target character or not;
if the character exists, generating a sub-picture recorded with a second character;
covering a target area of the target picture by using the sub-picture; the target area is: and the area corresponding to the position area information of the target character matched with the first character.
Optionally, before inputting the target picture into the pre-constructed picture character recognition model, the method may further include:
constructing a picture character recognition model;
the method comprises the following steps of constructing a picture character recognition model, comprising the following steps:
acquiring a plurality of preset pictures recorded with characters;
training the training sample by using a preset deep learning algorithm to obtain a picture character recognition model; wherein, a training sample comprises: the method comprises the steps of obtaining a preset picture, characters in the preset picture and corresponding position area information of the characters in the preset picture.
Optionally, one training sample may further include: and background contents of characters in a preset picture contained in the training sample in the preset picture.
Optionally, the step of inputting the target picture into a picture character recognition model constructed in advance to obtain the target characters recorded in the target picture and the position area information of each target character may include:
inputting the target picture into a picture character recognition model which is constructed in advance to obtain target characters recorded by the target picture, position area information of each target character and background content of each target character;
the step of generating the sub-picture recorded with the second character comprises the following steps:
generating a sub-picture recorded with second characters and target background content; the target background content is: the background content of the target character that matches the first character.
Optionally, the preset deep learning algorithm may include: any one of a convolutional recurrent neural network algorithm (CRNN) and a combinatorial algorithm; the combination algorithm comprises a convolution cyclic neural network algorithm CRNN and a scene text detection network algorithm CTPN.
In a second aspect, an embodiment of the present invention further provides a content replacement apparatus, where the apparatus may include:
a receiving unit configured to receive a content replacement instruction for a target picture in a document; wherein, the content replacement instruction at least carries: a first character to be replaced and a second character for replacing the first character;
the input unit is used for inputting the target picture into a picture character recognition model which is constructed in advance to obtain target characters recorded by the target picture and position area information of each target character; the picture character recognition model is used for: identifying characters recorded by the picture and position area information of each recorded character;
the judging unit is used for judging whether a character matched with the first character exists in the target character;
the generating unit is used for generating a sub-picture recorded with a second character when the character matched with the first character exists in the target character;
the covering unit is used for covering the target area of the target picture by using the sub-picture; the target area is: and the area corresponding to the position area information of the target character matched with the first character.
Optionally, in an embodiment of the present invention, the apparatus may further include:
the construction unit is used for constructing a picture character recognition model before inputting a target picture into a picture character recognition model constructed in advance;
the construction unit is specifically configured to:
acquiring a plurality of preset pictures recorded with characters;
training the training sample by using a preset deep learning algorithm to obtain a picture character recognition model; wherein, a training sample comprises: the method comprises the steps of obtaining a preset picture, characters in the preset picture and corresponding position area information of the characters in the preset picture.
Optionally, one training sample may further include: and background contents of characters in a preset picture contained in the training sample in the preset picture.
Optionally, in an embodiment of the present invention, the input unit may specifically be configured to:
inputting the target picture into a picture character recognition model which is constructed in advance to obtain target characters recorded by the target picture, position area information of each target character and background content of each target character;
accordingly, the generating unit may specifically be configured to:
generating a sub-picture recorded with second characters and target background content; the target background content is: the background content of the target character that matches the first character.
Optionally, the preset deep learning algorithm may include: any one of a convolutional recurrent neural network algorithm (CRNN) and a combinatorial algorithm; the combination algorithm comprises a convolution cyclic neural network algorithm CRNN and a scene text detection network algorithm CTPN.
In a third aspect, an embodiment of the present invention further provides an electronic device, which may include a processor, a communication interface, a memory, and a communication bus, where the processor, the communication interface, and the memory complete communication with each other through the communication bus;
a memory for storing a computer program;
a processor for implementing the method steps of any of the above-described content substitution methods when executing the program stored in the memory.
In a fourth aspect, the embodiment of the present invention further provides a readable storage medium, in which a computer program is stored, and when the computer program is executed by a processor, the method steps of any one of the above content replacement methods are implemented.
In a fifth aspect, an embodiment of the present invention further provides a computer program product including instructions, which when run on an electronic device, cause the electronic device to perform: method steps of any of the above content substitution methods.
In the embodiment of the present invention, a content replacement instruction for a target picture in a document may be received, where the content replacement instruction at least carries: a first character to be replaced and a second character for replacing the first character. After receiving the content replacement instruction, the target picture may be input to a pre-constructed picture character recognition model. The character recorded in the picture and the position area information of each recorded character can be identified due to the picture character recognition model. Thus, after the target picture is input to the picture character recognition model, the picture character recognition model can recognize and output: target characters recorded by the target picture and position area information of each target character. Then, it can be determined whether there is a character matching the first character in the target character. And if so, generating a sub-picture recorded with the second character. And then, covering a target area corresponding to the position area information of the target character matched with the first character in the target picture by using the sub-picture.
In this way, after the target area is covered by the sub-picture, the first character in the target picture is replaced by the second character. According to the content replacement mode, the user does not need to send the target picture to the picture editing software, and then the picture editing software adjusts the picture content, so that the operation complexity and the operation time for adjusting the picture content are reduced, the content replacement cost is reduced, and the office efficiency and the office experience of the user are improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a flowchart of a content replacement method according to an embodiment of the present invention;
fig. 2 is a schematic structural diagram of a content replacement apparatus according to an embodiment of the present invention;
fig. 3 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In order to solve the problems in the prior art, embodiments of the present invention provide a content replacement method, device, electronic device, and readable storage medium.
The following first describes a content replacement method provided by an embodiment of the present invention.
The content replacement method provided by the embodiment of the invention can be applied to the electronic equipment with office software. Such electronic devices include, but are not limited to, computers and cell phones.
Office software includes, but is not limited to: WPS (WPS software) office software, PPT (PowerPoint) office software, and PDF (Portable Document Format) office software, but is not limited thereto.
Accordingly, target documents in embodiments of the present invention include, but are not limited to: WPS documents, PPT documents, and PDF documents, though not limited thereto.
Referring to fig. 1, the method may include the steps of:
s101: receiving a content replacement instruction for a target picture in a document; wherein, the content replacement instruction at least carries: a first character to be replaced and a second character for replacing the first character;
s102: inputting the target picture into a picture character recognition model which is constructed in advance to obtain target characters recorded by the target picture and position area information of each target character; the picture character recognition model is used for: identifying characters recorded by the picture and position area information of each recorded character;
s103: judging whether a character matched with the first character exists in the target character or not; if yes, go to step S104;
s104: generating a sub-picture recorded with a second character;
s105: covering a target area of the target picture by using the sub-picture; the target area is: and the area corresponding to the position area information of the target character matched with the first character.
In the embodiment of the present invention, a content replacement instruction for a target picture in a document may be received, where the content replacement instruction at least carries: a first character to be replaced and a second character for replacing the first character. After receiving the content replacement instruction, the target picture may be input to a pre-constructed picture character recognition model. The character recorded in the picture and the position area information of each recorded character can be identified due to the picture character recognition model. Thus, after the target picture is input to the picture character recognition model, the picture character recognition model can recognize and output: target characters recorded by the target picture and position area information of each target character. Then, it can be determined whether there is a character matching the first character in the target character. And if so, generating a sub-picture recorded with the second character. And then, covering a target area corresponding to the position area information of the target character matched with the first character in the target picture by using the sub-picture.
In this way, after the target area is covered by the sub-picture, the first character in the target picture is replaced by the second character. According to the content replacement mode, the user does not need to send the target picture to the picture editing software, and then the picture editing software adjusts the picture content, so that the operation complexity and the operation time for adjusting the picture content are reduced, the content replacement cost is reduced, and the office efficiency and the office experience of the user are improved.
The following describes a content replacement method provided by an embodiment of the present invention by taking a PDF document as an example.
It is assumed that PDF office software is installed in an electronic device, and a PDF document, in which a target picture is stored, is opened by the PDF office software. Then, when the electronic device detects a content replacement instruction for the full-text of the PDF document, it indicates that the electronic device receives the content replacement instruction for the target picture.
In addition, when the electronic device detects a content replacement instruction for a target picture in the PDF document, the electronic device is also indicated to receive the content replacement instruction for the target picture. Wherein, the content replacement instruction at least carries: a first character to be replaced and a second character for replacing the first character.
The first character/the second character can be letters, numbers, words or symbols, any combination of letters, numbers, words and symbols, or English words composed of a plurality of letters, words composed of a plurality of words, but is not limited thereto, wherein the symbols include but are not limited to!, ####, ¥ and%.
For example, when the user wants to replace "other" recorded in the target picture in the PDF document with "other", the first character carried by the content replacement instruction for the target picture received by the electronic device is: otherwise, the second character carried is: and others.
After receiving a content replacement instruction for a target picture, the electronic device may input the target picture to a pre-constructed picture character recognition model. It is reasonable that the picture character recognition model may be a model stored in the electronic device or a model stored in the server.
When the picture character recognition model is stored in the server, the electronic equipment can input the target picture into the picture character recognition model in the server through a picture character recognition model interface in the server, and obtains a recognition result of the picture character recognition model for the target picture from the picture character recognition model interface.
Because the image character recognition model can recognize the characters recorded by the image and the position area information of each recorded character, after the target image is input into the pre-constructed image character recognition model, the image character recognition model can recognize and output the target image: target characters recorded by the target picture and position area information of each target character.
For example, the picture character recognition model can recognize the first line of text in the target picture as "plum blossom is different from other flowers", and recognize the second line of text in the target picture as "it is not wonderful and does not contend for spring, and only reports spring. Also, position area information of each character in the first line of letters and the second line of letters can be identified. For example, the position area information that can recognize the character "it" is: and coordinates of the upper left corner and the lower right corner of the rectangular area where the character 'it' is located in the target picture.
The method for constructing the image character recognition model comprises the following steps:
and forming a training sample by using a plurality of preset pictures recorded with characters. Wherein, the obtained training sample may include: the method comprises the steps of obtaining a preset picture, characters in the preset picture and position area information of the characters in the preset picture.
For example, the obtained training sample may include: the method comprises the steps of presetting a picture k, and presetting characters recorded by the picture k and position area information of the characters in the picture k. Wherein, the characters recorded by the preset picture k are as follows: other regions. The position area information of the character "it" is: presetting coordinates of the upper left corner and the lower right corner of a rectangular area where a character 'it' is located in a picture k; … …, respectively; the position area information of the character "area" is: coordinates of the upper left corner and the lower right corner of a rectangular area where the character area in the picture k is located are preset. Of course, the location area information is not limited thereto.
And then, training the training sample by using a preset deep learning algorithm, so that a picture character recognition model can be obtained.
In order to make the target picture after the replacement operation looks as similar to the target picture before the replacement operation, the reading experience of the user is enhanced. The training samples for training the picture character recognition model comprise the following components: besides the preset picture, the characters in the preset picture and the position area information of the characters in the preset picture, the method can further include: and background contents of characters in a preset picture contained in the training sample in the preset picture.
Thus, after the target picture is input into the pre-constructed picture character recognition model, the picture character recognition model can recognize and output the target picture: target characters recorded by the target picture, position area information of each target character, and background content of each target character.
The preset deep learning algorithm includes, but is not limited to, any one of a Convolutional Recurrent Neural Network (CRNN) algorithm and a combinatorial algorithm. The combination algorithm includes a convolutional recurrent neural Network algorithm CRNN and a scene text detection Network algorithm (CTPN).
The Convolutional Recurrent Neural Network algorithm (CRNN) integrates the advantages of a Convolutional Neural Network algorithm (CNN) and a Recurrent Neural Network algorithm (RNN), so that the character recognition model obtained by training in the embodiment of the present invention can more accurately recognize the character in the picture, the position region information of the character, and the background content of the character, and further more accurate search results can be obtained, and further accurate replacement can be realized.
In addition, the more training samples used for training the picture character recognition model, the more accurate the recognition result of the picture character recognition model obtained by training, so that the picture character recognition model can be trained by adopting the training samples as many as possible.
In addition, in order to improve the accuracy of the recognition result output by the image character recognition model, after the image character recognition model is obtained through training, the image character recognition model can be optimized by utilizing a plurality of optimization samples. Wherein, an optimization sample may include: the image used for optimizing the model and the recorded characters of the image and the position area information of each character. Of course, the background content of each character may also be included. In this way, parameters in the picture character recognition model can be optimized, so that the recognition result output by the model is more accurate.
In the above way, the trained picture character recognition model can recognize the characters recorded in the picture input into the model, the position area information of each character and the background content of each target character.
Assuming that target characters recorded by a picture in a PDF document, position area information of each target character, and background content of each target character can be recognized through a picture character recognition model constructed in advance, after a recognition result of the picture character recognition model is obtained, the first character "other" may be used to match the target characters recorded by the target picture.
Then, it can be determined whether there is a character matching the first character in the recognized target character. If the character exists, the character which is successfully matched can be determined, and the position area information of the character which is successfully matched can be determined. Then, a sub-picture in which the second character is recorded may be generated. And when judging that the character matched with the first character does not exist in the identified target character, giving up generating the sub-picture recorded with the second character.
In one implementation, the background of the generated sub-picture may be a background of a preset color, such as a white background. In another implementation, the background of the generated sub-picture may also be based on the background content of the successfully matched characters. This is all reasonable.
It is understood that the operation of generating the sub-picture may be performed on the electronic device or may be performed on the server. When the method is executed on the electronic equipment, the data transmission quantity between the electronic equipment and the server can be reduced, and the transmission bandwidth of the electronic equipment and the server is saved. When executed on a server, the computing load of the electronic equipment can be reduced, and the speed of generating the sub-picture can be improved.
After the sub-picture is generated, the target area of the target picture can be covered by the sub-picture. The target area is: and the region in the target picture corresponding to the position region information of the target character matched with the first character.
When the size of the generated sub-picture is equal to the size of the target area, the target area of the target picture can be directly covered by the sub-picture. When the size of the generated sub-picture is not equal to the size of the target area, the sub-picture may be scaled so that the size of the sub-picture is equal to the size of the target area, and then the overlay operation is performed using the scaled sub-picture.
If the content replacement instruction detected by the electronic equipment is for the whole document, matching the first character with the text content in the document and replacing the content matched with the first character in the text content with the second character. Thus, the "first character" in the whole text may be replaced with the "second character".
For example, assume that there are two pages of a PDF document, one page is the target picture and the other page is the text content. Then, after recognizing through the picture character recognition model: after the target characters recorded by the picture in the PDF document, the position area information of each target character, and the background content of each target character, the first character may be used to match the identified target character. And when the target character has a character matched with the first character, generating a sub-picture recorded with a second character. And covering a target area corresponding to the position area information of the target character matched with the first character in the target picture by using the sub-picture. And directly matching the first character with the text content in another page, and replacing the successfully matched character in the text content by using the second character.
It should be noted that, as for a manner of replacing contents in documents such as a word document, a WPS document, and a PPT document, reference may be made to a content replacement manner corresponding to the PDF document, which is not described in detail herein.
In the above way, after the electronic device receives the content replacement instruction for the target picture, the electronic device can cover the corresponding area, in which the first character is recorded, in the target picture through the sub-picture in which the second character is recorded, so that the first character in the target picture is replaced by the second character. According to the content replacement mode, the user does not need to send the target picture to the picture editing software, and then the picture editing software adjusts the picture content, so that the operation complexity and the operation time for adjusting the picture content are reduced, the content replacement cost is reduced, and the office efficiency and the office experience of the user are improved.
Corresponding to the above method embodiment, an embodiment of the present invention further provides a content replacement apparatus, and referring to fig. 2, the apparatus may include:
a receiving unit 201, configured to receive a content replacement instruction for a target picture in a document; wherein, the content replacement instruction at least carries: a first character to be replaced and a second character for replacing the first character;
the input unit 202 is configured to input a target picture to a picture character recognition model which is constructed in advance, so as to obtain target characters recorded by the target picture and position area information of each target character; the picture character recognition model is used for: identifying characters recorded by the picture and position area information of each recorded character;
a judging unit 203, configured to judge whether a character matching the first character exists in the target character;
a generating unit 204, configured to generate a sub-picture in which a second character is recorded when a character matching the first character exists in the target character;
a covering unit 205, configured to cover a target area of the target picture with the sub-picture; the target area is: and the area corresponding to the position area information of the target character matched with the first character.
By applying the device provided by the embodiment of the invention, a content replacement instruction aiming at the target picture in the document can be received, and the content replacement instruction at least carries: a first character to be replaced and a second character for replacing the first character. After receiving the content replacement instruction, the target picture may be input to a pre-constructed picture character recognition model. The character recorded in the picture and the position area information of each recorded character can be identified due to the picture character recognition model. Thus, after the target picture is input to the picture character recognition model, the picture character recognition model can recognize and output: target characters recorded by the target picture and position area information of each target character. Then, it can be determined whether there is a character matching the first character in the target character. And if so, generating a sub-picture recorded with the second character. And then, covering a target area corresponding to the position area information of the target character matched with the first character in the target picture by using the sub-picture.
In this way, after the target area is covered by the sub-picture, the first character in the target picture is replaced by the second character. According to the content replacement mode, the user does not need to send the target picture to the picture editing software, and then the picture editing software adjusts the picture content, so that the operation complexity and the operation time for adjusting the picture content are reduced, the content replacement cost is reduced, and the office efficiency and the office experience of the user are improved.
Optionally, in an embodiment of the present invention, the apparatus may further include:
the construction unit is used for constructing a picture character recognition model before inputting a target picture into a picture character recognition model constructed in advance;
the construction unit is specifically configured to:
acquiring a plurality of preset pictures recorded with characters;
training the training sample by using a preset deep learning algorithm to obtain a picture character recognition model; wherein, a training sample comprises: the method comprises the steps of obtaining a preset picture, characters in the preset picture and corresponding position area information of the characters in the preset picture.
Optionally, one training sample further includes: and background contents of characters in a preset picture contained in the training sample in the preset picture.
Optionally, in an embodiment of the present invention, the input unit 202 is specifically configured to:
inputting the target picture into a picture character recognition model which is constructed in advance to obtain target characters recorded by the target picture, position area information of each target character and background content of each target character;
correspondingly, the generating unit 204 is specifically configured to:
generating a sub-picture recorded with second characters and target background content; the target background content is: the background content of the target character that matches the first character.
Optionally, the preset deep learning algorithm includes: any one of a convolutional recurrent neural network algorithm (CRNN) and a combinatorial algorithm; the combination algorithm comprises a convolution cyclic neural network algorithm CRNN and a scene text detection network algorithm CTPN.
Corresponding to the above method embodiment, the embodiment of the present invention further provides an electronic device, referring to fig. 3, the electronic device includes a processor 301, a communication interface 302, a memory 303, and a communication bus 304, where the processor 301, the communication interface 302, and the memory 303 complete mutual communication through the communication bus 304,
a memory 303 for storing a computer program;
the processor 301 is configured to implement the method steps of any one of the above-described content replacement methods when executing the program stored in the memory 303.
In this embodiment of the present invention, the electronic device may receive a content replacement instruction for a target picture in a document, where the content replacement instruction at least carries: a first character to be replaced and a second character for replacing the first character. After receiving the content replacement instruction, the target picture may be input to a pre-constructed picture character recognition model. The character recorded in the picture and the position area information of each recorded character can be identified due to the picture character recognition model. Thus, after the target picture is input to the picture character recognition model, the picture character recognition model can recognize and output: target characters recorded by the target picture and position area information of each target character. Then, it can be determined whether there is a character matching the first character in the target character. And if so, generating a sub-picture recorded with the second character. And then, covering a target area corresponding to the position area information of the target character matched with the first character in the target picture by using the sub-picture.
In this way, after the target area is covered by the sub-picture, the first character in the target picture is replaced by the second character. According to the content replacement mode, the user does not need to send the target picture to the picture editing software, and then the picture editing software adjusts the picture content, so that the operation complexity and the operation time for adjusting the picture content are reduced, the content replacement cost is reduced, and the office efficiency and the office experience of the user are improved.
Corresponding to the above method embodiment, an embodiment of the present invention further provides a readable storage medium, in which a computer program is stored, and the computer program, when executed by a processor, implements the method steps of any of the above content replacement methods.
After the computer program stored in the readable storage medium provided by the embodiment of the present invention is executed by a processor of the electronic device, the electronic device may receive a content replacement instruction for a target picture in a document, where the content replacement instruction at least carries: a first character to be replaced and a second character for replacing the first character. After receiving the content replacement instruction, the target picture may be input to a pre-constructed picture character recognition model. The character recorded in the picture and the position area information of each recorded character can be identified due to the picture character recognition model. Thus, after the target picture is input to the picture character recognition model, the picture character recognition model can recognize and output: target characters recorded by the target picture and position area information of each target character. Then, it can be determined whether there is a character matching the first character in the target character. And if so, generating a sub-picture recorded with the second character. And then, covering a target area corresponding to the position area information of the target character matched with the first character in the target picture by using the sub-picture.
In this way, after the target area is covered by the sub-picture, the first character in the target picture is replaced by the second character. According to the content replacement mode, the user does not need to send the target picture to the picture editing software, and then the picture editing software adjusts the picture content, so that the operation complexity and the operation time for adjusting the picture content are reduced, the content replacement cost is reduced, and the office efficiency and the office experience of the user are improved.
Corresponding to the above method embodiment, an embodiment of the present invention further provides a computer program product including instructions, which, when run on an electronic device, cause the electronic device to perform: method steps of any of the above content substitution methods.
When the computer program product including the instruction provided by the embodiment of the present invention runs on an electronic device, the electronic device may receive a content replacement instruction for a target picture in a document, where the content replacement instruction at least carries: a first character to be replaced and a second character for replacing the first character. After receiving the content replacement instruction, the target picture may be input to a pre-constructed picture character recognition model. The character recorded in the picture and the position area information of each recorded character can be identified due to the picture character recognition model. Thus, after the target picture is input to the picture character recognition model, the picture character recognition model can recognize and output: target characters recorded by the target picture and position area information of each target character. Then, it can be determined whether there is a character matching the first character in the target character. And if so, generating a sub-picture recorded with the second character. And then, covering a target area corresponding to the position area information of the target character matched with the first character in the target picture by using the sub-picture.
In this way, after the target area is covered by the sub-picture, the first character in the target picture is replaced by the second character. According to the content replacement mode, the user does not need to send the target picture to the picture editing software, and then the picture editing software adjusts the picture content, so that the operation complexity and the operation time for adjusting the picture content are reduced, the content replacement cost is reduced, and the office efficiency and the office experience of the user are improved.
The communication bus mentioned in the electronic device may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this does not mean that there is only one bus or one type of bus.
The communication interface is used for communication between the electronic equipment and other equipment.
The Memory may include a Random Access Memory (RAM) or a Non-Volatile Memory (NVM), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the processor.
The Processor may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the apparatus, the electronic device, the readable storage medium, and the computer program product embodiments, since they are substantially similar to the method embodiments, the description is relatively simple, and in relation to the description, reference may be made to some of the description of the method embodiments.
The above description is only for the preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention shall fall within the protection scope of the present invention.

Claims (12)

1. A method for content replacement, the method comprising:
receiving a content replacement instruction for a target picture in a document; wherein, the content replacement instruction at least carries: a first character to be replaced and a second character for replacing the first character;
inputting the target picture into a picture character recognition model which is constructed in advance to obtain target characters recorded by the target picture and position area information of each target character; the picture character recognition model is used for: identifying characters recorded by the picture and position area information of each recorded character;
judging whether a character matched with the first character exists in the target character or not;
if the second character exists, generating a sub-picture recorded with the second character;
covering a target area of the target picture by using the sub-picture; the target area is as follows: and the area corresponds to the position area information of the target character matched with the first character.
2. The method of claim 1, wherein prior to inputting the target picture into a pre-built picture character recognition model, the method further comprises:
constructing the picture character recognition model;
the step of constructing the picture character recognition model includes:
acquiring a plurality of preset pictures recorded with characters;
training a training sample by using a preset deep learning algorithm to obtain the picture character recognition model; wherein, a training sample comprises: the method comprises the steps of obtaining a preset picture, characters in the preset picture and corresponding position area information of the characters in the preset picture.
3. The method of claim 2, wherein a training sample further comprises: and background contents of characters in a preset picture contained in the training sample in the preset picture.
4. The method according to claim 3, wherein the step of inputting the target picture into a pre-constructed picture character recognition model to obtain the target characters recorded in the target picture and the position area information of each target character comprises:
inputting the target picture into a picture character recognition model which is constructed in advance to obtain target characters recorded by the target picture, position area information of each target character and background content of each target character;
the step of generating the sub-picture recorded with the second character includes:
generating a sub-picture recorded with the second characters and the target background content; the target background content is as follows: a background content of a target character that matches the first character.
5. The method according to any one of claims 2-4, wherein the pre-set deep learning algorithm comprises: any one of a convolutional recurrent neural network algorithm (CRNN) and a combinatorial algorithm; the combination algorithm comprises the convolution cyclic neural network algorithm CRNN and a scene text detection network algorithm CTPN.
6. A content substitution apparatus, characterized in that the apparatus comprises:
a receiving unit configured to receive a content replacement instruction for a target picture in a document; wherein, the content replacement instruction at least carries: a first character to be replaced and a second character for replacing the first character;
the input unit is used for inputting the target picture into a picture character recognition model which is constructed in advance to obtain target characters recorded by the target picture and position area information of each target character; the picture character recognition model is used for: identifying characters recorded by the picture and position area information of each recorded character;
the judging unit is used for judging whether a character matched with the first character exists in the target character or not;
a generating unit, configured to generate a sub-picture in which the second character is recorded when a character matching the first character exists in the target character;
the covering unit is used for covering the target area of the target picture by utilizing the sub-picture; the target area is as follows: and the area corresponds to the position area information of the target character matched with the first character.
7. The apparatus of claim 6, further comprising:
the construction unit is used for constructing the picture character recognition model before the target picture is input into a picture character recognition model which is constructed in advance;
the construction unit is specifically configured to:
acquiring a plurality of preset pictures recorded with characters;
training a training sample by using a preset deep learning algorithm to obtain the picture character recognition model; wherein, a training sample comprises: the method comprises the steps of obtaining a preset picture, characters in the preset picture and corresponding position area information of the characters in the preset picture.
8. The apparatus of claim 7, wherein a training sample further comprises: and background contents of characters in a preset picture contained in the training sample in the preset picture.
9. The apparatus of claim 8, wherein the input unit is specifically configured to:
inputting the target picture into a picture character recognition model which is constructed in advance to obtain target characters recorded by the target picture, position area information of each target character and background content of each target character;
the generating unit is specifically configured to:
generating a sub-picture recorded with the second characters and the target background content; the target background content is as follows: a background content of a target character that matches the first character.
10. The apparatus according to any one of claims 7-9, wherein the pre-set deep learning algorithm comprises: any one of a convolutional recurrent neural network algorithm (CRNN) and a combinatorial algorithm; the combination algorithm comprises the convolution cyclic neural network algorithm CRNN and a scene text detection network algorithm CTPN.
11. An electronic device is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor and the communication interface are used for realizing mutual communication by the memory through the communication bus;
a memory for storing a computer program;
a processor for implementing the method steps of any one of claims 1 to 5 when executing a program stored in the memory.
12. A readable storage medium, characterized in that a computer program is stored in the readable storage medium, which computer program, when being executed by a processor, carries out the method steps of any one of claims 1-5.
CN201810651671.2A 2018-06-22 2018-06-22 Content replacement method and device, electronic equipment and readable storage medium Active CN110633457B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810651671.2A CN110633457B (en) 2018-06-22 2018-06-22 Content replacement method and device, electronic equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810651671.2A CN110633457B (en) 2018-06-22 2018-06-22 Content replacement method and device, electronic equipment and readable storage medium

Publications (2)

Publication Number Publication Date
CN110633457A true CN110633457A (en) 2019-12-31
CN110633457B CN110633457B (en) 2023-05-26

Family

ID=68967274

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810651671.2A Active CN110633457B (en) 2018-06-22 2018-06-22 Content replacement method and device, electronic equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN110633457B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110930302A (en) * 2018-08-30 2020-03-27 珠海金山办公软件有限公司 Picture processing method and device, electronic equipment and readable storage medium

Citations (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5167016A (en) * 1989-12-29 1992-11-24 Xerox Corporation Changing characters in an image
JPH05174188A (en) * 1991-12-20 1993-07-13 Ricoh Co Ltd Preprocessing method for character recognition
CN102651138A (en) * 2012-04-10 2012-08-29 西安理工大学 JPEG picture mosaicing-based oversize picture synthesis method
CN102843470A (en) * 2012-08-16 2012-12-26 广东步步高电子工业有限公司 Optimization editing information communication system and method thereof
CN103324924A (en) * 2012-03-19 2013-09-25 宇龙计算机通信科技(深圳)有限公司 Method and device for character positioning and terminal
CN104715497A (en) * 2014-12-30 2015-06-17 上海孩子国科教设备有限公司 Data replacement method and system
CN105184838A (en) * 2015-09-21 2015-12-23 深圳市金立通信设备有限公司 Picture processing method and terminal
CN106407981A (en) * 2016-11-24 2017-02-15 北京文安智能技术股份有限公司 License plate recognition method, device and system
CN106598623A (en) * 2016-12-23 2017-04-26 维沃移动通信有限公司 Picture combination template generation method and mobile terminal
CN106874909A (en) * 2017-01-18 2017-06-20 深圳怡化电脑股份有限公司 A kind of recognition methods of image character and its device
CN107679074A (en) * 2017-08-25 2018-02-09 百度在线网络技术(北京)有限公司 A kind of Picture Generation Method and equipment
CN107688772A (en) * 2017-06-23 2018-02-13 平安科技(深圳)有限公司 Method, apparatus, computer equipment and the storage medium of policy information typing
CN107797737A (en) * 2017-09-26 2018-03-13 努比亚技术有限公司 The method, apparatus and computer-readable recording medium that picture is edited again
CN108153468A (en) * 2017-12-14 2018-06-12 阿里巴巴集团控股有限公司 Image processing method and device

Patent Citations (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5167016A (en) * 1989-12-29 1992-11-24 Xerox Corporation Changing characters in an image
JPH05174188A (en) * 1991-12-20 1993-07-13 Ricoh Co Ltd Preprocessing method for character recognition
CN103324924A (en) * 2012-03-19 2013-09-25 宇龙计算机通信科技(深圳)有限公司 Method and device for character positioning and terminal
CN102651138A (en) * 2012-04-10 2012-08-29 西安理工大学 JPEG picture mosaicing-based oversize picture synthesis method
CN102843470A (en) * 2012-08-16 2012-12-26 广东步步高电子工业有限公司 Optimization editing information communication system and method thereof
CN104715497A (en) * 2014-12-30 2015-06-17 上海孩子国科教设备有限公司 Data replacement method and system
CN105184838A (en) * 2015-09-21 2015-12-23 深圳市金立通信设备有限公司 Picture processing method and terminal
CN106407981A (en) * 2016-11-24 2017-02-15 北京文安智能技术股份有限公司 License plate recognition method, device and system
CN106598623A (en) * 2016-12-23 2017-04-26 维沃移动通信有限公司 Picture combination template generation method and mobile terminal
CN106874909A (en) * 2017-01-18 2017-06-20 深圳怡化电脑股份有限公司 A kind of recognition methods of image character and its device
CN107688772A (en) * 2017-06-23 2018-02-13 平安科技(深圳)有限公司 Method, apparatus, computer equipment and the storage medium of policy information typing
CN107679074A (en) * 2017-08-25 2018-02-09 百度在线网络技术(北京)有限公司 A kind of Picture Generation Method and equipment
CN107797737A (en) * 2017-09-26 2018-03-13 努比亚技术有限公司 The method, apparatus and computer-readable recording medium that picture is edited again
CN108153468A (en) * 2017-12-14 2018-06-12 阿里巴巴集团控股有限公司 Image processing method and device

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110930302A (en) * 2018-08-30 2020-03-27 珠海金山办公软件有限公司 Picture processing method and device, electronic equipment and readable storage medium
CN110930302B (en) * 2018-08-30 2024-03-26 珠海金山办公软件有限公司 Picture processing method and device, electronic equipment and readable storage medium

Also Published As

Publication number Publication date
CN110633457B (en) 2023-05-26

Similar Documents

Publication Publication Date Title
US11410407B2 (en) Method and device for generating collection of incorrectly-answered questions
JP6244892B2 (en) Word detection for optical character recognition that is invariant to local scaling, rotation, and display position of characters in a document
KR101856119B1 (en) Techniques for distributed optical character recognition and distributed machine language translation
CN111444750B (en) PDF document identification method and device and electronic equipment
CN108664471B (en) Character recognition error correction method, device, equipment and computer readable storage medium
CN110597965B (en) Emotion polarity analysis method and device for article, electronic equipment and storage medium
CN114359533B (en) Page number identification method based on page text and computer equipment
WO2017211202A1 (en) Method, device, and terminal device for extracting data
CN110363189B (en) Document content restoration method and device, electronic equipment and readable storage medium
US20220058214A1 (en) Document information extraction method, storage medium and terminal
CN111027345A (en) Font identification method and apparatus
CN110633457B (en) Content replacement method and device, electronic equipment and readable storage medium
CN112330534A (en) Animal face style image generation method, model training method, device and equipment
CN112784594B (en) Document processing method and device, electronic equipment and readable storage medium
CN110895924B (en) Method and device for reading document content aloud, electronic equipment and readable storage medium
CN112000257A (en) Method and device for exporting key contents of document
CN111208955A (en) Printing method, printing device and server
CN110929479A (en) Method and device for converting PDF scanning piece, electronic equipment and storage medium
CN110399598B (en) Document content adjustment method and device, electronic equipment and readable storage medium
CN110309517B (en) Expression document processing method, device, system and storage medium
CN111563364B (en) Chapter title style conversion method and device, electronic equipment and storage medium
CN112784527A (en) Document merging method and device and electronic equipment
CN111695371B (en) Table identification method and device, electronic equipment and storage medium
CN112396057A (en) Character recognition method and device and electronic equipment
CN112784593B (en) Document processing method and device, electronic equipment and readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant