From 5bfb0d052e8f55cf4b8e371737827c4c284ec161 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20M=2E=20Basto?= Date: Sat, 20 Jan 2024 23:46:19 +0000 Subject: [PATCH] Update opencv to 4.9.0 Enable ffmpeg and xine (now they are available on Fedora) Really drop compat symlink for includes - rhbz#1830266 Note: conditional builds with underscrore don't have _without option https://github.com/rpm-software-management/rpm/issues/1929 --- .gitignore | 1 + numpy.distutils_removal.patch | 11 -- opencv-4.8.1-protobuf-v22.patch | 204 -------------------------------- opencv-clean.sh | 2 +- opencv.spec | 40 ++++--- sources | 6 +- 6 files changed, 28 insertions(+), 236 deletions(-) delete mode 100644 numpy.distutils_removal.patch delete mode 100644 opencv-4.8.1-protobuf-v22.patch diff --git a/.gitignore b/.gitignore index 0d40f7e..248de94 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ face_landmark_model.dat.xz /b624b995ec9c439cbc2e9e6ee940d3a2-v0.1.1f.zip /fa4b3e25167319cb0fa9432ef8281945-v0.1.2a.zip /wechat-20230712.git3487ef7.tar.gz +/dbb095a8bf3008e91edbbf45d8d34885-v0.1.2d.zip diff --git a/numpy.distutils_removal.patch b/numpy.distutils_removal.patch deleted file mode 100644 index 400651d..0000000 --- a/numpy.distutils_removal.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- ./cmake/OpenCVDetectPython.cmake.orig 2023-09-30 01:44:54.597603701 +0100 -+++ ./cmake/OpenCVDetectPython.cmake 2023-09-30 01:53:48.924119387 +0100 -@@ -216,7 +216,7 @@ if(NOT ${found}) - message(STATUS " PYTHON3_NUMPY_INCLUDE_DIRS") - else() - # Attempt to discover the NumPy include directory. If this succeeds, then build python API with NumPy -- execute_process(COMMAND "${_executable}" -c "import os; os.environ['DISTUTILS_USE_SDK']='1'; import numpy.distutils; print(os.pathsep.join(numpy.distutils.misc_util.get_numpy_include_dirs()))" -+ execute_process(COMMAND "${_executable}" -c "import numpy; print(numpy.get_include())" - RESULT_VARIABLE _numpy_process - OUTPUT_VARIABLE _numpy_include_dirs - OUTPUT_STRIP_TRAILING_WHITESPACE) diff --git a/opencv-4.8.1-protobuf-v22.patch b/opencv-4.8.1-protobuf-v22.patch deleted file mode 100644 index 1873ada..0000000 --- a/opencv-4.8.1-protobuf-v22.patch +++ /dev/null @@ -1,204 +0,0 @@ -From c205e36bf9d74d35021c68afe3c692f0d3678f77 Mon Sep 17 00:00:00 2001 -From: Kumataro -Date: Thu, 19 Oct 2023 14:45:08 +0900 -Subject: [PATCH] Merge pull request #24372 from Kumataro:fix24369 - -Supporting protobuf v22 and later(with abseil-cpp/C++17) #24372 - -fix https://github.com/opencv/opencv/issues/24369 -related https://github.com/opencv/opencv/issues/23791 - -1. This patch supports external protobuf v22 and later, it required abseil-cpp and c++17. - Even if the built-in protobuf is upgraded to v22 or later, - the dependency on abseil-cpp and the requirement for C++17 will continue. -2. Some test for caffe required patched protobuf, so this patch disable them. - -This patch is tested by following libraries. -- Protobuf: /usr/local/lib/libprotobuf.so (4.24.4) -- abseil-cpp: YES (20230125) - -See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - -- [x] I agree to contribute to the project under Apache 2 License. -- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV -- [x] The PR is proposed to the proper branch -- [x] There is a reference to the original bug report and related work -- [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable - Patch to opencv_extra has the same branch name. -- [x] The feature is well documented and sample code can be built with the project CMake ---- - cmake/OpenCVFindProtobuf.cmake | 35 +++++++++++++++++++++++++++----- - modules/dnn/CMakeLists.txt | 6 ++++++ - modules/dnn/test/test_layers.cpp | 24 ++++++++++++++++++---- - 3 files changed, 56 insertions(+), 9 deletions(-) - -diff --git a/cmake/OpenCVFindProtobuf.cmake b/cmake/OpenCVFindProtobuf.cmake -index 8835347d1d..5b1e17529f 100644 ---- a/cmake/OpenCVFindProtobuf.cmake -+++ b/cmake/OpenCVFindProtobuf.cmake -@@ -30,8 +30,14 @@ if(BUILD_PROTOBUF) - set(Protobuf_LIBRARIES "libprotobuf") - set(HAVE_PROTOBUF TRUE) - else() -+ # we still need this for command PROTOBUF_GENERATE_CPP. -+ set(protobuf_MODULE_COMPATIBLE ON) -+ - unset(Protobuf_VERSION CACHE) -- find_package(Protobuf QUIET) -+ find_package(Protobuf QUIET CONFIG) -+ if(NOT Protobuf_FOUND) -+ find_package(Protobuf QUIET) -+ endif() - - # Backwards compatibility - # Define camel case versions of input variables -@@ -67,6 +73,20 @@ else() - endif() - endif() - -+# See https://github.com/opencv/opencv/issues/24369 -+# In Protocol Buffers v22.0 and later drops C++11 support and depends abseil-cpp. -+# Details: https://protobuf.dev/news/2022-08-03/ -+# And if std::text_view is in abseil-cpp requests C++17 and later. -+ -+if(HAVE_PROTOBUF) -+ if(NOT (Protobuf_VERSION VERSION_LESS 22)) -+ if((CMAKE_CXX_STANDARD EQUAL 98) OR (CMAKE_CXX_STANDARD LESS 17)) -+ message(STATUS "CMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} is too old to support protobuf(${Protobuf_VERSION}) and/or abseil-cpp. Use C++17 or later. Turning HAVE_PROTOBUF off") -+ set(HAVE_PROTOBUF FALSE) -+ endif() -+ endif() -+endif() -+ - if(HAVE_PROTOBUF AND PROTOBUF_UPDATE_FILES AND NOT COMMAND PROTOBUF_GENERATE_CPP) - message(FATAL_ERROR "Can't configure protobuf dependency (BUILD_PROTOBUF=${BUILD_PROTOBUF} PROTOBUF_UPDATE_FILES=${PROTOBUF_UPDATE_FILES})") - endif() -@@ -74,15 +94,20 @@ endif() - if(HAVE_PROTOBUF) - list(APPEND CUSTOM_STATUS protobuf) - if(NOT BUILD_PROTOBUF) -+ unset( __location) - if(TARGET "${Protobuf_LIBRARIES}") - get_target_property(__location "${Protobuf_LIBRARIES}" IMPORTED_LOCATION_RELEASE) - if(NOT __location) - get_target_property(__location "${Protobuf_LIBRARIES}" IMPORTED_LOCATION) - endif() -- elseif(Protobuf_LIBRARY) -- set(__location "${Protobuf_LIBRARY}") -- else() -- set(__location "${Protobuf_LIBRARIES}") -+ endif() -+ -+ if(NOT __location) -+ if(Protobuf_LIBRARY) -+ set(__location "${Protobuf_LIBRARY}") -+ else() -+ set(__location "${Protobuf_LIBRARIES}") -+ endif() - endif() - endif() - list(APPEND CUSTOM_STATUS_protobuf " Protobuf:" -diff --git a/modules/dnn/CMakeLists.txt b/modules/dnn/CMakeLists.txt -index 804b78ead2..9fcc460909 100644 ---- a/modules/dnn/CMakeLists.txt -+++ b/modules/dnn/CMakeLists.txt -@@ -245,6 +245,12 @@ ocv_create_module(${libs} ${dnn_runtime_libs}) - ocv_add_samples() - ocv_add_accuracy_tests(${dnn_runtime_libs}) - -+if(NOT BUILD_PROTOBUF) -+ if(TARGET opencv_test_dnn) -+ ocv_target_compile_definitions(opencv_test_dnn PRIVATE "OPENCV_DNN_EXTERNAL_PROTOBUF=1") -+ endif() -+endif() -+ - set(perf_path "${CMAKE_CURRENT_LIST_DIR}/perf") - file(GLOB_RECURSE perf_srcs "${perf_path}/*.cpp") - file(GLOB_RECURSE perf_hdrs "${perf_path}/*.hpp" "${perf_path}/*.h") -diff --git a/modules/dnn/test/test_layers.cpp b/modules/dnn/test/test_layers.cpp -index 763d94b99c..6cb6d54b3f 100644 ---- a/modules/dnn/test/test_layers.cpp -+++ b/modules/dnn/test/test_layers.cpp -@@ -756,11 +756,15 @@ TEST_F(Layer_RNN_Test, get_set_test) - - TEST_P(Test_Caffe_layers, Accum) - { -+#ifdef OPENCV_DNN_EXTERNAL_PROTOBUF -+ throw SkipTestException("Requires patched protobuf"); -+#else - if (backend == DNN_BACKEND_OPENCV && target != DNN_TARGET_CPU) - applyTestTag(CV_TEST_TAG_DNN_SKIP_OPENCL, CV_TEST_TAG_DNN_SKIP_OPENCL_FP16); - - testLayerUsingCaffeModels("accum", false, false, 0.0, 0.0, 2); - testLayerUsingCaffeModels("accum_ref", false, false, 0.0, 0.0, 2); -+#endif - } - - TEST_P(Test_Caffe_layers, FlowWarp) -@@ -780,27 +784,39 @@ TEST_P(Test_Caffe_layers, ChannelNorm) - - TEST_P(Test_Caffe_layers, DataAugmentation) - { -+#ifdef OPENCV_DNN_EXTERNAL_PROTOBUF -+ throw SkipTestException("Requires patched protobuf"); -+#else - if (backend == DNN_BACKEND_OPENCV && target == DNN_TARGET_OPENCL_FP16) - applyTestTag(CV_TEST_TAG_DNN_SKIP_OPENCL_FP16); - testLayerUsingCaffeModels("data_augmentation", true, false); - testLayerUsingCaffeModels("data_augmentation_2x1", true, false); - testLayerUsingCaffeModels("data_augmentation_8x6", true, false); -+#endif - } - - TEST_P(Test_Caffe_layers, Resample) - { -+#ifdef OPENCV_DNN_EXTERNAL_PROTOBUF -+ throw SkipTestException("Requires patched protobuf"); -+#else - if (backend != DNN_BACKEND_OPENCV) - applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH); - testLayerUsingCaffeModels("nearest_2inps", false, false, 0.0, 0.0, 2); - testLayerUsingCaffeModels("nearest", false, false); -+#endif - } - - TEST_P(Test_Caffe_layers, Correlation) - { -+#ifdef OPENCV_DNN_EXTERNAL_PROTOBUF -+ throw SkipTestException("Requires patched protobuf"); -+#else - if (backend == DNN_BACKEND_OPENCV && target == DNN_TARGET_OPENCL_FP16) - applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER, - CV_TEST_TAG_DNN_SKIP_OPENCL, CV_TEST_TAG_DNN_SKIP_OPENCL_FP16); - testLayerUsingCaffeModels("correlation", false, false, 0.0, 0.0, 2); -+#endif - } - - TEST_P(Test_Caffe_layers, Convolution2Inputs) -@@ -1641,12 +1657,11 @@ private: - int outWidth, outHeight, zoomFactor; - }; - --#ifndef OPENCV_DNN_EXTERNAL_PROTOBUF - TEST_P(Test_Caffe_layers, Interp) --#else --TEST_P(Test_Caffe_layers, DISABLED_Interp) // requires patched protobuf (available in OpenCV source tree only) --#endif - { -+#ifdef OPENCV_DNN_EXTERNAL_PROTOBUF -+ throw SkipTestException("Requires patched protobuf"); -+#else - #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2021030000) - if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_MYRIAD) - applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH); // exception -@@ -1670,6 +1685,7 @@ TEST_P(Test_Caffe_layers, DISABLED_Interp) // requires patched protobuf (availa - - // Test an implemented layer. - testLayerUsingCaffeModels("layer_interp", false, false); -+#endif - } - - INSTANTIATE_TEST_CASE_P(/*nothing*/, Test_Caffe_layers, dnnBackendsAndTargets()); --- -2.43.0 - diff --git a/opencv-clean.sh b/opencv-clean.sh index e161ddf..df36b0c 100755 --- a/opencv-clean.sh +++ b/opencv-clean.sh @@ -1,6 +1,6 @@ #!/bin/bash -VERSION=4.8.1 +VERSION=4.9.0 wget -c https://github.com/opencv/opencv/archive/${VERSION}/opencv-${VERSION}.tar.gz wget -c https://github.com/opencv/opencv_contrib/archive/${VERSION}/opencv_contrib-${VERSION}.tar.gz diff --git a/opencv.spec b/opencv.spec index 64c8325..cc1fea3 100644 --- a/opencv.spec +++ b/opencv.spec @@ -1,6 +1,7 @@ %undefine __cmake_in_source_build %bcond_with tests +%bcond_with compat_openvc_pc %if %{without tests} %bcond_with extras_tests %else @@ -8,7 +9,7 @@ %endif # linters are enabled by default if BUILD_DOCS OR BUILD_EXAMPLES %bcond_with linters -%bcond_with ffmpeg +%bcond_without ffmpeg %bcond_without gstreamer %bcond_with eigen2 %bcond_without eigen3 @@ -21,7 +22,7 @@ %endif %bcond_without tbb %bcond_with cuda -%bcond_with xine +%bcond_without xine # Atlas need (missing: Atlas_CLAPACK_INCLUDE_DIR Atlas_CBLAS_LIBRARY Atlas_BLAS_LIBRARY Atlas_LAPACK_LIBRARY) # LAPACK may use atlas or openblas since now it detect openblas, atlas is not used anyway, more info please # check OpenCVFindLAPACK.cmake @@ -64,13 +65,13 @@ %endif Name: opencv -Version: 4.8.1 +Version: 4.9.0 %global javaver %(foo=%{version}; echo ${foo//./}) %global majorver %(foo=%{version}; a=(${foo//./ }); echo ${a[0]} ) %global minorver %(foo=%{version}; a=(${foo//./ }); echo ${a[1]} ) %global padding %(digits=00; num=%{minorver}; echo ${digits:${#num}:${#digits}} ) %global abiver %(echo %{majorver}%{padding}%{minorver} ) -Release: 8%{?dist} +Release: 1%{?dist} Summary: Collection of algorithms for computer vision # This is normal three clause BSD. License: BSD-3-Clause and Apache-2.0 and ISC @@ -87,9 +88,8 @@ Source1: %{name}_contrib-clean-%{version}.tar.gz Source2: %{name}_extra-clean-%{version}.tar.gz } Source3: face_landmark_model.dat.xz -# from https://github.com/opencv/ade/archive/v0.1.2a.zip -# mv v0.1.2a.zip $(md5sum v0.1.2a.zip | cut -d' ' -f1)-v0.1.2a.zip -Source4: fa4b3e25167319cb0fa9432ef8281945-v0.1.2a.zip +# SRC=v0.1.2d.zip ; wget https://github.com/opencv/ade/archive/$SRC; mv $SRC $(md5sum $SRC | cut -d' ' -f1)-$SRC +Source4: dbb095a8bf3008e91edbbf45d8d34885-v0.1.2d.zip Source5: xorg.conf %global wechat_commit 3487ef7cde71d93c6a01bb0b84aa0f22c6128f6b %global wechat_shortcommit %(c=%{wechat_commit}; echo ${c:0:7}) @@ -97,12 +97,7 @@ Source5: xorg.conf Source6: https://github.com/WeChatCV/opencv_3rdparty/archive/%{wechat_commit}/wechat-%{wechat_gitdate}.git%{wechat_shortcommit}.tar.gz Patch0: opencv-4.1.0-install_3rdparty_licenses.patch -# Backport support for protobuf v22 and later from opencv 4.9.0 -# https://github.com/opencv/opencv/commit/6e4280ea81b59c6dca45bb9801b758377beead55 -# Rebased on 4.8.1 -Patch1: opencv-4.8.1-protobuf-v22.patch Patch3: opencv.python.patch -Patch4: numpy.distutils_removal.patch BuildRequires: gcc-c++ BuildRequires: cmake >= 2.6.3 @@ -148,7 +143,13 @@ BuildRequires: pylint BuildRequires: python3-flake8 } BuildRequires: swig >= 1.3.24 -%{?with_ffmpeg:BuildRequires: ffmpeg-devel >= 0.4.9} +%{?with_ffmpeg: +BuildRequires: pkgconfig(libavcodec) +BuildRequires: pkgconfig(libavformat) +BuildRequires: pkgconfig(libavutil) +BuildRequires: pkgconfig(libswscale) +BuildRequires: pkgconfig(libavdevice) +} %if 0%{?fedora} || 0%{?rhel} > 7 %{?with_gstreamer:BuildRequires: gstreamer1-devel gstreamer1-plugins-base-devel} %else @@ -390,9 +391,7 @@ shopt -u extglob popd &>/dev/null %patch -P 0 -p1 -b .install_3rdparty_licenses -%patch -P 1 -p1 -b .protobuf-v22 %patch -P 3 -p1 -b .python_install_binary -%patch -P 4 -p1 -b .numpy.distutils_removal pushd %{name}_contrib-%{version} #patch1 -p1 -b .install_cvv @@ -502,7 +501,7 @@ ln -s -r %{buildroot}%{_jnidir}/opencv-%{javaver}.jar %{buildroot}%{_jnidir}/ope %endif # For compatibility with existing opencv.pc application -%{!?without_compat_openvc_pc: +%{?with_compat_openvc_pc: ln -s opencv4.pc %{buildroot}%{_libdir}/pkgconfig/opencv.pc } @@ -545,7 +544,7 @@ ln -s -r %{buildroot}%{_jnidir}/opencv-%{javaver}.jar %{buildroot}%{_jnidir}/ope %dir %{_includedir}/opencv4 %{_includedir}/opencv4/opencv2 %{_libdir}/lib*.so -%{!?without_compat_openvc_pc: +%{?with_compat_openvc_pc: %{_libdir}/pkgconfig/opencv.pc } %{_libdir}/pkgconfig/opencv4.pc @@ -568,6 +567,13 @@ ln -s -r %{buildroot}%{_jnidir}/opencv-%{javaver}.jar %{buildroot}%{_jnidir}/ope %changelog +* Sun Jan 28 2024 Sérgio Basto - 4.9.0-1 +- Update opencv to 4.9.0 (#2256160) +- Enable ffmpeg and xine (now they are available on Fedora) +- Really drop compat symlink for includes - rhbz#1830266 + Note: conditional builds with underscrore don't have _without option + https://github.com/rpm-software-management/rpm/issues/1929 + * Sun Jan 28 2024 Sandro Mani - 4.8.1-8 - Rebuild (tesseract) diff --git a/sources b/sources index c2c7616..3cdcd78 100644 --- a/sources +++ b/sources @@ -1,5 +1,5 @@ -SHA512 (opencv-clean-4.8.1.tar.gz) = d148e05cbe29a6e7b0eec8258b6f0260193ace0fec87c6b61225a36f3432a29d9c86b77018e51b547996db3227b561968e54856063ce7f2e9c47bc72aba7f0fb -SHA512 (opencv_contrib-clean-4.8.1.tar.gz) = cc5badd41b7c23e316d4984accc6373b608df591896827f9289dc511b163618036906c91f872cfa4de1fd3cc53838a6dfd5102e7c1856aa1f67b2c18323677f6 +SHA512 (opencv-clean-4.9.0.tar.gz) = 534d9c8bf9759008fd409f6c2c298d33aaf56a080229dccfaec98a789e4c309fc7872d85289f5c0a685f044f6c477f7c890a6788c35bc2f0aa795ec4f33b0ef6 +SHA512 (opencv_contrib-clean-4.9.0.tar.gz) = 595cb9bb5f1a57be883d7ccf448221bfad2c055a930a12f9658489d4a850be5b3f9e3ecd3949f45a183ccc4b8a62620af5d148039b4139c07d408fc3c789f076 SHA512 (face_landmark_model.dat.xz) = 7558f29431bb9cad1f22ee067ad3ed41be8f68b865992eb7d3a5ce6b6b9e1d031cb03e33c3c149220ef8faebd0471703a8a3bbb06402bcc8ce76bd28317aa307 -SHA512 (fa4b3e25167319cb0fa9432ef8281945-v0.1.2a.zip) = ce5af0bd5d7fb04022f92fed130898959aecb954cc09da2fc923c76b37ee92d2233888592a4c6bca8006ac4d3fda9c6da80f316c924a407a7a5961d9832a681c +SHA512 (dbb095a8bf3008e91edbbf45d8d34885-v0.1.2d.zip) = f6f87be8932c0c0ca40bec20b750ab3df27dac44f4507211c29c60f42160e3f2f2133b52c18245eff5241f216a3f5526d299937470b69b125e8eca369c8f6939 SHA512 (wechat-20230712.git3487ef7.tar.gz) = bc4f220465de41df8af0cb35312c1db155976d05f13a60e43c1798b161d8f56388e34a59108fb3e27e8c97b53acfd198256d9ae420b5f70a32ddc1ea65c3c8a6