libvibe++ : a generic C++ library for the ViBe algorithm
DistanceL1.h
Go to the documentation of this file.
1 /* Copyright - Benjamin Laugraud <blaugraud@ulg.ac.be> - 2016
2  * Copyright - Marc Van Droogenbroeck <m.vandroogenbroeck@ulg.ac.be> - 2016
3  *
4  * ViBe is covered by a patent (see http://www.telecom.ulg.ac.be/research/vibe).
5  *
6  * Permission to use ViBe without payment of fee is granted for nonprofit
7  * educational and research purposes only.
8  *
9  * This work may not be copied or reproduced in whole or in part for any
10  * purpose.
11  *
12  * Copying, reproduction, or republishing for any purpose shall require a
13  * license. Please contact the authors in such cases. All the code is provided
14  * without any guarantee.
15  */
16 
17 /**
18  @file DistanceL1.h
19  @brief
20 
21  @author Benjamin Laungraud and Marc Van Droogenbroeck
22 
23  @date June 2016
24 */
25 
26 #ifndef _LIB_VIBE_XX_METAPROGRAMS_DISTANCE_L1_H_
27 #define _LIB_VIBE_XX_METAPROGRAMS_DISTANCE_L1_H_
28 
29 #include "../math/AbsoluteValue.h"
30 #include "../system/inline.h"
31 #include "../system/types.h"
32 
33 namespace ViBe {
34  namespace internals {
35  /* ====================================================================== *
36  * DistanceL1<Channels> *
37  * ====================================================================== */
38 
39  template <int32_t Channels, typename Encoding = uint8_t>
40  struct DistanceL1 {
41  STRONG_INLINE static uint32_t add(
42  const Encoding* pixel1,
43  const Encoding* pixel2
44  ) {
45  return (
46  AbsoluteValue::abs(*pixel1 - *pixel2) +
47  DistanceL1<Channels - 1>::add(pixel1 + 1, pixel2 + 1)
48  );
49  }
50  };
51 
52  /* ====================================================================== *
53  * DistanceL1<1> *
54  * ====================================================================== */
55 
56  template <typename Encoding>
57  struct DistanceL1<1, Encoding> {
58  STRONG_INLINE static uint32_t add(
59  const Encoding* pixel1,
60  const Encoding* pixel2
61  ) {
62  return AbsoluteValue::abs(*pixel1 - *pixel2);
63  }
64  };
65  } /* _NS_internals_ */
66 } /* _NS_ViBe_ */
67 
68 #endif /* _LIB_VIBE_XX_METAPROGRAMS_DISTANCE_L1_H_ */

License/Copyright

This code is copyrighted by the University of Liège, Belgium. 
It is only shared for research purposes. Please do not distribute it. 
B. Laugraud and M. Van Droogenbroeck, May 2016.