Skip to content

Commit b8649d5

Browse files
committed
Merge branch 'dfsg' into debian
* dfsg: (84 commits) Fix stupid comparison mistake in audio serial fallback Update CMakeList.txt and ebuild for v0.5.0 c_sync: Collapse unused functions Configure audio support at runtime - fixes OpenKinect#372 Use audio serial as a fallback for K4W and 1473 models that do not provide a useful camera serial (thanks @olzhas). Fixes OpenKinect#360 and resolves OpenKinect#393. Remove legacy keep_alive.c; now require libusb >= 1.0.18 c_sync: Add freenect_sync_camera_to_world() (thanks @martyvona) - fixes OpenKinect#294 Fix a crash-on-exit in the OpenNI2 driver caused by using a deleted iterator. Cleanup imports in examples; also fixes a micview compile error on OS X. Allow freenect_set_tilt_degs to take a negative angle Update CMakeLists.txt for v0.4.3 win32: Fix command in examples/CMakeLists.txt ebuild: Improve python dependency - fixes OpenKinect#391 Standardize indentation in fnusb_open_subdevices Use non-infinite timeouts for bulk tilt / led commands Reset the audio device before using it to ensure the commands can be sent correctly Fixes OpenKinect#390 Update README.md and CMakeLists.txt for v0.4.2 Fix fakenect not handling freenect_process_events_timeout FN_DEBUG: print read_register and read_cmos_register replies Fix cmake module include order Fix cpack user option on linux Separate cpack options for different generators and add tgz generator Add cmake config file Fixes OpenKinect#355 wrappers/python: update freenect.c - fixes OpenKinect#326 ...
2 parents 1645521 + 9716fbf commit b8649d5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+15187
-4037
lines changed

CMakeLists.txt

Lines changed: 62 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -30,48 +30,49 @@
3030
# CMake directives
3131
######################################################################################
3232

33-
#Require 2.6 or higher.
34-
3533
cmake_minimum_required(VERSION 2.6)
34+
set(PYTHON_EXECUTABLE "python2")
3635

3736
######################################################################################
3837
# Project declaration and options
3938
######################################################################################
4039

4140
PROJECT(libfreenect)
4241

42+
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/")
43+
44+
# Find the host operating system and architecture
45+
include (FindOS)
46+
# Set up installation directories
47+
include (SetupDirectories)
48+
4349
set (PROJECT_VER_MAJOR 0)
44-
set (PROJECT_VER_MINOR 2)
50+
set (PROJECT_VER_MINOR 5)
4551
set (PROJECT_VER_PATCH 0)
46-
set (PROJECT_VER
52+
set (PROJECT_VER
4753
"${PROJECT_VER_MAJOR}.${PROJECT_VER_MINOR}.${PROJECT_VER_PATCH}")
48-
set (PROJECT_APIVER
54+
set (PROJECT_APIVER
4955
"${PROJECT_VER_MAJOR}.${PROJECT_VER_MINOR}")
5056

51-
OPTION(BUILD_AUDIO "Build audio support" OFF)
52-
OPTION(BUILD_REDIST_PACKAGE "Build libfreenect in a legally-redistributable manner (only affects audio)" OFF)
57+
OPTION(BUILD_REDIST_PACKAGE "Build libfreenect in a legally-redistributable manner (only affects audio)" ON)
5358
OPTION(BUILD_EXAMPLES "Build example programs" ON)
5459
OPTION(BUILD_FAKENECT "Build fakenect mock library" ON)
5560
OPTION(BUILD_C_SYNC "Build c synchronous library" ON)
5661
OPTION(BUILD_CPP "Build C++ Library (currently header only)" ON)
5762
OPTION(BUILD_CV "Build OpenCV wrapper" OFF)
5863
OPTION(BUILD_AS3_SERVER "Build the Actionscript 3 Server Example" OFF)
5964
OPTION(BUILD_PYTHON "Build Python extension" OFF)
65+
OPTION(BUILD_OPENNI2_DRIVER "Build libfreenect driver for OpenNI2" OFF)
6066
IF(PROJECT_OS_LINUX)
61-
OPTION(BUILD_CPACK "Build an RPM or DEB using CPack" OFF)
67+
OPTION(BUILD_CPACK_DEB "Build an DEB using CPack" OFF)
68+
OPTION(BUILD_CPACK_RPM "Build an RPM using CPack" OFF)
69+
OPTION(BUILD_CPACK_TGZ "Build an TGZ using CPack" OFF)
6270
ENDIF(PROJECT_OS_LINUX)
6371

6472
######################################################################################
65-
# CMake Modules
73+
# Dependencies and Definitions
6674
######################################################################################
6775

68-
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/")
69-
70-
# Find the host operating system and architecture
71-
include (FindOS)
72-
# Set up installation directories
73-
include (SetupDirectories)
74-
7576
# Find packages needed to build library
7677
find_package(libusb-1.0 REQUIRED)
7778

@@ -82,33 +83,41 @@ if(BIG_ENDIAN)
8283
add_definitions(-DFN_BIGENDIAN)
8384
endif()
8485

85-
if(BUILD_AUDIO)
86-
add_definitions(-DBUILD_AUDIO)
87-
endif()
88-
8986
if (WIN32)
90-
set(MATH_LIB "")
87+
set(MATH_LIB "")
9188
else(WIN32)
9289
set(MATH_LIB "m")
9390
endif()
9491

9592
######################################################################################
96-
# CMake
93+
# CMake
9794
######################################################################################
9895

9996
SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
10097
SET(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
10198
SET(DOC_OUTPUT_PATH ${CMAKE_BINARY_DIR}/doc)
10299

103-
# let CFLAGS env override this
104-
if(CMAKE_C_FLAGS STREQUAL "")
105-
set(CMAKE_C_FLAGS "-O2")
106-
endif()
107-
SET(CMAKE_C_FLAGS_DEBUG "-g -DDEBUG=1")
108-
SET(CMAKE_C_FLAGS_RELEASE "-O2")
109-
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g")
100+
if (MSVC)
101+
set(C_FLAGS_WARNING "-W4")
102+
else ()
103+
set(C_FLAGS_WARNING "-Wall")
104+
endif (MSVC)
110105

111-
add_definitions(-Wall)
106+
set(C_CXX_FLAGS_DEFAULT "${C_FLAGS_WARNING} -O2")
107+
108+
# These defaults can be overriden by -DCMAKE_C_FLAGS=""
109+
set(CMAKE_C_FLAGS "${C_CXX_FLAGS_DEFAULT} ${CMAKE_C_FLAGS}")
110+
# C Configurations
111+
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -g -DDEBUG=1")
112+
SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS}")
113+
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELEASE} -g")
114+
115+
# These defaults can be overriden by -DCMAKE_CXX_FLAGS=""
116+
set(CMAKE_CXX_FLAGS "${C_CXX_FLAGS_DEFAULT} ${CMAKE_CXX_FLAGS}")
117+
# C++ Configurations
118+
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -g -DDEBUG=1")
119+
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS}")
120+
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELEASE} -g")
112121

113122
# Pretty much everyone is going to need the main includes
114123
include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include)
@@ -118,13 +127,11 @@ include_directories(${LIBUSB_1_INCLUDE_DIRS})
118127

119128
if(WIN32)
120129
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/platform/windows")
121-
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/platform/windows/libusb10emu/libusb-1.0")
122130
endif()
123131

124132
# Add library project
125133
add_subdirectory (src)
126134

127-
# Add examples
128135
IF(BUILD_EXAMPLES)
129136
add_subdirectory (examples)
130137
ENDIF()
@@ -153,6 +160,10 @@ IF(BUILD_PYTHON)
153160
add_subdirectory (wrappers/python)
154161
ENDIF()
155162

163+
IF(BUILD_OPENNI2_DRIVER)
164+
add_subdirectory(OpenNI2-FreenectDriver)
165+
ENDIF()
166+
156167
######################################################################################
157168
# Extras
158169
######################################################################################
@@ -163,13 +174,17 @@ configure_file(
163174
"${CMAKE_CURRENT_BINARY_DIR}/UninstallTarget.cmake"
164175
IMMEDIATE @ONLY)
165176

