Skip to content

Commit 6f68a4e

Browse files
authored
Merge pull request #3642 from mshabunin:cleanup-imgproc-1
C-API cleanup: imgproc_c and some constants #3642 * removed all mentions of imgproc C-API headers (imgproc_c.h, types_c.h) - they were empty, included core C-API headers * replaced usage of several C constants with C++ ones (error codes) * minor warning fixes in _cvv_ module
1 parent d4a1aea commit 6f68a4e

28 files changed

+96
-105
lines changed

modules/ccalib/src/multicalib.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ void MultiCameraCalibration::loadImages()
225225
_xi[camera].convertTo(_xi[camera], CV_32F);
226226
//else
227227
//{
228-
// CV_Error_(CV_StsOutOfRange, "Unknown camera type, use PINHOLE or OMNIDIRECTIONAL");
228+
// CV_Error_(cv::Error::StsOutOfRange, "Unknown camera type, use PINHOLE or OMNIDIRECTIONAL");
229229
//}
230230

231231
for (int i = 0; i < (int)_omEachCamera[camera].size(); ++i)

modules/cudalegacy/src/fgd.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ Ptr<cuda::BackgroundSubtractorFGD> cv::cuda::createBackgroundSubtractorFGD(const
5454
#else
5555

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

5958
/////////////////////////////////////////////////////////////////////////
6059
// FGDParams

modules/cvv/samples/cvv_demo.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
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>
98
#include <opencv2/videoio/videoio_c.h>
109

@@ -33,8 +32,6 @@ template<class T> std::string toString(const T& p_arg)
3332
int
3433
main(int argc, char** argv)
3534
{
36-
cv::Size* resolution = nullptr;
37-
3835
// parser keys
3936
const char *keys =
4037
"{ help h usage ? | | show this message }"

modules/cvv/src/qtutil/filter/sobelfilterwidget.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#include "sobelfilterwidget.hpp"
22

33
#include "opencv2/imgproc.hpp"
4-
#include "opencv2/imgproc/types_c.h"
54

65
#include <QVBoxLayout>
76
#include <QLabel>

modules/cvv/test/test_reference.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ namespace opencv_test { namespace {
66

77
/**
88
* Makes sure that
9-
* - creating, reassigning and comparing `cvv::util::Reference<int>`s (from /src/util/util.hpp) works,
9+
* - creating, reassigning and comparing `cvv::util::Reference<int>`s (from /src/util/util.hpp) works,
1010
* as well as the
1111
* - `makeRef()` and `getPtr()` functions; that
1212
* - `Reference<const int>`s can be created with `makeRef(const int)`, `{const int}` initializer list
13-
* and via `Reference<const int>{int}` and, finally, that
14-
* - `cvv::util::Reference`s of super classes can be constructed with derived classes and
13+
* and via `Reference<const int>{int}` and, finally, that
14+
* - `cvv::util::Reference`s of super classes can be constructed with derived classes and
1515
* - `Reference`s to base classes can be `castTo()` `References` to the derived classes, but not the other way.
1616
*/
1717

@@ -71,7 +71,7 @@ TEST(ReferenceTest, ConstRefs)
7171

7272
TEST(ReferenceTest, ConstRefsFromMutable)
7373
{
74-
int i;
74+
int i = 100;
7575
Reference<const int> ref{ i };
7676
EXPECT_EQ(ref.getPtr(), &i);
7777
}

modules/dpm/src/dpm_cascade.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ void DPMCascade::loadCascadeModel(const string &modelPath)
6262
if (!is_success)
6363
{
6464
string errorMessage = format("Unable to parse the model: %s", modelPath.c_str());
65-
CV_Error(CV_StsBadArg, errorMessage);
65+
CV_Error(cv::Error::StsBadArg, errorMessage);
6666
}
6767

6868
model.initModel();

modules/dpm/src/dpm_feature.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ void ParalComputePyramid::initialize()
8181

8282
if (params.maxScale < params.interval)
8383
{
84-
CV_Error(CV_StsBadArg, "The image is too small to create a pyramid");
84+
CV_Error(cv::Error::StsBadArg, "The image is too small to create a pyramid");
8585
return;
8686
}
8787

modules/img_hash/src/precomp.hpp

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include "opencv2/core.hpp"
99
#include "opencv2/core/base.hpp"
1010
#include "opencv2/imgproc.hpp"
11-
#include "opencv2/imgproc/types_c.h"
1211
#include "opencv2/img_hash.hpp"
1312

1413
#include <bitset>

modules/ml/src/ann_mlp.cpp

+10-10
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ class ANN_MLPImpl CV_FINAL : public ANN_MLP
224224
void setActivationFunction(int _activ_func, double _f_param1, double _f_param2) CV_OVERRIDE
225225
{
226226
if( _activ_func < 0 || _activ_func > LEAKYRELU)
227-
CV_Error( CV_StsOutOfRange, "Unknown activation function" );
227+
CV_Error( cv::Error::StsOutOfRange, "Unknown activation function" );
228228

229229
activ_func = _activ_func;
230230

@@ -323,7 +323,7 @@ class ANN_MLPImpl CV_FINAL : public ANN_MLP
323323
{
324324
int n = layer_sizes[i];
325325
if( n < 1 + (0 < i && i < l_count-1))
326-
CV_Error( CV_StsOutOfRange,
326+
CV_Error( cv::Error::StsOutOfRange,
327327
"there should be at least one input and one output "
328328
"and every hidden layer must have more than 1 neuron" );
329329
max_lsize = std::max( max_lsize, n );
@@ -342,7 +342,7 @@ class ANN_MLPImpl CV_FINAL : public ANN_MLP
342342
float predict( InputArray _inputs, OutputArray _outputs, int ) const CV_OVERRIDE
343343
{
344344
if( !trained )
345-
CV_Error( CV_StsError, "The network has not been trained or loaded" );
345+
CV_Error( cv::Error::StsError, "The network has not been trained or loaded" );
346346

347347
Mat inputs = _inputs.getMat();
348348
int type = inputs.type(), l_count = layer_count();
@@ -791,7 +791,7 @@ class ANN_MLPImpl CV_FINAL : public ANN_MLP
791791
{
792792
t = t*inv_scale[j*2] + inv_scale[2*j+1];
793793
if( t < m1 || t > M1 )
794-
CV_Error( CV_StsOutOfRange,
794+
CV_Error( cv::Error::StsOutOfRange,
795795
"Some of new output training vector components run exceed the original range too much" );
796796
}
797797
}
@@ -818,25 +818,25 @@ class ANN_MLPImpl CV_FINAL : public ANN_MLP
818818
Mat& sample_weights, int flags )
819819
{
820820
if( layer_sizes.empty() )
821-
CV_Error( CV_StsError,
821+
CV_Error( cv::Error::StsError,
822822
"The network has not been created. Use method create or the appropriate constructor" );
823823

824824
if( (inputs.type() != CV_32F && inputs.type() != CV_64F) ||
825825
inputs.cols != layer_sizes[0] )
826-
CV_Error( CV_StsBadArg,
826+
CV_Error( cv::Error::StsBadArg,
827827
"input training data should be a floating-point matrix with "
828828
"the number of rows equal to the number of training samples and "
829829
"the number of columns equal to the size of 0-th (input) layer" );
830830

831831
if( (outputs.type() != CV_32F && outputs.type() != CV_64F) ||
832832
outputs.cols != layer_sizes.back() )
833-
CV_Error( CV_StsBadArg,
833+
CV_Error( cv::Error::StsBadArg,
834834
"output training data should be a floating-point matrix with "
835835
"the number of rows equal to the number of training samples and "
836836
"the number of columns equal to the size of last (output) layer" );
837837

838838
if( inputs.rows != outputs.rows )
839-
CV_Error( CV_StsUnmatchedSizes, "The numbers of input and output samples do not match" );
839+
CV_Error( cv::Error::StsUnmatchedSizes, "The numbers of input and output samples do not match" );
840840

841841
Mat temp;
842842
double s = sum(sample_weights)[0];
@@ -1324,7 +1324,7 @@ class ANN_MLPImpl CV_FINAL : public ANN_MLP
13241324
fs << "itePerStep" << params.itePerStep;
13251325
}
13261326
else
1327-
CV_Error(CV_StsError, "Unknown training method");
1327+
CV_Error(cv::Error::StsError, "Unknown training method");
13281328

13291329
fs << "term_criteria" << "{";
13301330
if( params.termCrit.type & TermCriteria::EPS )
@@ -1422,7 +1422,7 @@ class ANN_MLPImpl CV_FINAL : public ANN_MLP
14221422
params.itePerStep = tpn["itePerStep"];
14231423
}
14241424
else
1425-
CV_Error(CV_StsParseError, "Unknown training method (should be BACKPROP or RPROP)");
1425+
CV_Error(cv::Error::StsParseError, "Unknown training method (should be BACKPROP or RPROP)");
14261426

14271427
FileNode tcn = tpn["term_criteria"];
14281428
if( !tcn.empty() )

modules/ml/src/boost.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ class DTreesImplForBoost CV_FINAL : public DTreesImpl
308308
}
309309
}
310310
else
311-
CV_Error(CV_StsNotImplemented, "Unknown boosting type");
311+
CV_Error(cv::Error::StsNotImplemented, "Unknown boosting type");
312312

313313
/*if( bparams.boostType != Boost::LOGIT )
314314
{
@@ -387,7 +387,7 @@ class DTreesImplForBoost CV_FINAL : public DTreesImpl
387387
void write( FileStorage& fs ) const CV_OVERRIDE
388388
{
389389
if( roots.empty() )
390-
CV_Error( CV_StsBadArg, "RTrees have not been trained" );
390+
CV_Error( cv::Error::StsBadArg, "RTrees have not been trained" );
391391

392392
writeFormat(fs);
393393
writeParams(fs);

modules/ml/src/data.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ class TrainDataImpl CV_FINAL : public TrainData
574574
if( nvars == 0 )
575575
{
576576
if( rowvals.empty() )
577-
CV_Error(CV_StsBadArg, "invalid CSV format; no data found");
577+
CV_Error(cv::Error::StsBadArg, "invalid CSV format; no data found");
578578
nvars = (int)rowvals.size();
579579
if( !varTypeSpec.empty() && varTypeSpec.size() > 0 )
580580
{
@@ -637,7 +637,7 @@ class TrainDataImpl CV_FINAL : public TrainData
637637
{
638638
for( i = ninputvars; i < nvars; i++ )
639639
if( vtypes[i] == VAR_CATEGORICAL )
640-
CV_Error(CV_StsBadArg,
640+
CV_Error(cv::Error::StsBadArg,
641641
"If responses are vector values, not scalars, they must be marked as ordered responses");
642642
}
643643
}
@@ -724,14 +724,14 @@ class TrainDataImpl CV_FINAL : public TrainData
724724
}
725725

726726
if ( ptr[3] != '[')
727-
CV_Error( CV_StsBadArg, errmsg );
727+
CV_Error( cv::Error::StsBadArg, errmsg );
728728

729729
ptr += 4; // pass "ord["
730730
do
731731
{
732732
int b1 = (int)strtod( ptr, &stopstring );
733733
if( *stopstring == 0 || (*stopstring != ',' && *stopstring != ']' && *stopstring != '-') )
734-
CV_Error( CV_StsBadArg, errmsg );
734+
CV_Error( cv::Error::StsBadArg, errmsg );
735735
ptr = stopstring + 1;
736736
if( (stopstring[0] == ',') || (stopstring[0] == ']'))
737737
{
@@ -745,15 +745,15 @@ class TrainDataImpl CV_FINAL : public TrainData
745745
{
746746
int b2 = (int)strtod( ptr, &stopstring);
747747
if ( (*stopstring == 0) || (*stopstring != ',' && *stopstring != ']') )
748-
CV_Error( CV_StsBadArg, errmsg );
748+
CV_Error( cv::Error::StsBadArg, errmsg );
749749
ptr = stopstring + 1;
750750
CV_Assert( 0 <= b1 && b1 <= b2 && b2 < nvars );
751751
for (int i = b1; i <= b2; i++)
752752
vtypes[i] = (uchar)tp;
753753
specCounter += b2 - b1 + 1;
754754
}
755755
else
756-
CV_Error( CV_StsBadArg, errmsg );
756+
CV_Error( cv::Error::StsBadArg, errmsg );
757757

758758
}
759759
}
@@ -762,7 +762,7 @@ class TrainDataImpl CV_FINAL : public TrainData
762762
}
763763

764764
if( specCounter != nvars )
765-
CV_Error( CV_StsBadArg, "type of some variables is not specified" );
765+
CV_Error( cv::Error::StsBadArg, "type of some variables is not specified" );
766766
}
767767

768768
void setTrainTestSplitRatio(double ratio, bool shuffle) CV_OVERRIDE

modules/ml/src/gbt.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ CvGBTrees::train( const CvMat* _train_data, int _tflag,
218218
orig_response->data.fl[i] = (float) _responses->data.i[i*step];
219219
}; break;
220220
default:
221-
CV_Error(CV_StsUnmatchedFormats, "Response should be a 32fC1 or 32sC1 vector.");
221+
CV_Error(cv::Error::StsUnmatchedFormats, "Response should be a 32fC1 or 32sC1 vector.");
222222
}
223223

224224
if (!is_regression)
@@ -283,7 +283,7 @@ CvGBTrees::train( const CvMat* _train_data, int _tflag,
283283
sample_idx->data.i[active_samples_count++] = i;
284284

285285
} break;
286-
default: CV_Error(CV_StsUnmatchedFormats, "_sample_idx should be a 32sC1, 8sC1 or 8uC1 vector.");
286+
default: CV_Error(cv::Error::StsUnmatchedFormats, "_sample_idx should be a 32sC1, 8sC1 or 8uC1 vector.");
287287
}
288288
}
289289
else
@@ -1072,7 +1072,7 @@ void CvGBTrees::read_params( CvFileStorage* fs, CvFileNode* fnode )
10721072

10731073

10741074
if( params.loss_function_type < SQUARED_LOSS || params.loss_function_type > DEVIANCE_LOSS || params.loss_function_type == 2)
1075-
CV_ERROR( CV_StsBadArg, "Unknown loss function" );
1075+
CV_Error( cv::Error::StsBadArg, "Unknown loss function" );
10761076

10771077
params.weak_count = cvReadIntByName( fs, fnode, "ensemble_length" );
10781078
params.shrinkage = (float)cvReadRealByName( fs, fnode, "shrinkage", 0.1 );
@@ -1082,7 +1082,7 @@ void CvGBTrees::read_params( CvFileStorage* fs, CvFileNode* fnode )
10821082
{
10831083
class_labels = (CvMat*)cvReadByName( fs, fnode, "class_labels" );
10841084
if( class_labels && !CV_IS_MAT(class_labels))
1085-
CV_ERROR( CV_StsParseError, "class_labels must stored as a matrix");
1085+
CV_Error( cv::Error::StsParseError, "class_labels must stored as a matrix");
10861086
}
10871087
data->is_classifier = 0;
10881088

@@ -1105,7 +1105,7 @@ void CvGBTrees::write( CvFileStorage* fs, const char* name ) const
11051105
cvStartWriteStruct( fs, name, CV_NODE_MAP, CV_TYPE_NAME_ML_GBT );
11061106

11071107
if( !weak )
1108-
CV_ERROR( CV_StsBadArg, "The model has not been trained yet" );
1108+
CV_Error( cv::Error::StsBadArg, "The model has not been trained yet" );
11091109

11101110
write_params( fs );
11111111
cvWriteReal( fs, "base_value", base_value);
@@ -1170,13 +1170,13 @@ void CvGBTrees::read( CvFileStorage* fs, CvFileNode* node )
11701170

11711171
trees_fnode = cvGetFileNodeByName( fs, node, s.c_str() );
11721172
if( !trees_fnode || !CV_NODE_IS_SEQ(trees_fnode->tag) )
1173-
CV_ERROR( CV_StsParseError, "<trees_x> tag is missing" );
1173+
CV_Error( cv::Error::StsParseError, "<trees_x> tag is missing" );
11741174

11751175
cvStartReadSeq( trees_fnode->data.seq, &reader );
11761176
ntrees = trees_fnode->data.seq->total;
11771177

11781178
if( ntrees != params.weak_count )
1179-
CV_ERROR( CV_StsUnmatchedSizes,
1179+
CV_Error( cv::Error::StsUnmatchedSizes,
11801180
"The number of trees stored does not match <ntrees> tag value" );
11811181

11821182
CV_CALL( storage = cvCreateMemStorage() );

modules/ml/src/inner_functions.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ bool StatModel::train(const Ptr<TrainData>& trainData, int )
6363
{
6464
CV_TRACE_FUNCTION();
6565
CV_Assert(!trainData.empty());
66-
CV_Error(CV_StsNotImplemented, "");
66+
CV_Error(cv::Error::StsNotImplemented, "");
6767
return false;
6868
}
6969

0 commit comments

Comments
 (0)