Handwritten stroke recognition method and electronic device
By analyzing the positional relationships and writing order of strokes, strokes are grouped into different groups, solving the problem of inaccurate stroke selection in electronic devices and achieving accurate stroke selection and improving the success rate of column division.
Patent Information
- Application Number
- PCT/CN2025/097734
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-06-29
- Filing Date
- 2025-05-28
- Publication Date
- 2026-01-02
AI Technical Summary
When users take handwritten notes on electronic devices, it is difficult to accurately select the content of the notes, especially when the distance between words is close or the strokes intersect, making it impossible to select word by word. Furthermore, column recognition errors can lead to a chaotic selection order.
By analyzing the positional relationships and writing order of strokes, strokes are grouped into different stroke groups, overlapping areas and writing intervals are identified, ensuring that users can accurately select target strokes or patterns.
It enables accurate selection of individual characters and complete patterns even when strokes intersect or are close together, avoiding issues of missed or multiple selections and improving the success rate of column division.
Smart Images

Figure CN2025097734_02012026_PF_FP_ABST
Abstract
Description
A handwriting stroke recognition method and electronic device
[0001] The present application claims priority to the Chinese patent application No. 202410875199.6, filed on June 29, 2024, with the State Intellectual Property Office of China, and entitled "A handwriting stroke recognition method and electronic device", the whole content of which is incorporated herein by reference. TECHNICAL FIELD
[0002] The present application relates to the field of electronic devices, and more particularly, to a handwriting stroke recognition method and electronic device. BACKGROUND
[0003] With the advancement of technology, more and more users will use electronic devices to record notes by handwriting in scenarios such as meetings and classes. When recording notes, users often need to select note content for operations such as deletion, movement, and copying, which can include text and patterns. Currently, when selecting note content, users may encounter problems such as the following: 1. When the distance between two characters is close or there is stroke intersection, it may not be possible to select character by character; 2. When selecting a pattern, strokes may be selected or missed; 3. When users record notes in a columned manner, the columns may not be correctly identified, resulting in incorrect selection order when selecting note content. Therefore, how to quickly and accurately analyze notes so that users can accurately select the desired note content has become a technical problem to be solved. SUMMARY
[0004] The present application provides a handwriting stroke recognition method and electronic device, which can quickly and accurately analyze strokes so that users can accurately select the desired strokes when selecting strokes.
[0005] In a first aspect, a handwriting stroke recognition method is provided, which includes: displaying first content, the first content including a plurality of strokes; grouping the plurality of strokes according to the positional relationship of the plurality of strokes and the writing order of the plurality of strokes.
[0006] In the present application, the strokes can be grouped according to the positional relationship between the strokes and the writing order of the strokes. The strokes in the same stroke group can be strokes of the same pattern, strokes of the same character, or strokes in the same column, so that when selecting text and patterns, users will not miss, select too much, or fail to select a single character, and the column selection will not be incorrect.
[0007] With reference to the first aspect, in some implementations of the first aspect, the first content includes a first character and a second character, and the grouping the strokes according to the position relationship of the strokes and the writing order of the strokes includes: when a first rectangular frame corresponding to the first character and a second rectangular frame corresponding to the second character have a first overlapping area, determining the attribution of one or more strokes in the first overlapping area according to the writing order of the strokes of the first character and the second character and the position relationship of the one or more strokes and the first rectangular frame and the second rectangular frame.
[0008] With reference to the first aspect, in some implementations of the first aspect, the determining the attribution of the one or more strokes according to the writing order of the strokes of the first character and the second character and the position relationship of the one or more strokes and the first rectangular frame and the second rectangular frame includes: determining coordinates of the first rectangular frame, the second rectangular frame and the one or more strokes according to the position relationship of the first character and the second character; and determining the attribution of the one or more strokes according to a distance relationship between the coordinates of the first rectangular frame, the second rectangular frame and the one or more strokes and the writing order of the strokes of the first character and the second character.
[0009] In the embodiments of the present application, the attribution of the strokes in the overlapping area can be determined according to the writing order of the characters and the position relationship between the strokes in the overlapping area and the characters, so that the user can select a single character even when the adjacent characters are close to each other or the strokes overlap.
[0010] With reference to the first aspect, in some implementations of the first aspect, the first character and the second character are distributed left and right, the first character is on the left side of the second character, and the one or more strokes include a first stroke, and the determining the coordinates of the first rectangular frame, the second rectangular frame and the one or more strokes according to the position relationship of the first character and the second character includes: determining a first center horizontal coordinate of the first rectangular frame, a second center horizontal coordinate of the second rectangular frame and a first average horizontal coordinate of the first stroke.
[0011] With reference to the first aspect, in some implementations of the first aspect, the determining the attribution of the one or more strokes according to the distance relationship between the coordinates of the first rectangular frame, the second rectangular frame and the one or more strokes and the writing order of the strokes of the first character and the second character comprises: when the distance between the first average horizontal coordinate and the horizontal coordinate of the right side frame of the first rectangular frame is greater than the distance between the first average horizontal coordinate and the horizontal coordinate of the left side frame of the second rectangular frame, determining that the first stroke is attributed to the second character; or when the distance between the first average horizontal coordinate and the horizontal coordinate of the right side frame of the first rectangular frame is less than the distance between the first average horizontal coordinate and the horizontal coordinate of the left side frame of the second rectangular frame, and the previous stroke of the first stroke is attributed to the second character, determining that the first stroke is attributed to the second character; or when the distance between the first average horizontal coordinate and the horizontal coordinate of the right side frame of the first rectangular frame is less than the distance between the first average horizontal coordinate and the horizontal coordinate of the left side frame of the second rectangular frame, and the previous stroke of the first stroke is not attributed to the second character, determining that the first stroke is attributed to the first character.
[0012] With reference to the first aspect, in some implementations of the first aspect, the first character and the second character are left-right distributed, the first character is on the left side of the second character, the horizontal length of the first rectangular frame and / or the second rectangular frame is greater than a first threshold, the one or more strokes comprise a first stroke, and the determining the coordinates of the first rectangular frame, the second rectangular frame and the one or more strokes according to the positional relationship of the first character and the second character comprises: determining the horizontal coordinate of the right side frame of the first rectangular frame, the horizontal coordinate of the left side frame of the second rectangular frame and the first average horizontal coordinate of the first stroke.
[0013] With reference to the first aspect, in some implementations of the first aspect, the determining the attribution of the one or more strokes according to the distance relationship between the coordinates of the first rectangular frame, the second rectangular frame and the one or more strokes and the writing order of the strokes of the first character and the second character comprises: when the distance between the first average horizontal coordinate and the horizontal coordinate of the right side frame of the first rectangular frame is greater than the distance between the first average horizontal coordinate and the horizontal coordinate of the left side frame of the second rectangular frame, determining that the first stroke is attributed to the second character; or when the distance between the first average horizontal coordinate and the horizontal coordinate of the right side frame of the first rectangular frame is less than the distance between the first average horizontal coordinate and the horizontal coordinate of the left side frame of the second rectangular frame, and the previous stroke of the first stroke is attributed to the second character, determining that the first stroke is attributed to the second character; or when the distance between the first average horizontal coordinate and the horizontal coordinate of the right side frame of the first rectangular frame is less than the distance between the first average horizontal coordinate and the horizontal coordinate of the left side frame of the second rectangular frame, and the previous stroke of the first stroke is not attributed to the second character, determining that the first stroke is attributed to the first character.
[0014] With reference to the first aspect, in some implementations of the first aspect, the first character and the second character are distributed above and below, the first character is above the second character, and the one or more strokes include a first stroke. The determining the coordinates of the first rectangular frame, the second rectangular frame, and the one or more strokes according to the positional relationship between the first character and the second character includes determining a first central vertical coordinate of the first rectangular frame, a second central vertical coordinate of the second rectangular frame, and a first average vertical coordinate of the first stroke.
[0015] With reference to the first aspect, in some implementations of the first aspect, the determining the attribution of the one or more strokes according to the distance relationship between the coordinates of the first rectangular frame, the second rectangular frame, and the one or more strokes and the writing order of the strokes of the first character and the second character includes: when a distance between the first average vertical coordinate and the first central vertical coordinate is greater than a distance between the first average vertical coordinate and the second central vertical coordinate, determining that the first stroke is attributed to the second character; or when the distance between the first average vertical coordinate and the first central vertical coordinate is less than the distance between the first average vertical coordinate and the second central vertical coordinate, and a previous stroke of the first stroke is attributed to the second character, determining that the first stroke is attributed to the second character; or when the distance between the first average vertical coordinate and the first central vertical coordinate is less than the distance between the first average vertical coordinate and the second central vertical coordinate, and the previous stroke of the first stroke is not attributed to the second character, determining that the first stroke is attributed to the first character.
[0016] With reference to the first aspect, in some implementations of the first aspect, the first character and the second character are distributed diagonally, the first character is below and left of the second character or above and left of the second character, and the one or more strokes include a first stroke. The determining the coordinates of the first rectangular frame, the second rectangular frame, and the one or more strokes according to the positional relationship between the first character and the second character includes determining a first central coordinate of the first rectangular frame, a second central coordinate of the second rectangular frame, and a first average coordinate of the first stroke.
[0017] With reference to the first aspect, in some implementations of the first aspect, the determining the attribution of the one or more strokes according to the distance relationship between the coordinates of the first rectangular frame, the second rectangular frame and the one or more strokes and the writing order of the strokes of the first character and the second character comprises: when the distance between the first average coordinate and the first center coordinate is greater than the distance between the first average coordinate and the second center coordinate, determining that the first stroke is attributed to the second character; or when the distance between the first average coordinate and the first center coordinate is less than the distance between the first average coordinate and the second center coordinate and the previous strokes of the first stroke are attributed to the second character, determining that the first stroke is attributed to the second character; or when the distance between the first average coordinate and the first center coordinate is less than the distance between the first average coordinate and the second center coordinate and the previous strokes of the first stroke are not attributed to the second character, determining that the first stroke is attributed to the first character.
[0018] With reference to the first aspect, in some implementations of the first aspect, the first content comprises one or more patterns, and the method further comprises: identifying N strokes corresponding to the one or more patterns, N being an integer greater than or equal to 2; and grouping the plurality of strokes according to the positional relationship of the plurality of strokes and the writing order of the plurality of strokes comprises: dividing the N strokes into M stroke groups according to the positional relationship between the N strokes, wherein the distance between any two strokes in the M stroke groups is greater than a second threshold, N is greater than or equal to M and M is an integer.
[0019] In the embodiments of the present application, the electronic device can group the strokes according to the distance relationship between the strokes of the pattern, so that the user can quickly select a complete pattern when selecting the pattern.
[0020] With reference to the first aspect, in some implementations of the first aspect, the method further comprises: dividing the first stroke group into Q stroke groups according to the writing interval of the P strokes, wherein the M stroke groups comprise the first stroke group, the first stroke group comprises the P strokes, the writing interval between any two adjacent stroke groups in the Q stroke groups is greater than a third threshold, and Q is an integer greater than or equal to 1.
[0021] In the embodiments of the present application, the electronic device can first group the strokes of the pattern according to the distance relationship between the strokes, so that the strokes with a small distance can be attributed to the same stroke group, and then the electronic device can further divide a stroke group into a plurality of new stroke groups according to the writing interval of the strokes in the stroke group, thereby refining the granularity of the grouping and avoiding the problem of multiple selection of strokes when the user selects the pattern.
[0022] With reference to the first aspect, in some implementations of the first aspect, the method further includes: aggregating the Q stroke groups into W stroke groups according to writing intervals of the Q stroke groups and distance relationships between the Q stroke groups, wherein two stroke groups of the Q stroke groups that are adjacent in writing order in a plurality of stroke groups aggregated into a same stroke group have a writing interval less than or equal to a fourth threshold and a distance less than or equal to a fifth threshold, Q≥W≥1 and P is an integer.
[0023] In the embodiments of the present application, the electronic device can first group the strokes of the pattern according to the distance relationships between the strokes, so that the strokes with close distances can belong to the same stroke group, and then can further divide a stroke group into a plurality of new stroke groups according to the writing intervals of the strokes in the stroke group, and then can further aggregate the stroke groups according to the writing intervals and the distance relationships between the stroke groups, thereby avoiding the problem of missing strokes caused by the user when selecting the pattern.
[0024] With reference to the first aspect, in some implementations of the first aspect, the distance between any two stroke groups of the Q stroke groups is greater than a sixth threshold, and the sixth threshold is less than the second threshold.
[0025] With reference to the first aspect, in some implementations of the first aspect, the writing interval is a corresponding time interval between two strokes adjacent in writing order.
[0026] With reference to the first aspect, in some implementations of the first aspect, the method further includes: identifying a field and / or a pattern in the first content and grouping the plurality of strokes according to the position relationship of the plurality of strokes and the writing order of the plurality of strokes, including: dividing the first content into one or more area blocks according to the position relationship and the writing order of the field and / or the pattern; and columnizing the first content according to the position relationship of the one or more area blocks to obtain one or more columns.
[0027] In the embodiments of the present application, the electronic device can divide the content into one or more area blocks, and the strokes of the field and / or the pattern in each area block satisfy the writing order from left to right and from top to bottom, and then columnize the content according to the position relationship between the area blocks, thereby improving the success rate of columnization and ensuring that the user can select the content column by column in the manner from left to right and from top to bottom.
[0028] With reference to the first aspect, in some implementations of the first aspect, the method further includes: sorting the area blocks in the first column according to the position relationship between the area blocks in the first column. Wherein the one or more categories include the first column.
[0029] With reference to the first aspect, in some implementations of the first aspect, the method further includes: sorting the fields and / or patterns in the first region block according to the positional relationship of the fields and / or patterns in the first region block, wherein the one or more region blocks include the first region block.
[0030] With reference to the first aspect, in some implementations of the first aspect, the fields and / or patterns in the first region block satisfy an order from top to bottom and / or from left to right.
[0031] The second aspect provides a handwriting stroke recognition method, which includes: displaying first content, the first content including first text and second text; when a first rectangular frame corresponding to the first text and a second rectangular frame corresponding to the second text have a first overlapping area, determining the attribution of one or more strokes according to the writing order of the strokes of the first text and the second text and the positional relationship between the one or more strokes and the first rectangular frame and the second rectangular frame in the first overlapping area.
[0032] The third aspect provides a handwriting stroke recognition method, which includes: identifying N strokes corresponding to one or more patterns in first content; dividing the N strokes into M stroke groups according to the distance relationship of the N strokes; dividing the M stroke groups into Q stroke groups according to the writing interval of the N strokes; and aggregating the Q stroke groups into P stroke groups according to the writing interval of the Q stroke groups and the distance relationship of the Q stroke groups.
[0033] The fourth aspect provides a handwriting stroke recognition method, which includes: identifying fields and / or patterns in first stroke content; dividing the first stroke content into multiple region blocks according to the positional relationship and writing order of the fields and / or patterns; and columnating the first stroke content according to the positional relationship of the multiple region blocks.
[0034] The fifth aspect provides an electronic device, which includes one or more processors; one or more memories; and one or more computer programs stored in the one or more memories, the one or more computer programs including instructions that, when executed by the one or more processors, cause the above aspect or any possible implementation of the above aspect to be performed.
[0035] The sixth aspect provides a computer-readable storage medium, which includes a computer program or instructions, when the computer program or instructions are run on a computer, causing the method of the first aspect and any possible implementation of the first aspect to be performed.
[0036] In a seventh aspect, a computer program product is provided, which comprises a computer program or instructions, which when run on a computer, cause the method of the first aspect and any possible implementation of the first aspect to be performed.
[0037] In an eighth aspect, a computer program is provided, which when run on a computer, causes the method in the first aspect and any possible implementation thereof to be performed.
[0038] In a ninth aspect, an electronic device is provided, which comprises the modules / units for performing the method of the above aspect or any possible implementation of the above aspect; these modules / units can be implemented by hardware, or by hardware executing corresponding software.
[0039] The beneficial effects of the second aspect to the ninth aspect can be found in the beneficial effects of the first aspect, and will not be repeated here. BRIEF DESCRIPTION OF DRAWINGS
[0040] FIG. 1 is a structural schematic diagram of an electronic device provided by an embodiment of the present application.
[0041] FIG. 2 is a software structural block diagram of an electronic device provided by an embodiment of the present application.
[0042] FIG. 3 is a set of GUIs provided by an embodiment of the present application.
[0043] FIG. 4 is a schematic flowchart of a handwriting stroke recognition method provided by an embodiment of the present application.
[0044] FIG. 5 is a set of GUIs provided by an embodiment of the present application.
[0045] FIG. 6 is a schematic flowchart of a handwriting stroke recognition method provided by an embodiment of the present application.
[0046] FIG. 7 is a schematic diagram of the positional relationship of adjacent characters provided by an embodiment of the present application.
[0047] FIG. 8 is a schematic diagram of determining stroke coordinates provided by an embodiment of the present application.
[0048] FIG. 9 is a schematic flowchart of a handwriting stroke recognition method provided by an embodiment of the present application.
[0049] FIG. 10 is a set of GUIs provided by an embodiment of the present application.
[0050] FIG. 11 is a schematic flowchart of a handwriting stroke recognition method provided by an embodiment of the present application.
[0051] FIG. 12 is a set of GUIs provided by an embodiment of the present application.
[0052] FIG. 13 is a schematic flowchart of a method for recognizing handwriting strokes according to an embodiment of the present application.
[0053] FIG. 14 is a set of GUIs according to an embodiment of the present application.
[0054] FIG. 15 is a schematic flowchart of a method for dividing stroke groups according to an embodiment of the present application.
[0055] FIG. 16 is a schematic diagram of stroke groups according to an embodiment of the present application.
[0056] FIG. 17 is a schematic flowchart of a method for dividing stroke groups according to an embodiment of the present application.
[0057] FIG. 18 is a schematic flowchart of a method for dividing stroke groups according to an embodiment of the present application.
[0058] FIG. 19 is a schematic diagram of stroke groups according to an embodiment of the present application.
[0059] FIG. 20 is a schematic flowchart of a method for aggregating stroke groups according to an embodiment of the present application.
[0060] FIG. 21 is a schematic diagram of stroke groups according to an embodiment of the present application.
[0061] FIG. 22 is a schematic diagram of columnarizing content according to an embodiment of the present application.
[0062] FIG. 23 is a schematic flowchart of a method for dividing area blocks according to an embodiment of the present application.
[0063] FIG. 24 is a schematic diagram of the positional relationship of fields and / or patterns according to an embodiment of the present application.
[0064] FIG. 25 is a schematic flowchart of a method for columnarizing content according to the positional relationship of area blocks according to an embodiment of the present application.
[0065] FIG. 26 is a schematic flowchart of a method for recognizing handwriting strokes according to an embodiment of the present application.
[0066] FIG. 27 is a schematic flowchart of a method for recognizing handwriting strokes according to an embodiment of the present application.
[0067] FIG. 28 is a schematic flowchart of a method for recognizing handwriting strokes according to an embodiment of the present application.
[0068] FIG. 29 is a schematic diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0069] The technical solutions in the embodiments of the present application will be described below with reference to the accompanying drawings.
[0070] The terminology used in the following description merely for the purpose of describing particular embodiments and is not intended to be limiting of the application. As used in this description and the accompanying claims, the singular forms "a", "an" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will also be understood that the term "and / or" as used herein refers to and encompasses any and all possible combinations of one or more of the associated items, including items at different levels of granularity. The term "or" as used herein is used to denote exclusive, at least, or, at most, inclusive, or any combination thereof, as context dictates. The term "comprises the following features" or "comprises features of" as used herein is used to denote "comprises at least the following features" or "comprises at least features of", respectively, unless the context clearly indicates otherwise.
[0071] Reference throughout this specification to "one embodiment" or "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment is included in at least one embodiment of the application. Thus, the appearances of the phrases "in one embodiment", "in some embodiments", "in other embodiments", "in additional embodiments", and the like, in various places throughout this specification are not necessarily all referring to the same embodiment, unless otherwise indicated. The terms "comprises", "comprising", "including", and "having" and variations thereof herein are intended to be open-ended and mean that a stated
[0072] Embodiments of electronic devices, user interfaces for such electronic devices, and associated processes for using such electronic devices are described below. In some embodiments, an electronic device can be a portable electronic device that also contains other functionality such as personal digital assistant and / or music player functionality, such as a mobile phone, a tablet computer, a wearable electronic device with wireless communication capabilities (e.g., a smart watch), etc. Exemplary embodiments of portable electronic devices include, but are not limited to, portable electronic devices running the iOS® operating system, the Android® operating system, the Windows® operating system, or other operating systems. The portable electronic devices described above can also be other portable electronic devices, such as a laptop computer, etc. It will also be understood that, in other embodiments, the electronic devices described above can not be portable electronic devices, but can be desktop computers. Exemplary embodiments of portable electronic devices include, but are not limited to, portable electronic devices running the iOS® operating system, the Android® operating system, the Windows® operating system, or other operating systems. The portable electronic devices described above can also be other portable electronic devices, such as a laptop computer, etc. It will also be understood that, in other embodiments, the electronic devices described above can not be portable electronic devices, but can be desktop computers.
[0073] Exemplarily, FIG. 1 shows a structural schematic diagram of an electronic device 100. The electronic device 100 can include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a loudspeaker 170A, a receiver 170B, a microphone 170C, a headset jack 170D, a sensor module 180, a key 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, and the like. The sensor module 180 can include a pressure sensor 180A, a gyroscope sensor 180B, a barometric pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, and the like.
[0074] It can be understood that the structure shown in the embodiments of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 can include more or fewer components than shown, or combine certain components, or split certain components, or different arrangement of components. The components shown can be implemented in hardware, software, or a combination of software and hardware.
[0075] The processor 110 can include one or more processing units, for example: the processor 110 can include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), and the like. Different processing units can be independent devices, or can be integrated in one or more processors.
[0076] The controller can be the nerve center and command center of the electronic device 100. The controller can generate operation control signals according to instruction operation codes and timing signals, and complete the control of fetching instructions and executing instructions.
[0077] The processor 110 can also include a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory can hold instructions or data that the processor 110 has just used or is using in a loop. If the processor 110 needs to use the instructions or data again, it can be called directly from the memory. This avoids repeated access and reduces the latency of the processor 110, thus improving the efficiency of the system.
[0078] In some embodiments, the processor 110 can include one or more interfaces. The interfaces can include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.
[0079] The wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor, and the baseband processor, etc.
[0080] The antenna 1 and the antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in the electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be multiplexed to improve the utilization rate of the antennas. For example: the antenna 1 can be multiplexed as a diversity antenna of a wireless local area network. In some other embodiments, the antennas can be used in combination with a tuning switch.
[0081] The mobile communication module 150 can provide a solution for wireless communication including 2G / 3G / 4G / 5G, etc. applied to the electronic device 100. The mobile communication module 150 can include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves by the antenna 1, and perform filtering, amplification, etc. on the received electromagnetic waves, and transfer to a modem processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modem processor, and radiate as electromagnetic waves through the antenna 1. In some embodiments, at least part of the function modules of the mobile communication module 150 can be disposed in the processor 110. In some embodiments, at least part of the function modules of the mobile communication module 150 can be disposed in the same device as at least part of the modules of the processor 110.
[0082] The modem processor can include a modulator and a demodulator. The modulator is configured to modulate a low-frequency baseband signal to be transmitted into a medium-high frequency signal. The demodulator is configured to demodulate a received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. The low-frequency baseband signal processed by the baseband processor is transmitted to the application processor. The application processor outputs a sound signal through an audio device (not limited to the speaker 170A, the microphone 170B, etc.), or displays an image or a video through the display screen 194. In some embodiments, the modem processor can be a separate device. In other embodiments, the modem processor can be independent of the processor 110, and disposed in the same device as the mobile communication module 150 or other function modules.
[0083] The wireless communication module 160 can provide a solution for wireless communication including wireless local area networks (WLAN) (e.g., wireless fidelity (Wi-Fi) network), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR) technology, etc. applied to the electronic device 100. The wireless communication module 160 can be one or more devices that integrate at least one communication processing module. The wireless communication module 160 receives an electromagnetic wave via the antenna 2, frequency-modulates and filters the electromagnetic wave signal, and transmits the processed signal to the processor 110. The wireless communication module 160 can also receive a signal to be transmitted from the processor 110, frequency-modulate it, amplify it, and radiate it as an electromagnetic wave via the antenna 2.
[0084] In some embodiments, the antenna 1 and the mobile communication module 150 of the electronic device 100 are coupled, and the antenna 2 and the wireless communication module 160 are coupled, so that the electronic device 100 can communicate with a network and other devices through wireless communication technology. The wireless communication technology can include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), wideband code division multiple access (WCDMA), time-division code division multiple access (TD-CDMA), long term evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technology, etc. The GNSS can include global positioning system (GPS), global navigation satellite system (GLONASS), beidou navigation satellite system (BDS), quasi-zenith satellite system (QZSS), and / or satellite based augmentation systems (SBAS).
[0085] The electronic device 100 implements a display function through a GPU, a display screen 194, and an application processor, etc. The GPU is a microprocessor for image processing, which is connected to the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 can include one or more GPUs, which execute program instructions to generate or change display information.
[0086] The display screen 194 is configured to display images, videos, and the like. The display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flex light-emitting diode (FLED), a Miniled, a MicroLed, a Micro-oLed, a quantum dot light emitting diodes (QLED), or the like. In some embodiments, the electronic device 100 can include one or N display screens 194, where N is a positive integer greater than 1.
[0087] The electronic device 100 can implement the photographing function through the ISP, the camera 193, the video codec, the GPU, the display screen 194, and the application processor.
[0088] The ISP is configured to process the data fed back by the camera 193. For example, when taking a photo, the shutter is opened, the light is transmitted to the camera photosensitive element through the lens, the light signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to the ISP for processing to convert it into an image visible to the naked eye. The ISP can also optimize the noise, brightness, and skin color of the image. The ISP can also optimize the exposure, color temperature, and other parameters of the shooting scene. In some embodiments, the ISP can be disposed in the camera 193.
[0089] The camera 193 is configured to capture still images or videos. An object generates an optical image through a lens and projects it onto a photosensitive element. The photosensitive element can be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the light signal into an electrical signal, which is then transmitted to the ISP to convert it into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into an image signal in a standard RGB, YUV, or the like format. In some embodiments, the electronic device 100 can include one or N cameras 193, where N is a positive integer greater than 1.
[0090] The digital signal processor is used to process digital signals, in addition to being able to process digital image signals, it can also process other digital signals. For example, when the electronic device 100 selects a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy, etc.
[0091] The video codec is used to compress or decompress digital video. The electronic device 100 can support one or more video codecs. In this way, the electronic device 100 can play or record videos in multiple encoding formats, such as: moving picture experts group (MPEG) 1, MPEG 2, MPEG 3, MPEG 4, etc.
[0092] The NPU is a neural-network (NN) calculation processor, which can quickly process input information by drawing on the structure of a biological neural network, such as drawing on the transmission mode between human brain neurons, and can also constantly self-learn. Through the NPU, the electronic device 100 can realize intelligent cognition applications such as image recognition, face recognition, voice recognition, text understanding, etc.
[0093] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external memory interface 120 to realize data storage functions. For example, music, video, etc. Files are saved in the external memory card.
[0094] The internal memory 121 can be used to store computer executable program codes, which include instructions. The processor 110 executes various function applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 121. The internal memory 121 can include a program storage area and a data storage area. The program storage area can store an operating system, at least one application program required by a function (such as a sound playing function, an image playing function, etc.), etc. The data storage area can store data created during the use of the electronic device 100 (such as audio data, a phone book, etc.), etc. In addition, the internal memory 121 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, a universal flash memory (UFS), etc.
[0095] The electronic device 100 can realize audio functions through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the earphone interface 170D, and the application processor, etc. For example, music playing, recording, etc.
[0096] The audio module 170 is used for converting digital audio information into an analog audio signal output, and for converting an analog audio input into a digital audio signal. The audio module 170 can also be used for encoding and decoding an audio signal. In some embodiments, the audio module 170 can be disposed in the processor 110, or some functional modules of the audio module 170 can be disposed in the processor 110.
[0097] The speaker 170A, also referred to as a "loudspeaker", is used for converting an audio electrical signal into a sound signal. The electronic device 100 can listen to music or listen to a hands-free call through the speaker 170A.
[0098] The receiver 170B, also referred to as a "earpiece", is used for converting an audio electrical signal into a sound signal. When the electronic device 100 receives a call or a voice message, the user can listen to the voice through the receiver 170B close to the ear.
[0099] The microphone 170C, also referred to as a "microphone", "transducer", is used for converting a sound signal into an electrical signal. When making a call or sending a voice message, the user can make a sound through the mouth close to the microphone 170C, and input the sound signal into the microphone 170C. The electronic device 100 can be provided with at least one microphone 170C. In other embodiments, the electronic device 100 can be provided with two microphones 170C, in addition to collecting sound signals, noise reduction functions can also be realized. In other embodiments, the electronic device 100 can also be provided with three, four or more microphones 170C, in addition to collecting sound signals, noise reduction, and can also identify the source of the sound, realize the function of directional recording, etc.
[0100] The pressure sensor 180A is used for sensing a pressure signal, and can convert the pressure signal into an electrical signal. In some embodiments, the pressure sensor 180A can be disposed on the display screen 194. There are many types of pressure sensors 180A, such as resistive pressure sensors, inductive pressure sensors, capacitive pressure sensors, etc. The capacitive pressure sensor can include at least two parallel plates with conductive material. When a force acts on the pressure sensor 180A, the capacitance between the electrodes changes. The electronic device 100 determines the intensity of the pressure according to the change of the capacitance. When a touch operation acts on the display screen 194, the electronic device 100 detects the intensity of the touch operation according to the pressure sensor 180A. The electronic device 100 can also calculate the position of the touch according to the detection signal of the pressure sensor 180A. In some embodiments, touch operations acting on the same touch position but with different touch operation intensities can correspond to different operation instructions. For example, when a touch operation with a touch operation intensity greater than or equal to a first pressure threshold value acts on an alarm application icon, an instruction to create a new alarm is executed.
[0101] The fingerprint sensor 180H is configured to collect a fingerprint. The electronic device 100 can implement fingerprint unlocking, access to an application lock, fingerprint photographing, fingerprint answering a call, and the like using a characteristic of the collected fingerprint. For example, when the mobile phone detects a touch operation of a user in a lock screen interface, the mobile phone can collect fingerprint information of the user through the fingerprint sensor 180H and match the collected fingerprint information with preset fingerprint information in the mobile phone. If the matching is successful, the mobile phone can enter a non-lock screen interface from the lock screen interface.
[0102] The touch sensor 180K, also referred to as a "touch panel". The touch sensor 180K can be disposed on the display screen 194, and the touch sensor 180K and the display screen 194 form a touch screen, also referred to as a "touch panel". The touch sensor 180K is configured to detect a touch operation acting on or near the touch sensor 180K. The touch sensor 180K can transmit the detected touch operation to the application processor to determine a touch event type. Visual output related to the touch operation can be provided through the display screen 194. In other embodiments, the touch sensor 180K can also be disposed on the surface of the electronic device 100, which is different from the position of the display screen 194.
[0103] FIG. 2 is a software structure block diagram of the electronic device 100 according to an embodiment of the present application. A layered architecture divides the software into several layers, each of which has a clear role and division of labor. Layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom, the application layer, the application framework layer, the Android runtime and the system library, and the kernel layer. The application layer can include a series of application packages.
[0104] As shown in FIG. 2, the application layer can include a camera, a setting, a third-party application, and the like. Among them, the third-party application can include a gallery, a calendar, a call, a map, a navigation, a WLAN, a Bluetooth, music, a video, a short message, and the like.
[0105] The application framework layer provides an application programming interface (API) and a programming framework for the applications of the application layer. The application framework layer can include some pre-defined functions.
[0106] As shown in FIG. 2, the application framework layer can include a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, and the like.
[0107] The window manager is used to manage windows programs. The window manager can acquire the display screen size, determine whether there is a status bar, lock the screen, and capture the screen, etc. The content provider is used to store and acquire data, and make the data accessible to the application program. The data can include video, image, audio, dialed and received phone, browsing history and bookmark, phone book, etc.
[0108] The view system includes visual controls, such as a control for displaying text, a control for displaying pictures, etc., such as the indication information for prompting the virtual shutter key in the embodiment of the present application. The view system can be used to build an application program. The display interface can be composed of one or more views. For example, the display interface including the short message notification icon can include a view for displaying text and a view for displaying pictures.
[0109] The phone manager is used to provide the communication function of the electronic device 100. For example, the management of the call state (including call connection, call hang-up, etc.).
[0110] The resource manager provides various resources for the application program, such as localized strings, icons, pictures, layout files, video files, etc.
[0111] The notification manager makes the application program display the notification information in the status bar, which can be used to convey the message of the notification type, can automatically disappear after a short stay, and does not need user interaction. For example, the notification manager is used to notify the completion of the download, the message reminder, etc. The notification manager can also be the notification appearing in the top status bar of the system in the form of a chart or a scroll bar text, such as the notification of the application program running in the background, and can also be the notification appearing on the screen in the form of a dialogue window. For example, the text information is prompted in the status bar, a prompt sound is emitted, the electronic device is vibrated, the indicator light flashes, etc.
[0112] The Android runtime includes the core library and the virtual machine. The Android runtime is responsible for the scheduling and management of the Android system.
[0113] The core library contains two parts: one part is the function function called by the java language, and the other part is the core library of Android.
[0114] The application program layer and the application program framework layer run in the virtual machine. The virtual machine executes the java file of the application program layer and the application program framework layer into a binary file. The virtual machine is used to perform the management of the object life cycle, the management of the stack, the management of the thread, the management of the security and exception, and the garbage collection, etc.
[0115] The system library can include a plurality of functional modules. For example, a surface manager, media libraries, a three-dimensional graphics processing library (e.g., OpenGL ES), a 2D graphics engine (e.g., SGL), and the like.
[0116] The surface manager is used to manage a display subsystem and provides fusion of 2D and 3D layers for a plurality of applications.
[0117] The media libraries support playback and recording of a plurality of commonly used audio, video formats, and still image files. The media libraries can support a plurality of audio and video encoding formats, such as MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, and the like.
[0118] The three-dimensional graphics processing library is used to implement three-dimensional graphics drawing, image rendering, composition, and layer processing, and the like.
[0119] The 2D graphics engine is a drawing engine for 2D drawing.
[0120] In addition, the system library can also include a state monitoring service module, such as a physical state identification module used to analyze and identify user gestures, and a sensor service module used to monitor sensor data uploaded by various sensors of the hardware layer to determine the physical state of the electronic device 100.
[0121] The kernel layer is a layer between hardware and software. The kernel layer at least includes display drivers, camera drivers, audio drivers, and sensor drivers.
[0122] The hardware layer can include various sensors, such as the various sensors described in FIG. 1, the acceleration sensor, the gyroscope sensor, the touch sensor, and the like involved in the embodiments of the present application.
[0123] It should be noted that FIG. 2 only takes one way of dividing the system framework as an example, and should not be understood as a specific limitation on the embodiments of the present application. In the embodiments of the present application, when the operating system carried by the electronic device is different, different frameworks can be used for different operating systems. It can be understood that when different frameworks are used, the division of each layer of the framework, the specific naming, and the specific location of each module described above can be different.
[0124] With the advancement of technology, more and more users will use electronic devices to record by hand in meeting, class, and the like. Taking recording notes as an example, the user often needs to select note content to perform operations such as deletion, movement, and copying when recording notes, where the note content can include text and patterns. At present, when the user selects the note content, there are many problems, which will be described below in conjunction with FIG. 3.
[0125] Figure 3 shows a set of graphical user interfaces (GUI).
[0126] As shown in (a) and (b) of Figure 3, the note content displayed on the electronic device is: "Huawei Note", where the two characters "笔 (bǐ)" and "记 (jì)" are adjacent to each other. When the electronic device detects the operation of the user selecting "笔 (bǐ)", since the two characters "笔 (bǐ)" and "记 (jì)" are adjacent to each other, when the electronic device selects "笔 (bǐ)", it will also select the radical "讠 (yán)" of "记 (jì)", that is, the GUI shown in (b) of Figure 3 is displayed.
[0127] As shown in (c) and (d) of Figure 3, the note content displayed on the electronic device is: "Inspiration Collection", where the strokes of the two characters "灵 (líng)" and "感 (gǎn)" cross each other. When the electronic device detects the operation of the user selecting "灵 (líng)", since the strokes of the two characters "灵 (líng)" and "感 (gǎn)" cross each other, the electronic device may not be able to select "灵 (líng)" alone, but will directly select the two characters "灵 (líng)" and "感 (gǎn)", that is, the GUI shown in (d) of Figure 3 is displayed.
[0128] As shown in (e) and (f) of Figure 3, the note content displayed on the electronic device is a pattern. When the electronic device detects the operation of the user selecting the pattern and moving the pattern, the electronic device may miss the strokes that originally belonged to the pattern, that is, the GUI shown in (f) of Figure 3 is displayed.
[0129] As shown in (g) and (h) of Figure 3, the note content displayed on the electronic device includes two columns of text. In this case, the electronic device may not be able to recognize that the note content includes two columns of text. Therefore, in this case, the user cannot only select the text in a certain column, but still can only select the text in the note content line by line, that is, the electronic device can display the GUI shown in (h) of Figure 3.
[0130] In summary, when the user selects note content, there are problems such as the following: 1. When the distance between two characters is relatively close or there are intersecting strokes, it may not be possible to select each character separately; 2. When selecting a pattern, there may be over-selection or missed selection of strokes; 3. When the user records notes in a columnar format, the columnar format may not be correctly recognized, resulting in a disorder in the selection order when selecting note content. Based on this, the embodiments of the present application provide an analysis method for handwritten notes, which can quickly and accurately analyze the notes so that the user can accurately select the desired note content.
[0131] Figure 4 shows a schematic flowchart of the handwritten stroke recognition method provided by the embodiments of the present application. This method can be executed by an electronic device or by components of the electronic device (such as a processor, a chip system, etc.). Hereinafter, an example will be given with the execution subject being an electronic device. As shown in Figure 4, this method includes:
[0132] S410, display content #1.
[0133] The content #1 can include text. In embodiments of the present application, the type of text in the content #1 is not specifically limited, for example, the type of text in the content #1 includes but is not limited to Chinese, English, etc.
[0134] In some embodiments, the content #1 can be the content corresponding to the notes being recorded by the user.
[0135] In some embodiments, the content #1 can be the content corresponding to the notes that have been stored.
[0136] In some embodiments, the content #1 can be the content sent by other electronic devices.
[0137] S420, identify the text included in the content #1.
[0138] The electronic device can identify the text in the content #1 through optical character recognition (OCR) and other technologies.
[0139] In some embodiments, the content #1 includes text #1 and text #2, the text #1 and the text #2 are adjacent, the distance between the text #1 and the text #2 is less than or equal to a threshold value #1, or the text #1 and the text #2 have strokes intersecting.
[0140] It should be noted that when the text #1 and the text #2 have strokes intersecting, the distance between the text #1 and the text #2 is 0, so it can also be understood that the distance between the text #1 and the text #2 is less than the threshold value #1.
[0141] For example, FIG. 5 shows a set of GUIs provided by embodiments of the present application, and the content #1 displayed by the electronic device is shown in (a) of FIG. 5. The electronic device can identify that the content #1 includes two texts, which are “ling” and “gan” respectively.
[0142] S430, determine the overlapping area #1 according to the rectangular frame #1 corresponding to the text #1 and the rectangular frame #2 corresponding to the text #2.
[0143] The electronic device can use a rectangular box to enclose the recognized text in content 1 when recognizing the text. If two adjacent texts are close to each other or there is an overlap in strokes, the rectangular boxes corresponding to the two adjacent texts can have an overlapping area. Therefore, the electronic device can determine the overlapping area 1 according to the rectangular box 1 corresponding to the text 1 and the rectangular box 2 corresponding to the text 2. In other words, each text in content 1 can correspond to a rectangular box, and the rectangular boxes of adjacent texts can overlap. For example, as shown in (a) of FIG. 5, there is an overlap in strokes between “ling” and “gan”, and the rectangular boxes corresponding to “ling” and “gan” have an overlapping area.
[0144] In some embodiments, the overlapping area 1 includes one or more strokes. The one or more strokes can be complete strokes or a part of a stroke.
[0145] It can be understood that, for a non-overlapping area, the strokes included in the non-overlapping area belong to the text corresponding to the non-overlapping area, and for an overlapping area, the electronic device needs to determine the attribution of the strokes included in the overlapping area, which will be described in detail below.
[0146] S440, determining the strokes in the text and the writing order of the strokes.
[0147] The electronic device records a sequence of track points of the strokes in the content, and the sequence of track points includes track point landing information, lifting information, and writing order. Therefore, the electronic device can determine the track points and writing order of each stroke in the text according to the sequence of track points, that is, determine each stroke and the writing order of the stroke.
[0148] In some embodiments, the electronic device can determine the track points and writing order of the strokes of all texts in content 1.
[0149] For example, the electronic device can determine the track points and writing order of each stroke in “ling” and “gan”.
[0150] In some embodiments, the electronic device can determine the track points and writing order of the strokes of the overlapping area.
[0151] For example, as shown in (a) of FIG. 5, the electronic device can determine the track points and writing order of the strokes of the overlapping area of “ling” and “gan”.
[0152] It should be noted that, in some embodiments, the strokes of the overlapping area can be a part of a stroke, and the determination of the track points and writing order of the strokes of the overlapping area by the electronic device can be understood as the determination of the track points and writing order of the complete strokes corresponding to the strokes of the overlapping area by the electronic device.
[0153] For example, as shown in (a) of FIG. 5, the part of stroke 1 is in the overlapping area, the electronic device can determine the track points and writing order of the complete stroke 1.
[0154] S450, according to the writing order of the strokes of the text #1 and the text #2 and the position relationship between the one or more strokes in the overlapping area and the rectangular frame #1 and the rectangular frame #2, determine the attribution of the one or more strokes in the overlapping area.
[0155] It can be understood that the strokes in the overlapping area attributed to the text #1 should be closer to the rectangular frame #1. Similarly, the strokes in the overlapping area attributed to the text #2 should be closer to the rectangular frame #2.
[0156] It can also be understood that in some scenarios, due to the user's writing, the strokes in the overlapping area attributed to the text #2 may also be closer to the rectangular frame #1, in this scenario, it can also be judged whether the previous stroke of the stroke has a previous stroke, and when the previous stroke is attributed to the text #2, it indicates that the stroke is also attributed to the text #2.
[0157] In summary, the electronic device can determine the attribution of the one or more strokes in the overlapping area according to the writing order of the strokes of the text #1 and the text #2 and the position relationship between the one or more strokes in the overlapping area and the rectangular frame #1 and the rectangular frame #2.
[0158] In some embodiments, the text #1 and the text #2 are left-right distributed, the text #1 is on the left side of the text #2, and the one or more strokes in the overlapping area include stroke #1, as shown in FIG. 6, S450, according to the writing order of the strokes of the text #1 and the text #2 and the position relationship between the one or more strokes in the overlapping area and the rectangular frame #1 and the rectangular frame #2, determine the attribution of the one or more strokes in the overlapping area, including:
[0159] S451, determine the center horizontal coordinate #1 of the rectangular frame #1 and the center horizontal coordinate #2 of the rectangular frame #2.
[0160] After the electronic device recognizes the text #1 and the text #2, the rectangular frame #1 and the rectangular frame #2 can be used to enclose the text #1 and the text #2 respectively, and on the basis of determining the rectangular frame #1 and the rectangular frame #2, the center horizontal coordinate #1 of the rectangular frame #1 and the center horizontal coordinate #2 of the rectangular frame #2 can be further determined. The center horizontal coordinate #1 of the rectangular frame #1 can be understood as the horizontal coordinate corresponding to the center point of the rectangular frame #1, denoted as x1. The center horizontal coordinate #2 of the rectangular frame #2 can be understood as the horizontal coordinate corresponding to the center point of the rectangular frame #2, denoted as x2.
[0161] In the embodiments of the present application, the positional relationship of two adjacent characters includes left-right distribution, up-down distribution and diagonal distribution. As shown in (a) of FIG. 7, when the center angle of the rectangular frame corresponding to the two adjacent characters is less than an angle threshold #1 (for example, the angle threshold #1 is 30°), the two characters are left-right distributed. As shown in (b) of FIG. 7, when the center angle of the rectangular frame corresponding to the two adjacent characters is greater than or equal to the angle threshold #1 and less than or equal to an angle threshold #2 (for example, the angle threshold #2 is 60°), the two characters are diagonally distributed. As shown in (c) of FIG. 7, when the center angle of the rectangular frame corresponding to the two adjacent characters is greater than the angle threshold #2, the two characters are up-down distributed. The center angle of the rectangular frame corresponding to the two adjacent characters can be understood as the included angle between the line connecting the center points of the two rectangular frames and the horizontal direction.
[0162] S452, determine the average horizontal coordinate #1 of the stroke #1.
[0163] When the electronic device determines that the stroke #1 is the stroke of the overlapping region, the electronic device can determine the average horizontal coordinate #1 of the stroke #1. The average horizontal coordinate #1 of the stroke #1 can be understood as the horizontal coordinate corresponding to the center of gravity of the stroke #1.
[0164] In the embodiments of the present application, the method for determining the average horizontal coordinate #1 of the stroke #1 is not specifically limited, and a possible implementation manner is exemplarily introduced below.
[0165] In a possible implementation manner, the electronic device can rasterize the stroke #1 into an image, and the electronic device can determine the center of gravity of the image as the center of gravity of the stroke #1, denoted as x. The following is introduced in combination with FIG. 8.
[0166] As shown in FIG. 8, the electronic device can initialize a vertical projection array h with all 0s in the range of the maximum horizontal coordinate of the stroke #1. The electronic device traverses all points of the stroke #1, and calculates the range of the horizontal coordinate spanned by any two points, and adds 1 to the elements in the array corresponding to the two points. If the horizontal coordinates of the two points are the same, the absolute value of the difference between the vertical coordinates of the two points is added. Taking p0 and p1 in FIG. 8 as an example, the horizontal coordinate range is x0 and x1, and the values of h[x0] to h[x1] in the array are all added by 1. If x0=x1, the absolute value of y0-y1 is added in the array h[x0]. The value of the element in the array h can be determined in the above manner, and then the horizontal coordinate of the stroke #1 can be determined according to formula (1).
[0167] Wherein, x is the horizontal coordinate of the stroke #1, i is the horizontal coordinate of the i th element in the array h, h i is the value of the i th element in the array h.
[0168] S453, whether the distance between the average horizontal coordinate #1 and the center horizontal coordinate #1 is greater than the distance between the average horizontal coordinate #1 and the center horizontal coordinate #2.
[0169] The electronic device can determine the distance between the average horizontal coordinate #1 and the center horizontal coordinate #1 and the distance between the average horizontal coordinate #1 and the center horizontal coordinate #2, when it is determined that the distance between the average horizontal coordinate #1 and the center horizontal coordinate #1 is greater than the distance between the average horizontal coordinate #1 and the center horizontal coordinate #2, step S454 can be performed, when it is determined that the distance between the average horizontal coordinate #1 and the center horizontal coordinate #1 is less than the distance between the average horizontal coordinate #1 and the center horizontal coordinate #2, step S455 can be performed.
[0170] The parameter representing the distance between the average horizontal coordinate #1 and the center horizontal coordinate #1 and the center horizontal coordinate #2 is not limited in the embodiments of the present application, and any parameter capable of representing the distance can be used to represent the distance between the average horizontal coordinate #1 and the center horizontal coordinate #1 and the center horizontal coordinate #2.
[0171] For example, the distance between the average horizontal coordinate #1 and the center horizontal coordinate #1 is x-x1, and the distance between the average horizontal coordinate #1 and the center horizontal coordinate #2 is x2-x.
[0172] For another example, the distance between the average horizontal coordinate #1 and the center horizontal coordinate #1 is (x-x1) 2 , and the distance between the average horizontal coordinate #1 and the center horizontal coordinate #2 is (x2-x) 2 .
[0173] For another example, the distance between the average horizontal coordinate #1 and the center horizontal coordinate #1 is |x1-x|, and the distance between the average horizontal coordinate #1 and the center horizontal coordinate #2 is |x2-x|.
[0174] S454, determining that the stroke #1 belongs to the character #2.
[0175] When the distance between the average horizontal coordinate #1 and the center horizontal coordinate #1 is greater than the distance between the average horizontal coordinate #1 and the center horizontal coordinate #2, it indicates that the stroke #1 is closer to the rectangular frame #2, as described above, the stroke belonging to the character #2 in the overlapping area should be closer to the rectangular frame #2, and therefore it can be determined that the stroke #1 belongs to the character #2.
[0176] S455, whether the previous stroke of the stroke #1 belongs to the character #2.
[0177] As described above, the stroke belonging to the character #2 in the overlapping area can also be closer to the rectangular frame #1, in this scenario, it can also be determined whether the previous stroke of the stroke #1 belongs to the character #2, when it is determined that the previous stroke of the stroke #1 belongs to the character #2, step S454 can be performed, when it is determined that the previous stroke of the stroke #1 does not belong to the character #2, step S456 can be performed.
[0178] S456, determine that stroke #1 belongs to character #1.
[0179] When the distance between average horizontal coordinate #1 and center horizontal coordinate #1 is less than the distance between average horizontal coordinate #1 and center horizontal coordinate #2, it indicates that stroke #1 is closer to rectangular frame #1, and the previous stroke of stroke #1 does not belong to character #2, so it can be determined that stroke #1 belongs to character #1.
[0180] For example, as shown in (b) of FIG. 5, the electronic device can determine the center horizontal coordinate #1 of the rectangular frame #1 corresponding to “ling”, and determine the center horizontal coordinate #2 of the rectangular frame #2 corresponding to “gan”. Rectangular frame #1 and rectangular frame #2 have an overlapping area, and the overlapping area includes stroke 1, stroke 2 and stroke 3. The electronic device can determine the average horizontal coordinate corresponding to stroke 1, the average horizontal coordinate corresponding to stroke 2, and the average horizontal coordinate corresponding to stroke 3, respectively. The distance between the average horizontal coordinate corresponding to stroke 1 and the center horizontal coordinate #1 is less than the distance between the center horizontal coordinate #2, and the previous stroke of stroke 1 does not belong to “gan”, so the electronic device can determine that stroke 1 belongs to “ling”. The distance between the average horizontal coordinate corresponding to stroke 2 and the center horizontal coordinate #1 is greater than the distance between the center horizontal coordinate #2, so the electronic device can determine that stroke 2 belongs to “gan”. The distance between the average horizontal coordinate corresponding to stroke 3 and the center horizontal coordinate #1 is less than the distance between the center horizontal coordinate #2, but the previous stroke of stroke 3 is stroke 2, which belongs to “gan”, so the electronic device can determine that stroke 3 belongs to “gan”.
[0181] In some embodiments, character #1 and character #2 are left-right distributed, character #1 is on the left side of character #2, and one or more strokes in the overlapping area include stroke #1, wherein the horizontal length of the rectangular frame #1 corresponding to character #1 and / or the horizontal length of the rectangular frame #2 corresponding to character #2 is greater than threshold #2, as shown in FIG. 9, S450, determining the attribution of one or more strokes in the overlapping area according to the writing order of the strokes of character #1 and character #2 and the positional relationship between one or more strokes in the overlapping area and rectangular frame #1 and rectangular frame #2, including:
[0182] S457, determine the horizontal coordinate #1 of the right side frame of rectangular frame #1 and the horizontal coordinate #2 of the left side frame of rectangular frame #2.
[0183] After the electronic device identifies the character #1 and the character #2, the electronic device can use the rectangle #1 and the rectangle #2 to enclose the character #1 and the character #2 respectively. Based on the determination of the rectangle #1 and the rectangle #2, since the horizontal length of the rectangle #1 and / or the rectangle #2 is greater than the threshold #2, if the center horizontal coordinate is still used as the comparison reference, the result may be biased towards the character corresponding to the rectangle with shorter horizontal length. Therefore, the electronic device can determine the horizontal coordinate #1 of the right side frame of the rectangle #1 and the horizontal coordinate #2 of the left side frame of the rectangle #2. The horizontal coordinate #1 of the right side frame of the rectangle #1 can be understood as the horizontal coordinate corresponding to the right side frame of the rectangle #1, denoted as x1. The horizontal coordinate #2 of the left side frame of the rectangle #2 can be understood as the horizontal coordinate corresponding to the left side frame of the rectangle #2, denoted as x2.
[0184] S458, determine the average horizontal coordinate #1 of the stroke #1.
[0185] It should be understood that the description for step S458 can be referred to the above description, which will not be repeated here for brevity.
[0186] S459, whether the distance between the average horizontal coordinate #1 and the horizontal coordinate #1 of the right side frame of the rectangle #1 is greater than the distance between the average horizontal coordinate #1 and the horizontal coordinate #2 of the left side frame of the rectangle #2.
[0187] The electronic device can determine the distance between the average horizontal coordinate #1 and the horizontal coordinate #1 of the right side frame of the rectangle #1 and the distance between the average horizontal coordinate #1 and the horizontal coordinate #2 of the left side frame of the rectangle #2. When it is determined that the distance between the average horizontal coordinate #1 and the horizontal coordinate #1 of the right side frame of the rectangle #1 is greater than the distance between the average horizontal coordinate #1 and the horizontal coordinate #2 of the left side frame of the rectangle #2, step S4510 can be performed. When it is determined that the distance between the average horizontal coordinate #1 and the horizontal coordinate #1 of the right side frame of the rectangle #1 is less than the distance between the average horizontal coordinate #1 and the horizontal coordinate #2 of the left side frame of the rectangle #2, step S4511 can be performed.
[0188] S4510, determine that the stroke #1 belongs to the character #2.
[0189] When the distance between the average horizontal coordinate #1 and the horizontal coordinate #1 of the right side frame of the rectangle #1 is greater than the distance between the average horizontal coordinate #1 and the horizontal coordinate #2 of the left side frame of the rectangle #2, it indicates that the stroke #1 is closer to the rectangle #2. As described above, the strokes belonging to the character #2 in the overlapping area should be closer to the rectangle #2. Therefore, it can be determined that the stroke #1 belongs to the character #2.
[0190] S4511, whether the previous stroke of the stroke #1 belongs to the character #2.
[0191] It should be understood that the description for step S4511 can be referred to the above, and for brevity, will not be repeated here. When it is determined that the preceding stroke of stroke #1 belongs to character #2, step S4510 can be performed, and when it is determined that the preceding stroke of stroke #1 does not belong to character #2, step S4512 can be performed.
[0192] S4512, determining that stroke #1 belongs to character #1.
[0193] When the distance between average horizontal coordinate #1 and horizontal coordinate #1 of the right side frame of rectangular frame #1 is less than the distance between average horizontal coordinate #1 and horizontal coordinate #2 of the left side frame of rectangular frame #2, it indicates that stroke #1 is closer to rectangular frame #1, and the preceding stroke of stroke #1 does not belong to character #2, and thus it can be determined that stroke #1 belongs to character #1.
[0194] For example, as shown in FIG. 10, the electronic device can recognize that the characters include “hui” and “jiao”. Since the character type of “jiao” is English, the horizontal length of the corresponding rectangular frame is greater than threshold #2, and thus the electronic device can determine the horizontal coordinate #1 of the right side frame of rectangular frame #1 corresponding to “hui”, and determine the horizontal coordinate #2 of the left side frame of rectangular frame #2 corresponding to “jiao”. Rectangular frame #1 and rectangular frame #2 have an overlapping region, and the overlapping region includes stroke 1, stroke 2 and stroke 3. The electronic device can determine the average horizontal coordinate corresponding to stroke 1, the average horizontal coordinate corresponding to stroke 2, and the average horizontal coordinate corresponding to stroke 3, respectively. Since the distance between the average horizontal coordinate corresponding to stroke 1 and the horizontal coordinate #1 of the right side frame of rectangular frame #1 is greater than the distance between the average horizontal coordinate corresponding to stroke 1 and the horizontal coordinate #2 of the left side frame of rectangular frame #2, the electronic device can determine that stroke 1 belongs to “jiao”. Since the distance between the average horizontal coordinate corresponding to stroke 2 and the horizontal coordinate #1 of the right side frame of rectangular frame #1 is greater than the distance between the average horizontal coordinate corresponding to stroke 2 and the horizontal coordinate #2 of the left side frame of rectangular frame #2, the electronic device can determine that stroke 2 belongs to “jiao”. Since the distance between the average horizontal coordinate corresponding to stroke 3 and the horizontal coordinate #1 of the right side frame of rectangular frame #1 is less than the distance between the average horizontal coordinate corresponding to stroke 3 and the horizontal coordinate #2 of the left side frame of rectangular frame #2, and the preceding stroke of stroke 3 belongs to “hui”, the electronic device can determine that stroke 3 belongs to “hui”.
[0195] In some embodiments, character #1 and character #2 are distributed above and below, character #1 is on the upper side of character #2, and one or more strokes in the overlapping region include stroke #1, as shown in FIG. 11, S450, determining the attribution of one or more strokes in the overlapping region according to the writing order of the strokes of character #1 and character #2 and the positional relationship between one or more strokes in the overlapping region and rectangular frame #1 and rectangular frame #2, including:
[0196] S4513, determining the center vertical coordinate #1 of rectangular frame #1 and the center vertical coordinate #2 of rectangular frame #2.
[0197] After the electronic device identifies the character #1 and the character #2, the electronic device can enclose the character #1 and the character #2 by the rectangle #1 and the rectangle #2 respectively. Based on the determination of the rectangle #1 and the rectangle #2, since the character #1 and the character #2 are distributed vertically, the electronic device can further determine the center vertical coordinate #1 of the rectangle #1 and the center vertical coordinate #2 of the rectangle #2. The center vertical coordinate #1 of the rectangle #1 can be understood as the vertical coordinate corresponding to the center point of the rectangle #1, denoted as y1. The center vertical coordinate #2 of the rectangle #2 can be understood as the vertical coordinate corresponding to the center point of the rectangle #2, denoted as y2.
[0198] S4514, determine the average horizontal coordinate #1 of the stroke #1.
[0199] When the electronic device determines that the stroke #1 is the stroke of the overlapping area, the electronic device can determine the average horizontal coordinate #1 of the stroke #1. The average horizontal coordinate #1 of the stroke #1 can be understood as the horizontal coordinate corresponding to the center of gravity of the stroke #1.
[0200] It should be understood that the description of determining the average horizontal coordinate #1 of the stroke #1 can refer to the description of determining the average horizontal coordinate #1 of the stroke #1. For brevity, it will not be repeated here. The average horizontal coordinate of the stroke #1 can be denoted as x.
[0201] S4515, whether the distance between the average horizontal coordinate #1 and the center horizontal coordinate #1 is greater than the distance between the average horizontal coordinate #1 and the center horizontal coordinate #2.
[0202] The electronic device can determine the distance between the average horizontal coordinate #1 and the center horizontal coordinate #1 and the distance between the average horizontal coordinate #1 and the center horizontal coordinate #2. When it is determined that the distance between the average horizontal coordinate #1 and the center horizontal coordinate #1 is greater than the distance between the average horizontal coordinate #1 and the center horizontal coordinate #2, step S4516 can be performed. When it is determined that the distance between the average horizontal coordinate #1 and the center horizontal coordinate #1 is less than the distance between the average horizontal coordinate #1 and the center horizontal coordinate #2, step S4517 can be performed.
[0203] S4516, determine that the stroke #1 belongs to the character #2.
[0204] When the distance between the average horizontal coordinate #1 and the center horizontal coordinate #1 is greater than the distance between the average horizontal coordinate #1 and the center horizontal coordinate #2, it indicates that the stroke #1 is closer to the rectangle #2. As described above, the strokes belonging to the character #2 in the overlapping area should be closer to the rectangle #2. Therefore, it can be determined that the stroke #1 belongs to the character #2.
[0205] S4517, whether the previous stroke of the stroke #1 belongs to the character #2.
[0206] As described above, the strokes belonging to character #2 in the overlapping region can also be closer to the rectangular frame #1, in this scenario, it can be further determined whether the preceding stroke of stroke #1 belongs to character #2, when it is determined that the preceding stroke of stroke #1 belongs to character #2, step S454 can be performed, when it is determined that the preceding stroke of stroke #1 does not belong to character #2, step S456 can be performed.
[0207] S4518, determine that stroke #1 belongs to character #1.
[0208] When the distance between average vertical coordinate #1 and center vertical coordinate #1 is less than the distance between average vertical coordinate #1 and center vertical coordinate #2, it indicates that stroke #1 is closer to rectangular frame #1, and the preceding stroke of stroke #1 does not belong to character #2, so it can be determined that stroke #1 belongs to character #1.
[0209] For example, as shown in FIG. 12, the electronic device can determine the center vertical coordinate #1 of the rectangular frame #1 corresponding to “yan”, and determine the center vertical coordinate #2 of the rectangular frame #2 corresponding to “you”. Rectangular frame #1 and rectangular frame #2 have an overlapping region, and the overlapping region includes stroke 1 and stroke 2. The electronic device can determine the average vertical coordinate corresponding to stroke 1 and the average vertical coordinate corresponding to stroke 2 respectively. The distance between the average vertical coordinate corresponding to stroke 1 and center vertical coordinate #1 is greater than the distance between center vertical coordinate #2, so the electronic device can determine that stroke 1 belongs to “you”. The distance between the average vertical coordinate corresponding to stroke 2 and center vertical coordinate #1 is greater than the distance between center vertical coordinate #2, so the electronic device can determine that stroke 2 belongs to “you”.
[0210] In some embodiments, character #1 and character #2 are diagonally distributed, character #1 is on the upper left side or lower left side of character #2, and one or more strokes in the overlapping region include stroke #1, as shown in FIG. 13, S450, determining the attribution of one or more strokes in the overlapping region according to the writing order of the strokes of character #1 and character #2 and the positional relationship between one or more strokes in the overlapping region and rectangular frame #1 and rectangular frame #2, including:
[0211] S4519, determine the center coordinate #1 of rectangular frame #1 and the center coordinate #2 of rectangular frame #2.
[0212] After the electronic device identifies the character #1 and the character #2, the electronic device can enclose the character #1 and the character #2 by the rectangle #1 and the rectangle #2 respectively. Based on the determination of the rectangle #1 and the rectangle #2, since the character #1 and the character #2 are diagonally distributed, the electronic device can further determine the center coordinate #1 of the rectangle #1 and the center coordinate #2 of the rectangle #2. The center coordinate #1 of the rectangle #1 can be understood as the coordinate corresponding to the center point of the rectangle #1, denoted as (x1, y1). The center coordinate #2 of the rectangle #2 can be understood as the coordinate corresponding to the center point of the rectangle #2, denoted as (x2, y2).
[0213] S4520, determining the average coordinate #1 of the stroke #1.
[0214] When the electronic device determines that the stroke #1 is the stroke of the overlapping area, the electronic device can determine the average coordinate #1 of the stroke #1. The average coordinate #1 of the stroke #1 can be understood as the coordinate corresponding to the center of gravity of the stroke #1, denoted as (x, y).
[0215] S4521, whether the distance between the average coordinate #1 and the center coordinate #1 is greater than the distance between the average coordinate #1 and the center coordinate #2.
[0216] The electronic device can determine the distance between the average coordinate #1 and the center coordinate #1 and the distance between the average coordinate #1 and the center coordinate #2. When it is determined that the distance between the average coordinate #1 and the center coordinate #1 is greater than the distance between the average coordinate #1 and the center coordinate #2, step S4522 can be performed. When it is determined that the distance between the average coordinate #1 and the center coordinate #1 is less than the distance between the average coordinate #1 and the center coordinate #2, step S4523 can be performed.
[0217] S4522, determining that the stroke #1 belongs to the character #2.
[0218] When the distance between the average coordinate #1 and the center coordinate #1 is greater than the distance between the average coordinate #1 and the center coordinate #2, it indicates that the stroke #1 is closer to the rectangle #2. As described above, the stroke belonging to the character #2 in the overlapping area should be closer to the rectangle #2. Therefore, it can be determined that the stroke #1 belongs to the character #2.
[0219] S4523, whether the previous stroke of the stroke #1 belongs to the character #2.
[0220] As described above, the stroke belonging to the character #2 in the overlapping area can also be closer to the rectangle #1. In this scenario, it can be further determined whether the previous stroke of the stroke #1 belongs to the character #2. When it is determined that the previous stroke of the stroke #1 belongs to the character #2, step S4522 can be performed. When it is determined that the previous stroke of the stroke #1 does not belong to the character #2, step S4524 can be performed.
[0221] S4524, determine that stroke #1 belongs to character #1.
[0222] When the distance between average coordinate #1 and center coordinate #1 is less than the distance between average coordinate #1 and center coordinate #2, it indicates that stroke #1 is closer to rectangle frame #1, and the previous stroke of stroke #1 does not belong to character #2, so it can be determined that stroke #1 belongs to character #1.
[0223] For example, as shown in FIG. 14, the electronic device can determine the center coordinate #1 of the rectangle frame #1 corresponding to the “level”, and determine the center coordinate #2 of the rectangle frame #2 corresponding to the “part”. The rectangle frame #1 and the rectangle frame #2 have an overlapping area, and the overlapping area includes stroke 1. The electronic device can determine the average coordinate corresponding to stroke 1 respectively. The distance between the average coordinate corresponding to stroke 1 and the center coordinate #1 is greater than the distance between the center coordinate #2, so the electronic device can determine that stroke 1 belongs to “part”.
[0224] Through the above description for FIGS. 4-14, the electronic device can determine the coordinates of the rectangle frame corresponding to character #1, the rectangle frame corresponding to character #2, and the strokes in the overlapping area according to the positional relationship between character #1 and character #2.
[0225] For example, when character #1 and character #2 are distributed left and right, the electronic device can determine the center horizontal coordinates of the rectangle frame corresponding to character #1 and the rectangle frame corresponding to character #2, and determine the average horizontal coordinates of the strokes in the overlapping area.
[0226] For another example, when character #1 and character #2 are distributed left and right, character #1 is on the left side of character #2, and the horizontal length of the rectangle frame corresponding to character #1 and / or the rectangle frame corresponding to character #2 is greater than threshold #2, the electronic device can determine the horizontal coordinates of the right side frame of the rectangle frame corresponding to character #1, the horizontal coordinates of the left side frame of the rectangle frame corresponding to character #2, and the average horizontal coordinates of the strokes in the overlapping area.
[0227] For another example, when character #1 and character #2 are distributed up and down, the electronic device can determine the center vertical coordinates of the rectangle frame corresponding to character #1 and the rectangle frame corresponding to character #2, and determine the average vertical coordinates of the strokes in the overlapping area.
[0228] For another example, when character #1 and character #2 are diagonally distributed, the electronic device can determine the center coordinates of the rectangle frame corresponding to character #1 and the rectangle frame corresponding to character #2, and determine the average coordinates of the strokes in the overlapping area.
[0229] After determining the coordinates of the rectangular frame corresponding to character #1, the rectangular frame corresponding to character #2, and the strokes in the overlapping region, the electronic device can determine the ownership of the strokes in the overlapping region according to the distance relationship between the coordinates of the rectangular frame corresponding to character #1, the rectangular frame corresponding to character #2, and the strokes in the overlapping region, and the writing attributes of character #1 and character #2. For details, please refer to the foregoing description.
[0230] In some embodiments, content #1 further includes one or more patterns, as shown in FIG. 4, and the method further includes:
[0231] S460, identifying N strokes corresponding to the one or more patterns.
[0232] When identifying content #1, the electronic device can divide the strokes into strokes belonging to characters and strokes belonging to patterns. Therefore, when content #1 includes one or more patterns, the electronic device can identify N strokes belonging to the one or more patterns, where N≥2 and N is an integer.
[0233] The method for the electronic device to identify the type of strokes is not specifically limited in the embodiments of the present application. For example, a graphical neural network (GNN) can be trained, and the electronic device can input content #1 into the GNN, so as to identify the category of each stroke in content #1.
[0234] S470, dividing the N strokes into M stroke groups according to the positional relationship of the N strokes.
[0235] After identifying the N strokes, the electronic device can divide the N strokes into M stroke groups according to the positional relationship between the N strokes, where N≥M≥1 and M is an integer. A stroke group can be understood as a set of strokes corresponding to the same pattern.
[0236] It should be noted that when M≥2, the distance between any two strokes in the M groups is greater than or equal to a threshold value #3. The method for dividing groups according to the distance relationship between strokes will be introduced below.
[0237] FIG. 15 shows a schematic flowchart of a method for dividing stroke groups according to an embodiment of the present application. The method can be executed by an electronic device, or by a component (for example, a processor, a chip system, etc.) of the electronic device. In the following, the execution subject is taken as an example to introduce the electronic device, which can aggregate multiple strokes into a stroke group according to the spatial distance between the strokes, as shown in FIG. 14. The method includes:
[0238] S1510, creating a new stroke group.
[0239] The electronic device initializes the stroke grouping in step S1510, i.e. there are no strokes in the created new stroke grouping.
[0240] S1520, taking out the ungrouped strokes s i .
[0241] Since the electronic device can recognize the strokes of the pattern, the ungrouped strokes s i can be taken out. i .
[0242] S1530, determining a primary new stroke grouping.
[0243] The electronic device can take the strokes s i as elements in the primary new stroke grouping.
[0244] S1540, storing the current grouping.
[0245] When the electronic device determines that new elements are added to the primary new stroke grouping, the added elements can be added to the current stroke grouping.
[0246] S1550, searching for strokes with a distance less than or equal to threshold #3 from s i .
[0247] S1560, determining a secondary new stroke grouping according to the search result.
[0248] After the electronic device takes out the strokes s i in the primary new stroke grouping, it can search for strokes with a distance less than threshold #3 from the stroke s i , and determine the stroke s i and the strokes with a distance less than threshold #3 from the stroke as the secondary new stroke grouping.
[0249] It can be understood that when there are no strokes with a distance less than threshold #3 from the stroke s i , the secondary new stroke grouping can be an empty set.
[0250] S1570, whether the secondary new stroke grouping has strokes.
[0251] When the electronic device determines that the secondary new stroke grouping includes strokes, it can execute step S1580, and when it determines that the secondary new stroke grouping does not include strokes, it can execute step S1510 again.
[0252] S1580, determining that the secondary new stroke grouping is a new primary new stroke grouping.
[0253] When the electronic device determines that the secondary new stroke group includes a stroke, the electronic device can determine that the secondary new stroke group is a new primary new stroke group, and then store the strokes in the new primary new stroke group into the current stroke group, and perform steps S1540-S1560 cyclically.
[0254] It can be understood that, since the primary new stroke group after replacement adds strokes, the electronic device can continue to search for strokes with a distance less than threshold #3 from the added strokes to finally determine a stroke group. In other words, the method for dividing stroke groups provided by the embodiments of the present application can be understood as a depth search algorithm, that is, a stroke is first determined as a root node, and then strokes with a distance less than threshold #3 from the root node are searched as primary child nodes, and then strokes with a distance less than threshold #3 from the primary child nodes are searched as secondary child nodes, and so on. The electronic device can establish a tree relationship diagram, and the strokes associated with the tree relationship diagram are strokes in the same stroke group. The following will be described in combination with FIG. 16.
[0255] FIG. 16 shows a stroke group diagram provided by the embodiments of the present application.
[0256] As shown in (a) and (b) of FIG. 16, the electronic device identifies that the strokes of the pattern include stroke 1-stroke 13. After the electronic device identifies the strokes, the electronic device can create a new stroke group #1, and the electronic device can determine that stroke 1 is an element in the newly created stroke group #1, and stroke 1 is taken as a root node. The electronic device searches for strokes with a distance less than threshold #3 from stroke #1, which are stroke 2, stroke 3, stroke 4, and stroke 5, so that the electronic device can add stroke 2, stroke 3, stroke 4, and stroke 5 to the newly created stroke group #1, and take stroke 2, stroke 3, stroke 4, and stroke 5 as primary child nodes. Since stroke 2, stroke 3, stroke 4, and stroke 5 are added, the electronic device can continue to search for strokes with a distance less than threshold #3 from stroke 2, stroke 3, stroke 4, and stroke 5. In this search, stroke 6 can be added, and stroke 6 is taken as a secondary child node. Similarly, the electronic device can continue to search for strokes with a distance less than threshold #3 from stroke #6. In this search, stroke 7 can be added, and stroke 6 is taken as a tertiary child node. Similarly, the electronic device can continue to search for strokes with a distance less than threshold #3 from stroke #7. In this search, stroke 8 can be added, and stroke 8 is taken as a quaternary child node. Similarly, the electronic device can continue to search for strokes with a distance less than threshold #3 from stroke #8. Since no new stroke with a distance less than threshold #3 from stroke #8 is searched, this search is ended, and then it can be determined that stroke 1-stroke 8 is a stroke group, and the tree relationship diagram formed by stroke 1-stroke 8 is shown in (b) of FIG. 16.
[0257] Similarly, electronic devices can identify strokes 9-13 as a stroke group, and the tree relationship diagram formed by strokes 9-13 is shown in Figure 16(c).
[0258] In the embodiments of this application, the strokes in a stroke group can be understood as strokes belonging to the same pattern. The electronic device can quickly determine the strokes included in a pattern by dividing the stroke groups.
[0259] In some embodiments, as shown in FIG17, S1550, the search and s i Strokes whose distance is less than threshold #3 include:
[0260] S1551, based on the stroke s i The sliding window w is determined by threshold #3. i .
[0261] Electronic devices can use strokes s i The corresponding rectangle is used as a reference, and then expanded outward by a distance of threshold #3. This expanded rectangle is then used to define the sliding window w. i .
[0262] S1552, based on the sliding window w i Determine the stroke set.
[0263] Electronic devices can slide windows w i The covered strokes are identified as elements in a stroke set. This stroke set may include one or more strokes.
[0264] It should be noted that the sliding window w i The covered strokes can include a sliding window w i A fully covered stroke can also include a sliding window w i Partially covered strokes.
[0265] S1553, Calculate the number of strokes s in the stroke set. i j With strokes s i The distance d between i j .
[0266] S1554,d i j Is it less than or equal to threshold #3?
[0267] Electronic devices can sequentially calculate the strokes and strokes s in the stroke set. i The distance between them is determined, and it is determined whether the distance is less than or equal to the threshold #3. When it is determined that the distance is less than or equal to the threshold #3, step S1555 is executed.
[0268] S1555, the stroke si j store the strokes in the second new stroke group.
[0269] The electronic device can sequentially calculate the distance between all strokes in the stroke set and the stroke s i , and store the strokes in the stroke set whose distance to the stroke s i is less than the threshold #3 in the second new stroke group.
[0270] It can be understood that in the embodiments of the present application, one or more strokes with a relatively short distance to the stroke s i can be quickly screened out through the sliding window first, and then the distance between the stroke s i and the one or more strokes is calculated, so that a stroke group can be quickly determined.
[0271] As described above, in some embodiments, the distance between the strokes in any two stroke groups in the M stroke groups is greater than the threshold #3.
[0272] In the embodiments of the present application, the electronic device can divide the strokes into different stroke groups according to the distance relationship between the strokes of the pattern, so that the user can quickly select a complete pattern when selecting a pattern.
[0273] In some embodiments, after the electronic device divides the N strokes into M stroke groups, the electronic device can further divide one stroke group into multiple stroke groups according to the writing interval between the strokes, as shown in FIG. 4, the method further includes:
[0274] S480, dividing the first stroke group into Q stroke groups according to the writing interval of the P strokes.
[0275] The electronic device can divide the N strokes into M stroke groups, and the M stroke groups include a first stroke group, and the first stroke group includes P strokes. The electronic device can further divide the P strokes into Q stroke groups according to the writing interval of the P strokes, and Q≥1 and Q is an integer.
[0276] The writing interval of the strokes in the embodiments of the present application refers to the time interval between two strokes adjacent in writing order, and the writing interval of the strokes can also be referred to as the writing time interval of the strokes, which will be described below.
[0277] For example, stroke #1 and stroke #2 are strokes adjacent in writing order, that is, the user first writes stroke #1 and then writes stroke #2, and the writing interval of stroke #1 and stroke #2 refers to the difference between the time of starting to write stroke #2 and the time of ending to write stroke #1.
[0278] The method of dividing groups according to the writing interval of the strokes will be described below.
[0279] FIG. 18 shows a schematic flowchart of a method for dividing stroke groups, which can be executed by an electronic device or by a component (e.g., a processor, a chip system, etc.) of the electronic device. As shown in FIG. 18, the method includes the following steps:
[0280] S1810, ordering strokes in the stroke group #1 according to writing order.
[0281] The stroke group #1 is one of the M stroke groups, and the stroke group #1 includes one or more strokes. The electronic device can order the one or more strokes according to the writing order of the one or more strokes.
[0282] S1820, calculating the writing interval between two adjacent strokes in the stroke group #1.
[0283] After ordering the strokes in the stroke group #1 according to the writing order, the electronic device can calculate the writing interval between two adjacent strokes.
[0284] For example, the strokes in the stroke group #1 are ordered according to the writing order as stroke #1, stroke #2, stroke #3, and stroke #4. The electronic device can calculate the writing interval between stroke #1 and stroke #2, the writing interval between stroke #2 and stroke #3, and the writing interval between stroke #3 and stroke #4, respectively.
[0285] In the present embodiment, the electronic device can calculate the writing interval between two strokes in the following possible implementation manners.
[0286] In one possible implementation manner, each stroke is associated with a timestamp, which records the time when the stroke is written. The electronic device can calculate the writing interval between two adjacent strokes according to the timestamps.
[0287] In one possible implementation manner, the electronic device can assign a time value to each stroke, and use the time value as the time when the stroke is written. The electronic device can calculate the writing interval between two adjacent strokes according to the time values.
[0288] S1830, determining the writing interval greater than the threshold value #4.
[0289] It can be understood that, when the user draws a pattern, the writing interval between two strokes adjacent in writing order should be relatively short. If the writing interval between two strokes adjacent in writing order is relatively long, it indicates that the two strokes adjacent in writing order can belong to two different patterns. Therefore, the electronic device can calculate one or more writing intervals corresponding to the stroke grouping #1, and the electronic device can find a writing interval greater than the threshold value #4 in the one or more writing intervals.
[0290] For example, the strokes in the stroke grouping #1 are sorted in the order of writing as stroke #1, stroke #2, stroke #3, and stroke #4, and the electronic device calculates the writing interval between stroke #1 and stroke #2 as writing interval #1, the writing interval between stroke #2 and stroke #3 as writing interval #2, and the writing interval between stroke #3 and stroke #4 as writing interval #3. Among them, the writing interval #1 and the writing interval #3 are less than or equal to the threshold value #4, and the writing interval #2 is greater than the threshold value #4.
[0291] S1840, dividing the stroke grouping #1 into a plurality of stroke clusters according to the writing interval greater than the threshold value #4.
[0292] After the electronic device determines the writing interval greater than the threshold value #4, the electronic device can divide the stroke grouping #1 as a division point to divide the stroke grouping #1 into a plurality of stroke clusters, and each of the plurality of stroke clusters can include one or more strokes.
[0293] For example, the strokes in the stroke grouping #1 are sorted in the order of writing as stroke #1, stroke #2, stroke #3, and stroke #4, and the electronic device calculates the writing interval between stroke #1 and stroke #2 as writing interval #1, the writing interval between stroke #2 and stroke #3 as writing interval #2, and the writing interval between stroke #3 and stroke #4 as writing interval #3. Among them, the writing interval #1 and the writing interval #3 are less than or equal to the threshold value #4, and the writing interval #2 is greater than the threshold value #4. The electronic device can divide the stroke grouping #1 as a division point, where stroke #1 and stroke #2 are stroke cluster #1, and stroke #3 and stroke #4 are stroke cluster #2.
[0294] In some embodiments, after performing step S1840, the electronic device can perform step S1850, or can also perform step S1860.
[0295] S1850, determining the plurality of stroke clusters as new stroke groupings.
[0296] The electronic device can split the stroke group #1 into a plurality of stroke clusters and take the plurality of stroke clusters as a new stroke group. In other words, the electronic device can divide the stroke group #1 into a plurality of stroke groups according to the writing intervals of the strokes in the stroke group #1.
[0297] S1860, calculate the distance between stroke cluster c i and other stroke clusters.
[0298] After the electronic device divides the stroke group #1 into a plurality of stroke clusters, the electronic device can calculate the distance between stroke cluster c i and other stroke clusters.
[0299] For example, the electronic device divides the stroke group #1 into stroke cluster #1, stroke cluster #2, and stroke cluster #3. The electronic device can calculate the distance between stroke cluster #1 and stroke cluster #2, and calculate the distance between stroke cluster #1 and stroke cluster #3, respectively.
[0300] In some embodiments, the distance between stroke clusters can be the shortest distance between stroke clusters, that is, the distance corresponding to the closest stroke pair in the two stroke clusters.
[0301] S1870, stroke cluster c i is greater than threshold #5.
[0302] When the electronic device determines that the minimum value in the distance between stroke cluster c i and other stroke clusters is greater than threshold #5, step S1780 can be performed. When it is determined that the minimum value in the distance between stroke cluster c i and other stroke clusters is less than or equal to threshold #5, i+ can be made equal to 1 and step S1760 can be performed again, that is, the distance between stroke cluster c i+1 and other stroke clusters is calculated.
[0303] In some embodiments, threshold #5 is less than threshold #3.
[0304] S1880, whether there are still stroke clusters other than stroke cluster c i in stroke group #1.
[0305] When the electronic device determines that the minimum value in the distance between stroke cluster c i and other stroke clusters is greater than threshold #5, it can also be determined whether there are still stroke clusters other than stroke cluster c i in stroke group #1. When it is determined whether there are still stroke clusters other than stroke cluster c i in stroke group #1, step S1790 can be performed.
[0306] S1890, determine stroke cluster c i as a new stroke group.
[0307] The electronic device determines the stroke cluster c i When the minimum value in the distances to other stroke clusters is greater than the threshold #5 and the stroke grouping #1 has other stroke clusters, the stroke cluster c i is removed from the stroke grouping #1 and determined as a new stroke grouping.
[0308] In summary, the electronic device can divide the first grouping in the M stroke groupings into Q stroke groups according to the method shown in FIG. 17.
[0309] FIG. 19 shows a schematic diagram of dividing stroke groupings according to an embodiment of the present application.
[0310] As shown in FIG. 19, the content displayed by the electronic device includes a pattern #1 and a pattern #2. Since the pattern #1 and the pattern #2 are relatively close, the electronic device can divide the strokes of the pattern #1 and the pattern #2 into the same stroke grouping, denoted as stroke grouping #1, when dividing groupings according to the distance relationship of the strokes of the pattern #1 and the pattern #2. The pattern #1 includes strokes 1, 2, 3, and 4, and the pattern #2 includes strokes 5 and 6. The electronic device can sort the strokes according to the order of writing, and the sorting result is strokes 5, 6, 1, 2, 3, and 4. The electronic device can calculate the writing interval between strokes 5 and 6, the writing interval between strokes 6 and 1, the writing interval between strokes 1 and 2, the writing interval between strokes 2 and 3, and the writing interval between strokes 3 and 4, respectively.
[0311] When the electronic device determines that the writing interval between strokes 6 and 1 is greater than the threshold #4, the electronic device can divide the stroke grouping #1 into stroke cluster #1 and stroke cluster #2, and then take the stroke cluster #1 and the stroke cluster #2 as new stroke groupings, i.e., divide the stroke grouping #1 into two new stroke groupings, where the stroke cluster #1 includes strokes 5 and 6, and the stroke cluster #2 includes strokes 1, 2, 3, and 4.
[0312] When the electronic device determines that the writing interval between strokes 6 and 1 is greater than the threshold #4, the electronic device can divide the stroke grouping #1 into stroke cluster #1 and stroke cluster #2, and then calculate the distance between the stroke cluster #1 and the stroke cluster #2, and when the distance between the stroke cluster #1 and the stroke cluster #2 is greater than the threshold #5, take the stroke cluster #1 and the stroke cluster #2 as new stroke groupings.
[0313] As can be appreciated, when the electronic device divides the strokes into stroke groups according to the distance relationship between the strokes of the pattern, the electronic device can attribute the pattern #1 and the pattern #2 in FIG. 19 to the same stroke group. At this time, if the user only wants to select the pattern #1, the electronic device can select the pattern #2 synchronously. Therefore, the electronic device can further divide the stroke group #1 into two stroke groups according to the writing interval between the strokes, so that the pattern #1 corresponds to one stroke group and the pattern #2 corresponds to another stroke group. At this time, if the user only wants to select the pattern #1, since the pattern #1 and the pattern #2 belong to different stroke groups, the electronic device will not select the pattern #2 synchronously.
[0314] As can be appreciated from the above description, in some embodiments, the writing interval of two stroke groups adjacent in writing order in the Q stroke groups is greater than the threshold #4.
[0315] It should be noted that the writing interval of the stroke group in the embodiments of the present application refers to the time interval between two stroke groups adjacent in writing order.
[0316] For example, the stroke group #1 and the stroke group #2 are stroke groups adjacent in writing order, the user first writes the stroke group #1, and then writes the stroke group #2. The writing interval of the stroke group #1 and the stroke group #2 refers to the difference between the time of starting to write the stroke group #2 and the time of ending to write the stroke group #1.
[0317] In some embodiments, the distance between any two stroke groups in the Q stroke groups is greater than and can be greater than the threshold #5.
[0318] In the embodiments of the present application, the electronic device can first group the strokes of the pattern according to the distance relationship between the strokes, so that the strokes with a closer distance can belong to the same stroke group, and then can further divide a stroke group into multiple new stroke groups according to the writing interval of the strokes in the stroke group, thereby refining the granularity of the grouping and avoiding the problem of multiple selection of strokes when the user selects the pattern.
[0319] In some embodiments, after the electronic device divides the M strokes into Q stroke groups, the electronic device can further aggregate multiple stroke groups into one stroke group according to the writing interval between the stroke groups, as shown in FIG. 4, the method further includes:
[0320] S490, aggregating the Q stroke groups into W stroke groups according to the writing interval of the Q stroke groups and the distance relationship of the Q stroke groups.
[0321] The electronic device can first divide the first stroke group into Q stroke groups, and then can aggregate the Q stroke groups into W stroke groups according to the writing interval of the Q stroke groups and the distance relationship of the Q stroke groups, Q≥W≥1 and P is an integer.
[0322] The following section will introduce a method for grouping strokes based on their writing intervals.
[0323] Figure 20 shows a schematic flowchart of the method for grouping aggregated strokes provided in an embodiment of this application. This method can be executed by an electronic device or by a component of the electronic device (e.g., a processor, a chip system, etc.). The following description takes an electronic device as the executing entity. As shown in Figure 20, the method includes:
[0324] S2010, sort the Q strokes into groups according to the order in which they were written.
[0325] An electronic device can sort Q groups of strokes according to the order in which they were written, and the sorting result is denoted as {G0, G1, ..., G...}. Q}
[0326] S2020, calculates the writing interval between two consecutive stroke groups.
[0327] After the electronic device sorts the Q stroke groups according to the order in which they were written, it can calculate the writing interval between two adjacent stroke groups.
[0328] When calculating the writing interval between two adjacent stroke groups, electronic devices can determine the start time for writing the next stroke group; this time is denoted as t. i+1 start And determine the end time of writing the previous stroke group, which is denoted as t. i end Then the writing interval between the two stroke groups is δi = t i+1 start -t i end The calculation results of the electronic device can be denoted as {δ0, δ1, ... δ...} Q-1}
[0329] In some embodiments, the writing interval between two stroke groups can be less than 0.
[0330] S2030, is the minimum writing interval between stroke groups less than or equal to threshold #6?
[0331] Electronic devices can determine {δ0, δ1, ... δ Q-1 If the minimum value in the expression is less than or equal to the threshold #6, step S2040 can be executed. If the minimum value is greater than the threshold #6, aggregation can be stopped.
[0332] S2040, from {G0, G1, ... G...} Q Extract G from}i .
[0333] It should be understood that when the electronic device executes step S1940 for the first time, i can be equal to 0.
[0334] S2050, from {G i+1 G i+2 , ...G Q Extract G from} j And calculate G i With G j The writing interval.
[0335] It should be understood that when the electronic device executes step S2050 for the first time, since i can be equal to 0, j can be equal to 1.
[0336] It should also be understood that, for the calculation of G i With G j The description of the writing interval can be found above, and for the sake of brevity, it will not be repeated here. G i With G j The writing interval is denoted as δ ij .
[0337] S2060, 0≤δ ij ≤threshold #6 and G j It has not yet been merged.
[0338] When the electronic device determines that the condition in step S2060 is met, it can execute step S2070. When it determines that S2060 is not met, it can set j+=1 and execute step S2050 again.
[0339] S2070, Calculate G i With G j minimum distance d ij .
[0340] Among them, calculating G i With G j minimum distance d ij It is understandable to calculate G i The strokes in G j The distance between each stroke is calculated, and then the smallest distance is selected as G. i With G j The minimum distance.
[0341] S2080, d ij Is it less than or equal to threshold #7?
[0342] Electronic devices can determine G i With G j minimum distance d ijWhen the minimum distance d i between G j and G ij is greater than threshold #7, j+ can be set to 1 and step S2050 can be executed again.
[0343] In some embodiments, threshold #7 can be greater than threshold #3.
[0344] S2090, G i and G j are aggregated into a group.
[0345] When the minimum distance between G i and G j is less than or equal to threshold #7, G i and G j can be aggregated into a stroke group.
[0346] S20100, G j is the last stroke group.
[0347] When G j is the last stroke group in {G i+1 , G i+2 , …, G Q}, i+ can be set to 1 and step S2040 can be executed again. When G j is not the last stroke group in {G i+1 , G i+2 , …, G Q}, j+ can be set to 1 and step S2050 can be executed again.
[0348] It should be noted that S20100 is not only executed after S2090, but also executed after j+1 to determine whether the stroke groups in {G i+1 , G i+2 , …, G Q} have been traversed. When G jj after j+1 is the last stroke group in {G i+1 , G i+2 , …, G Q}, i+ can be set to 1 and step S2040 can be executed again.
[0349] FIG. 21 shows a schematic diagram of aggregating stroke groups according to an embodiment of the present application.
[0350] As shown in FIG. 21, the content displayed by the electronic device includes strokes 1-9. The electronic device can first group the strokes into 3 groups, stroke group #1, stroke group #2, and stroke group #3, according to the method shown in FIGS. 15 and 16, where stroke group #1 includes strokes 1 and 2, stroke group #2 includes strokes 3, 4, 5, 6, and 7, and stroke group #3 includes strokes 8 and 9. The electronic device can order the stroke groups according to the order in which they were written, resulting in the order stroke group #1, stroke group #2, and stroke group #3. The electronic device can calculate the writing gap between stroke group #1 and stroke group #2 and the writing gap between stroke group #2 and stroke group #3.
[0351] Assuming the writing gap between stroke group #1 and stroke group #2 is less than threshold #6 and the writing gap between stroke group #2 and stroke group #3 is less than threshold #6.
[0352] According to the method shown in FIG. 20, the electronic device can first take stroke group #1 from {stroke group #1, stroke group #2, stroke group #3} and stroke group #2 from {stroke group #2, stroke group #3}, and since the writing gap between stroke group #1 and stroke group #2 is less than threshold #6 and stroke group #2 has not yet been merged, the electronic device can calculate the minimum distance between stroke group #1 and stroke group #2. Assuming the minimum distance between stroke group #1 and stroke group #2 is less than threshold #7, the electronic device can aggregate stroke group #1 and stroke group #2.
[0353] Since stroke group #2 is not the last group in {stroke group #2, stroke group #3}, the electronic device can calculate the writing gap between stroke group #1 and stroke group #3. Assuming the writing gap between stroke group #1 and stroke group #3 is less than threshold #6, the electronic device can calculate the minimum distance between stroke group #1 and stroke group #3, and assuming the minimum distance between stroke group #1 and stroke group #3 is greater than threshold #7, the electronic device will not aggregate stroke group #1 and stroke group #3 into the same stroke group.
[0354] Since stroke group #3 is the last group in {stroke group #2, stroke group #3}, the electronic device has determined the writing interval and distance relationship between stroke group #1 and all other stroke groups, the electronic device can continue to determine the next stroke group, that is, the electronic device takes stroke group #2 from {stroke group #1, stroke group #2, stroke group #3}, and takes stroke group #3 from {stroke group #3}. Since the writing interval between stroke group #2 and stroke group #3 is less than threshold #6, the electronic device can calculate the minimum distance between stroke group #2 and stroke group #3. Assuming that the minimum distance between stroke group #2 and stroke group #3 is less than threshold #7, the electronic device can aggregate stroke group #2 and stroke group #3.
[0355] Since the electronic device aggregates stroke group #1 and stroke group #2 into the same stroke group, and aggregates stroke group #2 and stroke group #3 into the same stroke group, the electronic device can finally aggregate stroke group #1, stroke group #2 and stroke group #3 into the same stroke group.
[0356] As can be understood, when the electronic device divides stroke groups according to the distance between the strokes of the pattern and the writing interval of the strokes, the electronic device will divide the strokes in FIG. 21 into 3 stroke groups, but in essence, the strokes shown in FIG. 21 belong to the same pattern, at this time, if the user wants to select the pattern, the electronic device may miss the strokes in the pattern. Therefore, the electronic device can also aggregate the 3 stroke groups into the same stroke group according to the writing interval and distance relationship between the stroke groups, at this time, if the user wants to select the pattern, since the strokes in FIG. 21 belong to the same stroke group, the electronic device will not miss the strokes in the pattern.
[0357] Through the above description, in some embodiments, the writing interval of two stroke groups adjacent in writing order in the multiple stroke groups aggregated into the same stroke group in the Q stroke groups is less than or equal to threshold #6 and the distance is less than or equal to threshold #7.
[0358] In the embodiments of the present application, the electronic device can first group the strokes of the pattern according to the distance relationship between the strokes, so that the strokes with close distance can belong to the same stroke group, and then can further divide a stroke group into multiple new stroke groups according to the writing interval of the strokes in the stroke group, and then aggregate the stroke groups again according to the writing interval and distance relationship between the stroke groups, thereby avoiding the problem of missing strokes when the user selects the pattern.
[0359] In some embodiments, as shown in FIG. 4, the method further includes:
[0360] S4100, identifying a field and / or a pattern in content #1.
[0361] In some embodiments, the field recognized by the electronic device can correspond to a line of text.
[0362] In some embodiments, the field recognized by the electronic device can correspond to a paragraph of text.
[0363] In some embodiments, the image recognized by the electronic device corresponds to a complete pattern.
[0364] The field and the pattern in the embodiments of the present application can correspond to a rectangular box, which can enclose the field and the pattern.
[0365] FIG. 22 shows a schematic diagram of columnarizing content according to an embodiment of the present application.
[0366] As shown in (a) of FIG. 22, the content #1 includes fields 1-14, pattern 1 and pattern 2.
[0367] With reference to (a) of FIG. 22, since the surrounding line and the underline included in the content #1 are associated with text, the electronic device can regard the surrounding line and the underline as part of the field when recognizing the field and the pattern. In other words, in some embodiments, the field recognized by the electronic device can include the underline and the surrounding line.
[0368] In other embodiments, the electronic device can also regard the surrounding line and the underline as the pattern. In other words, in some embodiments, the field recognized by the electronic device can not include the underline and the surrounding line, but regard the underline and the surrounding line as the pattern.
[0369] S4110, dividing the content #1 into one or more area blocks according to the positional relationship and the writing order of the fields and / or the patterns.
[0370] In some embodiments, the writing order of the strokes in each area block follows the writing principle of from left to right and then from top to bottom. The method of dividing area blocks provided by the embodiments of the present application will be described below with reference to FIG. 23.
[0371] FIG. 23 shows a schematic flowchart of the method of dividing area blocks provided by the embodiments of the present application, which can be executed by the electronic device or the components (e.g., the processor, the chip system, etc.) of the electronic device. Hereinafter, the execution subject is taken as the electronic device for example, as shown in FIG. 23, the method includes:
[0372] S2310, sorting the fields and / or the patterns according to the writing order of the strokes.
[0373] As described above, the electronic device can recognize the fields and / or patterns in content #1, and then sort the fields and / or patterns according to the writing order of the strokes. The sorting result is denoted as {P1, P2, ..., P...}. i Each element in the} represents a field or pattern.
[0374] S2320, add P1 to area block D1, and iterate through the remaining fields and / or patterns.
[0375] S2330, P i With P i-1 Do the x-coordinates overlap and P? i Is it located at P? i-1 Below.
[0376] As described above, each field and pattern corresponds to a rectangle, allowing the electronic device to determine P. i The x-coordinate of the corresponding rectangle and P i-1 Whether the x-coordinates of the corresponding rectangles overlap, and determine P. i Is it located at P? i-1 Below, when P is determined i The x-coordinate of the corresponding rectangle and P i-1 The horizontal coordinates of the corresponding rectangles overlap and P i Located at P i-1 When the following is true, step S2350 can be executed. When P is determined... i The x-coordinate of the corresponding rectangle and P i-1 The x-coordinates of the corresponding rectangles do not overlap and / or P i Not located in P i-1 When proceeding to the next step, step S2340 can be executed.
[0377] In this embodiment, there are three positional relationships between the rectangular frames of the fields and / or patterns: overlapping horizontal coordinates, overlapping vertical coordinates, and non-overlapping horizontal and vertical coordinates. As shown in Figure 24(a), rectangle #1 is the rectangle corresponding to field #1, and rectangle #2 is the rectangle corresponding to field #2. Since the horizontal coordinates of rectangle #1 and rectangle #2 are the same, their horizontal coordinates can be considered to overlap. Similarly, as shown in Figure 24(b), since the vertical coordinates of rectangle #1 and rectangle #2 are the same, their vertical coordinates can be considered to overlap. As shown in Figure 24(c), since the horizontal and vertical coordinates of rectangle #1 and rectangle #2 are not the same, their horizontal and vertical coordinates can be considered to non-overlapping.
[0378] S2340, P i With P i-1 Do the ordinates overlap and P?i Is located in P i-1 Right.
[0379] It should be understood that the detailed description for S2340 can refer to the description for S2330, which will not be repeated here for brevity.
[0380] When it is determined that P i The longitudinal coordinate of the corresponding rectangular frame overlaps with P i-1 The longitudinal coordinate of the corresponding rectangular frame overlaps with P i Is located in P i-1 Right, step S2350 can be performed, when it is determined that P i The longitudinal coordinate of the corresponding rectangular frame does not overlap with P i-1 The longitudinal coordinate of the corresponding rectangular frame does not overlap with P i Is not located in P i-1 Right, step S2360 can be performed.
[0381] It should be noted that in some other embodiments of the present application, the execution order of step S2330 and step S2340 can be reversed, that is, step S2340 is executed first, when it is determined that the condition in step S2340 is met, the electronic device executes step S2350, when it is determined that the condition in step S2340 is not met, the electronic device executes step S2330. When the electronic device executes step S2330, when it is determined that the condition in step S2330 is met, the electronic device executes step S2350, when it is determined that the condition in step S23330 is not met, the electronic device executes step S2360.
[0382] S2350, P i and P i-1 Whether the distance between them is less than a threshold value #8.
[0383] The electronic device can execute step S2370 when it is determined that the distance between P i and P i-1 is less than a threshold value #8, and execute step S23260 when it is determined whether the distance between P i and P i-1 is greater than or equal to a threshold value #8.
[0384] S2360, P i is added to a new region block D j+1 .
[0385] When P i and P i-1 do not overlap in horizontal and longitudinal coordinates, the electronic device can add P i to a new region block D j+1 .
[0386] S2370, Pi P i-1 located in the region block.
[0387] When P i is located to the right of P i-1 and the longitudinal coordinate of P i overlaps with the longitudinal coordinate of P i-1 , or when P i is located below P i-1 and the horizontal coordinate of P i overlaps with the horizontal coordinate of P i-1 , the electronic device can add P i to the region block in which P i-1 is located.
[0388] By the method shown in FIG. 23, the electronic device can traverse {P2, …, P i} to determine the region block corresponding to each field and pattern. An exemplary description is made below in conjunction with FIG. 22. Assume that the writing order of field 1- field 14, pattern 1 and pattern 2 in FIG. 22 is field 1, field 2, pattern 1, field 3, field 4, field 5, field 6, field 7, field 8, field 9, pattern 2, field 10, field 11, field 12, field 13 and field 14. The electronic device can add field 1 to region block #1, and then traverse from field 14.
[0389] Since the horizontal coordinate of field 14 overlaps with the horizontal coordinate of field 13 and field 14 is located below field 13, and the distance between them is less than threshold #8, the electronic device can add field 14 to the region block to which field 13 belongs.
[0390] Since the horizontal coordinate of field 13 overlaps with the horizontal coordinate of field 12 and field 13 is located below field 12, and the distance between them is less than threshold #8, the electronic device can add field 13 to the region block to which field 12 belongs.
[0391] Since the horizontal coordinate of field 12 overlaps with the horizontal coordinate of field 11 and field 12 is located below field 11, and the distance between them is less than threshold #8, the electronic device can add field 12 to the region block to which field 11 belongs.
[0392] Since the horizontal coordinate of field 11 overlaps with the horizontal coordinate of field 10 and field 11 is located below field 10, and the distance between them is less than threshold #8, the electronic device can add field 11 to the region block to which field 10 belongs.
[0393] Since the horizontal and vertical coordinates of the field 10 and the field pattern 2 do not overlap, the electronic device can determine that the field 10 is added to a new area block, and since the field 11 has been added to the area block of the field 10, the field 12 is added to the area block of the field 11, the field 13 is added to the area block of the field 12, and the field 14 is added to the area block of the field 13, therefore, the fields 10-14 can belong to the same area block.
[0394] According to the above division method, as shown in (b) of FIG. 22, the electronic device can divide the content #1 shown in FIG. 21 into four area blocks, namely, an area block #1, an area block #2, an area block #3, and an area block #4, wherein the area block #1 includes the fields 1, 2, the pattern 1, the fields 3, 4, and 5, the area block #2 includes the fields 6, 7, 8, and 9, the area block #3 includes the pattern 2, and the area block #4 includes the fields 10, 11, 12, 13, and 14.
[0395] It can be understood that the strokes of the fields and / or patterns in each area block satisfy the order from left to right and from top to bottom.
[0396] S4120, according to the positional relationship of one or more area blocks, the content #1 is columned to obtain one or more columns.
[0397] The electronic device can determine to divide the content #1 into one or more area blocks by performing step S4110, denoted as {D1, D2, …, D i The electronic device can determine the number of columns of the content #1 and to which column each area block belongs according to the positional relationship of each area block, thereby completing the columnation of the content #1, that is, obtaining one or more columns.
[0398] FIG. 25 shows a schematic flowchart of a method for columnating content according to the positional relationship of area blocks provided by the embodiments of the present application, which can be executed by an electronic device, or by a component (for example, a processor, a chip system, etc.) of the electronic device, and hereinafter, the execution subject is taken as an example to be introduced, as shown in FIG. 25, the method includes:
[0399] S2510, determining an area block set #1.
[0400] After the electronic device divides the content #1 into multiple area blocks, the area block set #1 is determined.
[0401] S2520, generating an area block set #2 by shrinking the area blocks in the area block set #1 in the horizontal direction.
[0402] Since the lines may be uneven when the user writes, the electronic device can generate a set of region blocks #2 by shrinking the region blocks in the set of region blocks #1 in the horizontal direction.
[0403] For example, as shown in (c) of FIG. 21, region block #1 can generate region block #5 after being shrunk in the horizontal direction, region block #2 can generate region block #6 after being shrunk in the horizontal direction, region block #3 can generate region block #7 after being shrunk in the horizontal direction, and region block #4 can generate region block #8 after being shrunk in the horizontal direction.
[0404] It should be noted that if the rectangular frames corresponding to the region blocks in the set of region blocks #1 can be aligned in the horizontal direction, the electronic device can not perform step S2520, but directly perform step S2530.
[0405] It should be further noted that the rectangular frames corresponding to the region blocks in the set of region blocks #1 being aligned in the horizontal direction can be understood as the rectangular frames corresponding to the region blocks being aligned in the horizontal direction within an allowable error range. In other words, the horizontal coordinates of the left and right frames of two region blocks in an up-down relationship are equal or the difference is within an allowable error range.
[0406] S2530, calculating the vertical projection of the region blocks in the set of region blocks #2 to determine the peak value.
[0407] The electronic device can calculate the vertical projection of the region blocks in the set of region blocks #2, and determine the peak value according to the vertical projection result.
[0408] For example, as shown in (d) of FIG. 22, when the electronic device projects region block #5, region block #6, region block #7 and region block #8 vertically, it projects region block #6 first, then projects region block #5 and region block #6, and then projects region block #5 in the order from left to right, so it can determine a peak value, i.e. peak value #1. Similarly, the electronic device can also determine peak value #2 and peak value #3.
[0409] S2540, columnating the region blocks according to the positions of the peak values and the positions of the region blocks.
[0410] After the electronic device determines the number of peak values, i.e. the number of columns, it can columnate the region blocks according to the positions of the peak values and the positions of the region blocks.
[0411] For example, as shown in (d) of FIG. 22, the electronic device can determine that region block #1 and region block #2 (also referred to as region block #5 and region block #6) belong to the first column, determine that region block #3 (also referred to as region block #7) belongs to the second column, and determine that region block #4 (also referred to as region block #8) belongs to the third column.
[0412] S2550, the region blocks in the first column are sorted according to the positional relationship between the region blocks in the first column.
[0413] The electronic device divides the content #1 into one or more columns, which includes a first column. Since the first column can include one or more region blocks, the electronic device can sort the region blocks in the first column according to the principle of from left to right and from top to bottom. In other words, the electronic device can sort the region blocks in the first column according to the top-bottom relationship and left-right relationship of the region blocks.
[0414] For example, as shown in (d) of FIG. 22, the electronic device determines that the first column includes region block #1 and region block #2, where the position of region block #1 is above region block #2. Then, the electronic device can determine the order of region block #1 and region block #2 as: region block #1-region block #2.
[0415] It can be understood that when the electronic device determines the order of the region blocks in each column, the electronic device can sequentially select the corresponding region blocks according to the determined order of the region blocks when the user selects the fields and / or patterns in the column.
[0416] In the embodiments of the present application, the electronic device can divide the content into one or more region blocks, where the strokes of the fields and / or patterns in each region block satisfy the writing order from left to right and from top to bottom, and then divide the content into columns according to the positional relationship between the region blocks, thereby improving the success rate of column division and ensuring that the user can select the content column by column in the manner of from left to right and from top to bottom.
[0417] In some embodiments, the method further includes:
[0418] Determining the order of the fields and / or patterns in the first region block according to the positional relationship between the fields and / or patterns in the first region block.
[0419] The electronic device can divide the content #1 into one or more region blocks, which includes a first region block. The electronic device can also determine the order of the fields and / or patterns in the first region block according to the positional relationship between the fields and / or patterns in the first region block.
[0420] In some embodiments, the electronic device determines that the order of the fields and / or patterns in the first region block satisfies the order from top to bottom and / or from left to right.
[0421] For example, as shown in (d) of FIG. 22, the electronic device can determine that the order of the fields and patterns in region block #1 (or also region block #5) is: field 1, field 2, pattern 1, field 3, field 4, and field 5.
[0422] It can be understood that, when the electronic device determines the order of the fields and / or the patterns in each region block, the electronic device can select the corresponding fields and / or patterns in sequence according to the determined order of the fields and / or the patterns when the user selects the fields and / or the patterns in the content block.
[0423] FIG. 26 shows a schematic flowchart of a method for recognizing handwriting strokes, which can be performed by an electronic device or a component (e.g., a processor, a chip system, etc.) of the electronic device. As shown in FIG. 26, the method includes the following steps:
[0424] S2610, identifying N strokes corresponding to one or more patterns.
[0425] S2620, dividing the N strokes into M stroke groups according to the positional relationship of the N strokes.
[0426] S2630, dividing the first stroke group into Q stroke groups according to the writing interval of the P strokes.
[0427] S2640, aggregating the Q stroke groups into W stroke groups according to the writing interval of the Q stroke groups and the distance relationship of the Q stroke groups.
[0428] It should be understood that the detailed description of steps S2610-S2640 can refer to the description of steps S460-S490. For brevity, the detailed description is not repeated here.
[0429] In the embodiments of the present application, the electronic device can divide the strokes into different stroke groups according to the positional relationship between the pattern strokes, so that the user can quickly select a complete pattern when selecting the pattern.
[0430] In addition, the electronic device can also divide a stroke group into multiple new stroke groups according to the writing interval of the strokes in the stroke group, which refines the granularity of the grouping and avoids the problem of multiple selection of strokes when the user selects the pattern.
[0431] In addition, the electronic device can also aggregate the stroke groups according to the writing interval and the positional relationship between the stroke groups, which avoids the problem of missing strokes when the user selects the pattern.
[0432] FIG. 27 shows a schematic flowchart of a method for recognizing handwriting strokes, which can be performed by an electronic device or a component (e.g., a processor, a chip system, etc.) of the electronic device. As shown in FIG. 27, the method includes the following steps:
[0433] S2710, identify the fields and / or patterns in the content #1.
[0434] S2720, divide the content #1 into one or more area blocks according to the positional relationship and writing order of the fields and / or patterns.
[0435] S2730, columnize the content #1 according to the positional relationship of the one or more area blocks to obtain one or more columns.
[0436] It should be understood that the detailed description for steps S2710-S2730 can refer to the description for steps S4100-S4120, which will not be repeated here for brevity.
[0437] In the embodiments of the present application, the electronic device can divide the content into one or more area blocks, the strokes of the fields and / or patterns in each area block meet the writing order from left to right and from top to bottom, and then columnize the pen content according to the positional relationship between the area blocks, thereby improving the success rate of columnization and ensuring that the user can select the content column by column in the manner from left to right and from top to bottom.
[0438] FIG. 28 shows a schematic flowchart of a handwriting stroke recognition method provided by the embodiments of the present application, which can be executed by an electronic device or a component (e.g., a processor, a chip system, etc.) of the electronic device. Hereinafter, the execution subject is taken as an example of the electronic device, and the method includes the following steps, as shown in FIG. 28:
[0439] S2810, display a first content, the first content including a plurality of strokes.
[0440] For example, the first content displayed by the electronic device can be as shown in FIG. 5, and the first content includes characters.
[0441] For another example, the first content displayed by the electronic device can be as shown in FIG. 16, and the first content includes patterns.
[0442] For another example, the first content displayed by the electronic device can be as shown in FIG. 22, and the first content includes patterns and characters.
[0443] S2820, group the plurality of strokes according to the positional relationship of the plurality of strokes and the writing order of the plurality of strokes.
[0444] The electronic device can group the plurality of strokes in the first content according to the positional relationship of the plurality of strokes and the writing order of the plurality of strokes. The strokes in the same stroke group can be strokes of the same pattern, strokes of the same character, or strokes in the same column.
[0445] In this embodiment of the application, the positional relationship includes a distance relationship and an orientation relationship, wherein the distance relationship is used to indicate the distance between strokes (for example, the distance between stroke #1 and stroke #2 is 1cm), and the orientation relationship is used to indicate the orientation between strokes (for example, stroke #1 is located to the left of stroke #2).
[0446] In this embodiment, strokes can be grouped according to the positional relationship between strokes and the writing order of strokes. Strokes belonging to the same stroke group can be strokes of the same pattern, or strokes of the same character, or strokes in the same column, so that when users select text and patterns, they will not encounter problems such as omission, multiple selection, inability to select a single character, or incorrect column division.
[0447] In some embodiments, the first content includes a first character and a second character, and grouping the multiple strokes according to the positional relationship and writing order of the multiple strokes includes:
[0448] When there is a first overlapping area between the first rectangular frame corresponding to the first character and the second rectangular frame corresponding to the second character, the attribution of one or more strokes is determined according to the writing order of the strokes of the first character and the second character and the positional relationship between one or more strokes in the first overlapping area and the first and second rectangular frames.
[0449] It should be understood that a detailed description of the attribution of strokes in determining overlapping areas can be found above, and will not be repeated here for the sake of brevity.
[0450] In some embodiments, determining the attribution of one or more strokes based on the writing order of the strokes of the first and second characters and the positional relationship between one or more strokes in the first overlapping area and the first and second rectangular frames includes:
[0451] Determine the coordinates of the first rectangle, the second rectangle, and one or more strokes based on the positional relationship between the first and second characters;
[0452] The attribution of one or more strokes is determined based on the distance relationship between the coordinates of the first rectangle, the second rectangle, and one or more strokes, as well as the writing order of the strokes of the first and second characters.
[0453] In some embodiments, the first character and the second character are arranged horizontally, with the first character to the left of the second character, and one or more strokes including the first stroke. Determining the coordinates of the first rectangle, the second rectangle, and one or more strokes based on the positional relationship between the first character and the second character includes:
[0454] Determine the first center x-coordinate of the first rectangle, the second center x-coordinate of the second rectangle, and the first average x-coordinate of the first stroke.
[0455] In some embodiments, determining the attribution of one or more strokes based on the distance relationship between the coordinates of the first rectangle, the second rectangle, and one or more strokes, and the writing order of the strokes of the first and second characters, includes:
[0456] When the distance between the first average horizontal coordinate and the first central horizontal coordinate is greater than the distance between the first average horizontal coordinate and the second central horizontal coordinate, the first stroke is determined to belong to the second character; or
[0457] When the distance between the first average horizontal coordinate and the first central horizontal coordinate is less than the distance between the first average horizontal coordinate and the second central horizontal coordinate, and the preceding stroke of the first stroke belongs to the second character, then the first stroke is determined to belong to the second character; or
[0458] When the distance between the first average horizontal coordinate and the first central horizontal coordinate is less than the distance between the first average horizontal coordinate and the second central horizontal coordinate, and the preceding stroke of the first stroke does not belong to the second character, the first stroke is determined to belong to the first character.
[0459] In some embodiments, the first character and the second character are arranged horizontally, with the first character to the left of the second character. The horizontal length of the first rectangle and / or the second rectangle is greater than a first threshold. One or more strokes include the first stroke. Determining the coordinates of the first rectangle, the second rectangle, and one or more strokes based on the positional relationship between the first character and the second character includes:
[0460] Determine the x-coordinate of the right border of the first rectangle, the x-coordinate of the left border of the second rectangle, and the first average x-coordinate of the first stroke.
[0461] In some embodiments, determining the attribution of one or more strokes based on the distance relationship between the coordinates of the first rectangle, the second rectangle, and one or more strokes, and the writing order of the strokes of the first and second characters, includes:
[0462] When the distance between the first average horizontal coordinate and the horizontal coordinate of the right border of the first rectangle is greater than the distance between the first average horizontal coordinate and the horizontal coordinate of the left border of the second rectangle, the first stroke is determined to belong to the second character; or
[0463] When the distance between the first average horizontal coordinate and the horizontal coordinate of the right border of the first rectangle is less than the distance between the first average horizontal coordinate and the horizontal coordinate of the left border of the second rectangle, and the preceding stroke of the first stroke belongs to the second character, then the first stroke is determined to belong to the second character; or
[0464] When the distance between the first average horizontal coordinate and the horizontal coordinate of the right side frame of the first rectangular frame is less than the distance between the first average horizontal coordinate and the horizontal coordinate of the left side frame of the second rectangular frame, and the previous stroke of the first stroke does not belong to the second character, it is determined that the first stroke belongs to the first character.
[0465] In some embodiments, the first character and the second character are distributed in up and down directions, the first character is on the upper side of the second character, the one or more strokes include the first stroke, and the coordinates of the first rectangular frame, the second rectangular frame and the one or more strokes are determined according to the positional relationship between the first character and the second character, including:
[0466] A first center vertical coordinate of the first rectangular frame, a second center vertical coordinate of the second rectangular frame and a first average vertical coordinate of the first stroke are determined.
[0467] In some embodiments, the attribution of the one or more strokes is determined according to the distance relationship between the coordinates of the first rectangular frame, the second rectangular frame and the one or more strokes and the writing order of the strokes of the first character and the second character, including:
[0468] When the distance between the first average vertical coordinate and the first center vertical coordinate is greater than the distance between the first average vertical coordinate and the second center vertical coordinate, it is determined that the first stroke belongs to the second character; or
[0469] When the distance between the first average vertical coordinate and the first center vertical coordinate is less than the distance between the first average vertical coordinate and the second center vertical coordinate, and the previous stroke of the first stroke belongs to the second character, it is determined that the first stroke belongs to the second character; or
[0470] When the distance between the first average vertical coordinate and the first center vertical coordinate is less than the distance between the first average vertical coordinate and the second center vertical coordinate, and the previous stroke of the first stroke does not belong to the second character, it is determined that the first stroke belongs to the first character.
[0471] In some embodiments, the first character and the second character are distributed in diagonal directions, the first character is on the lower left side or the upper left side of the second character, the one or more strokes include the first stroke, and the coordinates of the first rectangular frame, the second rectangular frame and the one or more strokes are determined according to the positional relationship between the first character and the second character, including:
[0472] A first center coordinate of the first rectangular frame, a second center coordinate of the second rectangular frame and a first average coordinate of the first stroke are determined.
[0473] In some embodiments, the attribution of the one or more strokes is determined according to the distance relationship between the coordinates of the first rectangular frame, the second rectangular frame and the one or more strokes and the writing order of the strokes of the first character and the second character, including:
[0474] determine that the first stroke belongs to the second character when the distance between the first average coordinate and the first center coordinate is greater than the distance between the first average coordinate and the second center coordinate; or
[0475] determine that the first stroke belongs to the second character when the distance between the first average coordinate and the first center coordinate is less than the distance between the first average coordinate and the second center coordinate, and the previous stroke of the first stroke belongs to the second character; or
[0476] determine that the first stroke belongs to the first character when the distance between the first average coordinate and the first center coordinate is less than the distance between the first average coordinate and the second center coordinate, and the previous stroke of the first stroke does not belong to the second character.
[0477] In some embodiments, the first content includes one or more patterns, and the method further includes: identifying N strokes corresponding to the one or more patterns, N≥2 and N is an integer; grouping the plurality of strokes according to the positional relationship of the plurality of strokes and the writing order of the plurality of strokes, including: dividing the N strokes into M stroke groups according to the positional relationship between the N strokes, wherein the distance between any two strokes in the M stroke groups is greater than a second threshold, N≥M≥1 and M is an integer.
[0478] In some embodiments, the method further includes: dividing the first stroke group into Q stroke groups according to the writing interval of the P strokes, wherein the M stroke groups include the first stroke group, the first stroke group includes the P strokes, the writing interval between two stroke groups adjacent in writing order in the Q stroke groups is greater than a third threshold, and Q≥1 and Q is an integer.
[0479] In some embodiments, the method further includes: aggregating the Q stroke groups into W stroke groups according to the writing interval of the Q stroke groups and the distance relationship between the Q stroke groups, wherein the writing interval between two stroke groups adjacent in writing order in the multiple stroke groups aggregated into the same stroke group in the Q stroke groups is less than or equal to a fourth threshold and the distance is less than or equal to a fifth threshold, Q≥W≥1 and P is an integer.
[0480] In some embodiments, the distance between any two stroke groups in the Q stroke groups is greater than a sixth threshold, and the sixth threshold is less than the second threshold.
[0481] In some embodiments, the writing interval is a corresponding time interval between two strokes adjacent in writing order.
[0482] It should be understood that the detailed description of dividing stroke groups and aggregating stroke groups can be referred to the above, and for the sake of brevity, will not be repeated here.
[0483] In some embodiments, the method further comprises: identifying a field and / or a pattern in the first content; grouping the plurality of strokes according to a positional relationship of the plurality of strokes and a writing order of the plurality of strokes, comprising: dividing the first content into one or more area blocks according to a positional relationship and a writing order of the field and / or the pattern; and columnizing the first content according to a positional relationship of the one or more area blocks to obtain one or more columns.
[0484] In some embodiments, the method further comprises: sorting the area blocks in the first column according to a positional relationship between the area blocks in the first column. Wherein, the one or more categories comprise the first column.
[0485] In some embodiments, the method further comprises: sorting the field and / or the pattern in the first area block according to a positional relationship of the field and / or the pattern in the first area block, wherein the one or more area blocks comprise the first area block.
[0486] In some embodiments, the field and / or the pattern in the first area block satisfies an order from top to bottom and / or from left to right.
[0487] It should be understood that the detailed description of dividing the area blocks and columnizing can be referred to the above, which will not be repeated here for brevity.
[0488] The handwriting stroke recognition method provided by the embodiments of the present application is described in detail above. In various embodiments of the present application, the terms and / or descriptions between various embodiments are consistent and can be referred to each other if there is no special description and logical conflict, and the technical features in different embodiments can be combined to form new embodiments according to their inherent logical relationship.
[0489] The handwriting stroke recognition method provided by the embodiments of the present application is mainly introduced from the perspective of the electronic device. It can be understood that the electronic device contains the hardware structure and / or software module corresponding to the execution of each function in order to realize the above functions. Those skilled in the art should easily realize that the algorithm steps of each example described in combination with the embodiments disclosed in the present application can be realized in the form of hardware or a combination of hardware and computer software. Whether a certain function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.
[0490] In the case of dividing various functional modules (or units) corresponding to each function, FIG. 29 shows a composition diagram of an electronic device 2900 provided by the embodiments of the present application, as shown in FIG. 29, the electronic device 2900 comprises: a display module 2910, a processing module 2920.
[0491] The display module 2910 is configured to display the first content, and the first content includes a plurality of strokes.
[0492] The processing module 2920 is configured to group the plurality of strokes according to a positional relationship of the plurality of strokes and a writing order of the plurality of strokes.
[0493] In some embodiments, the first content includes a first character and a second character, and the processing module 2920 is specifically configured to, when a first rectangular frame corresponding to the first character and a second rectangular frame corresponding to the second character exist a first overlapping area, determine the attribution of one or more strokes according to the writing order of the strokes of the first character and the second character and the positional relationship of the one or more strokes with the first rectangular frame and the second rectangular frame.
[0494] In some embodiments, the processing module 2920 is specifically configured to determine the coordinates of the first rectangular frame, the second rectangular frame and the one or more strokes according to the positional relationship of the first character and the second character, and determine the attribution of the one or more strokes according to the distance relationship between the coordinates of the first rectangular frame, the second rectangular frame and the one or more strokes and the writing order of the strokes of the first character and the second character.
[0495] In some embodiments, the first character and the second character are left-right distributed, the first character is on the left side of the second character, and the one or more strokes include a first stroke, and the processing module 2920 is specifically configured to determine a first center horizontal coordinate of the first rectangular frame, a second center horizontal coordinate of the second rectangular frame and a first average horizontal coordinate of the first stroke.
[0496] In some embodiments, the processing module 2920 is specifically configured to, when the distance between the first average horizontal coordinate and the first center horizontal coordinate is greater than the distance between the first average horizontal coordinate and the second center horizontal coordinate, determine that the first stroke belongs to the second character, or when the distance between the first average horizontal coordinate and the first center horizontal coordinate is less than the distance between the first average horizontal coordinate and the second center horizontal coordinate and a previous stroke of the first stroke belongs to the second character, determine that the first stroke belongs to the second character, or when the distance between the first average horizontal coordinate and the first center horizontal coordinate is less than the distance between the first average horizontal coordinate and the second center horizontal coordinate and the previous stroke of the first stroke does not belong to the second character, determine that the first stroke belongs to the first character.
[0497] In some embodiments, the first character and the second character are left-right distributed, the first character is on the left side of the second character, the horizontal length of the first rectangular frame and / or the second rectangular frame is greater than a first threshold value, and the one or more strokes include a first stroke, and the processing module 2920 is specifically configured to determine a horizontal coordinate of a right side frame of the first rectangular frame, a horizontal coordinate of a left side frame of the second rectangular frame and a first average horizontal coordinate of the first stroke.
[0498] In some embodiments, the processing module 2920 is specifically configured to determine that the first stroke belongs to the second character when the distance between the first average horizontal coordinate and the horizontal coordinate of the right side frame of the first rectangular frame is greater than the distance between the first average horizontal coordinate and the horizontal coordinate of the left side frame of the second rectangular frame; or when the distance between the first average horizontal coordinate and the horizontal coordinate of the right side frame of the first rectangular frame is less than the distance between the first average horizontal coordinate and the horizontal coordinate of the left side frame of the second rectangular frame, and the previous stroke of the first stroke belongs to the second character; or when the distance between the first average horizontal coordinate and the horizontal coordinate of the right side frame of the first rectangular frame is less than the distance between the first average horizontal coordinate and the horizontal coordinate of the left side frame of the second rectangular frame, and the previous stroke of the first stroke does not belong to the second character, determine that the first stroke belongs to the first character.
[0499] In some embodiments, the first character and the second character are distributed in an up-down manner, the first character is on the upper side of the second character, and the one or more strokes include the first stroke. The processing module 2920 is specifically configured to determine a first central vertical coordinate of the first rectangular frame, a second central vertical coordinate of the second rectangular frame, and a first average vertical coordinate of the first stroke.
[0500] In some embodiments, the processing module 2920 is specifically configured to determine that the first stroke belongs to the second character when the distance between the first average vertical coordinate and the first central vertical coordinate is greater than the distance between the first average vertical coordinate and the second central vertical coordinate; or when the distance between the first average vertical coordinate and the first central vertical coordinate is less than the distance between the first average vertical coordinate and the second central vertical coordinate, and the previous stroke of the first stroke belongs to the second character; or when the distance between the first average vertical coordinate and the first central vertical coordinate is less than the distance between the first average vertical coordinate and the second central vertical coordinate, and the previous stroke of the first stroke does not belong to the second character, determine that the first stroke belongs to the first character.
[0501] In some embodiments, the first character and the second character are distributed in a diagonal manner, the first character is on the lower left side or the upper left side of the second character, and the one or more strokes include the first stroke. The processing module 2920 is specifically configured to determine a first central coordinate of the first rectangular frame, a second central coordinate of the second rectangular frame, and a first average coordinate of the first stroke.
[0502] In some embodiments, the processing module 2920 is specifically configured to determine that the first stroke belongs to the second character when the distance between the first average coordinate and the first center coordinate is greater than the distance between the first average coordinate and the second center coordinate; or when the distance between the first average coordinate and the first center coordinate is less than the distance between the first average coordinate and the second center coordinate, and the previous stroke of the first stroke belongs to the second character; or when the distance between the first average coordinate and the first center coordinate is less than the distance between the first average coordinate and the second center coordinate, and the previous stroke of the first stroke does not belong to the second character, determine that the first stroke belongs to the first character.
[0503] In some embodiments, the first content includes one or more patterns, and the processing module 2920 is further configured to identify N strokes corresponding to the one or more patterns, N≥2 and N is an integer; and the processing module 2920 is specifically configured to divide the N strokes into M stroke groups according to the positional relationship between the N strokes, where the distance between any two strokes in the M stroke groups is greater than a second threshold, N≥M≥1 and M is an integer.
[0504] In some embodiments, the processing module 2920 is further configured to divide the first stroke group into Q stroke groups according to the writing intervals of the P strokes, where the M stroke groups include the first stroke group, the first stroke group includes the P strokes, the writing interval between two stroke groups adjacent in writing order in the Q stroke groups is greater than a third threshold, and Q≥1 and Q is an integer.
[0505] In some embodiments, the processing module 2920 is further configured to aggregate the Q stroke groups into W stroke groups according to the writing intervals of the Q stroke groups and the distance relationship between the Q stroke groups, where the writing interval between two stroke groups adjacent in writing order in the multiple stroke groups aggregated into the same stroke group in the Q stroke groups is less than or equal to a fourth threshold and the distance is less than or equal to a fifth threshold, Q≥W≥1 and P is an integer.
[0506] In some embodiments, the distance between any two stroke groups in the Q stroke groups is greater than a sixth threshold, and the sixth threshold is less than the second threshold.
[0507] In some embodiments, the writing interval is a time interval corresponding to two strokes adjacent in writing order.
[0508] In some embodiments, the processing module 2920 is further configured to identify a field and / or a pattern in the first content.
[0509] The processing module 2920 is specifically configured to divide the first content into one or more area blocks according to the positional relationship and writing order of the fields and / or patterns; and columnize the first content according to the positional relationship of the one or more area blocks to obtain one or more columns.
[0510] In some embodiments, the processing module 2920 is further configured to sort the area blocks in the first column according to the positional relationship between the area blocks in the first column. The one or more columns include the first column.
[0511] In some embodiments, the processing module 2920 is further configured to sort the fields and / or patterns in the first area block according to the positional relationship of the fields and / or patterns in the first area block. The one or more area blocks include the first area block.
[0512] In some embodiments, the fields and / or patterns in the first area block satisfy the order from top to bottom and / or from left to right.
[0513] The embodiments of the present application provide a computer program product, when the computer program product runs in an electronic device, causes the electronic device to execute the technical solutions in the above embodiments. The implementation principles and technical effects are similar to the above method-related embodiments, and will not be described here.
[0514] The embodiments of the present application provide a readable storage medium, which contains instructions, when the instructions run in an electronic device, causes the electronic device to execute the technical solutions in the above embodiments. The implementation principles and technical effects are similar, and will not be described here.
[0515] The embodiments of the present application provide a chip, which is used to execute instructions, when the chip runs, executes the technical solutions in the above embodiments. The implementation principles and technical effects are similar, and will not be described here.
[0516] Those skilled in the art can clearly understand that the units and algorithm steps of the examples described in combination with the embodiments disclosed herein can be realized by electronic hardware or a combination of computer software and electronic hardware. Whether the functions are performed in hardware or software depends on the specific application and design constraints of the technical solutions. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the embodiments of the present application.
[0517] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the above-described system, device and unit can refer to the corresponding process in the foregoing method embodiments, which will not be described here.
[0518] In several embodiments provided in the present application, it should be understood that the disclosed system, device and method can be implemented in other manners. For example, the described device embodiments are merely schematic. The division of the units is merely logical function division. There can be another division manner for the actual implementation, for example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the displayed or discussed mutual couplings or direct couplings or communication connections can be indirect couplings or communication connections through some interfaces, devices or units, and can be in electrical, mechanical or other forms.
[0519] The units described as separate components can or can not be physically separate, and the components shown as units can or can not be physical units, i.e., can be located in one place, or can be distributed on multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the embodiment.
[0520] In addition, each functional unit in the various embodiments of the present application can be integrated into a processing unit, or each unit can be physically present separately, or two or more units can be integrated into one unit.
[0521] If the functions are implemented in the form of software function units and sold or used as independent products, they can be stored in a computer readable storage medium. Based on this understanding, the technical solutions of the embodiments of the present application can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to make a computer device (which can be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and various media that can store program codes.
[0522] The above is merely specific implementation of the embodiments of the present application, but the protection scope of the embodiments of the present application is not limited thereto. Any person skilled in the art can easily think of changes or replacements within the technical range disclosed in the embodiments of the present application, which should be covered in the protection scope of the embodiments of the present application. Therefore, the protection scope of the embodiments of the present application should be subject to the protection scope of the claims.
Claims
1. A method for recognizing handwritten strokes, characterized in that, The method includes: Display the first content, which includes multiple strokes; The strokes are grouped according to their positional relationship and the order in which they are written.
2. The method according to claim 1, characterized in that, The first content includes a first character and a second character. The step of grouping the multiple strokes according to their positional relationship and writing order includes: When there is a first overlapping area between the first rectangle corresponding to the first character and the second rectangle corresponding to the second character, the attribution of the one or more strokes is determined according to the writing order of the strokes of the first character and the second character and the positional relationship between one or more strokes in the first overlapping area and the first rectangle and the second rectangle.
3. The method according to claim 2, characterized in that, The step of determining the attribution of one or more strokes based on the writing order of the first and second characters and the positional relationship between one or more strokes in the first overlapping area and the first and second rectangular frames includes: The coordinates of the first rectangle, the second rectangle, and the one or more strokes are determined based on the positional relationship between the first and second characters. The attribution of the one or more strokes is determined based on the distance relationship between the coordinates of the first rectangle, the second rectangle, and the one or more strokes, as well as the writing order of the strokes of the first and second characters.
4. The method according to claim 2 or 3, characterized in that, The first character and the second character are arranged horizontally, with the first character to the left of the second character. The one or more strokes include the first stroke. Determining the coordinates of the first rectangle, the second rectangle, and the one or more strokes based on the positional relationship between the first character and the second character includes: Determine the first center x-coordinate of the first rectangle, the second center x-coordinate of the second rectangle, and the first average x-coordinate of the first stroke.
5. The method according to claim 4, characterized in that, The step of determining the affiliation of the one or more strokes based on the distance relationship between the coordinates of the first rectangle, the second rectangle, and the one or more strokes, and the writing order of the strokes of the first and second characters, includes: When the distance between the first average horizontal coordinate and the first central horizontal coordinate is greater than the distance between the first average horizontal coordinate and the second central horizontal coordinate, the first stroke is determined to belong to the second character; or When the distance between the first average horizontal coordinate and the first central horizontal coordinate is less than the distance between the first average horizontal coordinate and the second central horizontal coordinate, and the preceding stroke of the first stroke belongs to the second character, it is determined that the first stroke belongs to the second character; or When the distance between the first average horizontal coordinate and the first central horizontal coordinate is less than the distance between the first average horizontal coordinate and the second central horizontal coordinate, and the preceding stroke of the first stroke does not belong to the second character, the first stroke is determined to belong to the first character.
6. The method according to claim 2 or 3, characterized in that, The first character and the second character are arranged horizontally, with the first character to the left of the second character. The horizontal length of the first rectangle and / or the second rectangle is greater than a first threshold. The one or more strokes include the first stroke. Determining the coordinates of the first rectangle, the second rectangle, and the one or more strokes based on the positional relationship between the first character and the second character includes: Determine the x-coordinate of the right border of the first rectangle, the x-coordinate of the left border of the second rectangle, and the first average x-coordinate of the first stroke.
7. The method according to claim 6, characterized in that, The step of determining the affiliation of the one or more strokes based on the distance relationship between the coordinates of the first rectangle, the second rectangle, and the one or more strokes, and the writing order of the strokes of the first and second characters, includes: When the distance between the first average horizontal coordinate and the horizontal coordinate of the right border of the first rectangle is greater than the distance between the first average horizontal coordinate and the horizontal coordinate of the left border of the second rectangle, the first stroke is determined to belong to the second character; or When the distance between the first average horizontal coordinate and the horizontal coordinate of the right border of the first rectangle is less than the distance between the first average horizontal coordinate and the horizontal coordinate of the left border of the second rectangle, and the preceding stroke of the first stroke belongs to the second character, it is determined that the first stroke belongs to the second character; or When the distance between the first average horizontal coordinate and the horizontal coordinate of the right border of the first rectangle is less than the distance between the first average horizontal coordinate and the horizontal coordinate of the left border of the second rectangle, and the preceding stroke of the first stroke does not belong to the second character, the first stroke is determined to belong to the first character.
8. The method according to claim 2 or 3, characterized in that, The first character and the second character are arranged vertically, with the first character above the second character. The one or more strokes include the first stroke. Determining the coordinates of the first rectangle, the second rectangle, and the one or more strokes based on the positional relationship between the first character and the second character includes: Determine the first center ordinate of the first rectangle, the second center ordinate of the second rectangle, and the first average ordinate of the first stroke.
9. The method according to claim 8, characterized in that, The step of determining the affiliation of the one or more strokes based on the distance relationship between the coordinates of the first rectangle, the second rectangle, and the one or more strokes, and the writing order of the strokes of the first and second characters, includes: When the distance between the first average ordinate and the first center ordinate is greater than the distance between the first average ordinate and the second center ordinate, the first stroke is determined to belong to the second character; or When the distance between the first average ordinate and the first center ordinate is less than the distance between the first average ordinate and the second center ordinate, and the preceding stroke of the first stroke belongs to the second character, it is determined that the first stroke belongs to the second character; or When the distance between the first average ordinate and the first center ordinate is less than the distance between the first average ordinate and the second center ordinate, and the preceding stroke of the first stroke does not belong to the second character, the first stroke is determined to belong to the first character.
10. The method according to claim 2 or 3, characterized in that, The first character and the second character are diagonally distributed, with the first character positioned to the lower left or upper left of the second character. The one or more strokes include the first stroke. Determining the coordinates of the first rectangle, the second rectangle, and the one or more strokes based on the positional relationship between the first character and the second character includes: Determine the first center coordinates of the first rectangle, the second center coordinates of the second rectangle, and the first average coordinates of the first stroke.
11. The method according to claim 10, characterized in that, The step of determining the affiliation of the one or more strokes based on the distance relationship between the coordinates of the first rectangle, the second rectangle, and the one or more strokes, and the writing order of the strokes of the first and second characters, includes: When the distance between the first average coordinate and the first center coordinate is greater than the distance between the first average coordinate and the second center coordinate, the first stroke is determined to belong to the second character; or When the distance between the first average coordinate and the first center coordinate is less than the distance between the first average coordinate and the second center coordinate, and the preceding stroke of the first stroke belongs to the second character, it is determined that the first stroke belongs to the second character; or When the distance between the first average coordinate and the first center coordinate is less than the distance between the first average coordinate and the second center coordinate, and the preceding stroke of the first stroke does not belong to the second character, the first stroke is determined to belong to the first character.
12. The method according to any one of claims 1 to 11, characterized in that, The first content includes one or more patterns, and the method further includes: Identify N strokes corresponding to one or more patterns, where N ≥ 2 and is an integer; The step of grouping the multiple strokes according to their positional relationship and writing order includes: The N strokes are divided into M stroke groups according to the positional relationship between them. The distance between any two strokes in the M stroke groups is greater than a second threshold, and N≥M≥1 and M is an integer.
13. The method according to claim 12, characterized in that, The method further includes: The first stroke group is divided into Q stroke groups based on the writing interval of P strokes. The M stroke groups include the first stroke group, and the first stroke group includes the P strokes. The writing interval of two stroke groups with adjacent writing order in the Q stroke groups is greater than a third threshold, Q≥1 and Q is an integer.
14. The method according to claim 13, characterized in that, The method further includes: The Q stroke groups are aggregated into W stroke groups based on the writing interval of the Q stroke groups and the distance relationship between the Q stroke groups. Among the multiple stroke groups aggregated into the same stroke group, the writing interval of two stroke groups with adjacent writing order is less than or equal to the fourth threshold and the distance is less than or equal to the fifth threshold. Q≥W≥1 and P is an integer.
15. The method according to claim 13 or 14, characterized in that, The distance between any two stroke groups in the Q stroke groups is greater than a sixth threshold, and the sixth threshold is less than the second threshold.
16. The method according to any one of claims 13 to 15, characterized in that, The writing interval is the time interval between two strokes that are adjacent in the writing sequence.
17. The method according to any one of claims 1 to 16, characterized in that, The method further includes: Identify fields and / or patterns in the first content; The step of grouping the multiple strokes according to their positional relationship and writing order includes: The first content is divided into one or more area blocks according to the positional relationship and writing order of the fields and / or the patterns; The first content is divided into one or more columns based on the positional relationship of the one or more area blocks.
18. The method according to claim 17, characterized in that, The method further includes: The regions in the first column are sorted according to the positional relationship between the regions in the first column, wherein the one or more categories include the first column.
19. The method according to claim 17 or 18, characterized in that, The method further includes: The fields and / or patterns in the first region block are sorted according to their positional relationship, wherein the one or more region blocks include the first region block.
20. The method according to claim 19, characterized in that, The fields and / or patterns in the first region block satisfy a top-to-bottom and / or left-to-right order.
21. An electronic device, characterized in that, It includes one or more processors; one or more memories; said one or more memories storing one or more computer programs, said one or more computer programs including instructions that, when executed by said one or more processors, cause the method of any one of claims 1 to 20 to be performed.
22. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that, when executed on a computer, cause the method as described in any one of claims 1 to 20 to be performed.
23. A chip, characterized in that, The chip includes a processor and a communication interface, the communication interface being used to receive signals and transmit the signals to the processor, the processor processing the signals such that the method as described in any one of claims 1 to 20 is executed.
24. A computer program product, characterized in that, When the computer program product is run on a computer, it causes the computer to perform the method as described in any one of claims 1 to 20.
Citation Information
Patent Citations
Method and apparatus for segmenting strokes of overlapped handwriting into one or more groups
CN103080878A
Handwriting recognition method and device
CN105095924A
Electronic handwriting individual character disassembling apparatus and method
CN106203538A
Online handwritten character recognition method and device, electronic equipment and storage medium
CN111931710A
Character recognition method and device, readable medium and electronic equipment
CN118057487A