下载源码,解压得到如下的文件:
.
├── apriltag.c
├── apriltag.h
├── apriltag_math.h
├── apriltag.pc.in
├── apriltag_quad_thresh.c
├── common # ******************这是文件夹
├── example # ******************这是文件夹
├── install.sh
├── Makefile
├── README
├── tag16h5.c
├── tag16h5.h
├── tag25h7.c
├── tag25h7.h
├── tag25h9.c
├── tag25h9.h
├── tag36artoolkit.c
├── tag36artoolkit.h
├── tag36h10.c
├── tag36h10.h
├── tag36h11.c
└── tag36h11.h
新建一个目录,在该目录下建立如下的结构:
├── apriltag
│ ├── apriltag.c
│ ├── apriltag.h
│ ├── apriltag_math.h
│ ├── apriltag_quad_thresh.c
│ ├── CMakeLists.txt
│ ├── CMakeLists.txt~
│ ├── common # ******************这是文件夹
│ ├── tag16h5.c
│ ├── tag16h5.h
│ ├── tag25h7.c
│ ├── tag25h7.h
│ ├── tag25h9.c
│ ├── tag25h9.h
│ ├── tag36artoolkit.c
│ ├── tag36artoolkit.h
│ ├── tag36h10.c
│ ├── tag36h10.h
│ ├── tag36h11.c
│ └── tag36h11.h
├── cbiuld # ******************这是文件夹
├── CMakeLists.txt
└── opencv_demo.cpp
根目录下的CMakeLists.txt内容如下:
cmake_minimum_required(VERSION 2.8.3)
project(apriltag)
#add_definitions(-std=c99 -Wl --no-as-needed)
add_compile_options(-std=c99)
set(CMAKE_SHARED_LINKER_FLAGS "-Wl --no-as-needed")
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
find_package (Threads)
add_subdirectory(apriltag)
aux_source_directory(. srcs)
add_executable(solve_tag ${srcs})
target_link_libraries(solve_tag
apriltag
${OpenCV_LIBS}
${CMAKE_THREAD_LIBS_INIT}
)
下一级的CMakeLists.txt内容如下:
cmake_minimum_required(VERSION 2.8)
add_compile_options(-std=c99)
set(CMAKE_SHARED_LINKER_FLAGS "-Wl --no-as-needed")
aux_source_directory(common common_src)
aux_source_directory(. apriltag_src)
add_library(apriltag STATIC ${common_src} ${apriltag_src})
编译
注意,将所有#include <common/*.h>
中的common/
删除
之后进入cbuild文件夹,
cmake ..
make
./solve_tag