Skip to content
Snippets Groups Projects
Commit 7dd1613c authored by Andrews Sobral's avatar Andrews Sobral
Browse files

small fix

parent e3cc8313
No related branches found
No related tags found
No related merge requests found
......@@ -18,8 +18,8 @@ along with BGSLibrary. If not, see <http://www.gnu.org/licenses/>.
#include <opencv2/opencv.hpp>
using namespace cv;
//#include "package_bgs/bgslibrary.h"
#include "package_bgs/IBGS.h"
#include "package_bgs/bgslibrary.h"
using namespace ibgs;
int main(int argc, char **argv)
......@@ -45,8 +45,7 @@ int main(int argc, char **argv)
/* Background Subtraction Methods */
IBGS *bgs;
//bgs = new FrameDifference;
bgs=IBGS::create(std::string("FrameDifference"));
bgs = new FrameDifference;
//bgs = new StaticFrameDifference;
//bgs = new WeightedMovingMean;
//bgs = new WeightedMovingVariance;
......
......@@ -27,63 +27,58 @@ along with BGSLibrary. If not, see <http://www.gnu.org/licenses/>.
#define CV_RGB(r, g, b) cv::Scalar((b), (g), (r), 0)
namespace bgslibrary
{
namespace algorithms
{
class IBGS
{
public:
void setShowOutput(const bool _showOutput) {
showOutput = _showOutput;
}
cv::Mat apply(const cv::Mat &img_input) {
setShowOutput(false);
cv::Mat _img_foreground;
cv::Mat _img_background;
process(img_input, _img_foreground, _img_background);
namespace algorithms
{
class IBGS
{
public:
void setShowOutput(const bool _showOutput) {
showOutput = _showOutput;
}
cv::Mat apply(const cv::Mat &img_input) {
setShowOutput(false);
cv::Mat _img_foreground;
cv::Mat _img_background;
process(img_input, _img_foreground, _img_background);
_img_background.copyTo(img_background);
return _img_foreground;
}
cv::Mat getBackgroundModel() {
return img_background;
}
virtual void process(const cv::Mat &img_input, cv::Mat &img_foreground, cv::Mat &img_background) = 0;
virtual ~IBGS() {}
// create by name
static IBGS* create(const std::string alg_name);
static std::list<std::string> get_algs_name();
protected:
bool firstTime = true;
bool showOutput = true;
cv::Mat img_background;
cv::Mat img_foreground;
std::string config_xml;
void setup(const std::string _config_xml) {
config_xml = _config_xml;
if (!config_xml.empty()) {
if (!std::ifstream(config_xml))
saveConfig();
loadConfig();
}
}
void init(const cv::Mat &img_input, cv::Mat &img_outfg, cv::Mat &img_outbg) {
assert(img_input.empty() == false);
//img_outfg = cv::Mat::zeros(img_input.size(), img_input.type());
//img_outbg = cv::Mat::zeros(img_input.size(), img_input.type());
img_outfg = cv::Mat::zeros(img_input.size(), CV_8UC1);
img_outbg = cv::Mat::zeros(img_input.size(), CV_8UC3);
}
private:
virtual void saveConfig() = 0;
virtual void loadConfig() = 0;
};
}
return _img_foreground;
}
cv::Mat getBackgroundModel() {
return img_background;
}
virtual void process(const cv::Mat &img_input, cv::Mat &img_foreground, cv::Mat &img_background) = 0;
virtual ~IBGS() {}
//static IBGS* create(const std::string alg_name);
//static std::list<std::string> get_algs_name();
protected:
bool firstTime = true;
bool showOutput = true;
cv::Mat img_background;
cv::Mat img_foreground;
std::string config_xml;
void setup(const std::string _config_xml) {
config_xml = _config_xml;
if (!config_xml.empty()) {
if (!std::ifstream(config_xml))
saveConfig();
loadConfig();
}
}
void init(const cv::Mat &img_input, cv::Mat &img_outfg, cv::Mat &img_outbg) {
assert(img_input.empty() == false);
//img_outfg = cv::Mat::zeros(img_input.size(), img_input.type());
//img_outbg = cv::Mat::zeros(img_input.size(), img_input.type());
img_outfg = cv::Mat::zeros(img_input.size(), CV_8UC1);
img_outbg = cv::Mat::zeros(img_input.size(), CV_8UC3);
}
private:
virtual void saveConfig() = 0;
virtual void loadConfig() = 0;
};
}
}
namespace ibgs = bgslibrary::algorithms;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment