Disclosure of Invention
The invention aims to provide a touch identification method and a touch device aiming at the problem that the line dividing strip at the edge part of the line marking operation is bent to influence the touch effect caused by the sectional stretching in the prior art, so that the line dividing strip at the edge part of the line marking operation can be effectively prevented from being bent, and the touch effect is effectively improved.
A touch identification method comprises the following steps:
detecting a coordinate track of touch operation on a touch panel;
calculating and recording an included angle between the track and the X axis or the Y axis between adjacent coordinate points in the coordinate track;
calculating a vector value of a coordinate point in the coordinate track, and judging whether the coordinate track is a straight line;
if the coordinate track is a straight line, judging whether a coordinate point in the coordinate track is located in a preset edge area;
if the coordinate point is located in the preset edge area, stretching the coordinate point located in the preset edge area to obtain a stretched coordinate point;
judging whether the stretching coordinate point needs to be corrected or not according to the vector value of the corresponding coordinate point;
if the correction is needed, calculating a correction coordinate value according to the included angle between the track between the adjacent coordinate points and the X axis or the Y axis, the coordinate value of the stretching coordinate point, the stretching coefficient and the coordinate value of the precursor coordinate point of the stretching coordinate point, and obtaining the correction coordinate point.
Further, calculating a vector value of a coordinate point in the coordinate trajectory, and determining whether the coordinate trajectory is a straight line, includes:
coordinates of three adjacent coordinate points are obtained, and vector values are calculated according to the following formula:
wherein, PnPn+1As a coordinate point PnAnd coordinate point Pn+1In betweenDistance, PnPn+2As a coordinate point PnAnd coordinate point Pn+2A distance between Pn+1Pn+2As a coordinate point Pn+1And coordinate point Pn+2Q is a coordinate point PnCoordinate point Pn+1And a coordinate point Pn+2The vector value of (2);
and if the vector values of all the adjacent three points in the coordinate track infinitely approach to 0, determining that the coordinate track is a straight line.
Further, judging whether a coordinate point is located in a preset edge region in the coordinate track comprises:
and comparing the coordinate of the coordinate point with the coordinate in the preset edge area, and if the coordinate of the coordinate point is consistent with the coordinate in the preset edge area, determining that the coordinate point is positioned in the preset edge area.
Further, the preset edge area comprises a first preset edge area with the length direction parallel to the X axis and a second preset edge area with the length direction parallel to the Y axis;
stretching the coordinate point in the Y-axis direction when the coordinate point is located in the first preset edge area, and stretching the coordinate point in the X-axis direction when the coordinate point is located in the second preset edge area;
if a coordinate point in the coordinate track is located in the first preset edge area, an included angle between the track and the Y axis between the adjacent coordinate points is calculated, and if a coordinate point in the coordinate track is located in the second preset area, an included angle between the track and the X axis between the adjacent coordinate points is calculated.
Further, the coordinate point has a stretch coefficient of 1/8 to 4/8.
Further, determining whether the stretching coordinate point needs to be corrected includes:
calculating the vector values of the stretching coordinate point and the two precursor coordinate points, taking the vector value calculation mean value obtained by the previous three times of calculation, subtracting the vector values of the stretching coordinate point and the two precursor coordinate points from the mean value to obtain an absolute value, and determining that the stretching coordinate point needs to be corrected if the absolute value is greater than a preset vector change threshold value.
Further, the tensile coordinate point in the Y-axis direction is corrected by the following formula:
wherein (C)fx,Cfy) To correct the coordinates of the coordinate points, θiIs the angle between the track and the Y axis between adjacent coordinate points, CryIs the ordinate, R, of the tensile coordinate pointnIs the stretch coefficient, (P)1x,P1y) The coordinate values of the precursor coordinate points that are stretch coordinate points.
Further, the tensile coordinate point in the X-axis direction is corrected by the following formula:
wherein (C)fx,Cfy) To correct the coordinates of the coordinate points, [ theta'iIs the angle between the track and the X-axis between adjacent coordinate points, CrxIs the abscissa of the tensile coordinate point, RnIs the stretch coefficient, (P)1x,P1y) The coordinate values of the precursor coordinate points that are stretch coordinate points.
Further, after obtaining the correction coordinate point, replacing the correction coordinate point with the stretching coordinate point, calculating and recording vector values of the correction coordinate point and the two precursor points, and recording an included angle between a track of the correction coordinate point and the precursor coordinate point and an X axis or a Y axis.
A touch device comprising a touch panel, a touch I C, a processor, and a memory, the memory storing a plurality of instructions, the touch I C being configured to detect a coordinate trace of a touch operation on the touch panel, the processor being configured to read the plurality of instructions and to perform:
calculating and recording an included angle between the track and the X axis or the Y axis between adjacent coordinate points in the coordinate track;
calculating a vector value of a coordinate point in the coordinate track, and judging whether the coordinate track is a straight line;
if the coordinate track is a straight line, judging whether a coordinate point in the coordinate track is located in a preset edge area;
if the coordinate point is located in the preset edge area, stretching the coordinate point located in the preset edge area to obtain a stretched coordinate point;
judging whether the stretching coordinate point needs to be corrected or not according to the vector value of the corresponding coordinate point;
if the correction is needed, calculating a correction coordinate value according to the included angle between the track between the adjacent coordinate points and the X axis or the Y axis, the coordinate value of the stretching coordinate point, the stretching coefficient and the coordinate value of the precursor coordinate point of the stretching coordinate point, and obtaining the correction coordinate point.
According to the touch identification method and the touch device provided by the invention, the edge coordinates are corrected by recording the coordinate track vector change process, so that the problem of bending of the edge part line dividing strip caused by coordinate stretching is effectively solved, the linearity of edge scribing is improved, and the touch effect is improved.
Detailed Description
In order to make the objects, technical solutions and effects of the present invention clearer and clearer, the present invention is further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
Example one
Referring to fig. 2, the present embodiment provides a touch recognition method, including:
step S101, detecting a coordinate track of touch operation on a touch panel;
step S102, calculating and recording an included angle between a track and an X axis or a Y axis between adjacent coordinate points in the coordinate track;
step S103, calculating a vector value of a coordinate point in the coordinate track, and judging whether the coordinate track is a straight line;
step S104, if the coordinate track is a straight line, judging whether a coordinate point in the coordinate track is located in a preset edge area;
step S105, if a coordinate point is located in the preset edge area, stretching the coordinate point located in the preset edge area to obtain a stretched coordinate point;
step S106, judging whether the stretching coordinate point needs to be corrected or not according to the vector value of the corresponding coordinate point;
and step S107, if correction is needed, calculating a correction coordinate value according to the included angle between the track and the X axis or the Y axis between the adjacent coordinate points, the coordinate value of the stretching coordinate point, the stretching coefficient and the coordinate value of the precursor coordinate point of the stretching coordinate point, and obtaining the correction coordinate point.
Specifically, step S101 is performed first, and a touch operation on the touch panel is detected by touch I C.
And S102, calculating and recording an included angle between the track and the X axis or the Y axis between adjacent coordinate points in the coordinate track.
Referring to fig. 3, the preset edge regions include a first preset edge region a whose length direction is parallel to the X axis and a second preset edge region B whose length direction is parallel to the Y axis.
Taking the touch panel facing the user as an example, the first preset edge area is the preset edge areas on the upper side and the lower side of the touch panel, and the second preset edge area is the preset edge areas on the left side and the right side of the touch panel.
If a coordinate point in the coordinate track is located in the first preset edge area, an included angle between the track and the Y axis between the adjacent coordinate points is calculated, and if a coordinate point in the coordinate track is located in the second preset area, an included angle between the track and the X axis between the adjacent coordinate points is calculated.
Executing step S103, calculating vector values of coordinate points in the coordinate track, calculating one vector value for three adjacent coordinate points, acquiring coordinates of the three adjacent coordinate points by adopting a center line principle, and calculating the vector values according to the following formula:
wherein, PnPn+1As a coordinate point PnAnd coordinate point Pn+1A distance between PnPn+2As a coordinate point PnAnd coordinate point Pn+2A distance between Pn+1Pn+2As a coordinate point Pn+1And coordinate point Pn+2Q is a coordinate point PnCoordinate point Pn+1And a coordinate point Pn+2The vector value of (2).
And if the vector values of all the adjacent three points in the coordinate track infinitely approach to 0, determining that the coordinate track is a straight line.
And S104, after the coordinate track is determined to be a straight line, comparing the coordinates of each coordinate point in the coordinate track with the coordinates in the preset edge area, and if the coordinates are consistent with the coordinates in the preset edge area, determining that the coordinate point is located in the preset edge area.
Step S105 is executed to stretch the coordinate point in the Y-axis direction when the coordinate point is located in the first preset edge area a, and stretch the coordinate point in the X-axis direction when the coordinate point is located in the second preset edge area B.
As a preferred embodiment, the elongation coefficient of the coordinate point is 1/8 to 4/8.
And S106 is executed, the vector values of the stretching coordinate point and the two precursor coordinate points are calculated, the vector value calculation mean value obtained by the previous three times of calculation is taken, the vector values of the stretching coordinate point and the two precursor coordinate points and the mean value are subtracted to obtain an absolute value, and if the absolute value is larger than a preset vector change threshold value, the stretching coordinate point is determined to need to be corrected.
Executing step S107, the tensile coordinate point in the Y-axis direction is corrected by the following formula:
wherein (C)fx,Cfy) To correct the coordinates of the coordinate points, θiIs the angle between the track and the Y axis between adjacent coordinate points, CryIs the ordinate, R, of the tensile coordinate pointnIs the stretch coefficient, (P)1x,P1y) The coordinate values of the precursor coordinate points that are stretch coordinate points.
The tensile coordinate point in the X-axis direction is corrected by the following formula:
wherein (C)fx,Cfy) To correct the coordinates of the coordinate points, θiIs the angle between the track and the X-axis between adjacent coordinate points, CrxIs the abscissa of the tensile coordinate point, RnIs the stretch coefficient, (P)1x,P1y) The coordinate values of the precursor coordinate points that are stretch coordinate points.
And after obtaining the correction coordinate point, replacing the correction coordinate point with a stretching coordinate point, calculating and recording vector values of the correction coordinate point and two precursor points, and recording an included angle between the track of the correction coordinate point and the precursor coordinate point and an X axis or a Y axis.
Referring to fig. 4, the touch recognition method provided in the present embodiment is further explained with specific application scenarios.
The coordinate trajectory CrP5 is,the three-dimensional coordinate system comprises a first coordinate point P1, a second coordinate point P2, a third coordinate point P3, a fourth coordinate point P4, a fifth coordinate point P5 and a sixth coordinate point Cr, and records a fifth included angle theta between a fifth track P5P4 and the Y axis5A fourth included angle theta between the fourth track P4P3 and the Y axis4A third included angle theta between the third track P3P2 and the Y axis3A second included angle theta between the second track P2P1 and the Y axis2A first included angle theta between the first track P1Cr and the Y axis1;
After determining the coordinate trajectory as a straight line, performing:
calculating a coordinate value of a fifth coordinate point P5, judging whether the fifth coordinate point is located in a preset edge area, and if not, executing the next step;
calculating a coordinate value of the fourth coordinate point P4, judging whether the fourth coordinate point is located in a preset edge area, and if not, executing the next step;
calculating a coordinate value of the third coordinate point P3, judging whether the coordinate value is located in a preset edge area, and if not, calculating and storing a first vector value Q1 of the fifth coordinate point P5, the fourth coordinate point P4 and the third coordinate point P3;
calculating a coordinate value of the second coordinate point P2, judging whether the coordinate value is located in a preset edge area, and if not, calculating and storing a second vector value Q2 of the fourth coordinate point P4, the third coordinate point P3 and the second coordinate point P2;
calculating a coordinate value of the first coordinate point P1, judging whether the coordinate value is located in a preset edge region, if not, calculating and storing a third vector value Q3 of the third coordinate point P3, the second coordinate point P2 and the first coordinate point P1;
calculating the coordinate value of a sixth coordinate point Cr, which is located in the first preset edge area A and uses the tensile coefficient RnStretching the sixth coordinate point Cr in the Y-axis direction to obtain a stretched coordinate point Cp, calculating a fourth vector value of the stretched coordinate point Cp, the first coordinate point P1 and the second coordinate point P2, comparing the absolute value of the difference between the fourth vector value and the mean value of the first vector value Q1, the second vector value Q2 and the third vector value Q3 with a preset vector change threshold, and if the absolute value is greater than the preset vector change threshold, determining that the stretched coordinate point Cp is stretchedThe point Cp needs to be corrected.
The sixth coordinate point Cr is located in the first preset edge region, and therefore the coordinates of the correction coordinate point are calculated by using the following formula:
wherein (C)fx,Cfy) To correct the coordinates of the coordinate points, θiIs the angle between the track and the Y axis between adjacent coordinate points, CryIs the ordinate, R, of the tensile coordinate pointnIs the stretch coefficient, (P)1x,P1y) The coordinate values of the precursor coordinate points that are stretch coordinate points.
The stretched coordinate point Cp is replaced with the corrected coordinate point Cf as the stretched sixth coordinate point Cr, and a fourth vector value Q4 of the corrected coordinate point Cf, the first coordinate point P1, and the second coordinate point P2 is calculated and stored.
Referring to fig. 5 and 6, fig. 5 is a coordinate track obtained by only using the edge stretching method, and fig. 6 is a coordinate track corrected by using the method provided by this embodiment, which effectively avoids the problem of bending of the line dividing strip at the edge portion.
According to the touch identification method provided by the embodiment, the edge coordinates are corrected by recording the coordinate track vector change process, so that the problem of bending of the edge dividing line caused by coordinate stretching is effectively solved, the linearity of edge scribing is improved, and the touch effect is improved.
Example two
Referring to fig. 7, the present embodiment provides a touch device, including a touch panel 201, a touch IC202, a processor 203 and a memory 204, where the memory 204 stores a plurality of instructions, the touch IC201 is configured to detect a coordinate track of a touch operation on the touch panel, and the processor 201 is configured to read the plurality of instructions and execute:
calculating and recording an included angle between the track and the X axis or the Y axis between adjacent coordinate points in the coordinate track;
calculating a vector value of a coordinate point in the coordinate track, and judging whether the coordinate track is a straight line;
if the coordinate track is a straight line, judging whether a coordinate point in the coordinate track is located in a preset edge area;
if the coordinate point is located in the preset edge area, stretching the coordinate point located in the preset edge area to obtain a stretched coordinate point;
judging whether the stretching coordinate point needs to be corrected or not according to the vector value of the corresponding coordinate point;
if the correction is needed, calculating a correction coordinate value according to the included angle between the track between the adjacent coordinate points and the X axis or the Y axis, the coordinate value of the stretching coordinate point, the stretching coefficient and the coordinate value of the precursor coordinate point of the stretching coordinate point, and obtaining the correction coordinate point.
Further, the processor 203 is further configured to perform:
coordinates of three adjacent coordinate points are obtained, and vector values are calculated according to the following formula:
wherein, PnPn+1As a coordinate point PnAnd coordinate point Pn+1A distance between PnPn+2As a coordinate point PnAnd coordinate point Pn+2A distance between Pn+1Pn+2As a coordinate point Pn+1And coordinate point Pn+2Q is a coordinate point PnCoordinate point Pn+1And a coordinate point Pn+2The vector value of (2);
and if the vector values of all the adjacent three points in the coordinate track infinitely approach to 0, determining that the coordinate track is a straight line.
Further, the processor 203 is further configured to perform:
and comparing the coordinate of the coordinate point with the coordinate in the preset edge area, and if the coordinate of the coordinate point is consistent with the coordinate in the preset edge area, determining that the coordinate point is positioned in the preset edge area.
Further, the processor 203 is further configured to perform:
calculating the vector values of the stretching coordinate point and the two precursor coordinate points, taking the vector value calculation mean value obtained by the previous three times of calculation, subtracting the vector values of the stretching coordinate point and the two precursor coordinate points from the mean value to obtain an absolute value, and determining that the stretching coordinate point needs to be corrected if the absolute value is greater than a preset vector change threshold value.
Further, the processor 203 is further configured to perform:
correcting the tensile coordinate point in the Y-axis direction by the following formula:
wherein (C)fx,Cfy) To correct the coordinates of the coordinate points, θiIs the angle between the track and the Y axis between adjacent coordinate points, CryIs the ordinate, R, of the tensile coordinate pointnIs the stretch coefficient, (P)1x,P1y) The coordinate values of the precursor coordinate points that are stretch coordinate points.
Further, the processor 203 is further configured to perform:
correcting the stretching coordinate point in the X-axis direction by the following formula:
wherein (C)fx,Cfy) To correct the coordinates of the coordinate points, θiIs the angle between the track and the X-axis between adjacent coordinate points, CrxIs the abscissa of the tensile coordinate point, RnIs the stretch coefficient, (P)1x,P1y) The coordinate values of the precursor coordinate points that are stretch coordinate points.
Further, the processor 203 is further configured to perform:
and after obtaining the correction coordinate point, replacing the correction coordinate point with a stretching coordinate point, calculating and recording vector values of the correction coordinate point and two precursor points, and recording an included angle between the track of the correction coordinate point and the precursor coordinate point and an X axis or a Y axis.
The touch identification device provided by the embodiment corrects the edge coordinates by recording the coordinate track vector change process, effectively solves the problem of bending of the edge dividing line caused by coordinate stretching, improves the linearity of edge scribing, and improves the touch effect.
It will be understood that modifications and variations can be made by persons skilled in the art in light of the above teachings and all such modifications and variations are intended to be included within the scope of the invention as defined in the appended claims.