CN114359929A - Method, device, terminal and storage medium for translating cartoon file in JPG format - Google Patents
Method, device, terminal and storage medium for translating cartoon file in JPG format Download PDFInfo
- Publication number
- CN114359929A CN114359929A CN202111461763.2A CN202111461763A CN114359929A CN 114359929 A CN114359929 A CN 114359929A CN 202111461763 A CN202111461763 A CN 202111461763A CN 114359929 A CN114359929 A CN 114359929A
- Authority
- CN
- China
- Prior art keywords
- target
- text
- area
- region
- determining
- 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.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 52
- 238000013519 translation Methods 0.000 claims abstract description 135
- 238000004422 calculation algorithm Methods 0.000 claims abstract description 41
- 230000000694 effects Effects 0.000 claims abstract description 40
- 238000004590 computer program Methods 0.000 claims description 14
- 230000006870 function Effects 0.000 claims description 14
- 238000012545 processing Methods 0.000 claims description 5
- 230000014616 translation Effects 0.000 description 103
- 230000008569 process Effects 0.000 description 10
- 238000004364 calculation method Methods 0.000 description 5
- 238000010586 diagram Methods 0.000 description 4
- 238000004891 communication Methods 0.000 description 3
- 238000011161 development Methods 0.000 description 2
- 230000008676 import Effects 0.000 description 2
- 230000004044 response Effects 0.000 description 2
- 238000012937 correction Methods 0.000 description 1
- 238000013500 data storage Methods 0.000 description 1
- 238000001514 detection method Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 238000000605 extraction Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 238000012546 transfer Methods 0.000 description 1
Images
Landscapes
- Processing Or Creating Images (AREA)
Abstract
The application discloses a method, a device, a terminal and a storage medium for translating a cartoon file in a JPG format. The method comprises the following steps: determining a first initial text area corresponding to special-effect characters and a first position coordinate corresponding to the first initial text area, and a second initial text area corresponding to non-effective characters and a second position coordinate corresponding to the second initial text area based on the initial cartoon file in the JPG format; determining a first target translation and a first target background region corresponding to the special-effect characters and a second target translation and a second target background region corresponding to the non-effect characters based on the first initial text region and the second initial text region respectively; determining a first target text region based on the first target translation and a preset typesetting algorithm, and determining a second target text region based on the second target translation and the preset typesetting algorithm; and determining a target cartoon file in the JPG format based on the first target text area and the second target text area. The invention improves the translation efficiency.
Description
Technical Field
The application relates to the technical field of cartoon translation, in particular to a method, a device, a terminal and a storage medium for translating a cartoon file in a JPG format.
Background
Along with the rapid development of the romans in Japan and Korea, the national cartoon industry is in a rapid development trend, and the cartoon translation market is derived from the import and export of the cartoon. In the cartoon translation market, how to quickly obtain translated versions of cartoon files in different import and export countries becomes an urgent problem to be solved.
Currently, there are two major workflows in the market that have been applied to caricature translation: pure manual work: erasing characters in the cartoon by using Photoshop, and then posting a corresponding translation and typesetting; auxiliary of AI tool: and eliminating characters in the cartoon, performing online translation on the eliminated characters, and finally performing manual correction on the translated text obtained through translation.
However, the method for translating the cartoon file has the problem of low efficiency.
Disclosure of Invention
The application mainly aims to provide a method, a device, a terminal and a storage medium for translating a cartoon file in a JPG format, so as to solve the problem of low efficiency in translating the cartoon file in the related technology.
In order to achieve the above object, in a first aspect, the present application provides a method for translating a cartoon file in a JPG format, including:
determining a first initial text area corresponding to special-effect characters and a first position coordinate corresponding to the first initial text area, and a second initial text area corresponding to non-effective characters and a second position coordinate corresponding to the second initial text area based on the initial cartoon file in the JPG format;
determining a first target translation and a first target background area corresponding to the special-effect characters and a second target translation and a second target background area corresponding to the non-effect characters based on the first initial text area and the second initial text area respectively;
determining a first target text region based on the first target translation, the first target background region, the first position coordinate and a preset typesetting algorithm, and determining a second target text region based on the second target translation, the second target background region, the second position coordinate and the preset typesetting algorithm;
and determining a target cartoon file in the JPG format based on the first target text area and the second target text area.
In a possible implementation manner, determining, based on an initial cartoon file in a JPG format, a first initial text region corresponding to special-effect characters and a first position coordinate corresponding to the first initial text region, and a second initial text region corresponding to non-special-effect characters and a second position coordinate corresponding to the second initial text region, includes:
extracting all text boxes in the initial cartoon file;
recognizing characters in all the text boxes to obtain a first text box corresponding to the special-effect characters and a second text box corresponding to the non-effect characters;
a first initial text region and first location coordinates are determined based on the first text box, and a second initial text region and second location coordinates are determined based on the second text box.
In one possible implementation manner, determining a first target translation and a first target background region corresponding to the special effect text based on the first initial text region includes:
extracting special effect characters in the first initial text region, and obtaining a first target translation by using the special effect characters, a preset translation and a similarity algorithm;
and sequentially eliminating and complementing the first initial background area in the first initial text area to obtain a first target background area.
In one possible implementation manner, determining a second target translation and a second target background region corresponding to the non-effective text based on the second initial text region includes:
slicing the second initial text region to obtain a plurality of sub initial text regions;
processing the plurality of sub-initial text regions by using a preset text box merging algorithm to obtain a second intermediate text region;
extracting non-effective characters in the second intermediate text area to obtain a second target background area;
and obtaining a second target translation by using the non-effective characters, the preset translation and a similarity algorithm.
In one possible implementation, determining the first target text region based on the first target translation, the first target background region, the first position coordinate, and the preset composition algorithm, and determining the first target text region based on the second target translation, the second target background region, the second position coordinate, and the preset composition algorithm includes:
determining a first area value corresponding to a sub-area in the first target background area and a second area value corresponding to a sub-area in the second target background area according to the first position coordinate and the first target translation, and the second position coordinate and the second target translation;
determining a third area value corresponding to the sub-area in the first target background area and a fourth area value corresponding to the sub-area in the second target background area based on the preset function and the first area value, and the preset function and the second area value respectively;
the first target text region and the second target text region are determined based on the first target translation and the third area value, and the second target translation and the fourth area value, respectively.
In one possible implementation manner, determining, according to the first position coordinate and the first target translation, a first area value corresponding to a sub-region in the first target background region includes:
determining the length and width corresponding to the first target background area based on the first position coordinates;
determining the length of the first target translation;
and determining a first area value according to the length and the width corresponding to the first target background area and the length of the first target translation.
In one possible implementation, determining the first target text region based on the first target translation and the third area value includes:
dividing the first target background area into a plurality of sub-areas by taking the third area value as a unit;
setting the first target translation into a plurality of sub-areas according to a preset sequence to form a first target translation area;
and taking the first target translation region as a first target text region.
In a second aspect, an embodiment of the present invention provides a device for translating a cartoon file in a JPG format, including:
the first parameter determining module is used for determining a first initial text area corresponding to special-effect characters and a first position coordinate corresponding to the first initial text area, and a second initial text area corresponding to non-effective characters and a second position coordinate corresponding to the second initial text area based on the initial cartoon file in the JPG format;
the second parameter determining module is used for determining a first target translation and a first target background area corresponding to the special-effect characters and a second target translation and a second target background area corresponding to the non-effect characters respectively based on the first initial text area and the second initial text area;
a target text region determining module, configured to determine a first target text region based on the first target translation, the first target background region, the first position coordinate, and a preset composition algorithm, and determine a second target text region based on the second target translation, the second target background region, the second position coordinate, and the preset composition algorithm;
and the target file determining module is used for determining a target cartoon file in a JPG format based on the first target text area and the second target text area.
In a third aspect, an embodiment of the present invention provides a terminal, including a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor implements, when executing the computer program, the steps of the method for translating a comic file in a JPG format as described above.
In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, where a computer program is stored, and when the computer program is executed by a processor, the steps of the method for translating a cartoon file in a JPG format as described above are implemented.
The embodiment of the invention provides a method, a device, a terminal and a storage medium for translating a cartoon file in a JPG format, wherein the method comprises the following steps: firstly, based on an initial cartoon file in a JPG format, determining a first initial text area corresponding to special effect characters and a first position coordinate corresponding to the first initial text area, and a second initial text area corresponding to non-effect characters and a second position coordinate corresponding to the second initial text area, then respectively based on the first initial text area and the second initial text area, determining a first target translation and a first target background area corresponding to the special effect characters, and a second target translation and a second target background area corresponding to the non-effect characters, then based on the first target translation, the first target background area, the first position coordinate and a preset typesetting algorithm, determining a first target text area, and based on the second target translation, the second target background area, the second position coordinate and the preset typesetting algorithm, determining a second target text area, and finally based on the first target text area and the second target text area, and determining a target cartoon file in the JPG format. The method respectively translates the special-effect characters and the non-effective characters in the cartoon file with the JPG format by using the text similarity matching method, reduces the error risk of online translation, ensures the accuracy of the translated text while maximally utilizing the machine to speed up, really saves manpower, improves efficiency, typesets the translated text based on the position coordinates, and greatly ensures the consistency of the structure of the text layer before and after the typesetting.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this application, serve to provide a further understanding of the application and to enable other features, objects, and advantages of the application to be more apparent. The drawings and their description illustrate the embodiments of the invention and do not limit it. In the drawings:
fig. 1 is a flowchart of an implementation of a method for translating a comic file in a JPG format according to an embodiment of the present invention;
fig. 2 is a schematic structural diagram of a device for translating a comic file in a JPG format according to an embodiment of the present invention;
fig. 3 is a schematic diagram of a terminal according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, 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.
The terms "first," "second," "third," "fourth," and the like in the description and in the claims, as well as in the drawings, if any, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are capable of operation in sequences other than those illustrated or described herein.
It should be understood that, in various embodiments of the present invention, the sequence numbers of the processes do not mean the execution sequence, and the execution sequence of the processes should be determined by the functions and the internal logic of the processes, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
It should be understood that in the present application, "comprising" and "having" and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
It should be understood that, in the present invention, "a plurality" means two or more. "and/or" is merely an association describing an associated object, meaning that three relationships may exist, for example, and/or B, may mean: a exists alone, A and B exist simultaneously, and B exists alone. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship. "comprises A, B and C" and "comprises A, B, C" means that all three of A, B, C comprise, "comprises A, B or C" means that one of A, B, C comprises, "comprises A, B and/or C" means that any 1 or any 2 or 3 of A, B, C comprises.
It should be understood that in the present invention, "B corresponding to a", "a corresponds to B", or "B corresponds to a" means that B is associated with a, and B can be determined from a. Determining B from a does not mean determining B from a alone, but may be determined from a and/or other information. And the matching of A and B means that the similarity of A and B is greater than or equal to a preset threshold value.
As used herein, "if" may be interpreted as "at … …" or "when … …" or "in response to a determination" or "in response to a detection", depending on the context.
The technical solution of the present invention will be described in detail below with specific examples. The following several specific embodiments may be combined with each other, and details of the same or similar concepts or processes may not be repeated in some embodiments.
In order to make the objects, technical solutions and advantages of the present invention more apparent, the following description is made by way of specific embodiments with reference to the accompanying drawings.
In one embodiment, as shown in fig. 1, there is provided a method for translating a comic file in a JPG format, including the steps of:
step S101: determining a first initial text area corresponding to special-effect characters and a first position coordinate corresponding to the first initial text area, and a second initial text area corresponding to non-effective characters and a second position coordinate corresponding to the second initial text area based on the initial cartoon file in the JPG format;
step S102: determining a first target translation and a first target background area corresponding to the special-effect characters and a second target translation and a second target background area corresponding to the non-effect characters based on the first initial text area and the second initial text area respectively;
step S103: determining a first target text region based on the first target translation, the first target background region, the first position coordinate and a preset typesetting algorithm, and determining a second target text region based on the second target translation, the second target background region, the second position coordinate and the preset typesetting algorithm;
step S104: and determining a target cartoon file in the JPG format based on the first target text area and the second target text area.
Wherein, the non-specific characters refer to the conventional characters without specific effects. The method includes the steps that an initial cartoon file in the JPG format comprises special effect characters and non-special effect characters, the special effect characters and the non-special effect characters are translated and typeset respectively according to the characteristics of the special effect characters and the non-special effect characters, and finally a target cartoon file in the JPG format is obtained.
Specifically, for special-effect characters, a text box only containing the special-effect characters in an initial cartoon file in a JPG format is determined, then the special-effect characters and a background area in the text box are respectively processed, namely the special-effect characters are extracted, a first target translation corresponding to the special-effect characters is determined by adopting a similarity algorithm, then the background area is eliminated and completed to determine a first target background area, and finally a first target text area corresponding to the special-effect characters is obtained based on a preset typesetting algorithm and a first position coordinate. Aiming at non-special-effect characters, the text box only containing the non-special-effect characters in the initial cartoon file in the JPG format is determined, then a second initial text area corresponding to the text box is processed to determine a second target background area and a second target translation corresponding to the non-effect characters, and finally a second target text area corresponding to the non-effect characters is obtained based on a preset typesetting algorithm and a second position coordinate. And constructing a target cartoon file based on the obtained first target text area and the second target text area as well as the non-effective characters and the effective character areas in the initial cartoon file.
The embodiment of the invention provides a method for translating a cartoon file in a JPG format, which comprises the following steps: firstly, based on an initial cartoon file in a JPG format, determining a first initial text area corresponding to special effect characters and a first position coordinate corresponding to the first initial text area, and a second initial text area corresponding to non-effect characters and a second position coordinate corresponding to the second initial text area, then respectively based on the first initial text area and the second initial text area, determining a first target translation and a first target background area corresponding to the special effect characters, and a second target translation and a second target background area corresponding to the non-effect characters, then based on the first target translation, the first target background area, the first position coordinate and a preset typesetting algorithm, determining a first target text area, and based on the second target translation, the second target background area, the second position coordinate and the preset typesetting algorithm, determining a second target text area, and finally based on the first target text area and the second target text area, and determining a target cartoon file in the JPG format. The method respectively translates the special-effect characters and the non-effective characters in the cartoon file with the JPG format by using the text similarity matching method, reduces the error risk of online translation, ensures the accuracy of the translated text while maximally utilizing the machine to speed up, really saves manpower, improves efficiency, typesets the translated text based on the position coordinates, and greatly ensures the consistency of the structure of the text layer before and after the typesetting.
In one embodiment, step S101 includes:
step S201: extracting all text boxes in the initial cartoon file;
step S202: recognizing characters in all the text boxes to obtain a first text box corresponding to the special-effect characters and a second text box corresponding to the non-effect characters;
step S203: a first initial text region and first location coordinates are determined based on the first text box, and a second initial text region and second location coordinates are determined based on the second text box.
Specifically, the initial cartoon file includes a plurality of text boxes, one part of the text boxes is special-effect characters, and the other part of the text boxes is non-special-effect characters. According to the method and the device, all text boxes in the initial cartoon file need to be extracted, and then characters in all the text boxes are recognized based on a character recognition algorithm so as to determine a first text box corresponding to special-effect characters and a second text box corresponding to non-special-effect characters. After the first text box and the second text box are determined, taking the first text box as an example, the area corresponding to the first text box is the first initial text area, and the position coordinate where the first text box is located is the first position coordinate. The determination of the second initial text region and the second position coordinate corresponding to the second initial text region is similar to that described above, and details are not repeated here.
In one embodiment, step S102 includes:
for a first initial text region, the method for determining a corresponding first target translation and first target background region includes: extracting special effect characters in the first initial text region, and obtaining a first target translation by using the special effect characters, a preset translation and a similarity algorithm; and sequentially eliminating and complementing the first initial background area in the first initial text area to obtain a first target background area.
Specifically, the preset translation refers to a database in which translations are stored, similarity calculation is performed on the basis of the special effect characters and the translations in the preset translation, and when a calculation result meets a preset threshold value, the corresponding translation is the first target translation. In order to keep the effect of the special effect text after the later typesetting consistent with that before the typesetting, the special effect text needs to be extracted first, then the background region (i.e. the first initial background region) in the first initial text region is eliminated, then the background region is complemented to obtain a complete background region (i.e. the first target background region), and finally the first target translation is pasted on the first target background region.
For the second initial text region, the method for determining the corresponding second target translation and second target background region includes: slicing the second initial text region to obtain a plurality of sub initial text regions; processing the plurality of sub-initial text regions by using a preset text box merging algorithm to obtain a second intermediate text region; extracting non-effective characters in the second intermediate text area to obtain a second target background area; and obtaining a second target translation by using the non-effective characters, the preset translation and a similarity algorithm.
Specifically, as the number of words of the non-effective characters is relatively large, the second initial text region is sliced to obtain a plurality of sub initial text regions, and then adjacent text regions are merged, i.e. whether adjacent regions exist in the horizontal direction and the vertical direction is calculated according to the coordinates of the corner points, if yes, the minimum circumscribed rectangle is merged, and the maximum mask frame is merged in an iterative manner to obtain a second intermediate text region. After the second intermediate text region is determined, the non-effective characters and the second target background region need to be separated, specifically: and according to the merged text box index, merging the non-effective characters identified by the OCR text in the corresponding second intermediate text area, extracting the non-effective characters, and separating the non-effective characters from the second target background area. And for the extracted non-effective characters, a similarity algorithm needs to be used to determine a second target translation corresponding to the non-effective characters, which is similar to the method for determining the first target translation and is not repeated here.
In one embodiment, step S103 includes:
aiming at the special effect characters: the first target text area is determined based on the first target translation, the first target background area, the first position coordinate and a preset typesetting algorithm. The method specifically comprises the following steps:
step S301: and determining a first area value corresponding to the sub-region in the first target background region according to the first position coordinate and the first target translation.
Specifically, first, the length and width corresponding to the first target background area are determined based on the first position coordinate, then the length of the first target translation is determined, and then the first area value is determined according to the length and width corresponding to the first target background area and the length of the first target translation.
Further, after the first position coordinate of the first initial text region is determined, the text box (i.e., the first target background region) corresponding to the first initial text region may be determined, and the length and width corresponding to the first target background region may also be determined.
Determining the first area value x (i.e., the initial area value or size of the sub-region) is formulated as follows:
x*x*len(text)=h*w
where len (text) is the length of the first target translation, h is the length of the first target background region, and w represents the width of the first target background region.
Step S302: and determining a third area value corresponding to the sub-area in the first target background area based on the preset function and the first area value.
Specifically, the preset function is as follows:
(h//x)*(w//x)>=len(text)
where len (text) is the length of the first target translation, h is the length of the first target background region, w represents the width of the first target background region, and x represents the first area value.
In the iteration process of the preset function, if the first target translation exceeds the first target background region, the x is required to be reduced by self until the first target translation is completely within the first target background region, and x at this time is called as a third area value.
Step S303: a first target text region is determined based on the first target translation and the third area value.
Specifically, the first target text region is determined to be a plurality of sub-regions into which the first target background region is divided by taking the third area value as a unit, the first target translation is arranged in the plurality of sub-regions according to a preset sequence to form a first target translation region, and the first target translation region is used as the first target text region.
Further, if the first target background area is a rectangle of 8 × 8 and the third area value is 4, the first target background area may be divided into 16 sub-areas by 4, and then the 16 sub-areas are filled with the first target translation one by one to form a first target translation area, i.e., a first target text area.
Aiming at non-special-effect characters: and determining a second target text area based on the second target translation, the second target background area, the second position coordinate and a preset typesetting algorithm. The specific method comprises the following steps:
step S401: determining a second area value corresponding to a sub-region in a background region of the second target according to the second position coordinate and the second target translation;
step S402: determining a fourth area value corresponding to the sub-area in the second target background area based on the preset function and the second area value;
step S403: based on the second target translation and the fourth area value, a second target text region is determined.
Specifically, steps S401 to S403 involved in determining the second target text region corresponding to the non-effective character are similar to steps S301 to S303 involved in determining the first target text region corresponding to the effective character, and are not described in detail here.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present invention.
The following are embodiments of the apparatus of the invention, reference being made to the corresponding method embodiments described above for details which are not described in detail therein.
Fig. 2 is a schematic structural diagram of a translation apparatus for a comic file in a JPG format according to an embodiment of the present invention, and for convenience of description, only a part related to the embodiment of the present invention is shown, where the translation apparatus for a comic file in a JPG format includes a first parameter determining module 21, a second parameter determining module 22, a target text area determining module 23, and a target file determining module 24, and the specific details are as follows:
the first parameter determining module 21 is configured to determine, based on the initial cartoon file in the JPG format, a first initial text region corresponding to the special-effect text and a first position coordinate corresponding to the first initial text region, and a second initial text region corresponding to the non-special-effect text and a second position coordinate corresponding to the second initial text region;
a second parameter determining module 22, configured to determine, based on the first initial text region and the second initial text region, a first target translation and a first target background region corresponding to the special-effect text, and a second target translation and a second target background region corresponding to the non-effect text, respectively;
a target text region determining module 23, configured to determine a first target text region based on the first target translation, the first target background region, the first position coordinate, and a preset composition algorithm, and determine a second target text region based on the second target translation, the second target background region, the second position coordinate, and the preset composition algorithm;
and the target file determining module 24 is used for determining a target cartoon file in the JPG format based on the first target text area and the second target text area.
In one possible implementation, the first parameter determining module 21 includes:
the extraction submodule is used for extracting all text boxes in the initial cartoon file;
the text recognition submodule is used for recognizing characters in all the text boxes to obtain a first text box corresponding to the special-effect characters and a second text box corresponding to the non-effective characters;
a first parameter determination sub-module to determine a first initial text region and first location coordinates based on the first text box and a second initial text region and second location coordinates based on the second text box.
In one possible implementation, the second parameter determining module 22 includes:
the first calculation submodule is used for extracting the special effect characters in the first initial text region and obtaining a first target translation by utilizing the special effect characters, the preset translation and a similarity algorithm;
and the first background area determining submodule is used for eliminating and complementing the first initial background area in the first initial text area in sequence to obtain a first target background area.
In one possible implementation, the second parameter determining module 22 includes:
the region slicing submodule is used for slicing the second initial text region to obtain a plurality of sub initial text regions;
the second calculation submodule is used for processing the plurality of sub-initial text regions by using a preset text box merging algorithm to obtain a second intermediate text region;
the second background area determining submodule is used for extracting non-effective characters in the second middle text area to obtain a second target background area;
and the third calculation submodule is used for obtaining a second target translation by using the non-effective characters, the preset translation and the similarity algorithm.
In one possible implementation, the target text region determining module 23 includes:
the first parameter value determining submodule is used for determining a first area value corresponding to a sub-area in a first target background area and a second area value corresponding to a sub-area in a second target background area according to the first position coordinate and the first target translation, and the second position coordinate and the second target translation;
the second parameter value determining submodule is used for determining a third area value corresponding to the sub-area in the first target background area and a fourth area value corresponding to the sub-area in the second target background area respectively based on the preset function and the first area value as well as the preset function and the second area value;
a target text region determination sub-module to determine a first target text region and a second target text region based on the first target translation and the third area value, and the second target translation and the fourth area value, respectively.
In one possible implementation, the first parameter value determining sub-module includes:
a first parameter value determining unit, configured to determine, based on the first position coordinate, a length and a width corresponding to the first target background area;
the second parameter value determining unit is used for determining the length of the first target translation;
and the third parameter value determining unit is used for determining a first area value according to the length and the width corresponding to the first target background area and the length of the first target translation.
In one possible implementation, the target text region determination sub-module includes:
a sub-region determining unit configured to divide the first target background region into a plurality of sub-regions in units of the third area value;
the translation region determining unit is used for setting the first target translation in the plurality of sub-regions according to a preset sequence to form a first target translation region;
a target text region determination unit to use the first target translation region as a first target text region.
Fig. 3 is a schematic diagram of a terminal according to an embodiment of the present invention. As shown in fig. 3, the terminal 3 of this embodiment includes: a processor 30, a memory 31, and a computer program 32 stored in the memory 31 and executable on the processor 30. The processor 30 executes the computer program 32 to implement the steps in the embodiments of the method for translating the comic file in the JPG format, such as the steps 101 to 104 shown in fig. 1. Alternatively, the processor 30, when executing the computer program 32, implements the functions of the modules/units in the translation apparatus embodiments of the respective comic files in the JPG format, such as the functions of the modules/units 21 to 24 shown in fig. 2.
The present invention also provides a readable storage medium, in which a computer program is stored, and the computer program is used for implementing the method provided by the above-mentioned various embodiments when being executed by a processor.
The readable storage medium may be a computer storage medium or a communication medium. Communication media includes any medium that facilitates transfer of a computer program from one place to another. Computer storage media may be any available media that can be accessed by a general purpose or special purpose computer. For example, a readable storage medium is coupled to the processor such that the processor can read information from, and write information to, the readable storage medium. Of course, the readable storage medium may also be an integral part of the processor. The processor and the readable storage medium may reside in an Application Specific Integrated Circuits (ASIC). Additionally, the ASIC may reside in user equipment. Of course, the processor and the readable storage medium may also reside as discrete components in a communication device. The readable storage medium may be a read-only memory (ROM), a random-access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
The present invention also provides a program product comprising execution instructions stored in a readable storage medium. The at least one processor of the device may read the execution instructions from the readable storage medium, and the execution of the execution instructions by the at least one processor causes the device to implement the methods provided by the various embodiments described above.
In the above embodiments of the apparatus, it should be understood that the Processor may be a Central Processing Unit (CPU), other general purpose processors, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of a method disclosed in connection with the present invention may be embodied directly in a hardware processor, or in a combination of the hardware and software modules within the processor.
The above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present 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 solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present invention, and are intended to be included within the scope of the present invention.
Claims (10)
1. A method for translating cartoon files in a JPG format is characterized by comprising the following steps:
determining a first initial text area corresponding to special-effect characters and a first position coordinate corresponding to the first initial text area, and a second initial text area corresponding to non-effective characters and a second position coordinate corresponding to the second initial text area based on an initial cartoon file in a JPG format;
determining a first target translation and a first target background region corresponding to the special-effect words and a second target translation and a second target background region corresponding to the non-effect words based on the first initial text region and the second initial text region respectively;
determining a first target text region based on the first target translation, the first target background region, the first position coordinate and a preset composition algorithm, and determining a second target text region based on the second target translation, the second target background region, the second position coordinate and the preset composition algorithm;
and determining a target cartoon file in a JPG format based on the first target text area and the second target text area.
2. The method for translating a comic file in a JPG format according to claim 1, wherein determining, based on the initial comic file in the JPG format, a first position coordinate corresponding to a first initial text region and the first initial text region corresponding to special-effect characters, and a second position coordinate corresponding to a second initial text region and the second initial text region corresponding to non-special-effect characters, comprises:
extracting all text boxes in the initial cartoon file;
recognizing characters in all the text boxes to obtain a first text box corresponding to the special-effect characters and a second text box corresponding to the non-special-effect characters;
determining the first initial text region and the first location coordinates based on the first text box, and determining the second initial text region and the second location coordinates based on the second text box.
3. The method for translating a cartoon file in a JPG format according to claim 2, wherein the determining a first target translation and a first target background region corresponding to the special-effect text based on the first initial text region comprises:
extracting special effect characters in the first initial text region, and obtaining the first target translation by using the special effect characters, a preset translation and a similarity algorithm;
and sequentially eliminating and complementing the first initial background area in the first initial text area to obtain the first target background area.
4. The method for translating a comic file in a JPG format according to claim 2, wherein the determining a second target translation and a second target background region corresponding to the non-effective character based on the second initial text region comprises:
slicing the second initial text region to obtain a plurality of sub initial text regions;
processing the plurality of sub-initial text regions by using a preset text box merging algorithm to obtain a second intermediate text region;
extracting non-effective characters in the second intermediate text area to obtain a second target background area;
and obtaining the second target translation by using the non-effective characters, the preset translation and a similarity algorithm.
5. The method for translating a comic file in a JPG format according to claim 3 or 4, wherein the determining the first target text region based on the first target translation, the first target background region, the first position coordinates, and a preset composition algorithm, and the determining the first target text region based on the second target translation, the second target background region, the second position coordinates, and a preset composition algorithm comprises:
determining a first area value corresponding to a sub-region in the first target background region and a second area value corresponding to a sub-region in the second target background region according to the first position coordinate and the first target translation, and the second position coordinate and the second target translation, respectively;
determining a third area value corresponding to a sub-area in the first target background area and a fourth area value corresponding to a sub-area in the second target background area based on a preset function and the first area value, and a preset function and the second area value, respectively;
determining the first target text region and the second target text region based on the first target translation and the third area value, and the second target translation and the fourth area value, respectively.
6. The method for translating a comic file in a JPG format according to claim 5, wherein the determining a first area value corresponding to a sub-region in the first target background region according to the first position coordinate and the first target translation comprises:
determining the length and width corresponding to the first target background area based on the first position coordinates;
determining the length of the first target translation;
and determining the first area value according to the length and the width corresponding to the first target background area and the length of the first target translation.
7. The method for translating a comic file in a JPG format according to claim 6, wherein the determining the first target text region based on the first target translation and the third area value comprises:
dividing the first target background area into a plurality of sub-areas by taking a third area value as a unit;
setting the first target translation into the plurality of sub-areas according to a preset sequence to form a first target translation area;
and taking the first target translation region as the first target text region.
8. An apparatus for translating a comic file in a JPG format, comprising:
the first parameter determining module is used for determining a first initial text area corresponding to special-effect characters and a first position coordinate corresponding to the first initial text area, and a second initial text area corresponding to non-effective characters and a second position coordinate corresponding to the second initial text area based on the initial cartoon file in the JPG format;
a second parameter determining module, configured to determine, based on the first initial text region and the second initial text region, a first target translation and a first target background region corresponding to the special-effect text, and a second target translation and a second target background region corresponding to the non-effect text, respectively;
a target text region determining module, configured to determine a first target text region based on the first target translation, the first target background region, the first position coordinate, and a preset composition algorithm, and determine a second target text region based on the second target translation, the second target background region, the second position coordinate, and the preset composition algorithm;
and the target file determining module is used for determining a target cartoon file in a JPG format based on the first target text area and the second target text area.
9. A terminal comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the steps of the method for translating a caricature file in JPG format according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium storing a computer program, the computer program implementing the steps of the method for translating a comic file in JPG format according to any one of claims 1 to 7 when executed by a processor.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111461763.2A CN114359929A (en) | 2021-12-03 | 2021-12-03 | Method, device, terminal and storage medium for translating cartoon file in JPG format |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111461763.2A CN114359929A (en) | 2021-12-03 | 2021-12-03 | Method, device, terminal and storage medium for translating cartoon file in JPG format |
Publications (1)
Publication Number | Publication Date |
---|---|
CN114359929A true CN114359929A (en) | 2022-04-15 |
Family
ID=81096760
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111461763.2A Pending CN114359929A (en) | 2021-12-03 | 2021-12-03 | Method, device, terminal and storage medium for translating cartoon file in JPG format |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114359929A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117274438A (en) * | 2023-11-06 | 2023-12-22 | 杭州同花顺数据开发有限公司 | Picture translation method and system |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2009080727A (en) * | 2007-09-27 | 2009-04-16 | Fuji Xerox Co Ltd | Translation device and program |
CN103348338A (en) * | 2010-12-22 | 2013-10-09 | 富士胶片株式会社 | File format, server, view device for digital comic, digital comic generation device |
KR20170008357A (en) * | 2015-07-13 | 2017-01-24 | 주식회사 에버트란 | System for Translating Using Crowd Sourcing, Server and Method for Web toon Language Automatic Translating |
CN111723585A (en) * | 2020-06-08 | 2020-09-29 | 中国石油大学(华东) | Style-controllable image text real-time translation and conversion method |
CN113591437A (en) * | 2021-08-09 | 2021-11-02 | 网易(杭州)网络有限公司 | Game text translation method, electronic device and storage medium |
CN113705158A (en) * | 2021-09-26 | 2021-11-26 | 上海一者信息科技有限公司 | Method for intelligently restoring original text style in document translation |
-
2021
- 2021-12-03 CN CN202111461763.2A patent/CN114359929A/en active Pending
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2009080727A (en) * | 2007-09-27 | 2009-04-16 | Fuji Xerox Co Ltd | Translation device and program |
CN103348338A (en) * | 2010-12-22 | 2013-10-09 | 富士胶片株式会社 | File format, server, view device for digital comic, digital comic generation device |
KR20170008357A (en) * | 2015-07-13 | 2017-01-24 | 주식회사 에버트란 | System for Translating Using Crowd Sourcing, Server and Method for Web toon Language Automatic Translating |
CN111723585A (en) * | 2020-06-08 | 2020-09-29 | 中国石油大学(华东) | Style-controllable image text real-time translation and conversion method |
CN113591437A (en) * | 2021-08-09 | 2021-11-02 | 网易(杭州)网络有限公司 | Game text translation method, electronic device and storage medium |
CN113705158A (en) * | 2021-09-26 | 2021-11-26 | 上海一者信息科技有限公司 | Method for intelligently restoring original text style in document translation |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117274438A (en) * | 2023-11-06 | 2023-12-22 | 杭州同花顺数据开发有限公司 | Picture translation method and system |
CN117274438B (en) * | 2023-11-06 | 2024-02-20 | 杭州同花顺数据开发有限公司 | Picture translation method and system |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2021147252A1 (en) | Ocr-based table format recovery method and apparatus, electronic device, and storage medium | |
WO2021147222A1 (en) | Ocr-based table layout restoration method and device, electronic apparatus, and storage medium | |
CN113642584A (en) | Character recognition method, device, equipment, storage medium and intelligent dictionary pen | |
CN109271598B (en) | Method, device and storage medium for extracting news webpage content | |
CN114359929A (en) | Method, device, terminal and storage medium for translating cartoon file in JPG format | |
CN113920038A (en) | Cut contour extraction method, device system and medium | |
CN115546809A (en) | Table structure identification method based on cell constraint and application thereof | |
CN114663897A (en) | Table extraction method and table extraction system | |
CN116402020A (en) | Signature imaging processing method, system and storage medium based on OFD document | |
CN115223172A (en) | Text extraction method, device and equipment | |
CN114332885A (en) | Method, device, terminal and storage medium for translating cartoon file in PSD format | |
CN112464626B (en) | Graph extraction method of PDF (Portable document Format) document, electronic equipment and storage medium | |
CN111798542B (en) | Model training method, data processing device, model training apparatus, and storage medium | |
CN113780297A (en) | Image processing method, device, equipment and storage medium | |
CN112861485A (en) | Method, device and equipment for processing nuclear power DCS control logic drawing | |
CN111523531A (en) | Word processing method and device, electronic equipment and computer readable storage medium | |
CN109741426B (en) | Cartoon form conversion method and device | |
CN113011131B (en) | Typesetting method based on picture electronic book, electronic equipment and storage medium | |
CN115797955A (en) | Table structure identification method based on cell constraint and application thereof | |
CN113269153B (en) | Form identification method and device | |
CN113343797A (en) | Information extraction method and device, terminal equipment and computer readable storage medium | |
CN113743056A (en) | Document conversion method based on paragraph shrinkage amount, computing device and storage medium | |
CN112100978B (en) | Typesetting processing method based on electronic book, electronic equipment and storage medium | |
CN114386407A (en) | Word segmentation method and device for text | |
CN114743203A (en) | Document processing method, device, equipment and 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 |