1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-31 00:03:03 +04:00

Merge branch 4.x

This commit is contained in:
Alexander Smorkalov
2025-09-26 09:24:38 +03:00
91 changed files with 5339 additions and 1508 deletions
@@ -335,23 +335,6 @@ namespace fs {
//! @} // core_utils
} // namespace cv::utils
//! @cond IGNORED
CV_WRAP static inline
int setLogLevel(int level)
{
// NB: Binding generators doesn't work with enums properly yet, so we define separate overload here
return cv::utils::logging::setLogLevel((cv::utils::logging::LogLevel)level);
}
CV_WRAP static inline
int getLogLevel()
{
return cv::utils::logging::getLogLevel();
}
//! @endcond IGNORED
} // namespaces cv / utils
#endif // OPENCV_CORE_BINDINGS_UTILS_HPP
@@ -170,7 +170,10 @@ inline _InputArray::_InputArray(const std::vector<UMat>& vec) { init(+STD_VECTOR
template<typename _Tp> inline
_InputArray::_InputArray(const std::vector<_Tp>& vec)
{ init(FIXED_TYPE + STD_VECTOR + traits::Type<_Tp>::value + ACCESS_READ, &vec); }
{
CV_CheckLE(vec.size(), static_cast<size_t>(std::numeric_limits<int>::max()), "Must not be larger than INT_MAX");
init(FIXED_TYPE + STD_VECTOR + traits::Type<_Tp>::value + ACCESS_READ, &vec);
}
template<typename _Tp, std::size_t _Nm> inline
_InputArray::_InputArray(const std::array<_Tp, _Nm>& arr)
@@ -22,9 +22,9 @@ namespace logging {
/** Set global logging level
@return previous logging level
*/
CV_EXPORTS LogLevel setLogLevel(LogLevel logLevel);
CV_EXPORTS_W LogLevel setLogLevel(LogLevel logLevel);
/** Get global logging level */
CV_EXPORTS LogLevel getLogLevel();
CV_EXPORTS_W LogLevel getLogLevel();
CV_EXPORTS void registerLogTag(cv::utils::logging::LogTag* plogtag);
+9 -1
View File
@@ -131,7 +131,15 @@ static void generateCentersPP(const Mat& data, Mat& _out_centers,
KMeansPPDistanceComputer(tdist2, data, dist, ci),
(double)divUp((size_t)(dims * N), CV_KMEANS_PARALLEL_GRANULARITY));
double s = 0;
for (int i = 0; i < N; i++)
int i = 0;
#if CV_ENABLE_UNROLLED
for (; i + 7 < N; i += 8)
{
s += tdist2[i + 0] + tdist2[i + 1] + tdist2[i + 2] + tdist2[i + 3] +
tdist2[i + 4] + tdist2[i + 5] + tdist2[i + 6] + tdist2[i + 7];
}
#endif
for (; i < N; i++)
{
s += tdist2[i];
}
+28 -4
View File
@@ -71,7 +71,7 @@ std::shared_ptr<ParallelForAPI> createParallelForAPI()
std::shared_ptr<ParallelForAPI> backend = info.backendFactory->create();
if (!backend)
{
CV_LOG_VERBOSE(NULL, 0, "core(parallel): not available: " << info.name);
CV_LOG_DEBUG(NULL, "core(parallel): not available: " << info.name);
continue;
}
CV_LOG_INFO(NULL, "core(parallel): using backend: " << info.name << " (priority=" << info.priority << ")");
@@ -95,9 +95,16 @@ std::shared_ptr<ParallelForAPI> createParallelForAPI()
else
{
if (!isKnown)
CV_LOG_INFO(NULL, "core(parallel): unknown backend: " << name);
{
CV_LOG_INFO(NULL, "core(parallel): unknown backend: " << name << ", fallback on builtin code");
}
else
{
CV_LOG_INFO(NULL, "core(parallel): backend=" << name << " is not available, fallback on builtin code");
}
}
g_initializedParallelForAPI = true;
getParallelBackendName() = std::string();
return std::shared_ptr<ParallelForAPI>();
}
@@ -127,6 +134,10 @@ bool setParallelForBackend(const std::string& backendName, bool propagateNumThre
{
CV_TRACE_FUNCTION();
bool saved_initialized = g_initializedParallelForAPI;
std::string saved_backendName = getParallelBackendName();
std::shared_ptr<ParallelForAPI> saved_backend; // don't call getCurrentParallelForAPI() if g_initializedParallelForAPI = false to avoid unnecessary "default" initialization
std::string backendName_u = toUpperCase(backendName);
if (g_initializedParallelForAPI)
{
@@ -138,8 +149,9 @@ bool setParallelForBackend(const std::string& backendName, bool propagateNumThre
}
else
{
saved_backend = getCurrentParallelForAPI();
// ... re-create new
CV_LOG_DEBUG(NULL, "core(parallel): replacing parallel backend...");
CV_LOG_DEBUG(NULL, "core(parallel): replacing parallel backend (old=" << saved_backendName << " new=" << backendName << ")...");
getParallelBackendName() = backendName_u;
getCurrentParallelForAPI() = createParallelForAPI();
}
@@ -154,7 +166,19 @@ bool setParallelForBackend(const std::string& backendName, bool propagateNumThre
{
if (!backendName.empty())
{
CV_LOG_WARNING(NULL, "core(parallel): backend is not available: " << backendName << " (using builtin legacy code)");
// restore previous backend or build default
getParallelBackendName() = saved_backendName;
if (saved_initialized)
{
CV_LOG_WARNING(NULL, "core(parallel): backend is not available: " << backendName << " (keep previous)");
getCurrentParallelForAPI() = saved_backend;
}
else
{
CV_LOG_WARNING(NULL, "core(parallel): backend is not available: " << backendName << " (use default)");
g_initializedParallelForAPI = false;
getCurrentParallelForAPI() = createDefaultParallelForAPI();
}
return false;
}
else
+8
View File
@@ -1376,6 +1376,14 @@ TEST(Core_InputArray, empty)
ASSERT_TRUE( _InputArray(data).empty() );
}
TEST(Core_InputArray, convert_from_vector_over2GB)
{
applyTestTag(CV_TEST_TAG_MEMORY_6GB);
// empty buffer more than 2GB size
std::vector<uint8_t> buf(size_t(INT_MAX) + 4096);
EXPECT_ANY_THROW(auto work = _InputArray(buf));
}
TEST(Core_CopyMask, bug1918)
{
Mat_<unsigned char> tmpSrc(100,100);