Alvaro Cassinelli
/
skinGames_forktest
just a test
Fork of scoreLight_Advanced by
classLaserSensingTrajectory.h@24:4e52031a495b, 2012-06-18 (annotated)
- Committer:
- mbedalvaro
- Date:
- Mon Jun 18 08:00:57 2012 +0000
- Revision:
- 24:4e52031a495b
- Parent:
- 22:d87317d7ca91
- Child:
- 25:74cb85b85fd2
Various modifications for show at TV Asahi
Who changed what in which revision?
User | Revision | Line number | New 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 | 24:4e52031a495b | 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 | 24:4e52031a495b | 9 | #define THRESHOLD_FACTOR 0.55//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 | 10:6f8e48dca1bd | 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 | 11:62f7183a03e7 | 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 | 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 | 24:4e52031a495b | 31 | void addDelayMirrors(int add_delay); |
mbedalvaro | 5:73cd58b58f95 | 32 | |
mbedalvaro | 0:345b3bc7a0ea | 33 | // DATA: |
mbedalvaro | 0:345b3bc7a0ea | 34 | vector <laserSensingPoint> lsdTrajectory; |
mbedalvaro | 11:62f7183a03e7 | 35 | unsigned char displayColor; |
mbedalvaro | 5:73cd58b58f95 | 36 | |
mbedalvaro | 4:f9d364f10335 | 37 | // software adjustement of mirror delay: |
mbedalvaro | 24:4e52031a495b | 38 | unsigned char delayMirrorSamples; // this is required because it will affect the way the blob behaves - it |
mbedalvaro | 24:4e52031a495b | 39 | //could be in the laser renderer, but by putting it here we can have more per-blob fine tunning |
mbedalvaro | 4:f9d364f10335 | 40 | |
mbedalvaro | 0:345b3bc7a0ea | 41 | // parameters for thresholding: |
mbedalvaro | 11:62f7183a03e7 | 42 | unsigned char autoThreshold; // 0 to 255 |
mbedalvaro | 5:73cd58b58f95 | 43 | |
mbedalvaro | 0:345b3bc7a0ea | 44 | // Statistics and tests: |
mbedalvaro | 7:0df17f3078bc | 45 | //float lightRatio; |
mbedalvaro | 10:6f8e48dca1bd | 46 | unsigned char maxI, minI; // Max and Min intensity RATIOS (normalized between 0 and 255) |
mbedalvaro | 0:345b3bc7a0ea | 47 | bool lightTouched; // true if something went over the autoThreshold for the whole loop |
mbedalvaro | 5:73cd58b58f95 | 48 | // char coko; |
mbedalvaro | 0:345b3bc7a0ea | 49 | }; |
mbedalvaro | 0:345b3bc7a0ea | 50 | |
mbedalvaro | 0:345b3bc7a0ea | 51 | #endif |
mbedalvaro | 0:345b3bc7a0ea | 52 | |
mbedalvaro | 0:345b3bc7a0ea | 53 |