Data processing method and device, electronic equipment and computer readable storage medium

By normalizing the position information of text characters in game development and mapping it to preset texture maps, the problem of stretching or compression of long text or multi-line text font textures is solved, improving image clarity and user experience.

CN120031997APending Publication Date: 2025-05-23NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510075550.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-16
Publication Date
2025-05-23

AI Technical Summary

Technical Problem

In game development, the font texture of long text or multiple lines of text is easily stretched or compressed, resulting in unclear font display and affecting image quality.

Method used

By obtaining the pending character segments and preset texture maps, the position information of each character is determined and normalized, mapped into the preset texture map to obtain color information, and finally rendering and displaying to avoid image stretching or compression.

Benefits of technology

Improves the image clarity after text characters are converted into images, and improves the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120031997A_ABST
    Figure CN120031997A_ABST
Patent Text Reader

Abstract

The invention discloses a data processing method and device, electronic equipment and a computer readable storage medium, and the method comprises the steps: obtaining a to-be-processed character field and a preset texture map; determining first position information of each character in the to-be-processed character field, wherein the first position information is used for representing pixel coordinates of the character in the to-be-processed character field; performing normalization processing on the first position information to obtain second position information of each character in the to-be-processed character field, the second position information being used for representing normalization coordinates of the character in the to-be-processed character field; and sampling in the texture map according to the second position information to obtain color information corresponding to each character. Therefore, according to the data processing method provided by the embodiment of the invention, the definition of the image after the text characters are converted into the image can be improved, and the user experience is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computers, and in particular to a data processing method, device, electronic device and computer-readable storage medium. Background Art

[0002] In game development, you can achieve diversified font effects in text based on Unreal Engine (UE). In UE, each line of text is regarded as a UV sampling range of 0 to 1, and the font texture is sampled with the UV range of 0 to 1, and the sampled font texture is rendered and displayed.

[0003] However, when the text content is long or contains multiple lines, the font texture will be stretched or compressed, resulting in unclear font display and affecting image quality. Summary of the invention

[0004] The present application provides a data processing method, device, electronic device and computer-readable storage medium, which can improve the clarity of images after converting text characters into images and enhance user experience. The specific scheme is as follows:

[0005] In a first aspect, an embodiment of the present application provides a data processing method, the method comprising:

[0006] Get the character segment to be processed and the preset texture map;

[0007] Determine first position information of each character in the character segment to be processed, where the first position information is used to represent the pixel coordinates of the character in the character segment to be processed;

[0008] Normalizing the first position information to obtain second position information of each character in the character segment to be processed, wherein the second position information is used to represent the normalized coordinates of the character in the character segment to be processed;

[0009] Sampling in the texture map according to the second position information to obtain color information corresponding to each of the characters;

[0010] The character segment to be processed is rendered and displayed according to the color information corresponding to each of the characters.

[0011] In some embodiments, obtaining the character segment to be processed includes: parsing an encoding file corresponding to the character segment to be processed to obtain the character segment to be processed.

[0012] In some embodiments, parsing the encoding file corresponding to the character segment to be processed to obtain the character segment to be processed includes: parsing the encoding file corresponding to the character segment to be processed according to the escape characters in the encoding file corresponding to the character segment to be processed to obtain the character segment to be processed.

[0013] In some embodiments, determining the first position information of each character in the character segment to be processed includes: selecting a font file and obtaining the attributes of each character in the character segment to be processed from the font file; determining the bounding box of the character segment to be processed based on the attributes of the character; determining the position information of the bounding box of the character in the character segment to be processed, and using the position information of the bounding box of the character in the character segment to be processed as the first position information.

[0014] In some embodiments, determining the position information of the bounding box of the character in the character segment to be processed includes: determining the bounding box of the character based on the attributes of the character; determining the position information of the bounding box of the character in the bounding box of the character segment to be processed, and using the position information of the bounding box of the character in the bounding box of the character segment to be processed as the position information of the bounding box of the character in the character segment to be processed.

[0015] In some embodiments, before determining the position information of the bounding box of the character in the bounding box of the character segment to be processed, the method further includes: determining the upper left corner coordinates and lower right corner coordinates of the bounding box of the character and the upper left corner coordinates and lower right corner coordinates of the bounding box of the character segment to be processed; determining the position information of the bounding box of the character in the bounding box of the character segment to be processed includes: determining the position information of the bounding box of the character in the bounding box of the character segment to be processed based on the upper left corner coordinates and lower right corner coordinates of the bounding box of the character and the upper left corner coordinates and lower right corner coordinates of the bounding box of the character segment to be processed.

[0016] In some embodiments, the first position information is normalized to obtain the second position information of each character in the character segment to be processed, including: normalizing the first position information according to the ratio of the horizontal coordinate of the upper left corner coordinate of the character's bounding box to the width of the bounding box of the character segment to be processed, the ratio of the vertical coordinate of the upper left corner coordinate of the character's bounding box to the height of the bounding box of the character segment to be processed, the ratio of the horizontal coordinate of the lower right corner coordinate of the character's bounding box to the width of the bounding box of the character segment to be processed, and the ratio of the vertical coordinate of the lower right corner coordinate of the character's bounding box to the height of the bounding box of the character segment to be processed, to obtain the second position information of each character in the character segment to be processed.

[0017] In some embodiments, sampling in the texture map according to the second position information to obtain color information corresponding to each of the characters includes: determining the ratio of the width of the bounding box of the character segment to be processed to the width of the preset texture map and the ratio of the height of the bounding box of the character segment to be processed to the height of the preset texture map; mapping the second position information to the preset texture map according to the ratio of the width of the bounding box of the character segment to be processed to the width of the preset texture map and the ratio of the height of the bounding box of the character segment to be processed to the height of the preset texture map to obtain the color information of the character segment to be processed.

[0018] In a second aspect, an embodiment of the present application provides a data processing device, the device comprising:

