diff --git a/CMakeLists.txt b/CMakeLists.txt index e9a8f4cd..474cb234 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,7 +48,7 @@ include (SetupDirectories) set (PROJECT_VER_MAJOR 0) set (PROJECT_VER_MINOR 5) -set (PROJECT_VER_PATCH 0) +set (PROJECT_VER_PATCH 2) set (PROJECT_VER "${PROJECT_VER_MAJOR}.${PROJECT_VER_MINOR}.${PROJECT_VER_PATCH}") set (PROJECT_APIVER @@ -108,14 +108,14 @@ set(C_CXX_FLAGS_DEFAULT "${C_FLAGS_WARNING} -O2") # 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_DEBUG "${CMAKE_C_FLAGS} -O0 -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_DEBUG "${CMAKE_CXX_FLAGS} -O0 -g -DDEBUG=1") SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS}") SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELEASE} -g") diff --git a/OpenNI2-FreenectDriver/CMakeLists.txt b/OpenNI2-FreenectDriver/CMakeLists.txt index a1be114a..30f70dce 100644 --- a/OpenNI2-FreenectDriver/CMakeLists.txt +++ b/OpenNI2-FreenectDriver/CMakeLists.txt @@ -17,6 +17,7 @@ set_target_properties(FreenectDriver PROPERTIES add_definitions(-DPROJECT_VER="${PROJECT_VER}") include_directories(extern/OpenNI-Linux-x64-2.2.0.33/Include) +include_directories(${PROJECT_SOURCE_DIR}/src) include_directories(${PROJECT_SOURCE_DIR}/wrappers/cpp) target_link_libraries(FreenectDriver freenectstatic ${MATH_LIB}) diff --git a/OpenNI2-FreenectDriver/README.md b/OpenNI2-FreenectDriver/README.md index 55fd3791..c5ae5c15 100644 --- a/OpenNI2-FreenectDriver/README.md +++ b/OpenNI2-FreenectDriver/README.md @@ -3,12 +3,11 @@ OpenNI2-FreenectDriver OpenNI2-FreenectDriver is a bridge to libfreenect implemented as an OpenNI2 driver. It allows OpenNI2 to use Kinect hardware on Linux and OSX. -It was originally a [separate project](https://github.com/piedar/OpenNI2-FreenectDriver) but is now distributed with libfreenect. OpenNI2-FreenectDriver is distributed under the [Apache 2](https://github.com/OpenKinect/libfreenect/blob/master/APACHE20) license. Install ------- -1. Download and unpack [OpenNI](http://www.openni.org/openni-sdk/) 2.2.0.33 or higher. +1. Download and unpack [OpenNI](http://structure.io/openni) 2.2.0.33 or higher. 2. Go to the top libfreenect directory and build it with the OpenNI2 driver. mkdir build diff --git a/OpenNI2-FreenectDriver/src/DeviceDriver.cpp b/OpenNI2-FreenectDriver/src/DeviceDriver.cpp index a6cfe025..6a52ff58 100644 --- a/OpenNI2-FreenectDriver/src/DeviceDriver.cpp +++ b/OpenNI2-FreenectDriver/src/DeviceDriver.cpp @@ -17,6 +17,7 @@ #include #include #include "Driver/OniDriverAPI.h" +#include "freenect_internal.h" #include "libfreenect.hpp" #include "DepthStream.hpp" #include "ColorStream.hpp" @@ -254,6 +255,18 @@ namespace FreenectDriver devices[info] = NULL; deviceConnected(&info); deviceStateChanged(&info, 0); + + freenect_device* dev; + if (freenect_open_device(m_ctx, &dev, i) == 0) + { + info.usbVendorId = dev->usb_cam.VID; + info.usbProductId = dev->usb_cam.PID; + freenect_close_device(dev); + } + else + { + WriteMessage("Unable to open device to query VID/PID"); + } } return ONI_STATUS_OK; } diff --git a/README.md b/README.md index 33cc55b7..c25c8370 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,7 @@ Continue with [Fetch & Build](#fetch-build). ## Linux +Remember to install the [udev rules](https://github.com/OpenKinect/libfreenect/tree/master/platform/linux/udev). For a manual build, see [the wiki](http://openkinect.org/wiki/Getting_Started#Manual_Build_on_Linux). ### Ubuntu/Debian/Mint @@ -83,12 +84,10 @@ The version packaged in Ubuntu may be very old. To install newer packaged builds, see [the wiki](http://openkinect.org/wiki/Getting_Started#Ubuntu.2FDebian). Continue with this section for a manual build. - sudo apt-get install git-core cmake pkg-config build-essential libusb-1.0-0-dev - sudo adduser $USER video - sudo adduser $USER plugdev # necessary? + sudo apt-get install git cmake build-essential libusb-1.0-0-dev # only if you are building the examples: - sudo apt-get install libglut3-dev libxmu-dev libxi-dev + sudo apt-get install freeglut3-dev libxmu-dev libxi-dev Continue with [Fetch & Build](#fetch-build). diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 4e9cb3ed..c37b61af 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -2,79 +2,58 @@ # Packages needed for examples ###################################################################################### -# todo: use these throughout -file(GLOB SRC_STANDARD chunkview.c glview.c hiview.c regview.c) -file(GLOB SRC_AUDIO micview.c wavrecord.c) -file(GLOB SRC_SYNC glpclview.c regtest.c tiltdemo.c) -set (SRC_ALL ${SRC_STANDARD} ${SRC_AUDIO} ${SRC_SYNC}) - -if (WIN32) - set(THREADS_USE_PTHREADS_WIN32 true) - find_package(Threads REQUIRED) - include_directories(${THREADS_PTHREADS_INCLUDE_DIR}) - set_source_files_properties(${SRC_ALL} PROPERTIES LANGUAGE CXX) -endif() - -add_executable(freenect-glview glview.c) -add_executable(freenect-regview regview.c) -add_executable(freenect-hiview hiview.c) -add_executable(freenect-chunkview chunkview.c) +# These examples have no external dependencies and should always build. +add_executable(freenect-camtest camtest.c) add_executable(freenect-wavrecord wavrecord.c) -add_executable(freenect-micview micview.c) - -if (BUILD_C_SYNC) - add_executable(freenect-glpclview glpclview.c) - add_executable(freenect-tiltdemo tiltdemo.c) - add_executable(freenect-regtest regtest.c) - - add_dependencies(freenect-glpclview freenect-tiltdemo freenect-regtest - freenect_sync) -endif() - -# We need to include libfreenect_sync.h for glpclview -include_directories (../wrappers/c_sync/) - -# Mac just has everything already -if(APPLE) - set(CMAKE_EXE_LINKER_FLAGS "-framework OpenGL -framework GLUT") - target_link_libraries(freenect-glview freenect) - target_link_libraries(freenect-regview freenect) - target_link_libraries(freenect-hiview freenect) - target_link_libraries(freenect-chunkview freenect) - target_link_libraries(freenect-wavrecord freenect) - target_link_libraries(freenect-micview freenect) - if (BUILD_C_SYNC) - target_link_libraries(freenect-glpclview freenect_sync) - target_link_libraries(freenect-tiltdemo freenect_sync) - target_link_libraries(freenect-regtest freenect_sync) - endif() -# Linux, not so much -else() - - find_package(Threads REQUIRED) - find_package(OpenGL REQUIRED) - find_package(GLUT REQUIRED) - - include_directories(${OPENGL_INCLUDE_DIR} ${GLUT_INCLUDE_DIR} ${USB_INCLUDE_DIRS}) +target_link_libraries(freenect-camtest freenect) +target_link_libraries(freenect-wavrecord freenect) +install(TARGETS freenect-camtest freenect-wavrecord + DESTINATION bin) + +# All viewers need pthreads and GLUT. +set(THREADS_USE_PTHREADS_WIN32 true) +find_package(Threads) +find_package(OpenGL) +find_package(GLUT) + +if (Threads_FOUND AND OPENGL_FOUND AND GLUT_FOUND) + include_directories(${THREADS_PTHREADS_INCLUDE_DIR} ${OPENGL_INCLUDE_DIR} ${GLUT_INCLUDE_DIR}) + + add_executable(freenect-glview glview.c) + add_executable(freenect-regview regview.c) + add_executable(freenect-hiview hiview.c) + add_executable(freenect-chunkview chunkview.c) + add_executable(freenect-micview micview.c) target_link_libraries(freenect-glview freenect ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB}) target_link_libraries(freenect-regview freenect ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB}) target_link_libraries(freenect-hiview freenect ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB}) target_link_libraries(freenect-chunkview freenect ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB}) - target_link_libraries(freenect-wavrecord freenect ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB}) target_link_libraries(freenect-micview freenect ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB}) - if (BUILD_C_SYNC) - target_link_libraries(freenect-glpclview freenect_sync ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} - ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB}) - target_link_libraries(freenect-tiltdemo freenect_sync ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB}) - target_link_libraries(freenect-regtest freenect_sync ${CMAKE_THREAD_LIBS_INIT}) - endif() -endif() -install (TARGETS freenect-glview freenect-regview freenect-hiview freenect-chunkview freenect-wavrecord freenect-micview - DESTINATION bin) + install(TARGETS freenect-glview freenect-regview freenect-hiview freenect-chunkview freenect-micview + DESTINATION bin) +endif () +# A few examples use c_sync. if (BUILD_C_SYNC) - install (TARGETS freenect-glpclview freenect-tiltdemo - DESTINATION bin) -endif() + find_package(Threads REQUIRED) + include_directories(../wrappers/c_sync/) + include_directories(${THREADS_PTHREADS_INCLUDE_DIR} ${OPENGL_INCLUDE_DIR} ${GLUT_INCLUDE_DIR}) + + add_executable(freenect-regtest regtest.c) + add_executable(freenect-tiltdemo tiltdemo.c) + + target_link_libraries(freenect-regtest freenect_sync ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB}) + target_link_libraries(freenect-tiltdemo freenect_sync ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB}) + + install(TARGETS freenect-regtest freenect-tiltdemo + DESTINATION bin) + + if (OPENGL_FOUND AND GLUT_FOUND) + add_executable(freenect-glpclview glpclview.c) + target_link_libraries(freenect-glpclview freenect_sync ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB}) + install(TARGETS freenect-glpclview + DESTINATION bin) + endif () +endif () diff --git a/examples/camtest.c b/examples/camtest.c new file mode 100644 index 00000000..7d796cc1 --- /dev/null +++ b/examples/camtest.c @@ -0,0 +1,144 @@ +/* + * This file is part of the OpenKinect Project. http://www.openkinect.org + * + * Copyright (c) 2010 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. + */ +#include +#include +#include +#include +#include "libfreenect.h" + +#ifndef SIGQUIT // win32 compat + #define SIGQUIT SIGTERM +#endif + + +void depth_cb(freenect_device* dev, void* data, uint32_t timestamp) +{ + printf("Received depth frame at %d\n", timestamp); +} + +void video_cb(freenect_device* dev, void* data, uint32_t timestamp) +{ + printf("Received video frame at %d\n", timestamp); +} + +volatile bool running = true; +void signalHandler(int signal) +{ + if (signal == SIGINT + || signal == SIGTERM + || signal == SIGQUIT) + { + running = false; + } +} + +int main(int argc, char** argv) +{ + // Handle signals gracefully. + signal(SIGINT, signalHandler); + signal(SIGTERM, signalHandler); + signal(SIGQUIT, signalHandler); + + // Initialize libfreenect. + freenect_context* fn_ctx; + int ret = freenect_init(&fn_ctx, NULL); + if (ret < 0) + return ret; + + // Show debug messages and use camera only. + freenect_set_log_level(fn_ctx, FREENECT_LOG_DEBUG); + freenect_select_subdevices(fn_ctx, FREENECT_DEVICE_CAMERA); + + // Find out how many devices are connected. + int num_devices = ret = freenect_num_devices(fn_ctx); + if (ret < 0) + return ret; + if (num_devices == 0) + { + printf("No device found!\n"); + freenect_shutdown(fn_ctx); + return 1; + } + + // Open the first device. + freenect_device* fn_dev; + ret = freenect_open_device(fn_ctx, &fn_dev, 0); + if (ret < 0) + { + freenect_shutdown(fn_ctx); + return ret; + } + + // Set depth and video modes. + ret = freenect_set_depth_mode(fn_dev, freenect_find_depth_mode(FREENECT_RESOLUTION_MEDIUM, FREENECT_DEPTH_MM)); + if (ret < 0) + { + freenect_shutdown(fn_ctx); + return ret; + } + ret = freenect_set_video_mode(fn_dev, freenect_find_video_mode(FREENECT_RESOLUTION_MEDIUM, FREENECT_VIDEO_RGB)); + if (ret < 0) + { + freenect_shutdown(fn_ctx); + return ret; + } + + // Set frame callbacks. + freenect_set_depth_callback(fn_dev, depth_cb); + freenect_set_video_callback(fn_dev, video_cb); + + // Start depth and video. + ret = freenect_start_depth(fn_dev); + if (ret < 0) + { + freenect_shutdown(fn_ctx); + return ret; + } + ret = freenect_start_video(fn_dev); + if (ret < 0) + { + freenect_shutdown(fn_ctx); + return ret; + } + + // Run until interruption or failure. + while (running && freenect_process_events(fn_ctx) >= 0) + { + + } + + printf("Shutting down\n"); + + // Stop everything and shutdown. + freenect_stop_depth(fn_dev); + freenect_stop_video(fn_dev); + freenect_close_device(fn_dev); + freenect_shutdown(fn_ctx); + + printf("Done!\n"); + + return 0; +} diff --git a/examples/glview.c b/examples/glview.c index bfdbb561..9c67d6f7 100644 --- a/examples/glview.c +++ b/examples/glview.c @@ -39,6 +39,7 @@ #include #endif +#define _USE_MATH_DEFINES #include pthread_t freenect_thread; @@ -231,6 +232,21 @@ void keyPressed(unsigned char key, int x, int y) freenect_set_flag(f_dev, FREENECT_MIRROR_VIDEO, mirror); mirror = mirror ? FREENECT_OFF : FREENECT_ON; } + if (key == 'n') { + static freenect_flag_value near_mode = FREENECT_ON; + freenect_set_flag(f_dev, FREENECT_NEAR_MODE, near_mode); + near_mode = near_mode ? FREENECT_OFF : FREENECT_ON; + } + + if (key == '+') { + uint16_t brightness = freenect_get_ir_brightness(f_dev) + 2; + freenect_set_ir_brightness(f_dev, brightness); + } + if (key == '-') { + uint16_t brightness = freenect_get_ir_brightness(f_dev) - 2; + freenect_set_ir_brightness(f_dev, brightness); + } + if (key == '1') { freenect_set_led(f_dev,LED_GREEN); } @@ -253,6 +269,7 @@ void keyPressed(unsigned char key, int x, int y) if (key == '0') { freenect_set_led(f_dev,LED_OFF); } + if (key == 'o') { if (camera_rotate) { camera_rotate = 0; @@ -414,9 +431,9 @@ void *freenect_threadfunc(void *arg) freenect_start_depth(f_dev); freenect_start_video(f_dev); - printf("'w' - tilt up, 's' - level, 'x' - tilt down, '0'-'6' - select LED mode \n"); + printf("'w' - tilt up, 's' - level, 'x' - tilt down, '0'-'6' - select LED mode, '+' & '-' - change IR intensity \n"); printf("'f' - change video format, 'm' - mirror video, 'o' - rotate video with accelerometer \n"); - printf("'e' - auto exposure, 'b' - white balance, 'r' - raw color \n"); + printf("'e' - auto exposure, 'b' - white balance, 'r' - raw color, 'n' - near mode (K4W only) \n"); while (!die && freenect_process_events(f_ctx) >= 0) { //Throttle the text output diff --git a/examples/micview.c b/examples/micview.c index fde49cd5..802d3b4e 100644 --- a/examples/micview.c +++ b/examples/micview.c @@ -180,10 +180,10 @@ int main(int argc, char** argv) { state.max_samples = 256 * 60; state.current_idx = 0; - state.buffers[0] = malloc(state.max_samples * sizeof(int32_t)); - state.buffers[1] = malloc(state.max_samples * sizeof(int32_t)); - state.buffers[2] = malloc(state.max_samples * sizeof(int32_t)); - state.buffers[3] = malloc(state.max_samples * sizeof(int32_t)); + state.buffers[0] = (int32_t*)malloc(state.max_samples * sizeof(int32_t)); + state.buffers[1] = (int32_t*)malloc(state.max_samples * sizeof(int32_t)); + state.buffers[2] = (int32_t*)malloc(state.max_samples * sizeof(int32_t)); + state.buffers[3] = (int32_t*)malloc(state.max_samples * sizeof(int32_t)); memset(state.buffers[0], 0, state.max_samples * sizeof(int32_t)); memset(state.buffers[1], 0, state.max_samples * sizeof(int32_t)); memset(state.buffers[2], 0, state.max_samples * sizeof(int32_t)); diff --git a/fakenect/fakenect.sh.in b/fakenect/fakenect.sh.in index 371520ea..af6aabcc 100755 --- a/fakenect/fakenect.sh.in +++ b/fakenect/fakenect.sh.in @@ -42,7 +42,7 @@ export FAKENECT_PATH=$1 # set link path (LD_LIBRARY_PATH for Linux, DYLIB_LIBRARY_PATH for OS X) if [ `uname` == "Darwin" ]; then - export DYLD_LIBRARY_PATH="@CMAKE_INSTALL_PREFIX@/@PROJECT_LIBRARY_INSTALL_DIR@/fakenect/:${LD_LIBRARY_PATH}" + export DYLD_LIBRARY_PATH="@CMAKE_INSTALL_PREFIX@/@PROJECT_LIBRARY_INSTALL_DIR@/fakenect/:${DYLD_LIBRARY_PATH}" else export LD_LIBRARY_PATH="@CMAKE_INSTALL_PREFIX@/@PROJECT_LIBRARY_INSTALL_DIR@/fakenect/:${LD_LIBRARY_PATH}" fi diff --git a/include/libfreenect.h b/include/libfreenect.h index edc38985..08397c04 100644 --- a/include/libfreenect.h +++ b/include/libfreenect.h @@ -115,6 +115,7 @@ typedef enum { // arbitrary bitfields to support flag combination FREENECT_MIRROR_DEPTH = 1 << 16, FREENECT_MIRROR_VIDEO = 1 << 17, + FREENECT_NEAR_MODE = 1 << 18, // K4W only } freenect_flag; /// Possible values for setting each `freenect_flag` @@ -669,6 +670,24 @@ FREENECTAPI int freenect_set_depth_mode(freenect_device* dev, const freenect_fra */ FREENECTAPI int freenect_set_flag(freenect_device *dev, freenect_flag flag, freenect_flag_value value); +/** + * Returns the brightness of the IR projector + * + * @param dev Device to get IR brightness + * + * @return IR brightness value in the range 1 - 50, < 0 if error + */ +FREENECTAPI int freenect_get_ir_brightness(freenect_device *dev); + +/** + * Sets the brightness of the IR projector + * + * @param dev Device to set IR brightness + * @param brighness Brightness value in range 1 - 50 + * + * @return 0 on success, < 0 if error + */ +FREENECTAPI int freenect_set_ir_brightness(freenect_device *dev, uint16_t brightness); /** * Allows the user to specify a pointer to the audio firmware in memory for the Xbox 360 Kinect diff --git a/include/libfreenect_registration.h b/include/libfreenect_registration.h index 43aeb973..a17a3437 100644 --- a/include/libfreenect_registration.h +++ b/include/libfreenect_registration.h @@ -120,6 +120,11 @@ FREENECTAPI int freenect_destroy_registration(freenect_registration* reg); FREENECTAPI void freenect_camera_to_world(freenect_device* dev, int cx, int cy, int wz, double* wx, double* wy); +// helper function to map one FREENECT_VIDEO_RGB image to a FREENECT_DEPTH_MM +// image (inverse mapping to FREENECT_DEPTH_REGISTERED, which is depth -> RGB) +FREENECTAPI void freenect_map_rgb_to_depth( freenect_device* dev, + uint16_t* depth_mm, uint8_t* rgb_raw, uint8_t* rgb_registered ); + #ifdef __cplusplus } #endif diff --git a/platform/windows/unistd.h b/platform/windows/unistd.h index 2652b31a..098ea47f 100644 --- a/platform/windows/unistd.h +++ b/platform/windows/unistd.h @@ -27,6 +27,7 @@ #pragma once #include +#include // MinGW defines _SSIZE_T_DEFINED in sys/types.h when it defines ssize_t to be a long. // Redefining it causes an error. @@ -35,3 +36,16 @@ #define _SSIZE_T_DEFINED typedef long ssize_t; #endif // _SSIZE_T_DEFINED + + +static void usleep(__int64 usec) +{ + // Convert to 100 nanosecond interval, negative for relative time. + LARGE_INTEGER ft; + ft.QuadPart = -(10 * usec); + + HANDLE timer = CreateWaitableTimer(NULL, TRUE, NULL); + SetWaitableTimer(timer, &ft, 0, NULL, NULL, 0); + WaitForSingleObject(timer, INFINITE); + CloseHandle(timer); +} diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c38b5cb0..841873a0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,13 +2,8 @@ # Build for main library ###################################################################################### -include_directories (${CMAKE_CURRENT_SOURCE_DIR}) - +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) include_directories(${LIBUSB_1_INCLUDE_DIRS}) -LIST(APPEND SRC core.c tilt.c cameras.c flags.c usb_libusb10.c registration.c audio.c loader.c) -IF(WIN32) - set_source_files_properties(${SRC} PROPERTIES LANGUAGE CXX) -ENDIF(WIN32) # Audio Firmware include(FindPythonInterp) @@ -24,6 +19,8 @@ ELSE(BUILD_REDIST_PACKAGE) install (FILES "${CMAKE_CURRENT_BINARY_DIR}/../audios.bin" DESTINATION "${CMAKE_INSTALL_PREFIX}/share/libfreenect") ENDIF() +LIST(APPEND SRC core.c tilt.c cameras.c flags.c usb_libusb10.c registration.c audio.c loader.c) + add_library (freenect SHARED ${SRC}) set_target_properties ( freenect PROPERTIES VERSION ${PROJECT_VER} diff --git a/src/cameras.c b/src/cameras.c index 12eaba22..834fefb3 100644 --- a/src/cameras.c +++ b/src/cameras.c @@ -841,7 +841,6 @@ static int freenect_fetch_zero_plane_info(freenect_device *dev) int freenect_start_depth(freenect_device *dev) { freenect_context *ctx = dev->parent; - int res; if (dev->depth.running) return -1; @@ -869,7 +868,12 @@ int freenect_start_depth(freenect_device *dev) return -1; } - res = fnusb_start_iso(&dev->usb_cam, &dev->depth_isoc, depth_process, 0x82, NUM_XFERS, PKTS_PER_XFER, DEPTH_PKTBUF); + const unsigned char depth_endpoint = 0x82; + int packet_size = fnusb_get_max_iso_packet_size(&dev->usb_cam, depth_endpoint, DEPTH_PKTBUF); + + FN_INFO("[Stream 70] Negotiated packet size %d\n", packet_size); + + int res = fnusb_start_iso(&dev->usb_cam, &dev->depth_isoc, depth_process, depth_endpoint, NUM_XFERS, PKTS_PER_XFER, packet_size); if (res < 0) return res; @@ -901,7 +905,6 @@ int freenect_start_depth(freenect_device *dev) int freenect_start_video(freenect_device *dev) { freenect_context *ctx = dev->parent; - int res; if (dev->video.running) return -1; @@ -1015,7 +1018,12 @@ int freenect_start_video(freenect_device *dev) break; } - res = fnusb_start_iso(&dev->usb_cam, &dev->video_isoc, video_process, 0x81, NUM_XFERS, PKTS_PER_XFER, VIDEO_PKTBUF); + const unsigned char video_endpoint = 0x81; + int packet_size = fnusb_get_max_iso_packet_size(&dev->usb_cam, video_endpoint, VIDEO_PKTBUF); + + FN_INFO("[Stream 80] Negotiated packet size %d\n", packet_size); + + int res = fnusb_start_iso(&dev->usb_cam, &dev->video_isoc, video_process, video_endpoint, NUM_XFERS, PKTS_PER_XFER, packet_size); if (res < 0) return res; diff --git a/src/core.c b/src/core.c index a03f7247..006152a6 100644 --- a/src/core.c +++ b/src/core.c @@ -188,7 +188,7 @@ FREENECTAPI int freenect_open_device_by_camera_serial(freenect_context *ctx, fre int count = fnusb_list_device_attributes(&ctx->usb, &attrlist); if (count < 0) { FN_ERROR("freenect_open_device_by_camera_serial: Couldn't enumerate serial numbers\n"); - return -1; + return count; } int index = 0; for(item = attrlist ; item != NULL; item = item->next , index++) { diff --git a/src/flags.c b/src/flags.c index 7036f487..f0cb9772 100644 --- a/src/flags.c +++ b/src/flags.c @@ -25,13 +25,11 @@ */ #include // for memcpy +#include // for usleep #include "freenect_internal.h" #include "flags.h" -// freenect_set_flag is the only function exposed in libfreenect.h -// The rest are available internally via #include flags.h - FN_INTERNAL int register_for_flag(int flag) { switch(flag) @@ -47,6 +45,34 @@ FN_INTERNAL int register_for_flag(int flag) int freenect_set_flag(freenect_device *dev, freenect_flag flag, freenect_flag_value value) { + freenect_context *ctx = dev->parent; + + if (flag == FREENECT_NEAR_MODE) + { + if (dev->usb_cam.PID != PID_K4W_CAMERA) + { + FN_WARNING("Near mode is only supported by K4W"); + return -1; + } + + if (value == FREENECT_ON) + { + int ret = write_register(dev, 0x0015, 0x0007); + if (ret < 0) + return ret; + usleep(100000); + return write_register(dev, 0x02EF, 0x0000); + } + else + { + int ret = write_register(dev, 0x0015, 0x001E); + if (ret < 0) + return ret; + usleep(100000); + return write_register(dev, 0x02EF, 0x0190); + } + } + if (flag >= (1 << 16)) { int reg = register_for_flag(flag); @@ -67,6 +93,42 @@ int freenect_set_flag(freenect_device *dev, freenect_flag flag, freenect_flag_va return write_cmos_register(dev, 0x0106, cmos_value); } +int freenect_get_ir_brightness(freenect_device *dev) +{ + freenect_context *ctx = dev->parent; + + const uint16_t brightness = read_register(dev, 0x15); + if (brightness == UINT16_MAX) + { + FN_WARNING("Failed to get IR brightness!"); + return -1; + } + + return brightness; +} + +int freenect_set_ir_brightness(freenect_device *dev, uint16_t brightness) +{ + freenect_context *ctx = dev->parent; + + if (brightness < 1) + { + brightness = 1; + } + if (brightness > 50) + { + brightness = 50; + } + + const int ret = write_register(dev, 0x15, brightness); + if (ret < 0) + { + FN_WARNING("Failed to set IR brightness"); + } + + return ret; +} + typedef struct { uint8_t magic[2]; uint16_t len; diff --git a/src/freenect_internal.h b/src/freenect_internal.h index 3cee98e8..c8a5f10d 100644 --- a/src/freenect_internal.h +++ b/src/freenect_internal.h @@ -253,6 +253,6 @@ struct _freenect_device { fnusb_dev usb_motor; freenect_raw_tilt_state raw_state; - int device_does_motor_control_with_audio; - int motor_control_with_audio_enabled; + int device_does_motor_control_with_audio; + int motor_control_with_audio_enabled; }; diff --git a/src/registration.c b/src/registration.c index 7111ae1f..efd38645 100644 --- a/src/registration.c +++ b/src/registration.c @@ -329,6 +329,73 @@ void freenect_camera_to_world(freenect_device* dev, int cx, int cy, int wz, doub *wy = (double)(cy - DEPTH_Y_RES/2) * factor; } +/// RGB -> depth mapping function (inverse of default FREENECT_DEPTH_REGISTERED mapping) +void freenect_map_rgb_to_depth(freenect_device* dev, uint16_t* depth_mm, uint8_t* rgb_raw, uint8_t* rgb_registered) +{ + uint32_t target_offset = dev->registration.reg_pad_info.start_lines * DEPTH_Y_RES; + int x,y; + int* map = (int*)malloc(DEPTH_Y_RES*DEPTH_X_RES* sizeof(int)); + unsigned short* zBuffer = (unsigned short*)malloc(DEPTH_Y_RES*DEPTH_X_RES* sizeof(unsigned short)); + memset(zBuffer, DEPTH_NO_MM_VALUE, DEPTH_X_RES*DEPTH_Y_RES * sizeof(unsigned short)); + + for (y = 0; y < DEPTH_Y_RES; y++) for (x = 0; x < DEPTH_X_RES; x++) { + uint32_t index = y * DEPTH_X_RES + x; + uint32_t cx,cy,cindex; + + map[index] = -1; + + int wz = depth_mm[index]; + + if (wz == DEPTH_NO_MM_VALUE) { + continue; + } + + // coordinates in rgb image corresponding to x,y in depth image + cx = (dev->registration.registration_table[index][0] + dev->registration.depth_to_rgb_shift[wz]) / REG_X_VAL_SCALE; + cy = dev->registration.registration_table[index][1] - target_offset; + + if (cx >= DEPTH_X_RES) continue; + + cindex = cy*DEPTH_X_RES+cx; + map[index] = cindex; + + if (zBuffer[cindex] == DEPTH_NO_MM_VALUE || zBuffer[cindex] > wz) { + zBuffer[cindex] = wz; + } + } + + for (y = 0; y < DEPTH_Y_RES; y++) for (x = 0; x < DEPTH_X_RES; x++) { + uint32_t index = y * DEPTH_X_RES + x; + uint32_t cindex = map[index]; + + // pixels without depth data or out of bounds are black + if (cindex == -1) { + index *= 3; + rgb_registered[index+0] = 0; + rgb_registered[index+1] = 0; + rgb_registered[index+2] = 0; + + continue; + } + + unsigned short currentDepth = depth_mm[index]; + unsigned short minDepth = zBuffer[cindex]; + + // filters out pixels that are occluded + if (currentDepth <= minDepth) { + index *= 3; + cindex *= 3; + + rgb_registered[index+0] = rgb_raw[cindex+0]; + rgb_registered[index+1] = rgb_raw[cindex+1]; + rgb_registered[index+2] = rgb_raw[cindex+2]; + } + } + + free(zBuffer); + free(map); +} + /// Allocate and fill registration tables /// This function should be called every time a new video (not depth!) mode is /// activated. diff --git a/src/tilt.c b/src/tilt.c index c1a61b15..4015607a 100644 --- a/src/tilt.c +++ b/src/tilt.c @@ -235,33 +235,30 @@ int freenect_set_tilt_degs(freenect_device *dev, double angle) return ret; } - FN_INTERNAL int fnusb_set_led_alt(libusb_device_handle * dev, freenect_context * ctx, freenect_led_options state) { - typedef enum { - LED_ALT_OFF = 1, - LED_ALT_BLINK_GREEN = 2, - LED_ALT_SOLID_GREEN = 3, - LED_ALT_SOLID_RED = 4, - }led_alt_state; - - int transferred = 0; - int res = 0; - - //The LED states are different between K4W/1473 and older 1414 - if( state == LED_GREEN ){ - state = (freenect_led_options)LED_ALT_SOLID_GREEN; - }else if( state == LED_RED ){ - state = (freenect_led_options)LED_ALT_SOLID_RED; - }else if( state == LED_YELLOW ){ - state = (freenect_led_options)LED_ALT_SOLID_GREEN; - }else if( state == LED_OFF ){ - state = (freenect_led_options)LED_ALT_OFF; - }else if( state == LED_BLINK_GREEN ){ - state = (freenect_led_options)LED_ALT_BLINK_GREEN; - }else{ - state = LED_GREEN; - } + enum + { + LED_ALT_OFF = 1, + LED_ALT_BLINK_GREEN = 2, + LED_ALT_SOLID_GREEN = 3, + LED_ALT_SOLID_RED = 4, + }; + + //The LED states are different between K4W/1473 and older 1414 + if( state == LED_GREEN ){ + state = (freenect_led_options)LED_ALT_SOLID_GREEN; + }else if( state == LED_RED ){ + state = (freenect_led_options)LED_ALT_SOLID_RED; + }else if( state == LED_YELLOW ){ + state = (freenect_led_options)LED_ALT_SOLID_GREEN; + }else if( state == LED_OFF ){ + state = (freenect_led_options)LED_ALT_OFF; + }else if( state == LED_BLINK_GREEN ){ + state = (freenect_led_options)LED_ALT_BLINK_GREEN; + }else{ + state = LED_GREEN; + } fn_alt_motor_command cmd; cmd.magic = fn_le32(0x06022009); @@ -272,8 +269,9 @@ FN_INTERNAL int fnusb_set_led_alt(libusb_device_handle * dev, freenect_context * unsigned char buffer[20]; memcpy(buffer, &cmd, 20); - - res = libusb_bulk_transfer(dev, 0x01, buffer, 20, &transferred, 100); + + int transferred = 0; + int res = libusb_bulk_transfer(dev, 0x01, buffer, 20, &transferred, 100); if (res != 0) { FN_WARNING("fnusb_set_led_alt(): libusb_bulk_transfer failed: %d (transferred = %d)\n", res, transferred); return res; diff --git a/src/usb_libusb10.c b/src/usb_libusb10.c index b51de128..43f1443e 100644 --- a/src/usb_libusb10.c +++ b/src/usb_libusb10.c @@ -256,8 +256,8 @@ FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index) { freenect_context *ctx = dev->parent; - dev->device_does_motor_control_with_audio = 0; - dev->motor_control_with_audio_enabled = 0; + dev->device_does_motor_control_with_audio = 0; + dev->motor_control_with_audio_enabled = 0; dev->usb_cam.parent = dev; dev->usb_cam.dev = NULL; @@ -291,6 +291,9 @@ FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index) // If the index given by the user matches our camera index if (nr_cam == index) { + dev->usb_cam.VID = desc.idVendor; + dev->usb_cam.PID = desc.idProduct; + res = libusb_open (devs[i], &dev->usb_cam.dev); if (res < 0 || !dev->usb_cam.dev) { @@ -416,6 +419,9 @@ FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index) // If the index given by the user matches our camera index if (nr_mot == index) { + dev->usb_motor.VID = desc.idVendor; + dev->usb_motor.PID = desc.idProduct; + res = libusb_open (devs[i], &dev->usb_motor.dev); if (res < 0 || !dev->usb_motor.dev) { @@ -444,6 +450,9 @@ FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index) // If the index given by the user matches our audio index if (nr_audio == index) { + dev->usb_audio.VID = desc.idVendor; + dev->usb_audio.PID = desc.idProduct; + res = libusb_open (devs[i], &dev->usb_audio.dev); if (res < 0 || !dev->usb_audio.dev) { @@ -752,10 +761,22 @@ static void LIBUSB_CALL iso_callback(struct libusb_transfer *xfer) } } -FN_INTERNAL int fnusb_start_iso(fnusb_dev *dev, fnusb_isoc_stream *strm, fnusb_iso_cb cb, int ep, int xfers, int pkts, int len) +FN_INTERNAL int fnusb_get_max_iso_packet_size(fnusb_dev *dev, unsigned char endpoint, int default_size) +{ + freenect_context *ctx = dev->parent->parent; + + int size = libusb_get_max_iso_packet_size(libusb_get_device(dev->dev), endpoint); + if (size <= 0) + { + FN_WARNING("libusb_get_max_iso_packet_size() returned %d; using default %d\n", size, default_size); + size = default_size; + } + return size; +} + +FN_INTERNAL int fnusb_start_iso(fnusb_dev *dev, fnusb_isoc_stream *strm, fnusb_iso_cb cb, unsigned char endpoint, int xfers, int pkts, int len) { freenect_context *ctx = dev->parent->parent; - int ret, i; strm->parent = dev; strm->cb = cb; @@ -767,27 +788,36 @@ FN_INTERNAL int fnusb_start_iso(fnusb_dev *dev, fnusb_isoc_stream *strm, fnusb_i strm->dead = 0; strm->dead_xfers = 0; + int i; uint8_t *bufp = strm->buffer; - for (i=0; ixfers[i] = libusb_alloc_transfer(pkts); - - libusb_fill_iso_transfer(strm->xfers[i], dev->dev, ep, bufp, pkts * len, pkts, iso_callback, strm, 0); - - libusb_set_iso_packet_lengths(strm->xfers[i], len); + for (i = 0; i < xfers; i++) + { + FN_SPEW("Creating endpoint %02x transfer #%d\n", endpoint, i); - ret = libusb_submit_transfer(strm->xfers[i]); - if (ret < 0) { - FN_WARNING("Failed to submit isochronous transfer %d: %d\n", i, ret); + strm->xfers[i] = libusb_alloc_transfer(pkts); + if (strm->xfers[i] == NULL) + { + FN_WARNING("Failed to allocate transfer\n"); strm->dead_xfers++; } + else + { + libusb_fill_iso_transfer(strm->xfers[i], dev->dev, endpoint, bufp, pkts * len, pkts, iso_callback, strm, 0); + libusb_set_iso_packet_lengths(strm->xfers[i], len); + + int ret = libusb_submit_transfer(strm->xfers[i]); + if (ret < 0) + { + FN_WARNING("Failed to submit isochronous transfer %d: %d\n", i, ret); + strm->dead_xfers++; + } + } bufp += pkts*len; } return 0; - } FN_INTERNAL int fnusb_stop_iso(fnusb_dev *dev, fnusb_isoc_stream *strm) diff --git a/src/usb_libusb10.h b/src/usb_libusb10.h index 63d56d74..71a17a39 100644 --- a/src/usb_libusb10.h +++ b/src/usb_libusb10.h @@ -29,35 +29,24 @@ #include "libfreenect.h" #include +// There are a few rules: PKTS_PER_XFER * NUM_XFERS <= 1000, PKTS_PER_XFER % 8 == 0. #if defined(__APPLE__) -/* - From Github Issue 22 by Roefer - - https://github.com/OpenKinect/libfreenect/issues/#issue/22 - - The current implementation still does not reach 30 Hz on MacOS. This - is due to bad scheduling of USB transfers in libusb (Ed Note: libusb - 1.0.8). A fix can be found at - http://www.informatik.uni-bremen.de/~roefer/libusb/libusb-osx-kinect.diff - - (Ed Note: patch applies to libusb repo at 7da756e09fd) + #define DEPTH_PKTBUF 2048 + #define VIDEO_PKTBUF 2048 - In camera.c, I use PKTS_PER_XFER = 128, NUM_XFERS = 4. There are a - few rules: PKTS_PER_XFER * NUM_XFERS <= 1000, PKTS_PER_XFER % 8 == 0. -*/ -#define PKTS_PER_XFER 128 -#define NUM_XFERS 4 -#define DEPTH_PKTBUF 2048 -#define VIDEO_PKTBUF 2048 + #define PKTS_PER_XFER 128 + #define NUM_XFERS 4 #else -#ifdef _WIN32 - #define PKTS_PER_XFER 32 - #define NUM_XFERS 8 -#else - #define PKTS_PER_XFER 16 - #define NUM_XFERS 16 -#endif -#define DEPTH_PKTBUF 1920 -#define VIDEO_PKTBUF 1920 + #define DEPTH_PKTBUF 1920 + #define VIDEO_PKTBUF 1920 + + #if defined(_WIN32) + #define PKTS_PER_XFER 32 + #define NUM_XFERS 8 + #else + #define PKTS_PER_XFER 16 + #define NUM_XFERS 16 + #endif #endif typedef struct { @@ -69,6 +58,8 @@ typedef struct { freenect_device *parent; //so we can go up from the libusb userdata libusb_device_handle *dev; int device_dead; // set to 1 when the underlying libusb_device_handle vanishes (ie, Kinect was unplugged) + int VID; + int PID; } fnusb_dev; typedef struct { @@ -94,8 +85,9 @@ int fnusb_process_events_timeout(fnusb_ctx *ctx, struct timeval* timeout); int fnusb_open_subdevices(freenect_device *dev, int index); int fnusb_close_subdevices(freenect_device *dev); -int fnusb_start_iso(fnusb_dev *dev, fnusb_isoc_stream *strm, fnusb_iso_cb cb, int ep, int xfers, int pkts, int len); +int fnusb_start_iso(fnusb_dev *dev, fnusb_isoc_stream *strm, fnusb_iso_cb cb, unsigned char endpoint, int xfers, int pkts, int len); int fnusb_stop_iso(fnusb_dev *dev, fnusb_isoc_stream *strm); +int fnusb_get_max_iso_packet_size(fnusb_dev *dev, unsigned char endpoint, int default_size); int fnusb_control(fnusb_dev *dev, uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, uint8_t *data, uint16_t wLength); int fnusb_bulk(fnusb_dev *dev, uint8_t endpoint, uint8_t *data, int len, int *transferred); diff --git a/wrappers/c_sync/CMakeLists.txt b/wrappers/c_sync/CMakeLists.txt index 051453f2..bc93bb85 100644 --- a/wrappers/c_sync/CMakeLists.txt +++ b/wrappers/c_sync/CMakeLists.txt @@ -1,11 +1,8 @@ ###################################################################################### # C Synchronous Interface ###################################################################################### -if (WIN32) - set_source_files_properties(libfreenect_sync.c PROPERTIES LANGUAGE CXX) - set(THREADS_USE_PTHREADS_WIN32 true) -endif() +set(THREADS_USE_PTHREADS_WIN32 true) find_package(Threads REQUIRED) include_directories(${THREADS_PTHREADS_INCLUDE_DIR}) @@ -26,4 +23,3 @@ install (TARGETS freenect_sync_static DESTINATION "${PROJECT_LIBRARY_INSTALL_DIR}") install (FILES "libfreenect_sync.h" DESTINATION ${PROJECT_INCLUDE_INSTALL_DIR}) - diff --git a/wrappers/c_sync/libfreenect_sync.c b/wrappers/c_sync/libfreenect_sync.c index 45ffbf5a..1b2e0494 100644 --- a/wrappers/c_sync/libfreenect_sync.c +++ b/wrappers/c_sync/libfreenect_sync.c @@ -50,7 +50,7 @@ typedef struct sync_kinect { typedef int (*set_buffer_t)(freenect_device *dev, void *buf); #define MAX_KINECTS 64 -static sync_kinect_t *kinects[MAX_KINECTS] = {}; +static sync_kinect_t *kinects[MAX_KINECTS] = { 0 }; static freenect_context *ctx; static int thread_running = 0; static pthread_t thread; diff --git a/wrappers/c_sync/libfreenect_sync.h b/wrappers/c_sync/libfreenect_sync.h index d792b650..5df21265 100644 --- a/wrappers/c_sync/libfreenect_sync.h +++ b/wrappers/c_sync/libfreenect_sync.h @@ -65,7 +65,7 @@ FREENECTAPI_SYNC int freenect_sync_get_video_with_res(void **video, uint32_t *ti Nonzero on error. */ -int freenect_sync_get_video(void **video, uint32_t *timestamp, int index, freenect_video_format fmt); +FREENECTAPI_SYNC int freenect_sync_get_video(void **video, uint32_t *timestamp, int index, freenect_video_format fmt); /* Does the exact same as above, but with a default resolution, so backwards compatibilty is maintained. The Resolution is kept at the default FREENECT_RESOLUTION_MEDIUM @@ -89,7 +89,7 @@ FREENECTAPI_SYNC int freenect_sync_get_depth_with_res(void **depth, uint32_t *ti Nonzero on error. */ -int freenect_sync_get_depth(void **depth, uint32_t *timestamp, int index, freenect_depth_format fmt); +FREENECTAPI_SYNC int freenect_sync_get_depth(void **depth, uint32_t *timestamp, int index, freenect_depth_format fmt); /* Again, a wrapper function to keep backward compatibility. The Resolution is kept at the default FREENECT_RESOLUTION_MEDIUM diff --git a/wrappers/cpp/CMakeLists.txt b/wrappers/cpp/CMakeLists.txt index cdd32587..8a9b11a1 100644 --- a/wrappers/cpp/CMakeLists.txt +++ b/wrappers/cpp/CMakeLists.txt @@ -1,40 +1,20 @@ -INSTALL(FILES libfreenect.hpp - DESTINATION ${PROJECT_INCLUDE_INSTALL_DIR}) +install(FILES libfreenect.hpp + DESTINATION ${PROJECT_INCLUDE_INSTALL_DIR}) -IF(BUILD_EXAMPLES) - -if (WIN32) +if (BUILD_EXAMPLES) set(THREADS_USE_PTHREADS_WIN32 true) find_package(Threads REQUIRED) - - include_directories(${THREADS_PTHREADS_INCLUDE_DIR}) -endif() - -include_directories(.) - -add_executable(freenect-cppview cppview.cpp) -add_executable(freenect-cpp_pcview cpp_pc_view.cpp) - -# Mac just has everything already -if(APPLE) - set(CMAKE_EXE_LINKER_FLAGS "-framework OpenGL -framework GLUT") - target_link_libraries(freenect-cppview freenect) - target_link_libraries(freenect-cpp_pcview freenect) -else() - find_package(Threads REQUIRED) find_package(OpenGL REQUIRED) find_package(GLUT REQUIRED) - include_directories(${OPENGL_INCLUDE_DIR} ${GLUT_INCLUDE_DIR} ${USB_INCLUDE_DIRS}) - - target_link_libraries(freenect-cppview freenect ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB}) - target_link_libraries(freenect-cpp_pcview freenect ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT}) -endif() + include_directories(. ${THREADS_PTHREADS_INCLUDE_DIR} ${OPENGL_INCLUDE_DIR} ${GLUT_INCLUDE_DIR}) -install (TARGETS freenect-cppview - DESTINATION bin) + add_executable(freenect-cppview cppview.cpp) + add_executable(freenect-cpp_pcview cpp_pc_view.cpp) -install (TARGETS freenect-cpp_pcview - DESTINATION bin) + target_link_libraries(freenect-cppview freenect ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB}) + target_link_libraries(freenect-cpp_pcview freenect ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB}) + install(TARGETS freenect-cppview freenect-cpp_pcview + DESTINATION bin) ENDIF() diff --git a/wrappers/cpp/cppview.cpp b/wrappers/cpp/cppview.cpp old mode 100755 new mode 100644 diff --git a/wrappers/python/setup.py b/wrappers/python/setup.py index 40a0f93c..005d4da5 100755 --- a/wrappers/python/setup.py +++ b/wrappers/python/setup.py @@ -14,10 +14,16 @@ def get_cython_version(): ImportError: Can't load cython or find version """ import Cython.Compiler.Main - match = re.search('^([0-9]+)\.([0-9]+)', - Cython.Compiler.Main.Version.version) + + try: + # old way, fails for me + version = Cython.Compiler.Main.Version.version + except AttributeError: + version = Cython.Compiler.Main.version + + match = re.search('^([0-9]+)\.([0-9]+)', version) try: - return map(int, match.groups()) + return [int(g) for g in match.groups()] except AttributeError: raise ImportError