每一个错误的经验积累,就是通向成功的阶梯。
Each mistake I made shall become one of the stairs towards success.
Tuesday, 19 November 2019
openCV Troubleshooting (2) : error: ‘CV_LOAD_IMAGE_GRAYSCALE’ was not declared in this scope
This is due to different versions of openCV. Things got update to different names.
Didn't work:
image1= cv::imread("test.bmp", CV_LOAD_IMAGE_GRAYSCALE);
Didn't work:
image1= cv::imread("test.bmp", IMREAD_GRAYSCALE);
WORKED!!!!!
image1= cv::imread("test.bmp", cv::ImreadModes::IMREAD_GRAYSCALE);
ref:
https://stackoverflow.com/questions/27424285/cv-load-image-grayscale-is-not-definedpy
https://stackoverflow.com/questions/22547416/open-cv-flags-dont-work
openCV Troubleshooting (1) : undefined reference to `cv::xxxx`
I am compiling openCV project with cmake and I am getting errors like:
test.cpp:(.text+0xc0): undefined reference to `cv::imread(std::string const&, int)'
test.cpp:(.text+0x11f): undefined reference to `cv::_OutputArray::_OutputArray(cv::Mat&)'
test.cpp:(.text+0x138): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
test.cpp:(.text+0x158): undefined reference to `cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int)'
test.cpp:(.text+0x180): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
The following compiling script won't cause the issue.
g++ -o test_1 test_1.cpp `pkg-config opencv --cflags --libs`
But to fix cmake compile, we need to add the following red line to CMakeList.txt.
cmake_minimum_required(VERSION 2.8)
project( DisplayImage )
find_package( OpenCV REQUIRED )
add_executable( DisplayImage DisplayImage.cpp )
target_link_libraries( DisplayImage ${OpenCV_LIBS} )
ref:
Subscribe to:
Posts (Atom)