[0019] An acquisition unit, used for acquiring a character segment to be processed and a preset texture map;

[0020] A determination unit, which determines first position information of each character in the character segment to be processed, wherein the first position information is used to represent the pixel coordinates of the character in the character segment to be processed;

[0021] A processing unit, performing normalization processing on the first position information to obtain second position information of each character in the character segment to be processed, wherein the second position information is used to represent the normalized coordinates of the character in the character segment to be processed;

[0022] A sampling unit, configured to sample in the texture map according to the second position information to obtain color information corresponding to each of the characters;

[0023] A rendering unit is used to render and display the character segment to be processed according to the color information corresponding to each character.

[0024] Optionally, the acquisition unit is specifically used to: parse the encoding file corresponding to the character segment to be processed to obtain the character segment to be processed.

[0025] Optionally, the acquisition unit is specifically used to: parse the encoding file corresponding to the character segment to be processed according to the escape character in the encoding file corresponding to the character segment to be processed, so as to obtain the character segment to be processed.

[0026] Optionally, the determination unit is specifically used to: select a font file, and obtain the attributes of each character in the character segment to be processed from the font file; determine the bounding box of the character segment to be processed based on the attributes of the character; determine the position information of the bounding box of the character in the character segment to be processed, and use the position information of the bounding box of the character in the character segment to be processed as the first position information.

[0027] Optionally, the determination unit is specifically used to: determine the bounding box of the character according to the attributes of the character; determine the position information of the bounding box of the character in the bounding box of the character segment to be processed, and use the position information of the bounding box of the character in the bounding box of the character segment to be processed as the position information of the bounding box of the character in the character segment to be processed.

[0028] Optionally, the determination unit is also used to: determine the upper left corner coordinates and lower right corner coordinates of the bounding box of the character and the upper left corner coordinates and lower right corner coordinates of the bounding box of the character segment to be processed; the determination unit is specifically used to: determine the position information of the bounding box of the character in the bounding box of the character segment to be processed based on the upper left corner coordinates and lower right corner coordinates of the bounding box of the character and the upper left corner coordinates and lower right corner coordinates of the bounding box of the character segment to be processed.

[0029] Optionally, the processing unit is specifically used to: normalize the first position information according to the ratio of the horizontal coordinate of the upper left corner coordinate of the character's bounding box to the width of the bounding box of the character segment to be processed, the ratio of the vertical coordinate of the upper left corner coordinate of the character's bounding box to the height of the bounding box of the character segment to be processed, the ratio of the horizontal coordinate of the lower right corner coordinate of the character's bounding box to the width of the bounding box of the character segment to be processed, and the ratio of the vertical coordinate of the lower right corner coordinate of the character's bounding box to the height of the bounding box of the character segment to be processed, so as to obtain the second position information of each character in the character segment to be processed.

[0030] Optionally, the sampling unit is specifically used to: determine the ratio of the width of the bounding box of the character segment to be processed to the width of the preset texture map and the ratio of the height of the bounding box of the character segment to be processed to the height of the preset texture map; map the second position information to the preset texture map according to the ratio of the width of the bounding box of the character segment to be processed to the width of the preset texture map and the ratio of the height of the bounding box of the character segment to be processed to the height of the preset texture map to obtain the color information of the character segment to be processed.

[0031] In a third aspect, the present application further provides an electronic device, including:

[0032] Processor; and

[0033] The memory is used to store a data processing program. After the electronic device is powered on and the program is run by the processor, the method described in the first aspect is executed.

[0034] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium storing a data processing program, which is executed by a processor to perform the method described in the first aspect.

[0035] The data processing method provided by the embodiment of the present application includes the following steps: obtaining a character segment to be processed and a preset texture map; determining the first position information of each character in the character segment to be processed, the first position information being used to characterize the pixel coordinates of the character in the character segment to be processed; normalizing the first position information to obtain the second position information of each character in the character segment to be processed, the second position information being used to characterize the normalized coordinates of the character in the character segment to be processed; sampling the texture map according to the second position information to obtain the color information corresponding to each character; rendering and displaying the character segment to be processed according to the color information corresponding to each character. It can be seen that in the present application, the position of each character in the character segment to be processed is determined based on each character in the character segment to be processed, and the position of each character in the character segment to be processed is normalized, so that the position information of each character in the character segment to be processed is mapped to the preset texture map to obtain the color information corresponding to each character, and finally the character segment to be processed is rendered and displayed according to the color information corresponding to each character. Compared with the prior art method of treating each line of text as a UV sampling range of 0 to 1 and sampling the font texture with a UV range of 0 to 1, the present application avoids the situation where the image is stretched or compressed. Therefore, the data processing method provided in the embodiment of the present application can improve the clarity of the image after converting text characters into an image, and enhance the user experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] Figure 1 A schematic diagram of an image obtained by sampling each line of text as an independent UV range provided in an embodiment of the present application;

[0037] Figure 2 A flowchart of a data processing method provided in an embodiment of the present application;

[0038] Figure 3 A schematic diagram of a bounding box of a character segment to be processed provided in an embodiment of the present application;

[0039] Figure 4 A schematic diagram of baseline shift when the characters provided in the embodiment of the present application are English letters;

[0040] Figure 5 is a structural block diagram of an example of a data processing device provided in an embodiment of the present application;

[0041] Figure 6 It is a structural block diagram of an example of an electronic device for data processing provided in an embodiment of the present application. DETAILED DESCRIPTION

[0042] Many specific details are described in the following description to facilitate a full understanding of the present application. However, the present application can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the connotation of the present application, so the present application is not limited by the specific implementation disclosed below.

[0043] It should be noted that the terms "first", "second", "third", etc. in the claims, description and drawings of the present application are used to distinguish similar objects and are not used to describe a specific order or sequence. The data used in this way are interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "including", "having" and their variants are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0044] It should be understood that in the embodiments of the present application, "at least one" refers to one or more, and "more than one" refers to two or more. "And / or" is merely a way to describe the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the previous and subsequent associated objects are in an "or" relationship. "Including A, B and / or C" means including any one, any two, or any three of A, B, and C.

