Skip to content

Commit

Permalink
C-API cleanup: use error codes enumeration
Browse files Browse the repository at this point in the history
  • Loading branch information
mshabunin committed Sep 4, 2024
1 parent 19ae44a commit 4d41317
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion modules/bioinspired/src/retina_ocl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ bool RetinaOCLImpl::convertToColorPlanes(const UMat& input, UMat &output)
}
else
{
CV_Error(-1, "Retina ocl only support 1, 3, 4 channel input");
CV_Error(cv::Error::StsError, "Retina ocl only support 1, 3, 4 channel input");
}
}
void RetinaOCLImpl::convertToInterleaved(const UMat& input, bool colorMode, UMat &output)
Expand Down
4 changes: 2 additions & 2 deletions modules/bioinspired/src/retinafasttonemapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class RetinaFastToneMappingImpl : public RetinaFastToneMapping

// basic error check
if (nbPixels <= 0)
throw cv::Exception(-1, "Bad retina size setup : size height and with must be superior to zero", "RetinaImpl::setup", "retinafasttonemapping.cpp", 0);
CV_Error(cv::Error::StsError, "Bad retina size setup : size height and with must be superior to zero");

// resize buffers
_inputBuffer.resize(nbPixels*3); // buffer supports gray images but also 3 channels color buffers... (larger is better...)
Expand Down Expand Up @@ -222,7 +222,7 @@ bool _convertCvMat2ValarrayBuffer(InputArray inputMat, std::valarray<float> &out
const Mat inputMatToConvert=inputMat.getMat();
// first check input consistency
if (inputMatToConvert.empty())
throw cv::Exception(-1, "RetinaImpl cannot be applied, input buffer is empty", "RetinaImpl::run", "RetinaImpl.h", 0);
CV_Error(cv::Error::StsError, "RetinaImpl cannot be applied, input buffer is empty");

// retreive color mode from image input
int imageNumberOfChannels = inputMatToConvert.channels();
Expand Down
6 changes: 3 additions & 3 deletions modules/bioinspired/src/transientareassegmentationmodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,13 +417,13 @@ void TransientAreasSegmentationModuleImpl::run(InputArray inputToProcess, const
errorMsg<<"Input matrix size does not match instance buffers setup !"
<<"\n\t Input size is : "<<inputToSegment.rows*inputToSegment.cols
<<"\n\t v.s. internalBuffer size is : "<< _inputToSegment.size();
throw cv::Exception(-1, errorMsg.str().c_str(), "SegmentationModule::run", "SegmentationModule.cpp", 0);
CV_Error(cv::Error::StsError, errorMsg.str().c_str());
}
if (channelIndex >= inputToSegment.channels())
{
std::stringstream errorMsg;
errorMsg<<"Cannot access channel index "<<channelIndex<<" on the input matrix with channels quantity = "<<inputToSegment.channels();
throw cv::Exception(-1, errorMsg.str().c_str(), "SegmentationModule::run", "SegmentationModule.cpp", 0);
CV_Error(cv::Error::StsError, errorMsg.str().c_str());
}

// create a cv::Mat header for the input valarray
Expand Down Expand Up @@ -538,7 +538,7 @@ bool TransientAreasSegmentationModuleImpl::_convertCvMat2ValarrayBuffer(InputArr
const Mat inputMatToConvert=inputMat.getMat();
// first check input consistency
if (inputMatToConvert.empty())
throw cv::Exception(-1, "RetinaImpl cannot be applied, input buffer is empty", "RetinaImpl::run", "RetinaImpl.h", 0);
CV_Error(cv::Error::StsError, "RetinaImpl cannot be applied, input buffer is empty");

// retreive color mode from image input
int imageNumberOfChannels = inputMatToConvert.channels();
Expand Down
3 changes: 1 addition & 2 deletions modules/ml/src/svm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,7 @@ ParamGrid SVM::getDefaultGrid( int param_id )
grid.logStep = 7; // total iterations = 3
}
else
cvError( cv::Error::StsBadArg, "SVM::getDefaultGrid", "Invalid type of parameter "
"(use one of SVM::C, SVM::GAMMA et al.)", __FILE__, __LINE__ );
CV_Error(cv::Error::StsBadArg, "Invalid type of parameter: use one of SVM::C, SVM::GAMMA et al.");
return grid;
}

Expand Down
2 changes: 1 addition & 1 deletion modules/tracking/src/trackerBoostingModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void TrackerBoostingModel::responseToConfidenceMap( const std::vector<Mat>& resp
{
if( currentSample.empty() )
{
CV_Error( -1, "The samples in Model estimation are empty" );
CV_Error( cv::Error::StsError, "The samples in Model estimation are empty" );
}

for ( size_t i = 0; i < currentSample.size(); i++ )
Expand Down
2 changes: 1 addition & 1 deletion modules/tracking/src/trackerFeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Ptr<TrackerContribFeature> TrackerContribFeature::create( const String& trackerF
return Ptr<TrackerFeatureLBP>( new TrackerFeatureLBP() );
}

CV_Error( -1, "Tracker feature type not supported" );
CV_Error( cv::Error::StsError, "Tracker feature type not supported" );
}

String TrackerContribFeature::getClassName() const
Expand Down
2 changes: 1 addition & 1 deletion modules/tracking/src/trackerStateEstimator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Ptr<TrackerStateEstimator> TrackerStateEstimator::create( const String& trackeSt
//return Ptr<TrackerStateEstimatorMILBoosting>( new TrackerStateEstimatorMILBoosting() );
}

CV_Error( -1, "Tracker state estimator type not supported" );
CV_Error( cv::Error::StsError, "Tracker state estimator type not supported" );
}


Expand Down
2 changes: 1 addition & 1 deletion modules/videostab/src/frame_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class VideoFileSourceImpl : public IFrameSource
vc.release();
vc.open(path_);
if (!vc.isOpened())
CV_Error(0, "can't open file: " + path_);
CV_Error(cv::Error::StsError, "can't open file: " + path_);
#else
CV_Error(Error::StsNotImplemented, "OpenCV has been compiled without video I/O support");
#endif
Expand Down

0 comments on commit 4d41317

Please sign in to comment.