Laser Sensing Display for UI interfaces in the real world
Fork of skinGames_forktest by
Diff: classLaserSensingTrajectory.cpp
- Revision:
- 10:6f8e48dca1bd
- Parent:
- 7:0df17f3078bc
- Child:
- 11:62f7183a03e7
--- a/classLaserSensingTrajectory.cpp Wed Apr 11 13:06:23 2012 +0000 +++ b/classLaserSensingTrajectory.cpp Wed Apr 11 14:51:08 2012 +0000 @@ -15,21 +15,22 @@ void LaserSensingTrajectory::processSensedData() { // Compute max and min intensity on the loop maxI=0; - minI=4096; + minI=255; // ratio has been normalized between 0 and 255 int auxSize=lsdTrajectory.size(); // Compute minimum and maximum intensities: for (int i = 0; i < lsdTrajectory.size(); i++) { - float mesI=lsdTrajectory[i].intensity; + unsigned char mesI=lsdTrajectory[i].intensity; if (maxI<mesI) maxI=mesI; if (minI>mesI) minI=mesI; } // Compute autoThreshold: - if (1.0*maxI/(minI+0.1) > MIN_CONTRAST_RATIO ) { - autoThreshold = 1.0 * (maxI-minI) * THRESHOLD_FACTOR + minI; // THRESHOLD_FACTOR = 2/3 or 1/2 is a good value. + if (minI==0) autoThreshold=0; // (we consider that the saccade is FULL on something white) + else if (1.0*maxI/minI > MIN_CONTRAST_RATIO ) { + autoThreshold = (unsigned char) (1.0 * (maxI-minI) * THRESHOLD_FACTOR + minI); // THRESHOLD_FACTOR = 2/3 or 1/2 is a good value. } else {// ... otherwise, we consider that the saccade is FULL on something white - autoThreshold=-1; + autoThreshold=0; } // Segment the trajectory (only two levels for the time being, but we can have more - meaning different forces, real or even complex values to have different angle forces...): @@ -40,11 +41,11 @@ // int counterLight=0; for (int i = 0; i < lsdTrajectory.size(); i++) { int delayedpoint=(i+auxSize+delayMirrorSamples)%auxSize; // this way we can have negative delayMirrorSamples if required (would be absurd though) - if (lsdTrajectory[delayedpoint].intensity>autoThreshold) { // this means a WHITE zone: + if (lsdTrajectory[delayedpoint].intensity>=autoThreshold) { // this means a WHITE zone: lsdTrajectory[i].lightZone= -1;//1; // counterLight++; } else { // something touched: DARK ZONE - lsdTrajectory[i].lightZone= 2;//0; + lsdTrajectory[i].lightZone= -1;// 2;//0; lightTouched=true; // (for the whole loop) } }