A method, system, device and storage medium for adjusting touch screen sampling rate
By creating curve classes and pen classes in Android devices and determining sampling points using Euclidean distance, the problem of low sampling rate of Android devices is solved, and high-quality data acquisition and good interactivity are achieved.
Patent Information
- Application Number
- CN202210449982.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-27
- Publication Date
- 2025-01-14
- Estimated Expiration
- 2042-04-27
AI Technical Summary
The screen information sampling rate of Android devices is low, and it is impossible to take into account both good interactivity and high-quality data acquisition, especially in scenarios where high-precision real-time data is required.
By creating curve classes and pen classes, use Euclidean distance to determine the number of sampling points, rewrite the touch event function to obtain sampling point information on the curve track, increase the sampling rate and record sampling points that cannot be obtained by the system's native API.
It improves the sampling rate of Android devices, ensures the true validity of the sampling points, has small algorithm calculation volume, low memory usage, and is easy to integrate and modify.
Smart Images

Figure CN114967972B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of terminal technology, and in particular to a method, system, device and storage medium for adjusting a touch screen sampling rate. Background Art
[0002] At present, most Android devices use screen sensors to obtain real-time information such as the coordinates and pressure of the touch point when touching the screen, and this information can be obtained through Android programming. For projects that require users to touch the screen with their fingers or stylus for a long time to obtain real-time information, Android devices are often used as information acquisition media because of their popularity and good interactivity. However, the screen information sampling rate of Android devices is relatively low, only about 60Hz, which is not enough for some scenarios that require high-precision real-time data, and it is easy to cause poor data quality. For example, when using Android devices for handwriting data collection, if only the native Android API is used to obtain data, the 60Hz sampling rate will cause the device to record less user handwriting information; while the sampling rate of devices such as Wacom handwriting tablets can generally reach 100 to 300Hz, but their interactivity and convenience are worse than Android devices. In this way, it is impossible to take into account both good interaction and high-quality data collection. Summary of the invention
[0003] The purpose of the present invention is to solve one of the technical problems existing in the prior art to at least a certain extent.
[0004] Therefore, an object of the embodiments of the present invention is to provide a method, system, device and storage medium for adjusting the sampling rate of a touch screen.
[0005] In a first aspect, an embodiment of the present invention provides a method for adjusting a touch screen sampling rate, comprising the following steps:
[0006] Create a curve class, the curve class includes a source point, an end point and a control point, the source point, the end point and the control point are used to update the curve track, wherein the control point is used to record the track point generated by the touch screen;
[0007] Determine the Euclidean distance between the current control point and the previous control point, and determine the number of sampling points according to the Euclidean distance;
[0008] The information of the sampling points is determined according to the curve trajectory and the number of the sampling points.
[0009] Furthermore, the touch screen sampling rate adjustment method further includes the following steps:
[0010] A point class is created, where the point class is used to record the contact point information generated by the touch.
[0011] Furthermore, the touch screen sampling rate adjustment method further includes the following steps:
[0012] Create a pen class, wherein the pen class detects touch movement events by rewriting a touch event function to update the control point;
[0013] The pen class obtains the information of the sampling points on the curve track updated according to the control points according to the calling interface provided by the curve class.
[0014] Furthermore, the touch screen sampling rate adjustment method further includes the following steps:
[0015] A touch screen control class is created, and the touch screen control class calls an upper layer interface provided by the pen class to rewrite the touch event function to obtain information of sampling points on the curve track after the control point is updated.
[0016] Furthermore, the touch screen sampling rate adjustment method further includes the following steps:
[0017] A global list is created, where the global list is used to store information of points on the curve trajectory obtained by the pen storage class.
[0018] Furthermore, the step of determining the information of the sampling points according to the curve trajectory and the number of the sampling points comprises the following steps:
[0019] Determining a sampling variable according to the number of the sampling points;
[0020] The information of the sampling points on the curve trajectory is determined according to the sampling variables.
[0021] Furthermore, the expression of the curve trajectory is as follows:
[0022] a=Dv-2×C.v+Sv
[0023] b=2×(Cv-Sv)
[0024] Pv=a×t 2 +b×t+Sv
[0025] Among them, Sv represents the information of the source point, Dv represents the information of the end point, Cv represents the information of the control point, Pv is a quadratic function expression, a and b are parameters of the quadratic function expression, and t is a sampling variable.
[0026] In a second aspect, an embodiment of the present invention provides a touch screen sampling rate adjustment system, comprising:
[0027] A trajectory update module, used to create a curve class, the curve class includes a source point, an end point and a control point, the source point, the end point and the control point are used to update the curve trajectory, wherein the control point is used to record the trajectory point generated by the touch screen;
[0028] A distance determination module, used to determine the Euclidean distance between the current control point and the previous control point, and determine the number of sampling points according to the Euclidean distance;
[0029] The sampling point determination module is used to determine the information of the sampling points according to the curve trajectory and the number of the sampling points.
[0030] In a third aspect, an embodiment of the present invention provides a device for adjusting a touch screen sampling rate, comprising:
[0031] at least one processor;
[0032] at least one memory for storing at least one program;
[0033] When the at least one program is executed by the at least one processor, the at least one processor implements the method for adjusting the sampling rate of a touch screen.
[0034] In a fourth aspect, an embodiment of the present invention provides a storage medium, in which a program executable by a processor is stored. When the program executable by the processor is executed by the processor, it is used to implement the method for adjusting the sampling rate of a touch screen.
[0035] The advantages and beneficial effects of the present invention will be partly given in the following description, partly become apparent from the following description, or be understood through the practice of the present invention:
[0036] The embodiment of the present invention determines the number of sampling points on the current curve trajectory by determining the Euclidean distance between adjacent control points, and completes the sampling of the curve trajectory. These sampling points cannot be recorded by the system native API, thereby improving the sampling rate of the Android device and ensuring the authenticity and effectiveness of the sampling points. It also has the characteristics of small algorithm calculation amount and low memory usage, and is easy to integrate and modify. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the embodiments of the present invention or the drawings of related technical solutions in the prior art are introduced below. It should be understood that the drawings introduced below are only for the convenience of clearly describing some embodiments of the technical solutions of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0038] Figure 1 A schematic flow chart of a method for adjusting a touch screen sampling rate according to an embodiment of the present invention;
[0039] Figure 2 A schematic diagram of class relationships in an embodiment of the present invention;
[0040] Figure 3 It is a schematic diagram of updating the curve track of an embodiment of the present invention;
[0041] Figure 4 A schematic diagram of a determined Euclidean distance according to an embodiment of the present invention;
[0042] Figure 5 is a schematic diagram of sampling points according to an embodiment of the present invention;
[0043] Figure 6 is a schematic diagram of a quadratic function for calculating a curve trajectory according to an embodiment of the present invention;
[0044] Figure 7 A schematic diagram of the structure of a touch screen sampling rate adjustment system according to an embodiment of the present invention;
[0045] Figure 8 The present invention is a schematic diagram of the structure of a device for adjusting the sampling rate of a touch screen according to an embodiment of the present invention. DETAILED DESCRIPTION
[0046] The embodiments of the present invention are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and are not to be construed as limitations of the present invention. For the step numbers in the following embodiments, they are only provided for the convenience of explanation, and the order between the steps is not limited in any way, and the execution order of each step in the embodiment can be adaptively adjusted according to the understanding of those skilled in the art.
[0047] A touch screen sampling rate adjustment method, system, device and storage medium according to an embodiment of the present invention are described in detail below with reference to the accompanying drawings. First, a touch screen sampling rate adjustment method according to an embodiment of the present invention is described with reference to the accompanying drawings.
[0048] Reference Figure 1 A touch screen sampling rate adjustment method in an embodiment of the present invention mainly includes the following steps S1-S3:
[0049] S1. Create a curve class, which includes a source point, an end point, and a control point. The source point, the end point, and the control point are used to update the curve trajectory, wherein the control point is used to record the trajectory points generated by touch;
[0050] Specifically, the curve class is recorded as Curve class, which is used to store the information of the curve trajectory at a certain moment. The curve class includes three point class embodiments, namely the source point, the end point and the control point. A curve trajectory representing a part of the trajectory can be constructed by connecting the source point and the end point in sequence. The control point is used to record the trajectory point generated by the touch screen when recording the curve trajectory each time. The newly generated trajectory point is used to update the curve trajectory. Figure 3 , the dynamic update algorithm of the curve trajectory is as follows (mainly refers to the update of the source point S, the end point D and the control point C):
[0051] S=D last
[0052]
[0053] C=N
[0054] Among them, N is the last point generated each time the curve trajectory is recorded, and D last is the end point of the previous curve trajectory, C last is the control point of the previous curve trajectory.
[0055] S2. Determine the current control point C current and the previous control point C last The Euclidean distance dist between them, and the number of sampling points steps is determined according to the Euclidean distance dist;
[0056] Specifically, refer to Figure 4 , determine the current control point C current The position information and the last control point C last The position information of the last control point C last Refers to the control point of the previous curve), thereby determining the Euclidean distance dist between the two control points, which is used to determine the number of sampling points steps for each sampling. The formula is as follows:
[0057]
[0058] Wherein, FACTOR is an influencing factor, which can be set according to actual conditions. In a specific embodiment, the value of FACTOR is 10.
[0059] S3, determining the information of the sampling points according to the curve trajectory and the number of sampling points;
[0060] Specifically, the distance between two control points can determine the number of sampling points on the curve trajectory. Therefore, by combining the number of sampling points and the curve trajectory, the information of the sampling points can be determined. Figure 5, this application can finally obtain and record the sampling points between the system sampling interval points, and the sampling points are the information of the points that the system native API cannot obtain.
[0061] From the above content, it can be seen that this application determines the number of sampling points on the current curve trajectory by determining the Euclidean distance between adjacent control points, and completes the sampling of the curve trajectory. These sampling points cannot be recorded by the system native API, thereby improving the sampling rate of the Android device and ensuring the authenticity and effectiveness of the sampling points. It also has the characteristics of small algorithm computational complexity and low memory usage, and is easy to integrate and modify.
[0062] As an optional implementation, the method for adjusting the touch screen sampling rate further includes the following steps:
[0063] S4. Create a point class, which is used to record the contact information generated by the touch.
[0064] Specifically, the point class is denoted as Point class, which represents the class of points. Figure 2 The Point class is an important basic class for the following parts (mainly Curve class, Pen class, TouchControl class), which contains the type of information that developers want to record, such as x coordinates, y coordinates, etc. For the convenience of the following description, the information contained in it is recorded as v.
[0065] As an optional implementation, the method for adjusting the touch screen sampling rate further includes the following steps:
[0066] S5. Create a pen class, which detects touch movement events by rewriting the touch event function to update the control point;
[0067] Specifically, the pen class is recorded as the pen class, which is used to detect touch movement events of the screen and save points used to describe the curve trajectory.
[0068] The Pen class obtains the information generated by the touch screen by rewriting the touch event function (onTouchEvent(event:MotionEvent)). This function contains a parameter of type MotionEvent, recorded as event. Event contains multiple actions (action). This algorithm focuses on the move action (ACTION_MOVE). Every time a move action occurs, the Pen class records the current point as the latest point N, and puts N as an update parameter into the Curve class to update the curve trajectory; at the same time, for the two touch screen actions of pressing (ACTION_DOWN) and lifting (ACTION_UP), some point information will also be recorded according to a similar process.
[0069] S6. The pen class obtains the information of the sampling points on the curve trajectory updated according to the control points according to the calling interface provided by the curve class.
[0070] Specifically, the pen class obtains the information generated by the touch screen, and puts the latest detected point N into the curve class through the interface provided by the curve class. The curve class then uses the latest point N to update the control point C, thereby completing the update of the curve trajectory.
[0071] As an optional implementation, the method for adjusting the touch screen sampling rate further includes the following steps:
[0072] S7. Create a touch screen control class. The touch screen control class calls the upper layer interface provided by the pen class to rewrite the touch event function to obtain the information of the sampling points on the curve trajectory after the control points are updated.
[0073] Specifically, the touch screen control class is recorded as TouchControl class, which is used to control screen touch and includes an instance of Pen class.
[0074] In Android development, it is necessary to customize the acquisition of touch screen information by overriding the touch event function. Therefore, the TouchControl class also needs to overwrite the touch event function and call the touch event function of the Pen class in the first line of the function definition body, which enables the collection of touch information, the update of the curve trajectory, and the saving of the sampling points.
[0075] In addition, you can also define an external writing function in the TouchControl class to export the saved touch screen information to the outside, such as writing it to a txt file in the device's external storage.
[0076] As an outermost class, the TouchControl class can embed the entire algorithm flow into the Android software.
[0077] As an optional implementation, the method for adjusting the touch screen sampling rate further includes the following steps:
[0078] S8. Create a global list, which is used to store information about points on the curve trajectory obtained by the pen class.
[0079] Specifically, each time a touch detection on the touch screen is completed, the Pen class obtains the information v of each point between the source point S and the end point D on the trajectory, and adds the information of these points to the global list. These points cannot be recorded by the system native API, so the sampling rate is improved.
[0080] As an optional implementation, step S3 includes the following steps:
[0081] S31, determining sampling variables according to the number of sampling points;
[0082] Specifically, after the number of sampling points on the curve trajectory is determined, the sampling variables need to be determined, and then the information of the sampling points on the curve trajectory can be determined according to the sampling variables.
[0083] The sampling interval △t can be determined according to the number of sampling points steps, and then the expression of the sampling variable t can be determined as follows:
[0084]
[0085] t=t+△t 0<t≤1
[0086] S32. Determine information of sampling points on the curve trajectory according to the sampling variables.
[0087] Specifically, when the sampling variables are determined, information of the sampling points corresponding to each sampling variable may be determined.
[0088] As an optional implementation, the expression of the trajectory variable is as follows:
[0089] a=Dv-2×C.v+Sv
[0090] b=2×(Cv-Sv)
[0091] Pv=a×t 2 +b×t+Sv
[0092] Among them, Sv represents the information of the source point, Dv represents the information of the end point, and Cv represents the information of the control point. Figure 6 , Pv is the quadratic function expression from the source point S to the end point D, and a and b are the parameters of the quadratic function expression.
[0093] t∈(0,1] is a step variable, starting from 0, and the interval of each step is Until 1. When t steps from 0 to 1, the points of the curve will be recorded from the source point S to the end point D, completing the recording of multiple points on the entire curve. Since t cannot be 0, the end point D of the previous curve and the source point S of the next curve will not be recorded repeatedly.
[0094] Next, a touch screen sampling rate adjustment system according to an embodiment of the present invention is described with reference to the accompanying drawings.
[0095] Figure 7 The present invention is a schematic diagram of a touch screen sampling rate adjustment system structure according to an embodiment of the present invention.
[0096] The system specifically includes:
[0097] 201 track update module, used to create a curve class, the curve class includes a source point, an end point and a control point, the source point, the end point and the control point are used to update the curve track, wherein the control point is used to record the track point generated by the touch screen;
[0098] 202 distance determination module, used to determine the Euclidean distance between the current control point and the previous control point, and determine the number of sampling points according to the Euclidean distance;
[0099] 203 sampling point determination module, used to determine the information of the sampling points according to the curve trajectory and the number of sampling points.
[0100] It can be seen that the contents of the above method embodiments are all applicable to the present system embodiments, the functions specifically implemented by the present system embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0101] Reference Figure 8 , an embodiment of the present invention provides a device for adjusting a touch screen sampling rate, comprising:
[0102] at least one processor 301;
[0103] At least one memory 302, used to store at least one program;
[0104] When at least one program is executed by at least one processor 301, at least one processor 301 implements a method for adjusting a touch screen sampling rate.
[0105] Similarly, the contents of the above method embodiments are all applicable to the present device embodiments. The functions specifically implemented by the present device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0106] In some selectable embodiments, the function / operation mentioned in the block diagram may not occur in the order mentioned in the operation diagram. For example, depending on the function / operation involved, the two boxes shown in succession can actually be executed substantially simultaneously or the boxes can sometimes be executed in reverse order. In addition, the embodiment presented and described in the flow chart of the present invention is provided by way of example, for the purpose of providing a more comprehensive understanding of technology. The disclosed method is not limited to the operation and logic flow presented herein. Selectable embodiments are expected, wherein the order of various operations is changed and the sub-operation of a part for which is described as a larger operation is performed independently.
[0107] In addition, although the present invention is described in the context of functional modules, it should be understood that, unless otherwise specified, one or more of the functions and / or features described may be integrated into a single physical device and / or software module, or one or more functions and / or features may be implemented in separate physical devices or software modules. It is also understood that a detailed discussion of the actual implementation of each module is unnecessary for understanding the present invention. More specifically, in view of the properties, functions, and internal relationships of the various functional modules in the device disclosed herein, the actual implementation of the module will be understood within the conventional skills of the engineer. Therefore, those skilled in the art can implement the present invention set forth in the claims without excessive experimentation using ordinary techniques. It is also understood that the specific concepts disclosed are merely illustrative and are not intended to limit the scope of the present invention, which is determined by the full scope of the appended claims and their equivalents.
[0108] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several programs to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc., which can store program codes.
[0109] The logic and / or steps represented in the flowchart or otherwise described herein, for example, may be considered as an ordered list of executable programs for implementing the logical functions, and may be embodied in any computer-readable medium for use by a program execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch and execute a program from a program execution system, device or apparatus), or in conjunction with such program execution systems, devices or apparatuses. For purposes of this specification, a "computer-readable medium" may be any device that can contain, store, communicate, propagate or transmit a program for use by a program execution system, device or apparatus, or in conjunction with such program execution systems, devices or apparatuses.
[0110] More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or more wires (electronic device), a portable computer disk case (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be a paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, deciphering or, if necessary, processing in another suitable manner, and then stored in a computer memory.
[0111] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, a plurality of steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable program execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0112] In the above description of this specification, the description with reference to the terms "one embodiment / example", "another embodiment / example" or "certain embodiments / examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0113] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the claims and their equivalents.
[0114] The above is a specific description of the preferred implementation of the present invention, but the present invention is not limited to the described embodiments. Those skilled in the art may make various equivalent modifications or substitutions without violating the spirit of the present invention. These equivalent modifications or substitutions are all included in the scope defined by the claims of this application.
Claims
1. A method for adjusting the sampling rate of a touch screen, characterized in that: The following steps are involved: Create a curve class, the curve class includes a source point, an end point and a control point, the source point, the end point and the control point are used to update the curve track, wherein the control point is used to record the track point generated by the touch screen; Determine the Euclidean distance between the current control point and the previous control point, and determine the number of sampling points according to the Euclidean distance; Determine the information of the sampling points according to the curve trajectory and the number of the sampling points; The step of determining the information of the sampling points according to the curve trajectory and the number of the sampling points comprises the following steps: Determining a sampling variable according to the number of the sampling points; The information of the sampling points on the curve trajectory is determined according to the sampling variables, and the expression of the curve trajectory is as follows: a=Dv-2×C.v+Sv b=2×(Cv-Sv) Pv=a×t 2 +b×t+Sv Among them, Sv represents the information of the source point, Dv represents the information of the end point, Cv represents the information of the control point, Pv is a quadratic function expression, a and b are parameters of the quadratic function expression, and t is the sampling variable.
2. The method for adjusting the touch screen sampling rate according to claim 1, characterized in that: The touch screen sampling rate adjustment method further includes the following steps: A point class is created, where the point class is used to record the contact point information generated by the touch.
3. The method for adjusting the touch screen sampling rate according to claim 1, characterized in that: The touch screen sampling rate adjustment method further includes the following steps: Create a pen class, wherein the pen class detects touch movement events by rewriting a touch event function to update the control point; The pen class obtains the information of the sampling points on the curve track updated according to the control points according to the calling interface provided by the curve class.
4. The method for adjusting the touch screen sampling rate according to claim 3, characterized in that: The touch screen sampling rate adjustment method further includes the following steps: A touch screen control class is created, and the touch screen control class calls an upper layer interface provided by the pen class to rewrite the touch event function to obtain information of sampling points on the curve track after the control point is updated.
5. The method for adjusting the touch screen sampling rate according to claim 3, characterized in that: The touch screen sampling rate adjustment method further includes the following steps: A global list is created, where the global list is used to store information of points on the curve trajectory obtained by the pen class.
6. A touch screen sampling rate adjustment system, characterized in that: include: A trajectory update module, used to create a curve class, the curve class includes a source point, an end point and a control point, the source point, the end point and the control point are used to update the curve trajectory, wherein the control point is used to record the trajectory point generated by the touch screen; A distance determination module, used to determine the Euclidean distance between the current control point and the previous control point, and determine the number of sampling points according to the Euclidean distance; The sampling point determination module is used to determine the information of the sampling points according to the curve trajectory and the number of the sampling points.
7. A device for adjusting the sampling rate of a touch screen, characterized in that: include: at least one processor; at least one memory for storing at least one program; When the at least one program is executed by the at least one processor, the at least one processor implements a touch screen sampling rate adjustment method as described in any one of claims 1-5.
8. A storage medium storing a program executable by a processor, characterized in that: The program executable by the processor is used to implement a touch screen sampling rate adjustment method according to any one of claims 1 to 5 when executed by the processor.
Citation Information
Patent Citations
Line drawing processing method and device for infrared touch screen
CN110888552A
Writing style implementation method, device and equipment and readable storage medium
CN111782131A