Skip to content

Commit d7870d9

Browse files
committed
Log Warning and GMG cuda patch
1 parent a3d235c commit d7870d9

File tree

8 files changed

+26
-21
lines changed

8 files changed

+26
-21
lines changed

modules/bgsegm/src/bgfg_gaussmix.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242

4343
#include "precomp.hpp"
4444
#include <float.h>
45+
#include "opencv2/core/utils/logger.hpp"
4546

4647
// to make sure we can use these short names
4748
#undef K
@@ -467,7 +468,7 @@ void BackgroundSubtractorMOGImpl::apply(InputArray _image, InputArray _knownFore
467468
Mat knownForegroundMask = _knownForegroundMask.getMat();
468469
if(!_knownForegroundMask.empty())
469470
{
470-
CV_Error( Error::StsNotImplemented, "Known Foreground Masking has not been implemented for this specific background subtractor, falling back to subtraction without known foreground");
471+
CV_LOG_WARNING(NULL, "Known Foreground Masking has not been implemented for this specific background subtractor, falling back to subtraction without known foreground");
471472
}
472473
apply(_image, _fgmask, learningRate);
473474
}

modules/bgsegm/src/bgfg_gmg.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
#include "precomp.hpp"
5252
#include "opencv2/core/utility.hpp"
5353
#include <limits>
54+
#include "opencv2/core/utils/logger.hpp"
5455

