45 #include <visp3/core/vpHinkley.h>
46 #if defined(VISP_BUILD_DEPRECATED_FUNCTIONS)
47 #include <visp3/core/vpDebug.h>
48 #include <visp3/core/vpMath.h>
74 vpHinkley::vpHinkley() : dmin2(0.1), alpha(0.2), nsignal(0), mean(0), Sk(0), Mk(0), Tk(0), Nk(0) { }
92 vpHinkley::vpHinkley(
double alpha_val,
double delta_val)
93 : dmin2(delta_val / 2.), alpha(alpha_val), nsignal(0), mean(0), Sk(0), Mk(0), Tk(0), Nk(0)
109 void vpHinkley::init(
double alpha_val,
double delta_val)
122 vpHinkley::~vpHinkley() { }
130 void vpHinkley::init()
150 void vpHinkley::setDelta(
double delta) { dmin2 = delta / 2; }
159 void vpHinkley::setAlpha(
double alpha_val) { this->alpha = alpha_val; }
171 vpHinkley::vpHinkleyJumpType vpHinkley::testDownwardJump(
double signal)
174 vpHinkleyJumpType jump = noJump;
186 vpCDEBUG(2) <<
"alpha: " << alpha <<
" dmin2: " << dmin2 <<
" signal: " << signal <<
" Sk: " << Sk <<
" Mk: " << Mk;
189 if ((Mk - Sk) > alpha)
193 if (VP_DEBUG_MODE >= 2) {
196 std::cout <<
"noJump " << std::endl;
199 std::cout <<
"downWardJump " << std::endl;
202 std::cout <<
"upwardJump " << std::endl;
210 if (jump == downwardJump) {
211 vpCDEBUG(2) <<
"\n*** Reset the Hinkley test ***\n";
231 vpHinkley::vpHinkleyJumpType vpHinkley::testUpwardJump(
double signal)
234 vpHinkleyJumpType jump = noJump;
246 vpCDEBUG(2) <<
"alpha: " << alpha <<
" dmin2: " << dmin2 <<
" signal: " << signal <<
" Tk: " << Tk <<
" Nk: " << Nk;
249 if ((Tk - Nk) > alpha)
253 if (VP_DEBUG_MODE >= 2) {
256 std::cout <<
"noJump " << std::endl;
259 std::cout <<
"downWardJump " << std::endl;
262 std::cout <<
"upWardJump " << std::endl;
269 if (jump == upwardJump) {
270 vpCDEBUG(2) <<
"\n*** Reset the Hinkley test ***\n";
290 vpHinkley::vpHinkleyJumpType vpHinkley::testDownUpwardJump(
double signal)
293 vpHinkleyJumpType jump = noJump;
307 vpCDEBUG(2) <<
"alpha: " << alpha <<
" dmin2: " << dmin2 <<
" signal: " << signal <<
" Sk: " << Sk <<
" Mk: " << Mk
308 <<
" Tk: " << Tk <<
" Nk: " << Nk << std::endl;
311 if ((Mk - Sk) > alpha)
313 else if ((Tk - Nk) > alpha)
317 if (VP_DEBUG_MODE >= 2) {
320 std::cout <<
"noJump " << std::endl;
323 std::cout <<
"downWardJump " << std::endl;
326 std::cout <<
"upwardJump " << std::endl;
334 if ((jump == upwardJump) || (jump == downwardJump)) {
335 vpCDEBUG(2) <<
"\n*** Reset the Hinkley test ***\n";
358 void vpHinkley::computeMean(
double signal)
366 if ((std::fabs(Mk - Sk) <= std::fabs(
vpMath::maximum(Mk, Sk)) * std::numeric_limits<double>::epsilon()) &&
367 (std::fabs(Tk - Nk) <= std::fabs(
vpMath::maximum(Tk, Nk)) * std::numeric_limits<double>::epsilon()))
371 mean = (mean * (nsignal - 1) + signal) / (nsignal);
380 void vpHinkley::computeSk(
double signal)
384 Sk += signal - mean + dmin2;
391 void vpHinkley::computeMk()
402 void vpHinkley::computeTk(
double signal)
406 Tk += signal - mean - dmin2;
413 void vpHinkley::computeNk()
419 void vpHinkley::print(vpHinkley::vpHinkleyJumpType jump)
423 std::cout <<
" No jump detected " << std::endl;
426 std::cout <<
" Jump downward detected " << std::endl;
429 std::cout <<
" Jump upward detected " << std::endl;
432 std::cout <<
" Jump detected " << std::endl;
437 #elif !defined(VISP_BUILD_SHARED_LIBS)
439 void dummy_vpRHinkley() { };
void init(unsigned int h, unsigned int w, Type value)
static Type maximum(const Type &a, const Type &b)