177+
# --- cmake config file ---
178+
CONFIGURE_FILE(libfreenectConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/libfreenectConfig.cmake @ONLY)
179+
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libfreenectConfig.cmake DESTINATION share/${PROJECT_NAME})
180+
166181
add_custom_target(uninstall
167182
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/UninstallTarget.cmake)
168183

169184
# Create Debian/RPM Packages
170185
# after make, use "fakeroot cpack" in the build Dir to complete
171186

172-
IF ( BUILD_CPACK )
187+
IF ( BUILD_CPACK_TGZ OR BUILD_CPACK_DEB OR BUILD_CPACK_RPM )
173188
set(CPACK_PACKAGE_DESCRIPTION "libfreenect for kinect")
174189
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "libfreenect library for using kinect")
175190
set(CPACK_PACKAGE_NAME "libfreenect-dev")
@@ -182,20 +197,27 @@ IF ( BUILD_CPACK )
182197
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VER_PATCH})
183198
set(VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
184199

185-
set(CPACK_GENERATOR "DEB;RPM;")
200+
set(CPACK_GENERATOR "")
201+
if (BUILD_CPACK_TGZ)
202+
list(APPEND CPACK_GENERATOR "TGZ")
203+
endif()
204+
if (BUILD_CPACK_RPM)
205+
list(APPEND CPACK_GENERATOR "RPM")
206+
endif()
207+
if (BUILD_CPACK_DEB)
208+
list(APPEND CPACK_GENERATOR "DEB")
209+
endif()
186210
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}-${CMAKE_SYSTEM_PROCESSOR}")
187211

188212
include(CPack)
189213

190214
INSTALL(FILES "${CMAKE_BINARY_DIR}/lib/libfreenect.a" DESTINATION ${PROJECT_LIBRARY_INSTALL_DIR})
191-
if (BUILD_AUDIO)
192-
INSTALL(FILES "include/libfreenect-audio.h" DESTINATION ${PROJECT_INCLUDE_INSTALL_DIR})
193-
endif()
194215
INSTALL(FILES "include/libfreenect.h" DESTINATION ${PROJECT_INCLUDE_INSTALL_DIR})
195-
INSTALL(FILES "include/libfreenect-registration.h" DESTINATION ${PROJECT_INCLUDE_INSTALL_DIR})
216+
INSTALL(FILES "include/libfreenect_registration.h" DESTINATION ${PROJECT_INCLUDE_INSTALL_DIR})
217+
INSTALL(FILES "include/libfreenect_audio.h" DESTINATION ${PROJECT_INCLUDE_INSTALL_DIR})
196218
INSTALL(FILES "APACHE20" DESTINATION "share/doc/${CPACK_PACKAGE_NAME}")
197219
INSTALL(FILES "GPL2" DESTINATION "share/doc/${CPACK_PACKAGE_NAME}")
198-
INSTALL(FILES "README.asciidoc" DESTINATION "share/doc/${CPACK_PACKAGE_NAME}")
220+
INSTALL(FILES "README.md" DESTINATION "share/doc/${CPACK_PACKAGE_NAME}")
199221

200-
ENDIF ( BUILD_CPACK )
222+
ENDIF ( )
201223

HACKING

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