[0045] It should be understood that in the embodiments of the present application, "B corresponding to A", "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 according to A. Determining B according to A does not mean determining B only according to A, and B can also be determined according to A and / or other information.

[0046] In game development, you can achieve diversified font effects in text based on Unreal Engine (UE). In UE, each line of text is regarded as a UV sampling range of 0 to 1, and the font texture is sampled with the UV range of 0 to 1, and the sampled font texture is rendered and displayed.

[0047] However, when the text content is long or contains multiple lines, the font texture will be stretched or compressed, resulting in unclear font display and affecting image quality.

[0048] Among them, Unreal Engine is a powerful game engine developed by Epic Games, which is widely used in game development, virtual reality (VR), augmented reality (AR) and other simulation environments. It provides developers with multiple functions such as graphics rendering, physical simulation, network communication, etc., allowing developers to create complex interactive scenes and high-quality three-dimensional (3D) graphics.

[0049] Font rendering refers to the process of converting text characters into graphic images, which can also be understood as representing text characters with pixels. For computer graphics, font rendering involves extracting the shape of the characters from the font file and drawing them to the screen or other output device, usually considering the font's size, color, spacing and other properties. UV coordinates are a two-dimensional coordinate system that is commonly used in computer graphics, especially in texture mapping of three-dimensional models. The U and V coordinates define a point on a two-dimensional texture image. The U coordinate represents the coordinate value in the horizontal direction, usually between 0 and 1 (or depending on the resolution of the texture image, it may exceed this range, but it will be normalized). The V coordinate represents the coordinate value in the vertical direction, also usually between 0 and 1.

[0050] In the prior art, when using the UV sampling image of the text provided by the UE, each line of text is usually sampled as an independent UV range, which means that for each line of text, the UE will map it to a UV range of 0 to 1. However, since the length and height of the text vary, the increase in text length and number of lines will increase the risk of texture deformation, especially in multi-line text, where the distribution of each line may be different. When they are forced to be mapped to the same UV range, stretching or compression will occur. As a result, after the text characters are converted into an image, the resolution is shared when long text or multi-line text is displayed, and the image is not clear, affecting the user's perception. The resolution refers to the number of pixels per unit area of ​​the image. A higher resolution means that the image can display more details.

[0051] Figure 1 A schematic diagram of an image obtained by sampling each line of text as an independent UV range provided in an embodiment of the present application. Figure 1 In the image, each line of text is sampled as a UV range of 0 to 1. Therefore, the image is stretched and compressed by the text range, making it unclear.

[0052] Based on background technical reasons, in order to improve the clarity of the image after converting text characters into an image and enhance the user experience. The first embodiment of the present application provides a data processing method, which is applied to an electronic device, which can be a desktop computer, a laptop computer, a mobile phone, a tablet computer, an electronic watch, etc., or other electronic devices capable of data processing, which is not specifically limited in the embodiments of the present application.

[0053] The technical solution of the present application is described in detail below through specific embodiments. It should be noted that the following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.

[0054] Figure 2 The following is a flow chart of a data processing method provided in an embodiment of the present application. Figure 2 As shown, the data processing method may include S201-S205.

[0055] S201, obtaining a character segment to be processed and a preset texture map.

[0056] For example, the encoding file corresponding to the character segment to be processed can be obtained first, the encoding file of the text to be processed can be decomposed into individual characters, and each character can be parsed to obtain the character segment to be processed. The texture map provided by the artist can also be obtained.

[0057] S202: Determine first position information of each character in the character segment to be processed, where the first position information is used to represent the pixel coordinates of the character in the character segment to be processed.

[0058] In an optional embodiment, S202 may be implemented through S301 - S303 .

[0059] S301, selecting a font file, and obtaining the attribute of each character in the character segment to be processed from the font file;

[0060] Exemplarily, a font file can be selected, such as a TrueType font (TTF), an OpenType font (OTF), etc., and the attributes of each character in the character segment to be processed can be determined based on the font file. The attributes of the characters may include the area occupied by each character in the character segment to be processed, the position of the area occupied by each character in the character segment to be processed, the width and height of each character, character spacing, line spacing, line height and line width of each line of characters, etc. Among them, TTF is a widely used font format developed by Apple. It is composed of curves and straight lines defined by mathematical formulas, and each glyph of the font is defined using mathematical curves, so they can be scaled to any size without distortion. This font format allows font designers to precisely control the placement of each pixel, especially at low resolutions, so that it can remain clear at different resolutions, making the text more readable on the screen. TTF font files usually contain all the necessary information of the font for rendering by the system or application. OTF is a font format developed by Microsoft and Adobe. It is an extension of TrueType fonts and supports a wide range of character sets, including characters and symbols in multiple languages. It also supports more advanced font features, such as contextual alternates, ligatures, character spacing adjustment, etc. OTF can also contain glyph information of PostScript fonts, so it has better cross-platform compatibility and can run seamlessly on operating systems such as Windows, macOS, and Linux. In addition, OpenType fonts also support font embedding technology, which means that they can be embedded in documents or applications to ensure that they can be displayed correctly on different computers or devices. Character spacing refers to the horizontal space between two adjacent characters. Line spacing refers to the vertical space between two lines of characters. It is usually determined based on the size of the characters and the line height. Too small line spacing may cause characters to overlap each other, and too large line spacing may affect the coherence of the character segment. Character width and height indicate the space occupied by a single character in the character segment to be processed on the screen. The width of the character refers to the horizontal size of the character, while the height of the character refers to the vertical size of the character.

[0061] S302, determining a bounding box of the character segment to be processed according to the attributes of the character;

