summaryrefslogtreecommitdiff
path: root/2005/i/robert/src/ovision/see/test_ovision.cc
blob: 765df94584706be2aba40268ff2713328c166466 (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
#include <iostream>
#include <stdlib.h>
#include <unistd.h>

#include "ovision.hh"

int 
main(int argv, char **argc)
{
    if (argv != 2)
      {
	std::cerr << "Usage : ./test_ovision {red, green}" << std::endl;
	return 1;
      }
    std::string arg (argc[1]);
    Group::ZoneType aim;
    if (arg == "red")
	aim = Group::redSkittle;
    else if (arg == "green")
	aim = Group::greenSkittle;
    else 
      {
	aim = Group::undefined;
	std::cerr << "Echec critique !" << std::endl;
      }
    OVision ovision;
    ovision.init (aim);

    int t = 200;
    while (t--)
      {
	// Prends une image
	ovision.takeShoot ();
	// Analyse une image
	ovision.update ();
	// Affiche d'info sur l'update
//	ovision.showInfo ();
	// Affiche les coordonn�es de la premi�re balle
//	double x, y;
//	if (ovision.getBall (x, y))
//	    std::cout << x <<"----" << y << std::endl;

	std::vector<Zone> &z = ovision.getSkittles ();
	for (unsigned i=0; i < z.size (); ++i)
	{
		int x, y, dist;
		double angle;
//		ovision.showInfo (z[i]);
		ovision.getLoc (z[i], x, y, angle, dist); 
	}
	usleep (500000);
      }
    return 0;
}