Update opencv to 4.8.0

Use bundle flatbuffers, tried build with flatbuffers from system but doesn't build
Use oneVPL instead libmfx
This commit is contained in:
Sérgio M. Basto 2023-08-07 00:03:55 +01:00
parent 464361d6d8
commit 193d86a5be
4 changed files with 23 additions and 98 deletions

View File

@ -1,72 +0,0 @@
From 82616eec41f6a6989a3b507822c17fc81a10e296 Mon Sep 17 00:00:00 2001
From: zihaomu <zihaomu@outlook.com>
Date: Mon, 9 Jan 2023 13:40:04 +0800
Subject: [PATCH] fix possible segmentation fault error in winograd on x86
---
.../src/layers/fast_convolution/fast_convolution.avx2.cpp | 2 +-
.../dnn/src/layers/fast_convolution/fast_convolution.cpp | 8 +++++++-
.../src/layers/fast_convolution/winograd_3x3s1_f63.cpp | 4 ++--
3 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/modules/dnn/src/layers/fast_convolution/fast_convolution.avx2.cpp b/modules/dnn/src/layers/fast_convolution/fast_convolution.avx2.cpp
index 0d3c1447626a..c98fbe72bda8 100644
--- a/modules/dnn/src/layers/fast_convolution/fast_convolution.avx2.cpp
+++ b/modules/dnn/src/layers/fast_convolution/fast_convolution.avx2.cpp
@@ -119,7 +119,7 @@ void convBlock_AVX2(int np, const float* a, const float* b, float* c, int ldc, b
void _fx_winograd_accum_f32(const float* inwptr, const float* wptr,
float* outbuf, int Cg, int iblock)
{
- CV_Assert(_FX_WINO_IBLOCK == 6 && _FX_WINO_KBLOCK == 4);// && _FX_WINO_ATOM_F32 == 8);
+ CV_Assert(_FX_WINO_IBLOCK == 6 && _FX_WINO_KBLOCK == 4 && _FX_WINO_ATOM_F32 == 8);
if (iblock > 3)
{
for (int atom_id = 0; atom_id < _FX_WINO_NATOMS_F32; atom_id++,
diff --git a/modules/dnn/src/layers/fast_convolution/fast_convolution.cpp b/modules/dnn/src/layers/fast_convolution/fast_convolution.cpp
index 1cde7b324f6f..946980bebe49 100644
--- a/modules/dnn/src/layers/fast_convolution/fast_convolution.cpp
+++ b/modules/dnn/src/layers/fast_convolution/fast_convolution.cpp
@@ -105,6 +105,12 @@ Ptr<FastConv> initFastConv(
conv->conv_type = _FX_CONV_TYPE_GENERIC;
#endif
+#if CV_TRY_AVX2
+ // Disabel Winograd when CV_TRY_AVX2 is true, but conv->useAVX2 is false.
+ if (conv->conv_type == _FX_CONV_TYPE_WINOGRAD3X3 && !conv->useAVX2)
+ conv->conv_type = _FX_CONV_TYPE_GENERIC;
+#endif
+
Mat weightsMat = _weightsMat.getMat();
auto wShape = shape(weightsMat);
const size_t wstep = weightsMat.step1();
@@ -257,7 +263,7 @@ Ptr<FastConv> initFastConv(
// we can always read MR elements starting from any valid index
{
int k = 0, nbias = K + VEC_ALIGN;
- conv->biasBuf.reserve(nbias);
+ conv->biasBuf.resize(nbias);
float* biasBufPtr = conv->biasBuf.data();
for(; k < K; k++)
biasBufPtr[k] = srcBias ? srcBias[k] : 0.f;
diff --git a/modules/dnn/src/layers/fast_convolution/winograd_3x3s1_f63.cpp b/modules/dnn/src/layers/fast_convolution/winograd_3x3s1_f63.cpp
index e3b80884102a..b0ccfd0cd24a 100644
--- a/modules/dnn/src/layers/fast_convolution/winograd_3x3s1_f63.cpp
+++ b/modules/dnn/src/layers/fast_convolution/winograd_3x3s1_f63.cpp
@@ -22,7 +22,7 @@ _fx_winograd_accum_f32(const float* inwptr, const float* wptr,
float* outbuf, int Cg, int iblock)
{
#if CV_NEON && CV_NEON_AARCH64
- CV_Assert(_FX_WINO_IBLOCK == 6 && _FX_WINO_KBLOCK == 4);
+ CV_Assert(_FX_WINO_IBLOCK == 6 && _FX_WINO_KBLOCK == 4 && _FX_WINO_ATOM_F32 == 4);
if (iblock > 3)
{
for (int atom_id = 0; atom_id < _FX_WINO_NATOMS_F32; atom_id++,
@@ -144,7 +144,7 @@ _fx_winograd_accum_f32(const float* inwptr, const float* wptr,
}
}
#elif CV_SIMD128
- CV_Assert(_FX_WINO_IBLOCK == 3 && _FX_WINO_KBLOCK == 4);
+ CV_Assert(_FX_WINO_IBLOCK == 3 && _FX_WINO_KBLOCK == 4 && _FX_WINO_ATOM_F32 == 4);
for (int atom_id = 0; atom_id < _FX_WINO_NATOMS_F32; atom_id++,
outbuf += _FX_WINO_ATOM_F32)
{

View File

@ -1,6 +1,6 @@
#!/bin/bash
VERSION=4.7.0
VERSION=4.8.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
@ -31,4 +31,4 @@ tar zcf opencv_extra-clean-${VERSION}.tar.gz opencv_extra-${VERSION}/
rm -r opencv_extra-${VERSION}/
echo fedpkg new-sources $(spectool -l --sources opencv.spec)
echo fedpkg new-sources $(spectool -l --sources opencv.spec | sed 's/.*: //;s/.*\///')

View File

@ -4,7 +4,7 @@
%if %{without tests}
%bcond_with extras_tests
%else
%bcond_with extras_tests
%bcond_without extras_tests
%endif
# linters are enabled by default if BUILD_DOCS OR BUILD_EXAMPLES
%bcond_with linters
@ -13,16 +13,12 @@
%bcond_with eigen2
%bcond_without eigen3
%bcond_without opencl
%if 0%{?rhel} >= 8
%bcond_with openni
%else
%ifarch x86_64 %{arm}
%bcond_without openni
%else
# we dont have openni in other archs
%bcond_with openni
%endif
%endif
%bcond_without tbb
%bcond_with cuda
%bcond_with xine
@ -68,13 +64,13 @@
%endif
Name: opencv
Version: 4.7.0
Version: 4.8.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: 15%{?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
@ -98,8 +94,6 @@ Source5: xorg.conf
Patch0: opencv-4.1.0-install_3rdparty_licenses.patch
Patch3: opencv.python.patch
# Upstream commit to fix rhbz#2190013
Patch4: https://github.com/opencv/opencv/pull/23112.patch
BuildRequires: gcc-c++
BuildRequires: cmake >= 2.6.3
@ -194,7 +188,7 @@ BuildRequires: blas-devel
BuildRequires: lapack-devel
}
%{?with_gdcm:BuildRequires: gdcm-devel}
%{?with_libmfx:BuildRequires: libmfx-devel}
%{?with_libmfx:BuildRequires: oneVPL-devel}
%{?with_clp:BuildRequires: coin-or-Clp-devel}
%{?with_va:BuildRequires: libva-devel}
%{?with_java:
@ -202,6 +196,7 @@ BuildRequires: ant
BuildRequires: java-devel
}
%{?with_vulkan:BuildRequires: vulkan-headers}
#BuildRequires: flatbuffers-devel
%if %{with tests}
BuildRequires: xorg-x11-drv-dummy
BuildRequires: mesa-dri-drivers
@ -282,19 +277,17 @@ to provide decent performance and stability.
# autosetup doesn't work with 2 sources
# https://github.com/rpm-software-management/rpm/issues/1204
%setup -q -a1 %{?with_extras_tests:-a2}
%if 1
# we don't use pre-built contribs except quirc
pushd 3rdparty
shopt -s extglob
#rm -r !(openexr|openvx|quirc)
rm -r !(openvx|quirc)
rm -r !(openvx|quirc|flatbuffers)
shopt -u extglob
popd &>/dev/null
%endif
%patch -P 0 -p1 -b .install_3rdparty_licenses
%patch -P 3 -p1 -b .python_install_binary
%patch -P 4 -p1 -b .backport_avx2
pushd %{name}_contrib-%{version}
#patch1 -p1 -b .install_cvv
@ -302,7 +295,7 @@ popd
# Install face_landmark_model
mkdir -p .cache/data
install -pm 0644 %{SOURCE3} .cache/data
install -pm 0644 %{S:3} .cache/data
pushd .cache/data
xz -d face_landmark_model.dat.xz
mv face_landmark_model.dat 7505c44ca4eb54b4ab1e4777cb96ac05-face_landmark_model.dat
@ -310,7 +303,7 @@ popd
# Install ADE, needed for opencv_gapi
mkdir -p .cache/ade
install -pm 0644 %{SOURCE4} .cache/ade/
install -pm 0644 %{S:4} .cache/ade/
%build
# enabled by default if libraries are presents at build time:
@ -335,7 +328,7 @@ install -pm 0644 %{SOURCE4} .cache/ade/
%ifarch x86_64 %{ix86}
-DCPU_BASELINE=SSE2 \
%endif
-DCMAKE_BUILD_TYPE=ReleaseWithDebInfo \
-DCMAKE_BUILD_TYPE=Release \
%{?with_java: -DBUILD_opencv_java=ON \
-DOPENCV_JAR_INSTALL_PATH=%{_jnidir} } \
%{!?with_java: -DBUILD_opencv_java=OFF } \
@ -366,7 +359,7 @@ install -pm 0644 %{SOURCE4} .cache/ade/
} \
-DBUILD_PROTOBUF=OFF \
-DPROTOBUF_UPDATE_FILES=ON \
%{?with_opencl: -DOPENCL_INCLUDE_DIR=%{_includedir}/CL } \
%{?with_opencl: -DOPENCL_INCLUDE_DIR=%{_includedir}/CL -DOPENCV_DNN_OPENCL=ON} \
%{!?with_opencl: -DWITH_OPENCL=OFF } \
-DOPENCV_EXTRA_MODULES_PATH=opencv_contrib-%{version}/modules \
-DWITH_LIBV4L=ON \
@ -375,7 +368,7 @@ install -pm 0644 %{SOURCE4} .cache/ade/
-DOPENCV_GENERATE_PKGCONFIG=ON \
%{?with_extras_tests: -DOPENCV_TEST_DATA_PATH=opencv_extra-%{version}/testdata} \
%{?with_gdcm: -DWITH_GDCM=ON } \
%{?with_libmfx: -DWITH_MFX=ON } \
%{?with_libmfx: -DWITH_MFX=ON -DWITH_GAPI_ONEVPL=ON} \
%{?with_clp: -DWITH_CLP=ON } \
%{?with_va: -DWITH_VA=ON } \
%{!?with_vtk: -DWITH_VTK=OFF} \
@ -404,7 +397,7 @@ ln -s -r %{buildroot}%{_jnidir}/opencv-%{javaver}.jar %{buildroot}%{_jnidir}/ope
%check
#ifnarch ppc64
%if %{with tests}
cp %SOURCE5 %{__cmake_builddir}
cp %{S:5} %{__cmake_builddir}
if [ -x /usr/libexec/Xorg ]; then
Xorg=/usr/libexec/Xorg
else
@ -475,7 +468,7 @@ ln -s -r %{buildroot}%{_jnidir}/opencv-%{javaver}.jar %{buildroot}%{_jnidir}/ope
%{_libdir}/libopencv_alphamat.so.{%{abiver},%{version}}
%{_libdir}/libopencv_aruco.so.{%{abiver},%{version}}
%{_libdir}/libopencv_bgsegm.so.{%{abiver},%{version}}
%{_libdir}/libopencv_barcode.so.{%{abiver},%{version}}
#%%{_libdir}/libopencv_barcode.so.{#%%{abiver},#%%{version}}
%{_libdir}/libopencv_bioinspired.so.{%{abiver},%{version}}
%{_libdir}/libopencv_ccalib.so.{%{abiver},%{version}}
%{?with_cuda:
@ -521,6 +514,11 @@ ln -s -r %{buildroot}%{_jnidir}/opencv-%{javaver}.jar %{buildroot}%{_jnidir}/ope
%{_libdir}/libopencv_xphoto.so.{%{abiver},%{version}}
%changelog
* Mon Aug 07 2023 Sérgio Basto <sergio@serjux.com> - 4.8.0-1
- Update opencv to 4.8.0
- Use bundle flatbuffers, tried build with flatbuffers from system but doesn't build
- Use oneVPL instead libmfx
* Thu Jul 20 2023 Fedora Release Engineering <releng@fedoraproject.org> - 4.7.0-15
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild

View File

@ -1,5 +1,4 @@
SHA512 (opencv-clean-4.7.0.tar.gz) = 75d33e006f5a00d6eda67076b368bbf7afa7cc2c31b843040f2df54246a978f055c12902ce7a8095cf0ce493a9ebedcbfb12b1e772ed688ef49bc8cb4ce9e57e
SHA512 (opencv_contrib-clean-4.7.0.tar.gz) = 5eb985d258afa17e50426e19a0172b14036082e7e3b93e05de43734af470edf45db3fabb0eb7a440aa95e9c87f9e94ef4bec19f629f2048ff08a75a01e787608
SHA512 (opencv_extra-clean-4.7.0.tar.gz) = a2ac18661b7709269b5efc6405080c2df4195b6a0d9e6fa011789f7217fbde90b4c832bafa243e2c6cccfd8fa06fe976e33b7f3f56fd40ab40cbf360c18dbbe1
SHA512 (opencv-clean-4.8.0.tar.gz) = 5c15a86893ebd4ef8d597b198f4467dbb76767c27ed49c20eb13a439f5a9ceb6d116dff82b6eb4ed39769f4bd75c05f08d843f21c4e9dbc5d1b1c8c4d469b5b5
SHA512 (opencv_contrib-clean-4.8.0.tar.gz) = decd6830c533014c0da7162dfaca18ef22a0cd2d10554c3f572c312cf3e76e45666ff5c6e10a4860d4bd4eaf73a1dfc8c8a4e76f49188a19d3de89019a15df3b
SHA512 (face_landmark_model.dat.xz) = 7558f29431bb9cad1f22ee067ad3ed41be8f68b865992eb7d3a5ce6b6b9e1d031cb03e33c3c149220ef8faebd0471703a8a3bbb06402bcc8ce76bd28317aa307
SHA512 (fa4b3e25167319cb0fa9432ef8281945-v0.1.2a.zip) = ce5af0bd5d7fb04022f92fed130898959aecb954cc09da2fc923c76b37ee92d2233888592a4c6bca8006ac4d3fda9c6da80f316c924a407a7a5961d9832a681c