forked from rafaelbes/foveatedFeatures
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdetections.h
196 lines (177 loc) · 5.43 KB
/
detections.h
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
/**
* \file detections.h
*
* \brief This file contains the prototype and implementation of strategies
* to move the foveae.
*
* \author
* Petrucio Ricardo Tavares de Medeiros \n
* Universidade Federal do Rio Grande do Norte \n
* Departamento de Computacao e Automacao Industrial \n
* petrucior at gmail (dot) com
*
* \version 0.1
* \date February 2019
*
* \copyright
* Copyright (C) 2016, Petrúcio Ricardo <[email protected]>
* If you use this software for academic purposes, consider citing the related
* paper: Rafael Beserra Gomes, Bruno Motta de Carvalho, Luiz Marcos Garcia
* Gonçalves, Visual attention guided features selection with foveated images,
* Neurocomputing, Volume 120, 23 November 2013, Pages 34-44, ISSN 0925-2312,
* http://dx.doi.org/10.1016/j.neucom.2012.10.033.
*
* This file is part of foveatedFeatures software.
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version. This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details. You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DETECTIONS_H
#define DETECTIONS_H
#include <stdlib.h>
#include <iostream>
#include <vector>
#include "statistics.h"
/**
* \struct Detections
*
* \brief Struct of strategies to control the foveae.
*/
struct Detections {
//
// Variables
//
//
// Methods
//
/**
* \fn cv::Point lastPosition( cv::Point lastPosition )
*
* \brief Detection strategy that holds the last position.
*
* \param lastPosition - Last position used to detect
*
* \return Point estimated through last position
*/
cv::Point lastPosition( cv::Point lastPosition );
/**
* \fn cv::Point nFrames( std::vector< cv::Point > samples )
*
* \brief Detection strategy that holds the n last frames using MLE, but
* is possible to use kalman filter.
*
* \param samples - vector with position of all keypoints of n last frames
*
* \return Point estimated through n last position
*/
cv::Point nFrames( std::vector< cv::Point > samples );
/**
* \fn void disableFovea( bool &fovea )
*
* \brief Detection strategy that disable the fovea.
*
* \param fovea - Pointer to enable/disable fovea
*/
void disableFovea( bool &fovea );
/**
* \fn void increaseGrowthFactor( int &wx, int &wy, float multiplier )
*
* \brief Detection strategy that increase growth factor.
*
* \param wx - Pointer to increase x axis the fovea
* wy - Pointer to increase y axis the fovea
* multiplier - Multiplier that will increase the growth factor
*/
void increaseGrowthFactor( int &wx, int &wy, float multiplier );
/**
* \fn cv::Point saliencyMap( cv::Mat img )
*
* \brief Detection strategy that use saliency map to control
* foveae.
*
* \param img - Source image
*
* \return Point estimated through saliency map
*/
cv::Point saliencyMap( cv::Mat img );
};
#endif
/**
* \fn cv::Point lastPosition( cv::Point lastPosition )
*
* \brief Detection strategy that holds the last position.
*
* \param lastPosition - Last position used to detect
*
* \return Point estimated through last position
*/
cv::Point
Detections::lastPosition( cv::Point lastPosition ){
return lastPosition;
}
/**
* \fn cv::Point nFrames( std::vector< cv::Point > samples )
*
* \brief Detection strategy that holds the n last frames using MLE, but
* is possible to use kalman filter.
*
* \param samples - vector with position of all keypoints of n last frames
*
* \return Point estimated through n last position
*/
cv::Point
Detections::nFrames( std::vector< cv::Point > samples ){
Statistics statistic = new Statistics();
return statistic.maximumLikelihoodEstimator( samples );
}
/**
* \fn void disableFovea( bool &fovea )
*
* \brief Detection strategy that disable the fovea.
*
* \param fovea - Pointer to enable/disable fovea
* If fovea == 0, then the fovea is disable
*/
void
Detections::disableFovea( bool &fovea ){
fovea = 0; // Disabling the fovea
}
/**
* \fn void increaseGrowthFactor( int &wx, int &wy, float multiplier )
*
* \brief Detection strategy that increase growth factor.
*
* \param wx - Pointer to increase x axis the fovea
* wy - Pointer to increase y axis the fovea
* multiplier - Multiplier that will increase the growth factor
*/
void
Detections::increaseGrowthFactor( int &wx, int &wy, float multiplier ){
wx *= multiplier;
wy *= multiplier;
}
/**
* \fn cv::Point saliencyMap( cv::Mat img )
*
* \brief Detection strategy that use saliency map to control
* foveae.
*
* \param img - Source image
*
* \return Point estimated through saliency map
*/
cv::Point
Detections::saliencyMap( cv::Mat img ){
cv::Mat saliencyMap;
Ptr<Saliency> saliencyAlgorithm = Saliency::create("SPECTRAL_RESIDUAL");
saliencyAlgorithm.computeSaliency(img, saliencyMap);
// SaliencyMap contém o mapa de saliência da imagem passada como argumento
// a questão é detectar em qual parte do mapa de saliência se encontra o
// ponto de maior saliência da imagem
return cv::Point(0, 0);
}