summaryrefslogtreecommitdiff
path: root/2004/i/nono/src/ovision/optim.cc
blob: 7c547d0369c10e11fc36f66ed3b48cf468eb6eb5 (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
87
88
89
90
91
92
93
94
95
#include "image/raw_loader.h"
#include "map.h"
#include "oconfig.h"
#include "group.h"
#include "space.h"

#include "segmTable.h"
#include "segmLearn.h"

#include <time.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/timeb.h>
static struct timeval _tstart, _tend;
static struct timezone tz;

void tstart(void)
{
    gettimeofday(&_tstart, &tz);
}
void tend(void)
{
    gettimeofday(&_tend,&tz);
}

double tval()
{
    double t1, t2;
    t1 =  (double)_tstart.tv_sec + (double)_tstart.tv_usec/(1000*1000);
    t2 =  (double)_tend.tv_sec + (double)_tend.tv_usec/(1000*1000);
    return t2-t1;
}



int
main()
{
    /////////////////////////////////////////////////////////////////////////////////////////
    /// Initialisation des classes
    tstart ();
    OConfig oconfig("rc/vision.conf");

    Img img;
    RawLoader rawLoader("../src/ovision/test.rgb", 360, 296, ImageLoader::rgb);
    img.load(rawLoader);

    Space space(img.width, img.height);
    space.AddSetupPoint (356, 23, 300, 300);
    space.AddSetupPoint (283, 171, 600, 600);
    space.AddSetupPoint (253, 234, 1000, 900);
    space.Setup (0.00603759, 0.593767, 291.474);

    SegmTable segmNN(&img);
    segmNN.BuildNN(oconfig.nn_NbCouleurs, LOAD_FROM_FILE);
    segmNN.DoColorTable ();

    Group group(&img, &segmNN);

    Map map(&space);
    tend ();
    std::cout << "Initialisation:\t" << tval () << std::endl;
    /////////////////////////////////////////////////////////////////////////////////////////


    /////////////////////////////////////////////////////////////////////////////////////////
    /// Prends une image a partir de la camera  et l'analyse

    tstart ();
    //segmNN.Segm();
    tend ();
    std::cout << "Segmentation:\t" << tval () << std::endl;

    tstart ();
    group.JumpPoints(oconfig.groupColor);
    tend ();
    std::cout << "Find Group:\t" << tval () << std::endl;

    group.ShowZones ();
    
    tstart ();
    if (group.zoneListBall)
      {
	int x,y;
	x = group.zoneListBall->centerx;
	y = img.height -  group.zoneListBall->centery;
	space.GetLoc(x, y, x, y);
	tend ();
	std::cout << "Map:\t\t" << tval () << std::endl;

      }
    /////////////////////////////////////////////////////////////////////////////////////////
}