diff --git a/.gitignore b/.gitignore index 4f0c1f8bd..6926523a6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,4 @@ -# generated config file -examples/protonect/include/libfreenect2/config.h - -# generated resource file -examples/protonect/src/resources.inc.h -examples/protonect/build -examples/protonect/lib +build # Dependency folders depends/*/ diff --git a/examples/protonect/CMakeLists.txt b/CMakeLists.txt similarity index 56% rename from examples/protonect/CMakeLists.txt rename to CMakeLists.txt index 4a1db9bb6..07c839f2c 100644 --- a/examples/protonect/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12) +CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12.1) if(WIN32 AND NOT MINGW) if(NOT DEFINED CMAKE_DEBUG_POSTFIX) @@ -6,12 +6,18 @@ if(WIN32 AND NOT MINGW) endif() endif() +IF(NOT DEFINED CMAKE_BUILD_TYPE) + # No effect for multi-configuration generators (e.g. for Visual Studio) + SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose: RelWithDebInfo Release Debug MinSizeRel None") +ENDIF() + PROJECT(libfreenect2) -SET(CMAKE_BUILD_TYPE RelWithDebInfo) SET(MY_DIR ${libfreenect2_SOURCE_DIR}) -SET(DEPENDS_DIR "${MY_DIR}/../../depends" CACHE STRING "dependency directory must be set to 'false' if external deps are used") +SET(DEPENDS_DIR "${MY_DIR}/depends" CACHE STRING "dependency directory must be set to 'false' if external deps are used") +OPTION(BUILD_SHARED_LIBS "Build shared (ON) or static (OFF) libraries" ON) +OPTION(BUILD_EXAMPLES "Build examples" ON) OPTION(ENABLE_CXX11 "Enable C++11 support" OFF) OPTION(ENABLE_OPENCL "Enable OpenCL support" ON) OPTION(ENABLE_OPENGL "Enable OpenGL support" ON) @@ -39,10 +45,10 @@ INCLUDE(SetupLibfreenect2Threading) INCLUDE(GenerateResources) #set the default path for built executables to the "bin" directory -SET(EXECUTABLE_OUTPUT_PATH ${MY_DIR}/bin) +SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) #set the default path for built libraries to the "lib" directory -SET(LIBRARY_OUTPUT_PATH ${MY_DIR}/lib) +SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) # dependencies FIND_PACKAGE(PkgConfig) # try find PKGConfig as it will be used if found @@ -52,6 +58,8 @@ FIND_PACKAGE(TurboJPEG REQUIRED) #does not provide a package-config file # Add includes INCLUDE_DIRECTORIES( "${MY_DIR}/include" + "${MY_DIR}/include/internal" + ${PROJECT_BINARY_DIR} # for generated headers ${LIBFREENECT2_THREADING_INCLUDE_DIR} ${LibUSB_INCLUDE_DIRS} ${TurboJPEG_INCLUDE_DIRS} @@ -59,36 +67,36 @@ INCLUDE_DIRECTORIES( LINK_DIRECTORIES(${LibUSB_LIBRARY_DIRS}) -SET(RESOURCES_INC_FILE "${MY_DIR}/src/resources.inc.h") +SET(RESOURCES_INC_FILE "${PROJECT_BINARY_DIR}/resources.inc.h") +SET(CONFIG_H_FILE "${PROJECT_BINARY_DIR}/libfreenect2/config.h") SET(SOURCES - include/libfreenect2/protocol/command.h - include/libfreenect2/protocol/command_transaction.h - include/libfreenect2/protocol/response.h - include/libfreenect2/protocol/usb_control.h - - include/libfreenect2/usb/event_loop.h - include/libfreenect2/usb/transfer_pool.h + include/internal/libfreenect2/protocol/command.h + include/internal/libfreenect2/protocol/command_transaction.h + include/internal/libfreenect2/protocol/response.h + include/internal/libfreenect2/protocol/usb_control.h + + include/internal/libfreenect2/usb/event_loop.h + include/internal/libfreenect2/usb/transfer_pool.h include/libfreenect2/logger.h - include/libfreenect2/logging.h + include/internal/libfreenect2/logging.h - include/libfreenect2/async_packet_processor.h + include/internal/libfreenect2/async_packet_processor.h include/libfreenect2/depth_packet_processor.h - include/libfreenect2/depth_packet_stream_parser.h - include/libfreenect2/double_buffer.h + include/internal/libfreenect2/depth_packet_stream_parser.h + include/internal/libfreenect2/double_buffer.h include/libfreenect2/frame_listener.hpp include/libfreenect2/frame_listener_impl.h - include/libfreenect2/config.h include/libfreenect2/libfreenect2.hpp include/libfreenect2/packet_pipeline.h include/libfreenect2/packet_processor.h include/libfreenect2/registration.h - include/libfreenect2/resource.h + include/internal/libfreenect2/resource.h include/libfreenect2/rgb_packet_processor.h - include/libfreenect2/rgb_packet_stream_parser.h - include/libfreenect2/threading.h - + include/internal/libfreenect2/rgb_packet_stream_parser.h + include/internal/libfreenect2/threading.h + src/transfer_pool.cpp src/event_loop.cpp src/usb_control.cpp @@ -106,9 +114,10 @@ SET(SOURCES src/registration.cpp src/logging.cpp src/libfreenect2.cpp - + ${LIBFREENECT2_THREADING_SOURCE} ${RESOURCES_INC_FILE} + ${CONFIG_H_FILE} ) SET(LIBRARIES @@ -118,9 +127,9 @@ SET(LIBRARIES ) SET(RESOURCES - 11to16.bin - xTable.bin - zTable.bin + data/11to16.bin + data/xTable.bin + data/zTable.bin ) IF(ENABLE_OPENGL) @@ -136,10 +145,10 @@ IF(ENABLE_OPENGL) ) SET(LIBFREENECT2_WITH_OPENGL_SUPPORT 1) LIST(APPEND SOURCES - src/flextGL.c + src/flextGL.cpp src/opengl_depth_packet_processor.cpp ) - + LIST(APPEND RESOURCES src/shader/debug.fs src/shader/default.vs @@ -154,10 +163,10 @@ ENDIF(ENABLE_OPENGL) IF(ENABLE_OPENCL) FIND_PACKAGE(OpenCL) - IF(OPENCL_FOUND) + IF(OPENCL_FOUND) SET(LIBFREENECT2_WITH_OPENCL_SUPPORT 1) INCLUDE_DIRECTORIES(${OPENCL_INCLUDE_DIRS}) - + LIST(APPEND SOURCES src/opencl_depth_packet_processor.cpp ) @@ -165,7 +174,7 @@ IF(ENABLE_OPENCL) LIST(APPEND LIBRARIES ${OPENCL_LIBRARIES} ) - + LIST(APPEND RESOURCES src/opencl_depth_packet_processor.cl ) @@ -179,54 +188,56 @@ IF(ENABLE_OPENCL) ENDIF(OPENCL_FOUND) ENDIF(ENABLE_OPENCL) -SET(CMAKE_INSTALL_RPATH ${LibUSB_LIBDIR}) +# RPATH handling for private libusb copies +# Users have two options: +# 1. Build libusb in depends/ and leave it there: +# Do NOT set CMAKE_INSTALL_RPATH. It works by default. +# 2. Build libusb and install it somewhere: +# Set CMAKE_INSTALL_RPATH to the libusb.so installation directory before compiling. +# Both command line -DCMAKE_INSTALL_RPATH=... and CMake GUI settings are accepted. +# +# Anyway if wrong versions of libusb is used, errors will be reported explicitly. +IF(NOT DEFINED CMAKE_INSTALL_RPATH) + SET(CMAKE_INSTALL_RPATH ${LibUSB_LIBDIR} CACHE STRING "Set RPATH for a private libusb") +ELSE() + SET(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH} CACHE STRING "Set RPATH for a private libusb") +ENDIF() +IF(DEFINED CMAKE_INSTALL_RPATH) + MESSAGE(STATUS "RPATH set to ${CMAKE_INSTALL_RPATH}") +ENDIF() -CONFIGURE_FILE("${MY_DIR}/include/libfreenect2/config.h.in" "${MY_DIR}/include/libfreenect2/config.h" @ONLY) +CONFIGURE_FILE("${MY_DIR}/include/libfreenect2/config.h.in" "${CONFIG_H_FILE}" @ONLY) GENERATE_RESOURCES(${RESOURCES_INC_FILE} ${MY_DIR} ${RESOURCES}) ADD_DEFINITIONS(-DRESOURCES_INC) -ADD_LIBRARY(freenect2 OBJECT ${SOURCES}) -set_target_properties(freenect2 PROPERTIES POSITION_INDEPENDENT_CODE 1) -ADD_LIBRARY(freenect2shared SHARED $) -ADD_LIBRARY(freenect2static STATIC $) -set_target_properties(freenect2shared PROPERTIES OUTPUT_NAME freenect2) -set_target_properties(freenect2static PROPERTIES OUTPUT_NAME freenect2) -IF(MSVC) - set_target_properties(freenect2static PROPERTIES OUTPUT_NAME freenect2static) -ENDIF() -MESSAGE("Linking with these libraries: ${LIBRARIES}") -TARGET_LINK_LIBRARIES(freenect2shared ${LIBRARIES}) - -SET(Protonect_src - Protonect.cpp - ) - -IF (ENABLE_OPENGL AND OPENGL_FOUND) - LIST(APPEND Protonect_src - viewer.h - viewer.cpp - src/flextGL.c - ) -ENDIF() - -ADD_EXECUTABLE(Protonect - ${Protonect_src} - -) - -TARGET_LINK_LIBRARIES(Protonect - freenect2shared +SET(CMAKE_CXX_VISIBILITY_PRESET hidden) +SET(CMAKE_C_VISIBILITY_PRESET hidden) +SET(CMAKE_VISIBILITY_INLINES_HIDDEN 1) +INCLUDE(GenerateExportHeader) + +ADD_LIBRARY(freenect2 ${SOURCES}) +GENERATE_EXPORT_HEADER(freenect2 + BASE_NAME libfreenect2 ) +IF(MSVC AND NOT BUILD_SHARED_LIBS) + # MSVC creates freenect2.lib for both dynamic and static by default + set_target_properties(freenect2 PROPERTIES SUFFIX "static.lib") +ENDIF() +MESSAGE(STATUS "Linking with these libraries: ${LIBRARIES}") +TARGET_LINK_LIBRARIES(freenect2 ${LIBRARIES}) + CONFIGURE_FILE(freenect2.cmake.in "${PROJECT_BINARY_DIR}/freenect2Config.cmake" @ONLY) CONFIGURE_FILE(freenect2.pc.in "${PROJECT_BINARY_DIR}/freenect2.pc" @ONLY) -INSTALL(TARGETS freenect2shared DESTINATION lib) -INSTALL(TARGETS freenect2static DESTINATION lib) -INSTALL(DIRECTORY "${MY_DIR}/include/" DESTINATION include PATTERN "*.in" EXCLUDE) -IF(LIBFREENECT2_THREADING_TINYTHREAD) - INSTALL(FILES "${MY_DIR}/src/tinythread/tinythread.h" DESTINATION include/${PROJECT_NAME}/tinythread/) -ENDIF(LIBFREENECT2_THREADING_TINYTHREAD) +INSTALL(TARGETS freenect2 DESTINATION lib) +INSTALL(DIRECTORY "${MY_DIR}/include/${PROJECT_NAME}" DESTINATION include PATTERN "*.in" EXCLUDE) +INSTALL(FILES "${CONFIG_H_FILE}" DESTINATION include/${PROJECT_NAME}) +INSTALL(FILES "${PROJECT_BINARY_DIR}/libfreenect2_export.h" DESTINATION include/${PROJECT_NAME}) INSTALL(FILES "${PROJECT_BINARY_DIR}/freenect2Config.cmake" DESTINATION lib/cmake/freenect2/) INSTALL(FILES "${PROJECT_BINARY_DIR}/freenect2.pc" DESTINATION lib/pkgconfig/) - + +IF(BUILD_EXAMPLES) + MESSAGE(STATUS "Configurating examples") + ADD_SUBDIRECTORY(${MY_DIR}/examples) +ENDIF() diff --git a/README.md b/README.md index 349f03365..9f535a8f0 100644 --- a/README.md +++ b/README.md @@ -136,7 +136,6 @@ Joshua Blake provided a Debug version binary: https://www.dropbox.com/s/madoye1a #### Build ``` -cd example\protonect mkdir build && cd build cmake .. -G "Visual Studio 12 2013 Win64" -DCMAKE_INSTALL_PREFIX=. cmake --build . --config Release --target install @@ -180,7 +179,6 @@ sh ./depends/install_mac.sh 1. Build the actual protonect executable ``` -cd ./examples/protonect/ mkdir build && cd build cmake .. make @@ -221,7 +219,6 @@ sudo dpkg -i libglfw3*_3.0.4-1_*.deb # Ubuntu 14.04 only 1. Build the actual protonect executable ``` -cd ../examples/protonect/ mkdir build && cd build cmake .. make @@ -238,23 +235,6 @@ sudo make install I'm not sure, but look for libusbx installation instructions for your OS. Figure out how to attach the driver to the Xbox NUI Sensor composite parent device, VID 045E PID 02C4, then contribute your procedure. -## Building - -Make sure you install the driver as describe above first. - -1. Follow directions in the ./depends/README.depends.txt to get the dependencies. (Process may be streamlined later.) - -### Windows / Visual Studio - - 1. Use CMake to generate a solution. - 2. Build and run. - -### Other platforms - -2. ? -3. Build and run. -4. Contribute your solution for your platform back to the project please. - ## Required notification The K4W2 hardware is currently pre-release. Per the K4W2 developer program agreement, all public demonstrations and code should display this notice: diff --git a/examples/protonect/cmake_modules/FindGLFW3.cmake b/cmake_modules/FindGLFW3.cmake similarity index 100% rename from examples/protonect/cmake_modules/FindGLFW3.cmake rename to cmake_modules/FindGLFW3.cmake diff --git a/examples/protonect/cmake_modules/FindLibUSB.cmake b/cmake_modules/FindLibUSB.cmake similarity index 100% rename from examples/protonect/cmake_modules/FindLibUSB.cmake rename to cmake_modules/FindLibUSB.cmake diff --git a/examples/protonect/cmake_modules/FindOpenCL.cmake b/cmake_modules/FindOpenCL.cmake similarity index 100% rename from examples/protonect/cmake_modules/FindOpenCL.cmake rename to cmake_modules/FindOpenCL.cmake diff --git a/examples/protonect/cmake_modules/FindTurboJPEG.cmake b/cmake_modules/FindTurboJPEG.cmake similarity index 100% rename from examples/protonect/cmake_modules/FindTurboJPEG.cmake rename to cmake_modules/FindTurboJPEG.cmake diff --git a/examples/protonect/cmake_modules/GenerateResources.cmake b/cmake_modules/GenerateResources.cmake similarity index 90% rename from examples/protonect/cmake_modules/GenerateResources.cmake rename to cmake_modules/GenerateResources.cmake index 712e02b11..8616e38ec 100644 --- a/examples/protonect/cmake_modules/GenerateResources.cmake +++ b/cmake_modules/GenerateResources.cmake @@ -1,7 +1,7 @@ FUNCTION(GENERATE_RESOURCES OUTPUT BASE_FOLDER) ADD_EXECUTABLE(generate_resources_tool - src/generate_resources.cpp + tools/generate_resources.cpp ) ADD_CUSTOM_COMMAND( diff --git a/examples/protonect/cmake_modules/SetupLibfreenect2Threading.cmake b/cmake_modules/SetupLibfreenect2Threading.cmake similarity index 100% rename from examples/protonect/cmake_modules/SetupLibfreenect2Threading.cmake rename to cmake_modules/SetupLibfreenect2Threading.cmake diff --git a/examples/protonect/11to16.bin b/data/11to16.bin similarity index 100% rename from examples/protonect/11to16.bin rename to data/11to16.bin diff --git a/examples/protonect/xTable.bin b/data/xTable.bin similarity index 100% rename from examples/protonect/xTable.bin rename to data/xTable.bin diff --git a/examples/protonect/zTable.bin b/data/zTable.bin similarity index 100% rename from examples/protonect/zTable.bin rename to data/zTable.bin diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt new file mode 100644 index 000000000..bff902fa0 --- /dev/null +++ b/examples/CMakeLists.txt @@ -0,0 +1,80 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12.1) + +if(WIN32 AND NOT MINGW) + if(NOT DEFINED CMAKE_DEBUG_POSTFIX) + set(CMAKE_DEBUG_POSTFIX "d") + endif() +endif() + +IF(NOT DEFINED CMAKE_BUILD_TYPE) + # No effect for multi-configuration generators (e.g. for Visual Studio) + SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose: RelWithDebInfo Release Debug MinSizeRel None") +ENDIF() + +PROJECT(libfreenect2_examples) + +SET(MY_DIR ${libfreenect2_examples_SOURCE_DIR}) +SET(DEPENDS_DIR "${MY_DIR}/../depends" CACHE STRING "Dependency directory") + +OPTION(ENABLE_OPENGL "Enable OpenGL support" ON) + +# The example build system is standalone and will work out-of-tree with these files copied +SET(freenect2_ROOT_DIR ${MY_DIR}/..) +SET(flextGL_SOURCES ${freenect2_ROOT_DIR}/src/flextGL.cpp) +SET(flextGL_INCLUDE_DIRS ${freenect2_ROOT_DIR}/src) # for flextGL.h + +FIND_PACKAGE(PkgConfig) # try find PKGConfig as it will be used if found +LIST(APPEND CMAKE_MODULE_PATH ${freenect2_ROOT_DIR}/cmake_modules) # FindGLFW3.cmake + +IF(TARGET freenect2) + MESSAGE(STATUS "Using in-tree freenect2 target") + SET(freenect2_LIBRARIES freenect2) +ELSE() + FIND_PACKAGE(freenect2 REQUIRED) +ENDIF() + +INCLUDE_DIRECTORIES( + ${freenect2_INCLUDE_DIR} +) + +LINK_DIRECTORIES( + ${freenect2_LIBRARY_DIRS} +) + +SET(Protonect_src + Protonect.cpp +) + +SET(Protonect_LIBRARIES + ${freenect2_LIBRARIES} +) + +IF(ENABLE_OPENGL) + FIND_PACKAGE(GLFW3) + FIND_PACKAGE(OpenGL) + IF(GLFW3_FOUND AND OPENGL_FOUND) + INCLUDE_DIRECTORIES( + ${GLFW3_INCLUDE_DIRS} + ${flextGL_INCLUDE_DIRS} + ) + + LINK_DIRECTORIES(${GLFW3_LIBRARY_DIRS}) + LIST(APPEND Protonect_src + viewer.cpp + ${flextGL_SOURCES} + ) + LIST(APPEND Protonect_LIBRARIES + ${GLFW3_LIBRARIES} + ${OPENGL_gl_LIBRARY} + ) + ADD_DEFINITIONS(-DEXAMPLES_WITH_OPENGL_SUPPORT=1) + ENDIF() +ENDIF(ENABLE_OPENGL) + +ADD_EXECUTABLE(Protonect + ${Protonect_src} +) + +TARGET_LINK_LIBRARIES(Protonect + ${Protonect_LIBRARIES} +) diff --git a/examples/protonect/Protonect.cpp b/examples/Protonect.cpp similarity index 97% rename from examples/protonect/Protonect.cpp rename to examples/Protonect.cpp index acb0d294e..54ced3cb3 100644 --- a/examples/protonect/Protonect.cpp +++ b/examples/Protonect.cpp @@ -31,11 +31,10 @@ #include #include -#include #include #include #include -#ifdef LIBFREENECT2_WITH_OPENGL_SUPPORT +#ifdef EXAMPLES_WITH_OPENGL_SUPPORT #include "viewer.h" #endif @@ -186,7 +185,7 @@ int main(int argc, char *argv[]) libfreenect2::Registration* registration = new libfreenect2::Registration(dev->getIrCameraParams(), dev->getColorCameraParams()); size_t framecount = 0; -#ifdef LIBFREENECT2_WITH_OPENGL_SUPPORT +#ifdef EXAMPLES_WITH_OPENGL_SUPPORT Viewer viewer; if (viewer_enabled) viewer.initialize(); @@ -212,7 +211,7 @@ int main(int argc, char *argv[]) continue; } -#ifdef LIBFREENECT2_WITH_OPENGL_SUPPORT +#ifdef EXAMPLES_WITH_OPENGL_SUPPORT viewer.addFrame("RGB", rgb); viewer.addFrame("ir", ir); viewer.addFrame("depth", depth); diff --git a/examples/protonect/src/test_opengl_depth_packet_processor.cpp b/examples/test_opengl_depth_packet_processor.cpp similarity index 100% rename from examples/protonect/src/test_opengl_depth_packet_processor.cpp rename to examples/test_opengl_depth_packet_processor.cpp diff --git a/examples/protonect/viewer.cpp b/examples/viewer.cpp similarity index 100% rename from examples/protonect/viewer.cpp rename to examples/viewer.cpp diff --git a/examples/protonect/viewer.h b/examples/viewer.h similarity index 99% rename from examples/protonect/viewer.h rename to examples/viewer.h index dada47f74..8f318d56d 100644 --- a/examples/protonect/viewer.h +++ b/examples/viewer.h @@ -7,7 +7,7 @@ #include #include -#include <../src/flextGL.h> +#include "flextGL.h" #include struct Vertex diff --git a/examples/protonect/freenect2.cmake.in b/freenect2.cmake.in similarity index 62% rename from examples/protonect/freenect2.cmake.in rename to freenect2.cmake.in index 677dd59f3..0b5c628e0 100644 --- a/examples/protonect/freenect2.cmake.in +++ b/freenect2.cmake.in @@ -7,7 +7,3 @@ FIND_PATH(freenect2_INCLUDE_DIR @PROJECT_NAME@/libfreenect2.hpp PATHS @CMAKE_INSTALL_PREFIX@/include NO_DEFAULT_PATH ) - -IF("@LIBFREENECT2_THREADING_TINYTHREAD@") - SET(freenect2_INCLUDE_DIRS ${freenect2_INCLUDE_DIR} ${freenect2_INCLUDE_DIR}/tinythread) -ENDIF("@LIBFREENECT2_THREADING_TINYTHREAD@") diff --git a/examples/protonect/freenect2.pc.in b/freenect2.pc.in similarity index 100% rename from examples/protonect/freenect2.pc.in rename to freenect2.pc.in diff --git a/examples/protonect/include/libfreenect2/async_packet_processor.h b/include/internal/libfreenect2/async_packet_processor.h similarity index 100% rename from examples/protonect/include/libfreenect2/async_packet_processor.h rename to include/internal/libfreenect2/async_packet_processor.h diff --git a/examples/protonect/include/libfreenect2/data_callback.h b/include/internal/libfreenect2/data_callback.h similarity index 97% rename from examples/protonect/include/libfreenect2/data_callback.h rename to include/internal/libfreenect2/data_callback.h index 63cc4eece..9fb2800ef 100644 --- a/examples/protonect/include/libfreenect2/data_callback.h +++ b/include/internal/libfreenect2/data_callback.h @@ -35,7 +35,7 @@ namespace libfreenect2 { -class LIBFREENECT2_API DataCallback +class DataCallback { public: /** diff --git a/examples/protonect/include/libfreenect2/depth_packet_stream_parser.h b/include/internal/libfreenect2/depth_packet_stream_parser.h similarity index 94% rename from examples/protonect/include/libfreenect2/depth_packet_stream_parser.h rename to include/internal/libfreenect2/depth_packet_stream_parser.h index aaab7bb95..cf3249d2c 100644 --- a/examples/protonect/include/libfreenect2/depth_packet_stream_parser.h +++ b/include/internal/libfreenect2/depth_packet_stream_parser.h @@ -43,7 +43,7 @@ namespace libfreenect2 { /** Footer of a depth packet. */ -LIBFREENECT2_PACK(struct LIBFREENECT2_API DepthSubPacketFooter +LIBFREENECT2_PACK(struct DepthSubPacketFooter { uint32_t magic0; uint32_t magic1; @@ -58,7 +58,7 @@ LIBFREENECT2_PACK(struct LIBFREENECT2_API DepthSubPacketFooter * Parser of th depth stream, recognizes valid depth packets in the stream, and * passes them on for further processing. */ -class LIBFREENECT2_API DepthPacketStreamParser : public DataCallback +class DepthPacketStreamParser : public DataCallback { public: DepthPacketStreamParser(); diff --git a/examples/protonect/include/libfreenect2/double_buffer.h b/include/internal/libfreenect2/double_buffer.h similarity index 96% rename from examples/protonect/include/libfreenect2/double_buffer.h rename to include/internal/libfreenect2/double_buffer.h index 4018447f0..54f52ba25 100644 --- a/examples/protonect/include/libfreenect2/double_buffer.h +++ b/include/internal/libfreenect2/double_buffer.h @@ -36,7 +36,7 @@ namespace libfreenect2 { /** Data of a single buffer. */ -struct LIBFREENECT2_API Buffer +struct Buffer { public: size_t capacity; ///< Capacity of the buffer. @@ -45,7 +45,7 @@ struct LIBFREENECT2_API Buffer }; /** Double bufffer class. */ -class LIBFREENECT2_API DoubleBuffer +class DoubleBuffer { public: DoubleBuffer(); diff --git a/examples/protonect/include/libfreenect2/logging.h b/include/internal/libfreenect2/logging.h similarity index 100% rename from examples/protonect/include/libfreenect2/logging.h rename to include/internal/libfreenect2/logging.h diff --git a/examples/protonect/include/libfreenect2/protocol/command.h b/include/internal/libfreenect2/protocol/command.h similarity index 100% rename from examples/protonect/include/libfreenect2/protocol/command.h rename to include/internal/libfreenect2/protocol/command.h diff --git a/examples/protonect/include/libfreenect2/protocol/command_transaction.h b/include/internal/libfreenect2/protocol/command_transaction.h similarity index 100% rename from examples/protonect/include/libfreenect2/protocol/command_transaction.h rename to include/internal/libfreenect2/protocol/command_transaction.h diff --git a/examples/protonect/include/libfreenect2/protocol/response.h b/include/internal/libfreenect2/protocol/response.h similarity index 100% rename from examples/protonect/include/libfreenect2/protocol/response.h rename to include/internal/libfreenect2/protocol/response.h diff --git a/examples/protonect/include/libfreenect2/protocol/usb_control.h b/include/internal/libfreenect2/protocol/usb_control.h similarity index 100% rename from examples/protonect/include/libfreenect2/protocol/usb_control.h rename to include/internal/libfreenect2/protocol/usb_control.h diff --git a/examples/protonect/include/libfreenect2/resource.h b/include/internal/libfreenect2/resource.h similarity index 100% rename from examples/protonect/include/libfreenect2/resource.h rename to include/internal/libfreenect2/resource.h diff --git a/examples/protonect/include/libfreenect2/rgb_packet_stream_parser.h b/include/internal/libfreenect2/rgb_packet_stream_parser.h similarity index 96% rename from examples/protonect/include/libfreenect2/rgb_packet_stream_parser.h rename to include/internal/libfreenect2/rgb_packet_stream_parser.h index 9c8bfa7e9..be099eb34 100644 --- a/examples/protonect/include/libfreenect2/rgb_packet_stream_parser.h +++ b/include/internal/libfreenect2/rgb_packet_stream_parser.h @@ -41,7 +41,7 @@ namespace libfreenect2 { /** Parser for getting an RGB packet from the stream. */ -class LIBFREENECT2_API RgbPacketStreamParser : public DataCallback +class RgbPacketStreamParser : public DataCallback { public: RgbPacketStreamParser(); diff --git a/examples/protonect/include/libfreenect2/threading.h b/include/internal/libfreenect2/threading.h similarity index 100% rename from examples/protonect/include/libfreenect2/threading.h rename to include/internal/libfreenect2/threading.h diff --git a/examples/protonect/include/libfreenect2/usb/event_loop.h b/include/internal/libfreenect2/usb/event_loop.h similarity index 100% rename from examples/protonect/include/libfreenect2/usb/event_loop.h rename to include/internal/libfreenect2/usb/event_loop.h diff --git a/examples/protonect/include/libfreenect2/usb/transfer_pool.h b/include/internal/libfreenect2/usb/transfer_pool.h similarity index 100% rename from examples/protonect/include/libfreenect2/usb/transfer_pool.h rename to include/internal/libfreenect2/usb/transfer_pool.h diff --git a/include/libfreenect2.h b/include/libfreenect2.h deleted file mode 100644 index 31c9f0b9a..000000000 --- a/include/libfreenect2.h +++ /dev/null @@ -1,506 +0,0 @@ -/* - * This file is part of the OpenKinect Project. http://www.openkinect.org - * - * Copyright (c) 2014 individual OpenKinect contributors. See the CONTRIB file - * for details. - * - * This code is licensed to you under the terms of the Apache License, version - * 2.0, or, at your option, the terms of the GNU General Public License, - * version 2.0. See the APACHE20 and GPL2 files for the text of the licenses, - * or the following URLs: - * http://www.apache.org/licenses/LICENSE-2.0 - * http://www.gnu.org/licenses/gpl-2.0.txt - * - * If you redistribute this file in source form, modified or unmodified, you - * may: - * 1) Leave this header intact and distribute it under the same terms, - * accompanying it with the APACHE20 and GPL20 files, or - * 2) Delete the Apache 2.0 clause and accompany it with the GPL2 file, or - * 3) Delete the GPL v2 clause and accompany it with the APACHE20 file - * In all cases you must keep the copyright notice intact and include a copy - * of the CONTRIB file. - * - * Binary distributions must follow the binary distribution requirements of - * either License. - */ - -/** @file libfreenect2.h Frrenect2 library file. */ - -#pragma once - -#include - -/* We need struct timeval */ -#ifdef _WIN32 -#include -#else -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif - - -/** - * A struct used in enumeration to give access to serial numbers, so you can - * open a particular device by serial rather than depending on index. This - * is most useful if you have more than one Kinect. - */ -struct freenect2_device_attributes; -struct freenect2_device_attributes { - const char* camera_serial; /**< Serial number of this device's camera subdevice */ -}; - -/** - * Enumeration of available resolutions. - * Not all available resolutions are actually supported for all video formats. - * Frame modes may not perfectly match resolutions. - */ -typedef enum { - FREENECT2_RESOLUTION_512x424 = 0, - FREENECT2_RESOLUTION_1920x1080 = 1, - FREENECT2_RESOLUTION_DUMMY = 2147483647, /**< Dummy value to force enum to be 32 bits wide */ -} freenect2_resolution; - -/** Enumeration of video frame formats. */ -typedef enum { - FREENECT2_VIDEO_RGB = 0, /**< Decompressed RGB mode */ - FREENECT2_VIDEO_YUV = 0, /**< Decompressed YUV mode */ - FREENECT2_VIDEO_RAW = 0, /**< Raw JPEG data mode */ - FREENECT2_VIDEO_DUMMY = 2147483647, /**< Dummy value to force enum to be 32 bits wide */ -} freenect2_video_format; - -/** Enumeration of ir frame formats. */ -typedef enum { - FREENECT2_IR_RAW = 5, /**< raw infrared data */ - FREENECT2_IR_DUMMY = 2147483647, /**< Dummy value to force enum to be 32 bits wide */ -} freenect2_ir_format; - -/** Enumeration of depth frame formats. */ -typedef enum { - FREENECT2_DEPTH_MM = 5, /**< depth to each pixel in mm, but left unaligned to RGB image */ - FREENECT2_DEPTH_DUMMY = 2147483647, /**< Dummy value to force enum to be 32 bits wide */ -} freenect2_depth_format; - -/** Enumeration of flags to toggle features with #freenect2_set_flag(). */ -typedef enum { - // arbitrary bitfields to support flag combination - FREENECT2_MIRROR_DEPTH = 1 << 16, - FREENECT2_MIRROR_VIDEO = 1 << 17, -} freenect2_flag; - -/** Possible values for setting each `freenect2_flag`. */ -typedef enum { - FREENECT2_OFF = 0, - FREENECT2_ON = 1, -} freenect2_flag_value; - -/** - * Structure to give information about the width, height, bitrate, - * framerate, and buffer size of a frame in a particular mode, as - * well as the total number of bytes needed to hold a single frame. - */ -typedef struct { - uint32_t reserved; /**< unique ID used internally. The meaning of values may change without notice. Don't touch or depend on the contents of this field. We mean it. */ - freenect2_resolution resolution; /**< Resolution this freenect2_frame_mode describes, should you want to find it again with freenect2_find_*_frame_mode(). */ - union { - int32_t dummy; - freenect2_video_format video_format; - freenect2_ir_format ir_format; - freenect2_depth_format depth_format; - }; /**< The video or depth format that this freenect2_frame_mode describes. The caller should know which of video_format or depth_format to use, since they called freenect2_get_*_frame_mode() */ - int32_t bytes; /**< Total buffer size in bytes to hold a single frame of data. Should be equivalent to width * height * (data_bits_per_pixel+padding_bits_per_pixel) / 8 */ - int16_t width; /**< Width of the frame, in pixels */ - int16_t height; /**< Height of the frame, in pixels */ - int8_t data_bits_per_pixel; /**< Number of bits of information needed for each pixel */ - int8_t padding_bits_per_pixel; /**< Number of bits of padding for alignment used for each pixel */ - int8_t framerate; /**< Approximate expected frame rate, in Hz */ - int8_t is_valid; /**< If 0, this freenect2_frame_mode is invalid and does not describe a supported mode. Otherwise, the frame_mode is valid. */ -} freenect2_frame_mode; - -struct _freenect2_context; -typedef struct _freenect2_context freenect2_context; /**< Holds information about the usb context. */ - -struct _freenect2_device; -typedef struct _freenect2_device freenect2_device; /**< Holds device information. */ - -// usb backend specific section -typedef void freenect2_usb_context; /**< Holds libusb-1.0 context */ -// - -/// If Win32, export all functions for DLL usage -#ifndef _WIN32 - #define FREENECT2API /**< DLLExport information for windows, set to nothing on other platforms */ -#else - /**< DLLExport information for windows, set to nothing on other platforms */ - #ifdef __cplusplus - #define FREENECT2API extern "C" __declspec(dllexport) - #else - // this is required when building from a Win32 port of gcc without being - // forced to compile all of the library files (.c) with g++... - #define FREENECT2API __declspec(dllexport) - #endif -#endif - -/** Enumeration of message logging levels. */ -typedef enum { - FREENECT2_LOG_FATAL = 0, /**< Log for crashing/non-recoverable errors */ - FREENECT2_LOG_ERROR, /**< Log for major errors */ - FREENECT2_LOG_WARNING, /**< Log for warning messages */ - FREENECT2_LOG_NOTICE, /**< Log for important messages */ - FREENECT2_LOG_INFO, /**< Log for normal messages */ - FREENECT2_LOG_DEBUG, /**< Log for useful development messages */ - FREENECT2_LOG_SPEW, /**< Log for slightly less useful messages */ - FREENECT2_LOG_FLOOD, /**< Log EVERYTHING. May slow performance. */ -} freenect2_loglevel; - -/** - * Initialize a freenect2 context and do any setup required for - * platform specific USB libraries. - * - * @param ctx Address of pointer to freenect2 context struct to allocate and initialize - * @param usb_ctx USB context to initialize. Can be NULL if not using multiple contexts. - * - * @return 0 on success, < 0 on error - */ -FREENECT2API int freenect2_init(freenect2_context **ctx, freenect2_usb_context *usb_ctx); - -/** - * Closes the device if it is open, and frees the context - * - * @param ctx freenect2 context to close/free - * - * @return 0 on success - */ -FREENECT2API int freenect2_shutdown(freenect2_context *ctx); - -/** Typedef for logging callback functions */ -typedef void (*freenect2_log_cb)(freenect2_context *dev, freenect2_loglevel level, const char *msg); - -/** - * Set the log level for the specified freenect2 context - * - * @param ctx context to set log level for - * @param level log level to use (see freenect_loglevel enum) - */ -FREENECT2API void freenect2_set_log_level(freenect2_context *ctx, freenect2_loglevel level); - -/** - * Callback for log messages (i.e. for rerouting to a file instead of - * stdout) - * - * @param ctx context to set log callback for - * @param cb callback function pointer - */ -FREENECT2API void freenect2_set_log_callback(freenect2_context *ctx, freenect2_log_cb cb); - -/** - * Scans for kinect devices and returns the number of kinect devices currently connected to the - * system - * - * @param ctx Context to access device count through - * - * @return Number of devices connected, < 0 on error - */ -FREENECT2API int freenect2_num_devices(freenect2_context *ctx); - -/** - * Gets the attributes of a kinect device at a given index. - * - * @param ctx Context to access device attributes through - * @param index Index of the kinect device - * - * @return Number of devices connected, < 0 on error - */ -FREENECT2API freenect2_device_attributes freenect2_get_device_attributes(freenect2_context *ctx, int index); - -/** - * Opens a kinect device via a context. Index specifies the index of - * the device on the current state of the bus. Bus resets may cause - * indexes to shift. - * - * @param ctx Context to open device through - * @param dev Device structure to assign opened device to - * @param index Index of the device on the bus - * - * @return 0 on success, < 0 on error - */ -FREENECT2API int freenect2_open_device(freenect2_context *ctx, freenect2_device **dev, int index); - -/** - * Opens a kinect device (via a context) associated with a particular camera - * subdevice serial number. This function will fail if no device with a - * matching serial number is found. - * - * @param ctx Context to open device through - * @param dev Device structure to assign opened device to - * @param camera_serial Null-terminated ASCII string containing the serial number of the camera subdevice in the device to open - * - * @return 0 on success, < 0 on error - */ -FREENECT2API int freenect2_open_device_by_camera_serial(freenect2_context *ctx, freenect2_device **dev, const char* camera_serial); - -/** - * Closes a device that is currently open - * - * @param dev Device to close - * - * @return 0 on success - */ -FREENECT2API int freenect2_close_device(freenect2_device *dev); - -/** Typedef for depth image received event callbacks. */ -typedef void (*freenect2_depth_cb)(freenect2_device *dev, uint32_t timestamp, void *depth, void *user); -/** Typedef for ir image received event callbacks. */ -typedef void (*freenect2_ir_cb)(freenect2_device *dev, uint32_t timestamp, void *ir, void *user); -/** Typedef for video image received event callbacks. */ -typedef void (*freenect2_video_cb)(freenect2_device *dev, uint32_t timestamp, void *video, void *user); - -/** - * Set callback for depth information received event - * - * @param dev Device to set callback for - * @param cb Function pointer for processing depth information - * @param user Pointer to user data - */ -FREENECT2API void freenect2_set_depth_callback(freenect2_device *dev, freenect2_depth_cb cb, void *user); - -/** - * Set callback for ir information received event - * - * @param dev Device to set callback for - * @param cb Function pointer for processing depth information - * @param user Pointer to user data - */ -FREENECT2API void freenect2_set_ir_callback(freenect2_device *dev, freenect2_ir_cb cb, void *user); - -/** - * Set callback for video information received event - * - * @param dev Device to set callback for - * @param cb Function pointer for processing video information - * @param user Pointer to user data - */ -FREENECT2API void freenect2_set_video_callback(freenect2_device *dev, freenect2_video_cb cb, void *user); - -/** - * Start the depth information stream for a device. - * - * @param dev Device to start depth information stream for. - * - * @return 0 on success, < 0 on error - */ -FREENECT2API int freenect2_start_depth(freenect2_device *dev); - -/** - * Start the ir information stream for a device. - * - * @param dev Device to start ir information stream for. - * - * @return 0 on success, < 0 on error - */ -FREENECT2API int freenect2_start_ir(freenect2_device *dev); - -/** - * Start the video information stream for a device. - * - * @param dev Device to start video information stream for. - * - * @return 0 on success, < 0 on error - */ -FREENECT2API int freenect2_start_video(freenect2_device *dev); - -/** - * Stop the depth information stream for a device - * - * @param dev Device to stop depth information stream on. - * - * @return 0 on success, < 0 on error - */ -FREENECT2API int freenect2_stop_depth(freenect2_device *dev); - -/** - * Stop the ir information stream for a device - * - * @param dev Device to stop ir information stream on. - * - * @return 0 on success, < 0 on error - */ -FREENECT2API int freenect2_stop_ir(freenect2_device *dev); - -/** - * Stop the video information stream for a device - * - * @param dev Device to stop video information stream on. - * - * @return 0 on success, < 0 on error - */ -FREENECT2API int freenect2_stop_video(freenect2_device *dev); - -/** - * Get the number of video camera modes supported by the driver. - * - * @return Number of video modes supported by the driver - */ -FREENECT2API int freenect2_get_video_mode_count(); - -/** - * Get the frame descriptor of the nth supported video mode for the - * video camera. - * - * @param mode_num Which of the supported modes to return information about - * - * @return A freenect2_frame_mode describing the nth video mode - */ -FREENECT2API freenect2_frame_mode freenect2_get_video_mode(int mode_num); - -/** - * Get the frame descriptor of the current video mode for the specified - * freenect device. - * - * @param dev Which device to return the currently-set video mode for - * - * @return A freenect2_frame_mode describing the current video mode of the specified device - */ -FREENECT2API freenect2_frame_mode freenect2_get_current_video_mode(freenect2_device *dev); - -/** - * Convenience function to return a mode descriptor matching the - * specified resolution and video camera pixel format, if one exists. - * - * @param res Resolution desired - * @param fmt Pixel format desired - * - * @return A freenect2_frame_mode that matches the arguments specified, if such a valid mode exists; otherwise, an invalid freenect2_frame_mode. - */ -FREENECT2API freenect2_frame_mode freenect2_find_video_mode(freenect2_resolution res, freenect2_video_format fmt); - -/** - * Sets the current video mode for the specified device. If the - * freenect2_frame_mode specified is not one provided by the driver - * e.g. from freenect2_get_video_mode() or freenect2_find_video_mode() - * then behavior is undefined. The current video mode cannot be - * changed while streaming is active. - * - * @param dev Device for which to set the video mode - * @param mode Frame mode to set - * - * @return 0 on success, < 0 if error - */ -FREENECT2API int freenect2_set_video_mode(freenect2_device* dev, freenect2_frame_mode mode); - -/** - * Get the number of ir camera modes supported by the driver. - * - * @return Number of ir modes supported by the driver - */ -FREENECT2API int freenect2_get_ir_mode_count(); - -/** - * Get the frame descriptor of the nth supported ir mode for the - * ir camera. - * - * @param mode_num Which of the supported modes to return information about - * - * @return A freenect2_frame_mode describing the nth ir mode - */ -FREENECT2API freenect2_frame_mode freenect2_get_ir_mode(int mode_num); - -/** - * Get the frame descriptor of the current ir mode for the specified - * freenect device. - * - * @param dev Which device to return the currently-set ir mode for - * - * @return A freenect2_frame_mode describing the ir video mode of the specified device - */ -FREENECT2API freenect2_frame_mode freenect2_get_current_ir_mode(freenect2_device *dev); - -/** - * Convenience function to return a mode descriptor matching the - * specified resolution and ir camera pixel format, if one exists. - * - * @param res Resolution desired - * @param fmt Pixel format desired - * - * @return A freenect2_frame_mode that matches the arguments specified, if such a valid mode exists; otherwise, an invalid freenect2_frame_mode. - */ -FREENECT2API freenect2_frame_mode freenect2_find_ir_mode(freenect2_resolution res, freenect2_ir_format fmt); - -/** - * Sets the current ir mode for the specified device. If the - * freenect2_frame_mode specified is not one provided by the driver - * e.g. from freenect2_get_ir_mode() or freenect2_find_ir_mode() - * then behavior is undefined. The current ir mode cannot be - * changed while streaming is active. - * - * @param dev Device for which to set the ir mode - * @param mode Frame mode to set - * - * @return 0 on success, < 0 if error - */ -FREENECT2API int freenect2_set_ir_mode(freenect2_device* dev, freenect2_frame_mode mode); - -/** - * Get the number of depth camera modes supported by the driver. - * - * @return Number of depth modes supported by the driver - */ -FREENECT2API int freenect2_get_depth_mode_count(); - -/** - * Get the frame descriptor of the nth supported depth mode for the - * depth camera. - * - * @param mode_num Which of the supported modes to return information about - * - * @return A freenect2_frame_mode describing the nth depth mode - */ -FREENECT2API freenect2_frame_mode freenect2_get_depth_mode(int mode_num); - -/** - * Get the frame descriptor of the current depth mode for the specified - * freenect2 device. - * - * @param dev Which device to return the currently-set depth mode for - * - * @return A freenect2_frame_mode describing the current depth mode of the specified device - */ -FREENECT2API freenect2_frame_mode freenect2_get_current_depth_mode(freenect2_device *dev); - -/** - * Convenience function to return a mode descriptor matching the - * specified resolution and depth camera pixel format, if one exists. - * - * @param res Resolution desired - * @param fmt Pixel format desired - * - * @return A freenect2_frame_mode that matches the arguments specified, if such a valid mode exists; otherwise, an invalid freenect2_frame_mode. - */ -FREENECT2API freenect2_frame_mode freenect2_find_depth_mode(freenect2_resolution res, freenect2_depth_format fmt); - -/** - * Sets the current depth mode for the specified device. The mode - * cannot be changed while streaming is active. - * - * @param dev Device for which to set the depth mode - * @param mode Frame mode to set - * - * @return 0 on success, < 0 if error - */ -FREENECT2API int freenect2_set_depth_mode(freenect2_device* dev, const freenect2_frame_mode mode); - -/** - * Enables or disables the specified flag. - * - * @param flag Feature to set - * @param value `FREENECT2_OFF` or `FREENECT2_ON` - * - * @return 0 on success, < 0 if error - */ -FREENECT2API int freenect2_set_flag(freenect2_device *dev, freenect2_flag flag, freenect2_flag_value value); - -#ifdef __cplusplus -} -#endif diff --git a/examples/protonect/include/libfreenect2/config.h.in b/include/libfreenect2/config.h.in similarity index 94% rename from examples/protonect/include/libfreenect2/config.h.in rename to include/libfreenect2/config.h.in index f67583453..94471835c 100644 --- a/examples/protonect/include/libfreenect2/config.h.in +++ b/include/libfreenect2/config.h.in @@ -33,11 +33,8 @@ #define LIBFREENECT2_PACK( __Declaration__ ) __Declaration__ __attribute__((__packed__)) #endif -#ifdef _WIN32 -#define LIBFREENECT2_API __declspec(dllexport) -#else -#define LIBFREENECT2_API -#endif +#include "libfreenect2_export.h" +#define LIBFREENECT2_API LIBFREENECT2_EXPORT #cmakedefine LIBFREENECT2_WITH_OPENGL_SUPPORT diff --git a/examples/protonect/include/libfreenect2/depth_packet_processor.h b/include/libfreenect2/depth_packet_processor.h similarity index 100% rename from examples/protonect/include/libfreenect2/depth_packet_processor.h rename to include/libfreenect2/depth_packet_processor.h diff --git a/examples/protonect/include/libfreenect2/frame_listener.hpp b/include/libfreenect2/frame_listener.hpp similarity index 100% rename from examples/protonect/include/libfreenect2/frame_listener.hpp rename to include/libfreenect2/frame_listener.hpp diff --git a/examples/protonect/include/libfreenect2/frame_listener_impl.h b/include/libfreenect2/frame_listener_impl.h similarity index 100% rename from examples/protonect/include/libfreenect2/frame_listener_impl.h rename to include/libfreenect2/frame_listener_impl.h diff --git a/examples/protonect/include/libfreenect2/libfreenect2.hpp b/include/libfreenect2/libfreenect2.hpp similarity index 100% rename from examples/protonect/include/libfreenect2/libfreenect2.hpp rename to include/libfreenect2/libfreenect2.hpp diff --git a/examples/protonect/include/libfreenect2/logger.h b/include/libfreenect2/logger.h similarity index 99% rename from examples/protonect/include/libfreenect2/logger.h rename to include/libfreenect2/logger.h index 323919786..8235e152e 100644 --- a/examples/protonect/include/libfreenect2/logger.h +++ b/include/libfreenect2/logger.h @@ -30,7 +30,6 @@ #define LIBFREENECT2_LOGGER_H_ #include -#include #include diff --git a/examples/protonect/include/libfreenect2/packet_pipeline.h b/include/libfreenect2/packet_pipeline.h similarity index 96% rename from examples/protonect/include/libfreenect2/packet_pipeline.h rename to include/libfreenect2/packet_pipeline.h index 7131f0333..4ae2e91d8 100644 --- a/examples/protonect/include/libfreenect2/packet_pipeline.h +++ b/include/libfreenect2/packet_pipeline.h @@ -30,15 +30,14 @@ #define PACKET_PIPELINE_H_ #include -#include -#include -#include #include #include namespace libfreenect2 { +class DataCallback; + /** Packet pipeline for data processing of the device. */ class LIBFREENECT2_API PacketPipeline { @@ -53,6 +52,9 @@ class LIBFREENECT2_API PacketPipeline virtual DepthPacketProcessor *getDepthPacketProcessor() const = 0; }; +class RgbPacketStreamParser; +class DepthPacketStreamParser; + /** Front of the pipeline, RGB and Depth parsing and processing. */ class LIBFREENECT2_API BasePacketPipeline : public PacketPipeline { diff --git a/examples/protonect/include/libfreenect2/packet_processor.h b/include/libfreenect2/packet_processor.h similarity index 100% rename from examples/protonect/include/libfreenect2/packet_processor.h rename to include/libfreenect2/packet_processor.h diff --git a/examples/protonect/include/libfreenect2/registration.h b/include/libfreenect2/registration.h similarity index 100% rename from examples/protonect/include/libfreenect2/registration.h rename to include/libfreenect2/registration.h diff --git a/examples/protonect/include/libfreenect2/rgb_packet_processor.h b/include/libfreenect2/rgb_packet_processor.h similarity index 100% rename from examples/protonect/include/libfreenect2/rgb_packet_processor.h rename to include/libfreenect2/rgb_packet_processor.h diff --git a/examples/protonect/src/command_transaction.cpp b/src/command_transaction.cpp similarity index 100% rename from examples/protonect/src/command_transaction.cpp rename to src/command_transaction.cpp diff --git a/examples/protonect/src/cpu_depth_packet_processor.cpp b/src/cpu_depth_packet_processor.cpp similarity index 100% rename from examples/protonect/src/cpu_depth_packet_processor.cpp rename to src/cpu_depth_packet_processor.cpp diff --git a/examples/protonect/src/depth_packet_processor.cpp b/src/depth_packet_processor.cpp similarity index 100% rename from examples/protonect/src/depth_packet_processor.cpp rename to src/depth_packet_processor.cpp diff --git a/examples/protonect/src/depth_packet_stream_parser.cpp b/src/depth_packet_stream_parser.cpp similarity index 100% rename from examples/protonect/src/depth_packet_stream_parser.cpp rename to src/depth_packet_stream_parser.cpp diff --git a/examples/protonect/src/double_buffer.cpp b/src/double_buffer.cpp similarity index 100% rename from examples/protonect/src/double_buffer.cpp rename to src/double_buffer.cpp diff --git a/examples/protonect/src/event_loop.cpp b/src/event_loop.cpp similarity index 100% rename from examples/protonect/src/event_loop.cpp rename to src/event_loop.cpp diff --git a/examples/protonect/src/flextGL.c b/src/flextGL.cpp similarity index 100% rename from examples/protonect/src/flextGL.c rename to src/flextGL.cpp diff --git a/examples/protonect/src/flextGL.h b/src/flextGL.h similarity index 100% rename from examples/protonect/src/flextGL.h rename to src/flextGL.h diff --git a/examples/protonect/src/frame_listener_impl.cpp b/src/frame_listener_impl.cpp similarity index 100% rename from examples/protonect/src/frame_listener_impl.cpp rename to src/frame_listener_impl.cpp diff --git a/examples/protonect/src/libfreenect2.cpp b/src/libfreenect2.cpp similarity index 100% rename from examples/protonect/src/libfreenect2.cpp rename to src/libfreenect2.cpp diff --git a/examples/protonect/src/logging.cpp b/src/logging.cpp similarity index 100% rename from examples/protonect/src/logging.cpp rename to src/logging.cpp diff --git a/examples/protonect/src/opencl_depth_packet_processor.cl b/src/opencl_depth_packet_processor.cl similarity index 100% rename from examples/protonect/src/opencl_depth_packet_processor.cl rename to src/opencl_depth_packet_processor.cl diff --git a/examples/protonect/src/opencl_depth_packet_processor.cpp b/src/opencl_depth_packet_processor.cpp similarity index 99% rename from examples/protonect/src/opencl_depth_packet_processor.cpp rename to src/opencl_depth_packet_processor.cpp index 825daac30..95e9d381a 100644 --- a/examples/protonect/src/opencl_depth_packet_processor.cpp +++ b/src/opencl_depth_packet_processor.cpp @@ -532,7 +532,7 @@ class OpenCLDepthPacketProcessorImpl: public WithPerfLogging bool readProgram(std::string &source) const { - source = loadCLSource("src/opencl_depth_packet_processor.cl"); + source = loadCLSource("opencl_depth_packet_processor.cl"); return !source.empty(); } diff --git a/examples/protonect/src/opengl_depth_packet_processor.cpp b/src/opengl_depth_packet_processor.cpp similarity index 97% rename from examples/protonect/src/opengl_depth_packet_processor.cpp rename to src/opengl_depth_packet_processor.cpp index a273444dd..b08c296d5 100644 --- a/examples/protonect/src/opengl_depth_packet_processor.cpp +++ b/src/opengl_depth_packet_processor.cpp @@ -400,7 +400,6 @@ struct Texture : public WithOpenGLBindings struct OpenGLDepthPacketProcessorImpl : public WithOpenGLBindings, public WithPerfLogging { GLFWwindow *opengl_context_ptr; - std::string shader_folder; libfreenect2::DepthPacketProcessor::Config config; GLuint square_vbo, square_vao, stage1_framebuffer, filter1_framebuffer, stage2_framebuffer, filter2_framebuffer; @@ -441,7 +440,6 @@ struct OpenGLDepthPacketProcessorImpl : public WithOpenGLBindings, public WithPe OpenGLDepthPacketProcessorImpl(GLFWwindow *new_opengl_context_ptr, bool debug) : opengl_context_ptr(new_opengl_context_ptr), - shader_folder("src/shader/"), square_vao(0), square_vbo(0), stage1_framebuffer(0), @@ -556,8 +554,8 @@ struct OpenGLDepthPacketProcessorImpl : public WithOpenGLBindings, public WithPe if(do_debug) filter2_debug.allocate(512, 424); filter2_depth.allocate(512, 424); - stage1.setVertexShader(loadShaderSource(shader_folder + "default.vs")); - stage1.setFragmentShader(loadShaderSource(shader_folder + "stage1.fs")); + stage1.setVertexShader(loadShaderSource("default.vs")); + stage1.setFragmentShader(loadShaderSource("stage1.fs")); stage1.bindFragDataLocation("Debug", 0); stage1.bindFragDataLocation("A", 1); stage1.bindFragDataLocation("B", 2); @@ -565,31 +563,31 @@ struct OpenGLDepthPacketProcessorImpl : public WithOpenGLBindings, public WithPe stage1.bindFragDataLocation("Infrared", 4); stage1.build(); - filter1.setVertexShader(loadShaderSource(shader_folder + "default.vs")); - filter1.setFragmentShader(loadShaderSource(shader_folder + "filter1.fs")); + filter1.setVertexShader(loadShaderSource("default.vs")); + filter1.setFragmentShader(loadShaderSource("filter1.fs")); filter1.bindFragDataLocation("Debug", 0); filter1.bindFragDataLocation("FilterA", 1); filter1.bindFragDataLocation("FilterB", 2); filter1.bindFragDataLocation("MaxEdgeTest", 3); filter1.build(); - stage2.setVertexShader(loadShaderSource(shader_folder + "default.vs")); - stage2.setFragmentShader(loadShaderSource(shader_folder + "stage2.fs")); + stage2.setVertexShader(loadShaderSource("default.vs")); + stage2.setFragmentShader(loadShaderSource("stage2.fs")); stage2.bindFragDataLocation("Debug", 0); stage2.bindFragDataLocation("Depth", 1); stage2.bindFragDataLocation("DepthAndIrSum", 2); stage2.build(); - filter2.setVertexShader(loadShaderSource(shader_folder + "default.vs")); - filter2.setFragmentShader(loadShaderSource(shader_folder + "filter2.fs")); + filter2.setVertexShader(loadShaderSource("default.vs")); + filter2.setFragmentShader(loadShaderSource("filter2.fs")); filter2.bindFragDataLocation("Debug", 0); filter2.bindFragDataLocation("FilterDepth", 1); filter2.build(); if(do_debug) { - debug.setVertexShader(loadShaderSource(shader_folder + "default.vs")); - debug.setFragmentShader(loadShaderSource(shader_folder + "debug.fs")); + debug.setVertexShader(loadShaderSource("default.vs")); + debug.setFragmentShader(loadShaderSource("debug.fs")); debug.bindFragDataLocation("Debug", 0); debug.build(); } diff --git a/examples/protonect/src/packet_pipeline.cpp b/src/packet_pipeline.cpp similarity index 96% rename from examples/protonect/src/packet_pipeline.cpp rename to src/packet_pipeline.cpp index eb080240d..70360feac 100644 --- a/examples/protonect/src/packet_pipeline.cpp +++ b/src/packet_pipeline.cpp @@ -28,6 +28,9 @@ #include #include +#include +#include +#include namespace libfreenect2 { diff --git a/examples/protonect/src/registration.cpp b/src/registration.cpp similarity index 100% rename from examples/protonect/src/registration.cpp rename to src/registration.cpp diff --git a/examples/protonect/src/resource.cpp b/src/resource.cpp similarity index 96% rename from examples/protonect/src/resource.cpp rename to src/resource.cpp index 26f93daf3..bf8ca0b40 100644 --- a/examples/protonect/src/resource.cpp +++ b/src/resource.cpp @@ -45,7 +45,8 @@ struct ResourceDescriptor #ifdef RESOURCES_INC #include "resources.inc.h" #else -ResourceDescriptor resource_descriptors[] = {}; +static ResourceDescriptor resource_descriptors[] = {}; +static int resource_descriptors_length = 0; #endif /** diff --git a/examples/protonect/src/rgb_packet_processor.cpp b/src/rgb_packet_processor.cpp similarity index 100% rename from examples/protonect/src/rgb_packet_processor.cpp rename to src/rgb_packet_processor.cpp diff --git a/examples/protonect/src/rgb_packet_stream_parser.cpp b/src/rgb_packet_stream_parser.cpp similarity index 100% rename from examples/protonect/src/rgb_packet_stream_parser.cpp rename to src/rgb_packet_stream_parser.cpp diff --git a/examples/protonect/src/shader/debug.fs b/src/shader/debug.fs similarity index 100% rename from examples/protonect/src/shader/debug.fs rename to src/shader/debug.fs diff --git a/examples/protonect/src/shader/default.vs b/src/shader/default.vs similarity index 100% rename from examples/protonect/src/shader/default.vs rename to src/shader/default.vs diff --git a/examples/protonect/src/shader/filter1.fs b/src/shader/filter1.fs similarity index 100% rename from examples/protonect/src/shader/filter1.fs rename to src/shader/filter1.fs diff --git a/examples/protonect/src/shader/filter2.fs b/src/shader/filter2.fs similarity index 100% rename from examples/protonect/src/shader/filter2.fs rename to src/shader/filter2.fs diff --git a/examples/protonect/src/shader/stage1.fs b/src/shader/stage1.fs similarity index 100% rename from examples/protonect/src/shader/stage1.fs rename to src/shader/stage1.fs diff --git a/examples/protonect/src/shader/stage2.fs b/src/shader/stage2.fs similarity index 100% rename from examples/protonect/src/shader/stage2.fs rename to src/shader/stage2.fs diff --git a/examples/protonect/src/tinythread/tinythread.cpp b/src/tinythread/tinythread.cpp similarity index 100% rename from examples/protonect/src/tinythread/tinythread.cpp rename to src/tinythread/tinythread.cpp diff --git a/examples/protonect/src/tinythread/tinythread.h b/src/tinythread/tinythread.h similarity index 98% rename from examples/protonect/src/tinythread/tinythread.h rename to src/tinythread/tinythread.h index 566997a43..39bf41dda 100644 --- a/examples/protonect/src/tinythread/tinythread.h +++ b/src/tinythread/tinythread.h @@ -158,7 +158,7 @@ namespace tthread { /// program may deadlock if the thread that owns a mutex object calls lock() /// on that object). /// @see recursive_mutex -class LIBFREENECT2_API mutex { +class mutex { public: /// Constructor. mutex() @@ -250,7 +250,7 @@ class LIBFREENECT2_API mutex { /// may lock the mutex several times, as long as it unlocks the mutex the same /// number of times). /// @see mutex -class LIBFREENECT2_API recursive_mutex { +class recursive_mutex { public: /// Constructor. recursive_mutex() @@ -342,7 +342,7 @@ class LIBFREENECT2_API recursive_mutex { /// @endcode template -class LIBFREENECT2_API lock_guard { +class lock_guard { public: typedef T mutex_type; @@ -391,7 +391,7 @@ class LIBFREENECT2_API lock_guard { /// cond.notify_all(); /// } /// @endcode -class LIBFREENECT2_API condition_variable { +class condition_variable { public: /// Constructor. #if defined(_TTHREAD_WIN32_) @@ -480,7 +480,7 @@ class LIBFREENECT2_API condition_variable { /// Thread class. -class LIBFREENECT2_API thread { +class thread { public: #if defined(_TTHREAD_WIN32_) typedef HANDLE native_handle_type; @@ -571,7 +571,7 @@ class LIBFREENECT2_API thread { /// Thread ID. /// The thread ID is a unique identifier for each thread. /// @see thread::get_id() -class LIBFREENECT2_API thread::id { +class thread::id { public: /// Default constructor. /// The default constructed ID is that of thread without a thread of diff --git a/examples/protonect/src/transfer_pool.cpp b/src/transfer_pool.cpp similarity index 100% rename from examples/protonect/src/transfer_pool.cpp rename to src/transfer_pool.cpp diff --git a/examples/protonect/src/turbo_jpeg_rgb_packet_processor.cpp b/src/turbo_jpeg_rgb_packet_processor.cpp similarity index 100% rename from examples/protonect/src/turbo_jpeg_rgb_packet_processor.cpp rename to src/turbo_jpeg_rgb_packet_processor.cpp diff --git a/examples/protonect/src/usb_control.cpp b/src/usb_control.cpp similarity index 100% rename from examples/protonect/src/usb_control.cpp rename to src/usb_control.cpp diff --git a/examples/protonect/src/generate_resources.cpp b/tools/generate_resources.cpp similarity index 81% rename from examples/protonect/src/generate_resources.cpp rename to tools/generate_resources.cpp index 381dad0d3..b9a358d3c 100644 --- a/examples/protonect/src/generate_resources.cpp +++ b/tools/generate_resources.cpp @@ -74,20 +74,24 @@ int main(int argc, char **argv) for(int i = 2; i < argc; ++i) { - cout << "unsigned char resource" << (i - 2) << "[] = {" << endl; + cout << "static unsigned char resource" << (i - 2) << "[] = {" << endl; dumpFile(basefolder + "/" + argv[i]); cout << "};" << endl; } - cout << "ResourceDescriptor resource_descriptors[] = {" << endl; + cout << "static ResourceDescriptor resource_descriptors[] = {" << endl; for(int i = 2; i < argc; ++i) { - cout << " { \"" << argv[i] << "\", resource" << (i - 2) << ", " << "sizeof(resource" << (i - 2) << ") }," << endl; + string path(argv[i]); + size_t last_slash = path.find_last_of("\\/"); + if (last_slash != std::string::npos) + path.erase(0, last_slash + 1); + cout << " { \"" << path << "\", resource" << (i - 2) << ", " << "sizeof(resource" << (i - 2) << ") }," << endl; } cout << "};" << endl; - cout << "int resource_descriptors_length = " << (argc - 2) << ";" << endl; + cout << "static int resource_descriptors_length = " << (argc - 2) << ";" << endl; return 0; }