zurutech / pillow-resize

Porting of Pillow resize method in C++ and OpenCV.
Apache License 2.0
123 stars 16 forks source link

Complie Error #3

Closed hongshenggeng closed 2 years ago

hongshenggeng commented 2 years ago

Dear Dep: I have cloned the pillow-resize and complied it. But met some Error as followed: the first one is "error: ‘_clip8_lut’ declared as an ‘inline’ field", the second is "‘static constexpr auto PillowResize::_lut(Generator&&) [with long unsigned int Length = 1280ul; Generator = PillowResize::<lambda(size_t)>]’ called in a constant expression _lut([](size_t n) -> uchar {". Could you help me to solve them?

Thanks.

marcov868 commented 2 years ago

Can you share some details about your platform (e.g. compiler, OS, OpenCV version), please?

bnascimento commented 2 years ago

Bumped into same issue. Tried to use the lib with the following line: cv::Mat resized = PillowResize::resize(src, cv::Size(INPUT_W, INPUT_H), cv::INTER_LINEAR);

and it gave me the following error: /usr/local/include/PillowResize/PillowResize.hpp: In instantiation of ‘constexpr const std::array<unsigned char, 1280> PillowResize::_clip8_lut<1280, -640>’: /usr/local/include/PillowResize/PillowResize.hpp:170:39: required from here /usr/local/include/PillowResize/PillowResize.hpp:147:34: error: temporary of non-literal type ‘PillowResize::<lambda(size_t)>’ in a constant expression 147 | static inline constexpr auto _clip8_lut = | ^~~~~~~~~~ /usr/local/include/PillowResize/PillowResize.hpp:148:22: note: ‘PillowResize::<lambda(size_t)>’ is not literal because: 148 | _lut<Length>([](size_t n) -> uchar { | ^~~~~~~~~~~~~~~~~~~~~~~ 149 | intmax_t saturate_val = static_cast<intmax_t>(n) + min_val; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 150 | if (saturate_val < 0) { | ~~~~~~~~~~~~~~~~~~~~~~~ 151 | return 0; | ~~~~~~~~~ 152 | } | ~ 153 | if (saturate_val > UCHAR_MAX) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 154 | return UCHAR_MAX; | ~~~~~~~~~~~~~~~~~ 155 | } | ~ 156 | return static_cast<uchar>(saturate_val); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 157 | }); | ~ cc1plus: note: ‘PillowResize::<lambda(size_t)>’ is a closure type, which is only literal in C++17 and later /home/bnascimento/development/evotegra/data_processing/apps/DeepHawkeye/cpp/src/main.cpp: In function ‘int main(int, char**)’:

bnascimento commented 2 years ago

Building the project with set(CMAKE_CXX_STANDARD 17) worked.

marcov868 commented 2 years ago

I added a different version of that function that can be compiled using either c++17 or the previous versions. Tell me if you still have problems