[0062] S303: Determine the position information of the bounding box of the character in the to-be-processed character segment, and use the position information of the bounding box of the character in the to-be-processed character segment as the first position information.

[0063] Exemplarily, the character segment to be processed is regarded as a whole, and the bounding box of the character segment to be processed is determined according to the attributes of each character mentioned above. The bounding box of the character segment to be processed is a rectangular area, which describes the minimum outer size of the character segment to be processed. In font rendering, the bounding box represents the outer boundary of a character segment or a single character, which is used to determine the position and size of the character on the screen or in a virtual space. The width of the bounding box of the character segment to be processed is the maximum width of all character rows, and the height of the bounding box of the character segment to be processed is the sum of the accumulated values ​​of the row heights of all character rows and the spacing between each row. Among them, the bounding box of the character segment to be processed also includes additional space. For example, when determining the bounding box of the character segment to be processed, if a picture is inserted into a row of characters, and the height of the picture is greater than the height of the character row in which it is located, then the row height of the character row where the picture is located is at least the height of the picture.

[0064] For example, Figure 3 Schematic diagram of the bounding box of the character segment to be processed provided in the embodiment of the present application. Figure 3 As shown, the width of the bounding box is x, and the height of the bounding box is (y+y+z). The width of the bounding box of the character segment to be processed, the height of the bounding box of the character segment to be processed, and the coordinates of the upper left corner and the lower right corner of the bounding box of the character segment to be processed in the pixel coordinate system can be stored in uv[3], where uv[3] is a two-dimensional vector. The coordinates of the upper left corner of the bounding box can be used as the origin to determine the coordinates of each character in the bounding box of the character segment to be processed, and the coordinates of each character in the bounding box of the character segment to be processed can be used as the first position information.

[0065] S203. Normalize the first position information to obtain second position information of each character in the character segment to be processed, where the second position information is used to represent the normalized coordinates of the character in the character segment to be processed.

[0066] Exemplarily, after determining the first position information of each character in the character segment to be processed, the first position information of each character in the character segment to be processed can be normalized to obtain the second position information of each character in the character segment to be processed, that is, the normalized coordinates of the character in the character segment to be processed, and the normalized coordinates of the character in the character segment to be processed are stored in the font's uv[0], where uv[0] is a two-dimensional vector. For example, assuming that the character segment to be processed is "HELO", the first position information of "H" is 1, the first position information of "E" is 2, the first position information of "L" is 3, and the first position information of "O" is 4, the first position of the character is normalized, and it can be determined that the length of the character segment is 4, the second position information of "H" is 1 / 4=0.25, the second position information of "E" is 2 / 4=0.5, the second position information of "L" is 3 / 4=0.75, and the second position information of "O" is 4 / 4=1.0.

[0067] S204: Sampling in the texture map according to the second position information to obtain color information corresponding to each character.

[0068] S205 , rendering and displaying the character segment to be processed according to the color information corresponding to each character.

[0069] Exemplarily, the texture map provided by the artist contains multiple character textures. On this map, each character occupies a specific area, and each area has its own UV coordinate range. After the second position information of each character is determined, each character can be mapped on the texture map, that is, the UV coordinate range of each character on the texture map is determined, and the rendering engine can draw the character's glyph on the screen according to the first position information of each character, and at the same time, sample the texture map according to the UV coordinate of each character on the texture map, that is, extract the color information of each character, and apply the sampled color information to the pixels of the image corresponding to the character, so as to present an image of the character with rich details on the screen. The above color information may include RGBA parameters. RGBA is a color model that represents the color information of four channels: red, green, blue, and alpha. In computer graphics, image processing, and web design, the RGBA color model is widely used because it can accurately describe colors and the transparency of colors. The red channel (red, R) represents the red component of the color, and its value range is usually 0 to 255 (at 8-bit color depth), with 0 representing no red and 255 representing the strongest red. The green channel (green, G) represents the green component of the color, and its value range is also 0 to 255. 0 represents no green and 255 represents the strongest green. The blue channel (blue, B) represents the blue component of the color, and its value range is also 0 to 255. 0 represents no blue and 255 represents the strongest blue. The transparency channel (alpha, A) represents the transparency of the color, and its value range is also 0 to 255 (in some cases it may be a floating point number from 0 to 1), with 0 representing completely transparent and 255 representing completely opaque. The RGBA color model allows you to create and represent almost any color by adjusting the values ​​of these four channels, including pure colors, gradients, and colors with transparency. For example, an RGBA value for pure red might be (255, 0, 0, 255), representing the strongest red, no green and blue, and completely opaque. A semi-transparent red value might be (255, 0, 0, 128), which means the strongest red, no green and blue, but 50% transparency (assuming 25 is completely opaque). In image processing software, the RGBA color model is also commonly used to edit the transparency and color of images. By adjusting the values ​​of each channel, users can create complex visual effects such as shadows, highlights, gradients, and semi-transparency.

[0070] In an optional embodiment, S303 may be implemented through S401 - S402 .

[0071] S401, determining a bounding box of the character according to the attributes of the character;

[0072] S402 determines the position information of the bounding box of the character in the bounding box of the character segment to be processed, and uses the position information of the bounding box of the character in the bounding box of the character segment to be processed as the position information of the bounding box of the character in the character segment to be processed.

