C/C++ library for the ViBe algorithm
vibe-background-sequential.h
Go to the documentation of this file.
1 /**
2  @file vibe-background-sequential.h
3  @brief Interface for the ViBe library
4 
5  @author Marc Van Droogenbroeck
6 
7  @date July 2014
8 
9  @details
10 
11  Full documentation is available online at:
12  http://www.ulg.ac.be/telecom/research/vibe/doc
13 
14  All technical details are available in the following paper:
15 <em>O. Barnich and M. Van Droogenbroeck. ViBe: A universal background subtraction algorithm for video sequences. IEEE Transactions on Image Processing, 20(6):1709-1724, June 2011.</em>
16 
17 \verbatim
18 BiBTeX information
19 
20  @article{Barnich2011ViBe,
21  title = {{ViBe}: A universal background subtraction algorithm for video sequences},
22  author = {O. Barnich and M. {Van Droogenbroeck}},
23  journal = {IEEE Transactions on Image Processing},
24  volume = {20},
25  number = {6},
26  pages = {1709-1724},
27  month = {June},
28  year = {2011},
29  keywords = {ViBe, Background, Background subtraction, Segmentation, Motion, Motion detection},
30  pdf = {http://orbi.ulg.ac.be/bitstream/2268/145853/1/Barnich2011ViBe.pdf},
31  doi = {10.1109/TIP.2010.2101613},
32  url = {http://hdl.handle.net/2268/145853}
33  }
34 \endverbatim
35 
36 See
37 \cite Barnich2011ViBe
38 */
39 
40 #ifndef _VIBE_SEQUENTIAL_H_
41 #define _VIBE_SEQUENTIAL_H_
42 
43 #ifdef __cplusplus
44 extern "C"
45 {
46 #endif
47 
48 #include <stdlib.h>
49 #include <stdint.h>
50 #include <stdio.h>
51 #include <string.h>
52 
53 #define COLOR_BACKGROUND 0 /*!< Default label for background pixels */
54 #define COLOR_FOREGROUND 255 /*!< Default label for foreground pixels. Note that some authors chose any value different from 0 instead */
55 
56 /**
57  * \typedef struct vibeModel_Sequential_t
58  * \brief Data structure for the background subtraction model.
59  *
60  * This data structure contains the background model as well as some paramaters value.
61  * The code is designed to hide all the implementation details to the user to ease its use.
62  */
63 typedef struct vibeModel_Sequential vibeModel_Sequential_t;
64 
65 /**
66  * Allocation of a new data structure where the background model will be stored.
67  * Please note that this function only creates the structure to host the data.
68  * This data structures will only be filled with a call to \ref libvibeModel_Sequential_AllocInit_8u_C1R.
69  *
70  * \result A pointer to a newly allocated \ref vibeModel_Sequential_t
71  * structure, or <tt>NULL</tt> in the case of an error.
72  */
74 
75 /**
76  * ViBe uses several parameters.
77  * You can print and change some of them if you want. However, default
78  * value should meet your needs for most videos.
79  *
80  * @param model The data structure with ViBe's background subtraction model and parameters.
81  * @return
82  */
84 
85 /**
86  * Setter.
87  *
88  * @param model The data structure with ViBe's background subtraction model and parameters.
89  * @param numberOfSamples
90  * @return
91  */
94  const uint32_t numberOfSamples
95 );
96 
97 /**
98  * Setter.
99  *
100  * @param model The data structure with ViBe's background subtraction model and parameters.
101  * @return
102  */
104 
105 /**
106  * Setter.
107  *
108  * @param model The data structure with ViBe's background subtraction model and parameters.
109  * @param matchingThreshold
110  * @return
111  */
113  vibeModel_Sequential_t *model,
114  const uint32_t matchingThreshold
115 );
116 
117 /**
118  * Setter.
119  *
120  * @param model The data structure with ViBe's background subtraction model and parameters.
121  * @return
122  */
124 
125 /**
126  * Setter.
127  *
128  * @param model The data structure with ViBe's background subtraction model and parameters.
129  * @param matchingNumber
130  * @return
131  */
133  vibeModel_Sequential_t *model,
134  const uint32_t matchingNumber
135 );
136 
137 /**
138  * Setter.
139  *
140  * @param model The data structure with ViBe's background subtraction model and parameters.
141  * @param updateFactor New value for the update factor. Please note that the update factor is to be understood as a probability of updating. More specifically, an update factor of 16 means that 1 out of every 16 background pixels is updated. Likewise, an update factor of 1 means that every background pixel is updated.
142  * @return
143  */
145  vibeModel_Sequential_t *model,
146  const uint32_t updateFactor
147 );
148 
149 /**
150  * Getter.
151  *
152  * @param model The data structure with ViBe's background subtraction model and parameters.
153  * @return
154  */
156 
157 
158 /**
159  * Getter.
160  *
161  * @param model The data structure with ViBe's background subtraction model and parameters.
162  * @return
163  */
165 
166 /**
167  * \brief Frees all the memory used by the <tt>model</tt> and deallocates the structure.
168  *
169  * This function frees all the memory allocated by \ref libvibeModel_SequentialNew and
170  * \ref libvibeModel_Sequential_AllocInit_8u_C1R or \ref libvibeModel_Sequential_AllocInit_8u_C3R.
171  * @param model The data structure with ViBe's background subtraction model and parameters.
172  * @return
173  */
175 
176 /**
177  * The two following functions allocate the required memory according to the
178  * model parameters and the dimensions of the input images.
179  * You must use the "C1R" function for grayscale images and the "C3R" for color
180  * images.
181  * These 2 functions also initialize the background model using the content
182  * of *image_data which is the pixel buffer of the first image of your stream.
183  */
184 // ------------------------- Single channel images ----------------------------
185 /**
186  *
187  * @param model The data structure with ViBe's background subtraction model and parameters.
188  * @param image_data
189  * @param width
190  * @param height
191  * @return
192  */
194  vibeModel_Sequential_t *model,
195  const uint8_t *image_data,
196  const uint32_t width,
197  const uint32_t height
198 );
199 
200 /* These 2 functions perform 2 operations:
201  * - they classify the pixels *image_data using the provided model and store
202  * the results in *segmentation_map.
203  * - they update *model according to these results and the content of
204  * *image_data.
205  * You must use the "C1R" function for grayscale images and the "C3R" for color
206  * images.
207  */
208 /**
209  *
210  * @param model The data structure with ViBe's background subtraction model and parameters.
211  * @param image_data
212  * @param segmentation_map
213  * @return
214  */
216  vibeModel_Sequential_t *model,
217  const uint8_t *image_data,
218  uint8_t *segmentation_map
219 );
220 
221 /**
222  *
223  * @param model The data structure with ViBe's background subtraction model and parameters.
224  * @param image_data
225  * @param updating_mask
226  * @return
227  */
229  vibeModel_Sequential_t *model,
230  const uint8_t *image_data,
231  uint8_t *updating_mask
232 );
233 
234 // ------------------------- Three channel images -----------------------------
235 /**
236  * The pixel values of color images are arranged in the following order
237  * RGBRGBRGB... (or HSVHSVHSVHSVHSVHSV...)
238  *
239  * @param model The data structure with ViBe's background subtraction model and parameters.
240  * @param image_data
241  * @param width
242  * @param height
243  * @return
244  */
246  vibeModel_Sequential_t *model,
247  const uint8_t *image_data,
248  const uint32_t width,
249  const uint32_t height
250 );
251 
252 /* These 2 functions perform 2 operations:
253  * - they classify the pixels *image_data using the provided model and store
254  * the results in *segmentation_map.
255  * - they update *model according to these results and the content of
256  * *image_data.
257  * You must use the "C1R" function for grayscale images and the "C3R" for color
258  * images.
259  */
260 /**
261  * The pixel values of color images are arranged in the following order
262  * RGBRGBRGB... (or HSVHSVHSVHSVHSVHSV...)
263  *
264  * @param model The data structure with ViBe's background subtraction model and parameters.
265  * @param image_data
266  * @param segmentation_map
267  * @return
268  */
270  vibeModel_Sequential_t *model,
271  const uint8_t *image_data,
272  uint8_t *segmentation_map
273 );
274 
275 /**
276  * The pixel values of color images are arranged in the following order
277  * RGBRGBRGB... (or HSVHSVHSVHSVHSVHSV...)
278  *
279  * @param model The data structure with ViBe's background subtraction model and parameters.
280  * @param image_data
281  * @param updating_mask
282  * @return
283  */
285  vibeModel_Sequential_t *model,
286  const uint8_t *image_data,
287  uint8_t *updating_mask
288 );
289 
290 #ifdef __cplusplus
291 }
292 #endif
293 
294 #endif
uint32_t libvibeModel_Sequential_GetUpdateFactor(const vibeModel_Sequential_t *model)
int32_t libvibeModel_Sequential_Segmentation_8u_C1R(vibeModel_Sequential_t *model, const uint8_t *image_data, uint8_t *segmentation_map)
int32_t libvibeModel_Sequential_Free(vibeModel_Sequential_t *model)
Frees all the memory used by the model and deallocates the structure.
uint32_t libvibeModel_Sequential_GetMatchingThreshold(const vibeModel_Sequential_t *model)
uint32_t libvibeModel_Sequential_PrintParameters(const vibeModel_Sequential_t *model)
int32_t libvibeModel_Sequential_Segmentation_8u_C3R(vibeModel_Sequential_t *model, const uint8_t *image_data, uint8_t *segmentation_map)
int32_t libvibeModel_Sequential_Update_8u_C1R(vibeModel_Sequential_t *model, const uint8_t *image_data, uint8_t *updating_mask)
int32_t libvibeModel_Sequential_AllocInit_8u_C1R(vibeModel_Sequential_t *model, const uint8_t *image_data, const uint32_t width, const uint32_t height)
uint32_t libvibeModel_Sequential_GetNumberOfSamples(const vibeModel_Sequential_t *model)
int32_t libvibeModel_Sequential_Update_8u_C3R(vibeModel_Sequential_t *model, const uint8_t *image_data, uint8_t *updating_mask)
int32_t libvibeModel_Sequential_AllocInit_8u_C3R(vibeModel_Sequential_t *model, const uint8_t *image_data, const uint32_t width, const uint32_t height)
int32_t libvibeModel_Sequential_SetMatchingNumber(vibeModel_Sequential_t *model, const uint32_t matchingNumber)
vibeModel_Sequential_t * libvibeModel_Sequential_New()
int32_t libvibeModel_Sequential_SetUpdateFactor(vibeModel_Sequential_t *model, const uint32_t updateFactor)
uint32_t libvibeModel_Sequential_GetMatchingNumber(const vibeModel_Sequential_t *model)
int32_t libvibeModel_Sequential_SetNumberOfSamples(vibeModel_Sequential_t *model, const uint32_t numberOfSamples)
int32_t libvibeModel_Sequential_SetMatchingThreshold(vibeModel_Sequential_t *model, const uint32_t matchingThreshold)
struct vibeModel_Sequential vibeModel_Sequential_t
Data structure for the background subtraction model.

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. 
Prof. M. Van Droogenbroeck, July 2014.