Message ID | 20250324075502.1255967-1-quic_ptak@quicinc.com |
---|---|
State | Under Review |
Headers | show |
Series | [meta-oe] Adding FastCV-HAL enablement option as packageconfig | expand |
On Mon, Mar 24, 2025 at 12:55 AM Pulkit Singh Tak (Temp) (QUIC) via lists.openembedded.org <quic_ptak=quicinc.com@lists.openembedded.org> wrote: > > Adding patches to support fastcv static lib compilation > and removal of cluster ecludian tests support > These are temporary patches to be removeed in next release. typo here 'removed' > > Signed-off-by: Pulkit Singh Tak <quic_ptak@quicinc.com> > --- > ...ng-fastcv-static-lib-for-compilation.patch | 96 +++++ > ...oved-cluster-euclidean-in-fastcv-ext.patch | 371 ++++++++++++++++++ > .../recipes-support/opencv/opencv_4.11.0.bb | 14 +- > 3 files changed, 479 insertions(+), 2 deletions(-) > create mode 100644 meta-oe/recipes-support/opencv/opencv/0001-FROMLIST-Using-fastcv-static-lib-for-compilation.patch > create mode 100644 meta-oe/recipes-support/opencv/opencv/0001-PENDING-Removed-cluster-euclidean-in-fastcv-ext.patch > > diff --git a/meta-oe/recipes-support/opencv/opencv/0001-FROMLIST-Using-fastcv-static-lib-for-compilation.patch b/meta-oe/recipes-support/opencv/opencv/0001-FROMLIST-Using-fastcv-static-lib-for-compilation.patch > new file mode 100644 > index 0000000000..5fce32f4b8 > --- /dev/null > +++ b/meta-oe/recipes-support/opencv/opencv/0001-FROMLIST-Using-fastcv-static-lib-for-compilation.patch > @@ -0,0 +1,96 @@ > +From 0141830e67ac7c60c474ab3c1e7d3e30c27c7943 Mon Sep 17 00:00:00 2001 > +From: Pulkit Singh Tak <quic_ptak@quicinc.com> > +Date: Mon, 10 Feb 2025 15:10:26 +0530 > +Subject: [PATCH] FROMLIST: Using fastcv static lib for compilation > + > +Signed-off-by: Pulkit Singh Tak <quic_ptak@quicinc.com> > +Upstream-Status: SUBMITTED [https://github.com/opencv/opencv/pull/26917] status should be 'Submitted' > +--- > + 3rdparty/fastcv/fastcv.cmake | 9 +++++---- > + cmake/OpenCVFindLibsPerf.cmake | 23 ++++++++++++++++------- > + 2 files changed, 21 insertions(+), 11 deletions(-) > + > +diff --git a/3rdparty/fastcv/fastcv.cmake b/3rdparty/fastcv/fastcv.cmake > +index b8172705ca..12c6616a16 100644 > +--- a/3rdparty/fastcv/fastcv.cmake > ++++ b/3rdparty/fastcv/fastcv.cmake > +@@ -1,7 +1,7 @@ > + function(download_fastcv root_dir) > + > + # Commit SHA in the opencv_3rdparty repo > +- set(FASTCV_COMMIT "dc5d58018f3af915a8d209386d2c58c0501c0f2c") > ++ set(FASTCV_COMMIT "f4413cc2ab7233fdfc383a4cded402c072677fb0") > + > + # Define actual FastCV versions > + if(ANDROID) > +@@ -16,14 +16,15 @@ function(download_fastcv root_dir) > + endif() > + elseif(UNIX AND NOT APPLE AND NOT IOS AND NOT XROS) > + if(AARCH64) > +- set(FCV_PACKAGE_NAME "fastcv_linux_aarch64_2024_12_11.tgz") > +- set(FCV_PACKAGE_HASH "7b33ad833e6f15ab6d4ec64fa3c17acd") > ++ set(FCV_PACKAGE_NAME "fastcv_linux_aarch64_2025_02_12.tgz") > ++ set(FCV_PACKAGE_HASH "33ac2a59cf3e7d6402eee2e010de1202") > + else() > + message("FastCV: fastcv lib for 32-bit Linux is not supported for now!") > + endif() > + endif(ANDROID) > + > + # Download Package > ++ > + set(OPENCV_FASTCV_URL "https://raw.githubusercontent.com/opencv/opencv_3rdparty/${FASTCV_COMMIT}/fastcv/") > + > + ocv_download( FILENAME ${FCV_PACKAGE_NAME} > +@@ -40,4 +41,4 @@ function(download_fastcv root_dir) > + message(WARNING "FastCV: package download failed!") > + endif() > + > +-endfunction() > ++endfunction() > +\ No newline at end of file > +diff --git a/cmake/OpenCVFindLibsPerf.cmake b/cmake/OpenCVFindLibsPerf.cmake > +index c2380e6ce5..a31842dfbb 100644 > +--- a/cmake/OpenCVFindLibsPerf.cmake > ++++ b/cmake/OpenCVFindLibsPerf.cmake > +@@ -181,7 +181,14 @@ endif(WITH_KLEIDICV) > + if(WITH_FASTCV) > + if((EXISTS ${FastCV_INCLUDE_PATH}) AND (EXISTS ${FastCV_LIB_PATH})) > + message(STATUS "Use external FastCV ${FastCV_INCLUDE_PATH}, ${FastCV_LIB_PATH}") > +- set(HAVE_FASTCV TRUE CACHE BOOL "FastCV status") > ++ find_library(FASTCV_LIBRARY NAMES "fastcv" > ++ PATHS "${FastCV_LIB_PATH}" NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) > ++ mark_as_advanced(FASTCV_LIBRARY) > ++ if (FASTCV_LIBRARY) > ++ set(HAVE_FASTCV TRUE CACHE BOOL "FastCV status") > ++ else() > ++ set(HAVE_FASTCV FALSE CACHE BOOL "FastCV status") > ++ endif() > + else() > + include("${OpenCV_SOURCE_DIR}/3rdparty/fastcv/fastcv.cmake") > + set(FCV_ROOT_DIR "${OpenCV_BINARY_DIR}/3rdparty/fastcv") > +@@ -190,13 +197,15 @@ if(WITH_FASTCV) > + set(FastCV_INCLUDE_PATH "${FCV_ROOT_DIR}/inc" CACHE PATH "FastCV includes directory") > + set(FastCV_LIB_PATH "${FCV_ROOT_DIR}/libs" CACHE PATH "FastCV library directory") > + ocv_install_3rdparty_licenses(FastCV "${OpenCV_BINARY_DIR}/3rdparty/fastcv/LICENSE") > +- install(FILES "${FastCV_LIB_PATH}/libfastcvopt.so" > +- DESTINATION "${OPENCV_LIB_INSTALL_PATH}" COMPONENT "bin") > ++ if(ANDROID) > ++ set(FASTCV_LIBRARY "${FastCV_LIB_PATH}/libfastcvopt.so" CACHE PATH "FastCV library") > ++ install(FILES "${FASTCV_LIBRARY}" DESTINATION "${OPENCV_LIB_INSTALL_PATH}" COMPONENT "bin") > ++ else() > ++ set(FASTCV_LIBRARY "${FastCV_LIB_PATH}/libfastcv.a" CACHE PATH "FastCV library") > ++ install(FILES "${FASTCV_LIBRARY}" DESTINATION "${OPENCV_LIB_INSTALL_PATH}" COMPONENT "dev") > ++ endif() > + else() > + set(HAVE_FASTCV FALSE CACHE BOOL "FastCV status") > + endif() > + endif() > +- if(HAVE_FASTCV) > +- set(FASTCV_LIBRARY "${FastCV_LIB_PATH}/libfastcvopt.so" CACHE PATH "FastCV library") > +- endif() > +-endif(WITH_FASTCV) > ++endif(WITH_FASTCV) > +\ No newline at end of file > +-- > +2.34.1 > + > diff --git a/meta-oe/recipes-support/opencv/opencv/0001-PENDING-Removed-cluster-euclidean-in-fastcv-ext.patch b/meta-oe/recipes-support/opencv/opencv/0001-PENDING-Removed-cluster-euclidean-in-fastcv-ext.patch > new file mode 100644 > index 0000000000..cb570c55e4 > --- /dev/null > +++ b/meta-oe/recipes-support/opencv/opencv/0001-PENDING-Removed-cluster-euclidean-in-fastcv-ext.patch > @@ -0,0 +1,371 @@ > +From d7db8fb8d715a86d0939797bc08073895c475989 Mon Sep 17 00:00:00 2001 > +From: Pulkit Singh Tak <quic_ptak@quicinc.com> > +Date: Thu, 13 Feb 2025 17:55:08 +0530 > +Subject: [PATCH] PENDING: Removed cluster euclidean in fastcv ext > + > +Signed-off-by: Pulkit Singh Tak <quic_ptak@quicinc.com> > +Upstream-Status: PENDING Status should be Pending aside from this, why is it not submitted yet ? it would be good to document that. Unsubmitted patches carry maintenance cost > +--- > + modules/fastcv/include/opencv2/fastcv.hpp | 1 - > + .../fastcv/include/opencv2/fastcv/cluster.hpp | 43 ------ > + .../fastcv/perf/perf_cluster_euclidean.cpp | 79 ----------- > + modules/fastcv/src/cluster_euclidean.cpp | 66 ---------- > + .../fastcv/test/test_cluster_euclidean.cpp | 124 ------------------ > + 5 files changed, 313 deletions(-) > + delete mode 100644 modules/fastcv/include/opencv2/fastcv/cluster.hpp > + delete mode 100644 modules/fastcv/perf/perf_cluster_euclidean.cpp > + delete mode 100644 modules/fastcv/src/cluster_euclidean.cpp > + delete mode 100644 modules/fastcv/test/test_cluster_euclidean.cpp > + > +diff --git a/modules/fastcv/include/opencv2/fastcv.hpp b/modules/fastcv/include/opencv2/fastcv.hpp > +index af188dfc..c5deb5e0 100644 > +--- a/modules/fastcv/include/opencv2/fastcv.hpp > ++++ b/modules/fastcv/include/opencv2/fastcv.hpp > +@@ -11,7 +11,6 @@ > + #include "opencv2/fastcv/arithm.hpp" > + #include "opencv2/fastcv/bilateralFilter.hpp" > + #include "opencv2/fastcv/blur.hpp" > +-#include "opencv2/fastcv/cluster.hpp" > + #include "opencv2/fastcv/draw.hpp" > + #include "opencv2/fastcv/edges.hpp" > + #include "opencv2/fastcv/fast10.hpp" > +diff --git a/modules/fastcv/include/opencv2/fastcv/cluster.hpp b/modules/fastcv/include/opencv2/fastcv/cluster.hpp > +deleted file mode 100644 > +index 46ac7ad1..00000000 > +--- a/modules/fastcv/include/opencv2/fastcv/cluster.hpp > ++++ /dev/null > +@@ -1,43 +0,0 @@ > +-/* > +- * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved. > +- * SPDX-License-Identifier: Apache-2.0 > +-*/ > +- > +-#ifndef OPENCV_FASTCV_CLUSTER_HPP > +-#define OPENCV_FASTCV_CLUSTER_HPP > +- > +-#include <opencv2/core.hpp> > +- > +-namespace cv { > +-namespace fastcv { > +- > +-//! @addtogroup fastcv > +-//! @{ > +- > +-/** > +- * @brief Clusterizes N input points in D-dimensional space into K clusters > +- * Accepts 8-bit unsigned integer points > +- * Provides faster execution time than cv::kmeans on Qualcomm's processors > +- * @param points Points array of type 8u, each row represets a point. > +- * Size is N rows by D columns, can be non-continuous. > +- * @param clusterCenters Initial cluster centers array of type 32f, each row represents a center. > +- * Size is K rows by D columns, can be non-continuous. > +- * @param newClusterCenters Resulting cluster centers array of type 32f, each row represents found center. > +- * Size is set to be K rows by D columns. > +- * @param clusterSizes Resulting cluster member counts array of type uint32, size is set to be 1 row by K columns. > +- * @param clusterBindings Resulting points indices array of type uint32, each index tells to which cluster the corresponding point belongs to. > +- * Size is set to be 1 row by numPointsUsed columns. > +- * @param clusterSumDists Resulting distance sums array of type 32f, each number is a sum of distances between each cluster center to its belonging points. > +- * Size is set to be 1 row by K columns > +- * @param numPointsUsed Number of points to clusterize starting from 0 to numPointsUsed-1 inclusively. Sets to N if negative. > +- */ > +-CV_EXPORTS_W void clusterEuclidean(InputArray points, InputArray clusterCenters, OutputArray newClusterCenters, > +- OutputArray clusterSizes, OutputArray clusterBindings, OutputArray clusterSumDists, > +- int numPointsUsed = -1); > +- > +-//! @} > +- > +-} // fastcv:: > +-} // cv:: > +- > +-#endif // OPENCV_FASTCV_CLUSTER_HPP > +diff --git a/modules/fastcv/perf/perf_cluster_euclidean.cpp b/modules/fastcv/perf/perf_cluster_euclidean.cpp > +deleted file mode 100644 > +index 20bc31a7..00000000 > +--- a/modules/fastcv/perf/perf_cluster_euclidean.cpp > ++++ /dev/null > +@@ -1,79 +0,0 @@ > +-/* > +- * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved. > +- * SPDX-License-Identifier: Apache-2.0 > +-*/ > +- > +-#include "perf_precomp.hpp" > +- > +-namespace opencv_test { > +- > +-typedef std::tuple<int /* nPts */, int /*nDims*/, int /*nClusters*/> ClusterEuclideanPerfParams; > +-typedef perf::TestBaseWithParam<ClusterEuclideanPerfParams> ClusterEuclideanPerfTest; > +- > +-PERF_TEST_P(ClusterEuclideanPerfTest, run, > +- ::testing::Combine(::testing::Values(100, 1000, 10000), // nPts > +- ::testing::Values(2, 10, 32), // nDims > +- ::testing::Values(5, 10, 16)) // nClusters > +- ) > +-{ > +- auto p = GetParam(); > +- int nPts = std::get<0>(p); > +- int nDims = std::get<1>(p); > +- int nClusters = std::get<2>(p); > +- > +- Mat points(nPts, nDims, CV_8U); > +- Mat clusterCenters(nClusters, nDims, CV_32F); > +- > +- Mat trueMeans(nClusters, nDims, CV_32F); > +- Mat stddevs(nClusters, nDims, CV_32F); > +- std::vector<int> trueClusterSizes(nClusters, 0); > +- std::vector<int> trueClusterBindings(nPts, 0); > +- std::vector<float> trueSumDists(nClusters, 0); > +- > +- cv::RNG& rng = cv::theRNG(); > +- for (int i = 0; i < nClusters; i++) > +- { > +- Mat mean(1, nDims, CV_64F), stdev(1, nDims, CV_64F); > +- rng.fill(mean, cv::RNG::UNIFORM, 0, 256); > +- rng.fill(stdev, cv::RNG::UNIFORM, 5.f, 16); > +- int lo = i * nPts / nClusters; > +- int hi = (i + 1) * nPts / nClusters; > +- > +- for (int d = 0; d < nDims; d++) > +- { > +- rng.fill(points.col(d).rowRange(lo, hi), cv::RNG::NORMAL, > +- mean.at<double>(d), stdev.at<double>(d)); > +- } > +- > +- float sd = 0; > +- for (int j = lo; j < hi; j++) > +- { > +- Mat pts64f; > +- points.row(j).convertTo(pts64f, CV_64F); > +- sd += cv::norm(mean, pts64f, NORM_L2); > +- trueClusterBindings.at(j) = i; > +- trueClusterSizes.at(i)++; > +- } > +- trueSumDists.at(i) = sd; > +- > +- // let's shift initial cluster center a bit > +- Mat(mean + stdev * 0.5).copyTo(clusterCenters.row(i)); > +- > +- mean.copyTo(trueMeans.row(i)); > +- stdev.copyTo(stddevs.row(i)); > +- } > +- > +- while(next()) > +- { > +- Mat newClusterCenters; > +- std::vector<int> clusterSizes, clusterBindings; > +- std::vector<float> clusterSumDists; > +- startTimer(); > +- cv::fastcv::clusterEuclidean(points, clusterCenters, newClusterCenters, clusterSizes, clusterBindings, clusterSumDists); > +- stopTimer(); > +- } > +- > +- SANITY_CHECK_NOTHING(); > +-} > +- > +-} // namespace > +diff --git a/modules/fastcv/src/cluster_euclidean.cpp b/modules/fastcv/src/cluster_euclidean.cpp > +deleted file mode 100644 > +index a50b027c..00000000 > +--- a/modules/fastcv/src/cluster_euclidean.cpp > ++++ /dev/null > +@@ -1,66 +0,0 @@ > +-/* > +- * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved. > +- * SPDX-License-Identifier: Apache-2.0 > +-*/ > +- > +-#include "precomp.hpp" > +- > +-namespace cv { > +-namespace fastcv { > +- > +-void clusterEuclidean(InputArray _points, InputArray _clusterCenters, OutputArray _newClusterCenters, > +- OutputArray _clusterSizes, OutputArray _clusterBindings, OutputArray _clusterSumDists, > +- int numPointsUsed) > +-{ > +- INITIALIZATION_CHECK; > +- > +- CV_Assert(!_points.empty() && _points.type() == CV_8UC1); > +- int nPts = _points.rows(); > +- int nDims = _points.cols(); > +- int ptsStride = _points.step(); > +- > +- CV_Assert(!_clusterCenters.empty() && _clusterCenters.depth() == CV_32F); > +- int nClusters = _clusterCenters.rows(); > +- int clusterCenterStride = _clusterCenters.step(); > +- > +- CV_Assert(_clusterCenters.cols() == nDims); > +- > +- CV_Assert(numPointsUsed <= nPts); > +- if (numPointsUsed < 0) > +- { > +- numPointsUsed = nPts; > +- } > +- > +- _newClusterCenters.create(nClusters, nDims, CV_32FC1); > +- _clusterSizes.create(1, nClusters, CV_32SC1); > +- _clusterBindings.create(1, numPointsUsed, CV_32SC1); > +- _clusterSumDists.create(1, nClusters, CV_32FC1); > +- > +- Mat points = _points.getMat(); > +- Mat clusterCenters = _clusterCenters.getMat(); > +- Mat newClusterCenters = _newClusterCenters.getMat(); > +- Mat clusterSizes = _clusterSizes.getMat(); > +- Mat clusterBindings = _clusterBindings.getMat(); > +- Mat clusterSumDists = _clusterSumDists.getMat(); > +- > +- int result = fcvClusterEuclideanu8(points.data, > +- nPts, > +- nDims, > +- ptsStride, > +- numPointsUsed, > +- nClusters, > +- (float32_t*)clusterCenters.data, > +- clusterCenterStride, > +- (float32_t*)newClusterCenters.data, > +- (uint32_t*)clusterSizes.data, > +- (uint32_t*)clusterBindings.data, > +- (float32_t*)clusterSumDists.data); > +- > +- if (result) > +- { > +- CV_Error(cv::Error::StsInternal, cv::format("Failed to clusterize, error code: %d", result)); > +- } > +-} > +- > +-} // fastcv:: > +-} // cv:: > +diff --git a/modules/fastcv/test/test_cluster_euclidean.cpp b/modules/fastcv/test/test_cluster_euclidean.cpp > +deleted file mode 100644 > +index c108f754..00000000 > +--- a/modules/fastcv/test/test_cluster_euclidean.cpp > ++++ /dev/null > +@@ -1,124 +0,0 @@ > +-/* > +- * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved. > +- * SPDX-License-Identifier: Apache-2.0 > +-*/ > +- > +-#include "test_precomp.hpp" > +- > +-namespace opencv_test { namespace { > +- > +-// nPts, nDims, nClusters > +-typedef std::tuple<int, int, int> ClusterEuclideanTestParams; > +-class ClusterEuclideanTest : public ::testing::TestWithParam<ClusterEuclideanTestParams> {}; > +- > +-TEST_P(ClusterEuclideanTest, accuracy) > +-{ > +- auto p = GetParam(); > +- int nPts = std::get<0>(p); > +- int nDims = std::get<1>(p); > +- int nClusters = std::get<2>(p); > +- > +- Mat points(nPts, nDims, CV_8U); > +- Mat clusterCenters(nClusters, nDims, CV_32F); > +- > +- Mat trueMeans(nClusters, nDims, CV_32F); > +- Mat stddevs(nClusters, nDims, CV_32F); > +- std::vector<int> trueClusterSizes(nClusters, 0); > +- std::vector<int> trueClusterBindings(nPts, 0); > +- std::vector<float> trueSumDists(nClusters, 0); > +- > +- cv::RNG& rng = cv::theRNG(); > +- for (int i = 0; i < nClusters; i++) > +- { > +- Mat mean(1, nDims, CV_64F), stdev(1, nDims, CV_64F); > +- rng.fill(mean, cv::RNG::UNIFORM, 0, 256); > +- rng.fill(stdev, cv::RNG::UNIFORM, 5.f, 16); > +- int lo = i * nPts / nClusters; > +- int hi = (i + 1) * nPts / nClusters; > +- > +- for (int d = 0; d < nDims; d++) > +- { > +- rng.fill(points.col(d).rowRange(lo, hi), cv::RNG::NORMAL, > +- mean.at<double>(d), stdev.at<double>(d)); > +- } > +- > +- float sd = 0; > +- for (int j = lo; j < hi; j++) > +- { > +- Mat pts64f; > +- points.row(j).convertTo(pts64f, CV_64F); > +- sd += cv::norm(mean, pts64f, NORM_L2); > +- trueClusterBindings.at(j) = i; > +- trueClusterSizes.at(i)++; > +- } > +- trueSumDists.at(i) = sd; > +- > +- // let's shift initial cluster center a bit > +- Mat(mean + stdev * 0.5).copyTo(clusterCenters.row(i)); > +- > +- mean.copyTo(trueMeans.row(i)); > +- stdev.copyTo(stddevs.row(i)); > +- } > +- > +- Mat newClusterCenters; > +- std::vector<int> clusterSizes, clusterBindings; > +- std::vector<float> clusterSumDists; > +- cv::fastcv::clusterEuclidean(points, clusterCenters, newClusterCenters, clusterSizes, clusterBindings, clusterSumDists); > +- > +- if (cvtest::debugLevel > 0 && nDims == 2) > +- { > +- Mat draw(256, 256, CV_8UC3, Scalar(0)); > +- for (int i = 0; i < nPts; i++) > +- { > +- int x = std::rint(points.at<uchar>(i, 0)); > +- int y = std::rint(points.at<uchar>(i, 1)); > +- draw.at<Vec3b>(y, x) = Vec3b::all(128); > +- } > +- for (int i = 0; i < nClusters; i++) > +- { > +- float cx = trueMeans.at<double>(i, 0); > +- float cy = trueMeans.at<double>(i, 1); > +- draw.at<Vec3b>(cy, cx) = Vec3b(0, 255, 0); > +- > +- float sx = stddevs.at<double>(i, 0); > +- float sy = stddevs.at<double>(i, 1); > +- cv::ellipse(draw, Point(cx, cy), Size(sx, sy), 0, 0, 360, Scalar(255, 0, 0)); > +- > +- float ox = clusterCenters.at<float>(i, 0); > +- float oy = clusterCenters.at<float>(i, 1); > +- draw.at<Vec3b>(oy, ox) = Vec3b(0, 0, 255); > +- > +- float nx = newClusterCenters.at<float>(i, 0); > +- float ny = newClusterCenters.at<float>(i, 1); > +- draw.at<Vec3b>(ny, nx) = Vec3b(255, 255, 0); > +- } > +- cv::imwrite(cv::format("draw_%d_%d_%d.png", nPts, nDims, nClusters), draw); > +- } > +- > +- { > +- std::vector<double> diffs; > +- for (int i = 0; i < nClusters; i++) > +- { > +- double cs = std::abs((trueClusterSizes[i] - clusterSizes[i]) / double(trueClusterSizes[i])); > +- diffs.push_back(cs); > +- } > +- double normL2 = cv::norm(diffs, NORM_L2) / nClusters; > +- > +- EXPECT_LT(normL2, 0.392); > +- } > +- > +- { > +- Mat bindings8u, trueBindings8u; > +- Mat(clusterBindings).convertTo(bindings8u, CV_8U); > +- Mat(trueClusterBindings).convertTo(trueBindings8u, CV_8U); > +- double normH = cv::norm(bindings8u, trueBindings8u, NORM_HAMMING) / nPts; > +- EXPECT_LT(normH, 0.658); > +- } > +-} > +- > +-INSTANTIATE_TEST_CASE_P(FastCV_Extension, ClusterEuclideanTest, > +- ::testing::Combine(::testing::Values(100, 1000, 10000), // nPts > +- ::testing::Values(2, 10, 32), // nDims > +- ::testing::Values(5, 10, 16))); // nClusters > +- > +-}} // namespaces opencv_test, :: > +\ No newline at end of file > +-- > +2.34.1 > + > diff --git a/meta-oe/recipes-support/opencv/opencv_4.11.0.bb b/meta-oe/recipes-support/opencv/opencv_4.11.0.bb > index 1613b6a3ed..1b0285e05b 100644 > --- a/meta-oe/recipes-support/opencv/opencv_4.11.0.bb > +++ b/meta-oe/recipes-support/opencv/opencv_4.11.0.bb > @@ -16,15 +16,17 @@ SRCREV_boostdesc = "34e4206aef44d50e6bbcd0ab06354b52e7466d26" > SRCREV_vgg = "fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d" > SRCREV_face = "8afa57abc8229d611c4937165d20e2a2d9fc5a12" > SRCREV_wechat-qrcode = "a8b69ccc738421293254aec5ddb38bd523503252" > +SRCREV_fastcv = "f4413cc2ab7233fdfc383a4cded402c072677fb0" > > > -SRCREV_FORMAT = "opencv_contrib_ipp_boostdesc_vgg" > +SRCREV_FORMAT = "opencv_contrib_ipp_boostdesc_vgg_fastcv" > SRC_URI = "git://github.com/opencv/opencv.git;name=opencv;branch=4.x;protocol=https \ > git://github.com/opencv/opencv_contrib.git;destsuffix=git/contrib;name=contrib;branch=4.x;protocol=https \ > git://github.com/opencv/opencv_3rdparty.git;branch=contrib_xfeatures2d_boostdesc_20161012;destsuffix=git/boostdesc;name=boostdesc;protocol=https \ > git://github.com/opencv/opencv_3rdparty.git;branch=contrib_xfeatures2d_vgg_20160317;destsuffix=git/vgg;name=vgg;protocol=https \ > git://github.com/opencv/opencv_3rdparty.git;branch=contrib_face_alignment_20170818;destsuffix=git/face;name=face;protocol=https \ > git://github.com/WeChatCV/opencv_3rdparty.git;branch=wechat_qrcode;destsuffix=git/wechat_qrcode;name=wechat-qrcode;protocol=https \ > + git://github.com/opencv/opencv_3rdparty.git;branch=fastcv/4.x_20250212;destsuffix=git/fastcv;name=fastcv;protocol=https \ > file://0003-To-fix-errors-as-following.patch \ > file://0001-Temporarliy-work-around-deprecated-ffmpeg-RAW-functi.patch \ > file://0001-Dont-use-isystem.patch \ > @@ -37,6 +39,13 @@ SRC_URI:append:riscv64 = " file://0001-Use-Os-to-compile-tinyxml2.cpp.patch;patc > > S = "${WORKDIR}/git" > > +# Disabling cluster ecludian tests in fastcv EXTN as it causes fastcv EXTN tests to be crashed. > +# Adding support for fastcv static lib as per Upstream OpenCV. > +# These are temporary patches, will be removed in next release. > + > +SRC_URI += "file://0001-PENDING-Removed-cluster-euclidean-in-fastcv-ext.patch;patchdir=${S}/contrib/ \ > + file://0001-FROMLIST-Using-fastcv-static-lib-for-compilation.patch" > + > # OpenCV wants to download more files during configure. We download these in > # do_fetch and construct a source cache in the format it expects > OPENCV_DLDIR = "${WORKDIR}/downloads" > @@ -61,6 +70,7 @@ do_unpack_extra() { > cache data ${S}/face/*.dat > cache wechat_qrcode ${S}/wechat_qrcode/*.caffemodel > cache wechat_qrcode ${S}/wechat_qrcode/*.prototxt > + cache fastcv ${S}/fastcv/fastcv/*.tgz > } > addtask unpack_extra after do_unpack before do_patch > > @@ -71,7 +81,6 @@ EXTRA_OECMAKE = "-DOPENCV_EXTRA_MODULES_PATH=${S}/contrib/modules \ > -DENABLE_PRECOMPILED_HEADERS=OFF \ > -DCMAKE_SKIP_RPATH=ON \ > -DWITH_IPP=OFF \ > - -DWITH_FASTCV=OFF \ > -DOPENCV_GENERATE_PKGCONFIG=ON \ > -DOPENCV_DOWNLOAD_PATH=${OPENCV_DLDIR} \ > -DOPENCV_ALLOW_DOWNLOADS=OFF \ > @@ -122,6 +131,7 @@ PACKAGECONFIG[tests] = "-DBUILD_TESTS=ON,-DBUILD_TESTS=OFF,," > PACKAGECONFIG[text] = "-DBUILD_opencv_text=ON,-DBUILD_opencv_text=OFF,tesseract," > PACKAGECONFIG[tiff] = "-DWITH_TIFF=ON,-DWITH_TIFF=OFF,tiff," > PACKAGECONFIG[v4l] = "-DWITH_V4L=ON,-DWITH_V4L=OFF,v4l-utils," > +PACKAGECONFIG[fastcv] = "-DWITH_FASTCV=ON ,-DWITH_FASTCV=OFF,," > > inherit pkgconfig cmake setuptools3-base python3native > > -- > 2.34.1 > > > -=-=-=-=-=-=-=-=-=-=-=- > Links: You receive all messages sent to this group. > View/Reply Online (#116206): https://lists.openembedded.org/g/openembedded-devel/message/116206 > Mute This Topic: https://lists.openembedded.org/mt/111872956/1997914 > Group Owner: openembedded-devel+owner@lists.openembedded.org > Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [raj.khem@gmail.com] > -=-=-=-=-=-=-=-=-=-=-=- >
see - https://errors.yoctoproject.org/Errors/Details/848705/ secondly subject line is to be prefixed with <recipename>: Short summary Description of change ... Please follow https://docs.yoctoproject.org/contributor-guide/index.html https://docs.yoctoproject.org/contributor-guide/recipe-style-guide.html#patch-upstream-status On Mon, Mar 24, 2025 at 7:36 AM Khem Raj <raj.khem@gmail.com> wrote: > > On Mon, Mar 24, 2025 at 12:55 AM Pulkit Singh Tak (Temp) (QUIC) via > lists.openembedded.org <quic_ptak=quicinc.com@lists.openembedded.org> > wrote: > > > > Adding patches to support fastcv static lib compilation > > and removal of cluster ecludian tests support > > These are temporary patches to be removeed in next release. > > typo here 'removed' > > > > > Signed-off-by: Pulkit Singh Tak <quic_ptak@quicinc.com> > > --- > > ...ng-fastcv-static-lib-for-compilation.patch | 96 +++++ > > ...oved-cluster-euclidean-in-fastcv-ext.patch | 371 ++++++++++++++++++ > > .../recipes-support/opencv/opencv_4.11.0.bb | 14 +- > > 3 files changed, 479 insertions(+), 2 deletions(-) > > create mode 100644 meta-oe/recipes-support/opencv/opencv/0001-FROMLIST-Using-fastcv-static-lib-for-compilation.patch > > create mode 100644 meta-oe/recipes-support/opencv/opencv/0001-PENDING-Removed-cluster-euclidean-in-fastcv-ext.patch > > > > diff --git a/meta-oe/recipes-support/opencv/opencv/0001-FROMLIST-Using-fastcv-static-lib-for-compilation.patch b/meta-oe/recipes-support/opencv/opencv/0001-FROMLIST-Using-fastcv-static-lib-for-compilation.patch > > new file mode 100644 > > index 0000000000..5fce32f4b8 > > --- /dev/null > > +++ b/meta-oe/recipes-support/opencv/opencv/0001-FROMLIST-Using-fastcv-static-lib-for-compilation.patch > > @@ -0,0 +1,96 @@ > > +From 0141830e67ac7c60c474ab3c1e7d3e30c27c7943 Mon Sep 17 00:00:00 2001 > > +From: Pulkit Singh Tak <quic_ptak@quicinc.com> > > +Date: Mon, 10 Feb 2025 15:10:26 +0530 > > +Subject: [PATCH] FROMLIST: Using fastcv static lib for compilation > > + > > +Signed-off-by: Pulkit Singh Tak <quic_ptak@quicinc.com> > > +Upstream-Status: SUBMITTED [https://github.com/opencv/opencv/pull/26917] > > status should be 'Submitted' > > > +--- > > + 3rdparty/fastcv/fastcv.cmake | 9 +++++---- > > + cmake/OpenCVFindLibsPerf.cmake | 23 ++++++++++++++++------- > > + 2 files changed, 21 insertions(+), 11 deletions(-) > > + > > +diff --git a/3rdparty/fastcv/fastcv.cmake b/3rdparty/fastcv/fastcv.cmake > > +index b8172705ca..12c6616a16 100644 > > +--- a/3rdparty/fastcv/fastcv.cmake > > ++++ b/3rdparty/fastcv/fastcv.cmake > > +@@ -1,7 +1,7 @@ > > + function(download_fastcv root_dir) > > + > > + # Commit SHA in the opencv_3rdparty repo > > +- set(FASTCV_COMMIT "dc5d58018f3af915a8d209386d2c58c0501c0f2c") > > ++ set(FASTCV_COMMIT "f4413cc2ab7233fdfc383a4cded402c072677fb0") > > + > > + # Define actual FastCV versions > > + if(ANDROID) > > +@@ -16,14 +16,15 @@ function(download_fastcv root_dir) > > + endif() > > + elseif(UNIX AND NOT APPLE AND NOT IOS AND NOT XROS) > > + if(AARCH64) > > +- set(FCV_PACKAGE_NAME "fastcv_linux_aarch64_2024_12_11.tgz") > > +- set(FCV_PACKAGE_HASH "7b33ad833e6f15ab6d4ec64fa3c17acd") > > ++ set(FCV_PACKAGE_NAME "fastcv_linux_aarch64_2025_02_12.tgz") > > ++ set(FCV_PACKAGE_HASH "33ac2a59cf3e7d6402eee2e010de1202") > > + else() > > + message("FastCV: fastcv lib for 32-bit Linux is not supported for now!") > > + endif() > > + endif(ANDROID) > > + > > + # Download Package > > ++ > > + set(OPENCV_FASTCV_URL "https://raw.githubusercontent.com/opencv/opencv_3rdparty/${FASTCV_COMMIT}/fastcv/") > > + > > + ocv_download( FILENAME ${FCV_PACKAGE_NAME} > > +@@ -40,4 +41,4 @@ function(download_fastcv root_dir) > > + message(WARNING "FastCV: package download failed!") > > + endif() > > + > > +-endfunction() > > ++endfunction() > > +\ No newline at end of file > > +diff --git a/cmake/OpenCVFindLibsPerf.cmake b/cmake/OpenCVFindLibsPerf.cmake > > +index c2380e6ce5..a31842dfbb 100644 > > +--- a/cmake/OpenCVFindLibsPerf.cmake > > ++++ b/cmake/OpenCVFindLibsPerf.cmake > > +@@ -181,7 +181,14 @@ endif(WITH_KLEIDICV) > > + if(WITH_FASTCV) > > + if((EXISTS ${FastCV_INCLUDE_PATH}) AND (EXISTS ${FastCV_LIB_PATH})) > > + message(STATUS "Use external FastCV ${FastCV_INCLUDE_PATH}, ${FastCV_LIB_PATH}") > > +- set(HAVE_FASTCV TRUE CACHE BOOL "FastCV status") > > ++ find_library(FASTCV_LIBRARY NAMES "fastcv" > > ++ PATHS "${FastCV_LIB_PATH}" NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) > > ++ mark_as_advanced(FASTCV_LIBRARY) > > ++ if (FASTCV_LIBRARY) > > ++ set(HAVE_FASTCV TRUE CACHE BOOL "FastCV status") > > ++ else() > > ++ set(HAVE_FASTCV FALSE CACHE BOOL "FastCV status") > > ++ endif() > > + else() > > + include("${OpenCV_SOURCE_DIR}/3rdparty/fastcv/fastcv.cmake") > > + set(FCV_ROOT_DIR "${OpenCV_BINARY_DIR}/3rdparty/fastcv") > > +@@ -190,13 +197,15 @@ if(WITH_FASTCV) > > + set(FastCV_INCLUDE_PATH "${FCV_ROOT_DIR}/inc" CACHE PATH "FastCV includes directory") > > + set(FastCV_LIB_PATH "${FCV_ROOT_DIR}/libs" CACHE PATH "FastCV library directory") > > + ocv_install_3rdparty_licenses(FastCV "${OpenCV_BINARY_DIR}/3rdparty/fastcv/LICENSE") > > +- install(FILES "${FastCV_LIB_PATH}/libfastcvopt.so" > > +- DESTINATION "${OPENCV_LIB_INSTALL_PATH}" COMPONENT "bin") > > ++ if(ANDROID) > > ++ set(FASTCV_LIBRARY "${FastCV_LIB_PATH}/libfastcvopt.so" CACHE PATH "FastCV library") > > ++ install(FILES "${FASTCV_LIBRARY}" DESTINATION "${OPENCV_LIB_INSTALL_PATH}" COMPONENT "bin") > > ++ else() > > ++ set(FASTCV_LIBRARY "${FastCV_LIB_PATH}/libfastcv.a" CACHE PATH "FastCV library") > > ++ install(FILES "${FASTCV_LIBRARY}" DESTINATION "${OPENCV_LIB_INSTALL_PATH}" COMPONENT "dev") > > ++ endif() > > + else() > > + set(HAVE_FASTCV FALSE CACHE BOOL "FastCV status") > > + endif() > > + endif() > > +- if(HAVE_FASTCV) > > +- set(FASTCV_LIBRARY "${FastCV_LIB_PATH}/libfastcvopt.so" CACHE PATH "FastCV library") > > +- endif() > > +-endif(WITH_FASTCV) > > ++endif(WITH_FASTCV) > > +\ No newline at end of file > > +-- > > +2.34.1 > > + > > diff --git a/meta-oe/recipes-support/opencv/opencv/0001-PENDING-Removed-cluster-euclidean-in-fastcv-ext.patch b/meta-oe/recipes-support/opencv/opencv/0001-PENDING-Removed-cluster-euclidean-in-fastcv-ext.patch > > new file mode 100644 > > index 0000000000..cb570c55e4 > > --- /dev/null > > +++ b/meta-oe/recipes-support/opencv/opencv/0001-PENDING-Removed-cluster-euclidean-in-fastcv-ext.patch > > @@ -0,0 +1,371 @@ > > +From d7db8fb8d715a86d0939797bc08073895c475989 Mon Sep 17 00:00:00 2001 > > +From: Pulkit Singh Tak <quic_ptak@quicinc.com> > > +Date: Thu, 13 Feb 2025 17:55:08 +0530 > > +Subject: [PATCH] PENDING: Removed cluster euclidean in fastcv ext > > + > > +Signed-off-by: Pulkit Singh Tak <quic_ptak@quicinc.com> > > +Upstream-Status: PENDING > > Status should be Pending > aside from this, why is it not submitted yet ? it would be good to > document that. Unsubmitted patches carry maintenance cost > > > +--- > > + modules/fastcv/include/opencv2/fastcv.hpp | 1 - > > + .../fastcv/include/opencv2/fastcv/cluster.hpp | 43 ------ > > + .../fastcv/perf/perf_cluster_euclidean.cpp | 79 ----------- > > + modules/fastcv/src/cluster_euclidean.cpp | 66 ---------- > > + .../fastcv/test/test_cluster_euclidean.cpp | 124 ------------------ > > + 5 files changed, 313 deletions(-) > > + delete mode 100644 modules/fastcv/include/opencv2/fastcv/cluster.hpp > > + delete mode 100644 modules/fastcv/perf/perf_cluster_euclidean.cpp > > + delete mode 100644 modules/fastcv/src/cluster_euclidean.cpp > > + delete mode 100644 modules/fastcv/test/test_cluster_euclidean.cpp > > + > > +diff --git a/modules/fastcv/include/opencv2/fastcv.hpp b/modules/fastcv/include/opencv2/fastcv.hpp > > +index af188dfc..c5deb5e0 100644 > > +--- a/modules/fastcv/include/opencv2/fastcv.hpp > > ++++ b/modules/fastcv/include/opencv2/fastcv.hpp > > +@@ -11,7 +11,6 @@ > > + #include "opencv2/fastcv/arithm.hpp" > > + #include "opencv2/fastcv/bilateralFilter.hpp" > > + #include "opencv2/fastcv/blur.hpp" > > +-#include "opencv2/fastcv/cluster.hpp" > > + #include "opencv2/fastcv/draw.hpp" > > + #include "opencv2/fastcv/edges.hpp" > > + #include "opencv2/fastcv/fast10.hpp" > > +diff --git a/modules/fastcv/include/opencv2/fastcv/cluster.hpp b/modules/fastcv/include/opencv2/fastcv/cluster.hpp > > +deleted file mode 100644 > > +index 46ac7ad1..00000000 > > +--- a/modules/fastcv/include/opencv2/fastcv/cluster.hpp > > ++++ /dev/null > > +@@ -1,43 +0,0 @@ > > +-/* > > +- * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved. > > +- * SPDX-License-Identifier: Apache-2.0 > > +-*/ > > +- > > +-#ifndef OPENCV_FASTCV_CLUSTER_HPP > > +-#define OPENCV_FASTCV_CLUSTER_HPP > > +- > > +-#include <opencv2/core.hpp> > > +- > > +-namespace cv { > > +-namespace fastcv { > > +- > > +-//! @addtogroup fastcv > > +-//! @{ > > +- > > +-/** > > +- * @brief Clusterizes N input points in D-dimensional space into K clusters > > +- * Accepts 8-bit unsigned integer points > > +- * Provides faster execution time than cv::kmeans on Qualcomm's processors > > +- * @param points Points array of type 8u, each row represets a point. > > +- * Size is N rows by D columns, can be non-continuous. > > +- * @param clusterCenters Initial cluster centers array of type 32f, each row represents a center. > > +- * Size is K rows by D columns, can be non-continuous. > > +- * @param newClusterCenters Resulting cluster centers array of type 32f, each row represents found center. > > +- * Size is set to be K rows by D columns. > > +- * @param clusterSizes Resulting cluster member counts array of type uint32, size is set to be 1 row by K columns. > > +- * @param clusterBindings Resulting points indices array of type uint32, each index tells to which cluster the corresponding point belongs to. > > +- * Size is set to be 1 row by numPointsUsed columns. > > +- * @param clusterSumDists Resulting distance sums array of type 32f, each number is a sum of distances between each cluster center to its belonging points. > > +- * Size is set to be 1 row by K columns > > +- * @param numPointsUsed Number of points to clusterize starting from 0 to numPointsUsed-1 inclusively. Sets to N if negative. > > +- */ > > +-CV_EXPORTS_W void clusterEuclidean(InputArray points, InputArray clusterCenters, OutputArray newClusterCenters, > > +- OutputArray clusterSizes, OutputArray clusterBindings, OutputArray clusterSumDists, > > +- int numPointsUsed = -1); > > +- > > +-//! @} > > +- > > +-} // fastcv:: > > +-} // cv:: > > +- > > +-#endif // OPENCV_FASTCV_CLUSTER_HPP > > +diff --git a/modules/fastcv/perf/perf_cluster_euclidean.cpp b/modules/fastcv/perf/perf_cluster_euclidean.cpp > > +deleted file mode 100644 > > +index 20bc31a7..00000000 > > +--- a/modules/fastcv/perf/perf_cluster_euclidean.cpp > > ++++ /dev/null > > +@@ -1,79 +0,0 @@ > > +-/* > > +- * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved. > > +- * SPDX-License-Identifier: Apache-2.0 > > +-*/ > > +- > > +-#include "perf_precomp.hpp" > > +- > > +-namespace opencv_test { > > +- > > +-typedef std::tuple<int /* nPts */, int /*nDims*/, int /*nClusters*/> ClusterEuclideanPerfParams; > > +-typedef perf::TestBaseWithParam<ClusterEuclideanPerfParams> ClusterEuclideanPerfTest; > > +- > > +-PERF_TEST_P(ClusterEuclideanPerfTest, run, > > +- ::testing::Combine(::testing::Values(100, 1000, 10000), // nPts > > +- ::testing::Values(2, 10, 32), // nDims > > +- ::testing::Values(5, 10, 16)) // nClusters > > +- ) > > +-{ > > +- auto p = GetParam(); > > +- int nPts = std::get<0>(p); > > +- int nDims = std::get<1>(p); > > +- int nClusters = std::get<2>(p); > > +- > > +- Mat points(nPts, nDims, CV_8U); > > +- Mat clusterCenters(nClusters, nDims, CV_32F); > > +- > > +- Mat trueMeans(nClusters, nDims, CV_32F); > > +- Mat stddevs(nClusters, nDims, CV_32F); > > +- std::vector<int> trueClusterSizes(nClusters, 0); > > +- std::vector<int> trueClusterBindings(nPts, 0); > > +- std::vector<float> trueSumDists(nClusters, 0); > > +- > > +- cv::RNG& rng = cv::theRNG(); > > +- for (int i = 0; i < nClusters; i++) > > +- { > > +- Mat mean(1, nDims, CV_64F), stdev(1, nDims, CV_64F); > > +- rng.fill(mean, cv::RNG::UNIFORM, 0, 256); > > +- rng.fill(stdev, cv::RNG::UNIFORM, 5.f, 16); > > +- int lo = i * nPts / nClusters; > > +- int hi = (i + 1) * nPts / nClusters; > > +- > > +- for (int d = 0; d < nDims; d++) > > +- { > > +- rng.fill(points.col(d).rowRange(lo, hi), cv::RNG::NORMAL, > > +- mean.at<double>(d), stdev.at<double>(d)); > > +- } > > +- > > +- float sd = 0; > > +- for (int j = lo; j < hi; j++) > > +- { > > +- Mat pts64f; > > +- points.row(j).convertTo(pts64f, CV_64F); > > +- sd += cv::norm(mean, pts64f, NORM_L2); > > +- trueClusterBindings.at(j) = i; > > +- trueClusterSizes.at(i)++; > > +- } > > +- trueSumDists.at(i) = sd; > > +- > > +- // let's shift initial cluster center a bit > > +- Mat(mean + stdev * 0.5).copyTo(clusterCenters.row(i)); > > +- > > +- mean.copyTo(trueMeans.row(i)); > > +- stdev.copyTo(stddevs.row(i)); > > +- } > > +- > > +- while(next()) > > +- { > > +- Mat newClusterCenters; > > +- std::vector<int> clusterSizes, clusterBindings; > > +- std::vector<float> clusterSumDists; > > +- startTimer(); > > +- cv::fastcv::clusterEuclidean(points, clusterCenters, newClusterCenters, clusterSizes, clusterBindings, clusterSumDists); > > +- stopTimer(); > > +- } > > +- > > +- SANITY_CHECK_NOTHING(); > > +-} > > +- > > +-} // namespace > > +diff --git a/modules/fastcv/src/cluster_euclidean.cpp b/modules/fastcv/src/cluster_euclidean.cpp > > +deleted file mode 100644 > > +index a50b027c..00000000 > > +--- a/modules/fastcv/src/cluster_euclidean.cpp > > ++++ /dev/null > > +@@ -1,66 +0,0 @@ > > +-/* > > +- * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved. > > +- * SPDX-License-Identifier: Apache-2.0 > > +-*/ > > +- > > +-#include "precomp.hpp" > > +- > > +-namespace cv { > > +-namespace fastcv { > > +- > > +-void clusterEuclidean(InputArray _points, InputArray _clusterCenters, OutputArray _newClusterCenters, > > +- OutputArray _clusterSizes, OutputArray _clusterBindings, OutputArray _clusterSumDists, > > +- int numPointsUsed) > > +-{ > > +- INITIALIZATION_CHECK; > > +- > > +- CV_Assert(!_points.empty() && _points.type() == CV_8UC1); > > +- int nPts = _points.rows(); > > +- int nDims = _points.cols(); > > +- int ptsStride = _points.step(); > > +- > > +- CV_Assert(!_clusterCenters.empty() && _clusterCenters.depth() == CV_32F); > > +- int nClusters = _clusterCenters.rows(); > > +- int clusterCenterStride = _clusterCenters.step(); > > +- > > +- CV_Assert(_clusterCenters.cols() == nDims); > > +- > > +- CV_Assert(numPointsUsed <= nPts); > > +- if (numPointsUsed < 0) > > +- { > > +- numPointsUsed = nPts; > > +- } > > +- > > +- _newClusterCenters.create(nClusters, nDims, CV_32FC1); > > +- _clusterSizes.create(1, nClusters, CV_32SC1); > > +- _clusterBindings.create(1, numPointsUsed, CV_32SC1); > > +- _clusterSumDists.create(1, nClusters, CV_32FC1); > > +- > > +- Mat points = _points.getMat(); > > +- Mat clusterCenters = _clusterCenters.getMat(); > > +- Mat newClusterCenters = _newClusterCenters.getMat(); > > +- Mat clusterSizes = _clusterSizes.getMat(); > > +- Mat clusterBindings = _clusterBindings.getMat(); > > +- Mat clusterSumDists = _clusterSumDists.getMat(); > > +- > > +- int result = fcvClusterEuclideanu8(points.data, > > +- nPts, > > +- nDims, > > +- ptsStride, > > +- numPointsUsed, > > +- nClusters, > > +- (float32_t*)clusterCenters.data, > > +- clusterCenterStride, > > +- (float32_t*)newClusterCenters.data, > > +- (uint32_t*)clusterSizes.data, > > +- (uint32_t*)clusterBindings.data, > > +- (float32_t*)clusterSumDists.data); > > +- > > +- if (result) > > +- { > > +- CV_Error(cv::Error::StsInternal, cv::format("Failed to clusterize, error code: %d", result)); > > +- } > > +-} > > +- > > +-} // fastcv:: > > +-} // cv:: > > +diff --git a/modules/fastcv/test/test_cluster_euclidean.cpp b/modules/fastcv/test/test_cluster_euclidean.cpp > > +deleted file mode 100644 > > +index c108f754..00000000 > > +--- a/modules/fastcv/test/test_cluster_euclidean.cpp > > ++++ /dev/null > > +@@ -1,124 +0,0 @@ > > +-/* > > +- * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved. > > +- * SPDX-License-Identifier: Apache-2.0 > > +-*/ > > +- > > +-#include "test_precomp.hpp" > > +- > > +-namespace opencv_test { namespace { > > +- > > +-// nPts, nDims, nClusters > > +-typedef std::tuple<int, int, int> ClusterEuclideanTestParams; > > +-class ClusterEuclideanTest : public ::testing::TestWithParam<ClusterEuclideanTestParams> {}; > > +- > > +-TEST_P(ClusterEuclideanTest, accuracy) > > +-{ > > +- auto p = GetParam(); > > +- int nPts = std::get<0>(p); > > +- int nDims = std::get<1>(p); > > +- int nClusters = std::get<2>(p); > > +- > > +- Mat points(nPts, nDims, CV_8U); > > +- Mat clusterCenters(nClusters, nDims, CV_32F); > > +- > > +- Mat trueMeans(nClusters, nDims, CV_32F); > > +- Mat stddevs(nClusters, nDims, CV_32F); > > +- std::vector<int> trueClusterSizes(nClusters, 0); > > +- std::vector<int> trueClusterBindings(nPts, 0); > > +- std::vector<float> trueSumDists(nClusters, 0); > > +- > > +- cv::RNG& rng = cv::theRNG(); > > +- for (int i = 0; i < nClusters; i++) > > +- { > > +- Mat mean(1, nDims, CV_64F), stdev(1, nDims, CV_64F); > > +- rng.fill(mean, cv::RNG::UNIFORM, 0, 256); > > +- rng.fill(stdev, cv::RNG::UNIFORM, 5.f, 16); > > +- int lo = i * nPts / nClusters; > > +- int hi = (i + 1) * nPts / nClusters; > > +- > > +- for (int d = 0; d < nDims; d++) > > +- { > > +- rng.fill(points.col(d).rowRange(lo, hi), cv::RNG::NORMAL, > > +- mean.at<double>(d), stdev.at<double>(d)); > > +- } > > +- > > +- float sd = 0; > > +- for (int j = lo; j < hi; j++) > > +- { > > +- Mat pts64f; > > +- points.row(j).convertTo(pts64f, CV_64F); > > +- sd += cv::norm(mean, pts64f, NORM_L2); > > +- trueClusterBindings.at(j) = i; > > +- trueClusterSizes.at(i)++; > > +- } > > +- trueSumDists.at(i) = sd; > > +- > > +- // let's shift initial cluster center a bit > > +- Mat(mean + stdev * 0.5).copyTo(clusterCenters.row(i)); > > +- > > +- mean.copyTo(trueMeans.row(i)); > > +- stdev.copyTo(stddevs.row(i)); > > +- } > > +- > > +- Mat newClusterCenters; > > +- std::vector<int> clusterSizes, clusterBindings; > > +- std::vector<float> clusterSumDists; > > +- cv::fastcv::clusterEuclidean(points, clusterCenters, newClusterCenters, clusterSizes, clusterBindings, clusterSumDists); > > +- > > +- if (cvtest::debugLevel > 0 && nDims == 2) > > +- { > > +- Mat draw(256, 256, CV_8UC3, Scalar(0)); > > +- for (int i = 0; i < nPts; i++) > > +- { > > +- int x = std::rint(points.at<uchar>(i, 0)); > > +- int y = std::rint(points.at<uchar>(i, 1)); > > +- draw.at<Vec3b>(y, x) = Vec3b::all(128); > > +- } > > +- for (int i = 0; i < nClusters; i++) > > +- { > > +- float cx = trueMeans.at<double>(i, 0); > > +- float cy = trueMeans.at<double>(i, 1); > > +- draw.at<Vec3b>(cy, cx) = Vec3b(0, 255, 0); > > +- > > +- float sx = stddevs.at<double>(i, 0); > > +- float sy = stddevs.at<double>(i, 1); > > +- cv::ellipse(draw, Point(cx, cy), Size(sx, sy), 0, 0, 360, Scalar(255, 0, 0)); > > +- > > +- float ox = clusterCenters.at<float>(i, 0); > > +- float oy = clusterCenters.at<float>(i, 1); > > +- draw.at<Vec3b>(oy, ox) = Vec3b(0, 0, 255); > > +- > > +- float nx = newClusterCenters.at<float>(i, 0); > > +- float ny = newClusterCenters.at<float>(i, 1); > > +- draw.at<Vec3b>(ny, nx) = Vec3b(255, 255, 0); > > +- } > > +- cv::imwrite(cv::format("draw_%d_%d_%d.png", nPts, nDims, nClusters), draw); > > +- } > > +- > > +- { > > +- std::vector<double> diffs; > > +- for (int i = 0; i < nClusters; i++) > > +- { > > +- double cs = std::abs((trueClusterSizes[i] - clusterSizes[i]) / double(trueClusterSizes[i])); > > +- diffs.push_back(cs); > > +- } > > +- double normL2 = cv::norm(diffs, NORM_L2) / nClusters; > > +- > > +- EXPECT_LT(normL2, 0.392); > > +- } > > +- > > +- { > > +- Mat bindings8u, trueBindings8u; > > +- Mat(clusterBindings).convertTo(bindings8u, CV_8U); > > +- Mat(trueClusterBindings).convertTo(trueBindings8u, CV_8U); > > +- double normH = cv::norm(bindings8u, trueBindings8u, NORM_HAMMING) / nPts; > > +- EXPECT_LT(normH, 0.658); > > +- } > > +-} > > +- > > +-INSTANTIATE_TEST_CASE_P(FastCV_Extension, ClusterEuclideanTest, > > +- ::testing::Combine(::testing::Values(100, 1000, 10000), // nPts > > +- ::testing::Values(2, 10, 32), // nDims > > +- ::testing::Values(5, 10, 16))); // nClusters > > +- > > +-}} // namespaces opencv_test, :: > > +\ No newline at end of file > > +-- > > +2.34.1 > > + > > diff --git a/meta-oe/recipes-support/opencv/opencv_4.11.0.bb b/meta-oe/recipes-support/opencv/opencv_4.11.0.bb > > index 1613b6a3ed..1b0285e05b 100644 > > --- a/meta-oe/recipes-support/opencv/opencv_4.11.0.bb > > +++ b/meta-oe/recipes-support/opencv/opencv_4.11.0.bb > > @@ -16,15 +16,17 @@ SRCREV_boostdesc = "34e4206aef44d50e6bbcd0ab06354b52e7466d26" > > SRCREV_vgg = "fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d" > > SRCREV_face = "8afa57abc8229d611c4937165d20e2a2d9fc5a12" > > SRCREV_wechat-qrcode = "a8b69ccc738421293254aec5ddb38bd523503252" > > +SRCREV_fastcv = "f4413cc2ab7233fdfc383a4cded402c072677fb0" > > > > > > -SRCREV_FORMAT = "opencv_contrib_ipp_boostdesc_vgg" > > +SRCREV_FORMAT = "opencv_contrib_ipp_boostdesc_vgg_fastcv" > > SRC_URI = "git://github.com/opencv/opencv.git;name=opencv;branch=4.x;protocol=https \ > > git://github.com/opencv/opencv_contrib.git;destsuffix=git/contrib;name=contrib;branch=4.x;protocol=https \ > > git://github.com/opencv/opencv_3rdparty.git;branch=contrib_xfeatures2d_boostdesc_20161012;destsuffix=git/boostdesc;name=boostdesc;protocol=https \ > > git://github.com/opencv/opencv_3rdparty.git;branch=contrib_xfeatures2d_vgg_20160317;destsuffix=git/vgg;name=vgg;protocol=https \ > > git://github.com/opencv/opencv_3rdparty.git;branch=contrib_face_alignment_20170818;destsuffix=git/face;name=face;protocol=https \ > > git://github.com/WeChatCV/opencv_3rdparty.git;branch=wechat_qrcode;destsuffix=git/wechat_qrcode;name=wechat-qrcode;protocol=https \ > > + git://github.com/opencv/opencv_3rdparty.git;branch=fastcv/4.x_20250212;destsuffix=git/fastcv;name=fastcv;protocol=https \ > > file://0003-To-fix-errors-as-following.patch \ > > file://0001-Temporarliy-work-around-deprecated-ffmpeg-RAW-functi.patch \ > > file://0001-Dont-use-isystem.patch \ > > @@ -37,6 +39,13 @@ SRC_URI:append:riscv64 = " file://0001-Use-Os-to-compile-tinyxml2.cpp.patch;patc > > > > S = "${WORKDIR}/git" > > > > +# Disabling cluster ecludian tests in fastcv EXTN as it causes fastcv EXTN tests to be crashed. > > +# Adding support for fastcv static lib as per Upstream OpenCV. > > +# These are temporary patches, will be removed in next release. > > + > > +SRC_URI += "file://0001-PENDING-Removed-cluster-euclidean-in-fastcv-ext.patch;patchdir=${S}/contrib/ \ > > + file://0001-FROMLIST-Using-fastcv-static-lib-for-compilation.patch" > > + > > # OpenCV wants to download more files during configure. We download these in > > # do_fetch and construct a source cache in the format it expects > > OPENCV_DLDIR = "${WORKDIR}/downloads" > > @@ -61,6 +70,7 @@ do_unpack_extra() { > > cache data ${S}/face/*.dat > > cache wechat_qrcode ${S}/wechat_qrcode/*.caffemodel > > cache wechat_qrcode ${S}/wechat_qrcode/*.prototxt > > + cache fastcv ${S}/fastcv/fastcv/*.tgz > > } > > addtask unpack_extra after do_unpack before do_patch > > > > @@ -71,7 +81,6 @@ EXTRA_OECMAKE = "-DOPENCV_EXTRA_MODULES_PATH=${S}/contrib/modules \ > > -DENABLE_PRECOMPILED_HEADERS=OFF \ > > -DCMAKE_SKIP_RPATH=ON \ > > -DWITH_IPP=OFF \ > > - -DWITH_FASTCV=OFF \ > > -DOPENCV_GENERATE_PKGCONFIG=ON \ > > -DOPENCV_DOWNLOAD_PATH=${OPENCV_DLDIR} \ > > -DOPENCV_ALLOW_DOWNLOADS=OFF \ > > @@ -122,6 +131,7 @@ PACKAGECONFIG[tests] = "-DBUILD_TESTS=ON,-DBUILD_TESTS=OFF,," > > PACKAGECONFIG[text] = "-DBUILD_opencv_text=ON,-DBUILD_opencv_text=OFF,tesseract," > > PACKAGECONFIG[tiff] = "-DWITH_TIFF=ON,-DWITH_TIFF=OFF,tiff," > > PACKAGECONFIG[v4l] = "-DWITH_V4L=ON,-DWITH_V4L=OFF,v4l-utils," > > +PACKAGECONFIG[fastcv] = "-DWITH_FASTCV=ON ,-DWITH_FASTCV=OFF,," > > > > inherit pkgconfig cmake setuptools3-base python3native > > > > -- > > 2.34.1 > > > > > > -=-=-=-=-=-=-=-=-=-=-=- > > Links: You receive all messages sent to this group. > > View/Reply Online (#116206): https://lists.openembedded.org/g/openembedded-devel/message/116206 > > Mute This Topic: https://lists.openembedded.org/mt/111872956/1997914 > > Group Owner: openembedded-devel+owner@lists.openembedded.org > > Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [raj.khem@gmail.com] > > -=-=-=-=-=-=-=-=-=-=-=- > >
diff --git a/meta-oe/recipes-support/opencv/opencv/0001-FROMLIST-Using-fastcv-static-lib-for-compilation.patch b/meta-oe/recipes-support/opencv/opencv/0001-FROMLIST-Using-fastcv-static-lib-for-compilation.patch new file mode 100644 index 0000000000..5fce32f4b8 --- /dev/null +++ b/meta-oe/recipes-support/opencv/opencv/0001-FROMLIST-Using-fastcv-static-lib-for-compilation.patch @@ -0,0 +1,96 @@ +From 0141830e67ac7c60c474ab3c1e7d3e30c27c7943 Mon Sep 17 00:00:00 2001 +From: Pulkit Singh Tak <quic_ptak@quicinc.com> +Date: Mon, 10 Feb 2025 15:10:26 +0530 +Subject: [PATCH] FROMLIST: Using fastcv static lib for compilation + +Signed-off-by: Pulkit Singh Tak <quic_ptak@quicinc.com> +Upstream-Status: SUBMITTED [https://github.com/opencv/opencv/pull/26917] +--- + 3rdparty/fastcv/fastcv.cmake | 9 +++++---- + cmake/OpenCVFindLibsPerf.cmake | 23 ++++++++++++++++------- + 2 files changed, 21 insertions(+), 11 deletions(-) + +diff --git a/3rdparty/fastcv/fastcv.cmake b/3rdparty/fastcv/fastcv.cmake +index b8172705ca..12c6616a16 100644 +--- a/3rdparty/fastcv/fastcv.cmake ++++ b/3rdparty/fastcv/fastcv.cmake +@@ -1,7 +1,7 @@ + function(download_fastcv root_dir) + + # Commit SHA in the opencv_3rdparty repo +- set(FASTCV_COMMIT "dc5d58018f3af915a8d209386d2c58c0501c0f2c") ++ set(FASTCV_COMMIT "f4413cc2ab7233fdfc383a4cded402c072677fb0") + + # Define actual FastCV versions + if(ANDROID) +@@ -16,14 +16,15 @@ function(download_fastcv root_dir) + endif() + elseif(UNIX AND NOT APPLE AND NOT IOS AND NOT XROS) + if(AARCH64) +- set(FCV_PACKAGE_NAME "fastcv_linux_aarch64_2024_12_11.tgz") +- set(FCV_PACKAGE_HASH "7b33ad833e6f15ab6d4ec64fa3c17acd") ++ set(FCV_PACKAGE_NAME "fastcv_linux_aarch64_2025_02_12.tgz") ++ set(FCV_PACKAGE_HASH "33ac2a59cf3e7d6402eee2e010de1202") + else() + message("FastCV: fastcv lib for 32-bit Linux is not supported for now!") + endif() + endif(ANDROID) + + # Download Package ++ + set(OPENCV_FASTCV_URL "https://raw.githubusercontent.com/opencv/opencv_3rdparty/${FASTCV_COMMIT}/fastcv/") + + ocv_download( FILENAME ${FCV_PACKAGE_NAME} +@@ -40,4 +41,4 @@ function(download_fastcv root_dir) + message(WARNING "FastCV: package download failed!") + endif() + +-endfunction() ++endfunction() +\ No newline at end of file +diff --git a/cmake/OpenCVFindLibsPerf.cmake b/cmake/OpenCVFindLibsPerf.cmake +index c2380e6ce5..a31842dfbb 100644 +--- a/cmake/OpenCVFindLibsPerf.cmake ++++ b/cmake/OpenCVFindLibsPerf.cmake +@@ -181,7 +181,14 @@ endif(WITH_KLEIDICV) + if(WITH_FASTCV) + if((EXISTS ${FastCV_INCLUDE_PATH}) AND (EXISTS ${FastCV_LIB_PATH})) + message(STATUS "Use external FastCV ${FastCV_INCLUDE_PATH}, ${FastCV_LIB_PATH}") +- set(HAVE_FASTCV TRUE CACHE BOOL "FastCV status") ++ find_library(FASTCV_LIBRARY NAMES "fastcv" ++ PATHS "${FastCV_LIB_PATH}" NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) ++ mark_as_advanced(FASTCV_LIBRARY) ++ if (FASTCV_LIBRARY) ++ set(HAVE_FASTCV TRUE CACHE BOOL "FastCV status") ++ else() ++ set(HAVE_FASTCV FALSE CACHE BOOL "FastCV status") ++ endif() + else() + include("${OpenCV_SOURCE_DIR}/3rdparty/fastcv/fastcv.cmake") + set(FCV_ROOT_DIR "${OpenCV_BINARY_DIR}/3rdparty/fastcv") +@@ -190,13 +197,15 @@ if(WITH_FASTCV) + set(FastCV_INCLUDE_PATH "${FCV_ROOT_DIR}/inc" CACHE PATH "FastCV includes directory") + set(FastCV_LIB_PATH "${FCV_ROOT_DIR}/libs" CACHE PATH "FastCV library directory") + ocv_install_3rdparty_licenses(FastCV "${OpenCV_BINARY_DIR}/3rdparty/fastcv/LICENSE") +- install(FILES "${FastCV_LIB_PATH}/libfastcvopt.so" +- DESTINATION "${OPENCV_LIB_INSTALL_PATH}" COMPONENT "bin") ++ if(ANDROID) ++ set(FASTCV_LIBRARY "${FastCV_LIB_PATH}/libfastcvopt.so" CACHE PATH "FastCV library") ++ install(FILES "${FASTCV_LIBRARY}" DESTINATION "${OPENCV_LIB_INSTALL_PATH}" COMPONENT "bin") ++ else() ++ set(FASTCV_LIBRARY "${FastCV_LIB_PATH}/libfastcv.a" CACHE PATH "FastCV library") ++ install(FILES "${FASTCV_LIBRARY}" DESTINATION "${OPENCV_LIB_INSTALL_PATH}" COMPONENT "dev") ++ endif() + else() + set(HAVE_FASTCV FALSE CACHE BOOL "FastCV status") + endif() + endif() +- if(HAVE_FASTCV) +- set(FASTCV_LIBRARY "${FastCV_LIB_PATH}/libfastcvopt.so" CACHE PATH "FastCV library") +- endif() +-endif(WITH_FASTCV) ++endif(WITH_FASTCV) +\ No newline at end of file +-- +2.34.1 + diff --git a/meta-oe/recipes-support/opencv/opencv/0001-PENDING-Removed-cluster-euclidean-in-fastcv-ext.patch b/meta-oe/recipes-support/opencv/opencv/0001-PENDING-Removed-cluster-euclidean-in-fastcv-ext.patch new file mode 100644 index 0000000000..cb570c55e4 --- /dev/null +++ b/meta-oe/recipes-support/opencv/opencv/0001-PENDING-Removed-cluster-euclidean-in-fastcv-ext.patch @@ -0,0 +1,371 @@ +From d7db8fb8d715a86d0939797bc08073895c475989 Mon Sep 17 00:00:00 2001 +From: Pulkit Singh Tak <quic_ptak@quicinc.com> +Date: Thu, 13 Feb 2025 17:55:08 +0530 +Subject: [PATCH] PENDING: Removed cluster euclidean in fastcv ext + +Signed-off-by: Pulkit Singh Tak <quic_ptak@quicinc.com> +Upstream-Status: PENDING +--- + modules/fastcv/include/opencv2/fastcv.hpp | 1 - + .../fastcv/include/opencv2/fastcv/cluster.hpp | 43 ------ + .../fastcv/perf/perf_cluster_euclidean.cpp | 79 ----------- + modules/fastcv/src/cluster_euclidean.cpp | 66 ---------- + .../fastcv/test/test_cluster_euclidean.cpp | 124 ------------------ + 5 files changed, 313 deletions(-) + delete mode 100644 modules/fastcv/include/opencv2/fastcv/cluster.hpp + delete mode 100644 modules/fastcv/perf/perf_cluster_euclidean.cpp + delete mode 100644 modules/fastcv/src/cluster_euclidean.cpp + delete mode 100644 modules/fastcv/test/test_cluster_euclidean.cpp + +diff --git a/modules/fastcv/include/opencv2/fastcv.hpp b/modules/fastcv/include/opencv2/fastcv.hpp +index af188dfc..c5deb5e0 100644 +--- a/modules/fastcv/include/opencv2/fastcv.hpp ++++ b/modules/fastcv/include/opencv2/fastcv.hpp +@@ -11,7 +11,6 @@ + #include "opencv2/fastcv/arithm.hpp" + #include "opencv2/fastcv/bilateralFilter.hpp" + #include "opencv2/fastcv/blur.hpp" +-#include "opencv2/fastcv/cluster.hpp" + #include "opencv2/fastcv/draw.hpp" + #include "opencv2/fastcv/edges.hpp" + #include "opencv2/fastcv/fast10.hpp" +diff --git a/modules/fastcv/include/opencv2/fastcv/cluster.hpp b/modules/fastcv/include/opencv2/fastcv/cluster.hpp +deleted file mode 100644 +index 46ac7ad1..00000000 +--- a/modules/fastcv/include/opencv2/fastcv/cluster.hpp ++++ /dev/null +@@ -1,43 +0,0 @@ +-/* +- * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved. +- * SPDX-License-Identifier: Apache-2.0 +-*/ +- +-#ifndef OPENCV_FASTCV_CLUSTER_HPP +-#define OPENCV_FASTCV_CLUSTER_HPP +- +-#include <opencv2/core.hpp> +- +-namespace cv { +-namespace fastcv { +- +-//! @addtogroup fastcv +-//! @{ +- +-/** +- * @brief Clusterizes N input points in D-dimensional space into K clusters +- * Accepts 8-bit unsigned integer points +- * Provides faster execution time than cv::kmeans on Qualcomm's processors +- * @param points Points array of type 8u, each row represets a point. +- * Size is N rows by D columns, can be non-continuous. +- * @param clusterCenters Initial cluster centers array of type 32f, each row represents a center. +- * Size is K rows by D columns, can be non-continuous. +- * @param newClusterCenters Resulting cluster centers array of type 32f, each row represents found center. +- * Size is set to be K rows by D columns. +- * @param clusterSizes Resulting cluster member counts array of type uint32, size is set to be 1 row by K columns. +- * @param clusterBindings Resulting points indices array of type uint32, each index tells to which cluster the corresponding point belongs to. +- * Size is set to be 1 row by numPointsUsed columns. +- * @param clusterSumDists Resulting distance sums array of type 32f, each number is a sum of distances between each cluster center to its belonging points. +- * Size is set to be 1 row by K columns +- * @param numPointsUsed Number of points to clusterize starting from 0 to numPointsUsed-1 inclusively. Sets to N if negative. +- */ +-CV_EXPORTS_W void clusterEuclidean(InputArray points, InputArray clusterCenters, OutputArray newClusterCenters, +- OutputArray clusterSizes, OutputArray clusterBindings, OutputArray clusterSumDists, +- int numPointsUsed = -1); +- +-//! @} +- +-} // fastcv:: +-} // cv:: +- +-#endif // OPENCV_FASTCV_CLUSTER_HPP +diff --git a/modules/fastcv/perf/perf_cluster_euclidean.cpp b/modules/fastcv/perf/perf_cluster_euclidean.cpp +deleted file mode 100644 +index 20bc31a7..00000000 +--- a/modules/fastcv/perf/perf_cluster_euclidean.cpp ++++ /dev/null +@@ -1,79 +0,0 @@ +-/* +- * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved. +- * SPDX-License-Identifier: Apache-2.0 +-*/ +- +-#include "perf_precomp.hpp" +- +-namespace opencv_test { +- +-typedef std::tuple<int /* nPts */, int /*nDims*/, int /*nClusters*/> ClusterEuclideanPerfParams; +-typedef perf::TestBaseWithParam<ClusterEuclideanPerfParams> ClusterEuclideanPerfTest; +- +-PERF_TEST_P(ClusterEuclideanPerfTest, run, +- ::testing::Combine(::testing::Values(100, 1000, 10000), // nPts +- ::testing::Values(2, 10, 32), // nDims +- ::testing::Values(5, 10, 16)) // nClusters +- ) +-{ +- auto p = GetParam(); +- int nPts = std::get<0>(p); +- int nDims = std::get<1>(p); +- int nClusters = std::get<2>(p); +- +- Mat points(nPts, nDims, CV_8U); +- Mat clusterCenters(nClusters, nDims, CV_32F); +- +- Mat trueMeans(nClusters, nDims, CV_32F); +- Mat stddevs(nClusters, nDims, CV_32F); +- std::vector<int> trueClusterSizes(nClusters, 0); +- std::vector<int> trueClusterBindings(nPts, 0); +- std::vector<float> trueSumDists(nClusters, 0); +- +- cv::RNG& rng = cv::theRNG(); +- for (int i = 0; i < nClusters; i++) +- { +- Mat mean(1, nDims, CV_64F), stdev(1, nDims, CV_64F); +- rng.fill(mean, cv::RNG::UNIFORM, 0, 256); +- rng.fill(stdev, cv::RNG::UNIFORM, 5.f, 16); +- int lo = i * nPts / nClusters; +- int hi = (i + 1) * nPts / nClusters; +- +- for (int d = 0; d < nDims; d++) +- { +- rng.fill(points.col(d).rowRange(lo, hi), cv::RNG::NORMAL, +- mean.at<double>(d), stdev.at<double>(d)); +- } +- +- float sd = 0; +- for (int j = lo; j < hi; j++) +- { +- Mat pts64f; +- points.row(j).convertTo(pts64f, CV_64F); +- sd += cv::norm(mean, pts64f, NORM_L2); +- trueClusterBindings.at(j) = i; +- trueClusterSizes.at(i)++; +- } +- trueSumDists.at(i) = sd; +- +- // let's shift initial cluster center a bit +- Mat(mean + stdev * 0.5).copyTo(clusterCenters.row(i)); +- +- mean.copyTo(trueMeans.row(i)); +- stdev.copyTo(stddevs.row(i)); +- } +- +- while(next()) +- { +- Mat newClusterCenters; +- std::vector<int> clusterSizes, clusterBindings; +- std::vector<float> clusterSumDists; +- startTimer(); +- cv::fastcv::clusterEuclidean(points, clusterCenters, newClusterCenters, clusterSizes, clusterBindings, clusterSumDists); +- stopTimer(); +- } +- +- SANITY_CHECK_NOTHING(); +-} +- +-} // namespace +diff --git a/modules/fastcv/src/cluster_euclidean.cpp b/modules/fastcv/src/cluster_euclidean.cpp +deleted file mode 100644 +index a50b027c..00000000 +--- a/modules/fastcv/src/cluster_euclidean.cpp ++++ /dev/null +@@ -1,66 +0,0 @@ +-/* +- * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved. +- * SPDX-License-Identifier: Apache-2.0 +-*/ +- +-#include "precomp.hpp" +- +-namespace cv { +-namespace fastcv { +- +-void clusterEuclidean(InputArray _points, InputArray _clusterCenters, OutputArray _newClusterCenters, +- OutputArray _clusterSizes, OutputArray _clusterBindings, OutputArray _clusterSumDists, +- int numPointsUsed) +-{ +- INITIALIZATION_CHECK; +- +- CV_Assert(!_points.empty() && _points.type() == CV_8UC1); +- int nPts = _points.rows(); +- int nDims = _points.cols(); +- int ptsStride = _points.step(); +- +- CV_Assert(!_clusterCenters.empty() && _clusterCenters.depth() == CV_32F); +- int nClusters = _clusterCenters.rows(); +- int clusterCenterStride = _clusterCenters.step(); +- +- CV_Assert(_clusterCenters.cols() == nDims); +- +- CV_Assert(numPointsUsed <= nPts); +- if (numPointsUsed < 0) +- { +- numPointsUsed = nPts; +- } +- +- _newClusterCenters.create(nClusters, nDims, CV_32FC1); +- _clusterSizes.create(1, nClusters, CV_32SC1); +- _clusterBindings.create(1, numPointsUsed, CV_32SC1); +- _clusterSumDists.create(1, nClusters, CV_32FC1); +- +- Mat points = _points.getMat(); +- Mat clusterCenters = _clusterCenters.getMat(); +- Mat newClusterCenters = _newClusterCenters.getMat(); +- Mat clusterSizes = _clusterSizes.getMat(); +- Mat clusterBindings = _clusterBindings.getMat(); +- Mat clusterSumDists = _clusterSumDists.getMat(); +- +- int result = fcvClusterEuclideanu8(points.data, +- nPts, +- nDims, +- ptsStride, +- numPointsUsed, +- nClusters, +- (float32_t*)clusterCenters.data, +- clusterCenterStride, +- (float32_t*)newClusterCenters.data, +- (uint32_t*)clusterSizes.data, +- (uint32_t*)clusterBindings.data, +- (float32_t*)clusterSumDists.data); +- +- if (result) +- { +- CV_Error(cv::Error::StsInternal, cv::format("Failed to clusterize, error code: %d", result)); +- } +-} +- +-} // fastcv:: +-} // cv:: +diff --git a/modules/fastcv/test/test_cluster_euclidean.cpp b/modules/fastcv/test/test_cluster_euclidean.cpp +deleted file mode 100644 +index c108f754..00000000 +--- a/modules/fastcv/test/test_cluster_euclidean.cpp ++++ /dev/null +@@ -1,124 +0,0 @@ +-/* +- * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved. +- * SPDX-License-Identifier: Apache-2.0 +-*/ +- +-#include "test_precomp.hpp" +- +-namespace opencv_test { namespace { +- +-// nPts, nDims, nClusters +-typedef std::tuple<int, int, int> ClusterEuclideanTestParams; +-class ClusterEuclideanTest : public ::testing::TestWithParam<ClusterEuclideanTestParams> {}; +- +-TEST_P(ClusterEuclideanTest, accuracy) +-{ +- auto p = GetParam(); +- int nPts = std::get<0>(p); +- int nDims = std::get<1>(p); +- int nClusters = std::get<2>(p); +- +- Mat points(nPts, nDims, CV_8U); +- Mat clusterCenters(nClusters, nDims, CV_32F); +- +- Mat trueMeans(nClusters, nDims, CV_32F); +- Mat stddevs(nClusters, nDims, CV_32F); +- std::vector<int> trueClusterSizes(nClusters, 0); +- std::vector<int> trueClusterBindings(nPts, 0); +- std::vector<float> trueSumDists(nClusters, 0); +- +- cv::RNG& rng = cv::theRNG(); +- for (int i = 0; i < nClusters; i++) +- { +- Mat mean(1, nDims, CV_64F), stdev(1, nDims, CV_64F); +- rng.fill(mean, cv::RNG::UNIFORM, 0, 256); +- rng.fill(stdev, cv::RNG::UNIFORM, 5.f, 16); +- int lo = i * nPts / nClusters; +- int hi = (i + 1) * nPts / nClusters; +- +- for (int d = 0; d < nDims; d++) +- { +- rng.fill(points.col(d).rowRange(lo, hi), cv::RNG::NORMAL, +- mean.at<double>(d), stdev.at<double>(d)); +- } +- +- float sd = 0; +- for (int j = lo; j < hi; j++) +- { +- Mat pts64f; +- points.row(j).convertTo(pts64f, CV_64F); +- sd += cv::norm(mean, pts64f, NORM_L2); +- trueClusterBindings.at(j) = i; +- trueClusterSizes.at(i)++; +- } +- trueSumDists.at(i) = sd; +- +- // let's shift initial cluster center a bit +- Mat(mean + stdev * 0.5).copyTo(clusterCenters.row(i)); +- +- mean.copyTo(trueMeans.row(i)); +- stdev.copyTo(stddevs.row(i)); +- } +- +- Mat newClusterCenters; +- std::vector<int> clusterSizes, clusterBindings; +- std::vector<float> clusterSumDists; +- cv::fastcv::clusterEuclidean(points, clusterCenters, newClusterCenters, clusterSizes, clusterBindings, clusterSumDists); +- +- if (cvtest::debugLevel > 0 && nDims == 2) +- { +- Mat draw(256, 256, CV_8UC3, Scalar(0)); +- for (int i = 0; i < nPts; i++) +- { +- int x = std::rint(points.at<uchar>(i, 0)); +- int y = std::rint(points.at<uchar>(i, 1)); +- draw.at<Vec3b>(y, x) = Vec3b::all(128); +- } +- for (int i = 0; i < nClusters; i++) +- { +- float cx = trueMeans.at<double>(i, 0); +- float cy = trueMeans.at<double>(i, 1); +- draw.at<Vec3b>(cy, cx) = Vec3b(0, 255, 0); +- +- float sx = stddevs.at<double>(i, 0); +- float sy = stddevs.at<double>(i, 1); +- cv::ellipse(draw, Point(cx, cy), Size(sx, sy), 0, 0, 360, Scalar(255, 0, 0)); +- +- float ox = clusterCenters.at<float>(i, 0); +- float oy = clusterCenters.at<float>(i, 1); +- draw.at<Vec3b>(oy, ox) = Vec3b(0, 0, 255); +- +- float nx = newClusterCenters.at<float>(i, 0); +- float ny = newClusterCenters.at<float>(i, 1); +- draw.at<Vec3b>(ny, nx) = Vec3b(255, 255, 0); +- } +- cv::imwrite(cv::format("draw_%d_%d_%d.png", nPts, nDims, nClusters), draw); +- } +- +- { +- std::vector<double> diffs; +- for (int i = 0; i < nClusters; i++) +- { +- double cs = std::abs((trueClusterSizes[i] - clusterSizes[i]) / double(trueClusterSizes[i])); +- diffs.push_back(cs); +- } +- double normL2 = cv::norm(diffs, NORM_L2) / nClusters; +- +- EXPECT_LT(normL2, 0.392); +- } +- +- { +- Mat bindings8u, trueBindings8u; +- Mat(clusterBindings).convertTo(bindings8u, CV_8U); +- Mat(trueClusterBindings).convertTo(trueBindings8u, CV_8U); +- double normH = cv::norm(bindings8u, trueBindings8u, NORM_HAMMING) / nPts; +- EXPECT_LT(normH, 0.658); +- } +-} +- +-INSTANTIATE_TEST_CASE_P(FastCV_Extension, ClusterEuclideanTest, +- ::testing::Combine(::testing::Values(100, 1000, 10000), // nPts +- ::testing::Values(2, 10, 32), // nDims +- ::testing::Values(5, 10, 16))); // nClusters +- +-}} // namespaces opencv_test, :: +\ No newline at end of file +-- +2.34.1 + diff --git a/meta-oe/recipes-support/opencv/opencv_4.11.0.bb b/meta-oe/recipes-support/opencv/opencv_4.11.0.bb index 1613b6a3ed..1b0285e05b 100644 --- a/meta-oe/recipes-support/opencv/opencv_4.11.0.bb +++ b/meta-oe/recipes-support/opencv/opencv_4.11.0.bb @@ -16,15 +16,17 @@ SRCREV_boostdesc = "34e4206aef44d50e6bbcd0ab06354b52e7466d26" SRCREV_vgg = "fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d" SRCREV_face = "8afa57abc8229d611c4937165d20e2a2d9fc5a12" SRCREV_wechat-qrcode = "a8b69ccc738421293254aec5ddb38bd523503252" +SRCREV_fastcv = "f4413cc2ab7233fdfc383a4cded402c072677fb0" -SRCREV_FORMAT = "opencv_contrib_ipp_boostdesc_vgg" +SRCREV_FORMAT = "opencv_contrib_ipp_boostdesc_vgg_fastcv" SRC_URI = "git://github.com/opencv/opencv.git;name=opencv;branch=4.x;protocol=https \ git://github.com/opencv/opencv_contrib.git;destsuffix=git/contrib;name=contrib;branch=4.x;protocol=https \ git://github.com/opencv/opencv_3rdparty.git;branch=contrib_xfeatures2d_boostdesc_20161012;destsuffix=git/boostdesc;name=boostdesc;protocol=https \ git://github.com/opencv/opencv_3rdparty.git;branch=contrib_xfeatures2d_vgg_20160317;destsuffix=git/vgg;name=vgg;protocol=https \ git://github.com/opencv/opencv_3rdparty.git;branch=contrib_face_alignment_20170818;destsuffix=git/face;name=face;protocol=https \ git://github.com/WeChatCV/opencv_3rdparty.git;branch=wechat_qrcode;destsuffix=git/wechat_qrcode;name=wechat-qrcode;protocol=https \ + git://github.com/opencv/opencv_3rdparty.git;branch=fastcv/4.x_20250212;destsuffix=git/fastcv;name=fastcv;protocol=https \ file://0003-To-fix-errors-as-following.patch \ file://0001-Temporarliy-work-around-deprecated-ffmpeg-RAW-functi.patch \ file://0001-Dont-use-isystem.patch \ @@ -37,6 +39,13 @@ SRC_URI:append:riscv64 = " file://0001-Use-Os-to-compile-tinyxml2.cpp.patch;patc S = "${WORKDIR}/git" +# Disabling cluster ecludian tests in fastcv EXTN as it causes fastcv EXTN tests to be crashed. +# Adding support for fastcv static lib as per Upstream OpenCV. +# These are temporary patches, will be removed in next release. + +SRC_URI += "file://0001-PENDING-Removed-cluster-euclidean-in-fastcv-ext.patch;patchdir=${S}/contrib/ \ + file://0001-FROMLIST-Using-fastcv-static-lib-for-compilation.patch" + # OpenCV wants to download more files during configure. We download these in # do_fetch and construct a source cache in the format it expects OPENCV_DLDIR = "${WORKDIR}/downloads" @@ -61,6 +70,7 @@ do_unpack_extra() { cache data ${S}/face/*.dat cache wechat_qrcode ${S}/wechat_qrcode/*.caffemodel cache wechat_qrcode ${S}/wechat_qrcode/*.prototxt + cache fastcv ${S}/fastcv/fastcv/*.tgz } addtask unpack_extra after do_unpack before do_patch @@ -71,7 +81,6 @@ EXTRA_OECMAKE = "-DOPENCV_EXTRA_MODULES_PATH=${S}/contrib/modules \ -DENABLE_PRECOMPILED_HEADERS=OFF \ -DCMAKE_SKIP_RPATH=ON \ -DWITH_IPP=OFF \ - -DWITH_FASTCV=OFF \ -DOPENCV_GENERATE_PKGCONFIG=ON \ -DOPENCV_DOWNLOAD_PATH=${OPENCV_DLDIR} \ -DOPENCV_ALLOW_DOWNLOADS=OFF \ @@ -122,6 +131,7 @@ PACKAGECONFIG[tests] = "-DBUILD_TESTS=ON,-DBUILD_TESTS=OFF,," PACKAGECONFIG[text] = "-DBUILD_opencv_text=ON,-DBUILD_opencv_text=OFF,tesseract," PACKAGECONFIG[tiff] = "-DWITH_TIFF=ON,-DWITH_TIFF=OFF,tiff," PACKAGECONFIG[v4l] = "-DWITH_V4L=ON,-DWITH_V4L=OFF,v4l-utils," +PACKAGECONFIG[fastcv] = "-DWITH_FASTCV=ON ,-DWITH_FASTCV=OFF,," inherit pkgconfig cmake setuptools3-base python3native
Adding patches to support fastcv static lib compilation and removal of cluster ecludian tests support These are temporary patches to be removeed in next release. Signed-off-by: Pulkit Singh Tak <quic_ptak@quicinc.com> --- ...ng-fastcv-static-lib-for-compilation.patch | 96 +++++ ...oved-cluster-euclidean-in-fastcv-ext.patch | 371 ++++++++++++++++++ .../recipes-support/opencv/opencv_4.11.0.bb | 14 +- 3 files changed, 479 insertions(+), 2 deletions(-) create mode 100644 meta-oe/recipes-support/opencv/opencv/0001-FROMLIST-Using-fastcv-static-lib-for-compilation.patch create mode 100644 meta-oe/recipes-support/opencv/opencv/0001-PENDING-Removed-cluster-euclidean-in-fastcv-ext.patch