[0073] Exemplarily, the attributes of the characters are obtained through the font file, and the attributes of the characters may include the size of the characters, the spacing between characters, the baseline offset of the characters, etc. According to the attributes of the characters, the bounding box of the characters may be determined, and the bounding box of the characters describes the minimum external dimensions of the characters. Among them, the baseline offset of the character refers to the part of the character that exceeds the baseline, and the bounding box of the character includes the baseline offset of the glyph. For example, when the character is a Chinese character, the bounding box of the character describes the minimum external dimensions of the Chinese character, which is usually a square. When the character is a lowercase English letter, some of the strokes of the lowercase English letters will exceed the baseline. The part that exceeds the baseline can be understood as the baseline offset of the character. When determining the bounding box of the character, the baseline offset of the character must be taken into account to ensure that the bounding box of the character completely frames the character in the bounding box, that is, to ensure that the bounding box of the character describes the minimum external dimensions of the character. Figure 4 The baseline offset diagram when the characters provided in the embodiment of the present application are English letters. Figure 4 As shown, the character segment to be processed includes the characters "abcdefg", and line 1 and line 2 can be understood as the baselines of the characters, wherein some strokes of the character "bdf" exceed line 1, and some strokes of the character "g" exceed line 2, so when determining the bounding box of the character "bdfg", the baseline offset of the character "bdfg" needs to be taken into account.

[0074] In an optional embodiment, the above method may further include S501-S502.

[0075] S501, determining the upper left corner coordinates and the lower right corner coordinates of the bounding box of the character and the upper left corner coordinates and the lower right corner coordinates of the bounding box of the character segment to be processed;

[0076] S502: Determine the position information of the bounding box of the character in the bounding box of the character segment to be processed according to the upper left corner coordinates and the lower right corner coordinates of the bounding box of the character and the upper left corner coordinates and the lower right corner coordinates of the bounding box of the character segment to be processed.

[0077] Exemplarily, the upper left pixel coordinates of the bounding box of the character segment to be processed can be used as the origin, and the width and height of the character segment to be processed can be used to determine the lower right pixel coordinates of the bounding box of the character segment to be processed. After the bounding box of each character in the character segment to be processed is determined, the upper left pixel coordinates and lower right pixel coordinates of the bounding box of each character can be determined based on the upper left pixel coordinates, lower right pixel coordinates, and the size of the bounding box of each character. The position information of the bounding box of the character in the bounding box of the character segment to be processed can be obtained through the upper left pixel coordinates and lower right pixel coordinates of the bounding box of each character.

[0078] In an optional embodiment, the above-mentioned normalization processing of the first position information to obtain the second position information of each character in the character segment to be processed may include: normalizing the first position information according to the ratio of the horizontal coordinate of the upper left corner coordinate of the character's bounding box to the width of the bounding box of the character segment to be processed, the ratio of the vertical coordinate of the upper left corner coordinate of the character's bounding box to the height of the bounding box of the character segment to be processed, the ratio of the horizontal coordinate of the lower right corner coordinate of the character's bounding box to the width of the bounding box of the character segment to be processed, and the ratio of the vertical coordinate of the lower right corner coordinate of the character's bounding box to the height of the bounding box of the character segment to be processed, so as to obtain the second position information of each character in the character segment to be processed.

[0079] Exemplarily, after determining the pixel coordinates of the upper left corner and the lower right corner of the bounding box of each character in the character segment to be processed, the first position information of each character in the character segment to be processed can be normalized by calculating the ratio of the horizontal coordinate of the pixel coordinates of the upper left corner of the character's bounding box to the width of the bounding box of the character segment to be processed, the ratio of the vertical coordinate of the pixel coordinates of the upper left corner of the character's bounding box to the height of the bounding box of the character segment to be processed, the ratio of the horizontal coordinate of the pixel coordinates of the lower right corner of the character's bounding box to the width of the bounding box of the character segment to be processed, and the ratio of the vertical coordinate of the pixel coordinates of the lower right corner of the character's bounding box to the height of the bounding box of the character segment to be processed, so as to obtain the second position information of each character in the character segment to be processed.

[0080] For example, in a character segment to be processed, the coordinates of the rectangular area occupied by the image of a character Q in the pixel coordinate system can be expressed as: (x min, y min), (x max, y max), where (x min, y min) represents the upper left pixel coordinates of the rectangular area occupied by the character, that is, the upper left pixel coordinates of the bounding box of the character, and (x_max, y_max) represents the lower right pixel coordinates of the rectangular area occupied by the character, that is, the lower right pixel coordinates of the bounding box of the character. Assuming that the total width of the bounding box of the character segment to be processed is W and the total height is H, the UV coordinates of each character in the bounding box of the character segment to be processed can be calculated by formula (1).

[0081] u min=x_min / W; v_min=y_min / H; u_max=x_max / W; v_max=y_max / H

[0082] Formula (1)

[0083] Among them, (u_min, v_min) is the normalized coordinate of the upper left corner of the rectangular area occupied by the character Q, that is, the normalized coordinate of the upper left corner of the bounding box of the character Q, and (u_max, v_max) is the normalized coordinate of the lower right corner of the rectangular area occupied by the character Q, that is, the normalized coordinate of the lower right corner of the bounding box of the character Q.

[0084] In an optional embodiment, the above S204 can be implemented through S501-S502.

[0085] S501 : Determine a ratio of a width of a bounding box of the to-be-processed character segment to a width of the preset texture map and a ratio of a height of a bounding box of the to-be-processed character segment to a height of the preset texture map.

[0086] S502. Map the second position information to the preset texture map according to the ratio of the width of the bounding box of the character segment to be processed to the width of the preset texture map and the ratio of the height of the bounding box of the character segment to be processed to the height of the preset texture map to obtain the color information of the character segment to be processed.

[0087] Exemplarily, the width and height of the texture map provided by the artist can be obtained, and by determining the ratio of the width of the bounding box of the character segment to be processed to the width of the preset texture map, and the ratio of the bounding box height of the character segment to be processed to the height of the preset texture map, the second position information of each character in the character segment to be processed is mapped to the preset texture map to obtain the color information of the character segment to be processed. Exemplarily, the second position information of each character in the character segment to be processed can be mapped to the preset texture map according to formula (2), and the texture map is sampled according to the UV coordinates of each character to obtain the color information corresponding to each character.

[0088] uvs = uv[0] * float2(uv[3].x / tw, uv[3].y / th) Formula (2)

