diff -Nuarp opencv-4.12.0.orig/modules/core/include/opencv2/core/bindings_utils.hpp opencv-4.12.0/modules/core/include/opencv2/core/bindings_utils.hpp --- opencv-4.12.0.orig/modules/core/include/opencv2/core/bindings_utils.hpp 2025-07-13 20:34:53.372129425 +0800 +++ opencv-4.12.0/modules/core/include/opencv2/core/bindings_utils.hpp 2025-07-13 21:38:10.818186252 +0800 @@ -202,12 +202,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; @@ -219,14 +213,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.12.0.orig/modules/core/src/async.cpp opencv-4.12.0/modules/core/src/async.cpp --- opencv-4.12.0.orig/modules/core/src/async.cpp 2025-07-13 20:39:13.959090096 +0800 +++ opencv-4.12.0/modules/core/src/async.cpp 2025-07-13 21:38:10.818321197 +0800 @@ -100,7 +100,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'"); } @@ -264,7 +263,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'"); return false; diff -Nuarp opencv-4.12.0.orig/modules/core/src/bindings_utils.cpp opencv-4.12.0/modules/core/src/bindings_utils.cpp --- opencv-4.12.0.orig/modules/core/src/bindings_utils.cpp 2025-07-13 20:34:53.534086711 +0800 +++ opencv-4.12.0/modules/core/src/bindings_utils.cpp 2025-07-13 21:38:10.818378715 +0800 @@ -22,7 +22,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()); @@ -56,14 +56,6 @@ String dumpInputArray(InputArray argumen ss << " type(-1)=" << cv::typeToString(argument.type(-1)); } while (0); } - catch (const std::exception& e) - { - ss << " ERROR: exception occurred: " << e.what(); - } - catch (...) - { - ss << " ERROR: unknown exception occurred, dump is non-complete"; - } return ss.str(); } @@ -73,7 +65,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()); @@ -113,14 +105,6 @@ CV_EXPORTS_W String dumpInputArrayOfArra } } while (0); } - catch (const std::exception& e) - { - ss << " ERROR: exception occurred: " << e.what(); - } - catch (...) - { - ss << " ERROR: unknown exception occurred, dump is non-complete"; - } return ss.str(); } @@ -130,7 +114,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()); @@ -164,14 +148,6 @@ CV_EXPORTS_W String dumpInputOutputArray ss << " type(-1)=" << cv::typeToString(argument.type(-1)); } while (0); } - catch (const std::exception& e) - { - ss << " ERROR: exception occurred: " << e.what(); - } - catch (...) - { - ss << " ERROR: unknown exception occurred, dump is non-complete"; - } return ss.str(); } @@ -181,7 +157,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()); @@ -221,14 +197,6 @@ CV_EXPORTS_W String dumpInputOutputArray } } while (0); } - catch (const std::exception& e) - { - ss << " ERROR: exception occurred: " << e.what(); - } - catch (...) - { - ss << " ERROR: unknown exception occurred, dump is non-complete"; - } return ss.str(); } diff -Nuarp opencv-4.12.0.orig/modules/core/src/command_line_parser.cpp opencv-4.12.0/modules/core/src/command_line_parser.cpp --- opencv-4.12.0.orig/modules/core/src/command_line_parser.cpp 2025-07-13 20:34:53.537230759 +0800 +++ opencv-4.12.0/modules/core/src/command_line_parser.cpp 2025-07-13 21:38:10.818428600 +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::Error::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::Error::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::Error::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.12.0.orig/modules/core/src/dxt.cpp opencv-4.12.0/modules/core/src/dxt.cpp --- opencv-4.12.0.orig/modules/core/src/dxt.cpp 2025-07-13 20:39:13.959381686 +0800 +++ opencv-4.12.0/modules/core/src/dxt.cpp 2025-07-13 21:37:40.157743062 +0800 @@ -826,6 +826,30 @@ struct OcvDftOptions { } }; +template +struct HALDFTCaller; + +template<> +struct HALDFTCaller { + static void call(const OcvDftOptions& c, const Complex* src, Complex* dst) { + CALL_HAL(dft, cv_hal_dft, reinterpret_cast(src), reinterpret_cast(dst), CV_32F, + c.nf, c.factors, c.scale, c.itab, c.wave, c.tab_size, c.n, c.isInverse, c.noPermute); + } +}; + +template<> +struct HALDFTCaller { + static void call(const OcvDftOptions& c, const Complex* src, Complex* dst) { + CALL_HAL(dft, cv_hal_dft, reinterpret_cast(src), reinterpret_cast(dst), CV_64F, + c.nf, c.factors, c.scale, c.itab, c.wave, c.tab_size, c.n, c.isInverse, c.noPermute); + } +}; + +template +static void HALDFT(const OcvDftOptions& c, const Complex* src, Complex* dst) { + HALDFTCaller::call(c, src, dst); +} + // mixed-radix complex discrete Fourier transform: double-precision version template static void DFT(const OcvDftOptions & c, const Complex* src, Complex* dst) @@ -841,16 +865,7 @@ DFT(const OcvDftOptions & c, const Compl Complex t; T scale = (T)c.scale; - if(typeid(T) == typeid(float)) - { - CALL_HAL(dft, cv_hal_dft, reinterpret_cast(src), reinterpret_cast(dst), CV_32F, - c.nf, c.factors, c.scale, c.itab, c.wave, c.tab_size, c.n, c.isInverse, c.noPermute); - } - if(typeid(T) == typeid(double)) - { - CALL_HAL(dft, cv_hal_dft, reinterpret_cast(src), reinterpret_cast(dst), CV_64F, - c.nf, c.factors, c.scale, c.itab, c.wave, c.tab_size, c.n, c.isInverse, c.noPermute); - } + HALDFT(c, src, dst); if( c.useIpp ) { diff -Nuarp opencv-4.12.0.orig/modules/core/src/glob.cpp opencv-4.12.0/modules/core/src/glob.cpp --- opencv-4.12.0.orig/modules/core/src/glob.cpp 2025-07-13 20:34:53.536156931 +0800 +++ opencv-4.12.0/modules/core/src/glob.cpp 2025-07-13 21:38:10.818490446 +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.12.0.orig/modules/core/src/matrix.cpp opencv-4.12.0/modules/core/src/matrix.cpp --- opencv-4.12.0.orig/modules/core/src/matrix.cpp 2025-07-13 20:34:53.545189782 +0800 +++ opencv-4.12.0/modules/core/src/matrix.cpp 2025-07-13 21:38:10.818552694 +0800 @@ -694,20 +694,11 @@ void Mat::create(int d, const int* _size MatAllocator *a = allocator, *a0 = getDefaultAllocator(); if(!a) a = a0; - try { u = a->allocate(dims, size, _type, 0, step.p, ACCESS_RW /* ignored */, USAGE_DEFAULT); CV_Assert(u != 0); allocator = a; } - catch (...) - { - if (a == a0) - throw; - u = a0->allocate(dims, size, _type, 0, step.p, ACCESS_RW /* ignored */, USAGE_DEFAULT); - CV_Assert(u != 0); - allocator = a0; - } CV_Assert( step[dims-1] == (size_t)CV_ELEM_SIZE(flags) ); } @@ -757,7 +748,6 @@ Mat::Mat(const Mat& m, const Range& _row } *this = m; - try { if( _rowRange != Range::all() && _rowRange != Range(0,rows) ) { @@ -777,11 +767,6 @@ Mat::Mat(const Mat& m, const Range& _row flags |= SUBMATRIX_FLAG; } } - catch(...) - { - release(); - throw; - } updateContinuityFlag(); diff -Nuarp opencv-4.12.0.orig/modules/core/src/parallel/parallel.cpp opencv-4.12.0/modules/core/src/parallel/parallel.cpp --- opencv-4.12.0.orig/modules/core/src/parallel/parallel.cpp 2025-07-13 20:34:53.506481139 +0800 +++ opencv-4.12.0/modules/core/src/parallel/parallel.cpp 2025-07-13 21:38:10.818617917 +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.12.0.orig/modules/core/src/parallel/plugin_parallel_wrapper.impl.hpp opencv-4.12.0/modules/core/src/parallel/plugin_parallel_wrapper.impl.hpp --- opencv-4.12.0.orig/modules/core/src/parallel/plugin_parallel_wrapper.impl.hpp 2025-07-13 20:34:53.506007655 +0800 +++ opencv-4.12.0/modules/core/src/parallel/plugin_parallel_wrapper.impl.hpp 2025-07-13 21:38:10.818654306 +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.12.0.orig/modules/core/src/parallel.cpp opencv-4.12.0/modules/core/src/parallel.cpp --- opencv-4.12.0.orig/modules/core/src/parallel.cpp 2025-07-13 20:34:53.534609328 +0800 +++ opencv-4.12.0/modules/core/src/parallel.cpp 2025-07-13 21:38:10.818707437 +0800 @@ -355,29 +355,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; @@ -523,16 +503,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.12.0.orig/modules/core/src/persistence.cpp opencv-4.12.0/modules/core/src/persistence.cpp --- opencv-4.12.0.orig/modules/core/src/persistence.cpp 2025-07-13 20:34:53.538606458 +0800 +++ opencv-4.12.0/modules/core/src/persistence.cpp 2025-07-13 21:38:10.818819829 +0800 @@ -758,7 +758,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); @@ -799,13 +799,6 @@ bool FileStorage::Impl::open(const char } } } - catch (...) - { - // FIXIT log error message - is_opened = true; - release(); - throw; - } // release resources that we do not need anymore closeFile(); @@ -1943,18 +1936,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.12.0.orig/modules/core/src/system.cpp opencv-4.12.0/modules/core/src/system.cpp --- opencv-4.12.0.orig/modules/core/src/system.cpp 2025-07-13 20:34:53.503020142 +0800 +++ opencv-4.12.0/modules/core/src/system.cpp 2025-07-13 21:38:10.818983909 +0800 @@ -1272,7 +1272,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] @@ -2080,15 +2079,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; } @@ -2192,7 +2185,7 @@ inline bool parseOption(const std::strin { return false; } - throw ParseError(value); + return false; } template<> @@ -2213,7 +2206,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<> @@ -2256,16 +2249,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.12.0.orig/modules/core/src/umatrix.cpp opencv-4.12.0/modules/core/src/umatrix.cpp --- opencv-4.12.0.orig/modules/core/src/umatrix.cpp 2025-07-13 20:39:13.960069736 +0800 +++ opencv-4.12.0/modules/core/src/umatrix.cpp 2025-07-13 21:38:10.819101641 +0800 @@ -594,14 +594,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); @@ -618,7 +613,6 @@ UMat Mat::getUMat(AccessFlag accessFlags CV_XADD(&(u->refcount), 1); CV_XADD(&(u->urefcount), 1); } - try { hdr.flags = flags; hdr.usageFlags = usageFlags; @@ -629,16 +623,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; - } } @@ -690,17 +674,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) ); } @@ -1067,7 +1044,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); @@ -1082,11 +1058,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.12.0.orig/modules/core/src/utils/filesystem.cpp opencv-4.12.0/modules/core/src/utils/filesystem.cpp --- opencv-4.12.0.orig/modules/core/src/utils/filesystem.cpp 2025-07-13 20:34:53.528264934 +0800 +++ opencv-4.12.0/modules/core/src/utils/filesystem.cpp 2025-07-13 21:38:10.819174299 +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.12.0.orig/modules/imgproc/src/contours.cpp opencv-4.12.0/modules/imgproc/src/contours.cpp --- opencv-4.12.0.orig/modules/imgproc/src/contours.cpp 2025-07-13 20:39:13.961175625 +0800 +++ opencv-4.12.0/modules/imgproc/src/contours.cpp 2025-07-13 21:38:10.819246104 +0800 @@ -1760,7 +1760,6 @@ cvFindContours_Impl( void* img, CvMemS } else { - try { scanner = cvStartFindContours_Impl( img, storage, cntHeaderSize, mode, method, offset, needFillBorder); @@ -1772,12 +1771,6 @@ cvFindContours_Impl( void* img, CvMemS } while( contour != 0 ); } - catch(...) - { - if( scanner ) - cvEndFindContours(&scanner); - throw; - } *firstContour = cvEndFindContours( &scanner ); } diff -Nuarp opencv-4.12.0.orig/modules/video/src/tracking/detail/tracking_feature.cpp opencv-4.12.0/modules/video/src/tracking/detail/tracking_feature.cpp --- opencv-4.12.0.orig/modules/video/src/tracking/detail/tracking_feature.cpp 2025-07-13 20:34:54.331668306 +0800 +++ opencv-4.12.0/modules/video/src/tracking/detail/tracking_feature.cpp 2025-07-13 21:38:10.819330454 +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)