Skip to content

Commit

Permalink
Merge tag 'v0.5.0' into dfsg
Browse files Browse the repository at this point in the history
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
  ...
  • Loading branch information
yarikoptic committed Oct 27, 2014
2 parents 29bc8ff + 8d95792 commit 9716fbf
Show file tree
Hide file tree
Showing 47 changed files with 6,060 additions and 4,201 deletions.
90 changes: 54 additions & 36 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,22 @@ set(PYTHON_EXECUTABLE "python2")

PROJECT(libfreenect)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/")

# Find the host operating system and architecture
include (FindOS)
# Set up installation directories
include (SetupDirectories)

set (PROJECT_VER_MAJOR 0)
set (PROJECT_VER_MINOR 4)
set (PROJECT_VER_MINOR 5)
set (PROJECT_VER_PATCH 0)
set (PROJECT_VER
set (PROJECT_VER
"${PROJECT_VER_MAJOR}.${PROJECT_VER_MINOR}.${PROJECT_VER_PATCH}")
set (PROJECT_APIVER
set (PROJECT_APIVER
"${PROJECT_VER_MAJOR}.${PROJECT_VER_MINOR}")

OPTION(BUILD_AUDIO "Build audio support" OFF)
OPTION(BUILD_REDIST_PACKAGE "Build libfreenect in a legally-redistributable manner (only affects audio)" OFF)
OPTION(BUILD_REDIST_PACKAGE "Build libfreenect in a legally-redistributable manner (only affects audio)" ON)
OPTION(BUILD_EXAMPLES "Build example programs" ON)
OPTION(BUILD_FAKENECT "Build fakenect mock library" ON)
OPTION(BUILD_C_SYNC "Build c synchronous library" ON)
Expand All @@ -58,20 +64,15 @@ OPTION(BUILD_AS3_SERVER "Build the Actionscript 3 Server Example" OFF)
OPTION(BUILD_PYTHON "Build Python extension" OFF)
OPTION(BUILD_OPENNI2_DRIVER "Build libfreenect driver for OpenNI2" OFF)
IF(PROJECT_OS_LINUX)
OPTION(BUILD_CPACK "Build an RPM or DEB using CPack" OFF)
OPTION(BUILD_CPACK_DEB "Build an DEB using CPack" OFF)
OPTION(BUILD_CPACK_RPM "Build an RPM using CPack" OFF)
OPTION(BUILD_CPACK_TGZ "Build an TGZ using CPack" OFF)
ENDIF(PROJECT_OS_LINUX)

######################################################################################
# CMake Modules
# Dependencies and Definitions
######################################################################################

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/")

# Find the host operating system and architecture
include (FindOS)
# Set up installation directories
include (SetupDirectories)

# Find packages needed to build library
find_package(libusb-1.0 REQUIRED)

Expand All @@ -82,33 +83,41 @@ if(BIG_ENDIAN)
add_definitions(-DFN_BIGENDIAN)
endif()

if(BUILD_AUDIO)
add_definitions(-DBUILD_AUDIO)
endif()

if (WIN32)
set(MATH_LIB "")
set(MATH_LIB "")
else(WIN32)
set(MATH_LIB "m")
endif()

######################################################################################
# CMake
# CMake
######################################################################################

SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
SET(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
SET(DOC_OUTPUT_PATH ${CMAKE_BINARY_DIR}/doc)

# let CFLAGS env override this
if(CMAKE_C_FLAGS STREQUAL "")
set(CMAKE_C_FLAGS "-O2")
endif()
SET(CMAKE_C_FLAGS_DEBUG "-g -DDEBUG=1")
SET(CMAKE_C_FLAGS_RELEASE "-O2")
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g")
if (MSVC)
set(C_FLAGS_WARNING "-W4")
else ()
set(C_FLAGS_WARNING "-Wall")
endif (MSVC)

set(C_CXX_FLAGS_DEFAULT "${C_FLAGS_WARNING} -O2")

add_definitions(-Wall)
# These defaults can be overriden by -DCMAKE_C_FLAGS=""
set(CMAKE_C_FLAGS "${C_CXX_FLAGS_DEFAULT} ${CMAKE_C_FLAGS}")
# C Configurations
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -g -DDEBUG=1")
SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS}")
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELEASE} -g")

# These defaults can be overriden by -DCMAKE_CXX_FLAGS=""
set(CMAKE_CXX_FLAGS "${C_CXX_FLAGS_DEFAULT} ${CMAKE_CXX_FLAGS}")
# C++ Configurations
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -g -DDEBUG=1")
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS}")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELEASE} -g")

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