[0089] Wherein, uv[0] represents the normalized coordinates of each character in the character segment to be processed, uv[3].x represents the width of the bounding box of the character segment to be processed, uv[3].y represents the height of the bounding box of the character segment to be processed, tw represents the width of the preset texture map, and th represents the height of the preset texture map. uvs can represent the UV coordinates corresponding to each character in the character segment to be processed in the preset texture map. According to the UV coordinates corresponding to each character in the character segment to be processed in the preset texture map, the color information of each character in the character segment to be processed can be sampled, such as the RGBA value of each character in the character segment to be processed, and each character in the character segment to be processed is rendered and displayed according to the color information of each character in the character segment to be processed.

[0090] In an optional embodiment, the above-mentioned parsing of the encoding file corresponding to the character segment to be processed to obtain the character segment to be processed may include: parsing the encoding file corresponding to the character segment to be processed according to the escape characters in the encoding file corresponding to the character segment to be processed to obtain the character segment to be processed.

[0091] Exemplarily, escape characters may include line breaks and tabs. The encoded file of the text to be processed is decomposed into individual characters. When each character is parsed, when an escape character is identified, the encoded file of the text to be processed can be processed according to the specific meaning of the escape character. For example, when the encoded file of the character segment to be processed includes line breaks (\n) and tabs (\t), the line break can be identified, the characters after the line break are arranged in a new line, and the line break is deleted. The tab character represents a horizontal tab position, which is usually used to indent or align text. During parsing, the tab character can be identified and the subsequent characters can be horizontally offset to align according to the typesetting rules, and the tab character can be deleted.

[0092] The above is a specific implementation of data processing. In the specific implementation, the model can also be trained in other feasible ways, and the embodiments of the present application are not limited thereto.

[0093] Corresponding to the data processing method provided in the first embodiment of the present application, the second embodiment of the present application further provides a data processing device, such as Figure 5 As shown, the data processing device 500 includes:

[0094] An acquisition unit 501 is used to acquire a character segment to be processed and a preset texture map;

[0095] A determining unit 502 is used to determine first position information of each character in the character segment to be processed, where the first position information is used to represent the pixel coordinates of the character in the character segment to be processed;

[0096] The processing unit 503 is used to perform normalization processing on the first position information to obtain second position information of each character in the character segment to be processed, where the second position information is used to represent the normalized coordinates of the character in the character segment to be processed;

[0097] A sampling unit 504, configured to sample in the texture map according to the second position information to obtain color information corresponding to each of the characters;

[0098] The rendering unit 505 is used to render and display the character segment to be processed according to the color information corresponding to each character.

[0099] Optionally, the acquisition unit 501 is specifically used to: parse the encoding file corresponding to the character segment to be processed to obtain the character segment to be processed.

[0100] Optionally, the acquisition unit 501 is specifically used to: parse the encoding file corresponding to the character segment to be processed according to the escape character in the encoding file corresponding to the character segment to be processed, so as to obtain the character segment to be processed.

[0101] Optionally, the determination unit 502 is specifically used to: select a font file, obtain the attributes of each character in the character segment to be processed from the font file; determine the bounding box of the character segment to be processed based on the attributes of the character; determine the position information of the bounding box of the character in the character segment to be processed, and use the position information of the bounding box of the character in the character segment to be processed as the first position information.

[0102] Optionally, the determination unit 502 is specifically used to: determine the bounding box of the character according to the attributes of the character; determine the position information of the bounding box of the character in the bounding box of the character segment to be processed, and use the position information of the bounding box of the character in the bounding box of the character segment to be processed as the position information of the bounding box of the character in the character segment to be processed.

[0103] Optionally, the determination unit 502 is also used to determine the upper-left corner coordinates and lower-right corner coordinates of the bounding box of the character and the upper-left corner coordinates and lower-right corner coordinates of the bounding box of the character segment to be processed; the determination unit 502 is specifically used to: determine the position information of the bounding box of the character in the bounding box of the character segment to be processed based on the upper-left corner coordinates and lower-right corner coordinates of the bounding box of the character and the upper-left corner coordinates and lower-right corner coordinates of the bounding box of the character segment to be processed.

[0104] Optionally, the processing unit 503 is specifically used to: normalize the first position information according to the ratio of the horizontal coordinate of the upper left corner coordinate of the character's bounding box to the width of the bounding box of the character segment to be processed, the ratio of the vertical coordinate of the upper left corner coordinate of the character's bounding box to the height of the bounding box of the character segment to be processed, the ratio of the horizontal coordinate of the lower right corner coordinate of the character's bounding box to the width of the bounding box of the character segment to be processed, and the ratio of the vertical coordinate of the lower right corner coordinate of the character's bounding box to the height of the bounding box of the character segment to be processed, so as to obtain the second position information of each character in the character segment to be processed.

[0105] Optionally, the sampling unit 504 is specifically used to: determine the ratio of the width of the bounding box of the character segment to be processed to the width of the preset texture map and the ratio of the height of the bounding box of the character segment to be processed to the height of the preset texture map; map the second position information to the preset texture map according to the ratio of the width of the bounding box of the character segment to be processed to the width of the preset texture map and the ratio of the height of the bounding box of the character segment to be processed to the height of the preset texture map to obtain the color information of the character segment to be processed.

[0106] Corresponding to the data processing method provided in the first embodiment of the present application, the third embodiment of the present application also provides an electronic device for data processing.

[0107] like Figure 6 , which is a structural block diagram of an example of an electronic device for data processing provided in an embodiment of the present application.

[0108] In this embodiment, an optional hardware structure of the electronic device 600 can be as follows: Figure 5As shown, it includes: at least one processor 601, at least one memory 602 and at least one communication bus 605; the memory 602 contains a program 603 and data 604.

[0109] The bus 605 may be a communication device for transmitting data between components inside the electronic device 600, such as an internal bus (e.g., a CPU-memory bus, where the processor is a central processing unit, CPU for short), an external bus (e.g., a universal serial bus port, a peripheral component interconnect express port), etc.

