]> rtime.felk.cvut.cz Git - eurobot/public.git/blob - src/camera/color-finder/control/CRecognition.h
camera/color-finder: add teamcolor to recognition
[eurobot/public.git] / src / camera / color-finder / control / CRecognition.h
1 /*
2  * File name: CRecognition.h
3  * Date:      2010
4  * Author:   Tom Krajnik 
5  */
6
7 #ifndef __CRECOGNITION_H__
8 #define __CRECOGNITION_H__
9
10 #include <CRawImage.h>
11 #include <math.h>
12 #define MAX_SEGMENTS 10000
13
14 typedef struct{
15         int x;
16         int y;
17         int size;
18 }SSegment;
19
20 typedef struct{
21         int x;
22         int y;
23         bool info;
24 }SPixelPosition;
25
26 class CRecognition
27 {
28 public:
29   CRecognition();
30   ~CRecognition();
31   SPixelPosition findMean(CRawImage* image);
32   SPixelPosition findSegment(CRawImage* image);
33   void learnPixel(unsigned char* a,unsigned char color [3], int teamcolor);
34   void increaseTolerance();
35   void decreaseTolerance();
36   void resetColorMap();
37
38 private:
39   int tolerance;  
40   float evaluatePixel1(unsigned char* a);
41   float evaluatePixel2(unsigned char* a);
42   float evaluatePixel3(unsigned char* a);
43   int evaluatePixelFast(unsigned char *a);
44   void rgbToHsv(unsigned char r, unsigned char  g, unsigned char b, unsigned int *h, unsigned char *s, unsigned char *v );
45   static void sig_handler(int sig);
46
47   unsigned char learned[3];
48   unsigned int learnedHue;
49   unsigned char learnedSaturation,learnedValue;
50   unsigned char colorArray[64*64*64];
51   SSegment segmentArray[MAX_SEGMENTS];
52   bool debug;
53 };
54
55 #endif
56
57 /* end of CRecognition.h */