if(WIN32)
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/platform/windows")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/platform/windows/libusb10emu/libusb-1.0")
endif()

# Add library project
add_subdirectory (src)

# Add examples
IF(BUILD_EXAMPLES)
add_subdirectory (examples)
ENDIF()
Expand Down Expand Up @@ -167,13 +174,17 @@ configure_file(
"${CMAKE_CURRENT_BINARY_DIR}/UninstallTarget.cmake"
IMMEDIATE @ONLY)

# --- cmake config file ---
CONFIGURE_FILE(libfreenectConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/libfreenectConfig.cmake @ONLY)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libfreenectConfig.cmake DESTINATION share/${PROJECT_NAME})

add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/UninstallTarget.cmake)

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

IF ( BUILD_CPACK )
IF ( BUILD_CPACK_TGZ OR BUILD_CPACK_DEB OR BUILD_CPACK_RPM )
set(CPACK_PACKAGE_DESCRIPTION "libfreenect for kinect")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "libfreenect library for using kinect")
set(CPACK_PACKAGE_NAME "libfreenect-dev")
Expand All @@ -186,20 +197,27 @@ IF ( BUILD_CPACK )
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VER_PATCH})
set(VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")

set(CPACK_GENERATOR "DEB;RPM;")
set(CPACK_GENERATOR "")
if (BUILD_CPACK_TGZ)
list(APPEND CPACK_GENERATOR "TGZ")
endif()
if (BUILD_CPACK_RPM)
list(APPEND CPACK_GENERATOR "RPM")
endif()
if (BUILD_CPACK_DEB)
list(APPEND CPACK_GENERATOR "DEB")
endif()
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}-${CMAKE_SYSTEM_PROCESSOR}")

include(CPack)

INSTALL(FILES "${CMAKE_BINARY_DIR}/lib/libfreenect.a" DESTINATION ${PROJECT_LIBRARY_INSTALL_DIR})
if (BUILD_AUDIO)
INSTALL(FILES "include/libfreenect_audio.h" DESTINATION ${PROJECT_INCLUDE_INSTALL_DIR})
endif()
INSTALL(FILES "include/libfreenect.h" DESTINATION ${PROJECT_INCLUDE_INSTALL_DIR})
INSTALL(FILES "include/libfreenect_registration.h" DESTINATION ${PROJECT_INCLUDE_INSTALL_DIR})
INSTALL(FILES "include/libfreenect_audio.h" DESTINATION ${PROJECT_INCLUDE_INSTALL_DIR})
INSTALL(FILES "APACHE20" DESTINATION "share/doc/${CPACK_PACKAGE_NAME}")
INSTALL(FILES "GPL2" DESTINATION "share/doc/${CPACK_PACKAGE_NAME}")
INSTALL(FILES "README.md" DESTINATION "share/doc/${CPACK_PACKAGE_NAME}")

ENDIF ( BUILD_CPACK )
ENDIF ( )

102 changes: 0 additions & 102 deletions HACKING

This file was deleted.

9 changes: 6 additions & 3 deletions OpenNI2-FreenectDriver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@
# OpenNI2-FreenectDriver
######################################################################################

