summaryrefslogtreecommitdiff
path: root/2003/i/buzz/src/vision/thresholds.h
blob: 42d73130ff8c04a482586079274c4873e76b3942 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#ifndef thresholds_h
#define thresholds_h
// thresholds.h - Chargement de seuils.
// buzz - Programme du robot Efrei Robotique I1-I2 2003
// Copyright (C) 2003 Nicolas Schodet

struct Threshold
{
    Threshold *next;
    unsigned char ym, yM, um, uM, vm, vM;
    unsigned char zone;
};

class Thresholds
{
    Threshold *m_thresholds;
  public:
    Thresholds (const char *filename);
    ~Thresholds (void);
    // Trouve la zone qui correspond aux composantes.
    unsigned char findZone (unsigned char y, unsigned char u, unsigned char v)
	const;
};

// Trouve la zone qui correspond aux composantes.
inline unsigned char
Thresholds::findZone (unsigned char y, unsigned char u, unsigned char v) const
{
    Threshold *t;
    for (t = m_thresholds; t; t = t->next)
      {
	if (y >= t->ym && y <= t->yM
	    && u >= t->um && u <= t->uM
	    && v >= t->vm && v <= t->vM)
	  {
	    return t->zone;
	  }
      }
    return 0;
}

#endif // thresholds_h