Hi,
I want to bound the foreground object by a rectangle, how shall I go about doing it?
I tried bounding the rectangle by collecting the white pixels , but it bounds the whole screen...

#include
#include "opencv2/imgcodecs.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/videoio.hpp"
#include
#include
#include
//C++
#include
#include
using namespace cv;
using namespace std;
//defined later
vector points;
RNG rng(12345);
// Global variables
Mat frame; //current frame
Mat fgMaskMOG2; //fg mask fg mask generated by MOG2 method
Mat frame_check;
Ptr pMOG2; //MOG2 Background subtractor
int keyboard; //input from keyboard
void help();
//void processVideo(char* videoFilename);
void processVideo();
void processImages(char* firstFrameFilename);
void help()
{
cout<< "--------------------------------------------------------------------------" << endl<< "This program shows how to use background subtraction methods provided by " << endl<< " OpenCV. You can process both videos (-vid) and images (-img)." << endl<< endl<< "Usage:" << endl<< "./bs {-vid