file(GLOB HEADERS src/*.hpp src/*.h)
file(GLOB SOURCES src/*.cpp)
add_library(FreenectDriver SHARED ${SOURCES})
add_library(FreenectDriver SHARED ${HEADERS} ${SOURCES})

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

set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib/OpenNI2-FreenectDriver)
set_target_properties( FreenectDriver PROPERTIES
set_target_properties(FreenectDriver PROPERTIES
VERSION ${PROJECT_VER}
SOVERSION ${PROJECT_APIVER}
OUTPUT_NAME FreenectDriver)

add_definitions(-DPROJECT_VER="${PROJECT_VER}")

include_directories(extern/OpenNI-Linux-x64-2.2.0.33/Include)
include_directories(${PROJECT_SOURCE_DIR}/wrappers/cpp)

Expand Down
33 changes: 8 additions & 25 deletions OpenNI2-FreenectDriver/src/ColorStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ ColorStream::ColorStream(Freenect::FreenectDevice* pDevice) : VideoStream(pDevic
{
video_mode = makeOniVideoMode(ONI_PIXEL_FORMAT_RGB888, 640, 480, 30);
setVideoMode(video_mode);
pDevice->startVideo();
}

// Add video modes here as you implement them
Expand Down Expand Up @@ -50,9 +51,10 @@ OniStatus ColorStream::setVideoMode(OniVideoMode requested_mode)
void ColorStream::populateFrame(void* data, OniFrame* frame) const
{
frame->sensorType = sensor_type;
frame->stride = video_mode.resolutionX*3;
frame->cropOriginX = frame->cropOriginY = 0;
frame->croppingEnabled = FALSE;
frame->stride = video_mode.resolutionX * 3;
frame->cropOriginX = 0;
frame->cropOriginY = 0;
frame->croppingEnabled = false;

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

case ONI_PIXEL_FORMAT_RGB888:
unsigned char* data_ptr = static_cast<unsigned char*>(data);
unsigned char* frame_data = static_cast<unsigned char*>(frame->data);
if (mirroring)
{
for (int i = 0; i < frame->dataSize; i += 3)
{
// find corresponding mirrored pixel
unsigned int pixel = i / 3;
unsigned int row = pixel / video_mode.resolutionX;
unsigned int col = video_mode.resolutionX - (pixel % video_mode.resolutionX);
unsigned int target = 3 * (row * video_mode.resolutionX + col);
// copy it to this pixel
frame_data[i] = data_ptr[target];
frame_data[i+1] = data_ptr[target+1];
frame_data[i+2] = data_ptr[target+2];
}
}
else
{
std::copy(data_ptr, data_ptr+frame->dataSize, frame_data);
}

uint8_t* source = static_cast<uint8_t*>(data);
uint8_t* target = static_cast<uint8_t*>(frame->data);
std::copy(source, source + frame->dataSize, target);
return;
}
}
Expand Down
13 changes: 12 additions & 1 deletion OpenNI2-FreenectDriver/src/ColorStream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace FreenectDriver
{
FreenectVideoModeMap supported_modes = getSupportedVideoModes();
OniVideoMode* modes = new OniVideoMode[supported_modes.size()];
std::transform(supported_modes.begin(), supported_modes.end(), modes, RetrieveKey());
std::transform(supported_modes.begin(), supported_modes.end(), modes, ExtractKey());
OniSensorInfo sensors = { sensor_type, static_cast<int>(supported_modes.size()), modes };
return sensors;
}
Expand Down Expand Up @@ -139,6 +139,17 @@ namespace FreenectDriver
int ret = device->setFlag(FREENECT_AUTO_WHITE_BALANCE, auto_exposure);
return (ret == 0) ? ONI_STATUS_OK : ONI_STATUS_ERROR;
}
case ONI_STREAM_PROPERTY_MIRRORING: // OniBool
{
if (dataSize != sizeof(OniBool))
{
LogError("Unexpected size for ONI_STREAM_PROPERTY_MIRRORING");
return ONI_STATUS_ERROR;
}
mirroring = *(static_cast<const OniBool*>(data));
int ret = device->setFlag(FREENECT_MIRROR_VIDEO, mirroring);
return (ret == 0) ? ONI_STATUS_OK : ONI_STATUS_ERROR;
}
}
}
};
Expand Down
Loading

0 comments on commit 9716fbf

Please sign in to comment.