@@ -345,29 +345,8 @@ namespace
345
345
346
346
namespace
347
347
{
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
-
369
348
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)
371
350
{
372
351
int region_count = 0 ;
373
352
@@ -380,12 +359,12 @@ namespace
380
359
CV_Assert (contours.size () > 0 );
381
360
382
361
// 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)
384
363
{
385
364
const std::vector<cv::Point> & cnt = contours[i];
386
365
const cv::Rect brect = cv::boundingRect (cnt);
387
366
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 ) )
389
368
continue ;
390
369
foreground_regions.push_back (cnt);
391
370
}
@@ -593,19 +572,14 @@ namespace
593
572
Ptr<cuda::Filter> dilateFilter_;
594
573
Ptr<cuda::Filter> erodeFilter_;
595
574
#endif
596
-
597
- CvMemStorage* storage_;
598
575
};
599
576
600
577
FGDImpl::FGDImpl (const FGDParams& params) : params_(params), frameSize_(0 , 0 )
601
578
{
602
- storage_ = cvCreateMemStorage ();
603
- CV_Assert ( storage_ != 0 );
604
579
}
605
580
606
581
FGDImpl::~FGDImpl ()
607
582
{
608
- cvReleaseMemStorage (&storage_);
609
583
}
610
584
611
585
void FGDImpl::apply (InputArray _frame, OutputArray fgmask, double )
@@ -621,7 +595,6 @@ namespace
621
595
CV_Assert ( curFrame.type () == CV_8UC3 || curFrame.type () == CV_8UC4 );
622
596
CV_Assert ( curFrame.size () == prevFrame_.size () );
623
597
624
- cvClearMemStorage (storage_);
625
598
foreground_regions_.clear ();
626
599
foreground_.setTo (Scalar::all (0 ));
627
600
@@ -636,7 +609,7 @@ namespace
636
609
#endif
637
610
638
611
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_);
640
613
641
614
// Check ALL BG update condition:
642
615
const double BGFG_FGD_BG_UPDATE_TRESH = 0.5 ;
0 commit comments