Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
camtron
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
kr69sugu
camtron
Commits
7dd1613c
Commit
7dd1613c
authored
7 years ago
by
Andrews Sobral
Browse files
Options
Downloads
Patches
Plain Diff
small fix
parent
e3cc8313
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Demo.cpp
+3
-4
3 additions, 4 deletions
Demo.cpp
package_bgs/IBGS.h
+49
-54
49 additions, 54 deletions
package_bgs/IBGS.h
with
52 additions
and
58 deletions
Demo.cpp
+
3
−
4
View file @
7dd1613c
...
...
@@ -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;
...
...
This diff is collapsed.
Click to expand it.
package_bgs/IBGS.h
+
49
−
54
View file @
7dd1613c
...
...
@@ -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
;
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment