Skip to content

Commit d880a9a

Browse files
committed
Remove more C code
1 parent 9e0bae6 commit d880a9a

File tree

11 files changed

+73
-166
lines changed

11 files changed

+73
-166
lines changed

modules/ccalib/src/ccalib.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
#include "opencv2/ccalib.hpp"
4848

4949
#include <opencv2/core.hpp>
50-
#include <opencv2/core/types_c.h> // CV_TERM
5150
#include <opencv2/imgproc.hpp>
5251
#include <opencv2/calib3d.hpp>
5352
#include <opencv2/features2d.hpp>
@@ -221,7 +220,7 @@ void CustomPattern::refinePointsPos(const Mat& img, vector<Point2f>& p)
221220
Mat gray;
222221
cvtColor(img, gray, COLOR_RGB2GRAY);
223222
cornerSubPix(gray, p, Size(10, 10), Size(-1, -1),
224-
TermCriteria(CV_TERMCRIT_ITER + CV_TERMCRIT_EPS, 30, 0.1));
223+
TermCriteria(TermCriteria::MAX_ITER | TermCriteria::EPS, 30, 0.1));
225224

226225
}
227226

modules/cudalegacy/src/fgd.cpp

Lines changed: 12 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Ptr<cuda::BackgroundSubtractorFGD> cv::cuda::createBackgroundSubtractorFGD(const
5454
#else
5555

5656
#include "cuda/fgd.hpp"
57-
#include "opencv2/imgproc/imgproc_c.h"
57+
#include "opencv2/imgproc.hpp"
5858

5959
/////////////////////////////////////////////////////////////////////////
6060
// FGDParams
@@ -345,69 +345,35 @@ 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-
368348
int findForegroundRegions(GpuMat& d_foreground, Mat& h_foreground, std::vector< std::vector<Point> >& foreground_regions,
369-
CvMemStorage* storage, const FGDParams& params)
349+
const FGDParams& params)
370350
{
371351
int region_count = 0;
372352

373353
// Discard under-size foreground regions:
374354

375355
d_foreground.download(h_foreground);
376-
IplImage ipl_foreground = cvIplImage(h_foreground);
377-
CvSeq* first_seq = 0;
378356

379-
cvFindContours(&ipl_foreground, storage, &first_seq, sizeof(CvContour), CV_RETR_LIST);
357+
int mode = RETR_LIST;
358+
if (params.is_obj_without_holes) mode |= RETR_EXTERNAL;
359+
findContours(h_foreground, foreground_regions, mode, CHAIN_APPROX_NONE);
380360

381-
for (CvSeq* seq = first_seq; seq; seq = seq->h_next)
361+
for (size_t i = 0; i < foreground_regions.size(); ++i)
382362
{
383-
CvContour* cnt = reinterpret_cast<CvContour*>(seq);
363+
const std::vector<Point> &cnt = foreground_regions[i];
364+
const Rect rect = boundingRect(cnt);
384365

385-
if (cnt->rect.width * cnt->rect.height < params.minArea || (params.is_obj_without_holes && CV_IS_SEQ_HOLE(seq)))
366+
if (rect.width * rect.height < params.minArea)
386367
{
387368
// Delete under-size contour:
388-
CvSeq* prev_seq = seq->h_prev;
389-
if (prev_seq)
390-
{
391-
prev_seq->h_next = seq->h_next;
392-
393-
if (seq->h_next)
394-
seq->h_next->h_prev = prev_seq;
395-
}
396-
else
397-
{
398-
first_seq = seq->h_next;
399-
400-
if (seq->h_next)
401-
seq->h_next->h_prev = NULL;
402-
}
403369
}
404370
else
405371
{
406-
region_count++;
372+
foreground_regions[region_count++] = foreground_regions[i];
407373
}
408374
}
409375

410-
seqToContours(first_seq, storage, foreground_regions);
376+
foreground_regions.resize(region_count);
411377
h_foreground.setTo(0);
412378

413379
drawContours(h_foreground, foreground_regions, -1, Scalar::all(255), -1);
@@ -612,19 +578,14 @@ namespace
612578
Ptr<cuda::Filter> dilateFilter_;
613579
Ptr<cuda::Filter> erodeFilter_;
614580
#endif
615-
616-
CvMemStorage* storage_;
617581
};
618582

619583
FGDImpl::FGDImpl(const FGDParams& params) : params_(params), frameSize_(0, 0)
620584
{
621-
storage_ = cvCreateMemStorage();
622-
CV_Assert( storage_ != 0 );
623585
}
624586

625587
FGDImpl::~FGDImpl()
626588
{
627-
cvReleaseMemStorage(&storage_);
628589
}
629590

630591
void FGDImpl::apply(InputArray _frame, OutputArray fgmask, double)
@@ -640,7 +601,6 @@ namespace
640601
CV_Assert( curFrame.type() == CV_8UC3 || curFrame.type() == CV_8UC4 );
641602
CV_Assert( curFrame.size() == prevFrame_.size() );
642603

643-
cvClearMemStorage(storage_);
644604
foreground_regions_.clear();
645605
foreground_.setTo(Scalar::all(0));
646606

@@ -655,7 +615,7 @@ namespace
655615
#endif
656616

657617
if (params_.minArea > 0 || params_.is_obj_without_holes)
658-
findForegroundRegions(foreground_, h_foreground_, foreground_regions_, storage_, params_);
618+
findForegroundRegions(foreground_, h_foreground_, foreground_regions_, params_);
659619

660620
// Check ALL BG update condition:
661621
const double BGFG_FGD_BG_UPDATE_TRESH = 0.5;

modules/cvv/samples/cvv_demo.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
// library includes
55
#include <opencv2/imgproc.hpp>
66
#include <opencv2/features2d.hpp>
7-
#include <opencv2/imgproc/types_c.h>
87
#include <opencv2/videoio.hpp>
9-
#include <opencv2/videoio/videoio_c.h>
108

119
#define CVVISUAL_DEBUGMODE
1210
#include <opencv2/cvv/debug_mode.hpp>

modules/dpm/samples/cascade_detect_camera.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
#include <opencv2/imgproc.hpp>
4646
#include <opencv2/highgui.hpp>
4747
#include <opencv2/videoio.hpp>
48-
#include <opencv2/videoio/videoio_c.h>
4948

5049
#include <stdio.h>
5150
#include <iostream>
@@ -88,8 +87,8 @@ int main( int argc, char** argv )
8887

8988
// use web camera
9089
VideoCapture capture(0);
91-
capture.set(CV_CAP_PROP_FRAME_WIDTH, 320);
92-
capture.set(CV_CAP_PROP_FRAME_HEIGHT, 240);
90+
capture.set(cv::CAP_PROP_FRAME_WIDTH, 320);
91+
capture.set(cv::CAP_PROP_FRAME_HEIGHT, 240);
9392

9493
if ( !capture.isOpened() )
9594
{

modules/fastcv/src/allocator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ cv::UMatData* QcAllocator::allocate(int dims, const int* sizes, int type,
4545
{
4646
if( step )
4747
{
48-
if( data0 && step[i] != CV_AUTOSTEP )
48+
if( data0 && step[i] != cv::Mat::AUTO_STEP )
4949
{
5050
CV_Assert(total <= step[i]);
5151
total = step[i];

modules/fastcv/src/precomp.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include <opencv2/imgproc.hpp>
1111
#include "opencv2/core/private.hpp"
1212
#include "opencv2/core/utils/logger.hpp"
13-
#include <opencv2/core/core_c.h>
1413
#include <opencv2/fastcv.hpp>
1514
#include <map>
1615
#include <atomic>

modules/freetype/src/precomp.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050

5151
#include <opencv2/core.hpp>
5252
#include <opencv2/imgproc.hpp>
53-
#include <opencv2/imgproc/imgproc_c.h> // for CV_AA
5453
#include <opencv2/freetype.hpp>
5554
#include "opencv2/opencv_modules.hpp"
5655

modules/reg/samples/map_test.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
#ifdef COMPARE_FEATURES
4444
#include <opencv2/xfeatures2d.hpp>
4545
#include <opencv2/calib3d.hpp>
46-
#include <opencv2/calib3d/calib3d_c.h>
4746
using namespace cv::xfeatures2d;
4847
#endif
4948

0 commit comments

Comments
 (0)