Hi Kees,
you are right, Gnash calibration is just different as TSLIB
calibration :
Gnash use 2 points
and
TSLIB use 5 points
The problem is that using 2 points is not enough :
http://www.embedded.com/story/OEG20020529S0046
3 points is a minimum...
I didn't managed to add TSLIB to gnash (linker problem see below), so
I modified the built in TS calibration in Gnash to use the 3 points
methode decribed above.
Here is the patch if somebody else need it (work fine for me) :
---------------begin fb.cpp.ts3points.patch----------------------
--- gnash-0.8.5/gui/fb.cpp.orig 2008-02-19 20:20:49.000000000 +0100
+++ gnash-0.8.5/gui/fb.cpp 2008-04-11 09:58:08.000000000 +0200
@@ -1045,24 +1045,24 @@
void FBGui::apply_ts_calibration(float* cx, float* cy, int rawx, int
rawy) {
/*
- <UdoG>:
- This is a *very* simple method to translate raw touchscreen
coordinates to
- the screen coordinates. We simply to linear interpolation between
two points.
- Note this won't work well when the touchscreen is not perfectly
aligned to
- the screen (ie. slightly rotated). Standard touchscreen calibration
uses
- 5 calibration points (or even 25). If someone can give me the
formula, tell
- me! I'm too lazy right now to do the math myself... ;)
-
- And sorry for the quick-and-dirty implementation! I'm in a hurry...
+ <GeorgesP>:
+ This method use 3 points calibration
+ it is described in
http://www.embedded.com/story/OEG20020529S0046
*/
-
- float ref1x = m_stage_width / 5 * 1;
+
+ float k,a,b,c,d,e,f;
+
+ float ref0x = m_stage_width / 5 * 1;
+ float ref0y = m_stage_height / 5 * 1;
+ float ref1x = m_stage_width / 5 * 4;
float ref1y = m_stage_height / 5 * 1;
float ref2x = m_stage_width / 5 * 4;
float ref2y = m_stage_height / 5 * 4;
- static float cal1x = 2048/5*1; // very approximative default
values
- static float cal1y = 2048/5*4;
+ static float cal0x = 2048/5*1; // very approximative default
values
+ static float cal0y = 2048/5*4;
+ static float cal1x = 2048/5*1;
+ static float cal1y = 2048/5*1;
static float cal2x = 2048/5*4;
static float cal2y = 2048/5*1;
@@ -1075,7 +1075,7 @@
if (settings) {
// expected format:
- // 491,1635,1581,646 (cal1x,cal1y,cal2x,cal2y; all
integers)
+ // 491,1635,451,537,1581,646
(cal0x,cal0y,cal1x,cal1y,cal2x,cal2y; all integers)
char buffer[1024];
char* p1;
@@ -1086,6 +1086,20 @@
p1 = buffer;
do {
+ // cal0x
+ p2 = strchr(p1, ',');
+ if (!p2) continue; // stop here
+ *p2 = 0;
+ cal0x = atoi(p1);
+ p1=p2+1;
+
+ // cal0y
+ p2 = strchr(p1, ',');
+ if (!p2) continue; // stop here
+ *p2 = 0;
+ cal0y = atoi(p1);
+ p1=p2+1;
+
// cal1x
p2 = strchr(p1, ',');
if (!p2) continue; // stop here
@@ -1117,8 +1131,8 @@
if (!ok)
log_debug(_("WARNING: Error parsing calibration data!"));
- log_debug(_("Using touchscreen calibration data: %.0f / %.0f /
%.0f / %.0f"),
- cal1x, cal1y, cal2x, cal2y);
+ log_debug(_("Using touchscreen calibration data: %.0f / %.0f /
%.0f / %.0f / %.0f / %.0f"),
+ cal0x, cal0y, cal1x, cal1y, cal2x, cal2y);
} else {
log_debug(_("WARNING: No touchscreen calibration settings
found. "
@@ -1128,10 +1142,18 @@
} //!initialized
+ // calcul of K, A, B, C, D, E and F
+ k = (cal0x - cal2x) * (cal1y - cal2y) - (cal1x - cal2x) * (cal0y -
cal2y);
+ a = ((ref0x - ref2x) * (cal1y - cal2y) - (ref1x - ref2x) * (cal0y -
cal2y)) / k;
+ b = ((ref1x - ref2x) * (cal0x - cal2x) - (ref0x - ref2x) * (cal1x -
cal2x)) / k;
+ c = (cal0y * (cal2x * ref1x - cal1x * ref2x) + cal1y * (cal0x *
ref2x - cal2x * ref0x) + cal2y * (cal1x * ref0x - cal0x * ref1x)) / k;
+ d = ((ref0y - ref2y) * (cal1y - cal2y) - (ref1y - ref2y) * (cal0y -
cal2y)) / k;
+ e = ((ref1y - ref2y) * (cal0x - cal2x) - (ref0y - ref2y) * (cal1x -
cal2x)) / k;
+ f = (cal0y * (cal2x * ref1y - cal1x * ref2y) + cal1y * (cal0x *
ref2y - cal2x * ref0y) + cal2y * (cal1x * ref0y - cal0x * ref1y)) / k;
// real duty:
- *cx = (rawx-cal1x) / (cal2x-cal1x) * (ref2x-ref1x) + ref1x;
- *cy = (rawy-cal1y) / (cal2y-cal1y) * (ref2y-ref1y) + ref1y;
+ *cx = a * rawx + b * rawy + c;
+ *cy = d * rawx + e * rawy + f;
}
void FBGui::check_mouse()
---------------end fb.cpp.ts3points.patch----------------------
Georges
On 30 nov, 03:32, Kees Jongenburger <
kees.jongenbur...@gmail.com>
wrote: