【解决方案】‘create’ is not a member of ‘cv::aruco::DetectorParameters’

‘create’ is not a member of ‘cv::aruco::DetectorParameters’
在构建AruCo标定板标定位姿代码的过程中,发现代码中认为create并不是aruco::DetectorParameters的成员函数,这是因为在4.7.0及以上的OpenCV版本中,对ArUco的代码做调整,删去create函数。
解决方法是安装OpenCV3的代码,我选择的是opencv3.4.13的版本。build成功之后就可以正常使用了。

【解决方案】‘create’ is not a member of ‘cv::aruco::DetectorParameters’_第1张图片
【4.6.0及以前的OpenCV是有create函数的】

【解决方案】‘create’ is not a member of ‘cv::aruco::DetectorParameters’_第2张图片
【4.7.0没有create函数】


如何在Ubuntu环境下安装OpenCV,通过Build源码的形式?参见OpenCV的官方文档Installation in Linux:

# Install minimal prerequisites (Ubuntu 18.04 as reference)
sudo apt update && sudo apt install -y cmake g++ wget unzip
# Download and unpack sources
wget -O opencv.zip https://github.com/opencv/opencv/archive/4.x.zip
wget -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/4.x.zip
unzip opencv.zip
unzip opencv_contrib.zip
# Create build directory and switch into it
mkdir -p build && cd build
# Configure
cmake -DOPENCV_EXTRA_MODULES_PATH=../opencv_contrib-3.4/modules ../opencv-3.4.13
# Build
cmake --build . -j4

这里注意,如果wget无法下载,要自己手动下载3.4.13的OpenCV及contrib安装包:
https://github.com/opencv/opencv/archive/3.4.13.zip
https://github.com/opencv/opencv_contrib/archive/3.4.zip

我将上述的build文件放在/home/ProfSnail/software/opencv3.4.13/build下面,在使用CMakeLists.txt的时候,要指定路径。比如:

project(PieceSeg)
cmake_minimum_required(VERSION 3.0)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_BUILD_TYPE Release)

set(OpenCV_DIR /home/ProfSnail/software/opencv3.4.13/build)
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})

add_executable(calibration calibration.cpp)
target_link_libraries(calibration ${OpenCV_LIBS} cnpy)

你可能感兴趣的:(OpenCV,cmakelist,OpenCV)