[0110] In addition, the electronic device also includes: at least one network interface 606, at least one peripheral interface 607. The network interface 606 provides wired or wireless communication related to an external network 608 (for example, the Internet, an intranet, a local area network, a mobile communication network, etc.); in some embodiments, the network interface 606 may include any number of network interface controllers (NICs), radio frequency (RF) modules, repeaters, transceivers, modems, routers, gateways, any combination of wired network adapters, wireless network adapters, Bluetooth adapters, infrared adapters, near field communication (NFC) adapters, cellular network chips, etc.

[0111] The peripheral interface 607 is used to connect to the peripheral device, and the peripheral device can be the peripheral device 1 ( Figure 6 609), peripheral 2 ( Figure 6 610) and peripheral 3 ( Figure 6 611 in the figure). Peripherals are peripheral devices, which may include but are not limited to cursor control devices (such as mice, touch pads or touch screens), keyboards, displays (such as cathode ray tube displays, liquid crystal displays), displays or light emitting diode displays, video input devices (such as cameras or input interfaces coupled to video files), etc.

[0112] The processor 601 may be a CPU, or an application specific integrated circuit ASIC (Application Specific Integrated Circuit), or one or more integrated circuits configured to implement the embodiments of the present application.

[0113] The memory 602 may include a high-speed RAM (full name: Random Access Memory) memory, and may also include a non-volatile memory, such as at least one disk memory.

[0114] The processor 601 calls the program and data stored in the memory 602 to perform the following steps:

[0115] Get the character segment to be processed and the preset texture map;

[0116] Determine first position information of each character in the character segment to be processed, where the first position information is used to represent the pixel coordinates of the character in the character segment to be processed;

[0117] Normalizing the first position information to obtain second position information of each character in the character segment to be processed, wherein the second position information is used to represent the normalized coordinates of the character in the character segment to be processed;

[0118] Sampling in the texture map according to the second position information to obtain color information corresponding to each of the characters;

[0119] The character segment to be processed is rendered and displayed according to the color information corresponding to each of the characters.

[0120] Corresponding to the data processing method in human-computer interaction provided in the first embodiment of the present application, the fourth embodiment of the present application provides a computer-readable storage medium storing a program of the data processing method in human-computer interaction, the program is executed by a processor to perform the following steps:

[0121] Get the character segment to be processed and the preset texture map;

[0122] Determine first position information of each character in the character segment to be processed, where the first position information is used to represent the pixel coordinates of the character in the character segment to be processed;

[0123] Normalizing the first position information to obtain second position information of each character in the character segment to be processed, wherein the second position information is used to represent the normalized coordinates of the character in the character segment to be processed;

[0124] Sampling in the texture map according to the second position information to obtain color information corresponding to each of the characters;

[0125] The character segment to be processed is rendered and displayed according to the color information corresponding to each of the characters.

[0126] It should be noted that for the detailed description of the devices, electronic devices and computer-readable storage media provided in the second, third and fourth embodiments of the present application, reference can be made to the relevant description of the first embodiment of the present application, and no further details will be given here.

[0127] Although the present application is disclosed as above in the form of a preferred embodiment, it is not intended to limit the present application. Any technical personnel in this field may make possible changes and modifications without departing from the spirit and scope of the present application. Therefore, the scope of protection of the present application shall be based on the scope defined by the claims of the present application.

[0128] In a typical configuration, a node device in a blockchain includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0129] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0130] 1. Computer-readable media includes permanent and non-permanent, removable and non-removable media that can be used to store information by any method or technology. Information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), random access memory (RAM) of other attributes, read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage media or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined in this article, computer-readable media does not include non-transitory media such as modulated data signals and carrier waves.

[0131] 2. Those skilled in the art should understand that the embodiments of the present application can be provided as methods, systems or computer program products. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0132] Although the present application is disclosed as above in the form of a preferred embodiment, it is not intended to limit the present application. Any technical personnel in this field may make possible changes and modifications without departing from the spirit and scope of the present application. Therefore, the scope of protection of the present application shall be based on the scope defined by the claims of the present application.

Claims

1. A data processing method, characterized in that: The method comprises: Get the character segment to be processed and the preset texture map; Determine first position information of each character in the character segment to be processed, where the first position information is used to represent the pixel coordinates of the character in the character segment to be processed; Normalizing the first position information to obtain second position information of each character in the character segment to be processed, wherein the second position information is used to represent the normalized coordinates of the character in the character segment to be processed; Sampling in the texture map according to the second position information to obtain color information corresponding to each of the characters; The character segment to be processed is rendered and displayed according to the color information corresponding to each of the characters.

2. The method according to claim 1, characterized in that The step of obtaining the character segment to be processed includes: The encoding file corresponding to the character segment to be processed is parsed to obtain the character segment to be processed.

3. The method according to claim 2, characterized in that The step of parsing the encoding file corresponding to the character segment to be processed to obtain the character segment to be processed includes: According to the escape characters in the encoding file corresponding to the character segment to be processed, the encoding file corresponding to the character segment to be processed is parsed to obtain the character segment to be processed.

4. The method according to claim 1, characterized in that: The determining of the first position information of each character in the to-be-processed character segment includes: Selecting a font file, and obtaining the attribute of each character in the character segment to be processed from the font file; Determining a bounding box of the character segment to be processed according to the attributes of the character; The position information of the character in the bounding box of the character segment to be processed is determined, and the position information of the character in the bounding box of the character segment to be processed is used as the first position information.

5. The method according to claim 4, characterized in that The determining the position information of the character in the bounding box of the character segment to be processed includes: Determining a bounding box of the character according to the attributes of the character; The position information of the bounding box of the character in the bounding box of the character segment to be processed is determined, and the position information of the bounding box of the character in the bounding box of the character segment to be processed is used as the position information of the bounding box of the character in the character segment to be processed.

