Fix OpenCV build with OpenEXR before 2.2.0

This commit is contained in:
y00593611 2021-11-10 18:43:15 +08:00
parent 2fc5ac26e3
commit 7e2e3c9469
2 changed files with 60 additions and 1 deletions

View File

@ -0,0 +1,55 @@
From 083a7c8f0a71076d4f2f5130d70abaedb2f8c8a5 Mon Sep 17 00:00:00 2001
From: Alexander Smorkalov <alexander.smorkalov@xperience.ai>
Date: Wed, 28 Apr 2021 10:41:59 +0300
Subject: [PATCH] Fix OpenCV build with OpenEXR before 2.2.0.
---
modules/imgcodecs/include/opencv2/imgcodecs.hpp | 4 ++--
modules/imgcodecs/src/grfmt_exr.cpp | 3 +++
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/modules/imgcodecs/include/opencv2/imgcodecs.hpp b/modules/imgcodecs/include/opencv2/imgcodecs.hpp
index 42227f3788..101a944146 100644
--- a/modules/imgcodecs/include/opencv2/imgcodecs.hpp
+++ b/modules/imgcodecs/include/opencv2/imgcodecs.hpp
@@ -120,8 +120,8 @@ enum ImwriteEXRCompressionFlags {
IMWRITE_EXR_COMPRESSION_PXR24 = 5, //!< lossy 24-bit float compression
IMWRITE_EXR_COMPRESSION_B44 = 6, //!< lossy 4-by-4 pixel block compression, fixed compression rate
IMWRITE_EXR_COMPRESSION_B44A = 7, //!< lossy 4-by-4 pixel block compression, flat fields are compressed more
- IMWRITE_EXR_COMPRESSION_DWAA = 8, //!< lossy DCT based compression, in blocks of 32 scanlines. More efficient for partial buffer access.
- IMWRITE_EXR_COMPRESSION_DWAB = 9, //!< lossy DCT based compression, in blocks of 256 scanlines. More efficient space wise and faster to decode full frames than DWAA_COMPRESSION.
+ IMWRITE_EXR_COMPRESSION_DWAA = 8, //!< lossy DCT based compression, in blocks of 32 scanlines. More efficient for partial buffer access. Supported since OpenEXR 2.2.0.
+ IMWRITE_EXR_COMPRESSION_DWAB = 9, //!< lossy DCT based compression, in blocks of 256 scanlines. More efficient space wise and faster to decode full frames than DWAA_COMPRESSION. Supported since OpenEXR 2.2.0.
};
//! Imwrite PNG specific flags used to tune the compression algorithm.
diff --git a/modules/imgcodecs/src/grfmt_exr.cpp b/modules/imgcodecs/src/grfmt_exr.cpp
index aaf28eead6..7acaf434c6 100644
--- a/modules/imgcodecs/src/grfmt_exr.cpp
+++ b/modules/imgcodecs/src/grfmt_exr.cpp
@@ -64,6 +64,7 @@
#include <ImfStandardAttributes.h>
#include <half.h>
#include "grfmt_exr.hpp"
+#include "OpenEXRConfig.h"
#if defined _WIN32
@@ -649,12 +650,14 @@ bool ExrEncoder::write( const Mat& img, const std::vector<int>& params )
case IMWRITE_EXR_COMPRESSION_B44A:
header.compression() = B44A_COMPRESSION;
break;
+#if ((OPENEXR_VERSION_MAJOR * 1000 + OPENEXR_VERSION_MINOR) >= (2 * 1000 + 2)) // available since version 2.2.0
case IMWRITE_EXR_COMPRESSION_DWAA:
header.compression() = DWAA_COMPRESSION;
break;
case IMWRITE_EXR_COMPRESSION_DWAB:
header.compression() = DWAB_COMPRESSION;
break;
+#endif
default:
CV_Error(Error::StsBadArg, "IMWRITE_EXR_COMPRESSION is invalid or not supported");
}
--
2.29.2.windows.2

View File

@ -1,6 +1,6 @@
Name: opencv Name: opencv
Version: 4.5.2 Version: 4.5.2
Release: 1 Release: 2
Summary: OpenCV means Intel® Open Source Computer Vision Library. Summary: OpenCV means Intel® Open Source Computer Vision Library.
License: Apache-2.0 License: Apache-2.0
URL: https://github.com/opencv/opencv URL: https://github.com/opencv/opencv
@ -11,6 +11,7 @@ Source3: opencv_extra-4.5.2.tar.gz.ab
Source4: opencv_extra-4.5.2.tar.gz.ac Source4: opencv_extra-4.5.2.tar.gz.ac
Source5: opencv_extra-4.5.2.tar.gz.ad Source5: opencv_extra-4.5.2.tar.gz.ad
Source6: opencv_extra-4.5.2.tar.gz.ae Source6: opencv_extra-4.5.2.tar.gz.ae
Patch1: Fix-OpenCV-build-with-OpenEXR-before-2.2.0.patch
BuildRequires: gcc-c++ gcc autoconf pkgconfig protobuf-compiler protobuf BuildRequires: gcc-c++ gcc autoconf pkgconfig protobuf-compiler protobuf
BuildRequires: cmake BuildRequires: cmake
BuildRequires: libjpeg-devel BuildRequires: libjpeg-devel
@ -74,5 +75,8 @@ make install DESTDIR=%{buildroot}
%exclude /usr/local/share/* %exclude /usr/local/share/*
%changelog %changelog
* Wed Nov 10 2021 yanhailiang <yanhailiang@huawei.com> - 4.5.2-2
- bugFix OpenCV build with OpenEXR before 2.2.0
* Wed Sep 30 2021 shenwei <shenwei41@huawei.com> - 4.5.2-1 * Wed Sep 30 2021 shenwei <shenwei41@huawei.com> - 4.5.2-1
- package init - package init