Skip to content

Commit 658b920

Browse files
Merge pull request opencv#1 from microsoft/melodic
Sync with upstream
2 parents 1c6e774 + 356f7eb commit 658b920

25 files changed

+1466
-760
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# External SDK Folder
2-
ext/sdk/*
2+
ext/**
3+
4+
# VS Code folders
5+
.vscode/
36

47
# Prerequisites
58
*.d

CMakeLists.txt

Lines changed: 21 additions & 160 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
11
# Copyright (c) Microsoft Corporation. All rights reserved.
22
# Licensed under the MIT License.
33

4-
cmake_minimum_required(VERSION 2.8.3)
4+
cmake_minimum_required(VERSION 3.5)
55
project(azure_kinect_ros_driver LANGUAGES C CXX)
66

7-
8-
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
9-
add_compile_options(/std:c++latest)
10-
else()
11-
add_compile_options(-std=c++11)
12-
endif()
13-
147
list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_CURRENT_LIST_DIR}/cmake)
158

169
## Find catkin macros and libraries
@@ -60,13 +53,17 @@ add_executable(${PROJECT_NAME}_node
6053
src/k4a_calibration_transform_data.cpp
6154
)
6255

56+
target_compile_features(${PROJECT_NAME}_node PUBLIC cxx_std_11)
57+
6358
add_library(${PROJECT_NAME}_nodelet
6459
src/k4a_ros_bridge_nodelet.cpp
6560
src/k4a_ros_device.cpp
6661
src/k4a_ros_device_params.cpp
6762
src/k4a_calibration_transform_data.cpp
6863
)
6964

65+
target_compile_features(${PROJECT_NAME}_nodelet PUBLIC cxx_std_11)
66+
7067
## Rename C++ executable without prefix
7168
## The above recommended prefix causes long target names, the following renames the
7269
## target back to the shorter version for ease of user use
@@ -77,51 +74,6 @@ set_target_properties(${PROJECT_NAME}_node PROPERTIES OUTPUT_NAME node PREFIX ""
7774
#### AZURE KINECT SDK ######
7875
############################
7976

80-
macro(process_ext_sdk)
81-
message(STATUS "K4A SDK found in ext/sdk!")
82-
message(STATUS "!! Not searching for SDK in system path !!")
83-
84-
# mark that the K4A SDK will need to be copied to the output binary folder
85-
# this is needed even on Linux if the SDK is not installed to the system path
86-
set(K4A_INSTALL_NEEDED true)
87-
88-
get_target_property(K4A_INCLUDE_DIRS k4a::k4a INTERFACE_INCLUDE_DIRECTORIES)
89-
get_target_property(K4A_CONFIGS k4a::k4a IMPORTED_CONFIGURATIONS)
90-
message("Configs: ${K4A_CONFIGS}")
91-
92-
# TODO: if we find more than one configuration, we should fail
93-
# TODO: potentially clean this logic up
94-
foreach(imported_config ${K4A_CONFIGS})
95-
if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
96-
get_target_property(K4A_CONFIG_LIBS k4a::k4a IMPORTED_IMPLIB_${imported_config})
97-
get_target_property(K4A_CONFIG_DLLS k4a::k4a IMPORTED_LOCATION_${imported_config})
98-
list(APPEND K4A_LIBS ${K4A_CONFIG_LIBS})
99-
list(APPEND K4A_DLL_FILES ${K4A_CONFIG_DLLS})
100-
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
101-
get_target_property(K4A_CONFIG_LIBS k4a::k4a IMPORTED_LOCATION_${imported_config})
102-
get_target_property(K4A_CONFIG_DLLS k4a::k4a IMPORTED_LOCATION_${imported_config})
103-
list(APPEND K4A_LIBS ${K4A_CONFIG_LIBS})
104-
list(APPEND K4A_DLL_FILES ${K4A_CONFIG_DLLS})
105-
endif()
106-
endforeach()
107-
108-
if(DEFINED DEPTHENGINE_DLL)
109-
## Find the depth engine DLL
110-
file(GLOB_RECURSE DEPTHENGINE_DLL_FILE
111-
"${CMAKE_CURRENT_SOURCE_DIR}/ext/sdk/*/${DEPTHENGINE_DLL}" )
112-
list(APPEND K4A_DLL_FILES ${DEPTHENGINE_DLL_FILE})
113-
endif()
114-
endmacro()
115-
116-
# Define the names of some files that we are going to try and find
117-
if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
118-
set(DEPTHENGINE_DLL "depthengine_1_0.dll")
119-
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
120-
set(DEPTHENGINE_DLL "libdepthengine.so.1.0")
121-
else()
122-
message(FATAL_ERROR "Platform ${CMAKE_SYSTEM_NAME} is not supported")
123-
endif()
124-
12577
message("Finding K4A SDK binaries")
12678

12779
# Disable cached locations for K4A SDK binaries.
@@ -132,112 +84,32 @@ message("Finding K4A SDK binaries")
13284
# differently (one needs install, one doesn't) we must disable the cache
13385
# so that find_package(k4a) will fail in all cases if not installed via the .deb.
13486
unset(k4a_DIR CACHE)
135-
unset(azure-kinect-sensor-sdk_DIR CACHE)
136-
137-
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
138-
message("Linux mode: Searching for K4A in system path and ./ext/sdk")
139-
140-
# Test if we can find the k4a library in the system path
141-
find_package(k4a 1.1.0 QUIET)
142-
143-
if (${k4a_FOUND})
144-
message("K4A SDK found in system libraries!")
145-
# For system libraries on linux, we can just append the target name (k4a::k4a)
146-
# to what will be passed into target_link_libraries()
147-
list(APPEND K4A_LIBS k4a::k4a)
148-
else()
149-
message("K4A SDK not found in system libraries. Searching ./ext/sdk...")
150-
find_package(k4a 1.1.0 PATHS "${CMAKE_CURRENT_SOURCE_DIR}/ext/sdk")
151-
152-
if(${k4a_FOUND})
153-
set(K4A_INSTALL_NEEDED true)
154-
message("K4A SDK found in ./ext/sdk!")
155-
process_ext_sdk()
156-
else()
157-
message(FATAL_ERROR "K4A SDK not found in system libraries or ./ext/sdk. Please install the Azure Kinect SDK.")
158-
endif()
15987

