Laser Sensing Display for UI interfaces in the real world
Fork of skinGames_forktest by
classLaserSensingTrajectory.h@32:52273c3291fe, 2012-10-29 (annotated)
- Committer:
- mbedalvaro
- Date:
- Mon Oct 29 14:28:47 2012 +0000
- Revision:
- 32:52273c3291fe
- Parent:
- 30:d8af03f01cd4
- Child:
- 33:43e8bc451ef0
code for Tokyo design week (starting with two colored following spots, and NO standby mode)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbedalvaro | 32:52273c3291fe | 1 | #ifndef LSDTRAJECTORY_H |
mbedalvaro | 32:52273c3291fe | 2 | #define LSDTRAJECTORY_H |
mbedalvaro | 32:52273c3291fe | 3 | |
mbedalvaro | 32:52273c3291fe | 4 | #include <vector> |
mbedalvaro | 32:52273c3291fe | 5 | using namespace std; |
mbedalvaro | 32:52273c3291fe | 6 | |
mbedalvaro | 32:52273c3291fe | 7 | // CONTRAST RATIO to compute autoThreshold: |
mbedalvaro | 32:52273c3291fe | 8 | // MIN_CONTRAST_RATIO is the minimum contrast between max and min intensity necessary to "accept" a black and white zone: |
mbedalvaro | 32:52273c3291fe | 9 | #define MIN_CONTRAST_RATIO 1.8//1.7 // 3 seems good when lookup table does not work |
mbedalvaro | 32:52273c3291fe | 10 | // THRESHOLD_FACTOR is where the threshold is actually placed between the min and max detected (with good contrast): |
mbedalvaro | 32:52273c3291fe | 11 | #define THRESHOLD_FACTOR 0.5 //0.75 // 2/3 or 1/2 are good values |
mbedalvaro | 32:52273c3291fe | 12 | #define MIN_ACCEPTABLE_INTENSITY 16 // if maxI< this then we consider all the saccade on something black |
mbedalvaro | 32:52273c3291fe | 13 | |
mbedalvaro | 32:52273c3291fe | 14 | struct laserSensingPoint { |
mbedalvaro | 32:52273c3291fe | 15 | // Position and color (after rendering) |
mbedalvaro | 32:52273c3291fe | 16 | unsigned short x, y; // position of the point (after rendering - its integer, because it is in "laser projector pixels") |
mbedalvaro | 32:52273c3291fe | 17 | // char color; // per point laser color (not used yet) |
mbedalvaro | 32:52273c3291fe | 18 | // Detection: |
mbedalvaro | 32:52273c3291fe | 19 | 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 | 32:52273c3291fe | 20 | 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 | 32:52273c3291fe | 21 | }; |
mbedalvaro | 32:52273c3291fe | 22 | |
mbedalvaro | 32:52273c3291fe | 23 | |
mbedalvaro | 32:52273c3291fe | 24 | class LaserSensingTrajectory { |
mbedalvaro | 32:52273c3291fe | 25 | |
mbedalvaro | 32:52273c3291fe | 26 | public: |
mbedalvaro | 32:52273c3291fe | 27 | |
mbedalvaro | 32:52273c3291fe | 28 | LaserSensingTrajectory(); |
mbedalvaro | 32:52273c3291fe | 29 | ~LaserSensingTrajectory(); |
mbedalvaro | 32:52273c3291fe | 30 | |
mbedalvaro | 32:52273c3291fe | 31 | // METHODS: |
mbedalvaro | 32:52273c3291fe | 32 | void processSensedData(); |
mbedalvaro | 32:52273c3291fe | 33 | 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 | 32:52273c3291fe | 34 | void addDelayMirrors(int add_delay); |
mbedalvaro | 32:52273c3291fe | 35 | |
mbedalvaro | 32:52273c3291fe | 36 | void setMinContrastRatio(float value) {min_contrast_ratio=value;}; |
mbedalvaro | 32:52273c3291fe | 37 | void setThresholdFactor(float value) {threshold_factor=value;}; |
mbedalvaro | 32:52273c3291fe | 38 | void setMinAcceptableIntensity(float value) {min_acceptable_intensity=value;}; |
mbedalvaro | 32:52273c3291fe | 39 | void multMinContrastRatio(float multfactor) {min_contrast_ratio*=multfactor;}; |
mbedalvaro | 32:52273c3291fe | 40 | void multThresholdFactor(float multfactor) {threshold_factor*=multfactor;}; |
mbedalvaro | 32:52273c3291fe | 41 | |
mbedalvaro | 32:52273c3291fe | 42 | // DATA: |
mbedalvaro | 32:52273c3291fe | 43 | vector <laserSensingPoint> lsdTrajectory; |
mbedalvaro | 32:52273c3291fe | 44 | unsigned char displayColor; // per blob color |
mbedalvaro | 32:52273c3291fe | 45 | |
mbedalvaro | 32:52273c3291fe | 46 | // software adjustement of mirror delay: |
mbedalvaro | 32:52273c3291fe | 47 | unsigned char delayMirrorSamples; // this is required because it will affect the way the blob behaves - it |
mbedalvaro | 32:52273c3291fe | 48 | //could be in the laser renderer, but by putting it here we can have more per-blob fine tunning |
mbedalvaro | 32:52273c3291fe | 49 | |
mbedalvaro | 32:52273c3291fe | 50 | // parameters for thresholding: |
mbedalvaro | 32:52273c3291fe | 51 | float min_contrast_ratio, threshold_factor, min_acceptable_intensity; |
mbedalvaro | 32:52273c3291fe | 52 | unsigned char autoThreshold; // 0 to 255 |
mbedalvaro | 32:52273c3291fe | 53 | |
mbedalvaro | 32:52273c3291fe | 54 | // Statistics and tests: |
mbedalvaro | 32:52273c3291fe | 55 | //float lightRatio; |
mbedalvaro | 32:52273c3291fe | 56 | unsigned char maxI, minI; // Max and Min intensity RATIOS (normalized between 0 and 255) |
mbedalvaro | 32:52273c3291fe | 57 | bool lightTouched; // true if something went over the autoThreshold for the whole loop |
mbedalvaro | 32:52273c3291fe | 58 | // char coko; |
mbedalvaro | 32:52273c3291fe | 59 | }; |
mbedalvaro | 32:52273c3291fe | 60 | |
mbedalvaro | 32:52273c3291fe | 61 | #endif |
mbedalvaro | 32:52273c3291fe | 62 | |
mbedalvaro | 32:52273c3291fe | 63 |