summaryrefslogtreecommitdiff
path: root/2004/i/nono/src/ovision/space.h
blob: 52f6e6d0f35db0e3e7da21b96514188ceaa6902b (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#ifndef space_h
#define space_h
// space.h - Space class
// nono - Programme du robot Efrei Robotique I1-I2 2004
// Copyright (C) 2004 Olivier Gaillard

#include <vector>
#include <iostream>

#define POS_ROBOT_ETALONNOGE_X 300

#include "group.h"
#include "oconfig.h"

struct SETUP_POINT
{
    int x, y;
    int distx, disty;
};


/// Etalonnage des distances et localisation de la balle
class Space
{
    /// Classe config
    OConfig *oconfig;
    
    /// tableau d'index des distances
    uint *tabX;
    uint *tabY;
    
    /// liste des distances etalonnees
    std::vector<SETUP_POINT> setupTab; 

    /// hautdddeur de l'image
    int imgHeight; 

    /// largeur de l'image
    int imgWidth; 

    /// coeff pour l'approximation de la profondeur
    double coefY[NB_POINTS];

    /// coeff pour l'approximation de l'horizontal
    double coefX[NB_POINTS];

  public:

    // Constructeur
    Space (int width, int height);

    // Destructeur
    ~Space ();

    /// Position d'un objet dans le referentiel du robot
    void GetLoc(int locImgX, int locImgY, int &locX, int &locY);
    void GetLoc(int locImgX, int locImgY, double &locX, double &locY);

    /// Ajoute un point pour l'etalonnage
    void AddSetupPoint(int x, int y, int distx, int disty);

    /// Chargement des points a partir d'un fichier
    void LoadFromFile();

    /// Etalonnage des distances
    int Setup();

    void Setup(double aX, double bX, double cX, double aY, double bY, double cY);
  protected:
    /// Calcul du determinant
    double Determinant33(double *matrix);
    double Determinant(double *matrix, int n);

    double CoeffDeterminant (double *matrix, int i, int n);

    
    /// Calcul du determinant caracteristique
    double CaracteristicDeterminant(double *matrix, double *endMat, int numCol);

    /// Donne la position reelle sur la table de la balle
    void GetPos(int locX, int locY, int posRobotX, int posRobotY, double angleRobot, int &posX, int &posY);

    int BestFitDoTab(double *mat, double *endMat);
};

#endif // space_h