mirror of
https://github.com/opencv/opencv.git
synced 2025-06-08 01:53:19 +08:00
Merge pull request #11417 from Turim:imgcodecs_cmake_decoders_customize_formats
* imgcodecs cmake: the option to customize supported formats list (WITH_IMGCODEC_HDR, WITH_IMGCODEC_SUNRASTER, WITH_IMGCODEC_PXM) * imgcodecs: fixes - fixed CMake scripts (=OFF doesn't really work) - restore dropped GDCM block - added _IMGCODEC_ prefix - fixed tests - include PAM format under WITH_IMGCODEC_PXM option
This commit is contained in:
parent
573e790107
commit
84584002f2
@ -280,6 +280,9 @@ OCV_OPTION(WITH_GPHOTO2 "Include gPhoto2 library support" ON
|
||||
OCV_OPTION(WITH_LAPACK "Include Lapack library support" (NOT CV_DISABLE_OPTIMIZATION) IF (NOT ANDROID AND NOT IOS) )
|
||||
OCV_OPTION(WITH_ITT "Include Intel ITT support" ON IF (NOT APPLE_FRAMEWORK) )
|
||||
OCV_OPTION(WITH_PROTOBUF "Enable libprotobuf" ON )
|
||||
OCV_OPTION(WITH_IMGCODEC_HDR "Include HDR support" ON)
|
||||
OCV_OPTION(WITH_IMGCODEC_SUNRASTER "Include SUNRASTER support" ON)
|
||||
OCV_OPTION(WITH_IMGCODEC_PXM "Include PNM (PBM,PGM,PPM) and PAM formats support" ON)
|
||||
|
||||
# OpenCV build components
|
||||
# ===================================================
|
||||
@ -1216,6 +1219,18 @@ if(WITH_GDCM OR HAVE_GDCM)
|
||||
status(" GDCM:" HAVE_GDCM THEN "YES (ver ${GDCM_VERSION})" ELSE "NO")
|
||||
endif()
|
||||
|
||||
if(WITH_IMGCODEC_HDR OR DEFINED HAVE_IMGCODEC_HDR)
|
||||
status(" HDR:" HAVE_IMGCODEC_HDR THEN "YES" ELSE "NO")
|
||||
endif()
|
||||
|
||||
if(WITH_IMGCODEC_SUNRASTER OR DEFINED HAVE_IMGCODEC_SUNRASTER)
|
||||
status(" SUNRASTER:" HAVE_IMGCODEC_SUNRASTER THEN "YES" ELSE "NO")
|
||||
endif()
|
||||
|
||||
if(WITH_IMGCODEC_PXM OR DEFINED HAVE_IMGCODEC_PXM)
|
||||
status(" PXM:" HAVE_IMGCODEC_PXM THEN "YES" ELSE "NO")
|
||||
endif()
|
||||
|
||||
# ========================== VIDEO IO ==========================
|
||||
status("")
|
||||
status(" Video I/O:")
|
||||
|
@ -252,3 +252,19 @@ if (WITH_GDCM)
|
||||
set(GDCM_LIBRARIES gdcmMSFF) # GDCM does not set this variable for some reason
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(WITH_IMGCODEC_HDR)
|
||||
set(HAVE_IMGCODEC_HDR ON)
|
||||
elseif(DEFINED WITH_IMGCODEC_HDR)
|
||||
set(HAVE_IMGCODEC_HDR OFF)
|
||||
endif()
|
||||
if(WITH_IMGCODEC_SUNRASTER)
|
||||
set(HAVE_IMGCODEC_SUNRASTER ON)
|
||||
elseif(DEFINED WITH_IMGCODEC_SUNRASTER)
|
||||
set(HAVE_IMGCODEC_SUNRASTER OFF)
|
||||
endif()
|
||||
if(WITH_IMGCODEC_PXM)
|
||||
set(HAVE_IMGCODEC_PXM ON)
|
||||
elseif(DEFINED WITH_IMGCODEC_PXM)
|
||||
set(HAVE_IMGCODEC_PXM OFF)
|
||||
endif()
|
||||
|
@ -60,6 +60,18 @@ if(HAVE_GDAL)
|
||||
list(APPEND GRFMT_LIBS ${GDAL_LIBRARY})
|
||||
endif()
|
||||
|
||||
if(HAVE_IMGCODEC_HDR)
|
||||
add_definitions(-DHAVE_IMGCODEC_HDR)
|
||||
endif()
|
||||
|
||||
if(HAVE_IMGCODEC_SUNRASTER)
|
||||
add_definitions(-DHAVE_IMGCODEC_SUNRASTER)
|
||||
endif()
|
||||
|
||||
if(HAVE_IMGCODEC_PXM)
|
||||
add_definitions(-DHAVE_IMGCODEC_PXM)
|
||||
endif()
|
||||
|
||||
file(GLOB grfmt_hdrs ${CMAKE_CURRENT_LIST_DIR}/src/grfmt*.hpp)
|
||||
file(GLOB grfmt_srcs ${CMAKE_CURRENT_LIST_DIR}/src/grfmt*.cpp)
|
||||
|
||||
|
@ -44,6 +44,8 @@
|
||||
#include "grfmt_hdr.hpp"
|
||||
#include "rgbe.hpp"
|
||||
|
||||
#ifdef HAVE_IMGCODEC_HDR
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
@ -166,3 +168,5 @@ bool HdrEncoder::isFormatSupported( int depth ) const {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // HAVE_IMGCODEC_HDR
|
||||
|
@ -45,6 +45,8 @@
|
||||
|
||||
#include "grfmt_base.hpp"
|
||||
|
||||
#ifdef HAVE_IMGCODEC_HDR
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
@ -85,4 +87,6 @@ protected:
|
||||
|
||||
}
|
||||
|
||||
#endif // HAVE_IMGCODEC_HDR
|
||||
|
||||
#endif/*_GRFMT_HDR_H_*/
|
||||
|
@ -46,10 +46,13 @@
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
|
||||
#ifdef HAVE_IMGCODEC_PXM
|
||||
|
||||
#include <cerrno>
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include "utils.hpp"
|
||||
#include "grfmt_pam.hpp"
|
||||
|
||||
@ -720,3 +723,5 @@ bool PAMEncoder::write( const Mat& img, const std::vector<int>& params )
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -53,6 +53,8 @@
|
||||
#ifndef _OPENCV_PAM_HPP_
|
||||
#define _OPENCV_PAM_HPP_
|
||||
|
||||
#ifdef HAVE_IMGCODEC_PXM
|
||||
|
||||
#include "grfmt_base.hpp"
|
||||
#include "bitstrm.hpp"
|
||||
|
||||
@ -96,4 +98,6 @@ public:
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _OPENCV_PAM_HPP_ */
|
||||
|
@ -45,6 +45,8 @@
|
||||
#include "grfmt_pxm.hpp"
|
||||
#include <iostream>
|
||||
|
||||
#ifdef HAVE_IMGCODEC_PXM
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
@ -619,3 +621,5 @@ bool PxMEncoder::write(const Mat& img, const std::vector<int>& params)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // HAVE_IMGCODEC_PXM
|
||||
|
@ -46,6 +46,8 @@
|
||||
#include "grfmt_base.hpp"
|
||||
#include "bitstrm.hpp"
|
||||
|
||||
#ifdef HAVE_IMGCODEC_PXM
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
@ -101,4 +103,6 @@ public:
|
||||
|
||||
}
|
||||
|
||||
#endif // HAVE_IMGCODEC_PXM
|
||||
|
||||
#endif/*_GRFMT_PxM_H_*/
|
||||
|
@ -43,6 +43,8 @@
|
||||
#include "precomp.hpp"
|
||||
#include "grfmt_sunras.hpp"
|
||||
|
||||
#ifdef HAVE_IMGCODEC_SUNRASTER
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
@ -427,3 +429,5 @@ bool SunRasterEncoder::write( const Mat& img, const std::vector<int>& )
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // HAVE_IMGCODEC_SUNRASTER
|
||||
|
@ -45,6 +45,8 @@
|
||||
|
||||
#include "grfmt_base.hpp"
|
||||
|
||||
#ifdef HAVE_IMGCODEC_SUNRASTER
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
@ -102,4 +104,6 @@ public:
|
||||
|
||||
}
|
||||
|
||||
#endif // HAVE_IMGCODEC_SUNRASTER
|
||||
|
||||
#endif/*_GRFMT_SUNRAS_H_*/
|
||||
|
@ -131,8 +131,10 @@ struct ImageCodecInitializer
|
||||
decoders.push_back( makePtr<BmpDecoder>() );
|
||||
encoders.push_back( makePtr<BmpEncoder>() );
|
||||
|
||||
#ifdef HAVE_IMGCODEC_HDR
|
||||
decoders.push_back( makePtr<HdrDecoder>() );
|
||||
encoders.push_back( makePtr<HdrEncoder>() );
|
||||
#endif
|
||||
#ifdef HAVE_JPEG
|
||||
decoders.push_back( makePtr<JpegDecoder>() );
|
||||
encoders.push_back( makePtr<JpegEncoder>() );
|
||||
@ -141,13 +143,19 @@ struct ImageCodecInitializer
|
||||
decoders.push_back( makePtr<WebPDecoder>() );
|
||||
encoders.push_back( makePtr<WebPEncoder>() );
|
||||
#endif
|
||||
#ifdef HAVE_IMGCODEC_SUNRASTER
|
||||
decoders.push_back( makePtr<SunRasterDecoder>() );
|
||||
encoders.push_back( makePtr<SunRasterEncoder>() );
|
||||
#endif
|
||||
#ifdef HAVE_IMGCODEC_PXM
|
||||
decoders.push_back( makePtr<PxMDecoder>() );
|
||||
encoders.push_back( makePtr<PxMEncoder>(PXM_TYPE_AUTO) );
|
||||
encoders.push_back( makePtr<PxMEncoder>(PXM_TYPE_PBM) );
|
||||
encoders.push_back( makePtr<PxMEncoder>(PXM_TYPE_PGM) );
|
||||
encoders.push_back( makePtr<PxMEncoder>(PXM_TYPE_PPM) );
|
||||
decoders.push_back( makePtr<PAMDecoder>() );
|
||||
encoders.push_back( makePtr<PAMEncoder>() );
|
||||
#endif
|
||||
#ifdef HAVE_TIFF
|
||||
decoders.push_back( makePtr<TiffDecoder>() );
|
||||
encoders.push_back( makePtr<TiffEncoder>() );
|
||||
@ -172,8 +180,6 @@ struct ImageCodecInitializer
|
||||
/// Attach the GDAL Decoder
|
||||
decoders.push_back( makePtr<GdalDecoder>() );
|
||||
#endif/*HAVE_GDAL*/
|
||||
decoders.push_back( makePtr<PAMDecoder>() );
|
||||
encoders.push_back( makePtr<PAMEncoder>() );
|
||||
}
|
||||
|
||||
std::vector<ImageDecoder> decoders;
|
||||
|
@ -89,7 +89,9 @@ const string all_images[] =
|
||||
"readwrite/ordinary.bmp",
|
||||
"readwrite/rle8.bmp",
|
||||
"readwrite/test_1_c1.jpg",
|
||||
#ifdef HAVE_IMGCODEC_HDR
|
||||
"readwrite/rle.hdr"
|
||||
#endif
|
||||
};
|
||||
|
||||
const int basic_modes[] =
|
||||
@ -207,11 +209,13 @@ const string all_exts[] =
|
||||
".jpg",
|
||||
#endif
|
||||
".bmp",
|
||||
#ifdef HAVE_IMGCODEC_PXM
|
||||
".pam",
|
||||
".ppm",
|
||||
".pgm",
|
||||
".pbm",
|
||||
".pnm"
|
||||
#endif
|
||||
};
|
||||
|
||||
vector<Size> all_sizes()
|
||||
@ -227,6 +231,7 @@ INSTANTIATE_TEST_CASE_P(All, Imgcodecs_ExtSize,
|
||||
testing::ValuesIn(all_exts),
|
||||
testing::ValuesIn(all_sizes())));
|
||||
|
||||
#ifdef HAVE_IMGCODEC_PXM
|
||||
typedef testing::TestWithParam<bool> Imgcodecs_pbm;
|
||||
TEST_P(Imgcodecs_pbm, write_read)
|
||||
{
|
||||
@ -259,6 +264,7 @@ TEST_P(Imgcodecs_pbm, write_read)
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(All, Imgcodecs_pbm, testing::Bool());
|
||||
#endif
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
@ -274,6 +280,7 @@ TEST(Imgcodecs_Bmp, read_rle8)
|
||||
EXPECT_PRED_FORMAT2(cvtest::MatComparator(0, 0), rle, ord);
|
||||
}
|
||||
|
||||
#ifdef HAVE_IMGCODEC_HDR
|
||||
TEST(Imgcodecs_Hdr, regression)
|
||||
{
|
||||
string folder = string(cvtest::TS::ptr()->get_data_path()) + "/readwrite/";
|
||||
@ -299,7 +306,9 @@ TEST(Imgcodecs_Hdr, regression)
|
||||
}
|
||||
remove(tmp_file_name.c_str());
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_IMGCODEC_PXM
|
||||
TEST(Imgcodecs_Pam, read_write)
|
||||
{
|
||||
string folder = string(cvtest::TS::ptr()->get_data_path()) + "readwrite/";
|
||||
@ -326,5 +335,6 @@ TEST(Imgcodecs_Pam, read_write)
|
||||
remove(writefile.c_str());
|
||||
remove(writefile_no_param.c_str());
|
||||
}
|
||||
#endif
|
||||
|
||||
}} // namespace
|
||||
|
@ -112,8 +112,12 @@ const string exts[] = {
|
||||
"exr",
|
||||
#endif
|
||||
"bmp",
|
||||
#ifdef HAVE_IMGCODEC_PXM
|
||||
"ppm",
|
||||
"ras"
|
||||
#endif
|
||||
#ifdef HAVE_IMGCODEC_SUNRASTER
|
||||
"ras",
|
||||
#endif
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(imgcodecs, Imgcodecs_Image, testing::ValuesIn(exts));
|
||||
|
Loading…
Reference in New Issue
Block a user