Skip to content

Commit 9716fbf

Browse files
committed
Merge tag 'v0.5.0' into dfsg
libfreenect v0.5.0 Satellite * tag 'v0.5.0': (44 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 29bc8ff + 8d95792 commit 9716fbf

47 files changed

Lines changed: 6060 additions & 4201 deletions

Some content is hidden

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

CMakeLists.txt

Lines changed: 54 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,22 @@ set(PYTHON_EXECUTABLE "python2")
3939

4040
PROJECT(libfreenect)
4141

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+
4249
set (PROJECT_VER_MAJOR 0)
43-
set (PROJECT_VER_MINOR 4)
50+
set (PROJECT_VER_MINOR 5)
4451
set (PROJECT_VER_PATCH 0)
45-
set (PROJECT_VER
52+
set (PROJECT_VER
4653
"${PROJECT_VER_MAJOR}.${PROJECT_VER_MINOR}.${PROJECT_VER_PATCH}")
47-
set (PROJECT_APIVER
54+
set (PROJECT_APIVER
4855
"${PROJECT_VER_MAJOR}.${PROJECT_VER_MINOR}")
4956

50-
OPTION(BUILD_AUDIO "Build audio support" OFF)
51-
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)
5258
OPTION(BUILD_EXAMPLES "Build example programs" ON)
5359
OPTION(BUILD_FAKENECT "Build fakenect mock library" ON)
5460
OPTION(BUILD_C_SYNC "Build c synchronous library" ON)
@@ -58,20 +64,15 @@ OPTION(BUILD_AS3_SERVER "Build the Actionscript 3 Server Example" OFF)
5864
OPTION(BUILD_PYTHON "Build Python extension" OFF)
5965
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)
105+
106+
set(C_CXX_FLAGS_DEFAULT "${C_FLAGS_WARNING} -O2")
110107

111-
add_definitions(-Wall)
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()
@@ -167,13 +174,17 @@ configure_file(
167174
"${CMAKE_CURRENT_BINARY_DIR}/UninstallTarget.cmake"
168175
IMMEDIATE @ONLY)
169176

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+
170181
add_custom_target(uninstall
171182
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/UninstallTarget.cmake)
172183

173184
# Create Debian/RPM Packages
174185
# after make, use "fakeroot cpack" in the build Dir to complete
175186

176-
IF ( BUILD_CPACK )
187+
IF ( BUILD_CPACK_TGZ OR BUILD_CPACK_DEB OR BUILD_CPACK_RPM )
177188
set(CPACK_PACKAGE_DESCRIPTION "libfreenect for kinect")
178189
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "libfreenect library for using kinect")
179190
set(CPACK_PACKAGE_NAME "libfreenect-dev")
@@ -186,20 +197,27 @@ IF ( BUILD_CPACK )
186197
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VER_PATCH})
187198
set(VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
188199

189-
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()
190210
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}-${CMAKE_SYSTEM_PROCESSOR}")
191211

192212
include(CPack)
193213

194214
INSTALL(FILES "${CMAKE_BINARY_DIR}/lib/libfreenect.a" DESTINATION ${PROJECT_LIBRARY_INSTALL_DIR})
195-
if (BUILD_AUDIO)
196-
INSTALL(FILES "include/libfreenect_audio.h" DESTINATION ${PROJECT_INCLUDE_INSTALL_DIR})
197-
endif()
198215
INSTALL(FILES "include/libfreenect.h" DESTINATION ${PROJECT_INCLUDE_INSTALL_DIR})
199216
INSTALL(FILES "include/libfreenect_registration.h" DESTINATION ${PROJECT_INCLUDE_INSTALL_DIR})
217+
INSTALL(FILES "include/libfreenect_audio.h" DESTINATION ${PROJECT_INCLUDE_INSTALL_DIR})
200218
INSTALL(FILES "APACHE20" DESTINATION "share/doc/${CPACK_PACKAGE_NAME}")
201219
INSTALL(FILES "GPL2" DESTINATION "share/doc/${CPACK_PACKAGE_NAME}")
202220
INSTALL(FILES "README.md" DESTINATION "share/doc/${CPACK_PACKAGE_NAME}")
203221

204-
ENDIF ( BUILD_CPACK )
222+
ENDIF ( )
205223

HACKING

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

OpenNI2-FreenectDriver/CMakeLists.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,20 @@
22
# OpenNI2-FreenectDriver
33
######################################################################################
44

