Skip to content

Commit 73b5a78

Browse files
authored
Merge pull request #3417 from tomoaki0705:fix_warning
2 parents d980cc3 + 52ec046 commit 73b5a78

File tree

1 file changed

+4
-31
lines changed

1 file changed

+4
-31
lines changed

modules/cudalegacy/src/fgd.cpp

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -345,29 +345,8 @@ namespace
345345

346346
namespace
347347
{
348-
void seqToContours(CvSeq* _ccontours, CvMemStorage* storage, OutputArrayOfArrays _contours)
349-
{
350-
Seq<CvSeq*> all_contours(cvTreeToNodeSeq(_ccontours, sizeof(CvSeq), storage));
351-
352-
size_t total = all_contours.size();
353-
354-
_contours.create((int) total, 1, 0, -1, true);
355-
356-
SeqIterator<CvSeq*> it = all_contours.begin();
357-
for (size_t i = 0; i < total; ++i, ++it)
358-
{
359-
CvSeq* c = *it;
360-
((CvContour*)c)->color = (int)i;
361-
_contours.create((int)c->total, 1, CV_32SC2, (int)i, true);
362-
Mat ci = _contours.getMat((int)i);
363-
CV_Assert( ci.isContinuous() );
364-
cvCvtSeqToArray(c, ci.data);
365-
}
366-
}
367-
368-
369348
int findForegroundRegions(GpuMat& d_foreground, Mat& h_foreground, std::vector< std::vector<Point> >& foreground_regions,
370-
CvMemStorage* storage, const FGDParams& params)
349+
const FGDParams& params)
371350
{
372351
int region_count = 0;
373352

@@ -380,12 +359,12 @@ namespace
380359
CV_Assert(contours.size() > 0);
381360

382361
// adding top-level contours to results, filtering by size
383-
for (int i = 0; i < contours.size(); ++i)
362+
for (size_t i = 0; i < contours.size(); ++i)
384363
{
385364
const std::vector<cv::Point> & cnt = contours[i];
386365
const cv::Rect brect = cv::boundingRect(cnt);
387366
bool isHole = hierarchy[i][3] >= 0; // contour with parent is hole
388-
if (brect.area() < params.minArea || isHole && params.is_obj_without_holes)
367+
if (brect.area() < params.minArea || (isHole && params.is_obj_without_holes))
389368
continue;
390369
foreground_regions.push_back(cnt);
391370
}
@@ -593,19 +572,14 @@ namespace
593572
Ptr<cuda::Filter> dilateFilter_;
594573
Ptr<cuda::Filter> erodeFilter_;
595574
#endif
596-
597-
CvMemStorage* storage_;
598575
};
599576

600577
FGDImpl::FGDImpl(const FGDParams& params) : params_(params), frameSize_(0, 0)
601578
{
602-
storage_ = cvCreateMemStorage();
603-
CV_Assert( storage_ != 0 );
604579
}
605580

606581
FGDImpl::~FGDImpl()
607582
{
608-
cvReleaseMemStorage(&storage_);
609583
}
610584

611585
void FGDImpl::apply(InputArray _frame, OutputArray fgmask, double)
@@ -621,7 +595,6 @@ namespace
621595
CV_Assert( curFrame.type() == CV_8UC3 || curFrame.type() == CV_8UC4 );
622596
CV_Assert( curFrame.size() == prevFrame_.size() );
623597

624-
cvClearMemStorage(storage_);
625598
foreground_regions_.clear();
626599
foreground_.setTo(Scalar::all(0));
627600

@@ -636,7 +609,7 @@ namespace
636609
#endif
637610

638611
if (params_.minArea > 0 || params_.is_obj_without_holes)
639-
findForegroundRegions(foreground_, h_foreground_, foreground_regions_, storage_, params_);
612+
findForegroundRegions(foreground_, h_foreground_, foreground_regions_, params_);
640613

641614
// Check ALL BG update condition:
642615
const double BGFG_FGD_BG_UPDATE_TRESH = 0.5;

0 commit comments

Comments
 (0)