Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenCV
opencv
提交
90e36926
O
opencv
项目概览
OpenCV
/
opencv
上一次同步 8 个月
通知
988
Star
71100
Fork
55581
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
opencv
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
90e36926
编写于
12月 24, 2021
作者:
A
Alexander Alekhin
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #21327 from alalek:imgcodecs_openexr_runtime_disabled
上级
3a8316ab
381d9baf
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
40 addition
and
1 deletion
+40
-1
cmake/OpenCVFindLibsGrfmt.cmake
cmake/OpenCVFindLibsGrfmt.cmake
+1
-0
modules/imgcodecs/CMakeLists.txt
modules/imgcodecs/CMakeLists.txt
+12
-0
modules/imgcodecs/src/grfmt_exr.cpp
modules/imgcodecs/src/grfmt_exr.cpp
+26
-0
modules/imgcodecs/test/test_grfmt.cpp
modules/imgcodecs/test/test_grfmt.cpp
+1
-1
未找到文件。
cmake/OpenCVFindLibsGrfmt.cmake
浏览文件 @
90e36926
...
...
@@ -240,6 +240,7 @@ if(WITH_OPENEXR)
set
(
OPENEXR_LIBRARIES IlmImf
)
add_subdirectory
(
"
${
OpenCV_SOURCE_DIR
}
/3rdparty/openexr"
)
if
(
OPENEXR_VERSION
)
# check via TARGET doesn't work
set
(
BUILD_OPENEXR ON
)
set
(
HAVE_OPENEXR YES
)
endif
()
endif
()
...
...
modules/imgcodecs/CMakeLists.txt
浏览文件 @
90e36926
...
...
@@ -45,12 +45,21 @@ if(HAVE_JASPER)
list
(
APPEND GRFMT_LIBS
${
JASPER_LIBRARIES
}
)
if
(
OPENCV_IO_FORCE_JASPER
)
add_definitions
(
-DOPENCV_IMGCODECS_FORCE_JASPER=1
)
else
()
message
(
STATUS
"imgcodecs: Jasper codec is disabled in runtime. Details: https://github.com/opencv/opencv/issues/14058"
)
endif
()
endif
()
if
(
HAVE_OPENEXR
)
include_directories
(
SYSTEM
${
OPENEXR_INCLUDE_PATHS
}
)
list
(
APPEND GRFMT_LIBS
${
OPENEXR_LIBRARIES
}
)
if
(
OPENCV_IO_FORCE_OPENEXR
OR NOT BUILD_OPENEXR
# external OpenEXR versions are not disabled
)
add_definitions
(
-DOPENCV_IMGCODECS_USE_OPENEXR=1
)
else
()
message
(
STATUS
"imgcodecs: OpenEXR codec is disabled in runtime. Details: https://github.com/opencv/opencv/issues/21326"
)
endif
()
endif
()
if
(
HAVE_PNG OR HAVE_TIFF OR HAVE_OPENEXR
)
...
...
@@ -149,6 +158,9 @@ ocv_add_accuracy_tests()
if
(
TARGET opencv_test_imgcodecs AND HAVE_JASPER AND
"$ENV{OPENCV_IO_ENABLE_JASPER}"
)
ocv_target_compile_definitions
(
opencv_test_imgcodecs PRIVATE OPENCV_IMGCODECS_ENABLE_JASPER_TESTS=1
)
endif
()
if
(
TARGET opencv_test_imgcodecs AND HAVE_OPENEXR AND
"$ENV{OPENCV_IO_ENABLE_OPENEXR}"
)
ocv_target_compile_definitions
(
opencv_test_imgcodecs PRIVATE OPENCV_IMGCODECS_ENABLE_OPENEXR_TESTS=1
)
endif
()
if
(
TARGET opencv_test_imgcodecs AND HAVE_PNG AND
NOT
(
PNG_VERSION VERSION_LESS
"1.6.31"
))
# details: https://github.com/glennrp/libpng/commit/68cb0aaee3de6371b81a4613476d9b33e43e95b1
ocv_target_compile_definitions
(
opencv_test_imgcodecs PRIVATE OPENCV_IMGCODECS_PNG_WITH_EXIF=1
)
...
...
modules/imgcodecs/src/grfmt_exr.cpp
浏览文件 @
90e36926
...
...
@@ -44,6 +44,9 @@
#ifdef HAVE_OPENEXR
#include <opencv2/core/utils/configuration.private.hpp>
#include <opencv2/core/utils/logger.hpp>
#if defined _MSC_VER && _MSC_VER >= 1200
# pragma warning( disable: 4100 4244 4267 )
#endif
...
...
@@ -78,6 +81,27 @@
namespace
cv
{
static
bool
isOpenEXREnabled
()
{
static
const
bool
PARAM_ENABLE_OPENEXR
=
utils
::
getConfigurationParameterBool
(
"OPENCV_IO_ENABLE_OPENEXR"
,
#ifdef OPENCV_IMGCODECS_USE_OPENEXR
true
#else
false
#endif
);
return
PARAM_ENABLE_OPENEXR
;
}
static
void
initOpenEXR
()
{
if
(
!
isOpenEXREnabled
())
{
const
char
*
message
=
"imgcodecs: OpenEXR codec is disabled. You can enable it via 'OPENCV_IO_ENABLE_OPENEXR' option. Refer for details and cautions here: https://github.com/opencv/opencv/issues/21326"
;
CV_LOG_WARNING
(
NULL
,
message
);
CV_Error
(
Error
::
StsNotImplemented
,
message
);
}
}
/////////////////////// ExrDecoder ///////////////////
ExrDecoder
::
ExrDecoder
()
...
...
@@ -575,6 +599,7 @@ void ExrDecoder::RGBToGray( float *in, float *out )
ImageDecoder
ExrDecoder
::
newDecoder
()
const
{
initOpenEXR
();
return
makePtr
<
ExrDecoder
>
();
}
...
...
@@ -698,6 +723,7 @@ bool ExrEncoder::write( const Mat& img, const std::vector<int>& params )
ImageEncoder
ExrEncoder
::
newEncoder
()
const
{
initOpenEXR
();
return
makePtr
<
ExrEncoder
>
();
}
...
...
modules/imgcodecs/test/test_grfmt.cpp
浏览文件 @
90e36926
...
...
@@ -363,6 +363,6 @@ TEST(Imgcodecs, write_parameter_type)
}}
// namespace
#if
def HAVE_OPENEXR
#if
defined(HAVE_OPENEXR) && defined(OPENCV_IMGCODECS_ENABLE_OPENEXR_TESTS)
#include "test_exr.impl.hpp"
#endif
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录