5+
file(GLOB HEADERS src/*.hpp src/*.h)
56
file(GLOB SOURCES src/*.cpp)
6-
add_library(FreenectDriver SHARED ${SOURCES})
7+
add_library(FreenectDriver SHARED ${HEADERS} ${SOURCES})
78

8-
set(CMAKE_CXX_FLAGS "-Wno-gnu-static-float-init -Wno-unused-function")
9+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-function")
910

1011
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib/OpenNI2-FreenectDriver)
11-
set_target_properties( FreenectDriver PROPERTIES
12+
set_target_properties(FreenectDriver PROPERTIES
1213
VERSION ${PROJECT_VER}
1314
SOVERSION ${PROJECT_APIVER}
1415
OUTPUT_NAME FreenectDriver)
1516

17+
add_definitions(-DPROJECT_VER="${PROJECT_VER}")
18+
1619
include_directories(extern/OpenNI-Linux-x64-2.2.0.33/Include)
1720
include_directories(${PROJECT_SOURCE_DIR}/wrappers/cpp)
1821

OpenNI2-FreenectDriver/src/ColorStream.cpp

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ ColorStream::ColorStream(Freenect::FreenectDevice* pDevice) : VideoStream(pDevic
88
{
99
video_mode = makeOniVideoMode(ONI_PIXEL_FORMAT_RGB888, 640, 480, 30);
1010
setVideoMode(video_mode);
11+
pDevice->startVideo();
1112
}
1213

1314
// Add video modes here as you implement them
@@ -50,9 +51,10 @@ OniStatus ColorStream::setVideoMode(OniVideoMode requested_mode)
5051
void ColorStream::populateFrame(void* data, OniFrame* frame) const
5152
{
5253
frame->sensorType = sensor_type;
53-
frame->stride = video_mode.resolutionX*3;
54-
frame->cropOriginX = frame->cropOriginY = 0;
55-
frame->croppingEnabled = FALSE;
54+
frame->stride = video_mode.resolutionX * 3;
55+
frame->cropOriginX = 0;
56+
frame->cropOriginY = 0;
57+
frame->croppingEnabled = false;
5658

5759
// copy stream buffer from freenect
5860
switch (video_mode.pixelFormat)
@@ -62,28 +64,9 @@ void ColorStream::populateFrame(void* data, OniFrame* frame) const
6264
return;
6365

6466
case ONI_PIXEL_FORMAT_RGB888:
65-
unsigned char* data_ptr = static_cast<unsigned char*>(data);
66-
unsigned char* frame_data = static_cast<unsigned char*>(frame->data);
67-
if (mirroring)
68-
{
69-
for (int i = 0; i < frame->dataSize; i += 3)
70-
{
71-
// find corresponding mirrored pixel
72-
unsigned int pixel = i / 3;
73-
unsigned int row = pixel / video_mode.resolutionX;
74-
unsigned int col = video_mode.resolutionX - (pixel % video_mode.resolutionX);
75-
unsigned int target = 3 * (row * video_mode.resolutionX + col);
76-
// copy it to this pixel
77-
frame_data[i] = data_ptr[target];
78-
frame_data[i+1] = data_ptr[target+1];
79-
frame_data[i+2] = data_ptr[target+2];
80-
}
81-
}
82-
else
83-
{
84-
std::copy(data_ptr, data_ptr+frame->dataSize, frame_data);
85-
}
86-
67+
uint8_t* source = static_cast<uint8_t*>(data);
68+
uint8_t* target = static_cast<uint8_t*>(frame->data);
69+
std::copy(source, source + frame->dataSize, target);
8770
return;
8871
}
8972
}

OpenNI2-FreenectDriver/src/ColorStream.hpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ namespace FreenectDriver
3636
{
3737
FreenectVideoModeMap supported_modes = getSupportedVideoModes();
3838
OniVideoMode* modes = new OniVideoMode[supported_modes.size()];
39-
std::transform(supported_modes.begin(), supported_modes.end(), modes, RetrieveKey());
39+
std::transform(supported_modes.begin(), supported_modes.end(), modes, ExtractKey());
4040
OniSensorInfo sensors = { sensor_type, static_cast<int>(supported_modes.size()), modes };
4141
return sensors;
4242
}
@@ -139,6 +139,17 @@ namespace FreenectDriver
139139
int ret = device->setFlag(FREENECT_AUTO_WHITE_BALANCE, auto_exposure);
140140
return (ret == 0) ? ONI_STATUS_OK : ONI_STATUS_ERROR;
141141
}
142+
case ONI_STREAM_PROPERTY_MIRRORING: // OniBool
143+
{
144+
if (dataSize != sizeof(OniBool))
145+
{
146+
LogError("Unexpected size for ONI_STREAM_PROPERTY_MIRRORING");
147+
return ONI_STATUS_ERROR;
148+
}
149+
mirroring = *(static_cast<const OniBool*>(data));
150+
int ret = device->setFlag(FREENECT_MIRROR_VIDEO, mirroring);
151+
return (ret == 0) ? ONI_STATUS_OK : ONI_STATUS_ERROR;
152+
}
142153
}
143154
}
144155
};

0 commit comments

Comments
 (0)