OpenNI2-FreenectDriver/CMakeLists.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
######################################################################################
2+
# OpenNI2-FreenectDriver
3+
######################################################################################
4+
5+
file(GLOB HEADERS src/*.hpp src/*.h)
6+
file(GLOB SOURCES src/*.cpp)
7+
add_library(FreenectDriver SHARED ${HEADERS} ${SOURCES})
8+
9+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-function")
10+
11+
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib/OpenNI2-FreenectDriver)
12+
set_target_properties(FreenectDriver PROPERTIES
13+
VERSION ${PROJECT_VER}
14+
SOVERSION ${PROJECT_APIVER}
15+
OUTPUT_NAME FreenectDriver)
16+
17+
add_definitions(-DPROJECT_VER="${PROJECT_VER}")
18+
19+
include_directories(extern/OpenNI-Linux-x64-2.2.0.33/Include)
20+
include_directories(${PROJECT_SOURCE_DIR}/wrappers/cpp)
21+
22+
target_link_libraries(FreenectDriver freenectstatic ${MATH_LIB})
23+
24+
install (TARGETS FreenectDriver
25+
DESTINATION "${PROJECT_LIBRARY_INSTALL_DIR}/OpenNI2-FreenectDriver")

OpenNI2-FreenectDriver/README.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
OpenNI2-FreenectDriver
2+
======================
3+
4+
OpenNI2-FreenectDriver is a bridge to libfreenect implemented as an OpenNI2 driver.
5+
It allows OpenNI2 to use Kinect hardware on Linux and OSX.
6+
It was originally a [separate project](https://github.com/piedar/OpenNI2-FreenectDriver) but is now distributed with libfreenect.
7+
OpenNI2-FreenectDriver is distributed under the [Apache 2](https://github.com/OpenKinect/libfreenect/blob/master/APACHE20) license.
8+
9+
Install
10+
-------
11+
1. Download and unpack [OpenNI](http://www.openni.org/openni-sdk/) 2.2.0.33 or higher.
12+
2. Go to the top libfreenect directory and build it with the OpenNI2 driver.
13+
14+
mkdir build
15+
cd build
16+
cmake .. -DBUILD_OPENNI2_DRIVER=ON
17+
make
18+
19+
3. Copy the driver to your OpenNI2 driver repository. You must first change `Repository` to match your project layout.
20+
21+
Repository="/example/path/to/Samples/Bin/OpenNI2/Drivers/"
22+
cp -L lib/OpenNI2-FreenectDriver/libFreenectDriver.{so,dylib} ${Repository}
23+
24+
# you could instead make a symlink to avoid copying after every build
25+
# ln -s lib/OpenNI2-FreenectDriver/libFreenectDriver.{so,dylib} ${Repository}
26+
27+
OpenNI2-FreenectDriver is built with a static libfreenect, so you do not need to include libfreenect when deploying.
28+
However, you will need to make sure target systems have libusb and all other dependencies listed in `ldd libFreenectDriver.so`.
29+
30+
__________________________________________________
31+
32+
Structure
33+
---------
34+
This driver is modeled on TestDevice.cpp and Drivers/Kinect/.
35+
In the FreenectDriver namespace, it ties together the C++ interfaces of OpenNI2 and libfreenect using multiple inheritance.
36+
37+
Driver inherits publically from oni::driver::DriverBase and privately from Freenect::Freenect.
38+
libfreenect.hpp allows protected access to the Freenect context, so that FreenectDriver can call the Freenect's C API.
39+
As a DriverBase, FreenectDriver manages devices and sets up device state callbacks.
40+
41+
Device inherits publically from oni::driver::DeviceBase and Freenect::FreenectDevice.
42+
Because of this, it can be built by Freenect::Freenect::createDevice() and it can define Device's depth and video callbacks.
43+
Those callbacks trigger acquireFrame() in FreenectStream.
44+
45+
VideoStream is a virtual base class inheriting from oni::driver::StreamBase.
46+
It does generic frame setup in buildFrame() and then calls pure virtual populateFrame() to let derived classes finish the frame.
47+
It also provides the base skeleton for setting and getting properties, which cascades down the inheritance tree.
48+
49+
DepthStream and ColorStream are nearly identical in definition and implementation, both inheriting from VideoStream.
50+
They differ mostly in the formats they use to process data and the video modes they support.
51+
These two classes offer a system to store and report supported video modes.
52+
To implement a new mode, simply add it to getSupportedVideoModes() and modify populateFrame() as necessary.
53+
54+
__________________________________________________
55+
56+
Todo
57+
----
58+
* support more FREENECT_RESOLUTION_\*, FREENECT_VIDEO_\*, and FREENECT_DEPTH_\*
59+
* provide more OniVideoMode and OniStreamProperty
60+
* implement remaining derived functions

0 commit comments

Comments
 (0)