Laser Sensing Display for UI interfaces in the real world

Dependencies:   mbed

Fork of skinGames_forktest by Alvaro Cassinelli

Committer:
mbedalvaro
Date:
Fri Sep 21 10:02:35 2012 +0000
Revision:
30:d8af03f01cd4
Parent:
25:74cb85b85fd2
Child:
32:52273c3291fe
first commit. Not yet functional. Added ghost and pacman game modes, but the behaviour of these "rigid spots" is not implemented yet

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbedalvaro 30:d8af03f01cd4 1 #ifndef LSDTRAJECTORY_H
mbedalvaro 30:d8af03f01cd4 2 #define LSDTRAJECTORY_H
mbedalvaro 30:d8af03f01cd4 3
mbedalvaro 30:d8af03f01cd4 4 #include <vector>
mbedalvaro 30:d8af03f01cd4 5 using namespace std;
mbedalvaro 30:d8af03f01cd4 6
mbedalvaro 30:d8af03f01cd4 7 // CONTRAST RATIO to compute autoThreshold:
mbedalvaro 30:d8af03f01cd4 8 #define MIN_CONTRAST_RATIO 1.7 // 3 seems good when lookup table does not work // This is the minimum contrast between max and min intensity necessary to "accept" a black and white zone
mbedalvaro 30:d8af03f01cd4 9 #define THRESHOLD_FACTOR 0.5 //0.75 // 2/3 or 1/2 are good values
mbedalvaro 30:d8af03f01cd4 10
mbedalvaro 30:d8af03f01cd4 11 struct laserSensingPoint {
mbedalvaro 30:d8af03f01cd4 12 // Position and color (after rendering)
mbedalvaro 30:d8af03f01cd4 13 unsigned short x, y; // position of the point (after rendering - its integer, because it is in "laser projector pixels")
mbedalvaro 30:d8af03f01cd4 14 // char color; // per point laser color (not used yet)
mbedalvaro 30:d8af03f01cd4 15 // Detection:
mbedalvaro 30:d8af03f01cd4 16 unsigned char intensity; // detected intensity (in fact, this will be the REFLECTIVITY RATIO if using LUT table, and it's between 0 and 1, but we will multiply by 255 to avoid using a float.
mbedalvaro 30:d8af03f01cd4 17 signed char lightZone; // the thresholded light zone (allow for negative values for simply computing "negative" forces - although this is not necessarily the best option)
mbedalvaro 30:d8af03f01cd4 18 };
mbedalvaro 30:d8af03f01cd4 19
mbedalvaro 30:d8af03f01cd4 20
mbedalvaro 30:d8af03f01cd4 21 class LaserSensingTrajectory {
mbedalvaro 30:d8af03f01cd4 22
mbedalvaro 30:d8af03f01cd4 23 public:
mbedalvaro 30:d8af03f01cd4 24
mbedalvaro 30:d8af03f01cd4 25 LaserSensingTrajectory();
mbedalvaro 30:d8af03f01cd4 26 ~LaserSensingTrajectory();
mbedalvaro 30:d8af03f01cd4 27
mbedalvaro 30:d8af03f01cd4 28 // METHODS:
mbedalvaro 30:d8af03f01cd4 29 void processSensedData();
mbedalvaro 30:d8af03f01cd4 30 void setDelayMirrors(int); // in general, the delay will depend on the number of points being DISPLAYED (in other terms, on the size of lsdTrajectory).
mbedalvaro 30:d8af03f01cd4 31 void addDelayMirrors(int add_delay);
mbedalvaro 30:d8af03f01cd4 32
mbedalvaro 30:d8af03f01cd4 33 // DATA:
mbedalvaro 30:d8af03f01cd4 34 vector <laserSensingPoint> lsdTrajectory;
mbedalvaro 30:d8af03f01cd4 35 unsigned char displayColor; // per blob color
mbedalvaro 30:d8af03f01cd4 36
mbedalvaro 30:d8af03f01cd4 37 // software adjustement of mirror delay:
mbedalvaro 30:d8af03f01cd4 38 unsigned char delayMirrorSamples; // this is required because it will affect the way the blob behaves - it
mbedalvaro 30:d8af03f01cd4 39 //could be in the laser renderer, but by putting it here we can have more per-blob fine tunning
mbedalvaro 30:d8af03f01cd4 40
mbedalvaro 30:d8af03f01cd4 41 // parameters for thresholding:
mbedalvaro 30:d8af03f01cd4 42 unsigned char autoThreshold; // 0 to 255
mbedalvaro 30:d8af03f01cd4 43
mbedalvaro 30:d8af03f01cd4 44 // Statistics and tests:
mbedalvaro 30:d8af03f01cd4 45 //float lightRatio;
mbedalvaro 30:d8af03f01cd4 46 unsigned char maxI, minI; // Max and Min intensity RATIOS (normalized between 0 and 255)
mbedalvaro 30:d8af03f01cd4 47 bool lightTouched; // true if something went over the autoThreshold for the whole loop
mbedalvaro 30:d8af03f01cd4 48 // char coko;
mbedalvaro 30:d8af03f01cd4 49 };
mbedalvaro 30:d8af03f01cd4 50
mbedalvaro 30:d8af03f01cd4 51 #endif
mbedalvaro 30:d8af03f01cd4 52
mbedalvaro 30:d8af03f01cd4 53