-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Correct the calibration when the axes are inverted. #52
base: master
Are you sure you want to change the base?
Conversation
I had a problem to calibrate a touch screen with the axes inverted. Looking at the code I found that when the axes inversion is detected, the {x,y}_{max,min} are swapped: // calculate average of clicks float x_min = (clicked.x[UL] + clicked.x[LL])/2.0; float x_max = (clicked.x[UR] + clicked.x[LR])/2.0; float y_min = (clicked.y[UL] + clicked.y[UR])/2.0; float y_max = (clicked.y[LL] + clicked.y[LR])/2.0; // Should x and y be swapped? if (abs(clicked.x[UL] - clicked.x[UR]) < abs(clicked.y[UL] - clicked.y[UR])) { std::swap(x_min, y_min); std::swap(x_max, y_max); However I think that when the axis are swapped the calculation of the {x,y}_{max,min} are wrong. Let me explain why: During the calibration, on the screen are showed four crosses called UL, LR, LL, UR (Upper Left, Lower Right...). If the axes are not swapped during the calibration we got the following coordinates (x,y the numbers are hypothetical): UL -> 10,10 UR -> 90,10 LL -> 10,70 LR -> 90,70 and x_min = (10+10)/2 = 10 x_max = (90+90)/2 = 90 y_min = (10+10/2 = 10 y_max = (70+70)/2 = 70 Instead if the axes are inverted UL -> 10,10 UR -> 10,90 LL -> 70,10 LR -> 70,90 and x_min = (10+70)/2 = 35 x_max = (10+70)/2 = 35 x_min == x_max y_min = (10+90)/2 = 45 y_max = (10+90)/2 = 45 y_min == y_max which are basically wrong. I think that the right solution should be to calculate the {x,y}_{max,min} as following when an axis inversion is detected: x_min = (clicked.x[UL] + clicked.x[UR])/2.0; x_max = (clicked.x[LL] + clicked.x[LR])/2.0; y_min = (clicked.y[UL] + clicked.y[LL])/2.0; y_max = (clicked.y[UR] + clicked.y[LR])/2.0; ( Note the different array indexes )
Just stumbled in the same problem and after I found my solution someone pointed me to yours which looks a little different. |
Hi, You would be right is the swapping is performed before the scaling.... |
Hi Goffredo, As far as I can see in the code, the check if (abs(clicked.x[UL] - clicked.x[UR]) < abs(clicked.y[UL] - is made to change the swap info and this applies both if Evdev Axes Swap From what I can see, touch coordinates are print in bool Calibrator::add_click(int x, int y) and report coordinates accordingly to the status of the Axes Swap So, assuming that we find axes have to be swapped (again, to me this Also I have to say that code checks if Evdex Axis Inversion is specified val = (pEvdev->absinfo[i].maximum - val + pEvdev->absinfo[i].minimum); but after that, it is also needed to see if x/y _max > If you want I have a patch that applies on current master and with it I Once I have time to clean it up I'd submit it but would be great if Daniele. On mar, 2016-09-20 at 12:17 -0700, Goffredo Baroncelli wrote:
|
I had a problem to calibrate a touch screen with the axes inverted. Looking at the code I found that when the axes inversion is detected, the {x,y}_{max,min} are swapped:
However I think that when the axis are swapped the calculation of the
{x,y}_{max,min} are wrong.
Let me explain why:
During the calibration, on the screen are showed four crosses called UL, LR, LL, UR (Upper Left, Lower Right...).
If the axes are not swapped during the calibration we got the following coordinates (x,y the numbers are hypothetical):
and
Instead if the axes are inverted
and
which are basically wrong. I think that the right solution should be to calculate the
{x,y}_{max,min} as following when an axis inversion is detected:
( Note the different array indexes )
How reproduce the bug:
RESULT: in the output message message you can see the MaxX and MinX values, the MaxY and the MinY values very near.
EXPECTED RESULT: the difference between MaxX and MinX should be comparable to the screen width.