cmake issue compiling bridging code for OpenCV,OpenKinect and PCL
Hi,
I'm trying to learn OpenCV using a couple of kinect sensors (360 & ONE) . To get the sensors working I grabbed OKPCL (https://github.com/Qworg/OKPCL) - some bridging code between OpenKinect, OpenCV and PCL.
I'm using OpenCV 4.0, on Ubuntu 16.04 LTS. Each of the libraries required compiled but when I compile the bridging code, OKPCL, the executables that rely on OpenCV fail with "not declared within scope" errors.
Scanning dependencies of target OKCV
[ 56%] Building CXX object CMakeFiles/OKCV.dir/OKCV.cpp.o
/home/ed/src/qworg_branch/OKPCL/OKCV.cpp: In function ‘double computeReprojectionErrors(const std::vector<std::vector<cv::Point3_<float> > >&, const std::vector<std::vector<cv::Point_<float> > >&, const std::vector<cv::Mat>&, const std::vector<cv::Mat>&, const cv::Mat&, const cv::Mat&, std::vector<float>&)’:
/home/ed/src/qworg_branch/OKPCL/OKCV.cpp:194:59: error: ‘CV_L2’ was not declared in this scope
err = norm(Mat(imagePoints[i]), Mat(imagePoints2),CV_L2);
^
I've checked the source file (OKCV.cpp) to make sure the OpenCV headers are included. The namespace seems correct.
#include <iostream>
#include <libfreenect/libfreenect.hpp>
#include <libfreenect/libfreenect_registration.h>
#include <pthread.h>
#include <stdio.h>
#include <string.h>
#include <cmath>
#include <vector>
#include <ctime>
#include <boost/thread/thread.hpp>
//OPENCV Includes
#include "opencv2/core/core.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/calib3d/calib3d.hpp"
#include "opencv2/highgui/highgui.hpp"
using namespace cv;
using namespace std;
I also tried changing the order of the includes to see if it was some kind of cross compilation issue but no.
I've checked the CMakeLists.txt file to ensure the OpenCV libraries are included. I added some lines but it made no difference to the compilation error.
exert from MakeLists.txt :
project(OKCV)
find_package(OpenCV REQUIRED)
include_directories( ${OpenCV_INCLUDE_DIRS} ) #[[ I randomly added ]]
link_directories(${OpenCV_LIBRARY_DIRS}) #[[ I randomly added ]]
add_definitions(${OpenCV_DEFINITIONS}) #[[ I randomly added]]
if (WIN32)
set(THREADS_USE_PTHREADS_WIN32 true)
find_package(Threads REQUIRED)
include_directories(${THREADS_PTHREADS_INCLUDE_DIR})
endif()
include_directories(. ${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
include_directories(/usr/local/include/opencv4) #[[ I added]]
link_directories(/usr/local/include/opencv4) #[[ I added ]]
add_executable(OKCV OKCV.cpp)
if(APPLE)
target_link_libraries(OKCV freenect ${PCL_LIBRARIES} ${OpenCV_LIBS} )
else()
find_package(Threads REQUIRED)
include_directories(${USB_INCLUDE_DIRS})
if (WIN32)
set(MATH_LIB "")
else(WIN32)
set(MATH_LIB "m")
endif()
target_link_libraries(OKCV freenect ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB} ${PCL_LIBRARIES} ${OpenCV_LIBS})
endif()
To build the OKPCL code I created the build directory, cd into and then:
rm -rf CMakeLists.txt
cmake -DCMAKE_CXX_FLAGS="-std=c++11" ..
make clean
make
I'm new to cmake so any help with this issue would be gold