Alvaro Cassinelli
/
skinGames_forktest
just a test
Fork of scoreLight_Advanced by
classLaserSensingTrajectory.h@11:62f7183a03e7, 2012-04-12 (annotated)
- Committer:
- mbedalvaro
- Date:
- Thu Apr 12 05:16:48 2012 +0000
- Revision:
- 11:62f7183a03e7
- Parent:
- 10:6f8e48dca1bd
- Child:
- 14:0fc33a3a7b4b
It seems to work (but not tested on real hardware). ; NEEDS TO DO: ; 1) DOUBLE BUFFERING; 2) template class for vector2D, so as to use unsigned short for the rigid scafold instead of float...;
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 | 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 | 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 | 5:73cd58b58f95 | 31 | |
mbedalvaro | 0:345b3bc7a0ea | 32 | // DATA: |
mbedalvaro | 0:345b3bc7a0ea | 33 | vector <laserSensingPoint> lsdTrajectory; |
mbedalvaro | 11:62f7183a03e7 | 34 | unsigned char displayColor; |
mbedalvaro | 5:73cd58b58f95 | 35 | |
mbedalvaro | 4:f9d364f10335 | 36 | // software adjustement of mirror delay: |
mbedalvaro | 10:6f8e48dca1bd | 37 | unsigned char 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 | 11:62f7183a03e7 | 40 | unsigned char autoThreshold; // 0 to 255 |
mbedalvaro | 5:73cd58b58f95 | 41 | |
mbedalvaro | 0:345b3bc7a0ea | 42 | // Statistics and tests: |
mbedalvaro | 7:0df17f3078bc | 43 | //float lightRatio; |
mbedalvaro | 10:6f8e48dca1bd | 44 | unsigned char maxI, minI; // Max and Min intensity RATIOS (normalized between 0 and 255) |
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 |