6. The method according to claim 5, characterized in that Before determining the position information of the bounding box of the character in the bounding box of the character segment to be processed, the method further includes: Determine the upper left corner coordinates and the lower right corner coordinates of the bounding box of the character and the upper left corner coordinates and the lower right corner coordinates of the bounding box of the character segment to be processed; The determining of the position information of the bounding box of the character in the bounding box of the character segment to be processed includes: According to the upper left corner coordinates and lower right corner coordinates of the bounding box of the character and the upper left corner coordinates and lower right corner coordinates of the bounding box of the character segment to be processed, the position information of the bounding box of the character in the bounding box of the character segment to be processed is determined.

7. The method according to claim 6, characterized in that The normalizing the first position information to obtain the second position information of each character in the character segment to be processed includes: The first position information is normalized according to the ratio of the horizontal coordinate of the upper left corner coordinate of the character's bounding box to the width of the bounding box of the character segment to be processed, the ratio of the vertical coordinate of the upper left corner coordinate of the character's bounding box to the height of the bounding box of the character segment to be processed, the ratio of the horizontal coordinate of the lower right corner coordinate of the character's bounding box to the width of the bounding box of the character segment to be processed, and the ratio of the vertical coordinate of the lower right corner coordinate of the character's bounding box to the height of the bounding box of the character segment to be processed to obtain the second position information of each character in the character segment to be processed.

8. The method according to claim 4, characterized in that The sampling in the texture map according to the second position information to obtain the color information corresponding to each of the characters includes: Determine a ratio of a width of a bounding box of the character segment to be processed to a width of the preset texture map and a ratio of a height of a bounding box of the character segment to be processed to a height of the preset texture map; According to the ratio of the width of the bounding box of the character segment to be processed to the width of the preset texture map and the ratio of the height of the bounding box of the character segment to be processed to the height of the preset texture map, the second position information is mapped to the preset texture map to obtain the color information of the character segment to be processed.

9. A data processing device, characterized in that: The device comprises: An acquisition unit, used for acquiring a character segment to be processed and a preset texture map; A determination unit, used to determine first position information of each character in the character segment to be processed, wherein the first position information is used to represent the pixel coordinates of the character in the character segment to be processed; A processing unit, configured to perform normalization processing on the first position information to obtain second position information of each character in the character segment to be processed, wherein the second position information is used to represent the normalized coordinates of the character in the character segment to be processed; A sampling unit, configured to sample in the texture map according to the second position information to obtain color information corresponding to each of the characters; A rendering unit is used to render and display the character segment to be processed according to the color information corresponding to each character.

10. The device according to claim 9, characterized in that The acquisition unit is specifically used for: The encoding file corresponding to the character segment to be processed is parsed to obtain the character segment to be processed.

11. The device according to claim 10, characterized in that The acquisition unit is specifically used for: According to the escape characters in the encoding file corresponding to the character segment to be processed, the encoding file corresponding to the character segment to be processed is parsed to obtain the character segment to be processed.

12. The device according to claim 9, characterized in that The determining unit is specifically configured to: Selecting a font file, and obtaining the attribute of each character in the character segment to be processed from the font file; Determining a bounding box of the character segment to be processed according to the attributes of the character; The position information of the character in the bounding box of the character segment to be processed is determined, and the position information of the character in the bounding box of the character segment to be processed is used as the first position information.

13. The device according to claim 12, characterized in that The determining unit is specifically configured to: Determining a bounding box of the character according to the attributes of the character; The position information of the bounding box of the character in the bounding box of the character segment to be processed is determined, and the position information of the bounding box of the character in the bounding box of the character segment to be processed is used as the position information of the bounding box of the character in the character segment to be processed.

14. The device according to claim 13, characterized in that The determining unit is further configured to: Determine the upper left corner coordinates and the lower right corner coordinates of the bounding box of the character and the upper left corner coordinates and the lower right corner coordinates of the bounding box of the character segment to be processed; The determining unit is specifically configured to: According to the upper left corner coordinates and lower right corner coordinates of the bounding box of the character and the upper left corner coordinates and lower right corner coordinates of the bounding box of the character segment to be processed, the position information of the bounding box of the character in the bounding box of the character segment to be processed is determined.

15. The device according to claim 14, characterized in that The processing unit is specifically used for: The first position information is normalized according to the ratio of the horizontal coordinate of the upper left corner coordinate of the character's bounding box to the width of the bounding box of the character segment to be processed, the ratio of the vertical coordinate of the upper left corner coordinate of the character's bounding box to the height of the bounding box of the character segment to be processed, the ratio of the horizontal coordinate of the lower right corner coordinate of the character's bounding box to the width of the bounding box of the character segment to be processed, and the ratio of the vertical coordinate of the lower right corner coordinate of the character's bounding box to the height of the bounding box of the character segment to be processed to obtain the second position information of each character in the character segment to be processed.

16. The device according to claim 12, characterized in that The sampling unit is specifically used for: Determine a ratio of a width of a bounding box of the character segment to be processed to a width of the preset texture map and a ratio of a height of a bounding box of the character segment to be processed to a height of the preset texture map; According to the ratio of the width of the bounding box of the character segment to be processed to the width of the preset texture map and the ratio of the height of the bounding box of the character segment to be processed to the height of the preset texture map, the second position information is mapped to the preset texture map to obtain the color information of the character segment to be processed.

17. An electronic device, characterized in that: include: processor; as well as The memory is used to store a data processing program. After the electronic device is powered on and the program is run by the processor, the method according to any one of claims 1 to 8 is executed.

18. A computer-readable storage medium, characterized in that: A data processing program is stored, and the program is run by a processor to execute the method according to any one of claims 1 to 8.

Citation Information

Cited By

  • Data processing method and apparatus, electronic device, and computer-readable storage medium

    WO2026153016A1