9 #include <opencv/highgui.h>
26 <<
"--------------------------------------------------------------------------" << endl
27 <<
"This program shows how to use ViBe with OpenCV " << endl
29 <<
"./main-opencv <video filename>" << endl
30 <<
"for example: ./main-opencv video.avi" << endl
31 <<
"--------------------------------------------------------------------------" << endl
38 int main(
int argc,
char* argv[])
45 cerr <<
"Incorrect input" << endl;
46 cerr <<
"exiting..." << endl;
52 namedWindow(
"Segmentation by ViBe");
69 VideoCapture capture(videoFilename);
71 if (!capture.isOpened()) {
73 cerr <<
"Unable to open video file: " << videoFilename << endl;
78 static int frameNumber = 1;
87 while ((
char)keyboard !=
'q' && (
char)keyboard != 27) {
89 if (!capture.read(frame)) {
90 cerr <<
"Unable to read next frame." << endl;
91 cerr <<
"Exiting..." << endl;
95 if ((frameNumber % 100) == 0) { cout <<
"Frame number = " << frameNumber << endl; }
102 cvtColor(frame, frame, CV_BGR2GRAY);
104 if (frameNumber == 1) {
105 segmentationMap = Mat(frame.rows, frame.cols, CV_8UC1);
119 medianBlur(segmentationMap, segmentationMap, 3);
122 imshow(
"Frame", frame);
123 imshow(
"Segmentation by ViBe", segmentationMap);
128 keyboard = waitKey(1);
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.
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)
void processVideo(char *videoFilename)
vibeModel_Sequential_t * libvibeModel_Sequential_New()
Interface for the ViBe library.
struct vibeModel_Sequential vibeModel_Sequential_t
Data structure for the background subtraction model.
int main(int argc, char *argv[])