5556
namespace cv
5657
{
@@ -478,7 +479,7 @@ void BackgroundSubtractorGMGImpl::apply(InputArray _image, InputArray _knownFore
478479
Mat knownForegroundMask = _knownForegroundMask.getMat();
479480
if(!_knownForegroundMask.empty())
480481
{
481-
CV_Error( Error::StsNotImplemented, "Known Foreground Masking has not been implemented for this specific background subtractor, falling back to subtraction without known foreground");
482+
CV_LOG_WARNING(NULL, "Known Foreground Masking has not been implemented for this specific background subtractor, falling back to subtraction without known foreground");
482483
}
483484
apply(_image, _fgmask, newLearningRate);
484485
}

modules/bgsegm/src/bgfg_gsoc.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
#include <opencv2/calib3d.hpp>
5454
#include <iostream>
5555
#include "opencv2/core/cvdef.h"
56+
#include "opencv2/core/utils/logger.hpp"
5657

5758
namespace cv
5859
{
@@ -799,7 +800,7 @@ void BackgroundSubtractorGSOCImpl::apply(InputArray _image, InputArray _knownFor
799800
Mat knownForegroundMask = _knownForegroundMask.getMat();
800801
if(!_knownForegroundMask.empty())
801802
{
802-
CV_Error( Error::StsNotImplemented, "Known Foreground Masking has not been implemented for this specific background subtractor, falling back to subtraction without known foreground");
803+
CV_LOG_WARNING(NULL, "Known Foreground Masking has not been implemented for this specific background subtractor, falling back to subtraction without known foreground");
803804
}
804805
apply(_image, _fgmask, learningRate);
805806
}
@@ -943,7 +944,7 @@ void BackgroundSubtractorLSBPImpl::apply(InputArray _image, InputArray _knownFor
943944
Mat knownForegroundMask = _knownForegroundMask.getMat();
944945
if(!_knownForegroundMask.empty())
945946
{
946-
CV_Error( Error::StsNotImplemented, "Known Foreground Masking has not been implemented for this specific background subtractor, falling back to subtraction without known foreground");
947+
CV_LOG_WARNING(NULL, "Known Foreground Masking has not been implemented for this specific background subtractor, falling back to subtraction without known foreground");
947948
}
948949
apply(_image, _fgmask, learningRate);
949950
}

modules/bgsegm/src/bgfg_subcnt.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444

4545
#include "precomp.hpp"
4646
#include <functional>
47+
#include "opencv2/core/utils/logger.hpp"
4748

4849
namespace cv
4950
{
@@ -415,7 +416,7 @@ void BackgroundSubtractorCNTImpl::apply(InputArray _image, InputArray _knownFore
415416
Mat knownForegroundMask = _knownForegroundMask.getMat();
416417
if(!_knownForegroundMask.empty())
417418
{
418-
CV_Error( Error::StsNotImplemented, "Known Foreground Masking has not been implemented for this specific background subtractor, falling back to subtraction without known foreground");
419+
CV_LOG_WARNING(NULL, "Known Foreground Masking has not been implemented for this specific background subtractor, falling back to subtraction without known foreground");
419420
}
420421
apply(_image, _fgmask, learningRate);
421422
}

modules/cudabgsegm/src/mog.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
//M*/
4242

4343
#include "precomp.hpp"
44+
#include "opencv2/core/utils/logger.hpp"
4445

4546
using namespace cv;
4647
using namespace cv::cuda;
@@ -137,15 +138,15 @@ namespace
137138
void MOGImpl::apply(InputArray _image, InputArray _knownForegroundMask, OutputArray _fgmask, double learningRate){
138139
if(!_knownForegroundMask.empty())
139140
{
140-
CV_Error( Error::StsNotImplemented, "Known Foreground Masking has not been implemented for this specific background subtractor, falling back to subtraction without known foreground");
141+
CV_LOG_WARNING(NULL, "Known Foreground Masking has not been implemented for this specific background subtractor, falling back to subtraction without known foreground");
141142
}
142143
apply(_image, _fgmask, learningRate, Stream::Null());
143144
}
144145

145146
void MOGImpl::apply(InputArray _image, InputArray _knownForegroundMask, OutputArray _fgmask, double learningRate, Stream &stream){
146147
if(!_knownForegroundMask.empty())
147148
{
148-
CV_Error( Error::StsNotImplemented, "Known Foreground Masking has not been implemented for this specific background subtractor, falling back to subtraction without known foreground");
149+
CV_LOG_WARNING(NULL, "Known Foreground Masking has not been implemented for this specific background subtractor, falling back to subtraction without known foreground");
149150
}
150151
apply(_image, _fgmask, learningRate, stream);
151152
}

modules/cudabgsegm/src/mog2.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242

4343
#include "precomp.hpp"
4444
#include "cuda/mog2.hpp"
45+
#include "opencv2/core/utils/logger.hpp"
4546

4647
using namespace cv;
4748
using namespace cv::cuda;

modules/cudalegacy/src/fgd.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ Ptr<cuda::BackgroundSubtractorFGD> cv::cuda::createBackgroundSubtractorFGD(const
5555

5656
#include "cuda/fgd.hpp"
5757
#include "opencv2/imgproc.hpp"
58+
#include "opencv2/core/utils/logger.hpp"
5859

5960
/////////////////////////////////////////////////////////////////////////
6061
// FGDParams
@@ -589,6 +590,14 @@ namespace
589590
{
590591
}
591592

593+
void FGDImpl::apply(InputArray _image, InputArray _knownForegroundMask, OutputArray _fgmask, double learningRate){
594+
if(!_knownForegroundMask.empty())
595+
{
596+
CV_LOG_WARNING(NULL, "Known Foreground Masking has not been implemented for this specific background subtractor, falling back to subtraction without known foreground");
597+
}
598+
apply(_image, _fgmask, learningRate);
599+
}
600+
592601
void FGDImpl::apply(InputArray _frame, OutputArray fgmask, double)
593602
{
594603
GpuMat curFrame = _frame.getGpuMat();
@@ -630,15 +639,6 @@ namespace
630639
foreground_.copyTo(fgmask);
631640
}
632641

633-
void FGDImpl::apply(InputArray _image, InputArray _knownForegroundMask, OutputArray _fgmask, double learningRate){
634-
Mat knownForegroundMask = _knownForegroundMask.getMat();
635-
if(!_knownForegroundMask.empty())
636-
{
637-
CV_Error( Error::StsNotImplemented, "Known Foreground Masking has not been implemented for this specific background subtractor, falling back to subtraction without known foreground");
638-
}
639-
apply(_image, _fgmask, learningRate);
640-
}
641-
642642
void FGDImpl::getBackgroundImage(OutputArray backgroundImage) const
643643
{
644644
cuda::cvtColor(background_, backgroundImage, COLOR_BGRA2BGR);

modules/cudalegacy/src/gmg.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
//M*/
4242

4343
#include "precomp.hpp"
44+
#include "opencv2/core/utils/logger.hpp"
4445

4546
using namespace cv;
4647
using namespace cv::cuda;
@@ -170,19 +171,17 @@ namespace
170171
}
171172

172173
void GMGImpl::apply(InputArray _image, InputArray _knownForegroundMask, OutputArray _fgmask, double learningRate){
173-
Mat knownForegroundMask = _knownForegroundMask.getMat();
174174
if(!_knownForegroundMask.empty())
175175
{
176-
CV_Error( Error::StsNotImplemented, "Known Foreground Masking has not been implemented for this specific background subtractor, falling back to subtraction without known foreground");
176+
CV_LOG_WARNING(NULL, "Known Foreground Masking has not been implemented for this specific background subtractor, falling back to subtraction without known foreground");
177177
}
178-
apply(_image, _fgmask, Stream::Null());
178+
apply(_image, _fgmask, learningRate);
179179
}
180180

181181
void GMGImpl::apply(InputArray _image, InputArray _knownForegroundMask, OutputArray _fgmask, double learningRate, Stream& stream){
182-
Mat knownForegroundMask = _knownForegroundMask.getMat();
183182
if(!_knownForegroundMask.empty())
184183
{
185-
CV_Error( Error::StsNotImplemented, "Known Foreground Masking has not been implemented for this specific background subtractor, falling back to subtraction without known foreground");
184+
CV_LOG_WARNING(NULL, "Known Foreground Masking has not been implemented for this specific background subtractor, falling back to subtraction without known foreground");
186185
}
187186
apply(_image, _fgmask, learningRate, stream);
188187
}

0 commit comments

Comments
 (0)