Laser Sensing Display for UI interfaces in the real world

Dependencies:   mbed

Fork of skinGames_forktest by Alvaro Cassinelli

Committer:
mbedalvaro
Date:
Wed Apr 11 13:06:23 2012 +0000
Revision:
9:3321170d157c
Parent:
7:0df17f3078bc
Child:
10:6f8e48dca1bd
I will use an unsigned short to store the intensity instead of a float

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbedalvaro 0:345b3bc7a0ea 1 #ifndef LSDTRAJECTORY_H
mbedalvaro 0:345b3bc7a0ea 2 #define LSDTRAJECTORY_H
mbedalvaro 0:345b3bc7a0ea 3
mbedalvaro 0:345b3bc7a0ea 4 #include <vector>
mbedalvaro 0:345b3bc7a0ea 5 using namespace std;
mbedalvaro 0:345b3bc7a0ea 6
mbedalvaro 0:345b3bc7a0ea 7 // CONTRAST RATIO to compute autoThreshold:
mbedalvaro 9:3321170d157c 8 #define MIN_CONTRAST_RATIO 1.3//2.4 // This is the minimum contrast between max and min intensity necessary to "accept" a black and white zone
mbedalvaro 9:3321170d157c 9 #define THRESHOLD_FACTOR 0.5//0.75 // 2/3 or 1/2 are good values
mbedalvaro 0:345b3bc7a0ea 10
mbedalvaro 0:345b3bc7a0ea 11 struct laserSensingPoint {
mbedalvaro 0:345b3bc7a0ea 12 // Position and color (after rendering)
mbedalvaro 9:3321170d157c 13 unsigned short x, y; // position of the point (after rendering - its integer, because it is in "laser projector pixels")
mbedalvaro 1:a4050fee11f7 14 // char color; // laser color of the point (we will use the first three bits to set the RGB colors)
mbedalvaro 0:345b3bc7a0ea 15 // Detection:
mbedalvaro 0:345b3bc7a0ea 16 float intensity; // detected intensity
mbedalvaro 9:3321170d157c 17 char lightZone; // the thresholded light zone (allow for negative values for simply computing "negative" forces - although this is not necessarily the best option)
mbedalvaro 0:345b3bc7a0ea 18 };
mbedalvaro 0:345b3bc7a0ea 19
mbedalvaro 0:345b3bc7a0ea 20
mbedalvaro 0:345b3bc7a0ea 21 class LaserSensingTrajectory {
mbedalvaro 0:345b3bc7a0ea 22
mbedalvaro 0:345b3bc7a0ea 23 public:
mbedalvaro 0:345b3bc7a0ea 24
mbedalvaro 0:345b3bc7a0ea 25 LaserSensingTrajectory();
mbedalvaro 0:345b3bc7a0ea 26 ~LaserSensingTrajectory();
mbedalvaro 0:345b3bc7a0ea 27
mbedalvaro 0:345b3bc7a0ea 28 // METHODS:
mbedalvaro 0:345b3bc7a0ea 29 void processSensedData();
mbedalvaro 5:73cd58b58f95 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 5:73cd58b58f95 31
mbedalvaro 0:345b3bc7a0ea 32 // DATA:
mbedalvaro 0:345b3bc7a0ea 33 vector <laserSensingPoint> lsdTrajectory;
mbedalvaro 0:345b3bc7a0ea 34 char displayColor;
mbedalvaro 5:73cd58b58f95 35
mbedalvaro 4:f9d364f10335 36 // software adjustement of mirror delay:
mbedalvaro 5:73cd58b58f95 37 int delayMirrorSamples; // this is required because it will affect the way the blob behaves - it could be in the laser renderer, but by putting it here we can have more per-blob fine tunning
mbedalvaro 4:f9d364f10335 38
mbedalvaro 0:345b3bc7a0ea 39 // parameters for thresholding:
mbedalvaro 0:345b3bc7a0ea 40 float autoThreshold;
mbedalvaro 5:73cd58b58f95 41
mbedalvaro 0:345b3bc7a0ea 42 // Statistics and tests:
mbedalvaro 7:0df17f3078bc 43 //float lightRatio;
mbedalvaro 5:73cd58b58f95 44 float maxI, minI; // Max and Min intensity
mbedalvaro 0:345b3bc7a0ea 45 bool lightTouched; // true if something went over the autoThreshold for the whole loop
mbedalvaro 5:73cd58b58f95 46 // char coko;
mbedalvaro 0:345b3bc7a0ea 47 };
mbedalvaro 0:345b3bc7a0ea 48
mbedalvaro 0:345b3bc7a0ea 49 #endif
mbedalvaro 0:345b3bc7a0ea 50
mbedalvaro 0:345b3bc7a0ea 51