diff -Nuarp opencv-4.5.4/modules/core/include/opencv2/core/bindings_utils.hpp opencv-4.5.4.nortti/modules/core/include/opencv2/core/bindings_utils.hpp --- opencv-4.5.4/modules/core/include/opencv2/core/bindings_utils.hpp 2021-10-09 08:48:26.000000000 +0800 +++ opencv-4.5.4.nortti/modules/core/include/opencv2/core/bindings_utils.hpp 2021-11-24 11:00:30.806463640 +0800 @@ -176,12 +176,6 @@ void generateVectorOfMat(size_t len, int } CV_WRAP static inline -void testRaiseGeneralException() -{ - throw std::runtime_error("exception text"); -} - -CV_WRAP static inline AsyncArray testAsyncArray(InputArray argument) { AsyncPromise p; @@ -193,14 +187,6 @@ CV_WRAP static inline AsyncArray testAsyncException() { AsyncPromise p; - try - { - CV_Error(Error::StsOk, "Test: Generated async error"); - } - catch (const cv::Exception& e) - { - p.setException(e); - } return p.getArrayResult(); } diff -Nuarp opencv-4.5.4/modules/core/include/opencv2/core/ocl.hpp opencv-4.5.4.nortti/modules/core/include/opencv2/core/ocl.hpp --- opencv-4.5.4/modules/core/include/opencv2/core/ocl.hpp 2021-10-09 08:48:26.000000000 +0800 +++ opencv-4.5.4.nortti/modules/core/include/opencv2/core/ocl.hpp 2021-11-24 11:00:30.807463640 +0800 @@ -302,21 +302,6 @@ public: void release(); - class CV_EXPORTS UserContext { - public: - virtual ~UserContext(); - }; - template - inline void setUserContext(const std::shared_ptr& userContext) { - setUserContext(typeid(T), userContext); - } - template - inline std::shared_ptr getUserContext() { - return std::dynamic_pointer_cast(getUserContext(typeid(T))); - } - void setUserContext(std::type_index typeId, const std::shared_ptr& userContext); - std::shared_ptr getUserContext(std::type_index typeId); - struct Impl; inline Impl* getImpl() const { return (Impl*)p; } inline bool empty() const { return !p; } diff -Nuarp opencv-4.5.4/modules/core/src/async.cpp opencv-4.5.4.nortti/modules/core/src/async.cpp --- opencv-4.5.4/modules/core/src/async.cpp 2021-10-09 08:48:26.000000000 +0800 +++ opencv-4.5.4.nortti/modules/core/src/async.cpp 2021-11-24 11:00:30.808463640 +0800 @@ -119,7 +119,6 @@ struct AsyncArray::Impl if (has_exception) { result_is_fetched = true; - throw cv_exception; } CV_Error(Error::StsInternal, "AsyncArray: invalid state of 'has_result = true'"); } diff -Nuarp opencv-4.5.4/modules/core/src/bindings_utils.cpp opencv-4.5.4.nortti/modules/core/src/bindings_utils.cpp --- opencv-4.5.4/modules/core/src/bindings_utils.cpp 2021-10-09 08:48:26.000000000 +0800 +++ opencv-4.5.4.nortti/modules/core/src/bindings_utils.cpp 2021-11-24 11:00:30.809463640 +0800 @@ -17,7 +17,7 @@ String dumpInputArray(InputArray argumen return "InputArray: noArray()"; std::ostringstream ss; ss << "InputArray:"; - try { + { do { ss << (argument.empty() ? " empty()=true" : " empty()=false"); ss << cv::format(" kind=0x%08llx", (long long int)argument.kind()); @@ -51,10 +51,6 @@ String dumpInputArray(InputArray argumen ss << " type(-1)=" << cv::typeToString(argument.type(-1)); } while (0); } - catch (...) - { - ss << " ERROR: exception occurred, dump is non-complete"; // need to properly support different kinds - } return ss.str(); } @@ -64,7 +60,7 @@ CV_EXPORTS_W String dumpInputArrayOfArra return "InputArrayOfArrays: noArray()"; std::ostringstream ss; ss << "InputArrayOfArrays:"; - try { + { do { ss << (argument.empty() ? " empty()=true" : " empty()=false"); ss << cv::format(" kind=0x%08llx", (long long int)argument.kind()); @@ -104,10 +100,6 @@ CV_EXPORTS_W String dumpInputArrayOfArra } } while (0); } - catch (...) - { - ss << " ERROR: exception occurred, dump is non-complete"; // need to properly support different kinds - } return ss.str(); } @@ -117,7 +109,7 @@ CV_EXPORTS_W String dumpInputOutputArray return "InputOutputArray: noArray()"; std::ostringstream ss; ss << "InputOutputArray:"; - try { + { do { ss << (argument.empty() ? " empty()=true" : " empty()=false"); ss << cv::format(" kind=0x%08llx", (long long int)argument.kind()); @@ -151,10 +143,6 @@ CV_EXPORTS_W String dumpInputOutputArray ss << " type(-1)=" << cv::typeToString(argument.type(-1)); } while (0); } - catch (...) - { - ss << " ERROR: exception occurred, dump is non-complete"; // need to properly support different kinds - } return ss.str(); } @@ -164,7 +152,7 @@ CV_EXPORTS_W String dumpInputOutputArray return "InputOutputArrayOfArrays: noArray()"; std::ostringstream ss; ss << "InputOutputArrayOfArrays:"; - try { + { do { ss << (argument.empty() ? " empty()=true" : " empty()=false"); ss << cv::format(" kind=0x%08llx", (long long int)argument.kind()); @@ -204,10 +192,6 @@ CV_EXPORTS_W String dumpInputOutputArray } } while (0); } - catch (...) - { - ss << " ERROR: exception occurred, dump is non-complete"; // need to properly support different kinds - } return ss.str(); } diff -Nuarp opencv-4.5.4/modules/core/src/command_line_parser.cpp opencv-4.5.4.nortti/modules/core/src/command_line_parser.cpp --- opencv-4.5.4/modules/core/src/command_line_parser.cpp 2021-10-09 08:48:26.000000000 +0800 +++ opencv-4.5.4.nortti/modules/core/src/command_line_parser.cpp 2021-11-24 11:00:30.809463640 +0800 @@ -119,7 +119,6 @@ static void from_str(const String& str, void CommandLineParser::getByName(const String& name, bool space_delete, Param type, void* dst) const { - try { for (size_t i = 0; i < impl->data.size(); i++) { @@ -144,12 +143,6 @@ void CommandLineParser::getByName(const } } } - catch (const Exception& e) - { - impl->error = true; - impl->error_message = impl->error_message + "Parameter '"+ name + "': " + e.err + "\n"; - return; - } CV_Error_(Error::StsBadArg, ("undeclared key '%s' requested", name.c_str())); } @@ -157,7 +150,6 @@ void CommandLineParser::getByName(const void CommandLineParser::getByIndex(int index, bool space_delete, Param type, void* dst) const { - try { for (size_t i = 0; i < impl->data.size(); i++) { @@ -177,12 +169,6 @@ void CommandLineParser::getByIndex(int i } } } - catch (const Exception& e) - { - impl->error = true; - impl->error_message = impl->error_message + format("Parameter #%d: ", index) + e.err + "\n"; - return; - } CV_Error_(Error::StsBadArg, ("undeclared position %d requested", index)); } @@ -464,16 +450,7 @@ std::vector CommandLineParser::I { if (begin == true) { - throw cv::Exception(CV_StsParseError, - String("error in split_range_string(") - + str - + String(", ") - + String(1, fs) - + String(", ") - + String(1, ss) - + String(")"), - "", __FILE__, __LINE__ - ); + return vec; } begin = true; word = ""; @@ -484,16 +461,7 @@ std::vector CommandLineParser::I { if (begin == false) { - throw cv::Exception(CV_StsParseError, - String("error in split_range_string(") - + str - + String(", ") - + String(1, fs) - + String(", ") - + String(1, ss) - + String(")"), - "", __FILE__, __LINE__ - ); + return vec; } begin = false; vec.push_back(word); @@ -508,16 +476,7 @@ std::vector CommandLineParser::I if (begin == true) { - throw cv::Exception(CV_StsParseError, - String("error in split_range_string(") - + str - + String(", ") - + String(1, fs) - + String(", ") - + String(1, ss) - + String(")"), - "", __FILE__, __LINE__ - ); + return vec; } return vec; diff -Nuarp opencv-4.5.4/modules/core/src/glob.cpp opencv-4.5.4.nortti/modules/core/src/glob.cpp --- opencv-4.5.4/modules/core/src/glob.cpp 2021-10-09 08:48:26.000000000 +0800 +++ opencv-4.5.4.nortti/modules/core/src/glob.cpp 2021-11-24 11:00:30.809463640 +0800 @@ -243,7 +243,6 @@ static void glob_rec(const cv::String& d if ((dir = opendir (directory.c_str())) != 0) { /* find all the files and directories within directory */ - try { struct dirent *ent; while ((ent = readdir (dir)) != 0) @@ -267,11 +266,6 @@ static void glob_rec(const cv::String& d result.push_back(entry); } } - catch (...) - { - closedir(dir); - throw; - } closedir(dir); } else diff -Nuarp opencv-4.5.4/modules/core/src/matrix.cpp opencv-4.5.4.nortti/modules/core/src/matrix.cpp --- opencv-4.5.4/modules/core/src/matrix.cpp 2021-10-09 08:48:26.000000000 +0800 +++ opencv-4.5.4.nortti/modules/core/src/matrix.cpp 2021-11-24 11:00:30.809463640 +0800 @@ -700,18 +700,10 @@ void Mat::create(int d, const int* _size #endif if(!a) a = a0; - try { u = a->allocate(dims, size, _type, 0, step.p, ACCESS_RW /* ignored */, USAGE_DEFAULT); CV_Assert(u != 0); } - catch (...) - { - if (a == a0) - throw; - u = a0->allocate(dims, size, _type, 0, step.p, ACCESS_RW /* ignored */, USAGE_DEFAULT); - CV_Assert(u != 0); - } CV_Assert( step[dims-1] == (size_t)CV_ELEM_SIZE(flags) ); } @@ -761,7 +753,6 @@ Mat::Mat(const Mat& m, const Range& _row } *this = m; - try { if( _rowRange != Range::all() && _rowRange != Range(0,rows) ) { @@ -781,11 +772,6 @@ Mat::Mat(const Mat& m, const Range& _row flags |= SUBMATRIX_FLAG; } } - catch(...) - { - release(); - throw; - } updateContinuityFlag(); diff -Nuarp opencv-4.5.4/modules/core/src/ocl_disabled.impl.hpp opencv-4.5.4.nortti/modules/core/src/ocl_disabled.impl.hpp --- opencv-4.5.4/modules/core/src/ocl_disabled.impl.hpp 2021-10-09 08:48:26.000000000 +0800 +++ opencv-4.5.4.nortti/modules/core/src/ocl_disabled.impl.hpp 2021-11-24 11:00:30.810463640 +0800 @@ -177,11 +177,6 @@ void* Context::getOpenCLContextProperty( bool Context::useSVM() const { return false; } void Context::setUseSVM(bool enabled) { } -Context::UserContext::~UserContext() { } - -void Context::setUserContext(std::type_index /*typeId*/, const std::shared_ptr& /*userContext*/) { OCL_NOT_AVAILABLE(); } -std::shared_ptr Context::getUserContext(std::type_index /*typeId*/) { OCL_NOT_AVAILABLE(); } - /* static */ Context Context::fromHandle(void* context) { OCL_NOT_AVAILABLE(); } /* static */ Context Context::fromDevice(const ocl::Device& device) { OCL_NOT_AVAILABLE(); } /* static */ Context Context::create(const std::string& configuration) { OCL_NOT_AVAILABLE(); } diff -Nuarp opencv-4.5.4/modules/core/src/parallel/parallel.cpp opencv-4.5.4.nortti/modules/core/src/parallel/parallel.cpp --- opencv-4.5.4/modules/core/src/parallel/parallel.cpp 2021-10-09 08:48:26.000000000 +0800 +++ opencv-4.5.4.nortti/modules/core/src/parallel/parallel.cpp 2021-11-24 11:00:30.810463640 +0800 @@ -60,7 +60,6 @@ std::shared_ptr createPa } isKnown = true; } - try { CV_LOG_DEBUG(NULL, "core(parallel): trying backend: " << info.name << " (priority=" << info.priority << ")"); if (!info.backendFactory) @@ -79,14 +78,6 @@ std::shared_ptr createPa getParallelBackendName() = info.name; return backend; } - catch (const std::exception& e) - { - CV_LOG_WARNING(NULL, "core(parallel): can't initialize " << info.name << " backend: " << e.what()); - } - catch (...) - { - CV_LOG_WARNING(NULL, "core(parallel): can't initialize " << info.name << " backend: Unknown C++ exception"); - } } if (name.empty()) { diff -Nuarp opencv-4.5.4/modules/core/src/parallel/plugin_parallel_wrapper.impl.hpp opencv-4.5.4.nortti/modules/core/src/parallel/plugin_parallel_wrapper.impl.hpp --- opencv-4.5.4/modules/core/src/parallel/plugin_parallel_wrapper.impl.hpp 2021-10-09 08:48:26.000000000 +0800 +++ opencv-4.5.4.nortti/modules/core/src/parallel/plugin_parallel_wrapper.impl.hpp 2021-11-24 11:00:30.810463640 +0800 @@ -155,15 +155,10 @@ protected: void initBackend() { AutoLock lock(getInitializationMutex()); - try { if (!initialized) loadPlugin(); } - catch (...) - { - CV_LOG_INFO(NULL, "core(parallel): exception during plugin loading: " << baseName_ << ". SKIP"); - } initialized = true; } void loadPlugin(); @@ -243,7 +238,6 @@ void PluginParallelBackendFactory::loadP { continue; } - try { auto pluginBackend = std::make_shared(lib); if (!pluginBackend) @@ -264,10 +258,6 @@ void PluginParallelBackendFactory::loadP backend = pluginBackend; return; } - catch (...) - { - CV_LOG_WARNING(NULL, "core(parallel): exception during plugin initialization: " << toPrintablePath(plugin) << ". SKIP"); - } } } diff -Nuarp opencv-4.5.4/modules/core/src/parallel.cpp opencv-4.5.4.nortti/modules/core/src/parallel.cpp --- opencv-4.5.4/modules/core/src/parallel.cpp 2021-10-09 08:48:26.000000000 +0800 +++ opencv-4.5.4.nortti/modules/core/src/parallel.cpp 2021-11-24 11:00:30.810463640 +0800 @@ -333,29 +333,9 @@ namespace { CV_TRACE_ARG_VALUE(range_end, "range.end", (int64)r.end); #endif - try { (*ctx.body)(r); } -#if CV__EXCEPTION_PTR - catch (...) - { - ctx.recordException(); - } -#else - catch (const cv::Exception& e) - { - ctx.recordException(e.what()); - } - catch (const std::exception& e) - { - ctx.recordException(e.what()); - } - catch (...) - { - ctx.recordException("Unknown exception"); - } -#endif if (!ctx.is_rng_used && !(cv::theRNG() == ctx.rng)) ctx.is_rng_used = true; @@ -501,16 +481,10 @@ void parallel_for_(const cv::Range& rang isNotNestedRegion = !flagNestedParallelFor.exchange(true); if (isNotNestedRegion) { - try { parallel_for_impl(range, body, nstripes); flagNestedParallelFor = false; } - catch (...) - { - flagNestedParallelFor = false; - throw; - } } else // nested parallel_for_() calls are not parallelized { diff -Nuarp opencv-4.5.4/modules/core/src/persistence.cpp opencv-4.5.4.nortti/modules/core/src/persistence.cpp --- opencv-4.5.4/modules/core/src/persistence.cpp 2021-10-09 08:48:26.000000000 +0800 +++ opencv-4.5.4.nortti/modules/core/src/persistence.cpp 2021-11-24 11:05:14.808459233 +0800 @@ -687,7 +687,7 @@ bool FileStorage::Impl::open(const char strbufpos = bufOffset; bufofs = 0; - try { + { char *ptr = bufferStart(); ptr[0] = ptr[1] = ptr[2] = '\0'; FileNode root_nodes(fs_ext, 0, 0); @@ -728,11 +728,6 @@ bool FileStorage::Impl::open(const char } } } - catch (...) { - is_opened = true; - release(); - throw; - } // release resources that we do not need anymore closeFile(); @@ -1865,18 +1860,12 @@ FileStorage::~FileStorage() bool FileStorage::open(const String& filename, int flags, const String& encoding) { - try { bool ok = p->open(filename.c_str(), flags, encoding.c_str()); if(ok) state = FileStorage::NAME_EXPECTED + FileStorage::INSIDE_MAP; return ok; } - catch (...) - { - release(); - throw; // re-throw - } } bool FileStorage::isOpened() const { return p->is_opened; } diff -Nuarp opencv-4.5.4/modules/core/src/system.cpp opencv-4.5.4.nortti/modules/core/src/system.cpp --- opencv-4.5.4/modules/core/src/system.cpp 2021-10-09 08:48:26.000000000 +0800 +++ opencv-4.5.4.nortti/modules/core/src/system.cpp 2021-11-24 11:00:30.811463640 +0800 @@ -1175,7 +1175,6 @@ void error( const Exception& exc ) *p = 0; } - throw exc; #ifdef __GNUC__ # if !defined __clang__ && !defined __APPLE__ // this suppresses this warning: "noreturn" function does return [enabled by default] @@ -1981,15 +1980,9 @@ void* TLSDataContainer::getData() const { // Create new data instance and save it to TLS storage pData = createDataInstance(); - try { getTlsStorage().setData(key_, pData); } - catch (...) - { - deleteDataInstance(pData); - throw; - } } return pData; } @@ -2093,7 +2086,7 @@ inline bool parseOption(const std::strin { return false; } - throw ParseError(value); + return false; } template<> @@ -2114,7 +2107,7 @@ inline size_t parseOption(const std::str return v * 1024 * 1024; else if (suffixStr == "KB" || suffixStr == "Kb" || suffixStr == "kb") return v * 1024; - throw ParseError(value); + return v; } template<> @@ -2157,16 +2150,11 @@ static inline const char * envRead(const template inline T read(const std::string & k, const T & defaultValue) { - try { const char * res = envRead(k.c_str()); if (res) return parseOption(std::string(res)); } - catch (const ParseError &err) - { - CV_Error(cv::Error::StsBadArg, err.toString(k)); - } return defaultValue; } diff -Nuarp opencv-4.5.4/modules/core/src/umatrix.cpp opencv-4.5.4.nortti/modules/core/src/umatrix.cpp --- opencv-4.5.4/modules/core/src/umatrix.cpp 2021-10-09 08:48:26.000000000 +0800 +++ opencv-4.5.4.nortti/modules/core/src/umatrix.cpp 2021-11-24 11:06:55.772457666 +0800 @@ -602,14 +602,9 @@ UMat Mat::getUMat(AccessFlag accessFlags new_u->originalUMatData = u; } bool allocated = false; - try { allocated = UMat::getStdAllocator()->allocate(new_u, accessFlags, usageFlags); } - catch (const cv::Exception& e) - { - fprintf(stderr, "Exception: %s\n", e.what()); - } if (!allocated) { allocated = getDefaultAllocator()->allocate(new_u, accessFlags, usageFlags); @@ -626,7 +621,6 @@ UMat Mat::getUMat(AccessFlag accessFlags CV_XADD(&(u->refcount), 1); CV_XADD(&(u->urefcount), 1); } - try { hdr.flags = flags; hdr.usageFlags = usageFlags; @@ -637,16 +631,6 @@ UMat Mat::getUMat(AccessFlag accessFlags hdr.addref(); return hdr; } - catch(...) - { - if (u != NULL) - { - CV_XADD(&(u->refcount), -1); - CV_XADD(&(u->urefcount), -1); - } - new_u->currAllocator->deallocate(new_u); - throw; - } } @@ -698,17 +682,10 @@ void UMat::create(int d, const int* _siz a = a0; a0 = Mat::getDefaultAllocator(); } - try { u = a->allocate(dims, size, _type, 0, step.p, ACCESS_RW /* ignored */, usageFlags); CV_Assert(u != 0); } - catch(...) - { - if(a != a0) - u = a0->allocate(dims, size, _type, 0, step.p, ACCESS_RW /* ignored */, usageFlags); - CV_Assert(u != 0); - } CV_Assert( step[dims-1] == (size_t)CV_ELEM_SIZE(flags) ); } @@ -1075,7 +1052,6 @@ Mat UMat::getMat(AccessFlag accessFlags) // TODO Support ACCESS_READ (ACCESS_WRITE) without unnecessary data transfers accessFlags |= ACCESS_RW; UMatDataAutoLock autolock(u); - try { if(CV_XADD(&u->refcount, 1) == 0) u->currAllocator->map(u, accessFlags); @@ -1090,11 +1066,6 @@ Mat UMat::getMat(AccessFlag accessFlags) return hdr; } } - catch(...) - { - CV_XADD(&u->refcount, -1); - throw; - } CV_XADD(&u->refcount, -1); CV_Assert(u->data != 0 && "Error mapping of UMat to host memory."); return Mat(); diff -Nuarp opencv-4.5.4/modules/core/src/utils/filesystem.cpp opencv-4.5.4.nortti/modules/core/src/utils/filesystem.cpp --- opencv-4.5.4/modules/core/src/utils/filesystem.cpp 2021-10-09 08:48:26.000000000 +0800 +++ opencv-4.5.4.nortti/modules/core/src/utils/filesystem.cpp 2021-11-24 11:00:30.811463640 +0800 @@ -508,14 +508,9 @@ cv::String getCacheDirectory(const char* && !utils::fs::isDirectory(default_cache_path)) { std::vector existedCacheDirs; - try { utils::fs::glob_relative(default_cache_path_base, "*", existedCacheDirs, false, true); } - catch (...) - { - // ignore - } if (!existedCacheDirs.empty()) { CV_LOG_WARNING(NULL, "Creating new OpenCV cache directory: " << default_cache_path); diff -Nuarp opencv-4.5.4/modules/imgproc/src/contours.cpp opencv-4.5.4.nortti/modules/imgproc/src/contours.cpp --- opencv-4.5.4/modules/imgproc/src/contours.cpp 2021-10-09 08:48:26.000000000 +0800 +++ opencv-4.5.4.nortti/modules/imgproc/src/contours.cpp 2021-11-24 11:00:30.812463640 +0800 @@ -1762,7 +1762,6 @@ cvFindContours_Impl( void* img, CvMemS } else { - try { scanner = cvStartFindContours_Impl( img, storage, cntHeaderSize, mode, method, offset, needFillBorder); @@ -1774,12 +1773,6 @@ cvFindContours_Impl( void* img, CvMemS } while( contour != 0 ); } - catch(...) - { - if( scanner ) - cvEndFindContours(&scanner); - throw; - } *firstContour = cvEndFindContours( &scanner ); } diff -Nuarp opencv-4.5.4/modules/video/src/tracking/detail/tracking_feature.cpp opencv-4.5.4.nortti/modules/video/src/tracking/detail/tracking_feature.cpp --- opencv-4.5.4/modules/video/src/tracking/detail/tracking_feature.cpp 2021-10-09 08:48:26.000000000 +0800 +++ opencv-4.5.4.nortti/modules/video/src/tracking/detail/tracking_feature.cpp 2021-11-24 11:00:30.812463640 +0800 @@ -107,15 +107,9 @@ void CvHaarEvaluator::generateFeatures(i CvHaarEvaluator::FeatureHaar::FeatureHaar(Size patchSize) { - try { generateRandomFeature(patchSize); } - catch (...) - { - // FIXIT - throw; - } } void CvHaarEvaluator::FeatureHaar::generateRandomFeature(Size patchSize)