Target identification method and device, electronic equipment and readable storage medium
By determining the graphic position of the target location on the display interface and searching for the corresponding byte range in the dot matrix font, the problem of high cost and low accuracy in OCR recognition of dot matrix fonts in the prior art is solved, and efficient and accurate character and pattern recognition is achieved.
Patent Information
- Application Number
- CN202411009521.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-25
- Publication Date
- 2024-11-15
AI Technical Summary
In existing technologies, the cost of recognizing dot matrix characters or patterns using optical character recognition (OCR) is high and the recognition accuracy is low.
By determining the graphic position of the target location on the display interface and searching for the corresponding byte range in the dot matrix font based on that position, the target data can be accurately identified using the dot matrix font database.
It reduced the recognition error rate, improved the recognition accuracy, and lowered the recognition cost.
Smart Images

Figure CN118968527A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of text recognition, and in particular to a target recognition method, device, electronic device and readable storage medium. Background Art
[0002] Dot matrix fonts are a way of presenting characters or patterns through dot matrix arrangement. Each character or pattern is decomposed into a rectangular area, which is divided into several points. Each point can correspond to a pixel. By controlling the brightness of each pixel, different characters or patterns can be formed. The brightness and brightness of the pixel correspond to 1 and 0 in the binary code, respectively. In this way, the dot matrix font corresponding to the above dot matrix is obtained. In other words, the dot matrix font is the coded byte stream corresponding to the character or pattern when it is displayed in a dot matrix.
[0003] Dot matrix fonts are widely used in fire protection and teaching. For example, in the field of fire protection, dot matrix fonts are used to transmit and display fire alarm information such as the specific location of the fire and the fire alarm level. In actual application, the transmitter sends the dot matrix font (for example, a hexadecimal byte stream) to the display end, and the display end decodes the dot matrix font and displays the characters or patterns in the form of a picture. Since multiple characters or patterns are displayed in the form of a whole picture, when the user wants to copy or select a certain character or pattern, it is impossible to identify the character or pattern selected by the user from multiple characters or patterns.
[0004] Currently, in response to operations such as copying by users, the above-mentioned images are converted into editable texts through optical character recognition (OCR), so as to recognize the characters or patterns selected by the user. However, this method is not only costly but also has a low recognition accuracy. Summary of the invention
[0005] In view of this, embodiments of the present application provide a target recognition method, device, electronic device, and readable storage medium, so as to accurately recognize specified characters or patterns when performing operations such as copying.
[0006] The present application provides a target recognition method, which is applied to an electronic device and includes:
[0007] In response to a selection operation on a display interface; the display interface displays a plurality of graphics, the plurality of graphics are obtained by decoding the received dot matrix font; the selection operation is used to select a target position from the display interface;
[0008] Determine the graphic position of the graphic where the target position is located based on the target position;
[0009] Based on the graphic position, find the byte range corresponding to the graphic position in the dot matrix font;
[0010] Based on the byte range, the target data in the byte range is searched in the database corresponding to the dot matrix font.
[0011] As an embodiment, determining the graphic position of the graphic where the target position is located based on the target position includes:
[0012] Determine a coordinate system corresponding to the display interface; the coordinate system includes a horizontal coordinate axis and a vertical coordinate axis, in which n pixels represent the size of a coordinate point; n is greater than or equal to 1;
[0013] The graphic position is determined based on the coordinate point information of the target position in the coordinate system, n pixel points, horizontal unit quantity, and vertical unit quantity; wherein the horizontal unit quantity refers to the size of any graphic along the horizontal coordinate axis, and the vertical unit quantity refers to the size of any graphic along the vertical coordinate axis.
[0014] As an embodiment, the multiple graphics include graphics corresponding to multiple characters; the graphic positions are the character positions.
[0015] As an embodiment, the coordinate system is a rectangular coordinate system, and the boundary point at the upper left corner of the display interface is used as the origin of the rectangular coordinate system;
[0016] The graphic position is represented by (my, nx), where (my, nx) indicates the text position according to the nxth character in the myth text line along the vertical coordinate axis.
[0017] As an example, my is determined by the following steps:
[0018] Performing a first specified operation on the coordinates of the target position on the longitudinal coordinate axis, the longitudinal unit quantity, n pixel points, the longitudinal positioning quantity, and the longitudinal spacing quantity to obtain an operation result; wherein the longitudinal spacing quantity refers to the size between any two adjacent characters along the longitudinal coordinate axis; the longitudinal positioning quantity refers to the size between the first character or the last character along the longitudinal coordinate axis and the boundary of the display interface;
[0019] Round the operation result and add it to the set value to get my;
[0020] nx is determined by the following steps:
[0021] Perform a second specified operation on the coordinates of the target position on the horizontal coordinate axis, the horizontal unit amount, n pixels, the horizontal positioning amount, and the horizontal spacing amount to obtain an operation result; wherein the horizontal spacing amount refers to the size between any two adjacent characters along the horizontal coordinate axis; the horizontal positioning amount refers to the size between the first character or the last character and the border of the display interface along the horizontal coordinate axis;
[0022] Round the operation result and add it to the set value to obtain nx;
[0023] As an embodiment, the byte range is K bytes starting from L;
[0024] L is determined based on the maximum number of characters that can be contained in a preset single text line, the horizontal unit quantity, the vertical unit quantity, and the number of bits corresponding to any byte;
[0025] K is determined based on the horizontal unit quantity, the vertical unit quantity, and the number of bits corresponding to any byte.
[0026] As an embodiment, searching for target data in a byte range in a database corresponding to a dot matrix font based on the byte range includes:
[0027] Determine the Chinese character library corresponding to the dot matrix font;
[0028] Based on the byte range, the target Chinese character within the byte range is searched in the Chinese character library.
[0029] The embodiment of the present application also provides a text recognition device based on dot matrix data, the device comprising:
[0030] The first obtaining module is used to obtain the target pixel point corresponding to the user pointer in the target text displayed on the display device; the target text is the dot matrix data translated from the target text or the target icon based on the specified translation rule;
[0031] The second obtaining module is used to obtain the target byte corresponding to the target pixel point according to the corresponding relationship between the dot matrix data and the pixel points corresponding to the display device;
[0032] The determination module is used to find the target text corresponding to the target byte from the dot matrix data.
[0033] As an embodiment, determining the graphic position of the graphic where the target position is located based on the target position includes:
[0034] Determine a coordinate system corresponding to the display interface; the coordinate system includes a horizontal coordinate axis and a vertical coordinate axis, in which n pixels represent the size of a coordinate point; n is greater than or equal to 1;
[0035] The graphic position is determined based on the coordinate point information of the target position in the coordinate system, n pixel points, horizontal unit quantity, and vertical unit quantity; wherein the horizontal unit quantity refers to the size of any graphic along the horizontal coordinate axis, and the vertical unit quantity refers to the size of any graphic along the vertical coordinate axis.
[0036] As an embodiment, the multiple graphics include graphics corresponding to multiple characters; the graphic positions are the character positions.
[0037] As an embodiment, the coordinate system is a rectangular coordinate system, and the boundary point at the upper left corner of the display interface is used as the origin of the rectangular coordinate system;
[0038] The graphic position is represented by (my, nx), where (my, nx) indicates the text position according to the nxth character in the myth text line along the vertical coordinate axis.
[0039] As an example, my is determined by the following steps:
[0040] Performing a first specified operation on the coordinates of the target position on the longitudinal coordinate axis, the longitudinal unit quantity, n pixel points, the longitudinal positioning quantity, and the longitudinal spacing quantity to obtain an operation result; wherein the longitudinal spacing quantity refers to the size between any two adjacent characters along the longitudinal coordinate axis; the longitudinal positioning quantity refers to the size between the first character or the last character along the longitudinal coordinate axis and the boundary of the display interface;
[0041] Round the operation result and add it to the set value to get my;
[0042] nx is determined by the following steps:
[0043] Perform a second specified operation on the coordinates of the target position on the horizontal coordinate axis, the horizontal unit amount, n pixels, the horizontal positioning amount, and the horizontal spacing amount to obtain an operation result; wherein the horizontal spacing amount refers to the size between any two adjacent characters along the horizontal coordinate axis; the horizontal positioning amount refers to the size between the first character or the last character and the border of the display interface along the horizontal coordinate axis;
[0044] Round the operation result and add it to the set value to obtain nx;
[0045] As an embodiment, the byte range is K bytes starting from L;
[0046] L is determined based on the maximum number of characters that can be contained in a preset single text line, the horizontal unit quantity, the vertical unit quantity, and the number of bits corresponding to any byte;
[0047] K is determined based on the horizontal unit quantity, the vertical unit quantity, and the number of bits corresponding to any byte.
[0048] As an embodiment, searching for target data in a byte range in a database corresponding to a dot matrix font based on the byte range includes:
[0049] Determine the Chinese character library corresponding to the dot matrix font;
[0050] Based on the byte range, the target Chinese character within the byte range is searched in the Chinese character library.
[0051] An embodiment of the present application also provides an electronic device, including: a processor and a memory for storing computer program instructions, and when the computer program instructions are executed by the processor, the processor executes the steps of the above method.
[0052] An embodiment of the present application also provides a machine-readable storage medium, which stores computer program instructions. When the computer program instructions are executed, the steps of the above method can be implemented.
[0053] It can be seen from the above technical scheme that in this embodiment, the received dot matrix font is decoded, multiple graphics are displayed in the display interface, and the position conversion relationship between the position on the display interface and the positions of the multiple graphics displayed when the dot matrix font is displayed is used to determine the graphic position of the graphic corresponding to the selected target position, and based on the graphic position, the byte range of the corresponding graphic position is found in the dot matrix font, and based on the byte range, the target data in the byte range is found in the database corresponding to the dot matrix font. This realizes accurate identification of the character or pattern corresponding to the selected operation when multiple characters or patterns are displayed in the form of pictures.
[0054] Furthermore, this method only requires determining the graphic position of the graphic corresponding to the selected target position, and then finding the byte range of the corresponding graphic position from the dot matrix font, as well as searching for target data through the byte range. Compared with using OCR to recognize the characters and patterns corresponding to the selected operation, this method does not require segmentation and recognition of the characters or images displayed in the picture. This not only reduces recognition errors caused by inaccurate segmentation, significantly improves recognition accuracy, but also reduces the recognition cost of characters and patterns. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] Figure 1 It is a schematic diagram of the structure of the dot matrix of Chinese characters provided in the related technology.
[0056] Figure 2 A flowchart of the method provided in the embodiment of the present application.
[0057] Figure 3 A schematic diagram of a process for determining text position provided in an embodiment of the present application.
[0058] Figure 4 A schematic diagram of the device structure provided in an embodiment of the present application.
[0059] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0060] In order to enable those skilled in the art to better understand the technical solutions provided by the embodiments of the present application and to make the above-mentioned purposes, features and advantages of the embodiments of the present application more obvious and understandable, the technical solutions in the embodiments of the present application are further described in detail below in conjunction with the accompanying drawings.
[0061] Before describing the method provided by this application, the generation of the dot matrix font is first introduced in detail:
[0062] The dot matrix font is obtained from the dot matrix font library, which records each Chinese character and the bytes corresponding to the Chinese character under the dot matrix required by the dot matrix font library. Commonly used dot matrix font libraries include 12-dot Chinese character library (displaying Chinese characters with 12×12 dot matrix), 12-dot ASCII character library (displaying characters with 6×12 dot matrix), 16-dot Chinese character library (displaying Chinese characters with 16×16 dot matrix), 16-dot ASCII character library (displaying characters with 8×16 dot matrix), and 24-dot Chinese character library (displaying Chinese characters with 24×24 dot matrix).
[0063] For example, taking the 16-dot Chinese character library as an example, the 16-dot Chinese character library displays a character in a 16*16 dot matrix. Figure 1 00 01 00 01 00 00 08. As shown in the figure, the word "Han" is placed in a dot matrix of 16*16=256. The white dots in the dot matrix correspond to 1 in the binary code (that is, the pixel corresponding to the dot is in a bright state), and the black dots correspond to 0 in the binary code (that is, the pixel corresponding to the dot is in a dark state). The binary code corresponding to the first column on the left side of the figure is 0000100000100000, 8 bits is one byte, then the column corresponds to 2 bytes, which is expressed as 0x 08 20 in hexadecimal characters, and so on. There are 16 columns in total, so the word "Han" is represented by 32 bytes in total: 0x 08 20 06 20 40 3E 30C0 03 01 40 01 78 02 47 04 40C840 30 40C8 47 04 78 02 00 01 00 01 00 00 08.
[0064] Thus, through the above method, the bytes corresponding to each character can be obtained, that is, a 16-dot matrix Chinese character library is formed.
[0065] Taking the two characters "Chinese characters" as an example, the sender searches for the bytes of the two characters "Chinese characters" from the above 16-dot matrix Chinese character library, and obtains the dot matrix font corresponding to "Chinese characters":
[0066] 0x 08 20 06 20 40 3E 30C0 03 01 40 01 78 02 47 04 40C8 40 30 40C8 4704 78 02 00 01 00 01 00 00 08
[0067] 0x 40 30 40 20 40 24 40 24 40 24 42A4 41 64FE 25 40 26 40 24 40 20 402040 28 40 30 40 00 00 (64 bytes in total).
[0068] The above describes in detail how the transmitter obtains the dot matrix font. The transmitter sends the obtained dot matrix font to the display terminal.
[0069] After the display terminal receives the dot matrix font, that is, after receiving the byte stream, it needs to know the dot matrix font library that the sender queried when generating the dot matrix font, and then decode it in a manner corresponding to the dot matrix font library. For example, if the dot matrix font is obtained by querying the 16-dot matrix Chinese character library, the display terminal decodes and displays it in a manner that matches the 16-dot matrix Chinese character library. How to decode to display text graphics in the display interface will be explained later, so I will not repeat it here.
[0070] The method provided in the embodiment of the present application is described below:
[0071] See also Figure 2 , Figure 2 The method flow diagram of the embodiment of the present application is shown in FIG. The method is applied to an electronic device, which may be a server, and the present application does not specifically limit the application.
[0072] like Figure 2 As shown, the process may include the following steps:
[0073] S201, responding to a selection operation on a display interface; the display interface displays a plurality of graphics, the plurality of graphics being obtained by decoding a received dot matrix font; the selection operation is used to select a target position from the display interface.
[0074] In this embodiment, the above-mentioned graphics can be text such as Chinese characters, English, French, etc., or can be an image such as an image of a cloud, etc.
[0075] In this embodiment, when the user needs to copy or paste a graphic displayed in the display interface, the user uses a mouse or touch screen to perform a selection operation in the display interface, and by detecting the position information of the mouse or touch screen in the display interface, the target position is obtained.
[0076] As an embodiment, the above target position can be reflected by the coordinate point information of the pixel coordinate system corresponding to the display interface of the mouse or touch screen. Here, the pixel coordinate system takes the upper left corner of the display interface as the origin, the x-axis extends to the right, the y-axis extends downward, and one pixel is one coordinate point. The above target position is obtained by detecting the horizontal coordinate and vertical coordinate of the pixel point on the display interface of the mouse or touch screen.
[0077] S202, determining the graphic position of the graphic where the target position is located based on the target position.
[0078] In this embodiment, the graphic position of the graphic where the target position is located is determined, that is, the graphic selected by the selection operation is determined from multiple graphics displayed on the display interface.
[0079] In this embodiment, after obtaining the above-mentioned target position, in order to determine the specific graphics corresponding to the selected operation, the coordinate system corresponding to the display interface is first determined, and the coordinate system includes a horizontal coordinate axis and a vertical coordinate axis. Here, this coordinate system is different from the above-mentioned pixel coordinate system. In this coordinate system, n pixels represent the size of a coordinate point, and n can be 4, 6 or 8, etc., which is not specifically limited in this embodiment. The coordinate point information of the above-mentioned target position in this coordinate system can be converted through the coordinate point information of the target position in the above-mentioned pixel coordinate system. For example, one coordinate point corresponds to 4 pixel points. If the pixel coordinates of the target position are (56, 34), 56 divided by 4 is equal to 14, and 34 divided by 4 is rounded and added with 1 to equal 9, then the coordinates of the target position in this coordinate system are (14, 9).
[0080] The above-mentioned graphic position is determined based on the coordinate point information of the target position in the coordinate system, n pixel points, horizontal unit quantity, and vertical unit quantity; wherein, the horizontal unit quantity refers to the size of any graphic along the horizontal coordinate axis, and the vertical unit quantity refers to the size of any graphic along the vertical coordinate axis. For example, the sending end queries the 16-dot matrix Chinese character library to obtain the dot matrix font, then the horizontal unit quantity is 16 and the vertical unit quantity is also 16.
[0081] In this embodiment, the specific implementation method of determining the position of the graphic will be described in detail later in the text in the form of a specific embodiment, which will not be described here in detail.
[0082] S203, searching for a byte range corresponding to the graphic position in the dot matrix font based on the graphic position.
[0083] In this embodiment, it can be seen from the above description of the dot matrix font that the dot matrix font is essentially a byte stream composed of multiple bytes. By finding the byte range corresponding to the graphic position in the byte stream, it is possible to determine which bytes the selected graphic corresponds to. As an embodiment, the byte range is K bytes starting from L. How to obtain K bytes starting from L will also be explained in the form of a specific embodiment later, and will not be repeated here.
[0084] S204, based on the byte range, searching for target data in a database corresponding to the dot matrix font.
[0085] In this embodiment, after determining the byte range, the dot matrix font library corresponding to the dot matrix font is determined, and the target data in the byte range is found in the dot matrix font library based on the byte range. Here, the target data refers to the character or image selected by the above selection operation. In this embodiment, the specific implementation method of the above step S104 will be described later and will not be repeated here.
[0086] It should be noted that there are many specific implementation methods for determining the database corresponding to the dot matrix font. For example, as an embodiment, when sending the dot matrix font, the sending end carries a tag for representing the dot matrix font library selected when obtaining the dot matrix font. When the display end receives the dot matrix font, it determines the dot matrix font library required for decoding based on the tag. The display end downloads the dot matrix font library and searches for the target data in the byte range in the dot matrix font library.
[0087] As another embodiment, the sending end and the display end pre-negotiate which dot matrix font library to use, the display end pre-configures the dot matrix font library, and searches for target data in a byte range in the dot matrix font library.
[0088] As another embodiment, after determining the byte range, the display end sends the byte range to the sending end. The sending end searches for the target data in the byte range from the dot matrix font library used, and sends the target data to the display end so that the display end obtains the above target data.
[0089] So far, completed Figure 2 The process shown.
[0090] pass Figure 2As can be seen from the process shown, the received dot matrix font is decoded, multiple graphics are displayed in the display interface, and the position conversion relationship between the position on the display interface and the positions of the multiple displayed graphics when the dot matrix font is displayed is used to determine the graphic position of the graphic corresponding to the selected target position, and based on the graphic position, the byte range of the corresponding graphic position is found in the dot matrix font, and based on the byte range, the target data in the byte range is found in the database corresponding to the dot matrix font, which realizes accurate identification of the character or pattern corresponding to the selected operation when multiple characters or patterns are displayed in the form of pictures.
[0091] Furthermore, this method only requires determining the graphic position of the graphic corresponding to the selected target position, and then finding the byte range of the corresponding graphic position from the dot matrix font, as well as searching for target data through the byte range. Compared with using OCR to recognize the characters and patterns corresponding to the selected operation, this method does not require segmentation and recognition of the characters or images displayed in the picture. This not only reduces recognition errors caused by inaccurate segmentation, significantly improves recognition accuracy, but also reduces the recognition cost of characters and patterns.
[0092] For the convenience of description, the specific implementation method of determining the graphic position of the graphic where the target position is located is described below in the form of a specific embodiment:
[0093] In this embodiment, the plurality of graphics include graphics corresponding to a plurality of characters, and the graphic position is the character position. The coordinate system is a rectangular coordinate system, and the rectangular coordinate system takes the boundary point of the upper left corner of the display interface as the origin of the rectangular coordinate system, and the positive direction of the X axis is from left to right, and the negative direction of the Y axis is from top to bottom. The graphic position is represented by (my, nx), and (my, nx) indicates that the character position is the nxth character of the myth character row along the longitudinal coordinate axis. The characters along the horizontal coordinate axis are represented by rows, and the characters along the vertical coordinate axis are represented by columns.
[0094] Since the target position corresponds to the text position, which is related to the specific display mode of the dot matrix font after decoding in the coordinate system, before determining the text position, it is explained as how to display multiple texts on the display interface:
[0095] When the display interface displays text, the following parameters are preset:
[0096] 1. Set the horizontal and vertical unit quantities.
[0097] The horizontal unit refers to the size of any graphic (here refers to text) along the horizontal coordinate axis, recorded as width. The vertical unit refers to the size of any graphic (here refers to text) along the vertical coordinate axis, recorded as height. The horizontal unit and vertical unit are determined based on the dot matrix font library. For example, if a 16-dot matrix Chinese character library is used to obtain a dot matrix font, then width = 16 and height = 16.
[0098] 2. Represent n pixels with piexlSize.
[0099] 3. Set the horizontal and vertical positioning amounts. The horizontal positioning amount refers to the size between the first or last character and the border of the display interface along the horizontal coordinate axis, that is, the left and right margins of the entire output text image and the display interface, which is represented by edgeSpacingForLeftAndRigt.
[0100] The vertical positioning amount refers to the size between the first or last character and the border of the display interface along the vertical coordinate axis; that is, the upper and lower margins of the output entire text image and the display interface, represented by edgeSpacingForTopAndBottom.
[0101] 4. Set the horizontal and vertical spacing.
[0102] The horizontal spacing refers to the size between any two adjacent characters along the horizontal coordinate axis, that is, the distance between characters in the same line of text, expressed as fontSpacing.
[0103] The vertical spacing refers to the size between any two adjacent characters along the vertical coordinate axis, that is, the distance between rows, which is represented by segmentSpacing.
[0104] After the above parameters are set, the pixels occupied by n Chinese characters in each of m rows on the display interface are expressed by the following formula:
[0105] S=m*n*width*height*piexlSize+
[0106] (n-1)*fontSpacing*piexlSize+
[0107] (m-1)*segmentSpacing*piexlSize+
[0108] 2*edgeSpacingForLeftAndRigt*piexlSize+
[0109] 2*edgeSpacingForTopAndBottom*piexlSize
[0110] Among them, width is the horizontal unit, height is the vertical unit, fontSpacing is the horizontal spacing, segmentSpacing is the vertical spacing, edgeSpacingForLeftAndRigt is the horizontal positioning, edgeSpacingForTopAndBottom is the vertical positioning, and piexlSize=n.
[0111] In this embodiment, the display size of the dot matrix font on the display interface is controlled by controlling the number of pixels n, the horizontal unit width, the vertical unit height, the horizontal spacing fontSpacing, the vertical spacing segmentSpacing, the horizontal positioning edgeSpacingForLeftAndRigt, and the vertical positioning edgeSpacingForTopAndBottom corresponding to a coordinate point, so as to improve the applicability of the method. Moreover, even if the above parameters change, the text position corresponding to the target position will not change, so that the effect of text recognition will not be affected by the change of the above parameters, and the text can still be accurately recognized.
[0112] After clarifying how to display multiple texts on the display interface, Figure 3 The method shown is used to determine the text position corresponding to the target position.
[0113] like Figure 3 As shown, the process may include the following steps:
[0114] S301, perform a first specified operation on the coordinates of the target position on the longitudinal coordinate axis, the longitudinal unit value, n pixel points, the longitudinal positioning value, and the longitudinal spacing value to obtain an operation result, round the operation result and add it to the set value to obtain my.
[0115] As an example, the above my is obtained by the following formula:
[0116] my=[(|y|-edgeSpacingForTopAndBottom)
[0117] *piexlSize / (height+segmentSpacing)*piexlSize)]+1
[0118] Among them, y is the coordinate of the target position on the vertical axis,
[0119] edgeSpacingForTopAndBottom is the vertical positioning amount,
[0120] height is the vertical unit, segmentSpacing is the vertical spacing, piexlSize = n,
[0121] [] indicates a rounding operation.
[0122] In this embodiment, the rounding operation is rounding down. For example, if (|y|-edgeSpacingForTopAndBottom)
[0123] *piexlSize / (height+segmentSpacing)*piexlSize) is 3.4 or 3.6, then round it to 3.
[0124] S302, performing a second specified operation on the coordinates of the target position on the horizontal coordinate axis, the horizontal unit value, n pixels, the horizontal positioning value, and the horizontal spacing value, obtaining the operation result, rounding the operation result and adding it to the set value to obtain nx.
[0125] As an embodiment, the above nx is obtained by the following formula:
[0126] nx=[(x-edgeSpacingForleftAndright)*piexlSize / (width+fontSpacing)
[0127] *piexlSize]+1;
[0128] Among them, x is the coordinate of the target position on the horizontal coordinate axis,
[0129] edgeSpacingForleftAndright is the horizontal positioning amount,
[0130] width is the horizontal unit, fontSpacing is the horizontal spacing, piexlSize=n,
[0131] [] indicates a rounding operation.
[0132] Here, the rounding operation is rounding down.
[0133] As an embodiment, after determining that the text position of the target position is located at the nxth word in the myth text line, the specific implementation method of determining the byte range is: determine L based on the maximum number of characters that a single text line can accommodate, the horizontal unit quantity, the vertical unit quantity, and the number of bits corresponding to any byte, and determine it based on the horizontal unit quantity, the vertical unit quantity, and the number of bits corresponding to any byte.
[0134] For example, the byte range is from the (my-1)*width*(height / 8)*n+(nx-1)*width(height / 8)+1th byte to the (my-1)*width*(height / 8)*n+(nx-1)*width(height / 8)+width*(height / 8)th byte in the braille template.
[0135] Here, n is the maximum number of characters that can be contained in a single text line.
[0136] In this embodiment, the byte range is obtained in the above manner, and then the target Chinese characters within the byte range are searched from the Chinese character library corresponding to the dot matrix font. The obtained target Chinese characters can be used for copying or pasting.
[0137] The method provided in the embodiment of the present application is described above. The device provided in the embodiment of the present application is described below:
[0138] See also Figure 4 , Figure 4 This is a structural diagram of a device provided in an embodiment of the present application. The device is applied to electronic devices, such as Figure 4 As shown, the device may include: a response module 401 , a first determination module 402 , a second determination module 403 , and a third determination module 404 .
[0139] The response module 401 is used to respond to the selection operation on the display interface; the display interface displays multiple graphics, and the multiple graphics are obtained by decoding the received dot matrix font; the selection operation is used to select a target position from the display interface;
[0140] A first determining module 402, configured to determine a graphic position of a graphic where a target position is located based on the target position;
[0141] A second determination module 403 is used to find a byte range corresponding to the graphic position in the dot matrix font based on the graphic position;
[0142] The third determining module 404 is used to search for target data in the byte range in the database corresponding to the dot matrix font based on the byte range.
[0143] In this embodiment, the received dot matrix font is decoded, and multiple graphics are displayed on the display interface. The position conversion relationship between the position on the display interface when the dot matrix font is displayed and the positions of the multiple displayed graphics is used to determine the graphic position of the graphic corresponding to the selected target position, and based on the graphic position, the byte range of the corresponding graphic position is found in the dot matrix font, and based on the byte range, the target data within the byte range is found in the database corresponding to the dot matrix font. This enables accurate identification of the character or pattern corresponding to the selected operation when multiple characters or patterns are displayed in the form of pictures.
[0144] Furthermore, this method only requires determining the graphic position of the graphic corresponding to the selected target position, and then finding the byte range of the corresponding graphic position from the dot matrix font, as well as searching for target data through the byte range. Compared with using OCR to recognize the characters and patterns corresponding to the selected operation, this method does not require segmentation and recognition of the characters or images displayed in the picture. This not only reduces recognition errors caused by inaccurate segmentation, significantly improves recognition accuracy, but also reduces the recognition cost of characters and patterns.
[0145] As an embodiment, determining the graphic position of the graphic where the target position is located based on the target position includes:
[0146] Determine a coordinate system corresponding to the display interface; the coordinate system includes a horizontal coordinate axis and a vertical coordinate axis, in which n pixels represent the size of a coordinate point; n is greater than or equal to 1;
[0147] The graphic position is determined based on the coordinate point information of the target position in the coordinate system, n pixel points, horizontal unit quantity, and vertical unit quantity; wherein the horizontal unit quantity refers to the size of any graphic along the horizontal coordinate axis, and the vertical unit quantity refers to the size of any graphic along the vertical coordinate axis.
[0148] As an embodiment, the multiple graphics include graphics corresponding to multiple characters; the graphic positions are the character positions.
[0149] As an embodiment, the coordinate system is a rectangular coordinate system, and the boundary point at the upper left corner of the display interface is used as the origin of the rectangular coordinate system;
[0150] The graphic position is represented by (my, nx), where (my, nx) indicates the text position according to the nxth character in the myth text line along the vertical coordinate axis.
[0151] As an example, my is determined by the following steps:
[0152] Performing a first specified operation on the coordinates of the target position on the longitudinal coordinate axis, the longitudinal unit quantity, n pixel points, the longitudinal positioning quantity, and the longitudinal spacing quantity to obtain an operation result; wherein the longitudinal spacing quantity refers to the size between any two adjacent characters along the longitudinal coordinate axis; the longitudinal positioning quantity refers to the size between the first character or the last character along the longitudinal coordinate axis and the boundary of the display interface;
[0153] Round the operation result and add it to the set value to get my;
[0154] nx is determined by the following steps:
[0155] Perform a second specified operation on the coordinates of the target position on the horizontal coordinate axis, the horizontal unit amount, n pixels, the horizontal positioning amount, and the horizontal spacing amount to obtain an operation result; wherein the horizontal spacing amount refers to the size between any two adjacent characters along the horizontal coordinate axis; the horizontal positioning amount refers to the size between the first character or the last character and the border of the display interface along the horizontal coordinate axis;
[0156] Round the operation result and add it to the set value to obtain nx;
[0157] As an embodiment, the byte range is K bytes starting from L;
[0158] L is determined based on the maximum number of characters that can be contained in a preset single text line, the horizontal unit quantity, the vertical unit quantity, and the number of bits corresponding to any byte;
[0159] K is determined based on the horizontal unit quantity, the vertical unit quantity, and the number of bits corresponding to any byte.
[0160] As an embodiment, searching for target data in a byte range in a database corresponding to a dot matrix font based on the byte range includes:
[0161] Determine the Chinese character library corresponding to the dot matrix font;
[0162] Based on the byte range, the target Chinese character within the byte range is searched in the Chinese character library.
[0163] So far, completed Figure 4 Structural description of the device shown.
[0164] See also Figure 5 , Figure 5 This is a structural diagram of an electronic device provided in an embodiment of the present application. Figure 5 As shown, the hardware structure may include: a processor and a machine-readable storage medium, the machine-readable storage medium storing machine-executable instructions that can be executed by the processor; the processor is used to execute the machine-executable instructions to implement the method disclosed in the above example of this application.
[0165] Based on the same application concept as the above method, an embodiment of the present application also provides a machine-readable storage medium, on which a number of computer instructions are stored. When the computer instructions are executed by a processor, the method disclosed in the above example of the present application can be implemented.
[0166] Exemplarily, the above-mentioned machine-readable storage medium can be any electronic, magnetic, optical or other physical storage device that can contain or store information, such as executable instructions, data, etc. For example, the machine-readable storage medium can be: RAM (Radom Access Memory), volatile memory, non-volatile memory, flash memory, storage drive (such as hard disk drive), solid state drive, any type of storage disk (such as CD, DVD, etc.), or similar storage medium, or a combination thereof.
[0167] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.
Claims
1. A target recognition method, It is characterized in that The method is applied to an electronic device, and the method comprises: In response to a selection operation on a display interface; the display interface displays a plurality of graphics, the plurality of graphics being obtained by decoding a received dot matrix font; the selection operation is used to select a target position from the display interface; Determine the graphic position of the graphic where the target position is located based on the target position; Based on the graphic position, searching the dot matrix font for a byte range corresponding to the graphic position; Based on the byte range, the target data in the byte range is searched in the database corresponding to the dot matrix font.
2. The method according to claim 1, It is characterized in that Determining the graphic position of the graphic where the target position is located based on the target position includes: Determine a coordinate system corresponding to the display interface; the coordinate system includes a horizontal coordinate axis and a vertical coordinate axis, in which n pixels represent the size of a coordinate point; n is greater than or equal to 1; The graphic position is determined based on the coordinate point information of the target position in the coordinate system, the n pixel points, the horizontal unit quantity, and the vertical unit quantity; wherein the horizontal unit quantity refers to the size of any graphic along the horizontal coordinate axis, and the vertical unit quantity refers to the size of any graphic along the vertical coordinate axis.
3. The method according to claim 2, It is characterized in that The multiple graphics include graphics corresponding to multiple characters; the graphic positions are character positions.
4. The method according to claim 3, It is characterized in that The coordinate system is a rectangular coordinate system, and the boundary point at the upper left corner of the display interface is taken as the origin of the rectangular coordinate system; The graphic position is represented by (my, nx), where (my, nx) indicates that the text position is the nxth character in the myth text row along the vertical coordinate axis.
5. The method according to claim 4, It is characterized in that The my is determined by the following steps: Performing a first specified operation on the coordinates of the target position on the longitudinal coordinate axis, the longitudinal unit amount, the n pixel points, the longitudinal positioning amount, and the longitudinal spacing amount to obtain an operation result; wherein the longitudinal spacing amount refers to the size between any two adjacent characters along the longitudinal coordinate axis; the longitudinal positioning amount refers to the size between the first character or the last character along the longitudinal coordinate axis and the boundary of the display interface; Rounding the operation result and adding it to the set value to obtain my; The nx is determined by the following steps: Performing a second specified operation on the coordinates of the target position on the horizontal coordinate axis, the horizontal unit amount, the n pixel points, the horizontal positioning amount, and the horizontal spacing amount to obtain an operation result; wherein the horizontal spacing amount refers to the size between any two adjacent characters along the horizontal coordinate axis; the horizontal positioning amount refers to the size between the first character or the last character along the horizontal coordinate axis and the boundary of the display interface; The operation result is rounded and added to a set value to obtain nx.
6. The method according to claim 4, It is characterized in that The byte range is K bytes starting from L; The L is determined according to the maximum number of characters that can be contained in a preset single character line, the horizontal unit quantity, the vertical unit quantity, and the number of bits corresponding to any byte; The K is determined according to the horizontal unit quantity, the vertical unit quantity, and the number of bits corresponding to any byte.
7. The method according to claim 3, It is characterized in that The step of searching the database corresponding to the dot matrix font for target data in the byte range based on the byte range includes: Determine the Chinese character library corresponding to the dot matrix font; Based on the byte range, a target Chinese character within the byte range is searched in the Chinese character library.
8. A target recognition device, It is characterized in that The device is applied to electronic equipment, and comprises: A response module, used to respond to a selection operation on a display interface; the display interface displays a plurality of graphics, the plurality of graphics are obtained by decoding the received dot matrix font; the selection operation is used to select a target position from the display interface; A first determining module, configured to determine a graphic position of a graphic where the target position is located based on the target position; A second determination module, configured to search the dot matrix font for a byte range corresponding to the graphic position based on the graphic position; The third determining module is used to search for target data in the byte range in the database corresponding to the dot matrix font based on the byte range.
9. The device according to claim 8, It is characterized in that Determining the graphic position of the graphic where the target position is located based on the target position includes: Determine a coordinate system corresponding to the display interface; the coordinate system includes a horizontal coordinate axis and a vertical coordinate axis, in which n pixels represent the size of a coordinate point; n is greater than or equal to 1; Determine the graphic position based on the coordinate point information of the target position in the coordinate system, the n pixel points, the horizontal unit quantity, and the vertical unit quantity; wherein the horizontal unit quantity refers to the size of any graphic along the horizontal coordinate axis, and the vertical unit quantity refers to the size of any graphic along the vertical coordinate axis; And / or, the plurality of graphics include graphics corresponding to a plurality of characters; the graphic positions are character positions; and / or, The coordinate system is a rectangular coordinate system, and the boundary point at the upper left corner of the display interface is taken as the origin of the rectangular coordinate system; The graphic position is represented by (my, nx), wherein (my, nx) indicates the text position according to the nxth character of the myth text line along the longitudinal coordinate axis; And / or, my is determined by the following steps: Performing a first specified operation on the coordinates of the target position on the longitudinal coordinate axis, the longitudinal unit amount, the n pixel points, the longitudinal positioning amount, and the longitudinal spacing amount to obtain an operation result; wherein the longitudinal spacing amount refers to the size between any two adjacent characters along the longitudinal coordinate axis; the longitudinal positioning amount refers to the size between the first character or the last character along the longitudinal coordinate axis and the boundary of the display interface; Rounding the operation result and adding it to the set value to obtain my; The nx is determined by the following steps: Performing a second specified operation on the coordinates of the target position on the horizontal coordinate axis, the horizontal unit amount, the n pixel points, the horizontal positioning amount, and the horizontal spacing amount to obtain an operation result; wherein the horizontal spacing amount refers to the size between any two adjacent characters along the horizontal coordinate axis; the horizontal positioning amount refers to the size between the first character or the last character along the horizontal coordinate axis and the boundary of the display interface; Rounding the operation result and adding it to a set value to obtain nx; And / or, the byte range is K bytes starting from L; The L is determined according to the maximum number of characters that can be contained in a preset single character line, the horizontal unit quantity, the vertical unit quantity, and the number of bits corresponding to any byte; The K is determined according to the horizontal unit quantity, the vertical unit quantity, and the number of bits corresponding to any byte; And / or, searching the database corresponding to the dot matrix font for target data in the byte range based on the byte range includes: Determine the Chinese character library corresponding to the dot matrix font; Based on the byte range, a target Chinese character within the byte range is searched in the Chinese character library.
10. An electronic device, It is characterized in that include: processor; as well as A memory, in which computer program instructions are stored, and when the computer program instructions are executed by the processor, the processor is caused to perform the steps of the method according to any one of claims 1 to 7.
11. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores computer program instructions, which, when executed by a processor, enable the processor to perform the steps of the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Mobile terminal screen word-selecting method, system and mobile terminal
CN101266534A
Dot matrix font library processing method
CN103186507A
Method and device for tracking equipment
CN106354516A
Commodity information representation method and system based on dot matrix image and application of commodity information representation method and system
CN115700590A
Text Operations In A Bitmap-Based Document
US20130125038A1
