Bibliotheques TP RT  1.0
Bibliotheque de support pour TP/RT
image.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 dimercur
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
28 #ifndef _IMAGE_H_
29 #define _IMAGE_H_
30 
31 #ifndef __STUB__
32 #ifndef __FOR_PC__
33 #include <raspicam/raspicam_cv.h>
34 #else
35 #include <opencv2/highgui/highgui.hpp>
36 #endif /* __FOR_PC__ */
37 #else
38 #include <opencv2/highgui/highgui.hpp>
39 #endif
40 #include "opencv2/imgproc/imgproc.hpp"
41 #include <unistd.h>
42 #include <math.h>
43 
44 #define WIDTH 480 //1280 1024 640 480
45 #define HEIGHT 360 // 960 768 480 360
46 
47 using namespace std;
48 using namespace cv;
49 #ifndef __STUB__
50 #ifndef __FOR_PC__
51 using namespace raspicam;
52 #endif /* __FOR_PC__ */
53 #endif
54 
55 typedef Mat Image;
56 #ifndef __STUB__
57 #ifndef __FOR_PC__
58 typedef RaspiCam_Cv Camera;
59 #else
60 typedef int Camera;
61 #endif /* __FOR_PC__ */
62 #else
63 typedef int Camera;
64 #endif
65 
66 typedef Rect Arene;
67 typedef vector<unsigned char> Jpg;
68 
69 struct Position {
70  Point center;
71  Point direction;
72  float angle;
73 };
74 
82 int open_camera(Camera *camera);
83 
89 void close_camera(Camera *camera);
90 
100 void get_image(Camera *camera, Image * monImage, const char *fichier = NULL);
101 
109 int detect_arena(Image *monImage, Arene *rectangle);
110 
118 void draw_arena(Image *imgInput, Image *imgOutput, Arene *monArene);
119 
129 int detect_position(Image *imgInput, Position *posTriangle, Arene * monArene = NULL);
130 
139 void draw_position(Image *imgInput, Image *imgOutput, Position *positionRobot);
140 
148 void compress_image(Image *imgInput, Jpg *imageCompress);
149 
150 #endif // _IMAGE_H_
Point center
Definition: image.h:70
float angle
Definition: image.h:72
void draw_position(Image *imgInput, Image *imgOutput, Position *positionRobot)
Dessine sur une image en entrée la position d&#39;un robot et sa direction.
Rect Arene
Definition: image.h:66
int open_camera(Camera *camera)
Ouvre une camera.
void close_camera(Camera *camera)
Ferme la camera passé en paramètre.
Mat Image
Definition: image.h:55
int detect_position(Image *imgInput, Position *posTriangle, Arene *monArene=NULL)
Détecte la position d&#39;un robot.
void get_image(Camera *camera, Image *monImage, const char *fichier=NULL)
Capture une image avec la camera passée en entrée. En cas de test sans camera, la fonction charge une...
Definition: image.h:69
vector< unsigned char > Jpg
Definition: image.h:67
void draw_arena(Image *imgInput, Image *imgOutput, Arene *monArene)
Dessine le plus petit rectangle contenant l&#39;arène.
RaspiCam_Cv Camera
Definition: image.h:58
void compress_image(Image *imgInput, Jpg *imageCompress)
Détecte la position d&#39;un robot.
int detect_arena(Image *monImage, Arene *rectangle)
Détecte une arène dans une image fournis en paramètre.
Point direction
Definition: image.h:71