160-
endif()
161-
162-
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
163-
# Windows will always need K4A install for all targets
164-
set(K4A_INSTALL_NEEDED true)
165-
166-
# Try to find K4A installed to Program Files
167-
find_package(azure-kinect-sensor-sdk 1.1.0 EXACT QUIET PATHS "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
168-
169-
if (${azure-kinect-sensor-sdk_FOUND})
170-
message("K4A SDK found in Program Files!")
171-
172-
list(APPEND K4A_LIBS ${azure-kinect-sensor-sdk_LIBRARIES})
173-
list(APPEND K4A_BINS ${azure-kinect-sensor-sdk_BINARIES})
174-
set(K4A_INCLUDE_DIRS ${azure-kinect-sensor-sdk_INCLUDE_DIRS})
175-
176-
# Create a list of all K4A DLLs
177-
list(APPEND K4A_DLLS ${azure-kinect-sensor-sdk_LIBRARIES})
178-
list(APPEND K4A_DLLS ${azure-kinect-sensor-sdk_BINARIES})
179-
180-
foreach(DLL ${K4A_DLLS})
181-
set(prop "PROPERTY-NOTFOUND")
182-
get_property(prop TARGET ${DLL} PROPERTY IMPORTED_LOCATION)
183-
message(STATUS "IMPORTED_LOCATION: ${prop}")
184-
185-
if((NOT prop) OR (prop EQUAL "PROPERTY-NOTFOUND"))
186-
message(FATAL_ERROR "Target '${DLL}' in package azure-kinect-sensor-sdk does not contain an IMPORTED_LOCATION property")
187-
endif()
188-
189-
list(APPEND K4A_DLL_FILES ${prop})
190-
endforeach(DLL)
191-
else()
192-
# Try to find K4A installed to ./ext/sdk
193-
find_package(k4a 1.1.0 QUIET PATHS "${CMAKE_CURRENT_SOURCE_DIR}/ext/sdk")
194-
195-
if (${k4a_FOUND})
196-
message("K4A SDK found in ./ext/sdk!")
197-
process_ext_sdk()
198-
else()
199-
message(FATAL_ERROR "K4A SDK not found in Program Files or ./ext/sdk. Please install the Azure Kinect SDK.")
200-
endif()
201-
endif()
88+
# Force running the Findk4a.cmake module
89+
find_package(k4a 1.2.0 QUIET MODULE REQUIRED)
90+
set(K4A_LIBS k4a::k4a;k4a::k4arecord)
91+
92+
# Try to find and enable the body tracking SDK
93+
find_package(k4abt 0.9.2 QUIET MODULE)
94+
if (k4abt_FOUND)
95+
list(APPEND K4A_LIBS k4abt::k4abt)
96+
message(STATUS "Body Tracking SDK found: compiling support for Body Tracking")
97+
target_compile_definitions(${PROJECT_NAME}_node PUBLIC K4A_BODY_TRACKING)
98+
target_compile_definitions(${PROJECT_NAME}_nodelet PUBLIC K4A_BODY_TRACKING)
99+
else()
100+
message("!!! Body Tracking SDK not found: body tracking features will not be available !!!")
202101
endif()
203102

204-
message("K4A Include Dirs: ${K4A_INCLUDE_DIRS}")
205-
message("K4A Libs: ${K4A_LIBS}")
206-
message("K4A DLLs: ${K4A_DLL_FILES}")
207-
message("K4A Install Needed: ${K4A_INSTALL_NEEDED}")
208-
209-
if (${K4A_INSTALL_NEEDED})
210-
# Tell cmake that we need to reconfigure if any of the DLL files change
211-
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${K4A_DLL_FILES})
212-
213-
# We need to copy the DLLs into the CATKIN_PACKAGE_LIB_DESTINATION so
214-
# the node executable can find them on launch, and CATKIN_PACKAGE_BIN_DESTINATION
215-
# so the nodelet can find them on launch
216-
set(DLL_COPY_DIRECTORY "${CATKIN_DEVEL_PREFIX}/${CATKIN_PACKAGE_BIN_DESTINATION};${CATKIN_DEVEL_PREFIX}/${CATKIN_PACKAGE_LIB_DESTINATION}")
217-
218-
foreach(DIRECTORY ${DLL_COPY_DIRECTORY})
219-
file(MAKE_DIRECTORY "${DIRECTORY}")
220-
endforeach(DIRECTORY)
221-
222-
foreach(DLL ${K4A_DLL_FILES})
223-
foreach(DIRECTORY ${DLL_COPY_DIRECTORY})
224-
file(COPY "${DLL}" DESTINATION "${DIRECTORY}")
225-
get_filename_component(DLL_NAME ${DLL} NAME)
226-
message(STATUS "Copied dll from ${DLL_NAME} to ${DIRECTORY}")
227-
# Tell cmake that we need to clean up these DLLs on a "make clean"
228-
set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${DIRECTORY}/${DLL_NAME}")
229-
endforeach(DIRECTORY)
230-
endforeach(DLL)
231-
232-
endif()
103+
# This reads the K4A_LIBS and K4A_INSTALL_REQUIRED variables and decides how to install
104+
# the various shared objects / DLLs
105+
include(Installk4a)
233106

234107
##################################
235108
###### END AZURE KINECT SDK ######
236109
##################################
237110

238111
include_directories(
239112
${catkin_INCLUDE_DIRS}
240-
${K4A_INCLUDE_DIRS}
241113
"include"
242114
)
243115

@@ -271,14 +143,3 @@ install(
271143
launch
272144
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
273145
)
274-
275-
## Run a custom install script for the K4A components
276-
## Running the two "CODE" blocks populates the cmake_install.cmake script with the information
277-
## about which DLLs to install, and where to install them.
278-
## We then run the more complex script to actually perform the installation.
279-
if (${K4A_INSTALL_NEEDED})
280-
message("Installing K4A SDK to binary output folder")
281-
install(CODE "set(K4A_DLL_FILES \"${K4A_DLL_FILES}\")")
282-
install(CODE "set(DLL_COPY_DIRECTORY \"${CMAKE_INSTALL_PREFIX}/${CATKIN_PACKAGE_BIN_DESTINATION}\")")
283-
install(SCRIPT "./cmake/azure-kinect-sensor-sdk-install.cmake")
284-
endif()

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ The camera is fully configurable using a variety of options which can be specifi
2121

2222
However, this node does ***not*** expose all the sensor data from the Azure Kinect Developer Kit hardware. It does not provide access to:
2323

24-
- Body tracking data
2524
- Microphone array
2625

2726
For more information about how to use the node, please see the [usage guide](docs/usage.md).

azure-pipelines.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
5555
# Download and install the Azure Kinect Sensor SDK
5656
- powershell: |
57-
wget http://download.microsoft.com/download/E/B/D/EBDBB3C1-ED3F-4236-96D6-2BCB352F3710/Azure%20Kinect%20SDK%201.1.0.msi -OutFile $(Build.SourcesDirectory)\sdk.msi
57+
wget http://download.microsoft.com/download/1/9/8/198048e8-63f2-45c6-8f96-1fd541d1b4bc/Azure%20Kinect%20SDK%201.2.0.msi -OutFile $(Build.SourcesDirectory)\sdk.msi
5858
$(Build.SourcesDirectory)\sdk.msi /passive
5959
6060
# Build the catkin workspace
@@ -94,9 +94,9 @@ jobs:
9494
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
9595
sudo apt-add-repository https://packages.microsoft.com/ubuntu/18.04/prod
9696
sudo apt-get update
97-
echo libk4a1.1 libk4a1.1/accept-eula boolean true | sudo debconf-set-selections
98-
echo libk4a1.1 libk4a1.1/accepted-eula-hash string 0f5d5c5de396e4fee4c0753a21fee0c1ed726cf0316204edda484f08cb266d76 | sudo debconf-set-selections -u
99-
sudo apt-get -y install libk4a1.1-dev
97+
echo libk4a1.2 libk4a1.2/accept-eula boolean true | sudo debconf-set-selections
98+
echo libk4a1.2 libk4a1.2/accepted-eula-hash string 0f5d5c5de396e4fee4c0753a21fee0c1ed726cf0316204edda484f08cb266d76 | sudo debconf-set-selections -u
99+
sudo apt-get -y install libk4a1.2-dev
100100
displayName: Install the Azure Kinect Sensor SDK
101101
102102
# Build the catkin workspace

cmake/CopyImportedBinary.cmake

Lines changed: 0 additions & 49 deletions
This file was deleted.

cmake/FindModuleHelpers.cmake

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
function(print_variable x)
2+
message(STATUS "${x}: ${${x}}")
3+
endfunction()
4+
5+
function(quiet_message)
6+
if(NOT FIND_QUIETLY)
7+
message(${ARGV})
8+
endif()
9+
endfunction()
10+
11+
## Initialize some standardized variables
12+
set(FIND_VERSION_COUNT ${${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION_COUNT})
13+
set(FIND_VERSION_EXACT ${${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION_EXACT})
14+
set(FIND_VERSION ${${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION})
15+
set(FIND_VERSION_MAJOR ${${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION_MAJOR})
16+
set(FIND_VERSION_MINOR ${${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION_MINOR})
17+
set(FIND_VERSION_PATCH ${${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION_PATCH})
18+
set(FIND_QUIETLY ${${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY})
19+
set(FIND_REQUIRED ${${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED})

0 commit comments

Comments
 (0)