1、VIBE算法源码VIBE算法源码这是源代码,经过稍微的修改,可完美运行。测试环境为vs2015+opencv3.4.6无任何预处理,直接运行效果图:vibe-background-sequential.h/* file vibe-background-sequential.h brief Interface for the ViBe library author Marc Van Droogenbroeck date July 2014 details Full documentation is available online at: http:/www.ulg.ac.be/telecom/
2、research/vibe/doc All technical details are available in the following paper: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.verbatimBiBTeX information articleBarnich2011ViB
3、e, title = ViBe: A universal background subtraction algorithm for video sequences, author = O. Barnich and M. Van Droogenbroeck, journal = IEEE Transactions on Image Processing, volume = 20, number = 6, pages = 1709-1724, month = June, year = 2011, keywords = ViBe, Background, Background subtraction
4、, Segmentation, Motion, Motion detection, pdf = http:/orbi.ulg.ac.be/bitstream/2268/145853/1/Barnich2011ViBe.pdf, doi = 10.1109/TIP.2010.2101613, url = endverbatimSeecite Barnich2011ViBe*/#ifndef _VIBE_SEQUENTIAL_H_#define _VIBE_SEQUENTIAL_H_#ifdef _cplusplusextern C#endif#include #include #include
5、#include #define COLOR_BACKGROUND 0 /*! Default label for background pixels */#define COLOR_FOREGROUND 255 /*! Default label for foreground pixels. Note that some authors chose any value different from 0 instead */* * typedef struct vibeModel_Sequential_t * brief Data structure for the background su
6、btraction model. * * This data structure contains the background model as well as some paramaters value. * The code is designed to hide all the implementation details to the user to ease its use. */typedef struct vibeModel_Sequential vibeModel_Sequential_t;/* * Allocation of a new data structure whe
7、re the background model will be stored. * Please note that this function only creates the structure to host the data. * This data structures will only be filled with a call to ref libvibeModel_Sequential_AllocInit_8u_C1R. * * result A pointer to a newly allocated ref vibeModel_Sequential_t * structu
8、re, or NULL in the case of an error. */vibeModel_Sequential_t *libvibeModel_Sequential_New();/* * ViBe uses several parameters. * You can print and change some of them if you want. However, default * value should meet your needs for most videos. * * param model The data structure with ViBes backgrou
9、nd subtraction model and parameters. * return */uint32_t libvibeModel_Sequential_PrintParameters(const vibeModel_Sequential_t *model);/* * Setter. * * param model The data structure with ViBes background subtraction model and parameters. * param numberOfSamples * return */int32_t libvibeModel_Sequen
10、tial_SetNumberOfSamples( vibeModel_Sequential_t *model, const uint32_t numberOfSamples);/* * Setter. * * param model The data structure with ViBes background subtraction model and parameters. * return */uint32_t libvibeModel_Sequential_GetNumberOfSamples(const vibeModel_Sequential_t *model);/* * Set
11、ter. * * param model The data structure with ViBes background subtraction model and parameters. * param matchingThreshold * return */int32_t libvibeModel_Sequential_SetMatchingThreshold( vibeModel_Sequential_t *model, const uint32_t matchingThreshold);/* * Setter. * * param model The data structure
12、with ViBes background subtraction model and parameters. * return */uint32_t libvibeModel_Sequential_GetMatchingThreshold(const vibeModel_Sequential_t *model);/* * Setter. * * param model The data structure with ViBes background subtraction model and parameters. * param matchingNumber * return */int3
13、2_t libvibeModel_Sequential_SetMatchingNumber( vibeModel_Sequential_t *model, const uint32_t matchingNumber);/* * Setter. * * param model The data structure with ViBes background subtraction model and parameters. * param updateFactor New value for the update factor. Please note that the update facto
14、r 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. * return */int32_t libvibeModel_Sequential_SetUpdateFactor( vibeModel
15、_Sequential_t *model, const uint32_t updateFactor);/* * Getter. * * param model The data structure with ViBes background subtraction model and parameters. * return */uint32_t libvibeModel_Sequential_GetMatchingNumber(const vibeModel_Sequential_t *model);/* * Getter. * * param model The data structur
16、e with ViBes background subtraction model and parameters. * return */uint32_t libvibeModel_Sequential_GetUpdateFactor(const vibeModel_Sequential_t *model);/* * brief Frees all the memory used by the model and deallocates the structure. * * This function frees all the memory allocated by ref libvibeM
17、odel_SequentialNew and * ref libvibeModel_Sequential_AllocInit_8u_C1R or ref libvibeModel_Sequential_AllocInit_8u_C3R. * param model The data structure with ViBes background subtraction model and parameters. * return */int32_t libvibeModel_Sequential_Free(vibeModel_Sequential_t *model);/* * The two
18、following functions allocate the required memory according to the * model parameters and the dimensions of the input images. * You must use the C1R function for grayscale images and the C3R for color * images. * These 2 functions also initialize the background model using the content * of *image_dat
19、a which is the pixel buffer of the first image of your stream. */ - Single channel images -/* * * param model The data structure with ViBes background subtraction model and parameters. * param image_data * param width * param height * return */int32_t libvibeModel_Sequential_AllocInit_8u_C1R( vibeMo
20、del_Sequential_t *model, const uint8_t *image_data, const uint32_t width, const uint32_t height);/* These 2 functions perform 2 operations: * - they classify the pixels *image_data using the provided model and store * the results in *segmentation_map. * - they update *model according to these result
21、s and the content of * *image_data. * You must use the C1R function for grayscale images and the C3R for color * images. */* * * param model The data structure with ViBes background subtraction model and parameters. * param image_data * param segmentation_map * return */int32_t libvibeModel_Sequenti
22、al_Segmentation_8u_C1R( vibeModel_Sequential_t *model, const uint8_t *image_data, uint8_t *segmentation_map);/* * * param model The data structure with ViBes background subtraction model and parameters. * param image_data * param updating_mask * return */int32_t libvibeModel_Sequential_Update_8u_C1R
23、( vibeModel_Sequential_t *model, const uint8_t *image_data, uint8_t *updating_mask);/ - Three channel images -/* * The pixel values of color images are arranged in the following order * RGBRGBRGB. (or HSVHSVHSVHSVHSVHSV.) * * param model The data structure with ViBes background subtraction model and
24、 parameters. * param image_data * param width * param height * return */int32_t libvibeModel_Sequential_AllocInit_8u_C3R( vibeModel_Sequential_t *model, const uint8_t *image_data, const uint32_t width, const uint32_t height);/* These 2 functions perform 2 operations: * - they classify the pixels *im
25、age_data using the provided model and store * the results in *segmentation_map. * - they update *model according to these results and the content of * *image_data. * You must use the C1R function for grayscale images and the C3R for color * images. */* * The pixel values of color images are arranged
26、 in the following order * RGBRGBRGB. (or HSVHSVHSVHSVHSVHSV.) * * param model The data structure with ViBes background subtraction model and parameters. * param image_data * param segmentation_map * return */int32_t libvibeModel_Sequential_Segmentation_8u_C3R( vibeModel_Sequential_t *model, const ui
27、nt8_t *image_data, uint8_t *segmentation_map);/* * The pixel values of color images are arranged in the following order * RGBRGBRGB. (or HSVHSVHSVHSVHSVHSV.) * * param model The data structure with ViBes background subtraction model and parameters. * param image_data * param updating_mask * return *
28、/int32_t libvibeModel_Sequential_Update_8u_C3R( vibeModel_Sequential_t *model, const uint8_t *image_data, uint8_t *updating_mask);#ifdef _cplusplus#endif#endifvibe-background-sequential.cpp/* file vibe-background-sequential.c brief Implementation of vibe-background-sequential.h author Marc Van Droog
29、enbroeck date May 2014*/*There are a few implementation tricks by Marc Van Droogenbroeck.Please note that THEY DONT AFFECT THE BEHAVIOR OF ViBe but help speeding up the implementation; they are described hereafter.1. Swapping values in order to bring best matching candidates in the first places of t
30、he memoryThe idea is that ViBe only needs two matches to classify a pixel into the background; to some extent, the 18 other pixels (out of N=20 pixels) are then useless. In addition, most of the time, there are no big changes between pixels located at the same place from successive images (90% of the pixels are in the background on average). Ther
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1