From 4d4131707f3107b8d10df5294f5dee1e5b5931bd Mon Sep 17 00:00:00 2001 From: Maksim Shabunin Date: Wed, 4 Sep 2024 20:38:31 +0300 Subject: [PATCH] C-API cleanup: use error codes enumeration --- modules/bioinspired/src/retina_ocl.cpp | 2 +- modules/bioinspired/src/retinafasttonemapping.cpp | 4 ++-- .../bioinspired/src/transientareassegmentationmodule.cpp | 6 +++--- modules/ml/src/svm.cpp | 3 +-- modules/tracking/src/trackerBoostingModel.cpp | 2 +- modules/tracking/src/trackerFeature.cpp | 2 +- modules/tracking/src/trackerStateEstimator.cpp | 2 +- modules/videostab/src/frame_source.cpp | 2 +- 8 files changed, 11 insertions(+), 12 deletions(-) diff --git a/modules/bioinspired/src/retina_ocl.cpp b/modules/bioinspired/src/retina_ocl.cpp index 5bbda144c71..65b05ce4edb 100644 --- a/modules/bioinspired/src/retina_ocl.cpp +++ b/modules/bioinspired/src/retina_ocl.cpp @@ -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) diff --git a/modules/bioinspired/src/retinafasttonemapping.cpp b/modules/bioinspired/src/retinafasttonemapping.cpp index 74f8906fefb..6b34f0c444e 100644 --- a/modules/bioinspired/src/retinafasttonemapping.cpp +++ b/modules/bioinspired/src/retinafasttonemapping.cpp @@ -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...) @@ -222,7 +222,7 @@ bool _convertCvMat2ValarrayBuffer(InputArray inputMat, std::valarray &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(); diff --git a/modules/bioinspired/src/transientareassegmentationmodule.cpp b/modules/bioinspired/src/transientareassegmentationmodule.cpp index 01360dc68cf..da7f4b2d9ab 100644 --- a/modules/bioinspired/src/transientareassegmentationmodule.cpp +++ b/modules/bioinspired/src/transientareassegmentationmodule.cpp @@ -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.channels()) { std::stringstream errorMsg; errorMsg<<"Cannot access channel index "<& 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++ ) diff --git a/modules/tracking/src/trackerFeature.cpp b/modules/tracking/src/trackerFeature.cpp index 257ed4acf06..8fde12d9f17 100644 --- a/modules/tracking/src/trackerFeature.cpp +++ b/modules/tracking/src/trackerFeature.cpp @@ -82,7 +82,7 @@ Ptr TrackerContribFeature::create( const String& trackerF return Ptr( new TrackerFeatureLBP() ); } - CV_Error( -1, "Tracker feature type not supported" ); + CV_Error( cv::Error::StsError, "Tracker feature type not supported" ); } String TrackerContribFeature::getClassName() const diff --git a/modules/tracking/src/trackerStateEstimator.cpp b/modules/tracking/src/trackerStateEstimator.cpp index 46b8a815b3b..935b27a6e3f 100644 --- a/modules/tracking/src/trackerStateEstimator.cpp +++ b/modules/tracking/src/trackerStateEstimator.cpp @@ -59,7 +59,7 @@ Ptr TrackerStateEstimator::create( const String& trackeSt //return Ptr( new TrackerStateEstimatorMILBoosting() ); } - CV_Error( -1, "Tracker state estimator type not supported" ); + CV_Error( cv::Error::StsError, "Tracker state estimator type not supported" ); } diff --git a/modules/videostab/src/frame_source.cpp b/modules/videostab/src/frame_source.cpp index a0176f131e4..f055aabec94 100644 --- a/modules/videostab/src/frame_source.cpp +++ b/modules/videostab/src/frame_source.cpp @@ -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