diff --git a/.gitattributes b/.gitattributes index fb5cfdb5..e69de29b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +0,0 @@ -wrappers/python/freenect.c binary diff --git a/CMakeLists.txt b/CMakeLists.txt index 479961a8..089a20b5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,7 +30,7 @@ # CMake directives ###################################################################################### -cmake_minimum_required(VERSION 2.6) +cmake_minimum_required(VERSION 2.8.12...3.12) ###################################################################################### # Project declaration and options @@ -46,12 +46,12 @@ include (FindOS) include (SetupDirectories) set (PROJECT_VER_MAJOR 0) -set (PROJECT_VER_MINOR 5) +set (PROJECT_VER_MINOR 7) set (PROJECT_VER_PATCH 5) set (PROJECT_VER "${PROJECT_VER_MAJOR}.${PROJECT_VER_MINOR}.${PROJECT_VER_PATCH}") set (PROJECT_APIVER - "${PROJECT_VER_MAJOR}.${PROJECT_VER_MINOR}") + "${PROJECT_VER_MAJOR}") OPTION(BUILD_REDIST_PACKAGE "Build libfreenect in a legally-redistributable manner (only affects audio)" ON) OPTION(BUILD_EXAMPLES "Build example programs" ON) diff --git a/OpenNI2-FreenectDriver/CMakeLists.txt b/OpenNI2-FreenectDriver/CMakeLists.txt index 483c3529..d35b4366 100644 --- a/OpenNI2-FreenectDriver/CMakeLists.txt +++ b/OpenNI2-FreenectDriver/CMakeLists.txt @@ -2,7 +2,7 @@ # OpenNI2-FreenectDriver ###################################################################################### -cmake_minimum_required(VERSION 3.1.0) +cmake_minimum_required(VERSION 3.8.2) file(GLOB HEADERS src/*.hpp src/*.h) file(GLOB SOURCES src/*.cpp) @@ -15,14 +15,14 @@ set_target_properties(FreenectDriver PROPERTIES VERSION ${PROJECT_VER} SOVERSION ${PROJECT_APIVER} OUTPUT_NAME FreenectDriver) - + add_definitions(-DPROJECT_VER="${PROJECT_VER}") include_directories(extern/OpenNI-Linux-x64-2.2.0.33/Include) include_directories(${PROJECT_SOURCE_DIR}/src) include_directories(${PROJECT_SOURCE_DIR}/wrappers/cpp) -target_compile_features(FreenectDriver PUBLIC cxx_constexpr) +target_compile_features(FreenectDriver PUBLIC cxx_std_11 cxx_constexpr) target_link_libraries(FreenectDriver freenectstatic ${MATH_LIB}) diff --git a/OpenNI2-FreenectDriver/src/DeviceDriver.cpp b/OpenNI2-FreenectDriver/src/DeviceDriver.cpp index f52586a5..8ed41f3d 100644 --- a/OpenNI2-FreenectDriver/src/DeviceDriver.cpp +++ b/OpenNI2-FreenectDriver/src/DeviceDriver.cpp @@ -141,7 +141,7 @@ namespace FreenectDriver return ONI_STATUS_OK; } } - + OniStatus setProperty(int propertyId, const void* data, int dataSize) { switch (propertyId) @@ -190,7 +190,7 @@ namespace FreenectDriver return false; } } - + OniStatus invoke(int commandId, void* data, int dataSize) { switch (commandId) @@ -247,14 +247,12 @@ namespace FreenectDriver std::string uri = devid_to_uri(i); WriteMessage("Found device " + uri); - + OniDeviceInfo info; strncpy(info.uri, uri.c_str(), ONI_MAX_STR); strncpy(info.vendor, "Microsoft", ONI_MAX_STR); strncpy(info.name, "Kinect", ONI_MAX_STR); - devices[info] = NULL; - deviceConnected(&info); - deviceStateChanged(&info, 0); + devices[info] = NULL; freenect_device* dev; if (freenect_open_device(m_ctx, &dev, i) == 0) @@ -262,6 +260,9 @@ namespace FreenectDriver info.usbVendorId = dev->usb_cam.VID; info.usbProductId = dev->usb_cam.PID; freenect_close_device(dev); + + deviceConnected(&info); + deviceStateChanged(&info, 0); } else { @@ -281,7 +282,7 @@ namespace FreenectDriver { return iter->second; } - else + else { WriteMessage("Opening device " + std::string(uri)); int id = uri_to_devid(iter->first.uri); @@ -304,7 +305,7 @@ namespace FreenectDriver { WriteMessage("Closing device " + std::string(iter->first.uri)); int id = uri_to_devid(iter->first.uri); - devices.erase(iter); + iter->second = NULL; deleteDevice(id); return; } diff --git a/OpenNI2-FreenectDriver/src/VideoStream.hpp b/OpenNI2-FreenectDriver/src/VideoStream.hpp index 6acde727..705a5449 100644 --- a/OpenNI2-FreenectDriver/src/VideoStream.hpp +++ b/OpenNI2-FreenectDriver/src/VideoStream.hpp @@ -28,6 +28,7 @@ namespace FreenectDriver frame_id(1), prev_timestamp(0), device(device), + running(false), mirroring(false) { // joy of structs diff --git a/README.md b/README.md index 8bb06f99..d0b51490 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,8 @@ Notice: If you have the newer Kinect v2 (XBox One), use [OpenKinect/libfreenect2 To build libfreenect, you'll need -- [libusb](http://libusb.info) >= 1.0.18 -- [CMake](http://cmake.org) >= 2.6 +- [libusb](http://libusb.info) >= 1.0.18 (Windows needs >= 1.0.22) +- [CMake](http://cmake.org) >= 3.12.4 - [python](http://python.org) >= 2.7 or >= 3.3 (only if BUILD_PYTHON=ON or BUILD_PYTHON2=ON or BUILD_PYTHON3=ON or BUILD_REDIST_PACKAGE=OFF) For the examples, you'll need @@ -40,11 +40,17 @@ For the examples, you'll need # cmake --build . Use CMake options to control what gets built. -For example, to build the python wrapper: +For example, to build the Python wrapper (defaults to system Python): - cmake .. -DCMAKE_BUILD_PYTHON=ON + cmake .. -DBUILD_PYTHON=ON make +Or the Python 3 wrapper: + + cmake .. -DBUILD_PYTHON3=ON + make + + You can specify a build with debug symbols: cmake .. -DCMAKE_BUILD_TYPE=debug @@ -106,7 +112,7 @@ There is also a [debian branch](https://github.com/OpenKinect/libfreenect/tree/d ### Gentoo Linux -There is a live ebuild for your convenience in [platform/linux/portage/dev-libs/libfreenect/](https://github.com/OpenKinect/libfreenect/tree/master/platform/linux/portage/dev-libs/libfreenect). +There are [dev-libs/libfreenect](https://github.com/piedar/overboard/tree/master/dev-libs/libfreenect) ebuilds in the [overboard repo](https://github.com/piedar/overboard). ### Arch Linux @@ -116,22 +122,14 @@ Alternately, the [libfreenect-git](https://aur.archlinux.org/packages/libfreenec ## Windows -As of February 2015, libusb still [does not support](https://github.com/libusb/libusb/issues/46) isochronous transfers on Windows. -This support may be patched in by performing these steps or their GUI equivalent. - - git clone https://github.com/libusb/libusb.git - cd libusb - git remote add jblake https://github.com/JoshBlake/libusbx.git - git fetch jblake - git cherry-pick c5b0af4 1c74211 - MSBuild.exe msvc/libusb_2013.sln +As of libusb 1.0.22, [libusbK isochronous transfers](https://github.com/libusb/libusb/commit/55ced7746dd697024f2042aca009b7436892bf2b) are now supported natively. There is no longer a need to compile a custom version of libusb. Use [Zadig](http://zadig.akeo.ie/) to install the libusbK driver for each device you wish to use. Follow [Fetch & Build](#fetch-build) or use Github and CMake GUI tools. Remember to supply paths to CMake so it can find dependencies. For example: - cmake .. -DLIBUSB_1_INCLUDE_DIR="C:\path\to\patched\libusb\include" -DLIBUSB_1_LIBRARY="C:\path\to\patched\libusb\libusb.lib" + cmake .. -DLIBUSB_1_INCLUDE_DIR="C:\path\to\libusb\include" -DLIBUSB_1_LIBRARY="C:\path\to\libusb\libusb.lib" # Wrappers @@ -147,6 +145,24 @@ Wrappers are not guaranteed to be API stable or up to date. - actionscript - Java (JNA) +# Fakenect + +Using fakenect, you can record a session to a directory and play it back later. + + mkdir session + fakenect-record ./session + +To use a fakenect recorded stream, just provide the fakenect lib as a pre loaded library with `LD_PRELOAD` and indicates the recorded files directory with `FAKENECT_PATH`. + +- Sample with python wrappers : +```shell + LD_PRELOAD="/usr/local/lib/fakenect/libfakenect.so" FAKENECT_PATH="./session" python ./wrappers/python/demo_cv_sync.py +``` +- Sample with C bin : +```shell + LD_PRELOAD="/usr/local/lib/fakenect/libfakenect.so" FAKENECT_PATH="./session" freenect-glview +``` + # Code Contributions In order of importance: diff --git a/cmake_modules/ChooseOpenGLTarget.cmake b/cmake_modules/ChooseOpenGLTarget.cmake new file mode 100644 index 00000000..999df793 --- /dev/null +++ b/cmake_modules/ChooseOpenGLTarget.cmake @@ -0,0 +1,11 @@ +# For maximum compatibility, choose the OpenGL target dynamically. +# On Linux with GLVND +# OpenGL::OpenGL gives us just what we need without GLX or EGL +# OpenGL::GL works as a fallback, but only if GLX is available +# On Linux without GLVND, OSX, Windows +# OpenGL::GL is the only option +if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.12) + set(OPENGL_TARGET "$,OpenGL::OpenGL,OpenGL::GL>") +else() + set(OPENGL_TARGET "$,OpenGL::OpenGL,OpenGL::GL>") +endif() diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index c37b61af..9097da77 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -2,6 +2,8 @@ # Packages needed for examples ###################################################################################### +cmake_minimum_required(VERSION 3.10) + # These examples have no external dependencies and should always build. add_executable(freenect-camtest camtest.c) add_executable(freenect-wavrecord wavrecord.c) @@ -10,13 +12,13 @@ target_link_libraries(freenect-wavrecord freenect) install(TARGETS freenect-camtest freenect-wavrecord DESTINATION bin) -# All viewers need pthreads and GLUT. +# Most viewers need pthreads and GLUT. set(THREADS_USE_PTHREADS_WIN32 true) find_package(Threads) -find_package(OpenGL) +find_package(OpenGL COMPONENTS OpenGL) find_package(GLUT) -if (Threads_FOUND AND OPENGL_FOUND AND GLUT_FOUND) +if (Threads_FOUND AND OpenGL_OpenGL_FOUND AND GLUT_FOUND) include_directories(${THREADS_PTHREADS_INCLUDE_DIR} ${OPENGL_INCLUDE_DIR} ${GLUT_INCLUDE_DIR}) add_executable(freenect-glview glview.c) @@ -25,11 +27,12 @@ if (Threads_FOUND AND OPENGL_FOUND AND GLUT_FOUND) 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-micview freenect ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB}) + include(ChooseOpenGLTarget) + target_link_libraries(freenect-glview freenect "${OPENGL_TARGET}" GLUT::GLUT ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB}) + target_link_libraries(freenect-regview freenect "${OPENGL_TARGET}" GLUT::GLUT ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB}) + target_link_libraries(freenect-hiview freenect "${OPENGL_TARGET}" GLUT::GLUT ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB}) + target_link_libraries(freenect-chunkview freenect "${OPENGL_TARGET}" GLUT::GLUT ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB}) + target_link_libraries(freenect-micview freenect "${OPENGL_TARGET}" GLUT::GLUT ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB}) install(TARGETS freenect-glview freenect-regview freenect-hiview freenect-chunkview freenect-micview DESTINATION bin) @@ -37,22 +40,22 @@ endif () # A few examples use c_sync. if (BUILD_C_SYNC) - 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}) + target_link_libraries(freenect-regtest freenect_sync ${MATH_LIB}) + target_link_libraries(freenect-tiltdemo freenect_sync ${MATH_LIB}) install(TARGETS freenect-regtest freenect-tiltdemo DESTINATION bin) - if (OPENGL_FOUND AND GLUT_FOUND) + if (OpenGL_OpenGL_FOUND AND GLUT_FOUND) + include_directories(${OPENGL_INCLUDE_DIR} ${GLUT_INCLUDE_DIR}) add_executable(freenect-glpclview glpclview.c) - target_link_libraries(freenect-glpclview freenect_sync ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB}) + include(ChooseOpenGLTarget) + target_link_libraries(freenect-glpclview freenect_sync "${OPENGL_TARGET}" GLUT::GLUT ${MATH_LIB}) install(TARGETS freenect-glpclview DESTINATION bin) endif () diff --git a/examples/chunkview.c b/examples/chunkview.c index 71c7dfa7..512c281a 100644 --- a/examples/chunkview.c +++ b/examples/chunkview.c @@ -30,7 +30,9 @@ #include #include #include "libfreenect.h" - +#ifdef _MSC_VER +#define HAVE_STRUCT_TIMESPEC +#endif #include #if defined(__APPLE__) diff --git a/examples/glpclview.c b/examples/glpclview.c index 3b89cb66..2235d2f4 100644 --- a/examples/glpclview.c +++ b/examples/glpclview.c @@ -45,6 +45,15 @@ int rotangles[2] = {0}; // Panning angles float zoom = 1; // zoom factor int color = 1; // Use the RGB texture or just draw it as color +// implemented here to avoid dependency on libGLU +void gluPerspective(GLdouble fovY, GLdouble aspect, GLdouble zNear, GLdouble zFar) +{ + const double pi = acos(-1); + const GLdouble fH = tan(fovY / 360 * pi) * zNear; + const GLdouble fW = fH * aspect; + glFrustum(-fW, fW, -fH, fH, zNear, zFar); +} + // Do the projection from u,v,depth to X,Y,Z directly in an opengl matrix // These numbers come from a combination of the ros kinect_node wiki, and // nicolas burrus' posts. diff --git a/examples/glview.c b/examples/glview.c index 9c67d6f7..480b0eb6 100644 --- a/examples/glview.c +++ b/examples/glview.c @@ -31,6 +31,9 @@ #include #include "libfreenect.h" +#ifdef _MSC_VER +#define HAVE_STRUCT_TIMESPEC +#endif #include #if defined(__APPLE__) @@ -214,6 +217,8 @@ void keyPressed(unsigned char key, int x, int y) if (key == 'e') { static freenect_flag_value auto_exposure = FREENECT_ON; freenect_set_flag(f_dev, FREENECT_AUTO_EXPOSURE, auto_exposure); + freenect_set_flag(f_dev, FREENECT_AUTO_FLICKER, auto_exposure); + freenect_set_flag(f_dev, FREENECT_AUTO_WHITE_BALANCE, auto_exposure); auto_exposure = auto_exposure ? FREENECT_OFF : FREENECT_ON; } if (key == 'b') { diff --git a/examples/hiview.c b/examples/hiview.c index 0143ce60..528cba82 100644 --- a/examples/hiview.c +++ b/examples/hiview.c @@ -31,6 +31,9 @@ #include #include "libfreenect.h" +#ifdef _MSC_VER +#define HAVE_STRUCT_TIMESPEC +#endif #include #if defined(__APPLE__) diff --git a/examples/micview.c b/examples/micview.c index 802d3b4e..0efdde93 100644 --- a/examples/micview.c +++ b/examples/micview.c @@ -26,9 +26,13 @@ #include "libfreenect.h" #include "libfreenect_audio.h" +#include #include #include #include +#ifdef _MSC_VER +#define HAVE_STRUCT_TIMESPEC +#endif #include #if defined(__APPLE__) @@ -40,6 +44,8 @@ pthread_t freenect_thread; volatile int die = 0; +int window; + static freenect_context* f_ctx; static freenect_device* f_dev; @@ -149,7 +155,8 @@ void Reshape(int w, int h) { void Keyboard(unsigned char key, int x, int y) { if(key == 'q') { die = 1; - pthread_exit(NULL); + pthread_join(freenect_thread, NULL); + glutDestroyWindow(window); } if(key == 32) { paused = !paused; @@ -205,7 +212,7 @@ int main(int argc, char** argv) { glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_ALPHA ); glutInitWindowSize(800, 600); glutInitWindowPosition(0, 0); - glutCreateWindow("Microphones"); + window = glutCreateWindow("Microphones"); glClearColor(0.0, 0.0, 0.0, 0.0); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); diff --git a/examples/regview.c b/examples/regview.c index 79f2f126..ae8d8afb 100644 --- a/examples/regview.c +++ b/examples/regview.c @@ -31,6 +31,9 @@ #include #include "libfreenect.h" +#ifdef _MSC_VER +#define HAVE_STRUCT_TIMESPEC +#endif #include #include diff --git a/fakenect/CMakeLists.txt b/fakenect/CMakeLists.txt index f1e36e39..9d5ec831 100644 --- a/fakenect/CMakeLists.txt +++ b/fakenect/CMakeLists.txt @@ -3,17 +3,18 @@ ###################################################################################### SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin) SET(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib/fakenect) -add_library (fakenect SHARED fakenect.c) +include_directories(../src) +add_library (fakenect SHARED fakenect.c parson.c ../src/registration.c) set_target_properties ( fakenect PROPERTIES VERSION ${PROJECT_VER} SOVERSION ${PROJECT_APIVER} - OUTPUT_NAME freenect) + OUTPUT_NAME fakenect) target_link_libraries(fakenect ${MATH_LIB}) install (TARGETS fakenect DESTINATION "${PROJECT_LIBRARY_INSTALL_DIR}/fakenect") -add_executable(fakenect-record record.c) +add_executable(fakenect-record record.c parson.c) target_link_libraries(fakenect-record freenect ${MATH_LIB}) install (TARGETS fakenect-record DESTINATION bin) diff --git a/fakenect/README b/fakenect/README deleted file mode 100644 index 0bc83228..00000000 --- a/fakenect/README +++ /dev/null @@ -1,39 +0,0 @@ -Fakenect -(c) 2010 Brandyn White - -See this blog post for more info -http://brandynwhite.com/fakenect-openkinect-driver-simulator-experime - -Description -This consists of a "record" program to save dumps from the kinect sensor and a library that can be linked to, providing an interface compatible with freenect. This allows you to save data and repeat for experiments, debug problems, share datasets, and experiment with the kinect without having one. - -Record -./record my_output // NOTE: output directory is created for you - -The program takes one argument (the output directory) and saves the acceleration, depth, and rgb data as individual files with names in the form "TYPE-CURRENTIME-TIMESTAMP" where TYPE is either (a)ccel, (d)epth, or (r)gb, TIMESTAMP corresponds to the timestamp associated with the observation (or in the case of accel, the last timestamp seen), and CURRENTTIME corresponds to a floating point version of the time in seconds. The purpose of storing the current time is so that delays can be recreated exactly as they occurred. For RGB and DEPTH the dump is just the entirety of the data provided in PPM and PGM formats respectively (just a 1 line header above the raw dump). For ACCEL, the dump is the 'freenect_raw_tilt_state'. Only the front part of the file name is used, with the rest left undefined (extension, extra info, etc). - -A file called INDEX.txt is also output with all of the filenames local to that directory to simplify the format (e.g., no need to read the directory structure). - -Here is an example of using the program -mkdir out -sudo ./record out - -And it will keep running, when you want to stop it, hit Ctrl-C and the signal will be caught, runloop stopped, and everything will be stored cleanly. - -Library -Use the resulting fakenect .so dynamically instead of libfreenect. - -We read 1 update from the index per call, so this needs to be called in a loop like usual. If the index line is a Depth/RGB image the provided callback is called. If the index line is accelerometer data, then it is used to update our internal state. If you query for the accelerometer data you get the last sensor reading that we have. The time delays are compensated as best as we can to match those from the original data and current run conditions (e.g., if it takes longer to run this code then we wait less). - -Build -This is built with the main cmake script. - -This gives you a build/lib/fakenect/libfreenect.so (note that it has the same name, but it is not the same) that you dynamically link in instead of libfreenect.so. - -Evaluation -There is a demo in wrappers/python, see the README there - -Here is an example of calling the cython demo -sudo LD_LIBRARY_PATH="../../../fakenect/" FAKENECT_PATH="thanksgiving0" python demo_cv_depth_show.py - -Note the FAKENECT_PATH, you pass in the path to a directory made with "record" \ No newline at end of file diff --git a/fakenect/fakenect.c b/fakenect/fakenect.c index 5a172fd0..8fee220e 100644 --- a/fakenect/fakenect.c +++ b/fakenect/fakenect.c @@ -24,33 +24,75 @@ */ #include "libfreenect.h" +#include "freenect_internal.h" #include "platform.h" +#include "parson.h" +#include "registration.h" #include #include #include #include #include #include +#include +#include #define GRAVITY 9.80665 // The dev and ctx are just faked with these numbers -static freenect_device *fake_dev = (freenect_device *)1234; +static freenect_device fake_dev_singleton; +static freenect_device *fake_dev = &fake_dev_singleton; static freenect_context *fake_ctx = (freenect_context *)5678; static freenect_depth_cb cur_depth_cb = NULL; -static freenect_video_cb cur_rgb_cb = NULL; +static freenect_video_cb cur_video_cb = NULL; static char *input_path = NULL; static FILE *index_fp = NULL; static freenect_raw_tilt_state state = { 0 }; +static uint16_t ir_brightness = 25; static int already_warned = 0; static double playback_prev_time = 0.; static double record_prev_time = 0.; -static void *depth_buffer = NULL; -static void *rgb_buffer = NULL; +static void *user_depth_buf = NULL; +static void *user_video_buf = NULL; static int depth_running = 0; static int rgb_running = 0; static void *user_ptr = NULL; +static bool loop_playback = true; + +#define MAKE_RESERVED(res, fmt) (uint32_t)(((res & 0xff) << 8) | (((fmt & 0xff)))) +#define RESERVED_TO_RESOLUTION(reserved) (freenect_resolution)((reserved >> 8) & 0xff) +#define RESERVED_TO_FORMAT(reserved) ((reserved) & 0xff) + +static freenect_frame_mode rgb_video_mode = + {MAKE_RESERVED(FREENECT_RESOLUTION_MEDIUM, FREENECT_VIDEO_RGB), + FREENECT_RESOLUTION_MEDIUM, {FREENECT_VIDEO_RGB}, + 640*480*3, 640, 480, 24, 0, 30, 1 }; +static freenect_frame_mode yuv_video_mode = + {MAKE_RESERVED(FREENECT_RESOLUTION_MEDIUM, FREENECT_VIDEO_YUV_RAW), + FREENECT_RESOLUTION_MEDIUM, {FREENECT_VIDEO_YUV_RAW}, + 640*480*2, 640, 480, 16, 0, 15, 1 }; + +static freenect_frame_mode video_mode; + +static freenect_frame_mode depth_11_mode = + {MAKE_RESERVED(FREENECT_RESOLUTION_MEDIUM, FREENECT_DEPTH_11BIT), + FREENECT_RESOLUTION_MEDIUM, {FREENECT_DEPTH_11BIT}, + 640*480*2, 640, 480, 11, 5, 30, 1}; +static freenect_frame_mode depth_registered_mode = + {MAKE_RESERVED(FREENECT_RESOLUTION_MEDIUM, FREENECT_DEPTH_REGISTERED), + FREENECT_RESOLUTION_MEDIUM, {FREENECT_DEPTH_REGISTERED}, + 640*480*2, 640, 480, 16, 0, 30, 1}; +static freenect_frame_mode depth_mm_mode = + {MAKE_RESERVED(FREENECT_RESOLUTION_MEDIUM, FREENECT_DEPTH_MM), + FREENECT_RESOLUTION_MEDIUM, {FREENECT_DEPTH_MM}, + 640*480*2, 640, 480, 16, 0, 30, 1}; + +static freenect_frame_mode depth_mode; + +static void *default_video_back; +static void *default_depth_back; + static char *one_line(FILE *fp) { @@ -111,11 +153,6 @@ static int parse_line(char *type, double *cur_time, unsigned int *timestamp, uns static void open_index() { - input_path = getenv("FAKENECT_PATH"); - if (!input_path) { - printf("Error: Environmental variable FAKENECT_PATH is not set. Set it to a path that was created using the 'record' utility.\n"); - exit(1); - } int index_path_size = strlen(input_path) + 50; char *index_path = malloc(index_path_size); snprintf(index_path, index_path_size, "%s/INDEX.txt", input_path); @@ -127,6 +164,14 @@ static void open_index() free(index_path); } +static void close_index() +{ + fclose(index_fp); + index_fp = NULL; + record_prev_time = 0; + playback_prev_time = 0; +} + static char *skip_line(char *str) { char *out = strchr(str, '\n'); @@ -137,6 +182,33 @@ static char *skip_line(char *str) return out + 1; } +static void convert_rgb_to_uyvy(uint8_t *rgb_buffer, uint8_t *yuv_buffer, + freenect_frame_mode mode) +{ + int x,y; + for (y = 0; y < mode.height; y++) { + for (x = 0; x < mode.width; x+=2) { + int pos = y * mode.width + x; + uint8_t *rgb0 = rgb_buffer + pos * 3; + uint8_t *rgb1 = rgb_buffer + (pos + 1) * 3; + float y0 = (0.257f * rgb0[0]) + (0.504f * rgb0[1]) + (0.098f * rgb0[2]) + 16; + float u0 = -(0.148f * rgb0[0]) - (0.291f * rgb0[1]) + (0.439f * rgb0[2]) + 128; + float v0 = (0.439f * rgb0[0]) - (0.368f * rgb0[1]) - (0.071f * rgb0[2]) + 128; + + float y1 = (0.257f * rgb1[0]) + (0.504f * rgb1[1]) + (0.098f * rgb1[2]) + 16; + float u1 = -(0.148f * rgb1[0]) - (0.291f * rgb1[1]) + (0.439f * rgb1[2]) + 128; + float v1 = (0.439f * rgb1[0]) - (0.368f * rgb1[1]) - (0.071f * rgb1[2]) + 128; + + uint8_t *uyvy = yuv_buffer + pos * 2; + + uyvy[0] = (u0+u1)/2.f; + uyvy[1] = y0; + uyvy[2] = (v0+v1)/2.f; + uyvy[3] = y1; + } + } +} + int freenect_process_events(freenect_context *ctx) { /* This is where the magic happens. We read 1 update from the index @@ -154,8 +226,13 @@ int freenect_process_events(freenect_context *ctx) double record_cur_time; unsigned int timestamp, data_size; char *data = NULL; - if (parse_line(&type, &record_cur_time, ×tamp, &data_size, &data)) - return -1; + if (parse_line(&type, &record_cur_time, ×tamp, &data_size, &data)) { + if (loop_playback) { + close_index(); + return 0; + } else + return -1; + } // Sleep an amount that compensates for the original and current delays // playback_ is w.r.t. the current time // record_ is w.r.t. the original time period during the recording @@ -165,22 +242,48 @@ int freenect_process_events(freenect_context *ctx) switch (type) { case 'd': if (cur_depth_cb && depth_running) { + freenect_frame_mode mode = freenect_get_current_depth_mode(fake_dev); void *cur_depth = skip_line(data); - if (depth_buffer) { - memcpy(depth_buffer, cur_depth, freenect_find_depth_mode(FREENECT_RESOLUTION_MEDIUM, FREENECT_DEPTH_11BIT).bytes); - cur_depth = depth_buffer; + void *depth_buffer = user_depth_buf ? user_depth_buf : default_depth_back; + + switch (mode.depth_format) { + case FREENECT_DEPTH_11BIT: + memcpy(depth_buffer, cur_depth, mode.bytes); + break; + case FREENECT_DEPTH_REGISTERED: + freenect_apply_registration(fake_dev, cur_depth, depth_buffer, true); + break; + case FREENECT_DEPTH_MM: + freenect_apply_depth_unpacked_to_mm(fake_dev, cur_depth, depth_buffer); + break; + default: + assert(0); + break; } - cur_depth_cb(fake_dev, cur_depth, timestamp); + + cur_depth_cb(fake_dev, depth_buffer, timestamp); } break; case 'r': - if (cur_rgb_cb && rgb_running) { - void *cur_rgb = skip_line(data); - if (rgb_buffer) { - memcpy(rgb_buffer, cur_rgb, freenect_find_video_mode(FREENECT_RESOLUTION_MEDIUM, FREENECT_VIDEO_RGB).bytes); - cur_rgb = rgb_buffer; + if (cur_video_cb && rgb_running) { + void *cur_video = skip_line(data); + void *video_buffer = user_video_buf ? user_video_buf : default_video_back; + + freenect_frame_mode mode = freenect_get_current_video_mode(fake_dev); + + switch (mode.video_format) { + case FREENECT_VIDEO_RGB: + memcpy(video_buffer, cur_video, mode.bytes); + break; + case FREENECT_VIDEO_YUV_RAW: + convert_rgb_to_uyvy(cur_video, video_buffer, mode); + break; + default: + assert(0); + break; } - cur_rgb_cb(fake_dev, cur_rgb, timestamp); + + cur_video_cb(fake_dev, video_buffer, timestamp); } break; case 'a': @@ -240,13 +343,14 @@ void freenect_set_depth_callback(freenect_device *dev, freenect_depth_cb cb) void freenect_set_video_callback(freenect_device *dev, freenect_video_cb cb) { - cur_rgb_cb = cb; + cur_video_cb = cb; } int freenect_set_video_mode(freenect_device* dev, const freenect_frame_mode mode) { // Always say it was successful but continue to pass through the // underlying data. Would be better to check for conflict. + video_mode = mode; return 0; } @@ -254,16 +358,33 @@ int freenect_set_depth_mode(freenect_device* dev, const freenect_frame_mode mode { // Always say it was successful but continue to pass through the // underlying data. Would be better to check for conflict. + depth_mode = mode; + + if ((mode.depth_format == FREENECT_DEPTH_MM || + mode.depth_format == FREENECT_DEPTH_REGISTERED) && + dev->registration.zero_plane_info.reference_distance == 0) { + printf("Warning: older fakenect recording doesn't contain " + "registration info for mapping depth to MM units\n"); + } + return 0; } freenect_frame_mode freenect_find_video_mode(freenect_resolution res, freenect_video_format fmt) { assert(FREENECT_RESOLUTION_MEDIUM == res); - assert(FREENECT_VIDEO_RGB == fmt); - // NOTE: This will leave uninitialized values if new fields are added. - // To update this line run the "record" program, look at the top output - freenect_frame_mode out = {256, 1, {0}, 921600, 640, 480, 24, 0, 30, 1}; - return out; + + switch(fmt) { + case FREENECT_VIDEO_RGB: + return rgb_video_mode; + case FREENECT_VIDEO_YUV_RAW: + return yuv_video_mode; + default: + assert(0); + break; + } + + freenect_frame_mode invalid = { 0 }; + return invalid; } int freenect_get_video_mode_count() @@ -273,36 +394,62 @@ int freenect_get_video_mode_count() freenect_frame_mode freenect_get_video_mode(int mode_num) { - return freenect_find_video_mode(FREENECT_RESOLUTION_MEDIUM, FREENECT_VIDEO_RGB); + if (mode_num == 0) + return rgb_video_mode; + else if (mode_num == 1) + return yuv_video_mode; + else { + freenect_frame_mode invalid = { 0 }; + return invalid; + } } freenect_frame_mode freenect_get_current_video_mode(freenect_device *dev) { - return freenect_get_video_mode(0); + return video_mode; } freenect_frame_mode freenect_find_depth_mode(freenect_resolution res, freenect_depth_format fmt) { assert(FREENECT_RESOLUTION_MEDIUM == res); - assert(FREENECT_DEPTH_11BIT == fmt); - // NOTE: This will leave uninitialized values if new fields are added. - // To update this line run the "record" program, look at the top output - freenect_frame_mode out = {256, 1, {0}, 614400, 640, 480, 11, 5, 30, 1}; - return out; + + switch (fmt) { + case FREENECT_DEPTH_11BIT: + return depth_11_mode; + case FREENECT_DEPTH_REGISTERED: + return depth_registered_mode; + case FREENECT_DEPTH_MM: + return depth_mm_mode; + default: + assert(0); + break; + } + + freenect_frame_mode invalid = { 0 }; + return invalid; } int freenect_get_depth_mode_count() { - return 1; + return 3; } freenect_frame_mode freenect_get_depth_mode(int mode_num) { - return freenect_find_depth_mode(FREENECT_RESOLUTION_MEDIUM, FREENECT_DEPTH_11BIT); + if (mode_num == 0) + return depth_11_mode; + else if (mode_num == 1) + return depth_mm_mode; + else if (mode_num == 2) + return depth_registered_mode; + else { + freenect_frame_mode invalid = { 0 }; + return invalid; + } } freenect_frame_mode freenect_get_current_depth_mode(freenect_device *dev) { - return freenect_get_depth_mode(0); + return depth_mode; } int freenect_num_devices(freenect_context *ctx) @@ -324,9 +471,99 @@ int freenect_open_device_by_camera_serial(freenect_context *ctx, freenect_device return 0; } +static void read_device_info(freenect_device *dev) +{ + char fn[512]; + snprintf(fn, sizeof(fn), "%s/device.json", input_path); + + /* We silently return if this file is missing for compatibility with + * older recordings and applications that don't depend on registration + * info. + */ + JSON_Value *js = json_parse_file(fn); + if (!js) + return; + + JSON_Object *reg_info = json_object_get_object(json_object(js), "reg_info"); + JSON_Object *pad_info = json_object_get_object(reg_info, "pad_info"); + JSON_Object *zp_info = json_object_get_object(reg_info, "zero_plane_info"); + + dev->registration.reg_info.ax = json_object_get_number(reg_info, "ax"); + dev->registration.reg_info.bx = json_object_get_number(reg_info, "bx"); + dev->registration.reg_info.cx = json_object_get_number(reg_info, "cx"); + dev->registration.reg_info.dx = json_object_get_number(reg_info, "dx"); + dev->registration.reg_info.ay = json_object_get_number(reg_info, "ay"); + dev->registration.reg_info.by = json_object_get_number(reg_info, "by"); + dev->registration.reg_info.cy = json_object_get_number(reg_info, "cy"); + dev->registration.reg_info.dy = json_object_get_number(reg_info, "dy"); + dev->registration.reg_info.dx_start = json_object_get_number(reg_info, "dx_start"); + dev->registration.reg_info.dy_start = json_object_get_number(reg_info, "dy_start"); + dev->registration.reg_info.dx_beta_start = json_object_get_number(reg_info, "dx_beta_start"); + dev->registration.reg_info.dy_beta_start = json_object_get_number(reg_info, "dy_beta_start"); + dev->registration.reg_info.dx_beta_inc = json_object_get_number(reg_info, "dx_beta_inc"); + dev->registration.reg_info.dy_beta_inc = json_object_get_number(reg_info, "dy_beta_inc"); + dev->registration.reg_info.dxdx_start = json_object_get_number(reg_info, "dxdx_start"); + dev->registration.reg_info.dxdy_start = json_object_get_number(reg_info, "dxdy_start"); + dev->registration.reg_info.dydx_start = json_object_get_number(reg_info, "dydx_start"); + dev->registration.reg_info.dydy_start = json_object_get_number(reg_info, "dydy_start"); + dev->registration.reg_info.dxdxdx_start = json_object_get_number(reg_info, "dxdxdx_start"); + dev->registration.reg_info.dydxdx_start = json_object_get_number(reg_info, "dydxdx_start"); + dev->registration.reg_info.dxdxdy_start = json_object_get_number(reg_info, "dxdxdy_start"); + dev->registration.reg_info.dydxdy_start = json_object_get_number(reg_info, "dydxdy_start"); + dev->registration.reg_info.dydydx_start = json_object_get_number(reg_info, "dydydx_start"); + dev->registration.reg_info.dydydy_start = json_object_get_number(reg_info, "dydydy_start"); + + dev->registration.reg_pad_info.start_lines = json_object_get_number(pad_info, "start_lines"); + dev->registration.reg_pad_info.end_lines = json_object_get_number(pad_info, "end_lines"); + dev->registration.reg_pad_info.cropping_lines = json_object_get_number(pad_info, "cropping_lines"); + + dev->registration.zero_plane_info.dcmos_emitter_dist = json_object_get_number(zp_info, "dcmos_emitter_distance"); + dev->registration.zero_plane_info.dcmos_rcmos_dist = json_object_get_number(zp_info, "dcmos_rcmos_distance"); + dev->registration.zero_plane_info.reference_distance = json_object_get_number(zp_info, "reference_distance"); + dev->registration.zero_plane_info.reference_pixel_size = json_object_get_number(zp_info, "reference_pixel_size"); + + dev->registration.const_shift = json_object_get_number(json_object(js), "const_shift"); + + json_value_free(js); + + freenect_init_registration(fake_dev); +} + int freenect_init(freenect_context **ctx, freenect_usb_context *usb_ctx) { + input_path = getenv("FAKENECT_PATH"); + if (!input_path) { + printf("Error: Environmental variable FAKENECT_PATH is not set. Set it to a path that was created using the 'record' utility.\n"); + exit(1); + } + + char *var = getenv("FAKENECT_LOOP"); + if (var) { + const int len = strlen(var); + char* tmp = malloc((len + 1) * sizeof(*tmp)); + int i; + for (i = 0; i < len; i++) + tmp[i] = tolower(var[i]); + tmp[len] = '\0'; + if (strcmp(tmp, "0") == 0 || + strcmp(tmp, "false") == 0 || + strcmp(tmp, "no") == 0 || + strcmp(tmp, "off") == 0) { + loop_playback = false; + } + free (tmp); + } + *ctx = fake_ctx; + + read_device_info(fake_dev); + + video_mode = rgb_video_mode; + depth_mode = depth_11_mode; + + default_video_back = malloc(640*480*3); + default_depth_back = malloc(640*480*2); + return 0; } @@ -342,13 +579,13 @@ void freenect_select_subdevices(freenect_context *ctx, freenect_device_flags sub int freenect_set_depth_buffer(freenect_device *dev, void *buf) { - depth_buffer = buf; + user_depth_buf = buf; return 0; } int freenect_set_video_buffer(freenect_device *dev, void *buf) { - rgb_buffer = buf; + user_video_buf = buf; return 0; } @@ -388,7 +625,7 @@ int freenect_stop_video(freenect_device *dev) int freenect_set_video_format(freenect_device *dev, freenect_video_format fmt) { - assert(fmt == FREENECT_VIDEO_RGB); + assert(fmt == FREENECT_VIDEO_RGB || fmt == FREENECT_VIDEO_YUV_RAW); return 0; } int freenect_set_depth_format(freenect_device *dev, freenect_depth_format fmt) @@ -401,6 +638,8 @@ void freenect_set_log_callback(freenect_context *ctx, freenect_log_cb cb) {} void freenect_set_log_level(freenect_context *ctx, freenect_loglevel level) {} int freenect_shutdown(freenect_context *ctx) { + free(default_video_back); + free(default_depth_back); return 0; } int freenect_close_device(freenect_device *dev) @@ -419,3 +658,13 @@ int freenect_update_tilt_state(freenect_device *dev) { return 0; } +int freenect_get_ir_brightness(freenect_device *dev) +{ + return ir_brightness; +} +int freenect_set_ir_brightness(freenect_device *dev, uint16_t brightness) +{ + ir_brightness = (brightness % 50); + return 0; +} + diff --git a/fakenect/parson.c b/fakenect/parson.c new file mode 100644 index 00000000..6345e74f --- /dev/null +++ b/fakenect/parson.c @@ -0,0 +1,1998 @@ +/* + Parson ( http://kgabis.github.com/parson/ ) + Copyright (c) 2012 - 2017 Krzysztof Gabis + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ +#ifdef _MSC_VER +#ifndef _CRT_SECURE_NO_WARNINGS +#define _CRT_SECURE_NO_WARNINGS +#endif /* _CRT_SECURE_NO_WARNINGS */ +#endif /* _MSC_VER */ + +#include "parson.h" + +#include +#include +#include +#include +#include +#include + +/* Apparently sscanf is not implemented in some "standard" libraries, so don't use it, if you + * don't have to. */ +#define sscanf THINK_TWICE_ABOUT_USING_SSCANF + +#define STARTING_CAPACITY 16 +#define MAX_NESTING 2048 +#define FLOAT_FORMAT "%1.17g" + +#define SIZEOF_TOKEN(a) (sizeof(a) - 1) +#define SKIP_CHAR(str) ((*str)++) +#define SKIP_WHITESPACES(str) while (isspace(**str)) { SKIP_CHAR(str); } +#define MAX(a, b) ((a) > (b) ? (a) : (b)) + +#undef malloc +#undef free + +static JSON_Malloc_Function parson_malloc = malloc; +static JSON_Free_Function parson_free = free; + +#define IS_CONT(b) (((unsigned char)(b) & 0xC0) == 0x80) /* is utf-8 continuation byte */ + +/* Type definitions */ +typedef union json_value_value { + char *string; + double number; + JSON_Object *object; + JSON_Array *array; + int boolean; + int null; +} JSON_Value_Value; + +struct json_value_t { + JSON_Value *parent; + JSON_Value_Type type; + JSON_Value_Value value; +}; + +struct json_object_t { + JSON_Value *wrapping_value; + char **names; + JSON_Value **values; + size_t count; + size_t capacity; +}; + +struct json_array_t { + JSON_Value *wrapping_value; + JSON_Value **items; + size_t count; + size_t capacity; +}; + +/* Various */ +static char * read_file(const char *filename); +static void remove_comments(char *string, const char *start_token, const char *end_token); +static char * parson_strndup(const char *string, size_t n); +static char * parson_strdup(const char *string); +static int hex_char_to_int(char c); +static int parse_utf16_hex(const char *string, unsigned int *result); +static int num_bytes_in_utf8_sequence(unsigned char c); +static int verify_utf8_sequence(const unsigned char *string, int *len); +static int is_valid_utf8(const char *string, size_t string_len); +static int is_decimal(const char *string, size_t length); + +/* JSON Object */ +static JSON_Object * json_object_init(JSON_Value *wrapping_value); +static JSON_Status json_object_add(JSON_Object *object, const char *name, JSON_Value *value); +static JSON_Status json_object_resize(JSON_Object *object, size_t new_capacity); +static JSON_Value * json_object_nget_value(const JSON_Object *object, const char *name, size_t n); +static void json_object_free(JSON_Object *object); + +/* JSON Array */ +static JSON_Array * json_array_init(JSON_Value *wrapping_value); +static JSON_Status json_array_add(JSON_Array *array, JSON_Value *value); +static JSON_Status json_array_resize(JSON_Array *array, size_t new_capacity); +static void json_array_free(JSON_Array *array); + +/* JSON Value */ +static JSON_Value * json_value_init_string_no_copy(char *string); + +/* Parser */ +static JSON_Status skip_quotes(const char **string); +static int parse_utf16(const char **unprocessed, char **processed); +static char * process_string(const char *input, size_t len); +static char * get_quoted_string(const char **string); +static JSON_Value * parse_object_value(const char **string, size_t nesting); +static JSON_Value * parse_array_value(const char **string, size_t nesting); +static JSON_Value * parse_string_value(const char **string); +static JSON_Value * parse_boolean_value(const char **string); +static JSON_Value * parse_number_value(const char **string); +static JSON_Value * parse_null_value(const char **string); +static JSON_Value * parse_value(const char **string, size_t nesting); + +/* Serialization */ +static int json_serialize_to_buffer_r(const JSON_Value *value, char *buf, int level, int is_pretty, char *num_buf); +static int json_serialize_string(const char *string, char *buf); +static int append_indent(char *buf, int level); +static int append_string(char *buf, const char *string); + +/* Various */ +static char * parson_strndup(const char *string, size_t n) { + char *output_string = (char*)parson_malloc(n + 1); + if (!output_string) { + return NULL; + } + output_string[n] = '\0'; + strncpy(output_string, string, n); + return output_string; +} + +static char * parson_strdup(const char *string) { + return parson_strndup(string, strlen(string)); +} + +static int hex_char_to_int(char c) { + if (c >= '0' && c <= '9') { + return c - '0'; + } else if (c >= 'a' && c <= 'f') { + return c - 'a' + 10; + } else if (c >= 'A' && c <= 'F') { + return c - 'A' + 10; + } + return -1; +} + +static int parse_utf16_hex(const char *s, unsigned int *result) { + int x1, x2, x3, x4; + if (s[0] == '\0' || s[1] == '\0' || s[2] == '\0' || s[3] == '\0') { + return 0; + } + x1 = hex_char_to_int(s[0]); + x2 = hex_char_to_int(s[1]); + x3 = hex_char_to_int(s[2]); + x4 = hex_char_to_int(s[3]); + if (x1 == -1 || x2 == -1 || x3 == -1 || x4 == -1) { + return 0; + } + *result = (unsigned int)((x1 << 12) | (x2 << 8) | (x3 << 4) | x4); + return 1; +} + +static int num_bytes_in_utf8_sequence(unsigned char c) { + if (c == 0xC0 || c == 0xC1 || c > 0xF4 || IS_CONT(c)) { + return 0; + } else if ((c & 0x80) == 0) { /* 0xxxxxxx */ + return 1; + } else if ((c & 0xE0) == 0xC0) { /* 110xxxxx */ + return 2; + } else if ((c & 0xF0) == 0xE0) { /* 1110xxxx */ + return 3; + } else if ((c & 0xF8) == 0xF0) { /* 11110xxx */ + return 4; + } + return 0; /* won't happen */ +} + +static int verify_utf8_sequence(const unsigned char *string, int *len) { + unsigned int cp = 0; + *len = num_bytes_in_utf8_sequence(string[0]); + + if (*len == 1) { + cp = string[0]; + } else if (*len == 2 && IS_CONT(string[1])) { + cp = string[0] & 0x1F; + cp = (cp << 6) | (string[1] & 0x3F); + } else if (*len == 3 && IS_CONT(string[1]) && IS_CONT(string[2])) { + cp = ((unsigned char)string[0]) & 0xF; + cp = (cp << 6) | (string[1] & 0x3F); + cp = (cp << 6) | (string[2] & 0x3F); + } else if (*len == 4 && IS_CONT(string[1]) && IS_CONT(string[2]) && IS_CONT(string[3])) { + cp = string[0] & 0x7; + cp = (cp << 6) | (string[1] & 0x3F); + cp = (cp << 6) | (string[2] & 0x3F); + cp = (cp << 6) | (string[3] & 0x3F); + } else { + return 0; + } + + /* overlong encodings */ + if ((cp < 0x80 && *len > 1) || + (cp < 0x800 && *len > 2) || + (cp < 0x10000 && *len > 3)) { + return 0; + } + + /* invalid unicode */ + if (cp > 0x10FFFF) { + return 0; + } + + /* surrogate halves */ + if (cp >= 0xD800 && cp <= 0xDFFF) { + return 0; + } + + return 1; +} + +static int is_valid_utf8(const char *string, size_t string_len) { + int len = 0; + const char *string_end = string + string_len; + while (string < string_end) { + if (!verify_utf8_sequence((const unsigned char*)string, &len)) { + return 0; + } + string += len; + } + return 1; +} + +static int is_decimal(const char *string, size_t length) { + if (length > 1 && string[0] == '0' && string[1] != '.') { + return 0; + } + if (length > 2 && !strncmp(string, "-0", 2) && string[2] != '.') { + return 0; + } + while (length--) { + if (strchr("xX", string[length])) { + return 0; + } + } + return 1; +} + +static char * read_file(const char * filename) { + FILE *fp = fopen(filename, "r"); + size_t file_size; + long pos; + char *file_contents; + if (!fp) { + return NULL; + } + fseek(fp, 0L, SEEK_END); + pos = ftell(fp); + if (pos < 0) { + fclose(fp); + return NULL; + } + file_size = pos; + rewind(fp); + file_contents = (char*)parson_malloc(sizeof(char) * (file_size + 1)); + if (!file_contents) { + fclose(fp); + return NULL; + } + if (fread(file_contents, file_size, 1, fp) < 1) { + if (ferror(fp)) { + fclose(fp); + parson_free(file_contents); + return NULL; + } + } + fclose(fp); + file_contents[file_size] = '\0'; + return file_contents; +} + +static void remove_comments(char *string, const char *start_token, const char *end_token) { + int in_string = 0, escaped = 0; + size_t i; + char *ptr = NULL, current_char; + size_t start_token_len = strlen(start_token); + size_t end_token_len = strlen(end_token); + if (start_token_len == 0 || end_token_len == 0) { + return; + } + while ((current_char = *string) != '\0') { + if (current_char == '\\' && !escaped) { + escaped = 1; + string++; + continue; + } else if (current_char == '\"' && !escaped) { + in_string = !in_string; + } else if (!in_string && strncmp(string, start_token, start_token_len) == 0) { + for(i = 0; i < start_token_len; i++) { + string[i] = ' '; + } + string = string + start_token_len; + ptr = strstr(string, end_token); + if (!ptr) { + return; + } + for (i = 0; i < (ptr - string) + end_token_len; i++) { + string[i] = ' '; + } + string = ptr + end_token_len - 1; + } + escaped = 0; + string++; + } +} + +/* JSON Object */ +static JSON_Object * json_object_init(JSON_Value *wrapping_value) { + JSON_Object *new_obj = (JSON_Object*)parson_malloc(sizeof(JSON_Object)); + if (new_obj == NULL) { + return NULL; + } + new_obj->wrapping_value = wrapping_value; + new_obj->names = (char**)NULL; + new_obj->values = (JSON_Value**)NULL; + new_obj->capacity = 0; + new_obj->count = 0; + return new_obj; +} + +static JSON_Status json_object_add(JSON_Object *object, const char *name, JSON_Value *value) { + size_t index = 0; + if (object == NULL || name == NULL || value == NULL) { + return JSONFailure; + } + if (json_object_get_value(object, name) != NULL) { + return JSONFailure; + } + if (object->count >= object->capacity) { + size_t new_capacity = MAX(object->capacity * 2, STARTING_CAPACITY); + if (json_object_resize(object, new_capacity) == JSONFailure) { + return JSONFailure; + } + } + index = object->count; + object->names[index] = parson_strdup(name); + if (object->names[index] == NULL) { + return JSONFailure; + } + value->parent = json_object_get_wrapping_value(object); + object->values[index] = value; + object->count++; + return JSONSuccess; +} + +static JSON_Status json_object_resize(JSON_Object *object, size_t new_capacity) { + char **temp_names = NULL; + JSON_Value **temp_values = NULL; + + if ((object->names == NULL && object->values != NULL) || + (object->names != NULL && object->values == NULL) || + new_capacity == 0) { + return JSONFailure; /* Shouldn't happen */ + } + temp_names = (char**)parson_malloc(new_capacity * sizeof(char*)); + if (temp_names == NULL) { + return JSONFailure; + } + temp_values = (JSON_Value**)parson_malloc(new_capacity * sizeof(JSON_Value*)); + if (temp_values == NULL) { + parson_free(temp_names); + return JSONFailure; + } + if (object->names != NULL && object->values != NULL && object->count > 0) { + memcpy(temp_names, object->names, object->count * sizeof(char*)); + memcpy(temp_values, object->values, object->count * sizeof(JSON_Value*)); + } + parson_free(object->names); + parson_free(object->values); + object->names = temp_names; + object->values = temp_values; + object->capacity = new_capacity; + return JSONSuccess; +} + +static JSON_Value * json_object_nget_value(const JSON_Object *object, const char *name, size_t n) { + size_t i, name_length; + for (i = 0; i < json_object_get_count(object); i++) { + name_length = strlen(object->names[i]); + if (name_length != n) { + continue; + } + if (strncmp(object->names[i], name, n) == 0) { + return object->values[i]; + } + } + return NULL; +} + +static void json_object_free(JSON_Object *object) { + size_t i; + for (i = 0; i < object->count; i++) { + parson_free(object->names[i]); + json_value_free(object->values[i]); + } + parson_free(object->names); + parson_free(object->values); + parson_free(object); +} + +/* JSON Array */ +static JSON_Array * json_array_init(JSON_Value *wrapping_value) { + JSON_Array *new_array = (JSON_Array*)parson_malloc(sizeof(JSON_Array)); + if (new_array == NULL) { + return NULL; + } + new_array->wrapping_value = wrapping_value; + new_array->items = (JSON_Value**)NULL; + new_array->capacity = 0; + new_array->count = 0; + return new_array; +} + +static JSON_Status json_array_add(JSON_Array *array, JSON_Value *value) { + if (array->count >= array->capacity) { + size_t new_capacity = MAX(array->capacity * 2, STARTING_CAPACITY); + if (json_array_resize(array, new_capacity) == JSONFailure) { + return JSONFailure; + } + } + value->parent = json_array_get_wrapping_value(array); + array->items[array->count] = value; + array->count++; + return JSONSuccess; +} + +static JSON_Status json_array_resize(JSON_Array *array, size_t new_capacity) { + JSON_Value **new_items = NULL; + if (new_capacity == 0) { + return JSONFailure; + } + new_items = (JSON_Value**)parson_malloc(new_capacity * sizeof(JSON_Value*)); + if (new_items == NULL) { + return JSONFailure; + } + if (array->items != NULL && array->count > 0) { + memcpy(new_items, array->items, array->count * sizeof(JSON_Value*)); + } + parson_free(array->items); + array->items = new_items; + array->capacity = new_capacity; + return JSONSuccess; +} + +static void json_array_free(JSON_Array *array) { + size_t i; + for (i = 0; i < array->count; i++) { + json_value_free(array->items[i]); + } + parson_free(array->items); + parson_free(array); +} + +/* JSON Value */ +static JSON_Value * json_value_init_string_no_copy(char *string) { + JSON_Value *new_value = (JSON_Value*)parson_malloc(sizeof(JSON_Value)); + if (!new_value) { + return NULL; + } + new_value->parent = NULL; + new_value->type = JSONString; + new_value->value.string = string; + return new_value; +} + +/* Parser */ +static JSON_Status skip_quotes(const char **string) { + if (**string != '\"') { + return JSONFailure; + } + SKIP_CHAR(string); + while (**string != '\"') { + if (**string == '\0') { + return JSONFailure; + } else if (**string == '\\') { + SKIP_CHAR(string); + if (**string == '\0') { + return JSONFailure; + } + } + SKIP_CHAR(string); + } + SKIP_CHAR(string); + return JSONSuccess; +} + +static int parse_utf16(const char **unprocessed, char **processed) { + unsigned int cp, lead, trail; + int parse_succeeded = 0; + char *processed_ptr = *processed; + const char *unprocessed_ptr = *unprocessed; + unprocessed_ptr++; /* skips u */ + parse_succeeded = parse_utf16_hex(unprocessed_ptr, &cp); + if (!parse_succeeded) { + return JSONFailure; + } + if (cp < 0x80) { + processed_ptr[0] = (char)cp; /* 0xxxxxxx */ + } else if (cp < 0x800) { + processed_ptr[0] = ((cp >> 6) & 0x1F) | 0xC0; /* 110xxxxx */ + processed_ptr[1] = ((cp) & 0x3F) | 0x80; /* 10xxxxxx */ + processed_ptr += 1; + } else if (cp < 0xD800 || cp > 0xDFFF) { + processed_ptr[0] = ((cp >> 12) & 0x0F) | 0xE0; /* 1110xxxx */ + processed_ptr[1] = ((cp >> 6) & 0x3F) | 0x80; /* 10xxxxxx */ + processed_ptr[2] = ((cp) & 0x3F) | 0x80; /* 10xxxxxx */ + processed_ptr += 2; + } else if (cp >= 0xD800 && cp <= 0xDBFF) { /* lead surrogate (0xD800..0xDBFF) */ + lead = cp; + unprocessed_ptr += 4; /* should always be within the buffer, otherwise previous sscanf would fail */ + if (*unprocessed_ptr++ != '\\' || *unprocessed_ptr++ != 'u') { + return JSONFailure; + } + parse_succeeded = parse_utf16_hex(unprocessed_ptr, &trail); + if (!parse_succeeded || trail < 0xDC00 || trail > 0xDFFF) { /* valid trail surrogate? (0xDC00..0xDFFF) */ + return JSONFailure; + } + cp = ((((lead - 0xD800) & 0x3FF) << 10) | ((trail - 0xDC00) & 0x3FF)) + 0x010000; + processed_ptr[0] = (((cp >> 18) & 0x07) | 0xF0); /* 11110xxx */ + processed_ptr[1] = (((cp >> 12) & 0x3F) | 0x80); /* 10xxxxxx */ + processed_ptr[2] = (((cp >> 6) & 0x3F) | 0x80); /* 10xxxxxx */ + processed_ptr[3] = (((cp) & 0x3F) | 0x80); /* 10xxxxxx */ + processed_ptr += 3; + } else { /* trail surrogate before lead surrogate */ + return JSONFailure; + } + unprocessed_ptr += 3; + *processed = processed_ptr; + *unprocessed = unprocessed_ptr; + return JSONSuccess; +} + + +/* Copies and processes passed string up to supplied length. +Example: "\u006Corem ipsum" -> lorem ipsum */ +static char* process_string(const char *input, size_t len) { + const char *input_ptr = input; + size_t initial_size = (len + 1) * sizeof(char); + size_t final_size = 0; + char *output = NULL, *output_ptr = NULL, *resized_output = NULL; + output = (char*)parson_malloc(initial_size); + if (output == NULL) { + goto error; + } + output_ptr = output; + while ((*input_ptr != '\0') && (size_t)(input_ptr - input) < len) { + if (*input_ptr == '\\') { + input_ptr++; + switch (*input_ptr) { + case '\"': *output_ptr = '\"'; break; + case '\\': *output_ptr = '\\'; break; + case '/': *output_ptr = '/'; break; + case 'b': *output_ptr = '\b'; break; + case 'f': *output_ptr = '\f'; break; + case 'n': *output_ptr = '\n'; break; + case 'r': *output_ptr = '\r'; break; + case 't': *output_ptr = '\t'; break; + case 'u': + if (parse_utf16(&input_ptr, &output_ptr) == JSONFailure) { + goto error; + } + break; + default: + goto error; + } + } else if ((unsigned char)*input_ptr < 0x20) { + goto error; /* 0x00-0x19 are invalid characters for json string (http://www.ietf.org/rfc/rfc4627.txt) */ + } else { + *output_ptr = *input_ptr; + } + output_ptr++; + input_ptr++; + } + *output_ptr = '\0'; + /* resize to new length */ + final_size = (size_t)(output_ptr-output) + 1; + /* todo: don't resize if final_size == initial_size */ + resized_output = (char*)parson_malloc(final_size); + if (resized_output == NULL) { + goto error; + } + memcpy(resized_output, output, final_size); + parson_free(output); + return resized_output; +error: + parson_free(output); + return NULL; +} + +/* Return processed contents of a string between quotes and + skips passed argument to a matching quote. */ +static char * get_quoted_string(const char **string) { + const char *string_start = *string; + size_t string_len = 0; + JSON_Status status = skip_quotes(string); + if (status != JSONSuccess) { + return NULL; + } + string_len = *string - string_start - 2; /* length without quotes */ + return process_string(string_start + 1, string_len); +} + +static JSON_Value * parse_value(const char **string, size_t nesting) { + if (nesting > MAX_NESTING) { + return NULL; + } + SKIP_WHITESPACES(string); + switch (**string) { + case '{': + return parse_object_value(string, nesting + 1); + case '[': + return parse_array_value(string, nesting + 1); + case '\"': + return parse_string_value(string); + case 'f': case 't': + return parse_boolean_value(string); + case '-': + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + return parse_number_value(string); + case 'n': + return parse_null_value(string); + default: + return NULL; + } +} + +static JSON_Value * parse_object_value(const char **string, size_t nesting) { + JSON_Value *output_value = json_value_init_object(), *new_value = NULL; + JSON_Object *output_object = json_value_get_object(output_value); + char *new_key = NULL; + if (output_value == NULL || **string != '{') { + return NULL; + } + SKIP_CHAR(string); + SKIP_WHITESPACES(string); + if (**string == '}') { /* empty object */ + SKIP_CHAR(string); + return output_value; + } + while (**string != '\0') { + new_key = get_quoted_string(string); + if (new_key == NULL) { + json_value_free(output_value); + return NULL; + } + SKIP_WHITESPACES(string); + if (**string != ':') { + parson_free(new_key); + json_value_free(output_value); + return NULL; + } + SKIP_CHAR(string); + new_value = parse_value(string, nesting); + if (new_value == NULL) { + parson_free(new_key); + json_value_free(output_value); + return NULL; + } + if (json_object_add(output_object, new_key, new_value) == JSONFailure) { + parson_free(new_key); + json_value_free(new_value); + json_value_free(output_value); + return NULL; + } + parson_free(new_key); + SKIP_WHITESPACES(string); + if (**string != ',') { + break; + } + SKIP_CHAR(string); + SKIP_WHITESPACES(string); + } + SKIP_WHITESPACES(string); + if (**string != '}' || /* Trim object after parsing is over */ + json_object_resize(output_object, json_object_get_count(output_object)) == JSONFailure) { + json_value_free(output_value); + return NULL; + } + SKIP_CHAR(string); + return output_value; +} + +static JSON_Value * parse_array_value(const char **string, size_t nesting) { + JSON_Value *output_value = json_value_init_array(), *new_array_value = NULL; + JSON_Array *output_array = json_value_get_array(output_value); + if (!output_value || **string != '[') { + return NULL; + } + SKIP_CHAR(string); + SKIP_WHITESPACES(string); + if (**string == ']') { /* empty array */ + SKIP_CHAR(string); + return output_value; + } + while (**string != '\0') { + new_array_value = parse_value(string, nesting); + if (new_array_value == NULL) { + json_value_free(output_value); + return NULL; + } + if (json_array_add(output_array, new_array_value) == JSONFailure) { + json_value_free(new_array_value); + json_value_free(output_value); + return NULL; + } + SKIP_WHITESPACES(string); + if (**string != ',') { + break; + } + SKIP_CHAR(string); + SKIP_WHITESPACES(string); + } + SKIP_WHITESPACES(string); + if (**string != ']' || /* Trim array after parsing is over */ + json_array_resize(output_array, json_array_get_count(output_array)) == JSONFailure) { + json_value_free(output_value); + return NULL; + } + SKIP_CHAR(string); + return output_value; +} + +static JSON_Value * parse_string_value(const char **string) { + JSON_Value *value = NULL; + char *new_string = get_quoted_string(string); + if (new_string == NULL) { + return NULL; + } + value = json_value_init_string_no_copy(new_string); + if (value == NULL) { + parson_free(new_string); + return NULL; + } + return value; +} + +static JSON_Value * parse_boolean_value(const char **string) { + size_t true_token_size = SIZEOF_TOKEN("true"); + size_t false_token_size = SIZEOF_TOKEN("false"); + if (strncmp("true", *string, true_token_size) == 0) { + *string += true_token_size; + return json_value_init_boolean(1); + } else if (strncmp("false", *string, false_token_size) == 0) { + *string += false_token_size; + return json_value_init_boolean(0); + } + return NULL; +} + +static JSON_Value * parse_number_value(const char **string) { + char *end; + double number = 0; + errno = 0; + number = strtod(*string, &end); + if (errno || !is_decimal(*string, end - *string)) { + return NULL; + } + *string = end; + return json_value_init_number(number); +} + +static JSON_Value * parse_null_value(const char **string) { + size_t token_size = SIZEOF_TOKEN("null"); + if (strncmp("null", *string, token_size) == 0) { + *string += token_size; + return json_value_init_null(); + } + return NULL; +} + +/* Serialization */ +#define APPEND_STRING(str) do { written = append_string(buf, (str));\ + if (written < 0) { return -1; }\ + if (buf != NULL) { buf += written; }\ + written_total += written; } while(0) + +#define APPEND_INDENT(level) do { written = append_indent(buf, (level));\ + if (written < 0) { return -1; }\ + if (buf != NULL) { buf += written; }\ + written_total += written; } while(0) + +static int json_serialize_to_buffer_r(const JSON_Value *value, char *buf, int level, int is_pretty, char *num_buf) +{ + const char *key = NULL, *string = NULL; + JSON_Value *temp_value = NULL; + JSON_Array *array = NULL; + JSON_Object *object = NULL; + size_t i = 0, count = 0; + double num = 0.0; + int written = -1, written_total = 0; + + switch (json_value_get_type(value)) { + case JSONArray: + array = json_value_get_array(value); + count = json_array_get_count(array); + APPEND_STRING("["); + if (count > 0 && is_pretty) { + APPEND_STRING("\n"); + } + for (i = 0; i < count; i++) { + if (is_pretty) { + APPEND_INDENT(level+1); + } + temp_value = json_array_get_value(array, i); + written = json_serialize_to_buffer_r(temp_value, buf, level+1, is_pretty, num_buf); + if (written < 0) { + return -1; + } + if (buf != NULL) { + buf += written; + } + written_total += written; + if (i < (count - 1)) { + APPEND_STRING(","); + } + if (is_pretty) { + APPEND_STRING("\n"); + } + } + if (count > 0 && is_pretty) { + APPEND_INDENT(level); + } + APPEND_STRING("]"); + return written_total; + case JSONObject: + object = json_value_get_object(value); + count = json_object_get_count(object); + APPEND_STRING("{"); + if (count > 0 && is_pretty) { + APPEND_STRING("\n"); + } + for (i = 0; i < count; i++) { + key = json_object_get_name(object, i); + if (key == NULL) { + return -1; + } + if (is_pretty) { + APPEND_INDENT(level+1); + } + written = json_serialize_string(key, buf); + if (written < 0) { + return -1; + } + if (buf != NULL) { + buf += written; + } + written_total += written; + APPEND_STRING(":"); + if (is_pretty) { + APPEND_STRING(" "); + } + temp_value = json_object_get_value(object, key); + written = json_serialize_to_buffer_r(temp_value, buf, level+1, is_pretty, num_buf); + if (written < 0) { + return -1; + } + if (buf != NULL) { + buf += written; + } + written_total += written; + if (i < (count - 1)) { + APPEND_STRING(","); + } + if (is_pretty) { + APPEND_STRING("\n"); + } + } + if (count > 0 && is_pretty) { + APPEND_INDENT(level); + } + APPEND_STRING("}"); + return written_total; + case JSONString: + string = json_value_get_string(value); + if (string == NULL) { + return -1; + } + written = json_serialize_string(string, buf); + if (written < 0) { + return -1; + } + if (buf != NULL) { + buf += written; + } + written_total += written; + return written_total; + case JSONBoolean: + if (json_value_get_boolean(value)) { + APPEND_STRING("true"); + } else { + APPEND_STRING("false"); + } + return written_total; + case JSONNumber: + num = json_value_get_number(value); + if (buf != NULL) { + num_buf = buf; + } + written = sprintf(num_buf, FLOAT_FORMAT, num); + if (written < 0) { + return -1; + } + if (buf != NULL) { + buf += written; + } + written_total += written; + return written_total; + case JSONNull: + APPEND_STRING("null"); + return written_total; + case JSONError: + return -1; + default: + return -1; + } +} + +static int json_serialize_string(const char *string, char *buf) { + size_t i = 0, len = strlen(string); + char c = '\0'; + int written = -1, written_total = 0; + APPEND_STRING("\""); + for (i = 0; i < len; i++) { + c = string[i]; + switch (c) { + case '\"': APPEND_STRING("\\\""); break; + case '\\': APPEND_STRING("\\\\"); break; + case '/': APPEND_STRING("\\/"); break; /* to make json embeddable in xml\/html */ + case '\b': APPEND_STRING("\\b"); break; + case '\f': APPEND_STRING("\\f"); break; + case '\n': APPEND_STRING("\\n"); break; + case '\r': APPEND_STRING("\\r"); break; + case '\t': APPEND_STRING("\\t"); break; + case '\x00': APPEND_STRING("\\u0000"); break; + case '\x01': APPEND_STRING("\\u0001"); break; + case '\x02': APPEND_STRING("\\u0002"); break; + case '\x03': APPEND_STRING("\\u0003"); break; + case '\x04': APPEND_STRING("\\u0004"); break; + case '\x05': APPEND_STRING("\\u0005"); break; + case '\x06': APPEND_STRING("\\u0006"); break; + case '\x07': APPEND_STRING("\\u0007"); break; + /* '\x08' duplicate: '\b' */ + /* '\x09' duplicate: '\t' */ + /* '\x0a' duplicate: '\n' */ + case '\x0b': APPEND_STRING("\\u000b"); break; + /* '\x0c' duplicate: '\f' */ + /* '\x0d' duplicate: '\r' */ + case '\x0e': APPEND_STRING("\\u000e"); break; + case '\x0f': APPEND_STRING("\\u000f"); break; + case '\x10': APPEND_STRING("\\u0010"); break; + case '\x11': APPEND_STRING("\\u0011"); break; + case '\x12': APPEND_STRING("\\u0012"); break; + case '\x13': APPEND_STRING("\\u0013"); break; + case '\x14': APPEND_STRING("\\u0014"); break; + case '\x15': APPEND_STRING("\\u0015"); break; + case '\x16': APPEND_STRING("\\u0016"); break; + case '\x17': APPEND_STRING("\\u0017"); break; + case '\x18': APPEND_STRING("\\u0018"); break; + case '\x19': APPEND_STRING("\\u0019"); break; + case '\x1a': APPEND_STRING("\\u001a"); break; + case '\x1b': APPEND_STRING("\\u001b"); break; + case '\x1c': APPEND_STRING("\\u001c"); break; + case '\x1d': APPEND_STRING("\\u001d"); break; + case '\x1e': APPEND_STRING("\\u001e"); break; + case '\x1f': APPEND_STRING("\\u001f"); break; + default: + if (buf != NULL) { + buf[0] = c; + buf += 1; + } + written_total += 1; + break; + } + } + APPEND_STRING("\""); + return written_total; +} + +static int append_indent(char *buf, int level) { + int i; + int written = -1, written_total = 0; + for (i = 0; i < level; i++) { + APPEND_STRING(" "); + } + return written_total; +} + +static int append_string(char *buf, const char *string) { + if (buf == NULL) { + return (int)strlen(string); + } + return sprintf(buf, "%s", string); +} + +#undef APPEND_STRING +#undef APPEND_INDENT + +/* Parser API */ +JSON_Value * json_parse_file(const char *filename) { + char *file_contents = read_file(filename); + JSON_Value *output_value = NULL; + if (file_contents == NULL) { + return NULL; + } + output_value = json_parse_string(file_contents); + parson_free(file_contents); + return output_value; +} + +JSON_Value * json_parse_file_with_comments(const char *filename) { + char *file_contents = read_file(filename); + JSON_Value *output_value = NULL; + if (file_contents == NULL) { + return NULL; + } + output_value = json_parse_string_with_comments(file_contents); + parson_free(file_contents); + return output_value; +} + +JSON_Value * json_parse_string(const char *string) { + if (string == NULL) { + return NULL; + } + if (string[0] == '\xEF' && string[1] == '\xBB' && string[2] == '\xBF') { + string = string + 3; /* Support for UTF-8 BOM */ + } + return parse_value((const char**)&string, 0); +} + +JSON_Value * json_parse_string_with_comments(const char *string) { + JSON_Value *result = NULL; + char *string_mutable_copy = NULL, *string_mutable_copy_ptr = NULL; + string_mutable_copy = parson_strdup(string); + if (string_mutable_copy == NULL) { + return NULL; + } + remove_comments(string_mutable_copy, "/*", "*/"); + remove_comments(string_mutable_copy, "//", "\n"); + string_mutable_copy_ptr = string_mutable_copy; + result = parse_value((const char**)&string_mutable_copy_ptr, 0); + parson_free(string_mutable_copy); + return result; +} + +/* JSON Object API */ + +JSON_Value * json_object_get_value(const JSON_Object *object, const char *name) { + if (object == NULL || name == NULL) { + return NULL; + } + return json_object_nget_value(object, name, strlen(name)); +} + +const char * json_object_get_string(const JSON_Object *object, const char *name) { + return json_value_get_string(json_object_get_value(object, name)); +} + +double json_object_get_number(const JSON_Object *object, const char *name) { + return json_value_get_number(json_object_get_value(object, name)); +} + +JSON_Object * json_object_get_object(const JSON_Object *object, const char *name) { + return json_value_get_object(json_object_get_value(object, name)); +} + +JSON_Array * json_object_get_array(const JSON_Object *object, const char *name) { + return json_value_get_array(json_object_get_value(object, name)); +} + +int json_object_get_boolean(const JSON_Object *object, const char *name) { + return json_value_get_boolean(json_object_get_value(object, name)); +} + +JSON_Value * json_object_dotget_value(const JSON_Object *object, const char *name) { + const char *dot_position = strchr(name, '.'); + if (!dot_position) { + return json_object_get_value(object, name); + } + object = json_value_get_object(json_object_nget_value(object, name, dot_position - name)); + return json_object_dotget_value(object, dot_position + 1); +} + +const char * json_object_dotget_string(const JSON_Object *object, const char *name) { + return json_value_get_string(json_object_dotget_value(object, name)); +} + +double json_object_dotget_number(const JSON_Object *object, const char *name) { + return json_value_get_number(json_object_dotget_value(object, name)); +} + +JSON_Object * json_object_dotget_object(const JSON_Object *object, const char *name) { + return json_value_get_object(json_object_dotget_value(object, name)); +} + +JSON_Array * json_object_dotget_array(const JSON_Object *object, const char *name) { + return json_value_get_array(json_object_dotget_value(object, name)); +} + +int json_object_dotget_boolean(const JSON_Object *object, const char *name) { + return json_value_get_boolean(json_object_dotget_value(object, name)); +} + +size_t json_object_get_count(const JSON_Object *object) { + return object ? object->count : 0; +} + +const char * json_object_get_name(const JSON_Object *object, size_t index) { + if (object == NULL || index >= json_object_get_count(object)) { + return NULL; + } + return object->names[index]; +} + +JSON_Value * json_object_get_value_at(const JSON_Object *object, size_t index) { + if (object == NULL || index >= json_object_get_count(object)) { + return NULL; + } + return object->values[index]; +} + +JSON_Value *json_object_get_wrapping_value(const JSON_Object *object) { + return object->wrapping_value; +} + +int json_object_has_value (const JSON_Object *object, const char *name) { + return json_object_get_value(object, name) != NULL; +} + +int json_object_has_value_of_type(const JSON_Object *object, const char *name, JSON_Value_Type type) { + JSON_Value *val = json_object_get_value(object, name); + return val != NULL && json_value_get_type(val) == type; +} + +int json_object_dothas_value (const JSON_Object *object, const char *name) { + return json_object_dotget_value(object, name) != NULL; +} + +int json_object_dothas_value_of_type(const JSON_Object *object, const char *name, JSON_Value_Type type) { + JSON_Value *val = json_object_dotget_value(object, name); + return val != NULL && json_value_get_type(val) == type; +} + +/* JSON Array API */ +JSON_Value * json_array_get_value(const JSON_Array *array, size_t index) { + if (array == NULL || index >= json_array_get_count(array)) { + return NULL; + } + return array->items[index]; +} + +const char * json_array_get_string(const JSON_Array *array, size_t index) { + return json_value_get_string(json_array_get_value(array, index)); +} + +double json_array_get_number(const JSON_Array *array, size_t index) { + return json_value_get_number(json_array_get_value(array, index)); +} + +JSON_Object * json_array_get_object(const JSON_Array *array, size_t index) { + return json_value_get_object(json_array_get_value(array, index)); +} + +JSON_Array * json_array_get_array(const JSON_Array *array, size_t index) { + return json_value_get_array(json_array_get_value(array, index)); +} + +int json_array_get_boolean(const JSON_Array *array, size_t index) { + return json_value_get_boolean(json_array_get_value(array, index)); +} + +size_t json_array_get_count(const JSON_Array *array) { + return array ? array->count : 0; +} + +JSON_Value * json_array_get_wrapping_value(const JSON_Array *array) { + return array->wrapping_value; +} + +/* JSON Value API */ +JSON_Value_Type json_value_get_type(const JSON_Value *value) { + return value ? value->type : JSONError; +} + +JSON_Object * json_value_get_object(const JSON_Value *value) { + return json_value_get_type(value) == JSONObject ? value->value.object : NULL; +} + +JSON_Array * json_value_get_array(const JSON_Value *value) { + return json_value_get_type(value) == JSONArray ? value->value.array : NULL; +} + +const char * json_value_get_string(const JSON_Value *value) { + return json_value_get_type(value) == JSONString ? value->value.string : NULL; +} + +double json_value_get_number(const JSON_Value *value) { + return json_value_get_type(value) == JSONNumber ? value->value.number : 0; +} + +int json_value_get_boolean(const JSON_Value *value) { + return json_value_get_type(value) == JSONBoolean ? value->value.boolean : -1; +} + +JSON_Value * json_value_get_parent (const JSON_Value *value) { + return value ? value->parent : NULL; +} + +void json_value_free(JSON_Value *value) { + switch (json_value_get_type(value)) { + case JSONObject: + json_object_free(value->value.object); + break; + case JSONString: + parson_free(value->value.string); + break; + case JSONArray: + json_array_free(value->value.array); + break; + default: + break; + } + parson_free(value); +} + +JSON_Value * json_value_init_object(void) { + JSON_Value *new_value = (JSON_Value*)parson_malloc(sizeof(JSON_Value)); + if (!new_value) { + return NULL; + } + new_value->parent = NULL; + new_value->type = JSONObject; + new_value->value.object = json_object_init(new_value); + if (!new_value->value.object) { + parson_free(new_value); + return NULL; + } + return new_value; +} + +JSON_Value * json_value_init_array(void) { + JSON_Value *new_value = (JSON_Value*)parson_malloc(sizeof(JSON_Value)); + if (!new_value) { + return NULL; + } + new_value->parent = NULL; + new_value->type = JSONArray; + new_value->value.array = json_array_init(new_value); + if (!new_value->value.array) { + parson_free(new_value); + return NULL; + } + return new_value; +} + +JSON_Value * json_value_init_string(const char *string) { + char *copy = NULL; + JSON_Value *value; + size_t string_len = 0; + if (string == NULL) { + return NULL; + } + string_len = strlen(string); + if (!is_valid_utf8(string, string_len)) { + return NULL; + } + copy = parson_strndup(string, string_len); + if (copy == NULL) { + return NULL; + } + value = json_value_init_string_no_copy(copy); + if (value == NULL) { + parson_free(copy); + } + return value; +} + +JSON_Value * json_value_init_number(double number) { + JSON_Value *new_value = NULL; + if ((number * 0.0) != 0.0) { /* nan and inf test */ + return NULL; + } + new_value = (JSON_Value*)parson_malloc(sizeof(JSON_Value)); + if (new_value == NULL) { + return NULL; + } + new_value->parent = NULL; + new_value->type = JSONNumber; + new_value->value.number = number; + return new_value; +} + +JSON_Value * json_value_init_boolean(int boolean) { + JSON_Value *new_value = (JSON_Value*)parson_malloc(sizeof(JSON_Value)); + if (!new_value) { + return NULL; + } + new_value->parent = NULL; + new_value->type = JSONBoolean; + new_value->value.boolean = boolean ? 1 : 0; + return new_value; +} + +JSON_Value * json_value_init_null(void) { + JSON_Value *new_value = (JSON_Value*)parson_malloc(sizeof(JSON_Value)); + if (!new_value) { + return NULL; + } + new_value->parent = NULL; + new_value->type = JSONNull; + return new_value; +} + +JSON_Value * json_value_deep_copy(const JSON_Value *value) { + size_t i = 0; + JSON_Value *return_value = NULL, *temp_value_copy = NULL, *temp_value = NULL; + const char *temp_string = NULL, *temp_key = NULL; + char *temp_string_copy = NULL; + JSON_Array *temp_array = NULL, *temp_array_copy = NULL; + JSON_Object *temp_object = NULL, *temp_object_copy = NULL; + + switch (json_value_get_type(value)) { + case JSONArray: + temp_array = json_value_get_array(value); + return_value = json_value_init_array(); + if (return_value == NULL) { + return NULL; + } + temp_array_copy = json_value_get_array(return_value); + for (i = 0; i < json_array_get_count(temp_array); i++) { + temp_value = json_array_get_value(temp_array, i); + temp_value_copy = json_value_deep_copy(temp_value); + if (temp_value_copy == NULL) { + json_value_free(return_value); + return NULL; + } + if (json_array_add(temp_array_copy, temp_value_copy) == JSONFailure) { + json_value_free(return_value); + json_value_free(temp_value_copy); + return NULL; + } + } + return return_value; + case JSONObject: + temp_object = json_value_get_object(value); + return_value = json_value_init_object(); + if (return_value == NULL) { + return NULL; + } + temp_object_copy = json_value_get_object(return_value); + for (i = 0; i < json_object_get_count(temp_object); i++) { + temp_key = json_object_get_name(temp_object, i); + temp_value = json_object_get_value(temp_object, temp_key); + temp_value_copy = json_value_deep_copy(temp_value); + if (temp_value_copy == NULL) { + json_value_free(return_value); + return NULL; + } + if (json_object_add(temp_object_copy, temp_key, temp_value_copy) == JSONFailure) { + json_value_free(return_value); + json_value_free(temp_value_copy); + return NULL; + } + } + return return_value; + case JSONBoolean: + return json_value_init_boolean(json_value_get_boolean(value)); + case JSONNumber: + return json_value_init_number(json_value_get_number(value)); + case JSONString: + temp_string = json_value_get_string(value); + if (temp_string == NULL) { + return NULL; + } + temp_string_copy = parson_strdup(temp_string); + if (temp_string_copy == NULL) { + return NULL; + } + return_value = json_value_init_string_no_copy(temp_string_copy); + if (return_value == NULL) { + parson_free(temp_string_copy); + } + return return_value; + case JSONNull: + return json_value_init_null(); + case JSONError: + return NULL; + default: + return NULL; + } +} + +size_t json_serialization_size(const JSON_Value *value) { + char num_buf[1100]; /* recursively allocating buffer on stack is a bad idea, so let's do it only once */ + int res = json_serialize_to_buffer_r(value, NULL, 0, 0, num_buf); + return res < 0 ? 0 : (size_t)(res + 1); +} + +JSON_Status json_serialize_to_buffer(const JSON_Value *value, char *buf, size_t buf_size_in_bytes) { + int written = -1; + size_t needed_size_in_bytes = json_serialization_size(value); + if (needed_size_in_bytes == 0 || buf_size_in_bytes < needed_size_in_bytes) { + return JSONFailure; + } + written = json_serialize_to_buffer_r(value, buf, 0, 0, NULL); + if (written < 0) { + return JSONFailure; + } + return JSONSuccess; +} + +JSON_Status json_serialize_to_file(const JSON_Value *value, const char *filename) { + JSON_Status return_code = JSONSuccess; + FILE *fp = NULL; + char *serialized_string = json_serialize_to_string(value); + if (serialized_string == NULL) { + return JSONFailure; + } + fp = fopen (filename, "w"); + if (fp == NULL) { + json_free_serialized_string(serialized_string); + return JSONFailure; + } + if (fputs(serialized_string, fp) == EOF) { + return_code = JSONFailure; + } + if (fclose(fp) == EOF) { + return_code = JSONFailure; + } + json_free_serialized_string(serialized_string); + return return_code; +} + +char * json_serialize_to_string(const JSON_Value *value) { + JSON_Status serialization_result = JSONFailure; + size_t buf_size_bytes = json_serialization_size(value); + char *buf = NULL; + if (buf_size_bytes == 0) { + return NULL; + } + buf = (char*)parson_malloc(buf_size_bytes); + if (buf == NULL) { + return NULL; + } + serialization_result = json_serialize_to_buffer(value, buf, buf_size_bytes); + if (serialization_result == JSONFailure) { + json_free_serialized_string(buf); + return NULL; + } + return buf; +} + +size_t json_serialization_size_pretty(const JSON_Value *value) { + char num_buf[1100]; /* recursively allocating buffer on stack is a bad idea, so let's do it only once */ + int res = json_serialize_to_buffer_r(value, NULL, 0, 1, num_buf); + return res < 0 ? 0 : (size_t)(res + 1); +} + +JSON_Status json_serialize_to_buffer_pretty(const JSON_Value *value, char *buf, size_t buf_size_in_bytes) { + int written = -1; + size_t needed_size_in_bytes = json_serialization_size_pretty(value); + if (needed_size_in_bytes == 0 || buf_size_in_bytes < needed_size_in_bytes) { + return JSONFailure; + } + written = json_serialize_to_buffer_r(value, buf, 0, 1, NULL); + if (written < 0) { + return JSONFailure; + } + return JSONSuccess; +} + +JSON_Status json_serialize_to_file_pretty(const JSON_Value *value, const char *filename) { + JSON_Status return_code = JSONSuccess; + FILE *fp = NULL; + char *serialized_string = json_serialize_to_string_pretty(value); + if (serialized_string == NULL) { + return JSONFailure; + } + fp = fopen (filename, "w"); + if (fp == NULL) { + json_free_serialized_string(serialized_string); + return JSONFailure; + } + if (fputs(serialized_string, fp) == EOF) { + return_code = JSONFailure; + } + if (fclose(fp) == EOF) { + return_code = JSONFailure; + } + json_free_serialized_string(serialized_string); + return return_code; +} + +char * json_serialize_to_string_pretty(const JSON_Value *value) { + JSON_Status serialization_result = JSONFailure; + size_t buf_size_bytes = json_serialization_size_pretty(value); + char *buf = NULL; + if (buf_size_bytes == 0) { + return NULL; + } + buf = (char*)parson_malloc(buf_size_bytes); + if (buf == NULL) { + return NULL; + } + serialization_result = json_serialize_to_buffer_pretty(value, buf, buf_size_bytes); + if (serialization_result == JSONFailure) { + json_free_serialized_string(buf); + return NULL; + } + return buf; +} + +void json_free_serialized_string(char *string) { + parson_free(string); +} + +JSON_Status json_array_remove(JSON_Array *array, size_t ix) { + size_t to_move_bytes = 0; + if (array == NULL || ix >= json_array_get_count(array)) { + return JSONFailure; + } + json_value_free(json_array_get_value(array, ix)); + to_move_bytes = (json_array_get_count(array) - 1 - ix) * sizeof(JSON_Value*); + memmove(array->items + ix, array->items + ix + 1, to_move_bytes); + array->count -= 1; + return JSONSuccess; +} + +JSON_Status json_array_replace_value(JSON_Array *array, size_t ix, JSON_Value *value) { + if (array == NULL || value == NULL || value->parent != NULL || ix >= json_array_get_count(array)) { + return JSONFailure; + } + json_value_free(json_array_get_value(array, ix)); + value->parent = json_array_get_wrapping_value(array); + array->items[ix] = value; + return JSONSuccess; +} + +JSON_Status json_array_replace_string(JSON_Array *array, size_t i, const char* string) { + JSON_Value *value = json_value_init_string(string); + if (value == NULL) { + return JSONFailure; + } + if (json_array_replace_value(array, i, value) == JSONFailure) { + json_value_free(value); + return JSONFailure; + } + return JSONSuccess; +} + +JSON_Status json_array_replace_number(JSON_Array *array, size_t i, double number) { + JSON_Value *value = json_value_init_number(number); + if (value == NULL) { + return JSONFailure; + } + if (json_array_replace_value(array, i, value) == JSONFailure) { + json_value_free(value); + return JSONFailure; + } + return JSONSuccess; +} + +JSON_Status json_array_replace_boolean(JSON_Array *array, size_t i, int boolean) { + JSON_Value *value = json_value_init_boolean(boolean); + if (value == NULL) { + return JSONFailure; + } + if (json_array_replace_value(array, i, value) == JSONFailure) { + json_value_free(value); + return JSONFailure; + } + return JSONSuccess; +} + +JSON_Status json_array_replace_null(JSON_Array *array, size_t i) { + JSON_Value *value = json_value_init_null(); + if (value == NULL) { + return JSONFailure; + } + if (json_array_replace_value(array, i, value) == JSONFailure) { + json_value_free(value); + return JSONFailure; + } + return JSONSuccess; +} + +JSON_Status json_array_clear(JSON_Array *array) { + size_t i = 0; + if (array == NULL) { + return JSONFailure; + } + for (i = 0; i < json_array_get_count(array); i++) { + json_value_free(json_array_get_value(array, i)); + } + array->count = 0; + return JSONSuccess; +} + +JSON_Status json_array_append_value(JSON_Array *array, JSON_Value *value) { + if (array == NULL || value == NULL || value->parent != NULL) { + return JSONFailure; + } + return json_array_add(array, value); +} + +JSON_Status json_array_append_string(JSON_Array *array, const char *string) { + JSON_Value *value = json_value_init_string(string); + if (value == NULL) { + return JSONFailure; + } + if (json_array_append_value(array, value) == JSONFailure) { + json_value_free(value); + return JSONFailure; + } + return JSONSuccess; +} + +JSON_Status json_array_append_number(JSON_Array *array, double number) { + JSON_Value *value = json_value_init_number(number); + if (value == NULL) { + return JSONFailure; + } + if (json_array_append_value(array, value) == JSONFailure) { + json_value_free(value); + return JSONFailure; + } + return JSONSuccess; +} + +JSON_Status json_array_append_boolean(JSON_Array *array, int boolean) { + JSON_Value *value = json_value_init_boolean(boolean); + if (value == NULL) { + return JSONFailure; + } + if (json_array_append_value(array, value) == JSONFailure) { + json_value_free(value); + return JSONFailure; + } + return JSONSuccess; +} + +JSON_Status json_array_append_null(JSON_Array *array) { + JSON_Value *value = json_value_init_null(); + if (value == NULL) { + return JSONFailure; + } + if (json_array_append_value(array, value) == JSONFailure) { + json_value_free(value); + return JSONFailure; + } + return JSONSuccess; +} + +JSON_Status json_object_set_value(JSON_Object *object, const char *name, JSON_Value *value) { + size_t i = 0; + JSON_Value *old_value; + if (object == NULL || name == NULL || value == NULL || value->parent != NULL) { + return JSONFailure; + } + old_value = json_object_get_value(object, name); + if (old_value != NULL) { /* free and overwrite old value */ + json_value_free(old_value); + for (i = 0; i < json_object_get_count(object); i++) { + if (strcmp(object->names[i], name) == 0) { + value->parent = json_object_get_wrapping_value(object); + object->values[i] = value; + return JSONSuccess; + } + } + } + /* add new key value pair */ + return json_object_add(object, name, value); +} + +JSON_Status json_object_set_string(JSON_Object *object, const char *name, const char *string) { + return json_object_set_value(object, name, json_value_init_string(string)); +} + +JSON_Status json_object_set_number(JSON_Object *object, const char *name, double number) { + return json_object_set_value(object, name, json_value_init_number(number)); +} + +JSON_Status json_object_set_boolean(JSON_Object *object, const char *name, int boolean) { + return json_object_set_value(object, name, json_value_init_boolean(boolean)); +} + +JSON_Status json_object_set_null(JSON_Object *object, const char *name) { + return json_object_set_value(object, name, json_value_init_null()); +} + +JSON_Status json_object_dotset_value(JSON_Object *object, const char *name, JSON_Value *value) { + const char *dot_pos = NULL; + char *current_name = NULL; + JSON_Object *temp_obj = NULL; + JSON_Value *new_value = NULL; + if (object == NULL || name == NULL || value == NULL) { + return JSONFailure; + } + dot_pos = strchr(name, '.'); + if (dot_pos == NULL) { + return json_object_set_value(object, name, value); + } else { + current_name = parson_strndup(name, dot_pos - name); + temp_obj = json_object_get_object(object, current_name); + if (temp_obj == NULL) { + new_value = json_value_init_object(); + if (new_value == NULL) { + parson_free(current_name); + return JSONFailure; + } + if (json_object_add(object, current_name, new_value) == JSONFailure) { + json_value_free(new_value); + parson_free(current_name); + return JSONFailure; + } + temp_obj = json_object_get_object(object, current_name); + } + parson_free(current_name); + return json_object_dotset_value(temp_obj, dot_pos + 1, value); + } +} + +JSON_Status json_object_dotset_string(JSON_Object *object, const char *name, const char *string) { + JSON_Value *value = json_value_init_string(string); + if (value == NULL) { + return JSONFailure; + } + if (json_object_dotset_value(object, name, value) == JSONFailure) { + json_value_free(value); + return JSONFailure; + } + return JSONSuccess; +} + +JSON_Status json_object_dotset_number(JSON_Object *object, const char *name, double number) { + JSON_Value *value = json_value_init_number(number); + if (value == NULL) { + return JSONFailure; + } + if (json_object_dotset_value(object, name, value) == JSONFailure) { + json_value_free(value); + return JSONFailure; + } + return JSONSuccess; +} + +JSON_Status json_object_dotset_boolean(JSON_Object *object, const char *name, int boolean) { + JSON_Value *value = json_value_init_boolean(boolean); + if (value == NULL) { + return JSONFailure; + } + if (json_object_dotset_value(object, name, value) == JSONFailure) { + json_value_free(value); + return JSONFailure; + } + return JSONSuccess; +} + +JSON_Status json_object_dotset_null(JSON_Object *object, const char *name) { + JSON_Value *value = json_value_init_null(); + if (value == NULL) { + return JSONFailure; + } + if (json_object_dotset_value(object, name, value) == JSONFailure) { + json_value_free(value); + return JSONFailure; + } + return JSONSuccess; +} + +JSON_Status json_object_remove(JSON_Object *object, const char *name) { + size_t i = 0, last_item_index = 0; + if (object == NULL || json_object_get_value(object, name) == NULL) { + return JSONFailure; + } + last_item_index = json_object_get_count(object) - 1; + for (i = 0; i < json_object_get_count(object); i++) { + if (strcmp(object->names[i], name) == 0) { + parson_free(object->names[i]); + json_value_free(object->values[i]); + if (i != last_item_index) { /* Replace key value pair with one from the end */ + object->names[i] = object->names[last_item_index]; + object->values[i] = object->values[last_item_index]; + } + object->count -= 1; + return JSONSuccess; + } + } + return JSONFailure; /* No execution path should end here */ +} + +JSON_Status json_object_dotremove(JSON_Object *object, const char *name) { + const char *dot_pos = strchr(name, '.'); + char *current_name = NULL; + JSON_Object *temp_obj = NULL; + if (dot_pos == NULL) { + return json_object_remove(object, name); + } else { + current_name = parson_strndup(name, dot_pos - name); + temp_obj = json_object_get_object(object, current_name); + parson_free(current_name); + if (temp_obj == NULL) { + return JSONFailure; + } + return json_object_dotremove(temp_obj, dot_pos + 1); + } +} + +JSON_Status json_object_clear(JSON_Object *object) { + size_t i = 0; + if (object == NULL) { + return JSONFailure; + } + for (i = 0; i < json_object_get_count(object); i++) { + parson_free(object->names[i]); + json_value_free(object->values[i]); + } + object->count = 0; + return JSONSuccess; +} + +JSON_Status json_validate(const JSON_Value *schema, const JSON_Value *value) { + JSON_Value *temp_schema_value = NULL, *temp_value = NULL; + JSON_Array *schema_array = NULL, *value_array = NULL; + JSON_Object *schema_object = NULL, *value_object = NULL; + JSON_Value_Type schema_type = JSONError, value_type = JSONError; + const char *key = NULL; + size_t i = 0, count = 0; + if (schema == NULL || value == NULL) { + return JSONFailure; + } + schema_type = json_value_get_type(schema); + value_type = json_value_get_type(value); + if (schema_type != value_type && schema_type != JSONNull) { /* null represents all values */ + return JSONFailure; + } + switch (schema_type) { + case JSONArray: + schema_array = json_value_get_array(schema); + value_array = json_value_get_array(value); + count = json_array_get_count(schema_array); + if (count == 0) { + return JSONSuccess; /* Empty array allows all types */ + } + /* Get first value from array, rest is ignored */ + temp_schema_value = json_array_get_value(schema_array, 0); + for (i = 0; i < json_array_get_count(value_array); i++) { + temp_value = json_array_get_value(value_array, i); + if (json_validate(temp_schema_value, temp_value) == JSONFailure) { + return JSONFailure; + } + } + return JSONSuccess; + case JSONObject: + schema_object = json_value_get_object(schema); + value_object = json_value_get_object(value); + count = json_object_get_count(schema_object); + if (count == 0) { + return JSONSuccess; /* Empty object allows all objects */ + } else if (json_object_get_count(value_object) < count) { + return JSONFailure; /* Tested object mustn't have less name-value pairs than schema */ + } + for (i = 0; i < count; i++) { + key = json_object_get_name(schema_object, i); + temp_schema_value = json_object_get_value(schema_object, key); + temp_value = json_object_get_value(value_object, key); + if (temp_value == NULL) { + return JSONFailure; + } + if (json_validate(temp_schema_value, temp_value) == JSONFailure) { + return JSONFailure; + } + } + return JSONSuccess; + case JSONString: case JSONNumber: case JSONBoolean: case JSONNull: + return JSONSuccess; /* equality already tested before switch */ + case JSONError: default: + return JSONFailure; + } +} + +int json_value_equals(const JSON_Value *a, const JSON_Value *b) { + JSON_Object *a_object = NULL, *b_object = NULL; + JSON_Array *a_array = NULL, *b_array = NULL; + const char *a_string = NULL, *b_string = NULL; + const char *key = NULL; + size_t a_count = 0, b_count = 0, i = 0; + JSON_Value_Type a_type, b_type; + a_type = json_value_get_type(a); + b_type = json_value_get_type(b); + if (a_type != b_type) { + return 0; + } + switch (a_type) { + case JSONArray: + a_array = json_value_get_array(a); + b_array = json_value_get_array(b); + a_count = json_array_get_count(a_array); + b_count = json_array_get_count(b_array); + if (a_count != b_count) { + return 0; + } + for (i = 0; i < a_count; i++) { + if (!json_value_equals(json_array_get_value(a_array, i), + json_array_get_value(b_array, i))) { + return 0; + } + } + return 1; + case JSONObject: + a_object = json_value_get_object(a); + b_object = json_value_get_object(b); + a_count = json_object_get_count(a_object); + b_count = json_object_get_count(b_object); + if (a_count != b_count) { + return 0; + } + for (i = 0; i < a_count; i++) { + key = json_object_get_name(a_object, i); + if (!json_value_equals(json_object_get_value(a_object, key), + json_object_get_value(b_object, key))) { + return 0; + } + } + return 1; + case JSONString: + a_string = json_value_get_string(a); + b_string = json_value_get_string(b); + if (a_string == NULL || b_string == NULL) { + return 0; /* shouldn't happen */ + } + return strcmp(a_string, b_string) == 0; + case JSONBoolean: + return json_value_get_boolean(a) == json_value_get_boolean(b); + case JSONNumber: + return fabs(json_value_get_number(a) - json_value_get_number(b)) < 0.000001; /* EPSILON */ + case JSONError: + return 1; + case JSONNull: + return 1; + default: + return 1; + } +} + +JSON_Value_Type json_type(const JSON_Value *value) { + return json_value_get_type(value); +} + +JSON_Object * json_object (const JSON_Value *value) { + return json_value_get_object(value); +} + +JSON_Array * json_array (const JSON_Value *value) { + return json_value_get_array(value); +} + +const char * json_string (const JSON_Value *value) { + return json_value_get_string(value); +} + +double json_number (const JSON_Value *value) { + return json_value_get_number(value); +} + +int json_boolean(const JSON_Value *value) { + return json_value_get_boolean(value); +} + +void json_set_allocation_functions(JSON_Malloc_Function malloc_fun, JSON_Free_Function free_fun) { + parson_malloc = malloc_fun; + parson_free = free_fun; +} diff --git a/fakenect/parson.h b/fakenect/parson.h new file mode 100644 index 00000000..6438c936 --- /dev/null +++ b/fakenect/parson.h @@ -0,0 +1,234 @@ +/* + Parson ( http://kgabis.github.com/parson/ ) + Copyright (c) 2012 - 2017 Krzysztof Gabis + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ + +#ifndef parson_parson_h +#define parson_parson_h + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include /* size_t */ + +/* Types and enums */ +typedef struct json_object_t JSON_Object; +typedef struct json_array_t JSON_Array; +typedef struct json_value_t JSON_Value; + +enum json_value_type { + JSONError = -1, + JSONNull = 1, + JSONString = 2, + JSONNumber = 3, + JSONObject = 4, + JSONArray = 5, + JSONBoolean = 6 +}; +typedef int JSON_Value_Type; + +enum json_result_t { + JSONSuccess = 0, + JSONFailure = -1 +}; +typedef int JSON_Status; + +typedef void * (*JSON_Malloc_Function)(size_t); +typedef void (*JSON_Free_Function)(void *); + +/* Call only once, before calling any other function from parson API. If not called, malloc and free + from stdlib will be used for all allocations */ +void json_set_allocation_functions(JSON_Malloc_Function malloc_fun, JSON_Free_Function free_fun); + +/* Parses first JSON value in a file, returns NULL in case of error */ +JSON_Value * json_parse_file(const char *filename); + +/* Parses first JSON value in a file and ignores comments (/ * * / and //), + returns NULL in case of error */ +JSON_Value * json_parse_file_with_comments(const char *filename); + +/* Parses first JSON value in a string, returns NULL in case of error */ +JSON_Value * json_parse_string(const char *string); + +/* Parses first JSON value in a string and ignores comments (/ * * / and //), + returns NULL in case of error */ +JSON_Value * json_parse_string_with_comments(const char *string); + +/* Serialization */ +size_t json_serialization_size(const JSON_Value *value); /* returns 0 on fail */ +JSON_Status json_serialize_to_buffer(const JSON_Value *value, char *buf, size_t buf_size_in_bytes); +JSON_Status json_serialize_to_file(const JSON_Value *value, const char *filename); +char * json_serialize_to_string(const JSON_Value *value); + +/* Pretty serialization */ +size_t json_serialization_size_pretty(const JSON_Value *value); /* returns 0 on fail */ +JSON_Status json_serialize_to_buffer_pretty(const JSON_Value *value, char *buf, size_t buf_size_in_bytes); +JSON_Status json_serialize_to_file_pretty(const JSON_Value *value, const char *filename); +char * json_serialize_to_string_pretty(const JSON_Value *value); + +void json_free_serialized_string(char *string); /* frees string from json_serialize_to_string and json_serialize_to_string_pretty */ + +/* Comparing */ +int json_value_equals(const JSON_Value *a, const JSON_Value *b); + +/* Validation + This is *NOT* JSON Schema. It validates json by checking if object have identically + named fields with matching types. + For example schema {"name":"", "age":0} will validate + {"name":"Joe", "age":25} and {"name":"Joe", "age":25, "gender":"m"}, + but not {"name":"Joe"} or {"name":"Joe", "age":"Cucumber"}. + In case of arrays, only first value in schema is checked against all values in tested array. + Empty objects ({}) validate all objects, empty arrays ([]) validate all arrays, + null validates values of every type. + */ +JSON_Status json_validate(const JSON_Value *schema, const JSON_Value *value); + +/* + * JSON Object + */ +JSON_Value * json_object_get_value (const JSON_Object *object, const char *name); +const char * json_object_get_string (const JSON_Object *object, const char *name); +JSON_Object * json_object_get_object (const JSON_Object *object, const char *name); +JSON_Array * json_object_get_array (const JSON_Object *object, const char *name); +double json_object_get_number (const JSON_Object *object, const char *name); /* returns 0 on fail */ +int json_object_get_boolean(const JSON_Object *object, const char *name); /* returns -1 on fail */ + +/* dotget functions enable addressing values with dot notation in nested objects, + just like in structs or c++/java/c# objects (e.g. objectA.objectB.value). + Because valid names in JSON can contain dots, some values may be inaccessible + this way. */ +JSON_Value * json_object_dotget_value (const JSON_Object *object, const char *name); +const char * json_object_dotget_string (const JSON_Object *object, const char *name); +JSON_Object * json_object_dotget_object (const JSON_Object *object, const char *name); +JSON_Array * json_object_dotget_array (const JSON_Object *object, const char *name); +double json_object_dotget_number (const JSON_Object *object, const char *name); /* returns 0 on fail */ +int json_object_dotget_boolean(const JSON_Object *object, const char *name); /* returns -1 on fail */ + +/* Functions to get available names */ +size_t json_object_get_count (const JSON_Object *object); +const char * json_object_get_name (const JSON_Object *object, size_t index); +JSON_Value * json_object_get_value_at(const JSON_Object *object, size_t index); +JSON_Value * json_object_get_wrapping_value(const JSON_Object *object); + +/* Functions to check if object has a value with a specific name. Returned value is 1 if object has + * a value and 0 if it doesn't. dothas functions behave exactly like dotget functions. */ +int json_object_has_value (const JSON_Object *object, const char *name); +int json_object_has_value_of_type(const JSON_Object *object, const char *name, JSON_Value_Type type); + +int json_object_dothas_value (const JSON_Object *object, const char *name); +int json_object_dothas_value_of_type(const JSON_Object *object, const char *name, JSON_Value_Type type); + +/* Creates new name-value pair or frees and replaces old value with a new one. + * json_object_set_value does not copy passed value so it shouldn't be freed afterwards. */ +JSON_Status json_object_set_value(JSON_Object *object, const char *name, JSON_Value *value); +JSON_Status json_object_set_string(JSON_Object *object, const char *name, const char *string); +JSON_Status json_object_set_number(JSON_Object *object, const char *name, double number); +JSON_Status json_object_set_boolean(JSON_Object *object, const char *name, int boolean); +JSON_Status json_object_set_null(JSON_Object *object, const char *name); + +/* Works like dotget functions, but creates whole hierarchy if necessary. + * json_object_dotset_value does not copy passed value so it shouldn't be freed afterwards. */ +JSON_Status json_object_dotset_value(JSON_Object *object, const char *name, JSON_Value *value); +JSON_Status json_object_dotset_string(JSON_Object *object, const char *name, const char *string); +JSON_Status json_object_dotset_number(JSON_Object *object, const char *name, double number); +JSON_Status json_object_dotset_boolean(JSON_Object *object, const char *name, int boolean); +JSON_Status json_object_dotset_null(JSON_Object *object, const char *name); + +/* Frees and removes name-value pair */ +JSON_Status json_object_remove(JSON_Object *object, const char *name); + +/* Works like dotget function, but removes name-value pair only on exact match. */ +JSON_Status json_object_dotremove(JSON_Object *object, const char *key); + +/* Removes all name-value pairs in object */ +JSON_Status json_object_clear(JSON_Object *object); + +/* + *JSON Array + */ +JSON_Value * json_array_get_value (const JSON_Array *array, size_t index); +const char * json_array_get_string (const JSON_Array *array, size_t index); +JSON_Object * json_array_get_object (const JSON_Array *array, size_t index); +JSON_Array * json_array_get_array (const JSON_Array *array, size_t index); +double json_array_get_number (const JSON_Array *array, size_t index); /* returns 0 on fail */ +int json_array_get_boolean(const JSON_Array *array, size_t index); /* returns -1 on fail */ +size_t json_array_get_count (const JSON_Array *array); +JSON_Value * json_array_get_wrapping_value(const JSON_Array *array); + +/* Frees and removes value at given index, does nothing and returns JSONFailure if index doesn't exist. + * Order of values in array may change during execution. */ +JSON_Status json_array_remove(JSON_Array *array, size_t i); + +/* Frees and removes from array value at given index and replaces it with given one. + * Does nothing and returns JSONFailure if index doesn't exist. + * json_array_replace_value does not copy passed value so it shouldn't be freed afterwards. */ +JSON_Status json_array_replace_value(JSON_Array *array, size_t i, JSON_Value *value); +JSON_Status json_array_replace_string(JSON_Array *array, size_t i, const char* string); +JSON_Status json_array_replace_number(JSON_Array *array, size_t i, double number); +JSON_Status json_array_replace_boolean(JSON_Array *array, size_t i, int boolean); +JSON_Status json_array_replace_null(JSON_Array *array, size_t i); + +/* Frees and removes all values from array */ +JSON_Status json_array_clear(JSON_Array *array); + +/* Appends new value at the end of array. + * json_array_append_value does not copy passed value so it shouldn't be freed afterwards. */ +JSON_Status json_array_append_value(JSON_Array *array, JSON_Value *value); +JSON_Status json_array_append_string(JSON_Array *array, const char *string); +JSON_Status json_array_append_number(JSON_Array *array, double number); +JSON_Status json_array_append_boolean(JSON_Array *array, int boolean); +JSON_Status json_array_append_null(JSON_Array *array); + +/* + *JSON Value + */ +JSON_Value * json_value_init_object (void); +JSON_Value * json_value_init_array (void); +JSON_Value * json_value_init_string (const char *string); /* copies passed string */ +JSON_Value * json_value_init_number (double number); +JSON_Value * json_value_init_boolean(int boolean); +JSON_Value * json_value_init_null (void); +JSON_Value * json_value_deep_copy (const JSON_Value *value); +void json_value_free (JSON_Value *value); + +JSON_Value_Type json_value_get_type (const JSON_Value *value); +JSON_Object * json_value_get_object (const JSON_Value *value); +JSON_Array * json_value_get_array (const JSON_Value *value); +const char * json_value_get_string (const JSON_Value *value); +double json_value_get_number (const JSON_Value *value); +int json_value_get_boolean(const JSON_Value *value); +JSON_Value * json_value_get_parent (const JSON_Value *value); + +/* Same as above, but shorter */ +JSON_Value_Type json_type (const JSON_Value *value); +JSON_Object * json_object (const JSON_Value *value); +JSON_Array * json_array (const JSON_Value *value); +const char * json_string (const JSON_Value *value); +double json_number (const JSON_Value *value); +int json_boolean(const JSON_Value *value); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/fakenect/platform.h b/fakenect/platform.h index 73c1d5e9..49507f2b 100644 --- a/fakenect/platform.h +++ b/fakenect/platform.h @@ -28,7 +28,9 @@ #ifdef _WIN32 #include #include - #define snprintf _snprintf + #if defined(_MSC_VER) && _MSC_VER < 1900 + #define snprintf _snprintf + #endif #define popen _popen #else #include diff --git a/fakenect/record.c b/fakenect/record.c index abd8d4b2..31f3807b 100644 --- a/fakenect/record.c +++ b/fakenect/record.c @@ -24,7 +24,9 @@ */ #include "libfreenect.h" +#include "freenect_internal.h" #include "platform.h" +#include "parson.h" #include #include #include @@ -201,6 +203,70 @@ void print_mode(const char *name, freenect_frame_mode mode) { mode.framerate, mode.is_valid); } +static void write_device_info(freenect_device *dev) +{ + JSON_Value *js = json_value_init_object(); + JSON_Object *dev_js = json_object(js); + + JSON_Value *reg_info_val = json_value_init_object(); + JSON_Object *reg_info = json_object(reg_info_val); + + json_object_set_value(dev_js, "reg_info", reg_info_val); + + json_object_set_number(reg_info, "ax", dev->registration.reg_info.ax); + json_object_set_number(reg_info, "bx", dev->registration.reg_info.bx); + json_object_set_number(reg_info, "cx", dev->registration.reg_info.cx); + json_object_set_number(reg_info, "dx", dev->registration.reg_info.dx); + json_object_set_number(reg_info, "ay", dev->registration.reg_info.ay); + json_object_set_number(reg_info, "by", dev->registration.reg_info.by); + json_object_set_number(reg_info, "cy", dev->registration.reg_info.cy); + json_object_set_number(reg_info, "dy", dev->registration.reg_info.dy); + json_object_set_number(reg_info, "dx_start", dev->registration.reg_info.dx_start); + json_object_set_number(reg_info, "dy_start", dev->registration.reg_info.dy_start); + json_object_set_number(reg_info, "dx_beta_start", dev->registration.reg_info.dx_beta_start); + json_object_set_number(reg_info, "dy_beta_start", dev->registration.reg_info.dy_beta_start); + json_object_set_number(reg_info, "dx_beta_inc", dev->registration.reg_info.dx_beta_inc); + json_object_set_number(reg_info, "dy_beta_inc", dev->registration.reg_info.dy_beta_inc); + json_object_set_number(reg_info, "dxdx_start", dev->registration.reg_info.dxdx_start); + json_object_set_number(reg_info, "dxdy_start", dev->registration.reg_info.dxdy_start); + json_object_set_number(reg_info, "dydx_start", dev->registration.reg_info.dydx_start); + json_object_set_number(reg_info, "dydy_start", dev->registration.reg_info.dydy_start); + json_object_set_number(reg_info, "dxdxdx_start", dev->registration.reg_info.dxdxdx_start); + json_object_set_number(reg_info, "dydxdx_start", dev->registration.reg_info.dydxdx_start); + json_object_set_number(reg_info, "dxdxdy_start", dev->registration.reg_info.dxdxdy_start); + json_object_set_number(reg_info, "dydxdy_start", dev->registration.reg_info.dydxdy_start); + json_object_set_number(reg_info, "dydydx_start", dev->registration.reg_info.dydydx_start); + json_object_set_number(reg_info, "dydydy_start", dev->registration.reg_info.dydydy_start); + + JSON_Value *pad_info_val = json_value_init_object(); + JSON_Object *pad_info = json_object(pad_info_val); + + json_object_set_value(reg_info, "pad_info", pad_info_val); + + json_object_set_number(pad_info, "start_lines", dev->registration.reg_pad_info.start_lines); + json_object_set_number(pad_info, "end_lines", dev->registration.reg_pad_info.end_lines); + json_object_set_number(pad_info, "cropping_lines", dev->registration.reg_pad_info.cropping_lines); + + JSON_Value *zp_info_val = json_value_init_object(); + JSON_Object *zp_info = json_object(zp_info_val); + + json_object_set_value(reg_info, "zero_plane_info", zp_info_val); + + json_object_set_number(zp_info, "dcmos_emitter_distance", dev->registration.zero_plane_info.dcmos_emitter_dist); + json_object_set_number(zp_info, "dcmos_rcmos_distance", dev->registration.zero_plane_info.dcmos_rcmos_dist); + json_object_set_number(zp_info, "reference_distance", dev->registration.zero_plane_info.reference_distance); + json_object_set_number(zp_info, "reference_pixel_size", dev->registration.zero_plane_info.reference_pixel_size); + + json_object_set_number(dev_js, "const_shift", dev->registration.const_shift); + + char fn[512]; + snprintf(fn, sizeof(fn), "%s/device.json", out_dir); + + json_serialize_to_file_pretty(js, fn); + + json_value_free(js); +} + void init() { freenect_context *ctx; @@ -223,6 +289,9 @@ void init() freenect_start_depth(dev); freenect_set_video_mode(dev, freenect_find_video_mode(FREENECT_RESOLUTION_MEDIUM, FREENECT_VIDEO_RGB)); freenect_start_video(dev); + + write_device_info(dev); + if (use_ffmpeg) { init_ffmpeg_streams(); freenect_set_depth_callback(dev, depth_cb_ffmpeg); diff --git a/include/libfreenect.h b/include/libfreenect.h index f436715c..a86fac6d 100644 --- a/include/libfreenect.h +++ b/include/libfreenect.h @@ -110,6 +110,7 @@ typedef enum { typedef enum { // values written to the CMOS register FREENECT_AUTO_EXPOSURE = 1 << 14, + FREENECT_AUTO_FLICKER = 1 << 7, FREENECT_AUTO_WHITE_BALANCE = 1 << 1, FREENECT_RAW_COLOR = 1 << 4, // arbitrary bitfields to support flag combination @@ -670,6 +671,34 @@ 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); +/** + * Get the current exposure in microseconds + * + * @param dev Device to set exposure + * @param time_us exposure time in microseconds + * + * @return 0 on success, < 0 if error + */ +FREENECTAPI int freenect_get_exposure(freenect_device *dev, int *time_us); + +/** + * Sets a static exposure time in microseconds + * note: you must turn off auto-exposure before calling this function + * + * Sample usage with 33.333ms exposure: + * + * freenect_set_flag(fn_dev, FREENECT_AUTO_EXPOSURE, FREENECT_OFF); + * freenect_set_flag(fn_dev, FREENECT_AUTO_FLICKER, FREENECT_OFF); + * freenect_set_flag(fn_dev, FREENECT_AUTO_WHITE_BALANCE, FREENECT_OFF); + * freenect_set_exposure(fn_dev, 33333); + * + * @param dev Device to set exposure + * @param time_us exposure time in microseconds + * + * @return 0 on success, < 0 if error + */ +FREENECTAPI int freenect_set_exposure(freenect_device *dev, int time_us); + /** * Returns the brightness of the IR sensor. * diff --git a/platform/linux/portage/dev-libs/libfreenect/Manifest b/platform/linux/portage/dev-libs/libfreenect/Manifest deleted file mode 100644 index 66181878..00000000 --- a/platform/linux/portage/dev-libs/libfreenect/Manifest +++ /dev/null @@ -1 +0,0 @@ -EBUILD libfreenect-9999.ebuild 2052 SHA256 cc490bd4f5c593d6cbee2c3e878389b85930893402c284f6d5c181ba5664f2e0 SHA512 a62f206923766eb6f468edbebff6109cdd77b1a7a4a80d8c0825d93ae9b7f881a3f15ec7fac0d4916b995150820ca1a7ac6ed1a625a47289632db3f95720be8d WHIRLPOOL 197fec2ca649a664fd02cdde6d704962e51d4970907cbf1092171646612bf5e34a6eae0784b23dc608b3c4438cecd261a8cd78528d695c18bb53fc7c0577d642 diff --git a/platform/linux/portage/dev-libs/libfreenect/libfreenect-9999.ebuild b/platform/linux/portage/dev-libs/libfreenect/libfreenect-9999.ebuild deleted file mode 100644 index eb308e23..00000000 --- a/platform/linux/portage/dev-libs/libfreenect/libfreenect-9999.ebuild +++ /dev/null @@ -1,74 +0,0 @@ -# Copyright 1999-2014 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 -# $Header: $ - -EAPI="5" - -inherit cmake-utils git-2 multilib python - - -DESCRIPTION="Core library for accessing the Microsoft Kinect." -HOMEPAGE="https://github.com/OpenKinect/${PN}" -EGIT_REPO_URI="git://github.com/OpenKinect/${PN}.git" - -LICENSE="Apache-2.0 GPL-2" -SLOT="0" -KEYWORDS="" -IUSE="bindist +c_sync +cpp doc examples fakenect opencv openni2 python" - -PYTHON_DEPEND="!bindist? 2" - -COMMON_DEP="virtual/libusb:1 - examples? ( media-libs/freeglut - virtual/opengl - x11-libs/libXi - x11-libs/libXmu ) - opencv? ( media-libs/opencv ) - python? ( dev-python/numpy )" - -RDEPEND="${COMMON_DEP}" -DEPEND="${COMMON_DEP} - dev-util/cmake - virtual/pkgconfig - doc? ( app-doc/doxygen ) - python? ( dev-python/cython )" - - -src_configure() { - local mycmakeargs=( - $(cmake-utils_use_build bindist REDIST_PACKAGE) - $(cmake-utils_use_build c_sync C_SYNC) - $(cmake-utils_use_build cpp CPP) - $(cmake-utils_use_build examples EXAMPLES) - $(cmake-utils_use_build fakenect FAKENECT) - $(cmake-utils_use_build opencv CV) - $(cmake-utils_use_build openni2 OPENNI2_DRIVER) - $(cmake-utils_use_build python PYTHON) - ) - cmake-utils_src_configure -} - -src_install() { - cmake-utils_src_install - - # udev rules - insinto /lib/udev/rules.d/ - doins "${S}"/platform/linux/udev/51-kinect.rules - - # documentation - dodoc README.md - if use doc; then - cd doc - doxygen || ewarn "doxygen failed" - dodoc -r html || ewarn "dodoc failed" - cd - - fi -} - -pkg_postinst() { - if ! use bindist; then - ewarn "The bindist USE flag is disabled. Resulting binaries may not be legal to re-distribute." - fi - elog "Make sure your user is in the 'video' group" - elog "Just run 'gpasswd -a video', then have re-login." -} diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 841873a0..6b625aec 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -6,15 +6,16 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}) include_directories(${LIBUSB_1_INCLUDE_DIRS}) # Audio Firmware -include(FindPythonInterp) IF(BUILD_REDIST_PACKAGE) # If this build is intended for a redistributable package, we can't include audios.bin, so we should include fwfetcher.py # and the package should run "python fwfetcher.py $INSTALL_PREFIX/share" as a postinst hook install (FILES "fwfetcher.py" DESTINATION "${CMAKE_INSTALL_PREFIX}/share") ELSE(BUILD_REDIST_PACKAGE) # If the install is local only, we can just run fwfetcher.py and install the audios.bin firmware to the system folder + cmake_minimum_required(VERSION 3.12) + find_package(Python REQUIRED COMPONENTS Interpreter) add_custom_target(firmware ALL - COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/fwfetcher.py" "../audios.bin" + COMMAND ${Python_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/fwfetcher.py" "../audios.bin" DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/fwfetcher.py") install (FILES "${CMAKE_CURRENT_BINARY_DIR}/../audios.bin" DESTINATION "${CMAKE_INSTALL_PREFIX}/share/libfreenect") ENDIF() diff --git a/src/cameras.c b/src/cameras.c index 834fefb3..a5d580a1 100644 --- a/src/cameras.c +++ b/src/cameras.c @@ -397,7 +397,7 @@ static void depth_process(freenect_device *dev, uint8_t *pkt, int len) convert_packed11_to_16bit(dev->depth.raw_buf, (uint16_t*)dev->depth.proc_buf, 640*480); break; case FREENECT_DEPTH_REGISTERED: - freenect_apply_registration(dev, dev->depth.raw_buf, (uint16_t*)dev->depth.proc_buf ); + freenect_apply_registration(dev, dev->depth.raw_buf, (uint16_t*)dev->depth.proc_buf, false); break; case FREENECT_DEPTH_MM: freenect_apply_depth_to_mm(dev, dev->depth.raw_buf, (uint16_t*)dev->depth.proc_buf ); diff --git a/src/flags.c b/src/flags.c index f0cb9772..17d3663f 100644 --- a/src/flags.c +++ b/src/flags.c @@ -93,6 +93,58 @@ int freenect_set_flag(freenect_device *dev, freenect_flag flag, freenect_flag_va return write_cmos_register(dev, 0x0106, cmos_value); } +int freenect_get_exposure(freenect_device *dev, int *time_us) +{ + freenect_context *ctx = dev->parent; + + uint16_t shutter_width = read_cmos_register(dev, 0x0009); + if (shutter_width == UINT16_MAX) + { + return -1; + } + switch (dev->video_format) { + case FREENECT_VIDEO_RGB: + case FREENECT_VIDEO_BAYER: + *time_us = shutter_width * SHUTTER_WIDTH_TO_EXP_RGB; + break; + case FREENECT_VIDEO_YUV_RGB: + case FREENECT_VIDEO_YUV_RAW: + *time_us = shutter_width * SHUTTER_WIDTH_TO_EXP_YUV; + break; + case FREENECT_VIDEO_DUMMY: + case FREENECT_VIDEO_IR_8BIT: + case FREENECT_VIDEO_IR_10BIT: + case FREENECT_VIDEO_IR_10BIT_PACKED: + FN_WARNING("Could not get exposure, invalid video format"); + return -1; + } + return 0; +} + +int freenect_set_exposure(freenect_device *dev, int time_us) +{ + freenect_context *ctx = dev->parent; + + uint16_t cmos_value = 0; + switch (dev->video_format) { + case FREENECT_VIDEO_RGB: + case FREENECT_VIDEO_BAYER: + cmos_value = time_us / SHUTTER_WIDTH_TO_EXP_RGB; + break; + case FREENECT_VIDEO_YUV_RGB: + case FREENECT_VIDEO_YUV_RAW: + cmos_value = time_us / SHUTTER_WIDTH_TO_EXP_YUV; + break; + case FREENECT_VIDEO_DUMMY: + case FREENECT_VIDEO_IR_8BIT: + case FREENECT_VIDEO_IR_10BIT: + case FREENECT_VIDEO_IR_10BIT_PACKED: + FN_WARNING("Could not set exposure, invalid video format"); + return -1; + } + return write_cmos_register(dev, 0x0009, cmos_value);; +} + int freenect_get_ir_brightness(freenect_device *dev) { freenect_context *ctx = dev->parent; @@ -168,6 +220,7 @@ FN_INTERNAL int send_cmd(freenect_device *dev, uint16_t cmd, void *cmdbuf, unsig do { actual_len = fnusb_control(&dev->usb_cam, 0xc0, 0, 0, 0, ibuf, 0x200); FN_FLOOD("send_cmd: actual length = %d\n", actual_len); + usleep(1); } while ((actual_len == 0) || (actual_len == 0x200)); FN_SPEW("Control reply: %d\n", res); if (actual_len < (int)sizeof(*rhdr)) { diff --git a/src/freenect_internal.h b/src/freenect_internal.h index 1ced7b75..0173209c 100644 --- a/src/freenect_internal.h +++ b/src/freenect_internal.h @@ -148,6 +148,12 @@ static inline int32_t fn_le32s(int32_t s) #define PID_K4W_AUDIO_ALT_1 0x02c3 #define PID_K4W_AUDIO_ALT_2 0x02bb +// Conversion from shutter width to exposure in microseconds +// Measured using camtest.c with various very long exposure times +// TODO: calculate this from camera registers instead of magic numbers +#define SHUTTER_WIDTH_TO_EXP_RGB 54.21 +#define SHUTTER_WIDTH_TO_EXP_YUV 63.25 + typedef struct { int running; uint8_t flag; diff --git a/src/fwfetcher.py b/src/fwfetcher.py index 08977aad..a3ffadd2 100644 --- a/src/fwfetcher.py +++ b/src/fwfetcher.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python from __future__ import absolute_import, division, print_function @@ -519,6 +519,24 @@ def handle_live_pirs(infile, fsize): # End of code taken from extract360.py. +def urlopen_timeout_retry(request, attempts = 5): + import socket + + last_error = None + for attempt in range(attempts): + try: + return urlopen(request) + except URLError as e: + if isinstance(e.reason, socket.timeout): + print("Timeout! ", e) + else: raise + last_error = e + except socket.timeout as e: + print("Timeout! ", e) + last_error = e + if last_error: + raise last_error + def getFileOrURL(filename, url): # Check if a file named filename exists on disk. # If so, return its contents. If not, download it, save it, and return its @@ -530,16 +548,11 @@ def getFileOrURL(filename, url): return retval except IOError: pass + print("Downloading", filename, "from", url) - req = Request(url, headers={'User-Agent': 'Mozilla/5.0'}) - try: - response = urlopen(req) - except URLError as e: - if hasattr(e, 'reason'): - print("Failed to reach download server. Reason:", e.reason) - elif hasattr(e, 'code'): - print("The server couldn't fulfill the request. Error code:", - e.code) + request = Request(url, headers={'User-Agent': 'Mozilla/5.0'}) + response = urlopen_timeout_retry(request) + print("Reading response...") retval = response.read() # Save downloaded file to disk @@ -564,7 +577,7 @@ def extractPirsFromZip(systemupdate): target = sys.argv[1] if not os.path.isfile(target): fw = getFileOrURL("SystemUpdate.zip", - "http://www.xbox.com/system-update-usb") + "https://www.xbox.com/system-update-usb") pirs = extractPirsFromZip(fw) lang = ["English", "Japanese", "German", "French", "Spanish", diff --git a/src/registration.c b/src/registration.c index efd38645..cbbf557a 100644 --- a/src/registration.c +++ b/src/registration.c @@ -101,7 +101,7 @@ static inline void unpack_8_pixels(uint8_t *raw, uint16_t *frame) } // apply registration data to a single packed frame -FN_INTERNAL int freenect_apply_registration(freenect_device* dev, uint8_t* input_packed, uint16_t* output_mm) +FN_INTERNAL int freenect_apply_registration(freenect_device* dev, uint8_t* input, uint16_t* output_mm, bool unpacked) { freenect_registration* reg = &(dev->registration); // set output buffer to zero using pointer-sized memory access (~ 30-40% faster than memset) @@ -116,15 +116,22 @@ FN_INTERNAL int freenect_apply_registration(freenect_device* dev, uint8_t* input for (y = 0; y < DEPTH_Y_RES; y++) { for (x = 0; x < DEPTH_X_RES; x++) { - // get 8 pixels from the packed frame - if (source_index == 8) { - unpack_8_pixels( input_packed, unpack ); - source_index = 0; - input_packed += 11; - } + uint16_t metric_depth; - // get the value at the current depth pixel, convert to millimeters - uint16_t metric_depth = reg->raw_to_mm_shift[ unpack[source_index++] ]; + if (unpacked) { + uint32_t buf_index = y * DEPTH_X_RES + x; + metric_depth = reg->raw_to_mm_shift[((uint16_t *)input)[buf_index]]; + } else { + // get 8 pixels from the packed frame + if (source_index == 8) { + unpack_8_pixels( input, unpack ); + source_index = 0; + input += 11; + } + + // get the value at the current depth pixel, convert to millimeters + metric_depth = reg->raw_to_mm_shift[ unpack[source_index++] ]; + } // so long as the current pixel has a depth value if (metric_depth == DEPTH_NO_MM_VALUE) continue; @@ -190,6 +197,22 @@ FN_INTERNAL int freenect_apply_depth_to_mm(freenect_device* dev, uint8_t* input_ return 0; } +// Same as freenect_apply_depth_to_mm, but don't need to unpack 11 bit depth values +FN_INTERNAL int freenect_apply_depth_unpacked_to_mm(freenect_device* dev, uint16_t* input, uint16_t* output_mm) +{ + freenect_registration* reg = &(dev->registration); + uint32_t x,y; + for (y = 0; y < DEPTH_Y_RES; y++) { + for (x = 0; x < DEPTH_X_RES; x++) { + // get the value at the current depth pixel, convert to millimeters + uint32_t buf_index = y * DEPTH_X_RES + x; + uint16_t metric_depth = reg->raw_to_mm_shift[input[buf_index]]; + output_mm[buf_index] = metric_depth < DEPTH_MAX_METRIC_VALUE ? metric_depth : DEPTH_MAX_METRIC_VALUE; + } + } + return 0; +} + // create temporary x/y shift tables static void freenect_create_dxdy_tables(double* reg_x_table, double* reg_y_table, int32_t resolution_x, int32_t resolution_y, freenect_reg_info* regdata ) { diff --git a/src/registration.h b/src/registration.h index 7da245c8..a2a044e2 100644 --- a/src/registration.h +++ b/src/registration.h @@ -26,9 +26,11 @@ #pragma once +#include #include "libfreenect.h" // Internal function declarations relating to registration int freenect_init_registration(freenect_device* dev); -int freenect_apply_registration(freenect_device* dev, uint8_t* input_packed, uint16_t* output_mm); +int freenect_apply_registration(freenect_device* dev, uint8_t* input, uint16_t* output_mm, bool unpacked); int freenect_apply_depth_to_mm(freenect_device* dev, uint8_t* input_packed, uint16_t* output_mm); +int freenect_apply_depth_unpacked_to_mm(freenect_device* dev, uint16_t* input, uint16_t* output_mm); diff --git a/src/tilt.c b/src/tilt.c index 43aa537d..9003921e 100644 --- a/src/tilt.c +++ b/src/tilt.c @@ -64,7 +64,7 @@ int get_reply(libusb_device_handle* dev, freenect_context *ctx){ int res = 0; res = libusb_bulk_transfer(dev, 0x81, buffer, 512, &transferred, 100); if (res != 0) { - FN_ERROR("get_reply(): libusb_bulk_transfer failed: %d (transferred = %d)\n", res, transferred); + FN_ERROR("get_reply(): libusb_bulk_transfer failed: %s (transferred = %d)\n", libusb_error_name(res), transferred); } else if (transferred != 12) { FN_ERROR("get_reply(): weird - got %d bytes (expected 12)\n", transferred); } else { @@ -214,7 +214,7 @@ int freenect_set_tilt_degs_alt(freenect_device *dev, int tilt_degrees) res = libusb_bulk_transfer(dev->usb_audio.dev, 0x01, buffer, 20, &transferred, 250); if (res != 0) { - FN_ERROR("freenect_set_tilt_alt(): libusb_bulk_transfer failed: %d (transferred = %d)\n", res, transferred); + FN_ERROR("freenect_set_tilt_alt(): libusb_bulk_transfer failed: %s (transferred = %d)\n", libusb_error_name(res), transferred); return res; } @@ -281,7 +281,7 @@ FN_INTERNAL int fnusb_set_led_alt(libusb_device_handle * dev, freenect_context * 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); + FN_WARNING("fnusb_set_led_alt(): libusb_bulk_transfer failed: %s (transferred = %d)\n", libusb_error_name(res), transferred); return res; } return get_reply(dev, ctx); diff --git a/src/usb_libusb10.c b/src/usb_libusb10.c index 55c21097..5ae4429c 100644 --- a/src/usb_libusb10.c +++ b/src/usb_libusb10.c @@ -63,7 +63,7 @@ FN_INTERNAL int fnusb_num_devices(freenect_context *ctx) } else if (desc.idProduct == PID_KV2_CAMERA) { - FN_NOTICE("Skipping Kinect v2 device (needs https://github.com/libfreenect2).\n"); + FN_NOTICE("Skipping Kinect v2 device (needs https://github.com/OpenKinect/libfreenect2).\n"); } } } @@ -72,48 +72,80 @@ FN_INTERNAL int fnusb_num_devices(freenect_context *ctx) return number_found; } -// Returns 1 if `pid` identifies K4W audio, 0 otherwise -FN_INTERNAL int fnusb_is_pid_k4w_audio(int pid) +FN_INTERNAL short fnusb_is_camera(struct libusb_device_descriptor desc) { - return (pid == PID_K4W_AUDIO || pid == PID_K4W_AUDIO_ALT_1 || pid == PID_K4W_AUDIO_ALT_2); + return desc.idVendor == VID_MICROSOFT + && (desc.idProduct == PID_NUI_CAMERA || desc.idProduct == PID_K4W_CAMERA); } -FN_INTERNAL libusb_device * fnusb_find_connected_audio_device(libusb_device * camera, libusb_device ** deviceList, int cnt) +FN_INTERNAL short fnusb_is_motor(struct libusb_device_descriptor desc) { - if (cnt <= 0) return NULL; + return desc.idVendor == VID_MICROSOFT + && desc.idProduct == PID_NUI_MOTOR; +} + +FN_INTERNAL short fnusb_is_audio(struct libusb_device_descriptor desc) +{ + return desc.idVendor == VID_MICROSOFT + && (desc.idProduct == PID_NUI_AUDIO + || desc.idProduct == PID_K4W_AUDIO || desc.idProduct == PID_K4W_AUDIO_ALT_1 || desc.idProduct == PID_K4W_AUDIO_ALT_2); +} - int cameraBusNo = libusb_get_bus_number(camera); +FN_INTERNAL libusb_device * fnusb_find_sibling_device(freenect_context* ctx, libusb_device* camera, + libusb_device** deviceList, int count, + short (*predicate)(struct libusb_device_descriptor)) +{ + if (count <= 0) return NULL; + + const int cameraBusNo = libusb_get_bus_number(camera); if (cameraBusNo < 0) return NULL; - libusb_device * cameraParent = libusb_get_parent(camera); + const libusb_device * cameraParent = libusb_get_parent(camera); + + int siblingCount_Total = 0; + int siblingCount_SameBus = 0; + libusb_device* siblingMatch_Single = NULL; + libusb_device* siblingMatch_SameBus = NULL; int i = 0; - for (i = 0; i < cnt; i++) + for (i = 0; i < count; i++) { + libusb_device* currentDevice = deviceList[i]; + struct libusb_device_descriptor desc; - int res = libusb_get_device_descriptor (deviceList[i], &desc); - if (res < 0) - { + int res = libusb_get_device_descriptor(currentDevice, &desc); + if (res < 0) { continue; } - if (desc.idVendor == VID_MICROSOFT) - { - // make sure its some type of Kinect audio device - if ((desc.idProduct == PID_NUI_AUDIO || fnusb_is_pid_k4w_audio(desc.idProduct))) - { - int audioBusNo = libusb_get_bus_number(deviceList[i]); - if (audioBusNo == cameraBusNo) - { - // we have a match! - // let's double check - libusb_device * audioParent = libusb_get_parent(deviceList[i]); - if (cameraParent == audioParent) - { - return deviceList[i]; - } - } - } + if (!(*predicate)(desc)) { + continue; + } + + siblingCount_Total++; + siblingMatch_Single = (siblingCount_Total == 1) ? currentDevice : NULL; + + if (cameraBusNo != libusb_get_bus_number(currentDevice)){ + continue; + } + + siblingCount_SameBus++; + siblingMatch_SameBus = (siblingCount_SameBus == 1) ? currentDevice : NULL; + + if (cameraParent == NULL || cameraParent != libusb_get_parent(currentDevice)) { + continue; } + + FN_DEBUG("Found sibling device [same parent]\n"); + return currentDevice; + } + + if (siblingMatch_SameBus != NULL) { + FN_DEBUG("Found sibling device [single on same bus]\n"); + return siblingMatch_SameBus; + } + if (siblingMatch_Single != NULL) { + FN_DEBUG("Found sibling device [single on system]\n"); + return siblingMatch_Single; } return NULL; @@ -175,15 +207,14 @@ FN_INTERNAL int fnusb_list_device_attributes(freenect_context *ctx, struct freen const char* const K4W_1473_SERIAL = "0000000000000000"; if (strncmp((const char*)serial, K4W_1473_SERIAL, 16) == 0) { - libusb_device* audio_device = fnusb_find_connected_audio_device(camera_device, devs, count); - + libusb_device* audio_device = fnusb_find_sibling_device(ctx, camera_device, devs, count, &fnusb_is_audio); if (audio_device != NULL) { struct libusb_device_descriptor audio_desc; res = libusb_get_device_descriptor(audio_device, &audio_desc); if (res != 0) { - FN_WARNING("Failed to get audio serial descriptors of K4W or 1473 device: %d\n", res); + FN_WARNING("Failed to get audio serial descriptors of K4W or 1473 device: %s\n", libusb_error_name(res)); } else { @@ -191,15 +222,15 @@ FN_INTERNAL int fnusb_list_device_attributes(freenect_context *ctx, struct freen res = libusb_open(audio_device, &audio_handle); if (res != 0) { - FN_WARNING("Failed to open audio device for serial of K4W or 1473 device: %d\n", res); + FN_WARNING("Failed to open audio device for serial of K4W or 1473 device: %s\n", libusb_error_name(res)); } else { res = libusb_get_string_descriptor_ascii(audio_handle, audio_desc.iSerialNumber, serial, 256); libusb_close(audio_handle); - if (res != 0) + if (res <= 0) { - FN_WARNING("Failed to get audio serial of K4W or 1473 device: %d\n", res); + FN_WARNING("Failed to get audio serial of K4W or 1473 device: %s\n", libusb_error_name(res)); } } } @@ -308,6 +339,44 @@ FN_INTERNAL int fnusb_claim_camera(freenect_device* dev) return ret; } +FN_INTERNAL int fnusb_keep_alive_led(freenect_context* ctx, libusb_device* audio) +{ + if (audio == NULL) return -1; + + int res = 0; + libusb_device_handle * audioHandle = NULL; + + res = libusb_open(audio, &audioHandle); + if (res < 0) { + FN_ERROR("Failed to set the LED of K4W or 1473 device: %s\n", libusb_error_name(res)); + return res; + } + + // we need to do this as it is possible that the device was not closed properly in a previous session + // if we don't do this and the device wasn't closed properly - it can cause infinite hangs on LED and TILT functions + libusb_reset_device(audioHandle); + libusb_close(audioHandle); + + res = libusb_open(audio, &audioHandle); + if (res < 0) { + FN_ERROR("Failed to set the LED of K4W or 1473 device: %s\n", libusb_error_name(res)); + return res; + } + + res = libusb_claim_interface(audioHandle, 0); + if (res < 0) + { + FN_ERROR("Unable to claim interface %s\n", libusb_error_name(res)); + } + else + { + fnusb_set_led_alt(audioHandle, ctx, LED_GREEN); + libusb_release_interface(audioHandle, 0); + } + + libusb_close(audioHandle); + return res; +} FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index) { @@ -324,402 +393,311 @@ FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index) dev->usb_audio.dev = NULL; libusb_device **devs; // pointer to pointer of device, used to retrieve a list of devices - ssize_t cnt = libusb_get_device_list (dev->parent->usb.ctx, &devs); //get the list of devices - if (cnt < 0) + ssize_t count = libusb_get_device_list (dev->parent->usb.ctx, &devs); //get the list of devices + if (count < 0) return -1; - int i = 0, nr_cam = 0; - - int res; - struct libusb_device_descriptor desc; + libusb_device* camera = NULL; - for (i = 0; i < cnt; i++) + int res = 0; + int i = 0, nr_cam = 0; + for (i = 0; i < count; i++) { - int r = libusb_get_device_descriptor (devs[i], &desc); - if (r < 0) + struct libusb_device_descriptor desc; + res = libusb_get_device_descriptor (devs[i], &desc); + if (res < 0) + continue; + + if (!fnusb_is_camera(desc)) { continue; + } - if (desc.idVendor != VID_MICROSOFT) + if (nr_cam != index) { + nr_cam++; continue; - res = 0; - // Search for the camera - if ((ctx->enabled_subdevices & FREENECT_DEVICE_CAMERA) && !dev->usb_cam.dev && (desc.idProduct == PID_NUI_CAMERA || desc.idProduct == PID_K4W_CAMERA)) + } + + camera = devs[i]; // found the requested camera + if (ctx->enabled_subdevices & FREENECT_DEVICE_CAMERA) { - // If the index given by the user matches our camera index - if (nr_cam == index) + res = libusb_open(camera, &dev->usb_cam.dev); + if (res < 0 || !dev->usb_cam.dev) { - dev->usb_cam.VID = desc.idVendor; - dev->usb_cam.PID = desc.idProduct; + FN_ERROR("Could not open camera: %s\n", libusb_error_name(res)); + dev->usb_cam.dev = NULL; + goto failure; + } - res = libusb_open (devs[i], &dev->usb_cam.dev); - if (res < 0 || !dev->usb_cam.dev) - { - FN_ERROR("Could not open camera: %d\n", res); - dev->usb_cam.dev = NULL; - break; - } + if (desc.idProduct == PID_K4W_CAMERA || desc.bcdDevice != fn_le32(267)) + { + freenect_device_flags requested_devices = ctx->enabled_subdevices; - if (desc.idProduct == PID_K4W_CAMERA || desc.bcdDevice != fn_le32(267)) - { - freenect_device_flags requested_devices = ctx->enabled_subdevices; - - // Not the 1414 kinect so remove the motor flag, this should preserve the audio flag if set - ctx->enabled_subdevices = (freenect_device_flags)(ctx->enabled_subdevices & ~FREENECT_DEVICE_MOTOR); - - ctx->zero_plane_res = 334; - dev->device_does_motor_control_with_audio = 1; - - // set the LED for non 1414 devices to keep the camera alive for some systems which get freezes - - libusb_device * audioDevice = fnusb_find_connected_audio_device(devs[i], devs, cnt); - if (audioDevice != NULL) - { - libusb_device_handle * audioHandle = NULL; - res = libusb_open(audioDevice, &audioHandle); + // Not the 1414 kinect so remove the motor flag, this should preserve the audio flag if set + ctx->enabled_subdevices = (freenect_device_flags)(ctx->enabled_subdevices & ~FREENECT_DEVICE_MOTOR); - if (res != 0) - { - FN_ERROR("Failed to set the LED of K4W or 1473 device: %d\n", res); - } - else - { - // we need to do this as it is possible that the device was not closed properly in a previous session - // if we don't do this and the device wasn't closed properly - it can cause infinite hangs on LED and TILT functions - libusb_reset_device(audioHandle); - libusb_close(audioHandle); + ctx->zero_plane_res = 334; + dev->device_does_motor_control_with_audio = 1; - res = libusb_open(audioDevice, &audioHandle); - if (res == 0) - { - res = libusb_claim_interface(audioHandle, 0); - if (res != 0) - { - FN_ERROR("Unable to claim interface %d\n", res); - } - else - { - fnusb_set_led_alt(audioHandle, ctx, LED_GREEN); - libusb_release_interface(audioHandle, 0); - } - libusb_close(audioHandle); - } - } - } - // for newer devices we need to enable the audio device for motor control - // we only do this though if motor has been requested. - if ((requested_devices & FREENECT_DEVICE_MOTOR) && (requested_devices & FREENECT_DEVICE_AUDIO) == 0) - { - ctx->enabled_subdevices = (freenect_device_flags)(ctx->enabled_subdevices | FREENECT_DEVICE_AUDIO); - } - } - else - { - // The good old kinect that tilts and tweets - ctx->zero_plane_res = 322; - } + // set the LED for non 1414 devices to keep the camera alive for some systems which get freezes + libusb_device * audio = fnusb_find_sibling_device(ctx, camera, devs, count, &fnusb_is_audio); + fnusb_keep_alive_led(ctx, audio); - res = fnusb_claim_camera(dev); - if (res < 0) + // for newer devices we need to enable the audio device for motor control + // we only do this though if motor has been requested. + if ((requested_devices & FREENECT_DEVICE_MOTOR) && (requested_devices & FREENECT_DEVICE_AUDIO) == 0) { - break; + ctx->enabled_subdevices = (freenect_device_flags)(ctx->enabled_subdevices | FREENECT_DEVICE_AUDIO); } } else { - nr_cam++; + // The good old kinect that tilts and tweets + ctx->zero_plane_res = 322; + } + + dev->usb_cam.VID = desc.idVendor; + dev->usb_cam.PID = desc.idProduct; + + res = fnusb_claim_camera(dev); + if (res < 0) { + goto failure; } } + + break; } - if (ctx->enabled_subdevices == FREENECT_DEVICE_CAMERA || res < 0) - cnt = 0; - - //FIND MOTOR BASED ON PARENT HUB - if( (ctx->enabled_subdevices & FREENECT_DEVICE_MOTOR) && dev->usb_cam.dev != NULL ) - { - - libusb_device * camera = libusb_get_device( dev->usb_cam.dev ); - libusb_device * cameraParent = libusb_get_parent( camera ); - - if( cameraParent != NULL ) - { - - for(i = 0; i < cnt; i++) - { - - // Match audio based on camera parent - if( cameraParent == libusb_get_parent(devs[i]) ) - { - - int r = libusb_get_device_descriptor (devs[i], &desc); - if (r < 0) - continue; + if (res < 0 || camera == NULL) { + res = -1; + goto failure; + } - if (desc.idVendor != VID_MICROSOFT) - continue; - - // This has to be the device we are looking for as it is a Kinect motor device with the same parent as the camera - if ( !dev->usb_motor.dev && desc.idProduct == PID_NUI_MOTOR) - { - dev->usb_motor.VID = desc.idVendor; - dev->usb_motor.PID = desc.idProduct; + // FIND MOTOR + if (ctx->enabled_subdevices & FREENECT_DEVICE_MOTOR) + { + libusb_device* motor = fnusb_find_sibling_device(ctx, camera, devs, count, &fnusb_is_motor); + if (motor == NULL) { + FN_ERROR("Could not find device sibling\n"); + res = -1; + goto failure; + } - res = libusb_open (devs[i], &dev->usb_motor.dev); - if (res < 0 || !dev->usb_motor.dev) - { - FN_ERROR("Could not open motor: %d\n", res); - dev->usb_motor.dev = NULL; - break; - } - res = libusb_claim_interface (dev->usb_motor.dev, 0); - if (res < 0) - { - FN_ERROR("Could not claim interface on motor: %d\n", res); - libusb_close(dev->usb_motor.dev); - dev->usb_motor.dev = NULL; - break; - } - - // This has to be the device we need, as it is matched by parent - so don't try any others - break; - } - } - } - } - } - - // FIND AUDIO BASED ON PARENT HUB - if( (ctx->enabled_subdevices & FREENECT_DEVICE_AUDIO) && dev->usb_cam.dev != NULL ) - { + struct libusb_device_descriptor desc; + res = libusb_get_device_descriptor(motor, &desc); + if (res < 0) { + FN_ERROR("Could not query device: %s\n", libusb_error_name(res)); + goto failure; + } + + res = libusb_open(motor, &dev->usb_motor.dev); + if (res < 0 || !dev->usb_motor.dev) + { + FN_ERROR("Could not open device: %s\n", libusb_error_name(res)); + dev->usb_motor.dev = NULL; + goto failure; + } + + res = libusb_claim_interface(dev->usb_motor.dev, 0); + if (res < 0) { + FN_ERROR("Could not claim interface: %s\n", libusb_error_name(res)); + libusb_close(dev->usb_motor.dev); + dev->usb_motor.dev = NULL; + goto failure; + } + + dev->usb_motor.VID = desc.idVendor; + dev->usb_motor.PID = desc.idProduct; + } - libusb_device * camera = libusb_get_device( dev->usb_cam.dev ); - libusb_device * cameraParent = libusb_get_parent( camera ); - - if( cameraParent != NULL ) - { - - for(i = 0; i < cnt; i++) - { - // Match audio based on camera parent - if( cameraParent == libusb_get_parent(devs[i]) ) - { - int r = libusb_get_device_descriptor (devs[i], &desc); - if (r < 0) - continue; - - if (desc.idVendor != VID_MICROSOFT) - continue; - - // This has to be the device we are looking for as it is a Kinect audio device with the same parent as the camera - if ( !dev->usb_audio.dev && (desc.idProduct == PID_NUI_AUDIO || fnusb_is_pid_k4w_audio(desc.idProduct))) + // FIND AUDIO + if (ctx->enabled_subdevices & FREENECT_DEVICE_AUDIO) + { + libusb_device* audio = fnusb_find_sibling_device(ctx, camera, devs, count, &fnusb_is_audio); + if (audio == NULL) { + FN_ERROR("Could not find device sibling\n"); + res = -1; + goto failure; + } + + struct libusb_device_descriptor desc; + res = libusb_get_device_descriptor(audio, &desc); + if (res < 0) { + FN_ERROR("Could not query device: %s\n", libusb_error_name(res)); + goto failure; + } + + res = libusb_open(audio, &dev->usb_audio.dev); + if (res < 0 || !dev->usb_audio.dev) + { + FN_ERROR("Could not open device: %s\n", libusb_error_name(res)); + dev->usb_audio.dev = NULL; + goto failure; + } + + res = libusb_claim_interface(dev->usb_audio.dev, 0); + if (res < 0) { + FN_ERROR("Could not claim interface: %s\n", libusb_error_name(res)); + libusb_close(dev->usb_audio.dev); + dev->usb_audio.dev = NULL; + goto failure; + } + + dev->usb_audio.VID = desc.idVendor; + dev->usb_audio.PID = desc.idProduct; + + // Using the device handle that we've claimed, see if this + // device has already uploaded firmware (has 2 interfaces). + // If not, save the serial number (by reading the appropriate + // descriptor), upload the firmware, and then enter a loop + // waiting for a device with the same serial number to + // reappear. + int num_interfaces = fnusb_num_interfaces(&dev->usb_audio); + if (num_interfaces >= 2) + { + if (dev->device_does_motor_control_with_audio) { - dev->usb_audio.VID = desc.idVendor; - dev->usb_audio.PID = desc.idProduct; + dev->motor_control_with_audio_enabled = 1; + } + } + else + { + // Read the serial number from the string descriptor and save it. + unsigned char string_desc[256]; // String descriptors are at most 256 bytes + res = libusb_get_string_descriptor_ascii(dev->usb_audio.dev, desc.iSerialNumber, string_desc, 256); + if (res < 0) { + FN_ERROR("Failed to retrieve serial number for audio device in bootloader state\n"); + goto failure; + } - res = libusb_open (devs[i], &dev->usb_audio.dev); - if (res < 0 || !dev->usb_audio.dev) - { - FN_ERROR("Could not open audio: %d\n", res); - dev->usb_audio.dev = NULL; - break; - } + char* audio_serial = strdup((char*)string_desc); - res = libusb_claim_interface (dev->usb_audio.dev, 0); - if (res < 0) - { - FN_ERROR("Could not claim interface on audio: %d\n", res); - libusb_close(dev->usb_audio.dev); - dev->usb_audio.dev = NULL; - break; - } + FN_SPEW("Uploading firmware to audio device in bootloader state.\n"); - // Using the device handle that we've claimed, see if this - // device has already uploaded firmware (has 2 interfaces). - // If not, save the serial number (by reading the appropriate - // descriptor), upload the firmware, and then enter a loop - // waiting for a device with the same serial number to - // reappear. - int num_interfaces = fnusb_num_interfaces(&dev->usb_audio); - - if (num_interfaces >= 2) - { - if (dev->device_does_motor_control_with_audio) - { - dev->motor_control_with_audio_enabled = 1; - } - } - else - { - // Read the serial number from the string descriptor and save it. - unsigned char string_desc[256]; // String descriptors are at most 256 bytes - res = libusb_get_string_descriptor_ascii(dev->usb_audio.dev, desc.iSerialNumber, string_desc, 256); - if (res < 0) - { - FN_ERROR("Failed to retrieve serial number for audio device in bootloader state\n"); - break; - } - char* audio_serial = strdup((char*)string_desc); - - FN_SPEW("Uploading firmware to audio device in bootloader state.\n"); - - // Check if we can load from memory - otherwise load from disk - if (desc.idProduct == PID_NUI_AUDIO && ctx->fn_fw_nui_ptr && ctx->fn_fw_nui_size > 0) - { - FN_SPEW("loading firmware from memory\n"); - res = upload_firmware_from_memory(&dev->usb_audio, ctx->fn_fw_nui_ptr, ctx->fn_fw_nui_size); - } - else if (desc.idProduct == PID_K4W_AUDIO && ctx->fn_fw_k4w_ptr && ctx->fn_fw_k4w_size > 0) - { - FN_SPEW("loading firmware from memory\n"); - res = upload_firmware_from_memory(&dev->usb_audio, ctx->fn_fw_k4w_ptr, ctx->fn_fw_k4w_size); - } - else - { - res = upload_firmware(&dev->usb_audio, "audios.bin"); - } + if (desc.idProduct == PID_NUI_AUDIO && ctx->fn_fw_nui_ptr && ctx->fn_fw_nui_size > 0) + { + FN_SPEW("loading firmware from memory\n"); + res = upload_firmware_from_memory(&dev->usb_audio, ctx->fn_fw_nui_ptr, ctx->fn_fw_nui_size); + } + else if (desc.idProduct == PID_K4W_AUDIO && ctx->fn_fw_k4w_ptr && ctx->fn_fw_k4w_size > 0) + { + FN_SPEW("loading firmware from memory\n"); + res = upload_firmware_from_memory(&dev->usb_audio, ctx->fn_fw_k4w_ptr, ctx->fn_fw_k4w_size); + } + else + { + res = upload_firmware(&dev->usb_audio, "audios.bin"); + } - if (res < 0) - { - FN_ERROR("upload_firmware failed: %d\n", res); - break; - } - libusb_close(dev->usb_audio.dev); - dev->usb_audio.dev = NULL; - // Wait for the device to reappear. - int loops = 0; - for (loops = 0; loops < 10; loops++) + if (res < 0) { + FN_ERROR("upload_firmware failed: %d\n", res); + free(audio_serial); + goto failure; + } + + libusb_close(dev->usb_audio.dev); + dev->usb_audio.dev = NULL; + + // Wait for the device to reappear. + int loops = 0; + for (loops = 0; loops < 10; loops++) + { + FN_SPEW("Try %d: Looking for new audio device matching serial %s\n", loops, audio_serial); + libusb_device **new_dev_list; + int dev_index; + ssize_t num_new_devs = libusb_get_device_list(ctx->usb.ctx, &new_dev_list); + + for (dev_index = 0; dev_index < num_new_devs; ++dev_index) + { + struct libusb_device_descriptor new_dev_desc; + int r; + r = libusb_get_device_descriptor (new_dev_list[dev_index], &new_dev_desc); + if (r < 0) + continue; + // If this dev is a Kinect audio device, open device, read serial, and compare. + if (fnusb_is_audio(new_dev_desc)) { - FN_SPEW("Try %d: Looking for new audio device matching serial %s\n", loops, audio_serial); - // Scan devices. - libusb_device **new_dev_list; - int dev_index; - ssize_t num_new_devs = libusb_get_device_list(ctx->usb.ctx, &new_dev_list); - for (dev_index = 0; dev_index < num_new_devs; ++dev_index) + FN_SPEW("Matched VID/PID!\n"); + libusb_device_handle* new_dev_handle; + // Open device + r = libusb_open(new_dev_list[dev_index], &new_dev_handle); + if (r < 0) + continue; + // Read serial + r = libusb_get_string_descriptor_ascii(new_dev_handle, new_dev_desc.iSerialNumber, string_desc, 256); + if (r < 0) + { + FN_SPEW("Lost new audio device while fetching serial number.\n"); + libusb_close(new_dev_handle); + continue; + } + // Compare to expected serial + if (r == strlen(audio_serial) && strcmp((char*)string_desc, audio_serial) == 0) { - struct libusb_device_descriptor new_dev_desc; - int r; - r = libusb_get_device_descriptor (new_dev_list[dev_index], &new_dev_desc); - if (r < 0) + // We found it! + r = libusb_claim_interface(new_dev_handle, 0); + if (r != 0) + { + // Ouch, found the device but couldn't claim the interface. + FN_SPEW("Device with serial %s reappeared but couldn't claim interface 0\n", audio_serial); + libusb_close(new_dev_handle); continue; - // If this dev is a Kinect audio device, open device, read serial, and compare. - if (new_dev_desc.idVendor == VID_MICROSOFT && (new_dev_desc.idProduct == PID_NUI_AUDIO || fnusb_is_pid_k4w_audio(desc.idProduct))) + } + // Save the device handle. + dev->usb_audio.dev = new_dev_handle; + + // Verify that we've actually found a device running the right firmware. + num_interfaces = fnusb_num_interfaces(&dev->usb_audio); + + if (num_interfaces >= 2) { - FN_SPEW("Matched VID/PID!\n"); - libusb_device_handle* new_dev_handle; - // Open device - r = libusb_open(new_dev_list[dev_index], &new_dev_handle); - if (r < 0) - continue; - // Read serial - r = libusb_get_string_descriptor_ascii(new_dev_handle, new_dev_desc.iSerialNumber, string_desc, 256); - if (r < 0) + if (dev->device_does_motor_control_with_audio) { - FN_SPEW("Lost new audio device while fetching serial number.\n"); - libusb_close(new_dev_handle); - continue; - } - // Compare to expected serial - if (r == strlen(audio_serial) && strcmp((char*)string_desc, audio_serial) == 0) - { - // We found it! - r = libusb_claim_interface(new_dev_handle, 0); - if (r != 0) - { - // Ouch, found the device but couldn't claim the interface. - FN_SPEW("Device with serial %s reappeared but couldn't claim interface 0\n", audio_serial); - libusb_close(new_dev_handle); - continue; - } - // Save the device handle. - dev->usb_audio.dev = new_dev_handle; - - // Verify that we've actually found a device running the right firmware. - num_interfaces = fnusb_num_interfaces(&dev->usb_audio); - - if (num_interfaces >= 2) - { - if (dev->device_does_motor_control_with_audio) - { - dev->motor_control_with_audio_enabled = 1; - } - } - else - { - FN_SPEW("Opened audio with matching serial but too few interfaces.\n"); - dev->usb_audio.dev = NULL; - libusb_close(new_dev_handle); - continue; - } - - break; - } - else - { - FN_SPEW("Got serial %s, expected serial %s\n", (char*)string_desc, audio_serial); + dev->motor_control_with_audio_enabled = 1; } } - } + else + { + FN_SPEW("Opened audio with matching serial but too few interfaces.\n"); + dev->usb_audio.dev = NULL; + libusb_close(new_dev_handle); + continue; + } - libusb_free_device_list(new_dev_list, 1); - // If we found the right device, break out of this loop. - if (dev->usb_audio.dev) break; - // Sleep for a second to give the device more time to reenumerate. - sleep(1); + } + else + { + FN_SPEW("Got serial %s, expected serial %s\n", (char*)string_desc, audio_serial); + } } - free(audio_serial); } - - // This has to be the device we need, as it is matched by parent - so don't try any others - break; - } - } + + libusb_free_device_list(new_dev_list, 1); + // If we found the right device, break out of this loop. + if (dev->usb_audio.dev) + break; + // Sleep for a second to give the device more time to reenumerate. + sleep(1); } + + free(audio_serial); } } - libusb_free_device_list (devs, 1); // free the list, unref the devices in it - if ((dev->usb_cam.dev || !(ctx->enabled_subdevices & FREENECT_DEVICE_CAMERA)) - && (dev->usb_motor.dev || !(ctx->enabled_subdevices & FREENECT_DEVICE_MOTOR))) - //&& (dev->usb_audio.dev || !(ctx->enabled_subdevices & FREENECT_DEVICE_AUDIO))) + && (dev->usb_motor.dev || !(ctx->enabled_subdevices & FREENECT_DEVICE_MOTOR)) + && (dev->usb_audio.dev || !(ctx->enabled_subdevices & FREENECT_DEVICE_AUDIO))) { // Each requested subdevice is open. - // Except audio, which may fail if firmware is missing (or because it hates us). - return 0; - } - - if (dev->usb_cam.dev != NULL) - { - libusb_release_interface(dev->usb_cam.dev, 0); - libusb_close(dev->usb_cam.dev); - } - else - { - FN_ERROR("Failed to open camera subdevice or it is not disabled."); + goto finally; } - if (dev->usb_motor.dev != NULL) - { - libusb_release_interface(dev->usb_motor.dev, 0); - libusb_close(dev->usb_motor.dev); - } - else - { - FN_ERROR("Failed to open motor subddevice or it is not disabled."); - } - - if (dev->usb_audio.dev != NULL) - { - libusb_release_interface(dev->usb_audio.dev, 0); - libusb_close(dev->usb_audio.dev); - } - else - { - FN_ERROR("Failed to open audio subdevice or it is not disabled."); - } +failure: + fnusb_close_subdevices(dev); - return -1; +finally: + libusb_free_device_list(devs, 1); // free the list, unref the devices in it + return res; } FN_INTERNAL int fnusb_close_subdevices(freenect_device *dev) @@ -768,7 +746,7 @@ static void LIBUSB_CALL iso_callback(struct libusb_transfer *xfer) int res; res = libusb_submit_transfer(xfer); if (res != 0) { - FN_ERROR("iso_callback(): failed to resubmit transfer after successful completion: %d\n", res); + FN_ERROR("iso_callback(): failed to resubmit transfer after successful completion: %s\n", libusb_error_name(res)); strm->dead_xfers++; if (res == LIBUSB_ERROR_NO_DEVICE) { strm->parent->device_dead = 1; @@ -816,7 +794,7 @@ static void LIBUSB_CALL iso_callback(struct libusb_transfer *xfer) int res; res = libusb_submit_transfer(xfer); if (res != 0) { - FN_ERROR("Isochronous transfer resubmission failed after unknown error: %d\n", res); + FN_ERROR("Isochronous transfer resubmission failed after unknown error: %s\n", libusb_error_name(res)); strm->dead_xfers++; if (res == LIBUSB_ERROR_NO_DEVICE) { strm->parent->device_dead = 1; @@ -875,7 +853,7 @@ FN_INTERNAL int fnusb_start_iso(fnusb_dev *dev, fnusb_isoc_stream *strm, fnusb_i int ret = libusb_submit_transfer(strm->xfers[i]); if (ret < 0) { - FN_WARNING("Failed to submit isochronous transfer %d: %d\n", i, ret); + FN_WARNING("Failed to submit isochronous transfer %d: %s\n", i, libusb_error_name(ret)); strm->dead_xfers++; } } diff --git a/wrappers/c_sync/libfreenect_sync.c b/wrappers/c_sync/libfreenect_sync.c index 1b2e0494..84acdc2f 100644 --- a/wrappers/c_sync/libfreenect_sync.c +++ b/wrappers/c_sync/libfreenect_sync.c @@ -24,6 +24,9 @@ * either License. */ #include +#ifdef _MSC_VER +#define HAVE_STRUCT_TIMESPEC +#endif #include #include #include @@ -211,15 +214,18 @@ static void *init(void *unused) return NULL; } -static void init_thread(void) +static int init_thread(void) { thread_running = 1; - freenect_init(&ctx, 0); + int ret = freenect_init(&ctx, 0); + if (ret != 0) return ret; // We claim both the motor and the camera, because we can't know in advance // which devices the caller will want, and the c_sync interface doesn't // support audio, so there's no reason to claim the device needlessly. freenect_select_subdevices(ctx, (freenect_device_flags)(FREENECT_DEVICE_MOTOR | FREENECT_DEVICE_CAMERA)); - pthread_create(&thread, NULL, init, NULL); + ret = pthread_create(&thread, NULL, init, NULL); + if (ret != 0) return ret; + return 0; } static int change_video_format(sync_kinect_t *kinect, freenect_resolution res, freenect_video_format fmt) @@ -249,7 +255,7 @@ static int change_depth_format(sync_kinect_t *kinect, freenect_resolution res, f static sync_kinect_t *alloc_kinect(int index) { sync_kinect_t *kinect = (sync_kinect_t*)malloc(sizeof(sync_kinect_t)); - if (freenect_open_device(ctx, &kinect->dev, index)) { + if (freenect_open_device(ctx, &kinect->dev, index) < 0) { free(kinect); return NULL; } @@ -276,8 +282,14 @@ static int setup_kinect(int index, int res, int fmt, int is_depth) pending_runloop_tasks_inc(); pthread_mutex_lock(&runloop_lock); int thread_running_prev = thread_running; - if (!thread_running) - init_thread(); + if (!thread_running) { + int ret = init_thread(); + if (ret != 0) { + pthread_mutex_unlock(&runloop_lock); + pending_runloop_tasks_dec(); + return ret; + } + } if (!kinects[index]) { kinects[index] = alloc_kinect(index); } @@ -331,15 +343,15 @@ static int sync_get(void **data, uint32_t *timestamp, buffer_ring_t *buf) } -/* +/* Use this to make sure the runloop is locked and no one is in it. Then you can call arbitrary functions from libfreenect.h in a safe way. If the kinect with - this index has not been initialized yet, then it will try to set it up. If + this index has not been initialized yet, then it will try to set it up. If this function is successful, then you can access kinects[index]. Don't forget to unlock the runloop when you're done. - + Returns 0 if successful, nonzero if kinect[index] is unvailable - */ + */ static int runloop_enter(int index) { if (index < 0 || index >= MAX_KINECTS) { @@ -349,7 +361,7 @@ static int runloop_enter(int index) if (!thread_running || !kinects[index]) if (setup_kinect(index, FREENECT_RESOLUTION_MEDIUM, FREENECT_DEPTH_11BIT, 1)) return -1; - + pending_runloop_tasks_inc(); pthread_mutex_lock(&runloop_lock); return 0; @@ -404,7 +416,7 @@ int freenect_sync_get_tilt_state(freenect_raw_tilt_state **state, int index) { if (runloop_enter(index)) return -1; freenect_update_tilt_state(kinects[index]->dev); - *state = freenect_get_tilt_state(kinects[index]->dev); + *state = freenect_get_tilt_state(kinects[index]->dev); runloop_exit(); return 0; } diff --git a/wrappers/cpp/CMakeLists.txt b/wrappers/cpp/CMakeLists.txt index 8a9b11a1..9344c6c7 100644 --- a/wrappers/cpp/CMakeLists.txt +++ b/wrappers/cpp/CMakeLists.txt @@ -1,20 +1,30 @@ +cmake_minimum_required(VERSION 3.10) + install(FILES libfreenect.hpp DESTINATION ${PROJECT_INCLUDE_INSTALL_DIR}) if (BUILD_EXAMPLES) set(THREADS_USE_PTHREADS_WIN32 true) - find_package(Threads REQUIRED) - find_package(OpenGL REQUIRED) - find_package(GLUT REQUIRED) - - include_directories(. ${THREADS_PTHREADS_INCLUDE_DIR} ${OPENGL_INCLUDE_DIR} ${GLUT_INCLUDE_DIR}) + find_package(Threads) + find_package(OpenGL COMPONENTS OpenGL) + find_package(GLUT) - add_executable(freenect-cppview cppview.cpp) - add_executable(freenect-cpp_pcview cpp_pc_view.cpp) + if (Threads_FOUND AND OpenGL_OpenGL_FOUND AND GLUT_FOUND) + include(ChooseOpenGLTarget) + include_directories(. ${THREADS_PTHREADS_INCLUDE_DIR} ${OPENGL_INCLUDE_DIR} ${GLUT_INCLUDE_DIR}) - 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}) + add_executable(freenect-cppview cppview.cpp) + target_compile_features(freenect-cppview PUBLIC cxx_std_11) + target_link_libraries(freenect-cppview freenect "${OPENGL_TARGET}" GLUT::GLUT ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB}) + install(TARGETS freenect-cppview + DESTINATION bin) - install(TARGETS freenect-cppview freenect-cpp_pcview - DESTINATION bin) -ENDIF() + if (OPENGL_GLU_FOUND) + add_executable(freenect-cpp_pcview cpp_pc_view.cpp) + target_compile_features(freenect-cpp_pcview PUBLIC cxx_std_11) + target_link_libraries(freenect-cpp_pcview freenect "${OPENGL_TARGET}" OpenGL::GLU GLUT::GLUT ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB}) + install(TARGETS freenect-cpp_pcview + DESTINATION bin) + endif() + endif() +endif() diff --git a/wrappers/cpp/cpp_pc_view.cpp b/wrappers/cpp/cpp_pc_view.cpp index 238765f1..5148ba2b 100644 --- a/wrappers/cpp/cpp_pc_view.cpp +++ b/wrappers/cpp/cpp_pc_view.cpp @@ -27,7 +27,6 @@ #include #include #include -#include #include #if defined(__APPLE__) diff --git a/wrappers/cpp/cppview.cpp b/wrappers/cpp/cppview.cpp index 557bf327..85d6760a 100644 --- a/wrappers/cpp/cppview.cpp +++ b/wrappers/cpp/cppview.cpp @@ -24,9 +24,7 @@ * either License. */ - #include "libfreenect.hpp" -#include #include #include #include @@ -36,11 +34,9 @@ #if defined(__APPLE__) #include #include -#include #else #include #include -#include #endif diff --git a/wrappers/cpp/libfreenect.hpp b/wrappers/cpp/libfreenect.hpp index 21498228..b227dc65 100644 --- a/wrappers/cpp/libfreenect.hpp +++ b/wrappers/cpp/libfreenect.hpp @@ -25,10 +25,14 @@ */ #pragma once +#include #include "libfreenect.h" #include #include #include +#ifdef _MSC_VER +#define HAVE_STRUCT_TIMESPEC +#endif #include #include @@ -41,7 +45,7 @@ namespace Freenect { Noncopyable( const Noncopyable& ); const Noncopyable& operator=( const Noncopyable& ); }; - + class FreenectTiltState { friend class FreenectDevice; FreenectTiltState(freenect_raw_tilt_state *_state): @@ -101,14 +105,19 @@ namespace Freenect { } void setVideoFormat(freenect_video_format requested_format, freenect_resolution requested_resolution = FREENECT_RESOLUTION_MEDIUM) { if (requested_format != m_video_format || requested_resolution != m_video_resolution) { - bool wasRunning = (freenect_stop_video(m_dev) >= 0); - freenect_frame_mode mode = freenect_find_video_mode(requested_resolution, requested_format); + const bool wasRunning = (freenect_stop_video(m_dev) >= 0); + const freenect_frame_mode mode = freenect_find_video_mode(requested_resolution, requested_format); if (!mode.is_valid) throw std::runtime_error("Cannot set video format: invalid mode"); if (freenect_set_video_mode(m_dev, mode) < 0) throw std::runtime_error("Cannot set video format"); - if (wasRunning) - freenect_start_video(m_dev); + m_video_format = requested_format; m_video_resolution = requested_resolution; + m_rgb_buffer.reset(new uint8_t[mode.bytes]); + freenect_set_video_buffer(m_dev, m_rgb_buffer.get()); + + if (wasRunning) { + freenect_start_video(m_dev); + } } } freenect_video_format getVideoFormat() { @@ -170,6 +179,7 @@ namespace Freenect { freenect_depth_format m_depth_format; freenect_resolution m_video_resolution; freenect_resolution m_depth_resolution; + std::unique_ptr m_rgb_buffer; static void freenect_depth_callback(freenect_device *dev, void *depth, uint32_t timestamp) { FreenectDevice* device = static_cast(freenect_get_user(dev)); device->DepthCallback(depth, timestamp); @@ -242,7 +252,7 @@ namespace Freenect { return NULL; } protected: - freenect_context *m_ctx; + freenect_context *m_ctx; private: volatile bool m_stop; pthread_t m_thread; diff --git a/wrappers/java/pom.xml b/wrappers/java/pom.xml index deaa10df..9c170132 100644 --- a/wrappers/java/pom.xml +++ b/wrappers/java/pom.xml @@ -16,7 +16,7 @@ junit junit - 4.8.2 + 4.13.1 test diff --git a/wrappers/opencv/CMakeLists.txt b/wrappers/opencv/CMakeLists.txt index 02390752..bc5df19b 100644 --- a/wrappers/opencv/CMakeLists.txt +++ b/wrappers/opencv/CMakeLists.txt @@ -2,7 +2,7 @@ # OpenCV Interface ###################################################################################### find_package(OpenCV REQUIRED) -add_library (freenect_cv SHARED libfreenect_cv.c) +add_library (freenect_cv SHARED libfreenect_cv.cpp) set_target_properties (freenect_cv PROPERTIES VERSION ${PROJECT_VER} SOVERSION ${PROJECT_APIVER}) @@ -16,7 +16,7 @@ install (TARGETS freenect_cv install (FILES "libfreenect_cv.h" DESTINATION ${PROJECT_INCLUDE_INSTALL_DIR}) -add_executable(freenect-cvdemo cvdemo.c) +add_executable(freenect-cvdemo cvdemo.cpp) target_link_libraries(freenect-cvdemo freenect freenect_sync freenect_cv ${OpenCV_LIBS}) install (TARGETS freenect-cvdemo DESTINATION bin) diff --git a/wrappers/opencv/cvdemo.c b/wrappers/opencv/cvdemo.cpp similarity index 96% rename from wrappers/opencv/cvdemo.c rename to wrappers/opencv/cvdemo.cpp index 94e8283d..742518a9 100644 --- a/wrappers/opencv/cvdemo.c +++ b/wrappers/opencv/cvdemo.cpp @@ -1,5 +1,4 @@ -#include -#include +#include #include #include "libfreenect_cv.h" diff --git a/wrappers/opencv/libfreenect_cv.c b/wrappers/opencv/libfreenect_cv.cpp similarity index 100% rename from wrappers/opencv/libfreenect_cv.c rename to wrappers/opencv/libfreenect_cv.cpp diff --git a/wrappers/opencv/libfreenect_cv.h b/wrappers/opencv/libfreenect_cv.h index b73b60c9..a1a0ebc1 100644 --- a/wrappers/opencv/libfreenect_cv.h +++ b/wrappers/opencv/libfreenect_cv.h @@ -1,11 +1,11 @@ #pragma once +#include + #ifdef __cplusplus extern "C" { #endif -#include - IplImage *freenect_sync_get_depth_cv(int index); IplImage *freenect_sync_get_rgb_cv(int index); diff --git a/wrappers/python/CMakeLists.txt b/wrappers/python/CMakeLists.txt index eb956ed0..48203a6e 100644 --- a/wrappers/python/CMakeLists.txt +++ b/wrappers/python/CMakeLists.txt @@ -2,62 +2,51 @@ # Python extension builder ###################################################################################### -macro(Python_BUILD_EXTENSION Python_BUILD_VERSION) +cmake_minimum_required(VERSION 3.12.4) -# Unfortunately, we can't use the cache because it treats 2 and 3 the same, so -# we wouldn't be able to compile against both. -foreach(_python_var - PYTHONINTERP_FOUND PYTHON_EXECUTABLE PYTHON_VERSION_STRING - PYTHON_VERSION_MAJOR PYTHON_VERSION_MINOR PYTHON_VERSION_PATCH) - unset(${_python_var}) - unset(${_python_var} CACHE) -endforeach(_python_var) -foreach(_python_var - PYTHONLIBS_FOUND PYTHONLIBS_VERSION_STRING PYTHON_DEBUG_LIBRARIES - PYTHON_INCLUDE_DIR PYTHON_INCLUDE_DIRS PYTHON_INCLUDE_PATH PYTHON_LIBRARIES - PYTHON_LIBRARY PYTHON_LIBRARY_DEBUG) - unset(${_python_var}) - unset(${_python_var} CACHE) -endforeach(_python_var) +set(Python2_EXACTVERSION CACHE STRING "exact version of python2") +set(Python3_EXACTVERSION CACHE STRING "exact version of python3") -set(Python_ADDITIONAL_VERSIONS ${Python_BUILD_VERSION}) -find_package(PythonInterp) -set(PYTHON${Python_BUILD_VERSION}INTERP_FOUND ${PYTHONINTERP_FOUND}) -set(PYTHON${Python_BUILD_VERSION}_EXECUTABLE ${PYTHON_EXECUTABLE}) -set(PYTHON${Python_BUILD_VERSION}_VERSION_STRING ${PYTHON_VERSION_STRING}) -set(PYTHON${Python_BUILD_VERSION}_VERSION_MAJOR ${PYTHON_VERSION_MAJOR}) -set(PYTHON${Python_BUILD_VERSION}_VERSION_MINOR ${PYTHON_VERSION_MINOR}) -set(PYTHON${Python_BUILD_VERSION}_VERSION_PATCH ${PYTHON_VERSION_PATCH}) -find_package(PythonLibs) -set(PYTHON${Python_BUILD_VERSION}LIBS_FOUND ${PYTHONLIBS_FOUND}) -set(PYTHON${Python_BUILD_VERSION}LIBS_VERSION_STRING ${PYTHONLIBS_VERSION_STRING}) -set(PYTHON${Python_BUILD_VERSION}_DEBUG_LIBRARIES ${PYTHON_DEBUG_LIBRARIES}) -set(PYTHON${Python_BUILD_VERSION}_INCLUDE_PATH ${PYTHON_INCLUDE_PATH}) -set(PYTHON${Python_BUILD_VERSION}_INCLUDE_DIRS ${PYTHON_INCLUDE_DIRS}) -set(PYTHON${Python_BUILD_VERSION}_LIBRARIES ${PYTHON_LIBRARIES}) -find_program(CYTHON_EXECUTABLE cython) +macro(Python_BUILD_EXTENSION Python_BUILD_VERSION) -if(NOT ${PYTHON${Python_BUILD_VERSION}_VERSION_MAJOR} EQUAL ${Python_BUILD_VERSION}) - message(FATAL_ERROR "Unable to find Python ${Python_BUILD_VERSION} interpreter.") -endif() -if(NOT ${PYTHON${Python_BUILD_VERSION}_VERSION_STRING} EQUAL ${PYTHON${Python_BUILD_VERSION}LIBS_VERSION_STRING}) - message(FATAL_ERROR - "Unable to find consistent Python ${Python_BUILD_VERSION} libraries. " - "Python interpreter is ${PYTHON${Python_BUILD_VERSION}_VERSION_STRING}, " - "but libraries are ${PYTHON${Python_BUILD_VERSION}LIBS_VERSION_STRING}.") +if(NOT ${Python${Python_BUILD_VERSION}_EXACTVERSION} STREQUAL "") + find_package(Python${Python_BUILD_VERSION} ${Python${Python_BUILD_VERSION}_EXACTVERSION} EXACT REQUIRED COMPONENTS Interpreter Development) +else() + find_package(Python${Python_BUILD_VERSION} REQUIRED COMPONENTS Interpreter Development) endif() +find_program(CYTHON_EXECUTABLE cython) + # Figure out installation path +# CMake populates this var automatically but we need to specify prefix execute_process(COMMAND - ${PYTHON${Python_BUILD_VERSION}_EXECUTABLE} - -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(prefix='${CMAKE_INSTALL_PREFIX}'))" - OUTPUT_VARIABLE PYTHON${Python_BUILD_VERSION}_SITE_PACKAGES OUTPUT_STRIP_TRAILING_WHITESPACE) + ${Python${Python_BUILD_VERSION}_EXECUTABLE} + -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(plat_specific=False, standard_lib=False, prefix='${CMAKE_INSTALL_PREFIX}'))" + OUTPUT_VARIABLE Python${Python_BUILD_VERSION}_SITELIB OUTPUT_STRIP_TRAILING_WHITESPACE) # Figure out numpy include path +# todo: CMake >= 3.14 populates this var automatically when using COMPONENTS NumPy execute_process(COMMAND - ${PYTHON${Python_BUILD_VERSION}_EXECUTABLE} + ${Python${Python_BUILD_VERSION}_EXECUTABLE} -c "import numpy; print(numpy.get_include())" - OUTPUT_VARIABLE PYTHON${Python_BUILD_VERSION}_NUMPY_INCLUDE_PATH OUTPUT_STRIP_TRAILING_WHITESPACE) + OUTPUT_VARIABLE Python${Python_BUILD_VERSION}_NumPy_INCLUDE_DIRS OUTPUT_STRIP_TRAILING_WHITESPACE) + +# cython 3.0 has breaking changes, like certain functions must be marked noexcept +# but noexcept is not defined in old cython < 0.29.31 shipped in ubuntu 20.04 +# todo: eventually drop support for cython 0.x.x +execute_process(COMMAND + ${CYTHON_EXECUTABLE} --version + ERROR_VARIABLE CYTHON_VERSION_OUTPUT ERROR_STRIP_TRAILING_WHITESPACE) +string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" CYTHON_VERSION "${CYTHON_VERSION_OUTPUT}") +string(REGEX MATCHALL "[0-9]+" CYTHON_VERSION_COMPONENTS "${CYTHON_VERSION}") +list(GET CYTHON_VERSION_COMPONENTS 0 CYTHON_VERSION_MAJOR) +list(GET CYTHON_VERSION_COMPONENTS 1 CYTHON_VERSION_MINOR) +list(GET CYTHON_VERSION_COMPONENTS 2 CYTHON_VERSION_PATCH) +if (${CYTHON_VERSION_MAJOR} LESS_EQUAL 0) + set(FREENECT_PYX "freenect.cython0.pyx") +else() + set(FREENECT_PYX "freenect.pyx") +endif() # How to Cython the .pyx file add_custom_command(OUTPUT freenect${Python_BUILD_VERSION}.c @@ -65,7 +54,7 @@ add_custom_command(OUTPUT freenect${Python_BUILD_VERSION}.c ${CYTHON_EXECUTABLE} -${Python_BUILD_VERSION} -o freenect${Python_BUILD_VERSION}.c - "${CMAKE_CURRENT_SOURCE_DIR}/freenect.pyx") + "${CMAKE_CURRENT_SOURCE_DIR}/${FREENECT_PYX}") list(APPEND ADDITIONAL_MAKE_CLEAN_FILES freenect${Python_BUILD_VERSION}.c) # Compile the extension @@ -76,15 +65,15 @@ set_target_properties(cython${Python_BUILD_VERSION}_freenect PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/python${Python_BUILD_VERSION}) target_link_libraries(cython${Python_BUILD_VERSION}_freenect freenect_sync - ${PYTHON${Python_BUILD_VERSION}_LIBRARIES}) + ${Python${Python_BUILD_VERSION}_LIBRARIES}) target_include_directories(cython${Python_BUILD_VERSION}_freenect PRIVATE - ${PYTHON${Python_BUILD_VERSION}_INCLUDE_PATH} + ${Python${Python_BUILD_VERSION}_INCLUDE_DIRS} ../c_sync/ - ${PYTHON${Python_BUILD_VERSION}_NUMPY_INCLUDE_PATH}) + ${Python${Python_BUILD_VERSION}_NumPy_INCLUDE_DIRS}) # Install the extension install(TARGETS cython${Python_BUILD_VERSION}_freenect - DESTINATION ${PYTHON${Python_BUILD_VERSION}_SITE_PACKAGES}) + DESTINATION ${Python${Python_BUILD_VERSION}_SITELIB}) # TODO: decide on what to do with demo_ scripts and were to install # them diff --git a/wrappers/python/freenect.c b/wrappers/python/freenect.c deleted file mode 100644 index f5738831..00000000 --- a/wrappers/python/freenect.c +++ /dev/null @@ -1,13040 +0,0 @@ -/* Generated by Cython 0.20.2 on Wed Jul 2 20:29:36 2014 */ - -#define PY_SSIZE_T_CLEAN -#ifndef CYTHON_USE_PYLONG_INTERNALS -#ifdef PYLONG_BITS_IN_DIGIT -#define CYTHON_USE_PYLONG_INTERNALS 0 -#else -#include "pyconfig.h" -#ifdef PYLONG_BITS_IN_DIGIT -#define CYTHON_USE_PYLONG_INTERNALS 1 -#else -#define CYTHON_USE_PYLONG_INTERNALS 0 -#endif -#endif -#endif -#include "Python.h" -#ifndef Py_PYTHON_H - #error Python headers needed to compile C extensions, please install development version of Python. -#elif PY_VERSION_HEX < 0x02040000 - #error Cython requires Python 2.4+. -#else -#define CYTHON_ABI "0_20_2" -#include /* For offsetof */ -#ifndef offsetof -#define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) -#endif -#if !defined(WIN32) && !defined(MS_WINDOWS) - #ifndef __stdcall - #define __stdcall - #endif - #ifndef __cdecl - #define __cdecl - #endif - #ifndef __fastcall - #define __fastcall - #endif -#endif -#ifndef DL_IMPORT - #define DL_IMPORT(t) t -#endif -#ifndef DL_EXPORT - #define DL_EXPORT(t) t -#endif -#ifndef PY_LONG_LONG - #define PY_LONG_LONG LONG_LONG -#endif -#ifndef Py_HUGE_VAL - #define Py_HUGE_VAL HUGE_VAL -#endif -#ifdef PYPY_VERSION -#define CYTHON_COMPILING_IN_PYPY 1 -#define CYTHON_COMPILING_IN_CPYTHON 0 -#else -#define CYTHON_COMPILING_IN_PYPY 0 -#define CYTHON_COMPILING_IN_CPYTHON 1 -#endif -#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 -#define Py_OptimizeFlag 0 -#endif -#if PY_VERSION_HEX < 0x02050000 - typedef int Py_ssize_t; - #define PY_SSIZE_T_MAX INT_MAX - #define PY_SSIZE_T_MIN INT_MIN - #define PY_FORMAT_SIZE_T "" - #define CYTHON_FORMAT_SSIZE_T "" - #define PyInt_FromSsize_t(z) PyInt_FromLong(z) - #define PyInt_AsSsize_t(o) __Pyx_PyInt_As_int(o) - #define PyNumber_Index(o) ((PyNumber_Check(o) && !PyFloat_Check(o)) ? PyNumber_Int(o) : \ - (PyErr_Format(PyExc_TypeError, \ - "expected index value, got %.200s", Py_TYPE(o)->tp_name), \ - (PyObject*)0)) - #define __Pyx_PyIndex_Check(o) (PyNumber_Check(o) && !PyFloat_Check(o) && \ - !PyComplex_Check(o)) - #define PyIndex_Check __Pyx_PyIndex_Check - #define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message) - #define __PYX_BUILD_PY_SSIZE_T "i" -#else - #define __PYX_BUILD_PY_SSIZE_T "n" - #define CYTHON_FORMAT_SSIZE_T "z" - #define __Pyx_PyIndex_Check PyIndex_Check -#endif -#if PY_VERSION_HEX < 0x02060000 - #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt) - #define Py_TYPE(ob) (((PyObject*)(ob))->ob_type) - #define Py_SIZE(ob) (((PyVarObject*)(ob))->ob_size) - #define PyVarObject_HEAD_INIT(type, size) \ - PyObject_HEAD_INIT(type) size, - #define PyType_Modified(t) - typedef struct { - void *buf; - PyObject *obj; - Py_ssize_t len; - Py_ssize_t itemsize; - int readonly; - int ndim; - char *format; - Py_ssize_t *shape; - Py_ssize_t *strides; - Py_ssize_t *suboffsets; - void *internal; - } Py_buffer; - #define PyBUF_SIMPLE 0 - #define PyBUF_WRITABLE 0x0001 - #define PyBUF_FORMAT 0x0004 - #define PyBUF_ND 0x0008 - #define PyBUF_STRIDES (0x0010 | PyBUF_ND) - #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES) - #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES) - #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES) - #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES) - #define PyBUF_RECORDS (PyBUF_STRIDES | PyBUF_FORMAT | PyBUF_WRITABLE) - #define PyBUF_FULL (PyBUF_INDIRECT | PyBUF_FORMAT | PyBUF_WRITABLE) - typedef int (*getbufferproc)(PyObject *, Py_buffer *, int); - typedef void (*releasebufferproc)(PyObject *, Py_buffer *); -#endif -#if PY_MAJOR_VERSION < 3 - #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" - #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \ - PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) - #define __Pyx_DefaultClassType PyClass_Type -#else - #define __Pyx_BUILTIN_MODULE_NAME "builtins" - #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \ - PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) - #define __Pyx_DefaultClassType PyType_Type -#endif -#if PY_VERSION_HEX < 0x02060000 - #define PyUnicode_FromString(s) PyUnicode_Decode(s, strlen(s), "UTF-8", "strict") -#endif -#if PY_MAJOR_VERSION >= 3 - #define Py_TPFLAGS_CHECKTYPES 0 - #define Py_TPFLAGS_HAVE_INDEX 0 -#endif -#if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3) - #define Py_TPFLAGS_HAVE_NEWBUFFER 0 -#endif -#if PY_VERSION_HEX < 0x02060000 - #define Py_TPFLAGS_HAVE_VERSION_TAG 0 -#endif -#if PY_VERSION_HEX < 0x02060000 && !defined(Py_TPFLAGS_IS_ABSTRACT) - #define Py_TPFLAGS_IS_ABSTRACT 0 -#endif -#if PY_VERSION_HEX < 0x030400a1 && !defined(Py_TPFLAGS_HAVE_FINALIZE) - #define Py_TPFLAGS_HAVE_FINALIZE 0 -#endif -#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) - #define CYTHON_PEP393_ENABLED 1 - #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ? \ - 0 : _PyUnicode_Ready((PyObject *)(op))) - #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) - #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) - #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u) - #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u) - #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) -#else - #define CYTHON_PEP393_ENABLED 0 - #define __Pyx_PyUnicode_READY(op) (0) - #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) - #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) - #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE)) - #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u)) - #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i])) -#endif -#if CYTHON_COMPILING_IN_PYPY - #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b) - #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b) -#else - #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b) - #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ? \ - PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b)) -#endif -#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) -#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) -#if PY_MAJOR_VERSION >= 3 - #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b) -#else - #define __Pyx_PyString_Format(a, b) PyString_Format(a, b) -#endif -#if PY_MAJOR_VERSION >= 3 - #define PyBaseString_Type PyUnicode_Type - #define PyStringObject PyUnicodeObject - #define PyString_Type PyUnicode_Type - #define PyString_Check PyUnicode_Check - #define PyString_CheckExact PyUnicode_CheckExact -#endif -#if PY_VERSION_HEX < 0x02060000 - #define PyBytesObject PyStringObject - #define PyBytes_Type PyString_Type - #define PyBytes_Check PyString_Check - #define PyBytes_CheckExact PyString_CheckExact - #define PyBytes_FromString PyString_FromString - #define PyBytes_FromStringAndSize PyString_FromStringAndSize - #define PyBytes_FromFormat PyString_FromFormat - #define PyBytes_DecodeEscape PyString_DecodeEscape - #define PyBytes_AsString PyString_AsString - #define PyBytes_AsStringAndSize PyString_AsStringAndSize - #define PyBytes_Size PyString_Size - #define PyBytes_AS_STRING PyString_AS_STRING - #define PyBytes_GET_SIZE PyString_GET_SIZE - #define PyBytes_Repr PyString_Repr - #define PyBytes_Concat PyString_Concat - #define PyBytes_ConcatAndDel PyString_ConcatAndDel -#endif -#if PY_MAJOR_VERSION >= 3 - #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj) - #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj) -#else - #define __Pyx_PyBaseString_Check(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj) || \ - PyString_Check(obj) || PyUnicode_Check(obj)) - #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj)) -#endif -#if PY_VERSION_HEX < 0x02060000 - #define PySet_Check(obj) PyObject_TypeCheck(obj, &PySet_Type) - #define PyFrozenSet_Check(obj) PyObject_TypeCheck(obj, &PyFrozenSet_Type) -#endif -#ifndef PySet_CheckExact - #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) -#endif -#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) -#if PY_MAJOR_VERSION >= 3 - #define PyIntObject PyLongObject - #define PyInt_Type PyLong_Type - #define PyInt_Check(op) PyLong_Check(op) - #define PyInt_CheckExact(op) PyLong_CheckExact(op) - #define PyInt_FromString PyLong_FromString - #define PyInt_FromUnicode PyLong_FromUnicode - #define PyInt_FromLong PyLong_FromLong - #define PyInt_FromSize_t PyLong_FromSize_t - #define PyInt_FromSsize_t PyLong_FromSsize_t - #define PyInt_AsLong PyLong_AsLong - #define PyInt_AS_LONG PyLong_AS_LONG - #define PyInt_AsSsize_t PyLong_AsSsize_t - #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask - #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask - #define PyNumber_Int PyNumber_Long -#endif -#if PY_MAJOR_VERSION >= 3 - #define PyBoolObject PyLongObject -#endif -#if PY_VERSION_HEX < 0x030200A4 - typedef long Py_hash_t; - #define __Pyx_PyInt_FromHash_t PyInt_FromLong - #define __Pyx_PyInt_AsHash_t PyInt_AsLong -#else - #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t - #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t -#endif -#if (PY_MAJOR_VERSION < 3) || (PY_VERSION_HEX >= 0x03010300) - #define __Pyx_PySequence_GetSlice(obj, a, b) PySequence_GetSlice(obj, a, b) - #define __Pyx_PySequence_SetSlice(obj, a, b, value) PySequence_SetSlice(obj, a, b, value) - #define __Pyx_PySequence_DelSlice(obj, a, b) PySequence_DelSlice(obj, a, b) -#else - #define __Pyx_PySequence_GetSlice(obj, a, b) (unlikely(!(obj)) ? \ - (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), (PyObject*)0) : \ - (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_GetSlice(obj, a, b)) : \ - (PyErr_Format(PyExc_TypeError, "'%.200s' object is unsliceable", (obj)->ob_type->tp_name), (PyObject*)0))) - #define __Pyx_PySequence_SetSlice(obj, a, b, value) (unlikely(!(obj)) ? \ - (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \ - (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_SetSlice(obj, a, b, value)) : \ - (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice assignment", (obj)->ob_type->tp_name), -1))) - #define __Pyx_PySequence_DelSlice(obj, a, b) (unlikely(!(obj)) ? \ - (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \ - (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_DelSlice(obj, a, b)) : \ - (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice deletion", (obj)->ob_type->tp_name), -1))) -#endif -#if PY_MAJOR_VERSION >= 3 - #define PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func)) -#endif -#if PY_VERSION_HEX < 0x02050000 - #define __Pyx_GetAttrString(o,n) PyObject_GetAttrString((o),((char *)(n))) - #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),((char *)(n)),(a)) - #define __Pyx_DelAttrString(o,n) PyObject_DelAttrString((o),((char *)(n))) -#else - #define __Pyx_GetAttrString(o,n) PyObject_GetAttrString((o),(n)) - #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),(n),(a)) - #define __Pyx_DelAttrString(o,n) PyObject_DelAttrString((o),(n)) -#endif -#if PY_VERSION_HEX < 0x02050000 - #define __Pyx_NAMESTR(n) ((char *)(n)) - #define __Pyx_DOCSTR(n) ((char *)(n)) -#else - #define __Pyx_NAMESTR(n) (n) - #define __Pyx_DOCSTR(n) (n) -#endif -#ifndef CYTHON_INLINE - #if defined(__GNUC__) - #define CYTHON_INLINE __inline__ - #elif defined(_MSC_VER) - #define CYTHON_INLINE __inline - #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - #define CYTHON_INLINE inline - #else - #define CYTHON_INLINE - #endif -#endif -#ifndef CYTHON_RESTRICT - #if defined(__GNUC__) - #define CYTHON_RESTRICT __restrict__ - #elif defined(_MSC_VER) && _MSC_VER >= 1400 - #define CYTHON_RESTRICT __restrict - #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - #define CYTHON_RESTRICT restrict - #else - #define CYTHON_RESTRICT - #endif -#endif -#ifdef NAN -#define __PYX_NAN() ((float) NAN) -#else -static CYTHON_INLINE float __PYX_NAN() { - /* Initialize NaN. The sign is irrelevant, an exponent with all bits 1 and - a nonzero mantissa means NaN. If the first bit in the mantissa is 1, it is - a quiet NaN. */ - float value; - memset(&value, 0xFF, sizeof(value)); - return value; -} -#endif -#ifdef __cplusplus -template -void __Pyx_call_destructor(T* x) { - x->~T(); -} -#endif - - -#if PY_MAJOR_VERSION >= 3 - #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) - #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) -#else - #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) - #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) -#endif - -#ifndef __PYX_EXTERN_C - #ifdef __cplusplus - #define __PYX_EXTERN_C extern "C" - #else - #define __PYX_EXTERN_C extern - #endif -#endif - -#if defined(WIN32) || defined(MS_WINDOWS) -#define _USE_MATH_DEFINES -#endif -#include -#define __PYX_HAVE__freenect -#define __PYX_HAVE_API__freenect -#include "stdint.h" -#include "string.h" -#include "stdio.h" -#include "stdlib.h" -#include "numpy/arrayobject.h" -#include "numpy/ufuncobject.h" -#include "libfreenect.h" -#include "libfreenect_sync.h" -#ifdef _OPENMP -#include -#endif /* _OPENMP */ - -#ifdef PYREX_WITHOUT_ASSERTIONS -#define CYTHON_WITHOUT_ASSERTIONS -#endif - -#ifndef CYTHON_UNUSED -# if defined(__GNUC__) -# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) -# define CYTHON_UNUSED __attribute__ ((__unused__)) -# else -# define CYTHON_UNUSED -# endif -# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) -# define CYTHON_UNUSED __attribute__ ((__unused__)) -# else -# define CYTHON_UNUSED -# endif -#endif -typedef struct {PyObject **p; char *s; const Py_ssize_t n; const char* encoding; - const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; /*proto*/ - -#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0 -#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0 -#define __PYX_DEFAULT_STRING_ENCODING "" -#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString -#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize -#define __Pyx_fits_Py_ssize_t(v, type, is_signed) ( \ - (sizeof(type) < sizeof(Py_ssize_t)) || \ - (sizeof(type) > sizeof(Py_ssize_t) && \ - likely(v < (type)PY_SSIZE_T_MAX || \ - v == (type)PY_SSIZE_T_MAX) && \ - (!is_signed || likely(v > (type)PY_SSIZE_T_MIN || \ - v == (type)PY_SSIZE_T_MIN))) || \ - (sizeof(type) == sizeof(Py_ssize_t) && \ - (is_signed || likely(v < (type)PY_SSIZE_T_MAX || \ - v == (type)PY_SSIZE_T_MAX))) ) -static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*); -static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); -#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s)) -#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l) -#define __Pyx_PyBytes_FromString PyBytes_FromString -#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize -static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); -#if PY_MAJOR_VERSION < 3 - #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString - #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize -#else - #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString - #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize -#endif -#define __Pyx_PyObject_AsSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) -#define __Pyx_PyObject_AsUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) -#define __Pyx_PyObject_FromUString(s) __Pyx_PyObject_FromString((const char*)s) -#define __Pyx_PyBytes_FromUString(s) __Pyx_PyBytes_FromString((const char*)s) -#define __Pyx_PyByteArray_FromUString(s) __Pyx_PyByteArray_FromString((const char*)s) -#define __Pyx_PyStr_FromUString(s) __Pyx_PyStr_FromString((const char*)s) -#define __Pyx_PyUnicode_FromUString(s) __Pyx_PyUnicode_FromString((const char*)s) -#if PY_MAJOR_VERSION < 3 -static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) -{ - const Py_UNICODE *u_end = u; - while (*u_end++) ; - return (size_t)(u_end - u - 1); -} -#else -#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen -#endif -#define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u)) -#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode -#define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode -#define __Pyx_Owned_Py_None(b) (Py_INCREF(Py_None), Py_None) -#define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False)) -static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); -static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x); -static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); -static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); -#if CYTHON_COMPILING_IN_CPYTHON -#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) -#else -#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x) -#endif -#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x)) -#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII -static int __Pyx_sys_getdefaultencoding_not_ascii; -static int __Pyx_init_sys_getdefaultencoding_params(void) { - PyObject* sys; - PyObject* default_encoding = NULL; - PyObject* ascii_chars_u = NULL; - PyObject* ascii_chars_b = NULL; - const char* default_encoding_c; - sys = PyImport_ImportModule("sys"); - if (!sys) goto bad; - default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); - Py_DECREF(sys); - if (!default_encoding) goto bad; - default_encoding_c = PyBytes_AsString(default_encoding); - if (!default_encoding_c) goto bad; - if (strcmp(default_encoding_c, "ascii") == 0) { - __Pyx_sys_getdefaultencoding_not_ascii = 0; - } else { - char ascii_chars[128]; - int c; - for (c = 0; c < 128; c++) { - ascii_chars[c] = c; - } - __Pyx_sys_getdefaultencoding_not_ascii = 1; - ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL); - if (!ascii_chars_u) goto bad; - ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL); - if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) { - PyErr_Format( - PyExc_ValueError, - "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.", - default_encoding_c); - goto bad; - } - Py_DECREF(ascii_chars_u); - Py_DECREF(ascii_chars_b); - } - Py_DECREF(default_encoding); - return 0; -bad: - Py_XDECREF(default_encoding); - Py_XDECREF(ascii_chars_u); - Py_XDECREF(ascii_chars_b); - return -1; -} -#endif -#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3 -#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL) -#else -#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL) -#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT -static char* __PYX_DEFAULT_STRING_ENCODING; -static int __Pyx_init_sys_getdefaultencoding_params(void) { - PyObject* sys; - PyObject* default_encoding = NULL; - char* default_encoding_c; - sys = PyImport_ImportModule("sys"); - if (!sys) goto bad; - default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); - Py_DECREF(sys); - if (!default_encoding) goto bad; - default_encoding_c = PyBytes_AsString(default_encoding); - if (!default_encoding_c) goto bad; - __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c)); - if (!__PYX_DEFAULT_STRING_ENCODING) goto bad; - strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c); - Py_DECREF(default_encoding); - return 0; -bad: - Py_XDECREF(default_encoding); - return -1; -} -#endif -#endif - - -/* Test for GCC > 2.95 */ -#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))) - #define likely(x) __builtin_expect(!!(x), 1) - #define unlikely(x) __builtin_expect(!!(x), 0) -#else /* !__GNUC__ or GCC < 2.95 */ - #define likely(x) (x) - #define unlikely(x) (x) -#endif /* __GNUC__ */ - -static PyObject *__pyx_m; -static PyObject *__pyx_d; -static PyObject *__pyx_b; -static PyObject *__pyx_empty_tuple; -static PyObject *__pyx_empty_bytes; -static int __pyx_lineno; -static int __pyx_clineno = 0; -static const char * __pyx_cfilenm= __FILE__; -static const char *__pyx_filename; - -#if !defined(CYTHON_CCOMPLEX) - #if defined(__cplusplus) - #define CYTHON_CCOMPLEX 1 - #elif defined(_Complex_I) - #define CYTHON_CCOMPLEX 1 - #else - #define CYTHON_CCOMPLEX 0 - #endif -#endif -#if CYTHON_CCOMPLEX - #ifdef __cplusplus - #include - #else - #include - #endif -#endif -#if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__) - #undef _Complex_I - #define _Complex_I 1.0fj -#endif - - -static const char *__pyx_f[] = { - "freenect.pyx", - "__init__.pxd", - "type.pxd", -}; - -/* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":723 - * # in Cython to enable them only on the right systems. - * - * ctypedef npy_int8 int8_t # <<<<<<<<<<<<<< - * ctypedef npy_int16 int16_t - * ctypedef npy_int32 int32_t - */ -typedef npy_int8 __pyx_t_5numpy_int8_t; - -/* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":724 - * - * ctypedef npy_int8 int8_t - * ctypedef npy_int16 int16_t # <<<<<<<<<<<<<< - * ctypedef npy_int32 int32_t - * ctypedef npy_int64 int64_t - */ -typedef npy_int16 __pyx_t_5numpy_int16_t; - -/* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":725 - * ctypedef npy_int8 int8_t - * ctypedef npy_int16 int16_t - * ctypedef npy_int32 int32_t # <<<<<<<<<<<<<< - * ctypedef npy_int64 int64_t - * #ctypedef npy_int96 int96_t - */ -typedef npy_int32 __pyx_t_5numpy_int32_t; - -/* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":726 - * ctypedef npy_int16 int16_t - * ctypedef npy_int32 int32_t - * ctypedef npy_int64 int64_t # <<<<<<<<<<<<<< - * #ctypedef npy_int96 int96_t - * #ctypedef npy_int128 int128_t - */ -typedef npy_int64 __pyx_t_5numpy_int64_t; - -/* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":730 - * #ctypedef npy_int128 int128_t - * - * ctypedef npy_uint8 uint8_t # <<<<<<<<<<<<<< - * ctypedef npy_uint16 uint16_t - * ctypedef npy_uint32 uint32_t - */ -typedef npy_uint8 __pyx_t_5numpy_uint8_t; - -/* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":731 - * - * ctypedef npy_uint8 uint8_t - * ctypedef npy_uint16 uint16_t # <<<<<<<<<<<<<< - * ctypedef npy_uint32 uint32_t - * ctypedef npy_uint64 uint64_t - */ -typedef npy_uint16 __pyx_t_5numpy_uint16_t; - -/* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":732 - * ctypedef npy_uint8 uint8_t - * ctypedef npy_uint16 uint16_t - * ctypedef npy_uint32 uint32_t # <<<<<<<<<<<<<< - * ctypedef npy_uint64 uint64_t - * #ctypedef npy_uint96 uint96_t - */ -typedef npy_uint32 __pyx_t_5numpy_uint32_t; - -/* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":733 - * ctypedef npy_uint16 uint16_t - * ctypedef npy_uint32 uint32_t - * ctypedef npy_uint64 uint64_t # <<<<<<<<<<<<<< - * #ctypedef npy_uint96 uint96_t - * #ctypedef npy_uint128 uint128_t - */ -typedef npy_uint64 __pyx_t_5numpy_uint64_t; - -/* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":737 - * #ctypedef npy_uint128 uint128_t - * - * ctypedef npy_float32 float32_t # <<<<<<<<<<<<<< - * ctypedef npy_float64 float64_t - * #ctypedef npy_float80 float80_t - */ -typedef npy_float32 __pyx_t_5numpy_float32_t; - -/* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":738 - * - * ctypedef npy_float32 float32_t - * ctypedef npy_float64 float64_t # <<<<<<<<<<<<<< - * #ctypedef npy_float80 float80_t - * #ctypedef npy_float128 float128_t - */ -typedef npy_float64 __pyx_t_5numpy_float64_t; - -/* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":747 - * # The int types are mapped a bit surprising -- - * # numpy.int corresponds to 'l' and numpy.long to 'q' - * ctypedef npy_long int_t # <<<<<<<<<<<<<< - * ctypedef npy_longlong long_t - * ctypedef npy_longlong longlong_t - */ -typedef npy_long __pyx_t_5numpy_int_t; - -/* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":748 - * # numpy.int corresponds to 'l' and numpy.long to 'q' - * ctypedef npy_long int_t - * ctypedef npy_longlong long_t # <<<<<<<<<<<<<< - * ctypedef npy_longlong longlong_t - * - */ -typedef npy_longlong __pyx_t_5numpy_long_t; - -/* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":749 - * ctypedef npy_long int_t - * ctypedef npy_longlong long_t - * ctypedef npy_longlong longlong_t # <<<<<<<<<<<<<< - * - * ctypedef npy_ulong uint_t - */ -typedef npy_longlong __pyx_t_5numpy_longlong_t; - -/* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":751 - * ctypedef npy_longlong longlong_t - * - * ctypedef npy_ulong uint_t # <<<<<<<<<<<<<< - * ctypedef npy_ulonglong ulong_t - * ctypedef npy_ulonglong ulonglong_t - */ -typedef npy_ulong __pyx_t_5numpy_uint_t; - -/* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":752 - * - * ctypedef npy_ulong uint_t - * ctypedef npy_ulonglong ulong_t # <<<<<<<<<<<<<< - * ctypedef npy_ulonglong ulonglong_t - * - */ -typedef npy_ulonglong __pyx_t_5numpy_ulong_t; - -/* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":753 - * ctypedef npy_ulong uint_t - * ctypedef npy_ulonglong ulong_t - * ctypedef npy_ulonglong ulonglong_t # <<<<<<<<<<<<<< - * - * ctypedef npy_intp intp_t - */ -typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t; - -/* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":755 - * ctypedef npy_ulonglong ulonglong_t - * - * ctypedef npy_intp intp_t # <<<<<<<<<<<<<< - * ctypedef npy_uintp uintp_t - * - */ -typedef npy_intp __pyx_t_5numpy_intp_t; - -/* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":756 - * - * ctypedef npy_intp intp_t - * ctypedef npy_uintp uintp_t # <<<<<<<<<<<<<< - * - * ctypedef npy_double float_t - */ -typedef npy_uintp __pyx_t_5numpy_uintp_t; - -/* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":758 - * ctypedef npy_uintp uintp_t - * - * ctypedef npy_double float_t # <<<<<<<<<<<<<< - * ctypedef npy_double double_t - * ctypedef npy_longdouble longdouble_t - */ -typedef npy_double __pyx_t_5numpy_float_t; - -/* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":759 - * - * ctypedef npy_double float_t - * ctypedef npy_double double_t # <<<<<<<<<<<<<< - * ctypedef npy_longdouble longdouble_t - * - */ -typedef npy_double __pyx_t_5numpy_double_t; - -/* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":760 - * ctypedef npy_double float_t - * ctypedef npy_double double_t - * ctypedef npy_longdouble longdouble_t # <<<<<<<<<<<<<< - * - * ctypedef npy_cfloat cfloat_t - */ -typedef npy_longdouble __pyx_t_5numpy_longdouble_t; -#if CYTHON_CCOMPLEX - #ifdef __cplusplus - typedef ::std::complex< float > __pyx_t_float_complex; - #else - typedef float _Complex __pyx_t_float_complex; - #endif -#else - typedef struct { float real, imag; } __pyx_t_float_complex; -#endif - -#if CYTHON_CCOMPLEX - #ifdef __cplusplus - typedef ::std::complex< double > __pyx_t_double_complex; - #else - typedef double _Complex __pyx_t_double_complex; - #endif -#else - typedef struct { double real, imag; } __pyx_t_double_complex; -#endif - - -/*--- Type declarations ---*/ -struct __pyx_obj_8freenect_CtxPtr; -struct __pyx_obj_8freenect_DevPtr; -struct __pyx_obj_8freenect_StatePtr; - -/* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":762 - * ctypedef npy_longdouble longdouble_t - * - * ctypedef npy_cfloat cfloat_t # <<<<<<<<<<<<<< - * ctypedef npy_cdouble cdouble_t - * ctypedef npy_clongdouble clongdouble_t - */ -typedef npy_cfloat __pyx_t_5numpy_cfloat_t; - -/* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":763 - * - * ctypedef npy_cfloat cfloat_t - * ctypedef npy_cdouble cdouble_t # <<<<<<<<<<<<<< - * ctypedef npy_clongdouble clongdouble_t - * - */ -typedef npy_cdouble __pyx_t_5numpy_cdouble_t; - -/* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":764 - * ctypedef npy_cfloat cfloat_t - * ctypedef npy_cdouble cdouble_t - * ctypedef npy_clongdouble clongdouble_t # <<<<<<<<<<<<<< - * - * ctypedef npy_cdouble complex_t - */ -typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t; - -/* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":766 - * ctypedef npy_clongdouble clongdouble_t - * - * ctypedef npy_cdouble complex_t # <<<<<<<<<<<<<< - * - * cdef inline object PyArray_MultiIterNew1(a): - */ -typedef npy_cdouble __pyx_t_5numpy_complex_t; - -/* "freenect.pyx":176 - * raise TypeError("What kind of system are you using?!") - * - * cdef class CtxPtr: # <<<<<<<<<<<<<< - * cdef freenect_context* _ptr - * def __init__(self): - */ -struct __pyx_obj_8freenect_CtxPtr { - PyObject_HEAD - freenect_context *_ptr; -}; - - -/* "freenect.pyx":185 - * return "" % _format_ptr(self._ptr) - * - * cdef class DevPtr: # <<<<<<<<<<<<<< - * cdef freenect_device* _ptr - * cdef CtxPtr ctx - */ -struct __pyx_obj_8freenect_DevPtr { - PyObject_HEAD - freenect_device *_ptr; - struct __pyx_obj_8freenect_CtxPtr *ctx; -}; - - -/* "freenect.pyx":195 - * return "" % _format_ptr(self._ptr) - * - * cdef class StatePtr: # <<<<<<<<<<<<<< - * cdef freenect_raw_tilt_state* _ptr - * def __init__(self): - */ -struct __pyx_obj_8freenect_StatePtr { - PyObject_HEAD - freenect_raw_tilt_state *_ptr; -}; - -#ifndef CYTHON_REFNANNY - #define CYTHON_REFNANNY 0 -#endif -#if CYTHON_REFNANNY - typedef struct { - void (*INCREF)(void*, PyObject*, int); - void (*DECREF)(void*, PyObject*, int); - void (*GOTREF)(void*, PyObject*, int); - void (*GIVEREF)(void*, PyObject*, int); - void* (*SetupContext)(const char*, int, const char*); - void (*FinishContext)(void**); - } __Pyx_RefNannyAPIStruct; - static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; - static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); /*proto*/ - #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL; -#ifdef WITH_THREAD - #define __Pyx_RefNannySetupContext(name, acquire_gil) \ - if (acquire_gil) { \ - PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); \ - __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \ - PyGILState_Release(__pyx_gilstate_save); \ - } else { \ - __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \ - } -#else - #define __Pyx_RefNannySetupContext(name, acquire_gil) \ - __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__) -#endif - #define __Pyx_RefNannyFinishContext() \ - __Pyx_RefNanny->FinishContext(&__pyx_refnanny) - #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__) - #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__) - #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__) - #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__) - #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0) - #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0) - #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0) - #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0) -#else - #define __Pyx_RefNannyDeclarations - #define __Pyx_RefNannySetupContext(name, acquire_gil) - #define __Pyx_RefNannyFinishContext() - #define __Pyx_INCREF(r) Py_INCREF(r) - #define __Pyx_DECREF(r) Py_DECREF(r) - #define __Pyx_GOTREF(r) - #define __Pyx_GIVEREF(r) - #define __Pyx_XINCREF(r) Py_XINCREF(r) - #define __Pyx_XDECREF(r) Py_XDECREF(r) - #define __Pyx_XGOTREF(r) - #define __Pyx_XGIVEREF(r) -#endif /* CYTHON_REFNANNY */ -#define __Pyx_XDECREF_SET(r, v) do { \ - PyObject *tmp = (PyObject *) r; \ - r = v; __Pyx_XDECREF(tmp); \ - } while (0) -#define __Pyx_DECREF_SET(r, v) do { \ - PyObject *tmp = (PyObject *) r; \ - r = v; __Pyx_DECREF(tmp); \ - } while (0) -#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0) -#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) - -#if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { - PyTypeObject* tp = Py_TYPE(obj); - if (likely(tp->tp_getattro)) - return tp->tp_getattro(obj, attr_name); -#if PY_MAJOR_VERSION < 3 - if (likely(tp->tp_getattr)) - return tp->tp_getattr(obj, PyString_AS_STRING(attr_name)); -#endif - return PyObject_GetAttr(obj, attr_name); -} -#else -#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n) -#endif - -static PyObject *__Pyx_GetBuiltinName(PyObject *name); /*proto*/ - -#if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); /*proto*/ -#else -#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw) -#endif - -static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/ -static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/ - -static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); /*proto*/ - -static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, - Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/ - -static CYTHON_INLINE int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed); /*proto*/ - -static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); /*proto*/ - -static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[], \ - PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, \ - const char* function_name); /*proto*/ - -static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, - const char *name, int exact); /*proto*/ - -static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/ - -static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); /*proto*/ - -#ifndef __PYX_FORCE_INIT_THREADS - #define __PYX_FORCE_INIT_THREADS 0 -#endif - -static void __Pyx_WriteUnraisable(const char *name, int clineno, - int lineno, const char *filename, - int full_traceback); /*proto*/ - -static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb); /*proto*/ -static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb); /*proto*/ - -static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected); - -static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index); - -static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void); - -static PyObject *__Pyx_GetNameInClass(PyObject *nmspace, PyObject *name); /*proto*/ - -static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases); - -static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, PyObject *qualname, - PyObject *mkw, PyObject *modname, PyObject *doc); /*proto*/ -static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases, PyObject *dict, - PyObject *mkw, int calculate_metaclass, int allow_py2_metaclass); /*proto*/ - -static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); /*proto*/ - -static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); - -static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int16_t(int16_t value); - -static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int8_t(int8_t value); - -static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value); - -static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int32_t(int32_t value); - -static int __Pyx_Print(PyObject*, PyObject *, int); /*proto*/ -#if CYTHON_COMPILING_IN_PYPY || PY_MAJOR_VERSION >= 3 -static PyObject* __pyx_print = 0; -static PyObject* __pyx_print_kwargs = 0; -#endif - -static int __Pyx_PrintOne(PyObject* stream, PyObject *o); /*proto*/ - -static CYTHON_INLINE PyObject* __Pyx_PyInt_From_uint32_t(uint32_t value); - -#if CYTHON_CCOMPLEX - #ifdef __cplusplus - #define __Pyx_CREAL(z) ((z).real()) - #define __Pyx_CIMAG(z) ((z).imag()) - #else - #define __Pyx_CREAL(z) (__real__(z)) - #define __Pyx_CIMAG(z) (__imag__(z)) - #endif -#else - #define __Pyx_CREAL(z) ((z).real) - #define __Pyx_CIMAG(z) ((z).imag) -#endif -#if (defined(_WIN32) || defined(__clang__)) && defined(__cplusplus) && CYTHON_CCOMPLEX - #define __Pyx_SET_CREAL(z,x) ((z).real(x)) - #define __Pyx_SET_CIMAG(z,y) ((z).imag(y)) -#else - #define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x) - #define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y) -#endif - -static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float, float); - -#if CYTHON_CCOMPLEX - #define __Pyx_c_eqf(a, b) ((a)==(b)) - #define __Pyx_c_sumf(a, b) ((a)+(b)) - #define __Pyx_c_difff(a, b) ((a)-(b)) - #define __Pyx_c_prodf(a, b) ((a)*(b)) - #define __Pyx_c_quotf(a, b) ((a)/(b)) - #define __Pyx_c_negf(a) (-(a)) - #ifdef __cplusplus - #define __Pyx_c_is_zerof(z) ((z)==(float)0) - #define __Pyx_c_conjf(z) (::std::conj(z)) - #if 1 - #define __Pyx_c_absf(z) (::std::abs(z)) - #define __Pyx_c_powf(a, b) (::std::pow(a, b)) - #endif - #else - #define __Pyx_c_is_zerof(z) ((z)==0) - #define __Pyx_c_conjf(z) (conjf(z)) - #if 1 - #define __Pyx_c_absf(z) (cabsf(z)) - #define __Pyx_c_powf(a, b) (cpowf(a, b)) - #endif - #endif -#else - static CYTHON_INLINE int __Pyx_c_eqf(__pyx_t_float_complex, __pyx_t_float_complex); - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sumf(__pyx_t_float_complex, __pyx_t_float_complex); - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_difff(__pyx_t_float_complex, __pyx_t_float_complex); - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prodf(__pyx_t_float_complex, __pyx_t_float_complex); - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quotf(__pyx_t_float_complex, __pyx_t_float_complex); - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_negf(__pyx_t_float_complex); - static CYTHON_INLINE int __Pyx_c_is_zerof(__pyx_t_float_complex); - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conjf(__pyx_t_float_complex); - #if 1 - static CYTHON_INLINE float __Pyx_c_absf(__pyx_t_float_complex); - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_powf(__pyx_t_float_complex, __pyx_t_float_complex); - #endif -#endif - -static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double); - -#if CYTHON_CCOMPLEX - #define __Pyx_c_eq(a, b) ((a)==(b)) - #define __Pyx_c_sum(a, b) ((a)+(b)) - #define __Pyx_c_diff(a, b) ((a)-(b)) - #define __Pyx_c_prod(a, b) ((a)*(b)) - #define __Pyx_c_quot(a, b) ((a)/(b)) - #define __Pyx_c_neg(a) (-(a)) - #ifdef __cplusplus - #define __Pyx_c_is_zero(z) ((z)==(double)0) - #define __Pyx_c_conj(z) (::std::conj(z)) - #if 1 - #define __Pyx_c_abs(z) (::std::abs(z)) - #define __Pyx_c_pow(a, b) (::std::pow(a, b)) - #endif - #else - #define __Pyx_c_is_zero(z) ((z)==0) - #define __Pyx_c_conj(z) (conj(z)) - #if 1 - #define __Pyx_c_abs(z) (cabs(z)) - #define __Pyx_c_pow(a, b) (cpow(a, b)) - #endif - #endif -#else - static CYTHON_INLINE int __Pyx_c_eq(__pyx_t_double_complex, __pyx_t_double_complex); - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum(__pyx_t_double_complex, __pyx_t_double_complex); - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff(__pyx_t_double_complex, __pyx_t_double_complex); - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod(__pyx_t_double_complex, __pyx_t_double_complex); - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot(__pyx_t_double_complex, __pyx_t_double_complex); - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg(__pyx_t_double_complex); - static CYTHON_INLINE int __Pyx_c_is_zero(__pyx_t_double_complex); - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj(__pyx_t_double_complex); - #if 1 - static CYTHON_INLINE double __Pyx_c_abs(__pyx_t_double_complex); - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow(__pyx_t_double_complex, __pyx_t_double_complex); - #endif -#endif - -static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); - -static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); - -static int __Pyx_check_binary_version(void); - -#if !defined(__Pyx_PyIdentifier_FromString) -#if PY_MAJOR_VERSION < 3 - #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s) -#else - #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s) -#endif -#endif - -static PyObject *__Pyx_ImportModule(const char *name); /*proto*/ - -static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict); /*proto*/ - -typedef struct { - int code_line; - PyCodeObject* code_object; -} __Pyx_CodeObjectCacheEntry; -struct __Pyx_CodeObjectCache { - int count; - int max_count; - __Pyx_CodeObjectCacheEntry* entries; -}; -static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL}; -static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line); -static PyCodeObject *__pyx_find_code_object(int code_line); -static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object); - -static void __Pyx_AddTraceback(const char *funcname, int c_line, - int py_line, const char *filename); /*proto*/ - -static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/ - - -/* Module declarations from 'libc.stdint' */ - -/* Module declarations from 'cpython.buffer' */ - -/* Module declarations from 'cpython.ref' */ - -/* Module declarations from 'libc.string' */ - -/* Module declarations from 'libc.stdio' */ - -/* Module declarations from 'cpython.object' */ - -/* Module declarations from '__builtin__' */ - -/* Module declarations from 'cpython.type' */ -static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0; - -/* Module declarations from 'libc.stdlib' */ - -/* Module declarations from 'numpy' */ - -/* Module declarations from 'numpy' */ -static PyTypeObject *__pyx_ptype_5numpy_dtype = 0; -static PyTypeObject *__pyx_ptype_5numpy_flatiter = 0; -static PyTypeObject *__pyx_ptype_5numpy_broadcast = 0; -static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0; -static PyTypeObject *__pyx_ptype_5numpy_ufunc = 0; -static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *, char *, char *, int *); /*proto*/ - -/* Module declarations from 'freenect' */ -static PyTypeObject *__pyx_ptype_8freenect_CtxPtr = 0; -static PyTypeObject *__pyx_ptype_8freenect_DevPtr = 0; -static PyTypeObject *__pyx_ptype_8freenect_StatePtr = 0; -static CYTHON_INLINE PyObject *__pyx_f_8freenect__format_ptr(void *); /*proto*/ -static PyObject *__pyx_f_8freenect_init(int __pyx_skip_dispatch); /*proto*/ -static PyObject *__pyx_f_8freenect_open_device(struct __pyx_obj_8freenect_CtxPtr *, int, int __pyx_skip_dispatch); /*proto*/ -static void __pyx_f_8freenect_depth_cb(freenect_device *, void *, uint32_t); /*proto*/ -static void __pyx_f_8freenect_video_cb(freenect_device *, void *, uint32_t); /*proto*/ -static PyObject *__pyx_f_8freenect__depth_cb_np(void *, freenect_frame_mode *); /*proto*/ -static PyObject *__pyx_f_8freenect__video_cb_np(void *, freenect_frame_mode *); /*proto*/ -#define __Pyx_MODULE_NAME "freenect" -int __pyx_module_is_main_freenect = 0; - -/* Implementation of 'freenect' */ -static PyObject *__pyx_builtin_property; -static PyObject *__pyx_builtin_Exception; -static PyObject *__pyx_builtin_TypeError; -static PyObject *__pyx_builtin_ValueError; -static PyObject *__pyx_builtin_range; -static PyObject *__pyx_builtin_RuntimeError; -static int __pyx_pf_8freenect_6CtxPtr___init__(CYTHON_UNUSED struct __pyx_obj_8freenect_CtxPtr *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_8freenect_6CtxPtr_2__repr__(struct __pyx_obj_8freenect_CtxPtr *__pyx_v_self); /* proto */ -static int __pyx_pf_8freenect_6DevPtr___init__(CYTHON_UNUSED struct __pyx_obj_8freenect_DevPtr *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_8freenect_6DevPtr_2__repr__(struct __pyx_obj_8freenect_DevPtr *__pyx_v_self); /* proto */ -static int __pyx_pf_8freenect_8StatePtr___init__(CYTHON_UNUSED struct __pyx_obj_8freenect_StatePtr *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_8freenect_8StatePtr_2__repr__(struct __pyx_obj_8freenect_StatePtr *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_8freenect_8StatePtr_4_get_accelx(struct __pyx_obj_8freenect_StatePtr *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_8freenect_8StatePtr_6_get_accely(struct __pyx_obj_8freenect_StatePtr *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_8freenect_8StatePtr_8_get_accelz(struct __pyx_obj_8freenect_StatePtr *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_8freenect_8StatePtr_10_get_tilt_angle(struct __pyx_obj_8freenect_StatePtr *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_8freenect_8StatePtr_12_get_tilt_status(struct __pyx_obj_8freenect_StatePtr *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_8freenect_set_depth_mode(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_DevPtr *__pyx_v_dev, int __pyx_v_res, int __pyx_v_mode); /* proto */ -static PyObject *__pyx_pf_8freenect_2set_video_mode(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_DevPtr *__pyx_v_dev, int __pyx_v_res, int __pyx_v_mode); /* proto */ -static PyObject *__pyx_pf_8freenect_4get_depth_format(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_DevPtr *__pyx_v_dev); /* proto */ -static PyObject *__pyx_pf_8freenect_6get_video_format(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_DevPtr *__pyx_v_dev); /* proto */ -static PyObject *__pyx_pf_8freenect_8start_depth(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_DevPtr *__pyx_v_dev); /* proto */ -static PyObject *__pyx_pf_8freenect_10start_video(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_DevPtr *__pyx_v_dev); /* proto */ -static PyObject *__pyx_pf_8freenect_12stop_depth(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_DevPtr *__pyx_v_dev); /* proto */ -static PyObject *__pyx_pf_8freenect_14stop_video(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_DevPtr *__pyx_v_dev); /* proto */ -static PyObject *__pyx_pf_8freenect_16shutdown(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_CtxPtr *__pyx_v_ctx); /* proto */ -static PyObject *__pyx_pf_8freenect_18process_events(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_CtxPtr *__pyx_v_ctx); /* proto */ -static PyObject *__pyx_pf_8freenect_20num_devices(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_CtxPtr *__pyx_v_ctx); /* proto */ -static PyObject *__pyx_pf_8freenect_22close_device(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_DevPtr *__pyx_v_dev); /* proto */ -static PyObject *__pyx_pf_8freenect_24set_tilt_degs(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_DevPtr *__pyx_v_dev, float __pyx_v_angle); /* proto */ -static PyObject *__pyx_pf_8freenect_26set_led(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_DevPtr *__pyx_v_dev, freenect_led_options __pyx_v_option); /* proto */ -static PyObject *__pyx_pf_8freenect_28update_tilt_state(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_DevPtr *__pyx_v_dev); /* proto */ -static PyObject *__pyx_pf_8freenect_30get_tilt_state(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_DevPtr *__pyx_v_dev); /* proto */ -static PyObject *__pyx_pf_8freenect_32get_mks_accel(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_StatePtr *__pyx_v_state); /* proto */ -static PyObject *__pyx_pf_8freenect_34get_accel(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_DevPtr *__pyx_v_dev); /* proto */ -static PyObject *__pyx_pf_8freenect_36get_tilt_degs(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_StatePtr *__pyx_v_state); /* proto */ -static PyObject *__pyx_pf_8freenect_38error_open_device(CYTHON_UNUSED PyObject *__pyx_self); /* proto */ -static PyObject *__pyx_pf_8freenect_40init(CYTHON_UNUSED PyObject *__pyx_self); /* proto */ -static PyObject *__pyx_pf_8freenect_42open_device(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_CtxPtr *__pyx_v_ctx, int __pyx_v_index); /* proto */ -static PyObject *__pyx_pf_8freenect_44set_depth_callback(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_DevPtr *__pyx_v_dev, PyObject *__pyx_v_cb); /* proto */ -static PyObject *__pyx_pf_8freenect_46set_video_callback(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_DevPtr *__pyx_v_dev, PyObject *__pyx_v_cb); /* proto */ -static PyObject *__pyx_pf_8freenect_48runloop(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_depth, PyObject *__pyx_v_video, PyObject *__pyx_v_body, PyObject *__pyx_v_dev); /* proto */ -static PyObject *__pyx_pf_8freenect_50base_runloop(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_CtxPtr *__pyx_v_ctx, PyObject *__pyx_v_body); /* proto */ -static PyObject *__pyx_pf_8freenect_52sync_get_depth(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_index, PyObject *__pyx_v_format); /* proto */ -static PyObject *__pyx_pf_8freenect_54sync_get_video(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_index, PyObject *__pyx_v_format); /* proto */ -static PyObject *__pyx_pf_8freenect_56sync_stop(CYTHON_UNUSED PyObject *__pyx_self); /* proto */ -static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */ -static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info); /* proto */ -static PyObject *__pyx_tp_new_8freenect_CtxPtr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ -static PyObject *__pyx_tp_new_8freenect_DevPtr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ -static PyObject *__pyx_tp_new_8freenect_StatePtr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ -static char __pyx_k_B[] = "B"; -static char __pyx_k_H[] = "H"; -static char __pyx_k_I[] = "I"; -static char __pyx_k_L[] = "L"; -static char __pyx_k_O[] = "O"; -static char __pyx_k_Q[] = "Q"; -static char __pyx_k_b[] = "b"; -static char __pyx_k_d[] = "d"; -static char __pyx_k_f[] = "f"; -static char __pyx_k_g[] = "g"; -static char __pyx_k_h[] = "h"; -static char __pyx_k_i[] = "i"; -static char __pyx_k_l[] = "l"; -static char __pyx_k_q[] = "q"; -static char __pyx_k_x[] = "x"; -static char __pyx_k_y[] = "y"; -static char __pyx_k_z[] = "z"; -static char __pyx_k_Zd[] = "Zd"; -static char __pyx_k_Zf[] = "Zf"; -static char __pyx_k_Zg[] = "Zg"; -static char __pyx_k_cb[] = "cb"; -static char __pyx_k_np[] = "np"; -static char __pyx_k_ctx[] = "ctx"; -static char __pyx_k_dev[] = "dev"; -static char __pyx_k_doc[] = "__doc__"; -static char __pyx_k_end[] = "end"; -static char __pyx_k_out[] = "out"; -static char __pyx_k_res[] = "res"; -static char __pyx_k_Kill[] = "Kill"; -static char __pyx_k_body[] = "body"; -static char __pyx_k_ctxp[] = "ctxp"; -static char __pyx_k_data[] = "data"; -static char __pyx_k_devp[] = "devp"; -static char __pyx_k_dims[] = "dims"; -static char __pyx_k_file[] = "file"; -static char __pyx_k_main[] = "__main__"; -static char __pyx_k_mdev[] = "mdev"; -static char __pyx_k_mode[] = "mode"; -static char __pyx_k_test[] = "__test__"; -static char __pyx_k_angle[] = "angle"; -static char __pyx_k_depth[] = "depth"; -static char __pyx_k_index[] = "index"; -static char __pyx_k_numpy[] = "numpy"; -static char __pyx_k_print[] = "print"; -static char __pyx_k_range[] = "range"; -static char __pyx_k_state[] = "state"; -static char __pyx_k_video[] = "video"; -static char __pyx_k_0x_08x[] = "0x%08x"; -static char __pyx_k_format[] = "format"; -static char __pyx_k_import[] = "__import__"; -static char __pyx_k_module[] = "__module__"; -static char __pyx_k_option[] = "option"; -static char __pyx_k_0x_016x[] = "0x%016x"; -static char __pyx_k_LED_OFF[] = "LED_OFF"; -static char __pyx_k_LED_RED[] = "LED_RED"; -static char __pyx_k_index_2[] = "_index"; -static char __pyx_k_prepare[] = "__prepare__"; -static char __pyx_k_runloop[] = "runloop"; -static char __pyx_k_set_led[] = "set_led"; -static char __pyx_k_DEPTH_MM[] = "DEPTH_MM"; -static char __pyx_k_depth_cb[] = "_depth_cb"; -static char __pyx_k_format_2[] = "_format"; -static char __pyx_k_freenect[] = "freenect"; -static char __pyx_k_property[] = "property"; -static char __pyx_k_qualname[] = "__qualname__"; -static char __pyx_k_shutdown[] = "shutdown"; -static char __pyx_k_video_cb[] = "_video_cb"; -static char __pyx_k_Exception[] = "Exception"; -static char __pyx_k_LED_GREEN[] = "LED_GREEN"; -static char __pyx_k_TypeError[] = "TypeError"; -static char __pyx_k_VIDEO_RGB[] = "VIDEO_RGB"; -static char __pyx_k_get_accel[] = "get_accel"; -static char __pyx_k_metaclass[] = "__metaclass__"; -static char __pyx_k_state_out[] = "state_out"; -static char __pyx_k_sync_stop[] = "sync_stop"; -static char __pyx_k_timestamp[] = "timestamp"; -static char __pyx_k_LED_YELLOW[] = "LED_YELLOW"; -static char __pyx_k_ValueError[] = "ValueError"; -static char __pyx_k_get_accelx[] = "_get_accelx"; -static char __pyx_k_get_accely[] = "_get_accely"; -static char __pyx_k_get_accelz[] = "_get_accelz"; -static char __pyx_k_stop_depth[] = "stop_depth"; -static char __pyx_k_stop_video[] = "stop_video"; -static char __pyx_k_tilt_angle[] = "tilt_angle"; -static char __pyx_k_DEPTH_10BIT[] = "DEPTH_10BIT"; -static char __pyx_k_DEPTH_11BIT[] = "DEPTH_11BIT"; -static char __pyx_k_VIDEO_BAYER[] = "VIDEO_BAYER"; -static char __pyx_k_num_devices[] = "num_devices"; -static char __pyx_k_start_depth[] = "start_depth"; -static char __pyx_k_start_video[] = "start_video"; -static char __pyx_k_tilt_status[] = "tilt_status"; -static char __pyx_k_DEVICE_AUDIO[] = "DEVICE_AUDIO"; -static char __pyx_k_DEVICE_MOTOR[] = "DEVICE_MOTOR"; -static char __pyx_k_RuntimeError[] = "RuntimeError"; -static char __pyx_k_base_runloop[] = "base_runloop"; -static char __pyx_k_close_device[] = "close_device"; -static char __pyx_k_freenect_pyx[] = "freenect.pyx"; -static char __pyx_k_Ctx_Pointer_s[] = ""; -static char __pyx_k_DEVICE_CAMERA[] = "DEVICE_CAMERA"; -static char __pyx_k_Dev_Pointer_s[] = ""; -static char __pyx_k_VIDEO_IR_8BIT[] = "VIDEO_IR_8BIT"; -static char __pyx_k_VIDEO_YUV_RAW[] = "VIDEO_YUV_RAW"; -static char __pyx_k_VIDEO_YUV_RGB[] = "VIDEO_YUV_RGB"; -static char __pyx_k_get_mks_accel[] = "get_mks_accel"; -static char __pyx_k_get_tilt_degs[] = "get_tilt_degs"; -static char __pyx_k_set_tilt_degs[] = "set_tilt_degs"; -static char __pyx_k_RESOLUTION_LOW[] = "RESOLUTION_LOW"; -static char __pyx_k_VIDEO_IR_10BIT[] = "VIDEO_IR_10BIT"; -static char __pyx_k_get_tilt_angle[] = "_get_tilt_angle"; -static char __pyx_k_get_tilt_state[] = "get_tilt_state"; -static char __pyx_k_process_events[] = "process_events"; -static char __pyx_k_set_depth_mode[] = "set_depth_mode"; -static char __pyx_k_set_video_mode[] = "set_video_mode"; -static char __pyx_k_sync_get_depth[] = "sync_get_depth"; -static char __pyx_k_sync_get_video[] = "sync_get_video"; -static char __pyx_k_LED_BLINK_GREEN[] = "LED_BLINK_GREEN"; -static char __pyx_k_RESOLUTION_HIGH[] = "RESOLUTION_HIGH"; -static char __pyx_k_State_Pointer_s[] = ""; -static char __pyx_k_accelerometer_x[] = "accelerometer_x"; -static char __pyx_k_accelerometer_y[] = "accelerometer_y"; -static char __pyx_k_accelerometer_z[] = "accelerometer_z"; -static char __pyx_k_get_tilt_status[] = "_get_tilt_status"; -static char __pyx_k_DEPTH_REGISTERED[] = "DEPTH_REGISTERED"; -static char __pyx_k_get_depth_format[] = "get_depth_format"; -static char __pyx_k_get_video_format[] = "get_video_format"; -static char __pyx_k_RESOLUTION_MEDIUM[] = "RESOLUTION_MEDIUM"; -static char __pyx_k_error_open_device[] = "error_open_device"; -static char __pyx_k_update_tilt_state[] = "update_tilt_state"; -static char __pyx_k_DEPTH_10BIT_PACKED[] = "DEPTH_10BIT_PACKED"; -static char __pyx_k_DEPTH_11BIT_PACKED[] = "DEPTH_11BIT_PACKED"; -static char __pyx_k_set_depth_callback[] = "set_depth_callback"; -static char __pyx_k_set_video_callback[] = "set_video_callback"; -static char __pyx_k_LED_BLINK_RED_YELLOW[] = "LED_BLINK_RED_YELLOW"; -static char __pyx_k_VIDEO_IR_10BIT_PACKED[] = "VIDEO_IR_10BIT_PACKED"; -static char __pyx_k_ndarray_is_not_C_contiguous[] = "ndarray is not C contiguous"; -static char __pyx_k_Error_Can_t_open_device_1_is_it[] = "Error: Can't open device. 1.) is it plugged in? 2.) Read the README"; -static char __pyx_k_unknown_dtype_code_in_numpy_pxd[] = "unknown dtype code in numpy.pxd (%d)"; -static char __pyx_k_Cannot_create_instances_of_CtxPt[] = "Cannot create instances of CtxPtr from Python"; -static char __pyx_k_Cannot_create_instances_of_DevPt[] = "Cannot create instances of DevPtr from Python"; -static char __pyx_k_Cannot_create_instances_of_State[] = "Cannot create instances of StatePtr from Python"; -static char __pyx_k_Conversion_not_implemented_for_t[] = "Conversion not implemented for type [%d]"; -static char __pyx_k_Format_string_allocated_too_shor[] = "Format string allocated too short, see comment in numpy.pxd"; -static char __pyx_k_Non_native_byte_order_not_suppor[] = "Non-native byte order not supported"; -static char __pyx_k_This_kills_the_runloop_raise_fro[] = "This kills the runloop, raise from the body only"; -static char __pyx_k_What_kind_of_system_are_you_usin[] = "What kind of system are you using?!"; -static char __pyx_k_ndarray_is_not_Fortran_contiguou[] = "ndarray is not Fortran contiguous"; -static char __pyx_k_Format_string_allocated_too_shor_2[] = "Format string allocated too short."; -static PyObject *__pyx_kp_s_0x_016x; -static PyObject *__pyx_kp_s_0x_08x; -static PyObject *__pyx_kp_s_Cannot_create_instances_of_CtxPt; -static PyObject *__pyx_kp_s_Cannot_create_instances_of_DevPt; -static PyObject *__pyx_kp_s_Cannot_create_instances_of_State; -static PyObject *__pyx_kp_s_Conversion_not_implemented_for_t; -static PyObject *__pyx_kp_s_Ctx_Pointer_s; -static PyObject *__pyx_n_s_DEPTH_10BIT; -static PyObject *__pyx_n_s_DEPTH_10BIT_PACKED; -static PyObject *__pyx_n_s_DEPTH_11BIT; -static PyObject *__pyx_n_s_DEPTH_11BIT_PACKED; -static PyObject *__pyx_n_s_DEPTH_MM; -static PyObject *__pyx_n_s_DEPTH_REGISTERED; -static PyObject *__pyx_n_s_DEVICE_AUDIO; -static PyObject *__pyx_n_s_DEVICE_CAMERA; -static PyObject *__pyx_n_s_DEVICE_MOTOR; -static PyObject *__pyx_kp_s_Dev_Pointer_s; -static PyObject *__pyx_kp_s_Error_Can_t_open_device_1_is_it; -static PyObject *__pyx_n_s_Exception; -static PyObject *__pyx_kp_u_Format_string_allocated_too_shor; -static PyObject *__pyx_kp_u_Format_string_allocated_too_shor_2; -static PyObject *__pyx_n_s_Kill; -static PyObject *__pyx_n_s_LED_BLINK_GREEN; -static PyObject *__pyx_n_s_LED_BLINK_RED_YELLOW; -static PyObject *__pyx_n_s_LED_GREEN; -static PyObject *__pyx_n_s_LED_OFF; -static PyObject *__pyx_n_s_LED_RED; -static PyObject *__pyx_n_s_LED_YELLOW; -static PyObject *__pyx_kp_u_Non_native_byte_order_not_suppor; -static PyObject *__pyx_n_s_RESOLUTION_HIGH; -static PyObject *__pyx_n_s_RESOLUTION_LOW; -static PyObject *__pyx_n_s_RESOLUTION_MEDIUM; -static PyObject *__pyx_n_s_RuntimeError; -static PyObject *__pyx_kp_s_State_Pointer_s; -static PyObject *__pyx_kp_s_This_kills_the_runloop_raise_fro; -static PyObject *__pyx_n_s_TypeError; -static PyObject *__pyx_n_s_VIDEO_BAYER; -static PyObject *__pyx_n_s_VIDEO_IR_10BIT; -static PyObject *__pyx_n_s_VIDEO_IR_10BIT_PACKED; -static PyObject *__pyx_n_s_VIDEO_IR_8BIT; -static PyObject *__pyx_n_s_VIDEO_RGB; -static PyObject *__pyx_n_s_VIDEO_YUV_RAW; -static PyObject *__pyx_n_s_VIDEO_YUV_RGB; -static PyObject *__pyx_n_s_ValueError; -static PyObject *__pyx_kp_s_What_kind_of_system_are_you_usin; -static PyObject *__pyx_n_s_accelerometer_x; -static PyObject *__pyx_n_s_accelerometer_y; -static PyObject *__pyx_n_s_accelerometer_z; -static PyObject *__pyx_n_s_angle; -static PyObject *__pyx_n_s_base_runloop; -static PyObject *__pyx_n_s_body; -static PyObject *__pyx_n_s_cb; -static PyObject *__pyx_n_s_close_device; -static PyObject *__pyx_n_s_ctx; -static PyObject *__pyx_n_s_ctxp; -static PyObject *__pyx_n_s_data; -static PyObject *__pyx_n_s_depth; -static PyObject *__pyx_n_s_depth_cb; -static PyObject *__pyx_n_s_dev; -static PyObject *__pyx_n_s_devp; -static PyObject *__pyx_n_s_dims; -static PyObject *__pyx_n_s_doc; -static PyObject *__pyx_n_s_end; -static PyObject *__pyx_n_s_error_open_device; -static PyObject *__pyx_n_s_file; -static PyObject *__pyx_n_s_format; -static PyObject *__pyx_n_s_format_2; -static PyObject *__pyx_n_s_freenect; -static PyObject *__pyx_kp_s_freenect_pyx; -static PyObject *__pyx_n_s_get_accel; -static PyObject *__pyx_n_s_get_accelx; -static PyObject *__pyx_n_s_get_accely; -static PyObject *__pyx_n_s_get_accelz; -static PyObject *__pyx_n_s_get_depth_format; -static PyObject *__pyx_n_s_get_mks_accel; -static PyObject *__pyx_n_s_get_tilt_angle; -static PyObject *__pyx_n_s_get_tilt_degs; -static PyObject *__pyx_n_s_get_tilt_state; -static PyObject *__pyx_n_s_get_tilt_status; -static PyObject *__pyx_n_s_get_video_format; -static PyObject *__pyx_n_s_import; -static PyObject *__pyx_n_s_index; -static PyObject *__pyx_n_s_index_2; -static PyObject *__pyx_n_s_main; -static PyObject *__pyx_n_s_mdev; -static PyObject *__pyx_n_s_metaclass; -static PyObject *__pyx_n_s_mode; -static PyObject *__pyx_n_s_module; -static PyObject *__pyx_kp_u_ndarray_is_not_C_contiguous; -static PyObject *__pyx_kp_u_ndarray_is_not_Fortran_contiguou; -static PyObject *__pyx_n_s_np; -static PyObject *__pyx_n_s_num_devices; -static PyObject *__pyx_n_s_numpy; -static PyObject *__pyx_n_s_option; -static PyObject *__pyx_n_s_out; -static PyObject *__pyx_n_s_prepare; -static PyObject *__pyx_n_s_print; -static PyObject *__pyx_n_s_process_events; -static PyObject *__pyx_n_s_property; -static PyObject *__pyx_n_s_qualname; -static PyObject *__pyx_n_s_range; -static PyObject *__pyx_n_s_res; -static PyObject *__pyx_n_s_runloop; -static PyObject *__pyx_n_s_set_depth_callback; -static PyObject *__pyx_n_s_set_depth_mode; -static PyObject *__pyx_n_s_set_led; -static PyObject *__pyx_n_s_set_tilt_degs; -static PyObject *__pyx_n_s_set_video_callback; -static PyObject *__pyx_n_s_set_video_mode; -static PyObject *__pyx_n_s_shutdown; -static PyObject *__pyx_n_s_start_depth; -static PyObject *__pyx_n_s_start_video; -static PyObject *__pyx_n_s_state; -static PyObject *__pyx_n_s_state_out; -static PyObject *__pyx_n_s_stop_depth; -static PyObject *__pyx_n_s_stop_video; -static PyObject *__pyx_n_s_sync_get_depth; -static PyObject *__pyx_n_s_sync_get_video; -static PyObject *__pyx_n_s_sync_stop; -static PyObject *__pyx_n_s_test; -static PyObject *__pyx_n_s_tilt_angle; -static PyObject *__pyx_n_s_tilt_status; -static PyObject *__pyx_n_s_timestamp; -static PyObject *__pyx_kp_u_unknown_dtype_code_in_numpy_pxd; -static PyObject *__pyx_n_s_update_tilt_state; -static PyObject *__pyx_n_s_video; -static PyObject *__pyx_n_s_video_cb; -static PyObject *__pyx_n_s_x; -static PyObject *__pyx_n_s_y; -static PyObject *__pyx_n_s_z; -static PyObject *__pyx_int_0; -static PyObject *__pyx_k__5; -static PyObject *__pyx_k__6; -static PyObject *__pyx_tuple_; -static PyObject *__pyx_tuple__2; -static PyObject *__pyx_tuple__3; -static PyObject *__pyx_tuple__4; -static PyObject *__pyx_tuple__7; -static PyObject *__pyx_tuple__8; -static PyObject *__pyx_tuple__9; -static PyObject *__pyx_tuple__10; -static PyObject *__pyx_tuple__11; -static PyObject *__pyx_tuple__12; -static PyObject *__pyx_tuple__13; -static PyObject *__pyx_tuple__15; -static PyObject *__pyx_tuple__17; -static PyObject *__pyx_tuple__19; -static PyObject *__pyx_tuple__21; -static PyObject *__pyx_tuple__23; -static PyObject *__pyx_tuple__25; -static PyObject *__pyx_tuple__27; -static PyObject *__pyx_tuple__29; -static PyObject *__pyx_tuple__31; -static PyObject *__pyx_tuple__33; -static PyObject *__pyx_tuple__35; -static PyObject *__pyx_tuple__37; -static PyObject *__pyx_tuple__39; -static PyObject *__pyx_tuple__41; -static PyObject *__pyx_tuple__43; -static PyObject *__pyx_tuple__45; -static PyObject *__pyx_tuple__47; -static PyObject *__pyx_tuple__49; -static PyObject *__pyx_tuple__52; -static PyObject *__pyx_tuple__54; -static PyObject *__pyx_tuple__56; -static PyObject *__pyx_tuple__58; -static PyObject *__pyx_tuple__60; -static PyObject *__pyx_tuple__62; -static PyObject *__pyx_codeobj__14; -static PyObject *__pyx_codeobj__16; -static PyObject *__pyx_codeobj__18; -static PyObject *__pyx_codeobj__20; -static PyObject *__pyx_codeobj__22; -static PyObject *__pyx_codeobj__24; -static PyObject *__pyx_codeobj__26; -static PyObject *__pyx_codeobj__28; -static PyObject *__pyx_codeobj__30; -static PyObject *__pyx_codeobj__32; -static PyObject *__pyx_codeobj__34; -static PyObject *__pyx_codeobj__36; -static PyObject *__pyx_codeobj__38; -static PyObject *__pyx_codeobj__40; -static PyObject *__pyx_codeobj__42; -static PyObject *__pyx_codeobj__44; -static PyObject *__pyx_codeobj__46; -static PyObject *__pyx_codeobj__48; -static PyObject *__pyx_codeobj__50; -static PyObject *__pyx_codeobj__51; -static PyObject *__pyx_codeobj__53; -static PyObject *__pyx_codeobj__55; -static PyObject *__pyx_codeobj__57; -static PyObject *__pyx_codeobj__59; -static PyObject *__pyx_codeobj__61; -static PyObject *__pyx_codeobj__63; -static PyObject *__pyx_codeobj__64; - -/* "freenect.pyx":168 - * DEVICE_AUDIO = FREENECT_DEVICE_AUDIO - * - * cdef inline str _format_ptr(void *ptr): # <<<<<<<<<<<<<< - * if sizeof(void *) == 4: - * return "0x%08x" % ptr - */ - -static CYTHON_INLINE PyObject *__pyx_f_8freenect__format_ptr(void *__pyx_v_ptr) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("_format_ptr", 0); - - /* "freenect.pyx":169 - * - * cdef inline str _format_ptr(void *ptr): - * if sizeof(void *) == 4: # <<<<<<<<<<<<<< - * return "0x%08x" % ptr - * elif sizeof(void *) == 8: - */ - __pyx_t_1 = (((sizeof(void *)) == 4) != 0); - if (__pyx_t_1) { - - /* "freenect.pyx":170 - * cdef inline str _format_ptr(void *ptr): - * if sizeof(void *) == 4: - * return "0x%08x" % ptr # <<<<<<<<<<<<<< - * elif sizeof(void *) == 8: - * return "0x%016x" % ptr - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = PyInt_FromSsize_t(((Py_ssize_t)__pyx_v_ptr)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_0x_08x, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (!(likely(PyString_CheckExact(__pyx_t_3))||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = ((PyObject*)__pyx_t_3); - __pyx_t_3 = 0; - goto __pyx_L0; - } - - /* "freenect.pyx":171 - * if sizeof(void *) == 4: - * return "0x%08x" % ptr - * elif sizeof(void *) == 8: # <<<<<<<<<<<<<< - * return "0x%016x" % ptr - * else: - */ - __pyx_t_1 = (((sizeof(void *)) == 8) != 0); - if (__pyx_t_1) { - - /* "freenect.pyx":172 - * return "0x%08x" % ptr - * elif sizeof(void *) == 8: - * return "0x%016x" % ptr # <<<<<<<<<<<<<< - * else: - * raise TypeError("What kind of system are you using?!") - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = PyInt_FromSsize_t(((Py_ssize_t)__pyx_v_ptr)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_0x_016x, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (!(likely(PyString_CheckExact(__pyx_t_2))||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_2)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = ((PyObject*)__pyx_t_2); - __pyx_t_2 = 0; - goto __pyx_L0; - } - /*else*/ { - - /* "freenect.pyx":174 - * return "0x%016x" % ptr - * else: - * raise TypeError("What kind of system are you using?!") # <<<<<<<<<<<<<< - * - * cdef class CtxPtr: - */ - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_Raise(__pyx_t_2, 0, 0, 0); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - - /* "freenect.pyx":168 - * DEVICE_AUDIO = FREENECT_DEVICE_AUDIO - * - * cdef inline str _format_ptr(void *ptr): # <<<<<<<<<<<<<< - * if sizeof(void *) == 4: - * return "0x%08x" % ptr - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_AddTraceback("freenect._format_ptr", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "freenect.pyx":178 - * cdef class CtxPtr: - * cdef freenect_context* _ptr - * def __init__(self): # <<<<<<<<<<<<<< - * # Safety: do not allow Python to create instances as they would be NULL - * raise TypeError("Cannot create instances of CtxPtr from Python") - */ - -/* Python wrapper */ -static int __pyx_pw_8freenect_6CtxPtr_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static int __pyx_pw_8freenect_6CtxPtr_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); - if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) { - __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;} - if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1; - __pyx_r = __pyx_pf_8freenect_6CtxPtr___init__(((struct __pyx_obj_8freenect_CtxPtr *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static int __pyx_pf_8freenect_6CtxPtr___init__(CYTHON_UNUSED struct __pyx_obj_8freenect_CtxPtr *__pyx_v_self) { - int __pyx_r; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__init__", 0); - - /* "freenect.pyx":180 - * def __init__(self): - * # Safety: do not allow Python to create instances as they would be NULL - * raise TypeError("Cannot create instances of CtxPtr from Python") # <<<<<<<<<<<<<< - * - * def __repr__(self): - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_Raise(__pyx_t_1, 0, 0, 0); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - - /* "freenect.pyx":178 - * cdef class CtxPtr: - * cdef freenect_context* _ptr - * def __init__(self): # <<<<<<<<<<<<<< - * # Safety: do not allow Python to create instances as they would be NULL - * raise TypeError("Cannot create instances of CtxPtr from Python") - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("freenect.CtxPtr.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "freenect.pyx":182 - * raise TypeError("Cannot create instances of CtxPtr from Python") - * - * def __repr__(self): # <<<<<<<<<<<<<< - * return "" % _format_ptr(self._ptr) - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_8freenect_6CtxPtr_3__repr__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pw_8freenect_6CtxPtr_3__repr__(PyObject *__pyx_v_self) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0); - __pyx_r = __pyx_pf_8freenect_6CtxPtr_2__repr__(((struct __pyx_obj_8freenect_CtxPtr *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_8freenect_6CtxPtr_2__repr__(struct __pyx_obj_8freenect_CtxPtr *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__repr__", 0); - - /* "freenect.pyx":183 - * - * def __repr__(self): - * return "" % _format_ptr(self._ptr) # <<<<<<<<<<<<<< - * - * cdef class DevPtr: - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_8freenect__format_ptr(__pyx_v_self->_ptr); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_Ctx_Pointer_s, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - goto __pyx_L0; - - /* "freenect.pyx":182 - * raise TypeError("Cannot create instances of CtxPtr from Python") - * - * def __repr__(self): # <<<<<<<<<<<<<< - * return "" % _format_ptr(self._ptr) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("freenect.CtxPtr.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "freenect.pyx":188 - * cdef freenect_device* _ptr - * cdef CtxPtr ctx - * def __init__(self): # <<<<<<<<<<<<<< - * # Safety: do not allow Python to create instances as they would be NULL - * raise TypeError("Cannot create instances of DevPtr from Python") - */ - -/* Python wrapper */ -static int __pyx_pw_8freenect_6DevPtr_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static int __pyx_pw_8freenect_6DevPtr_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); - if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) { - __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;} - if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1; - __pyx_r = __pyx_pf_8freenect_6DevPtr___init__(((struct __pyx_obj_8freenect_DevPtr *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static int __pyx_pf_8freenect_6DevPtr___init__(CYTHON_UNUSED struct __pyx_obj_8freenect_DevPtr *__pyx_v_self) { - int __pyx_r; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__init__", 0); - - /* "freenect.pyx":190 - * def __init__(self): - * # Safety: do not allow Python to create instances as they would be NULL - * raise TypeError("Cannot create instances of DevPtr from Python") # <<<<<<<<<<<<<< - * - * def __repr__(self): - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_Raise(__pyx_t_1, 0, 0, 0); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - - /* "freenect.pyx":188 - * cdef freenect_device* _ptr - * cdef CtxPtr ctx - * def __init__(self): # <<<<<<<<<<<<<< - * # Safety: do not allow Python to create instances as they would be NULL - * raise TypeError("Cannot create instances of DevPtr from Python") - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("freenect.DevPtr.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "freenect.pyx":192 - * raise TypeError("Cannot create instances of DevPtr from Python") - * - * def __repr__(self): # <<<<<<<<<<<<<< - * return "" % _format_ptr(self._ptr) - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_8freenect_6DevPtr_3__repr__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pw_8freenect_6DevPtr_3__repr__(PyObject *__pyx_v_self) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0); - __pyx_r = __pyx_pf_8freenect_6DevPtr_2__repr__(((struct __pyx_obj_8freenect_DevPtr *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_8freenect_6DevPtr_2__repr__(struct __pyx_obj_8freenect_DevPtr *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__repr__", 0); - - /* "freenect.pyx":193 - * - * def __repr__(self): - * return "" % _format_ptr(self._ptr) # <<<<<<<<<<<<<< - * - * cdef class StatePtr: - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_8freenect__format_ptr(__pyx_v_self->_ptr); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_Dev_Pointer_s, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - goto __pyx_L0; - - /* "freenect.pyx":192 - * raise TypeError("Cannot create instances of DevPtr from Python") - * - * def __repr__(self): # <<<<<<<<<<<<<< - * return "" % _format_ptr(self._ptr) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("freenect.DevPtr.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "freenect.pyx":197 - * cdef class StatePtr: - * cdef freenect_raw_tilt_state* _ptr - * def __init__(self): # <<<<<<<<<<<<<< - * # Safety: do not allow Python to create instances as they would be NULL - * raise TypeError("Cannot create instances of StatePtr from Python") - */ - -/* Python wrapper */ -static int __pyx_pw_8freenect_8StatePtr_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static int __pyx_pw_8freenect_8StatePtr_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); - if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) { - __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;} - if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1; - __pyx_r = __pyx_pf_8freenect_8StatePtr___init__(((struct __pyx_obj_8freenect_StatePtr *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static int __pyx_pf_8freenect_8StatePtr___init__(CYTHON_UNUSED struct __pyx_obj_8freenect_StatePtr *__pyx_v_self) { - int __pyx_r; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__init__", 0); - - /* "freenect.pyx":199 - * def __init__(self): - * # Safety: do not allow Python to create instances as they would be NULL - * raise TypeError("Cannot create instances of StatePtr from Python") # <<<<<<<<<<<<<< - * - * def __repr__(self): - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_Raise(__pyx_t_1, 0, 0, 0); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - - /* "freenect.pyx":197 - * cdef class StatePtr: - * cdef freenect_raw_tilt_state* _ptr - * def __init__(self): # <<<<<<<<<<<<<< - * # Safety: do not allow Python to create instances as they would be NULL - * raise TypeError("Cannot create instances of StatePtr from Python") - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("freenect.StatePtr.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "freenect.pyx":201 - * raise TypeError("Cannot create instances of StatePtr from Python") - * - * def __repr__(self): # <<<<<<<<<<<<<< - * return "" % _format_ptr(self._ptr) - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_8freenect_8StatePtr_3__repr__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pw_8freenect_8StatePtr_3__repr__(PyObject *__pyx_v_self) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0); - __pyx_r = __pyx_pf_8freenect_8StatePtr_2__repr__(((struct __pyx_obj_8freenect_StatePtr *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_8freenect_8StatePtr_2__repr__(struct __pyx_obj_8freenect_StatePtr *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__repr__", 0); - - /* "freenect.pyx":202 - * - * def __repr__(self): - * return "" % _format_ptr(self._ptr) # <<<<<<<<<<<<<< - * - * def _get_accelx(self): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_8freenect__format_ptr(__pyx_v_self->_ptr); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_State_Pointer_s, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - goto __pyx_L0; - - /* "freenect.pyx":201 - * raise TypeError("Cannot create instances of StatePtr from Python") - * - * def __repr__(self): # <<<<<<<<<<<<<< - * return "" % _format_ptr(self._ptr) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("freenect.StatePtr.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "freenect.pyx":204 - * return "" % _format_ptr(self._ptr) - * - * def _get_accelx(self): # <<<<<<<<<<<<<< - * return int(self._ptr.accelerometer_x) - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_8freenect_8StatePtr_5_get_accelx(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw_8freenect_8StatePtr_5_get_accelx(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("_get_accelx (wrapper)", 0); - __pyx_r = __pyx_pf_8freenect_8StatePtr_4_get_accelx(((struct __pyx_obj_8freenect_StatePtr *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_8freenect_8StatePtr_4_get_accelx(struct __pyx_obj_8freenect_StatePtr *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("_get_accelx", 0); - - /* "freenect.pyx":205 - * - * def _get_accelx(self): - * return int(self._ptr.accelerometer_x) # <<<<<<<<<<<<<< - * - * def _get_accely(self): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int16_t(__pyx_v_self->_ptr->accelerometer_x); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_1); - __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyInt_Type))), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "freenect.pyx":204 - * return "" % _format_ptr(self._ptr) - * - * def _get_accelx(self): # <<<<<<<<<<<<<< - * return int(self._ptr.accelerometer_x) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("freenect.StatePtr._get_accelx", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "freenect.pyx":207 - * return int(self._ptr.accelerometer_x) - * - * def _get_accely(self): # <<<<<<<<<<<<<< - * return int(self._ptr.accelerometer_y) - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_8freenect_8StatePtr_7_get_accely(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw_8freenect_8StatePtr_7_get_accely(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("_get_accely (wrapper)", 0); - __pyx_r = __pyx_pf_8freenect_8StatePtr_6_get_accely(((struct __pyx_obj_8freenect_StatePtr *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_8freenect_8StatePtr_6_get_accely(struct __pyx_obj_8freenect_StatePtr *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("_get_accely", 0); - - /* "freenect.pyx":208 - * - * def _get_accely(self): - * return int(self._ptr.accelerometer_y) # <<<<<<<<<<<<<< - * - * def _get_accelz(self): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int16_t(__pyx_v_self->_ptr->accelerometer_y); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_1); - __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyInt_Type))), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "freenect.pyx":207 - * return int(self._ptr.accelerometer_x) - * - * def _get_accely(self): # <<<<<<<<<<<<<< - * return int(self._ptr.accelerometer_y) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("freenect.StatePtr._get_accely", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "freenect.pyx":210 - * return int(self._ptr.accelerometer_y) - * - * def _get_accelz(self): # <<<<<<<<<<<<<< - * return int(self._ptr.accelerometer_z) - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_8freenect_8StatePtr_9_get_accelz(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw_8freenect_8StatePtr_9_get_accelz(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("_get_accelz (wrapper)", 0); - __pyx_r = __pyx_pf_8freenect_8StatePtr_8_get_accelz(((struct __pyx_obj_8freenect_StatePtr *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_8freenect_8StatePtr_8_get_accelz(struct __pyx_obj_8freenect_StatePtr *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("_get_accelz", 0); - - /* "freenect.pyx":211 - * - * def _get_accelz(self): - * return int(self._ptr.accelerometer_z) # <<<<<<<<<<<<<< - * - * def _get_tilt_angle(self): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int16_t(__pyx_v_self->_ptr->accelerometer_z); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_1); - __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyInt_Type))), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "freenect.pyx":210 - * return int(self._ptr.accelerometer_y) - * - * def _get_accelz(self): # <<<<<<<<<<<<<< - * return int(self._ptr.accelerometer_z) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("freenect.StatePtr._get_accelz", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "freenect.pyx":213 - * return int(self._ptr.accelerometer_z) - * - * def _get_tilt_angle(self): # <<<<<<<<<<<<<< - * return int(self._ptr.tilt_angle) - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_8freenect_8StatePtr_11_get_tilt_angle(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw_8freenect_8StatePtr_11_get_tilt_angle(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("_get_tilt_angle (wrapper)", 0); - __pyx_r = __pyx_pf_8freenect_8StatePtr_10_get_tilt_angle(((struct __pyx_obj_8freenect_StatePtr *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_8freenect_8StatePtr_10_get_tilt_angle(struct __pyx_obj_8freenect_StatePtr *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("_get_tilt_angle", 0); - - /* "freenect.pyx":214 - * - * def _get_tilt_angle(self): - * return int(self._ptr.tilt_angle) # <<<<<<<<<<<<<< - * - * def _get_tilt_status(self): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int8_t(__pyx_v_self->_ptr->tilt_angle); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_1); - __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyInt_Type))), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "freenect.pyx":213 - * return int(self._ptr.accelerometer_z) - * - * def _get_tilt_angle(self): # <<<<<<<<<<<<<< - * return int(self._ptr.tilt_angle) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("freenect.StatePtr._get_tilt_angle", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "freenect.pyx":216 - * return int(self._ptr.tilt_angle) - * - * def _get_tilt_status(self): # <<<<<<<<<<<<<< - * return int(self._ptr.tilt_status) - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_8freenect_8StatePtr_13_get_tilt_status(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw_8freenect_8StatePtr_13_get_tilt_status(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("_get_tilt_status (wrapper)", 0); - __pyx_r = __pyx_pf_8freenect_8StatePtr_12_get_tilt_status(((struct __pyx_obj_8freenect_StatePtr *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_8freenect_8StatePtr_12_get_tilt_status(struct __pyx_obj_8freenect_StatePtr *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("_get_tilt_status", 0); - - /* "freenect.pyx":217 - * - * def _get_tilt_status(self): - * return int(self._ptr.tilt_status) # <<<<<<<<<<<<<< - * - * accelerometer_x = property(_get_accelx) - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyInt_FromLong(__pyx_v_self->_ptr->tilt_status); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_1); - __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyInt_Type))), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "freenect.pyx":216 - * return int(self._ptr.tilt_angle) - * - * def _get_tilt_status(self): # <<<<<<<<<<<<<< - * return int(self._ptr.tilt_status) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("freenect.StatePtr._get_tilt_status", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "freenect.pyx":225 - * tilt_status = property(_get_tilt_status) - * - * def set_depth_mode(DevPtr dev, int res, int mode): # <<<<<<<<<<<<<< - * return freenect_set_depth_mode(dev._ptr, freenect_find_depth_mode(res, mode)) - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_8freenect_1set_depth_mode(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyMethodDef __pyx_mdef_8freenect_1set_depth_mode = {__Pyx_NAMESTR("set_depth_mode"), (PyCFunction)__pyx_pw_8freenect_1set_depth_mode, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}; -static PyObject *__pyx_pw_8freenect_1set_depth_mode(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - struct __pyx_obj_8freenect_DevPtr *__pyx_v_dev = 0; - int __pyx_v_res; - int __pyx_v_mode; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("set_depth_mode (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_dev,&__pyx_n_s_res,&__pyx_n_s_mode,0}; - PyObject* values[3] = {0,0,0}; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dev)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - case 1: - if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_res)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("set_depth_mode", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - case 2: - if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_mode)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("set_depth_mode", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "set_depth_mode") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - } - __pyx_v_dev = ((struct __pyx_obj_8freenect_DevPtr *)values[0]); - __pyx_v_res = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_res == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_v_mode = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_mode == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("set_depth_mode", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_L3_error:; - __Pyx_AddTraceback("freenect.set_depth_mode", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dev), __pyx_ptype_8freenect_DevPtr, 1, "dev", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = __pyx_pf_8freenect_set_depth_mode(__pyx_self, __pyx_v_dev, __pyx_v_res, __pyx_v_mode); - - /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_8freenect_set_depth_mode(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_DevPtr *__pyx_v_dev, int __pyx_v_res, int __pyx_v_mode) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("set_depth_mode", 0); - - /* "freenect.pyx":226 - * - * def set_depth_mode(DevPtr dev, int res, int mode): - * return freenect_set_depth_mode(dev._ptr, freenect_find_depth_mode(res, mode)) # <<<<<<<<<<<<<< - * - * def set_video_mode(DevPtr dev, int res, int mode): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(freenect_set_depth_mode(__pyx_v_dev->_ptr, freenect_find_depth_mode(__pyx_v_res, __pyx_v_mode))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "freenect.pyx":225 - * tilt_status = property(_get_tilt_status) - * - * def set_depth_mode(DevPtr dev, int res, int mode): # <<<<<<<<<<<<<< - * return freenect_set_depth_mode(dev._ptr, freenect_find_depth_mode(res, mode)) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("freenect.set_depth_mode", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "freenect.pyx":228 - * return freenect_set_depth_mode(dev._ptr, freenect_find_depth_mode(res, mode)) - * - * def set_video_mode(DevPtr dev, int res, int mode): # <<<<<<<<<<<<<< - * return freenect_set_video_mode(dev._ptr, freenect_find_video_mode(res, mode)) - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_8freenect_3set_video_mode(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyMethodDef __pyx_mdef_8freenect_3set_video_mode = {__Pyx_NAMESTR("set_video_mode"), (PyCFunction)__pyx_pw_8freenect_3set_video_mode, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}; -static PyObject *__pyx_pw_8freenect_3set_video_mode(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - struct __pyx_obj_8freenect_DevPtr *__pyx_v_dev = 0; - int __pyx_v_res; - int __pyx_v_mode; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("set_video_mode (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_dev,&__pyx_n_s_res,&__pyx_n_s_mode,0}; - PyObject* values[3] = {0,0,0}; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dev)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - case 1: - if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_res)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("set_video_mode", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - case 2: - if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_mode)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("set_video_mode", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "set_video_mode") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - } - __pyx_v_dev = ((struct __pyx_obj_8freenect_DevPtr *)values[0]); - __pyx_v_res = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_res == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_v_mode = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_mode == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("set_video_mode", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_L3_error:; - __Pyx_AddTraceback("freenect.set_video_mode", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dev), __pyx_ptype_8freenect_DevPtr, 1, "dev", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = __pyx_pf_8freenect_2set_video_mode(__pyx_self, __pyx_v_dev, __pyx_v_res, __pyx_v_mode); - - /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_8freenect_2set_video_mode(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_DevPtr *__pyx_v_dev, int __pyx_v_res, int __pyx_v_mode) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("set_video_mode", 0); - - /* "freenect.pyx":229 - * - * def set_video_mode(DevPtr dev, int res, int mode): - * return freenect_set_video_mode(dev._ptr, freenect_find_video_mode(res, mode)) # <<<<<<<<<<<<<< - * - * def get_depth_format(DevPtr dev): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(freenect_set_video_mode(__pyx_v_dev->_ptr, freenect_find_video_mode(__pyx_v_res, __pyx_v_mode))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "freenect.pyx":228 - * return freenect_set_depth_mode(dev._ptr, freenect_find_depth_mode(res, mode)) - * - * def set_video_mode(DevPtr dev, int res, int mode): # <<<<<<<<<<<<<< - * return freenect_set_video_mode(dev._ptr, freenect_find_video_mode(res, mode)) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("freenect.set_video_mode", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "freenect.pyx":231 - * return freenect_set_video_mode(dev._ptr, freenect_find_video_mode(res, mode)) - * - * def get_depth_format(DevPtr dev): # <<<<<<<<<<<<<< - * return freenect_get_current_depth_mode(dev._ptr).video_format - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_8freenect_5get_depth_format(PyObject *__pyx_self, PyObject *__pyx_v_dev); /*proto*/ -static PyMethodDef __pyx_mdef_8freenect_5get_depth_format = {__Pyx_NAMESTR("get_depth_format"), (PyCFunction)__pyx_pw_8freenect_5get_depth_format, METH_O, __Pyx_DOCSTR(0)}; -static PyObject *__pyx_pw_8freenect_5get_depth_format(PyObject *__pyx_self, PyObject *__pyx_v_dev) { - CYTHON_UNUSED int __pyx_lineno = 0; - CYTHON_UNUSED const char *__pyx_filename = NULL; - CYTHON_UNUSED int __pyx_clineno = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("get_depth_format (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dev), __pyx_ptype_8freenect_DevPtr, 1, "dev", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = __pyx_pf_8freenect_4get_depth_format(__pyx_self, ((struct __pyx_obj_8freenect_DevPtr *)__pyx_v_dev)); - - /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_8freenect_4get_depth_format(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_DevPtr *__pyx_v_dev) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("get_depth_format", 0); - - /* "freenect.pyx":232 - * - * def get_depth_format(DevPtr dev): - * return freenect_get_current_depth_mode(dev._ptr).video_format # <<<<<<<<<<<<<< - * - * def get_video_format(DevPtr dev): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int32_t(freenect_get_current_depth_mode(__pyx_v_dev->_ptr).video_format); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "freenect.pyx":231 - * return freenect_set_video_mode(dev._ptr, freenect_find_video_mode(res, mode)) - * - * def get_depth_format(DevPtr dev): # <<<<<<<<<<<<<< - * return freenect_get_current_depth_mode(dev._ptr).video_format - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("freenect.get_depth_format", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "freenect.pyx":234 - * return freenect_get_current_depth_mode(dev._ptr).video_format - * - * def get_video_format(DevPtr dev): # <<<<<<<<<<<<<< - * return freenect_get_current_video_mode(dev._ptr).video_format - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_8freenect_7get_video_format(PyObject *__pyx_self, PyObject *__pyx_v_dev); /*proto*/ -static PyMethodDef __pyx_mdef_8freenect_7get_video_format = {__Pyx_NAMESTR("get_video_format"), (PyCFunction)__pyx_pw_8freenect_7get_video_format, METH_O, __Pyx_DOCSTR(0)}; -static PyObject *__pyx_pw_8freenect_7get_video_format(PyObject *__pyx_self, PyObject *__pyx_v_dev) { - CYTHON_UNUSED int __pyx_lineno = 0; - CYTHON_UNUSED const char *__pyx_filename = NULL; - CYTHON_UNUSED int __pyx_clineno = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("get_video_format (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dev), __pyx_ptype_8freenect_DevPtr, 1, "dev", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = __pyx_pf_8freenect_6get_video_format(__pyx_self, ((struct __pyx_obj_8freenect_DevPtr *)__pyx_v_dev)); - - /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_8freenect_6get_video_format(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_DevPtr *__pyx_v_dev) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("get_video_format", 0); - - /* "freenect.pyx":235 - * - * def get_video_format(DevPtr dev): - * return freenect_get_current_video_mode(dev._ptr).video_format # <<<<<<<<<<<<<< - * - * def start_depth(DevPtr dev): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int32_t(freenect_get_current_video_mode(__pyx_v_dev->_ptr).video_format); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "freenect.pyx":234 - * return freenect_get_current_depth_mode(dev._ptr).video_format - * - * def get_video_format(DevPtr dev): # <<<<<<<<<<<<<< - * return freenect_get_current_video_mode(dev._ptr).video_format - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("freenect.get_video_format", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "freenect.pyx":237 - * return freenect_get_current_video_mode(dev._ptr).video_format - * - * def start_depth(DevPtr dev): # <<<<<<<<<<<<<< - * return freenect_start_depth(dev._ptr) - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_8freenect_9start_depth(PyObject *__pyx_self, PyObject *__pyx_v_dev); /*proto*/ -static PyMethodDef __pyx_mdef_8freenect_9start_depth = {__Pyx_NAMESTR("start_depth"), (PyCFunction)__pyx_pw_8freenect_9start_depth, METH_O, __Pyx_DOCSTR(0)}; -static PyObject *__pyx_pw_8freenect_9start_depth(PyObject *__pyx_self, PyObject *__pyx_v_dev) { - CYTHON_UNUSED int __pyx_lineno = 0; - CYTHON_UNUSED const char *__pyx_filename = NULL; - CYTHON_UNUSED int __pyx_clineno = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("start_depth (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dev), __pyx_ptype_8freenect_DevPtr, 1, "dev", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = __pyx_pf_8freenect_8start_depth(__pyx_self, ((struct __pyx_obj_8freenect_DevPtr *)__pyx_v_dev)); - - /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_8freenect_8start_depth(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_DevPtr *__pyx_v_dev) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("start_depth", 0); - - /* "freenect.pyx":238 - * - * def start_depth(DevPtr dev): - * return freenect_start_depth(dev._ptr) # <<<<<<<<<<<<<< - * - * def start_video(DevPtr dev): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(freenect_start_depth(__pyx_v_dev->_ptr)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "freenect.pyx":237 - * return freenect_get_current_video_mode(dev._ptr).video_format - * - * def start_depth(DevPtr dev): # <<<<<<<<<<<<<< - * return freenect_start_depth(dev._ptr) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("freenect.start_depth", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "freenect.pyx":240 - * return freenect_start_depth(dev._ptr) - * - * def start_video(DevPtr dev): # <<<<<<<<<<<<<< - * return freenect_start_video(dev._ptr) - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_8freenect_11start_video(PyObject *__pyx_self, PyObject *__pyx_v_dev); /*proto*/ -static PyMethodDef __pyx_mdef_8freenect_11start_video = {__Pyx_NAMESTR("start_video"), (PyCFunction)__pyx_pw_8freenect_11start_video, METH_O, __Pyx_DOCSTR(0)}; -static PyObject *__pyx_pw_8freenect_11start_video(PyObject *__pyx_self, PyObject *__pyx_v_dev) { - CYTHON_UNUSED int __pyx_lineno = 0; - CYTHON_UNUSED const char *__pyx_filename = NULL; - CYTHON_UNUSED int __pyx_clineno = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("start_video (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dev), __pyx_ptype_8freenect_DevPtr, 1, "dev", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = __pyx_pf_8freenect_10start_video(__pyx_self, ((struct __pyx_obj_8freenect_DevPtr *)__pyx_v_dev)); - - /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_8freenect_10start_video(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_DevPtr *__pyx_v_dev) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("start_video", 0); - - /* "freenect.pyx":241 - * - * def start_video(DevPtr dev): - * return freenect_start_video(dev._ptr) # <<<<<<<<<<<<<< - * - * def stop_depth(DevPtr dev): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(freenect_start_video(__pyx_v_dev->_ptr)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "freenect.pyx":240 - * return freenect_start_depth(dev._ptr) - * - * def start_video(DevPtr dev): # <<<<<<<<<<<<<< - * return freenect_start_video(dev._ptr) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("freenect.start_video", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "freenect.pyx":243 - * return freenect_start_video(dev._ptr) - * - * def stop_depth(DevPtr dev): # <<<<<<<<<<<<<< - * return freenect_stop_depth(dev._ptr) - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_8freenect_13stop_depth(PyObject *__pyx_self, PyObject *__pyx_v_dev); /*proto*/ -static PyMethodDef __pyx_mdef_8freenect_13stop_depth = {__Pyx_NAMESTR("stop_depth"), (PyCFunction)__pyx_pw_8freenect_13stop_depth, METH_O, __Pyx_DOCSTR(0)}; -static PyObject *__pyx_pw_8freenect_13stop_depth(PyObject *__pyx_self, PyObject *__pyx_v_dev) { - CYTHON_UNUSED int __pyx_lineno = 0; - CYTHON_UNUSED const char *__pyx_filename = NULL; - CYTHON_UNUSED int __pyx_clineno = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("stop_depth (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dev), __pyx_ptype_8freenect_DevPtr, 1, "dev", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = __pyx_pf_8freenect_12stop_depth(__pyx_self, ((struct __pyx_obj_8freenect_DevPtr *)__pyx_v_dev)); - - /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_8freenect_12stop_depth(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_DevPtr *__pyx_v_dev) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("stop_depth", 0); - - /* "freenect.pyx":244 - * - * def stop_depth(DevPtr dev): - * return freenect_stop_depth(dev._ptr) # <<<<<<<<<<<<<< - * - * def stop_video(DevPtr dev): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(freenect_stop_depth(__pyx_v_dev->_ptr)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "freenect.pyx":243 - * return freenect_start_video(dev._ptr) - * - * def stop_depth(DevPtr dev): # <<<<<<<<<<<<<< - * return freenect_stop_depth(dev._ptr) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("freenect.stop_depth", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "freenect.pyx":246 - * return freenect_stop_depth(dev._ptr) - * - * def stop_video(DevPtr dev): # <<<<<<<<<<<<<< - * return freenect_stop_video(dev._ptr) - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_8freenect_15stop_video(PyObject *__pyx_self, PyObject *__pyx_v_dev); /*proto*/ -static PyMethodDef __pyx_mdef_8freenect_15stop_video = {__Pyx_NAMESTR("stop_video"), (PyCFunction)__pyx_pw_8freenect_15stop_video, METH_O, __Pyx_DOCSTR(0)}; -static PyObject *__pyx_pw_8freenect_15stop_video(PyObject *__pyx_self, PyObject *__pyx_v_dev) { - CYTHON_UNUSED int __pyx_lineno = 0; - CYTHON_UNUSED const char *__pyx_filename = NULL; - CYTHON_UNUSED int __pyx_clineno = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("stop_video (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dev), __pyx_ptype_8freenect_DevPtr, 1, "dev", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = __pyx_pf_8freenect_14stop_video(__pyx_self, ((struct __pyx_obj_8freenect_DevPtr *)__pyx_v_dev)); - - /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_8freenect_14stop_video(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_DevPtr *__pyx_v_dev) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("stop_video", 0); - - /* "freenect.pyx":247 - * - * def stop_video(DevPtr dev): - * return freenect_stop_video(dev._ptr) # <<<<<<<<<<<<<< - * - * def shutdown(CtxPtr ctx): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(freenect_stop_video(__pyx_v_dev->_ptr)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "freenect.pyx":246 - * return freenect_stop_depth(dev._ptr) - * - * def stop_video(DevPtr dev): # <<<<<<<<<<<<<< - * return freenect_stop_video(dev._ptr) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("freenect.stop_video", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "freenect.pyx":249 - * return freenect_stop_video(dev._ptr) - * - * def shutdown(CtxPtr ctx): # <<<<<<<<<<<<<< - * return freenect_shutdown(ctx._ptr) - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_8freenect_17shutdown(PyObject *__pyx_self, PyObject *__pyx_v_ctx); /*proto*/ -static PyMethodDef __pyx_mdef_8freenect_17shutdown = {__Pyx_NAMESTR("shutdown"), (PyCFunction)__pyx_pw_8freenect_17shutdown, METH_O, __Pyx_DOCSTR(0)}; -static PyObject *__pyx_pw_8freenect_17shutdown(PyObject *__pyx_self, PyObject *__pyx_v_ctx) { - CYTHON_UNUSED int __pyx_lineno = 0; - CYTHON_UNUSED const char *__pyx_filename = NULL; - CYTHON_UNUSED int __pyx_clineno = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("shutdown (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_ctx), __pyx_ptype_8freenect_CtxPtr, 1, "ctx", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = __pyx_pf_8freenect_16shutdown(__pyx_self, ((struct __pyx_obj_8freenect_CtxPtr *)__pyx_v_ctx)); - - /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_8freenect_16shutdown(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_CtxPtr *__pyx_v_ctx) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("shutdown", 0); - - /* "freenect.pyx":250 - * - * def shutdown(CtxPtr ctx): - * return freenect_shutdown(ctx._ptr) # <<<<<<<<<<<<<< - * - * def process_events(CtxPtr ctx): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(freenect_shutdown(__pyx_v_ctx->_ptr)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "freenect.pyx":249 - * return freenect_stop_video(dev._ptr) - * - * def shutdown(CtxPtr ctx): # <<<<<<<<<<<<<< - * return freenect_shutdown(ctx._ptr) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("freenect.shutdown", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "freenect.pyx":252 - * return freenect_shutdown(ctx._ptr) - * - * def process_events(CtxPtr ctx): # <<<<<<<<<<<<<< - * return freenect_process_events(ctx._ptr) - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_8freenect_19process_events(PyObject *__pyx_self, PyObject *__pyx_v_ctx); /*proto*/ -static PyMethodDef __pyx_mdef_8freenect_19process_events = {__Pyx_NAMESTR("process_events"), (PyCFunction)__pyx_pw_8freenect_19process_events, METH_O, __Pyx_DOCSTR(0)}; -static PyObject *__pyx_pw_8freenect_19process_events(PyObject *__pyx_self, PyObject *__pyx_v_ctx) { - CYTHON_UNUSED int __pyx_lineno = 0; - CYTHON_UNUSED const char *__pyx_filename = NULL; - CYTHON_UNUSED int __pyx_clineno = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("process_events (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_ctx), __pyx_ptype_8freenect_CtxPtr, 1, "ctx", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = __pyx_pf_8freenect_18process_events(__pyx_self, ((struct __pyx_obj_8freenect_CtxPtr *)__pyx_v_ctx)); - - /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_8freenect_18process_events(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_CtxPtr *__pyx_v_ctx) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("process_events", 0); - - /* "freenect.pyx":253 - * - * def process_events(CtxPtr ctx): - * return freenect_process_events(ctx._ptr) # <<<<<<<<<<<<<< - * - * def num_devices(CtxPtr ctx): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(freenect_process_events(__pyx_v_ctx->_ptr)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "freenect.pyx":252 - * return freenect_shutdown(ctx._ptr) - * - * def process_events(CtxPtr ctx): # <<<<<<<<<<<<<< - * return freenect_process_events(ctx._ptr) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("freenect.process_events", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "freenect.pyx":255 - * return freenect_process_events(ctx._ptr) - * - * def num_devices(CtxPtr ctx): # <<<<<<<<<<<<<< - * return freenect_num_devices(ctx._ptr) - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_8freenect_21num_devices(PyObject *__pyx_self, PyObject *__pyx_v_ctx); /*proto*/ -static PyMethodDef __pyx_mdef_8freenect_21num_devices = {__Pyx_NAMESTR("num_devices"), (PyCFunction)__pyx_pw_8freenect_21num_devices, METH_O, __Pyx_DOCSTR(0)}; -static PyObject *__pyx_pw_8freenect_21num_devices(PyObject *__pyx_self, PyObject *__pyx_v_ctx) { - CYTHON_UNUSED int __pyx_lineno = 0; - CYTHON_UNUSED const char *__pyx_filename = NULL; - CYTHON_UNUSED int __pyx_clineno = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("num_devices (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_ctx), __pyx_ptype_8freenect_CtxPtr, 1, "ctx", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = __pyx_pf_8freenect_20num_devices(__pyx_self, ((struct __pyx_obj_8freenect_CtxPtr *)__pyx_v_ctx)); - - /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_8freenect_20num_devices(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_CtxPtr *__pyx_v_ctx) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("num_devices", 0); - - /* "freenect.pyx":256 - * - * def num_devices(CtxPtr ctx): - * return freenect_num_devices(ctx._ptr) # <<<<<<<<<<<<<< - * - * def close_device(DevPtr dev): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(freenect_num_devices(__pyx_v_ctx->_ptr)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "freenect.pyx":255 - * return freenect_process_events(ctx._ptr) - * - * def num_devices(CtxPtr ctx): # <<<<<<<<<<<<<< - * return freenect_num_devices(ctx._ptr) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("freenect.num_devices", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "freenect.pyx":258 - * return freenect_num_devices(ctx._ptr) - * - * def close_device(DevPtr dev): # <<<<<<<<<<<<<< - * return freenect_close_device(dev._ptr) - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_8freenect_23close_device(PyObject *__pyx_self, PyObject *__pyx_v_dev); /*proto*/ -static PyMethodDef __pyx_mdef_8freenect_23close_device = {__Pyx_NAMESTR("close_device"), (PyCFunction)__pyx_pw_8freenect_23close_device, METH_O, __Pyx_DOCSTR(0)}; -static PyObject *__pyx_pw_8freenect_23close_device(PyObject *__pyx_self, PyObject *__pyx_v_dev) { - CYTHON_UNUSED int __pyx_lineno = 0; - CYTHON_UNUSED const char *__pyx_filename = NULL; - CYTHON_UNUSED int __pyx_clineno = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("close_device (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dev), __pyx_ptype_8freenect_DevPtr, 1, "dev", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 258; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = __pyx_pf_8freenect_22close_device(__pyx_self, ((struct __pyx_obj_8freenect_DevPtr *)__pyx_v_dev)); - - /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_8freenect_22close_device(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_DevPtr *__pyx_v_dev) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("close_device", 0); - - /* "freenect.pyx":259 - * - * def close_device(DevPtr dev): - * return freenect_close_device(dev._ptr) # <<<<<<<<<<<<<< - * - * def set_tilt_degs(DevPtr dev, float angle): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(freenect_close_device(__pyx_v_dev->_ptr)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "freenect.pyx":258 - * return freenect_num_devices(ctx._ptr) - * - * def close_device(DevPtr dev): # <<<<<<<<<<<<<< - * return freenect_close_device(dev._ptr) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("freenect.close_device", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "freenect.pyx":261 - * return freenect_close_device(dev._ptr) - * - * def set_tilt_degs(DevPtr dev, float angle): # <<<<<<<<<<<<<< - * freenect_set_tilt_degs(dev._ptr, angle) - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_8freenect_25set_tilt_degs(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyMethodDef __pyx_mdef_8freenect_25set_tilt_degs = {__Pyx_NAMESTR("set_tilt_degs"), (PyCFunction)__pyx_pw_8freenect_25set_tilt_degs, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}; -static PyObject *__pyx_pw_8freenect_25set_tilt_degs(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - struct __pyx_obj_8freenect_DevPtr *__pyx_v_dev = 0; - float __pyx_v_angle; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("set_tilt_degs (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_dev,&__pyx_n_s_angle,0}; - PyObject* values[2] = {0,0}; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dev)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - case 1: - if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_angle)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("set_tilt_degs", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "set_tilt_degs") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - } - __pyx_v_dev = ((struct __pyx_obj_8freenect_DevPtr *)values[0]); - __pyx_v_angle = __pyx_PyFloat_AsFloat(values[1]); if (unlikely((__pyx_v_angle == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("set_tilt_degs", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_L3_error:; - __Pyx_AddTraceback("freenect.set_tilt_degs", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dev), __pyx_ptype_8freenect_DevPtr, 1, "dev", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = __pyx_pf_8freenect_24set_tilt_degs(__pyx_self, __pyx_v_dev, __pyx_v_angle); - - /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_8freenect_24set_tilt_degs(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_DevPtr *__pyx_v_dev, float __pyx_v_angle) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("set_tilt_degs", 0); - - /* "freenect.pyx":262 - * - * def set_tilt_degs(DevPtr dev, float angle): - * freenect_set_tilt_degs(dev._ptr, angle) # <<<<<<<<<<<<<< - * - * def set_led(DevPtr dev, freenect_led_options option): - */ - freenect_set_tilt_degs(__pyx_v_dev->_ptr, __pyx_v_angle); - - /* "freenect.pyx":261 - * return freenect_close_device(dev._ptr) - * - * def set_tilt_degs(DevPtr dev, float angle): # <<<<<<<<<<<<<< - * freenect_set_tilt_degs(dev._ptr, angle) - * - */ - - /* function exit code */ - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "freenect.pyx":264 - * freenect_set_tilt_degs(dev._ptr, angle) - * - * def set_led(DevPtr dev, freenect_led_options option): # <<<<<<<<<<<<<< - * return freenect_set_led(dev._ptr, option) - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_8freenect_27set_led(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyMethodDef __pyx_mdef_8freenect_27set_led = {__Pyx_NAMESTR("set_led"), (PyCFunction)__pyx_pw_8freenect_27set_led, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}; -static PyObject *__pyx_pw_8freenect_27set_led(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - struct __pyx_obj_8freenect_DevPtr *__pyx_v_dev = 0; - freenect_led_options __pyx_v_option; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("set_led (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_dev,&__pyx_n_s_option,0}; - PyObject* values[2] = {0,0}; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dev)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - case 1: - if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_option)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("set_led", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "set_led") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - } - __pyx_v_dev = ((struct __pyx_obj_8freenect_DevPtr *)values[0]); - __pyx_v_option = ((freenect_led_options)PyInt_AsLong(values[1])); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("set_led", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_L3_error:; - __Pyx_AddTraceback("freenect.set_led", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dev), __pyx_ptype_8freenect_DevPtr, 1, "dev", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = __pyx_pf_8freenect_26set_led(__pyx_self, __pyx_v_dev, __pyx_v_option); - - /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_8freenect_26set_led(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_DevPtr *__pyx_v_dev, freenect_led_options __pyx_v_option) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("set_led", 0); - - /* "freenect.pyx":265 - * - * def set_led(DevPtr dev, freenect_led_options option): - * return freenect_set_led(dev._ptr, option) # <<<<<<<<<<<<<< - * - * def update_tilt_state(DevPtr dev): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(freenect_set_led(__pyx_v_dev->_ptr, __pyx_v_option)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "freenect.pyx":264 - * freenect_set_tilt_degs(dev._ptr, angle) - * - * def set_led(DevPtr dev, freenect_led_options option): # <<<<<<<<<<<<<< - * return freenect_set_led(dev._ptr, option) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("freenect.set_led", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "freenect.pyx":267 - * return freenect_set_led(dev._ptr, option) - * - * def update_tilt_state(DevPtr dev): # <<<<<<<<<<<<<< - * return freenect_update_tilt_state(dev._ptr) - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_8freenect_29update_tilt_state(PyObject *__pyx_self, PyObject *__pyx_v_dev); /*proto*/ -static PyMethodDef __pyx_mdef_8freenect_29update_tilt_state = {__Pyx_NAMESTR("update_tilt_state"), (PyCFunction)__pyx_pw_8freenect_29update_tilt_state, METH_O, __Pyx_DOCSTR(0)}; -static PyObject *__pyx_pw_8freenect_29update_tilt_state(PyObject *__pyx_self, PyObject *__pyx_v_dev) { - CYTHON_UNUSED int __pyx_lineno = 0; - CYTHON_UNUSED const char *__pyx_filename = NULL; - CYTHON_UNUSED int __pyx_clineno = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("update_tilt_state (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dev), __pyx_ptype_8freenect_DevPtr, 1, "dev", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = __pyx_pf_8freenect_28update_tilt_state(__pyx_self, ((struct __pyx_obj_8freenect_DevPtr *)__pyx_v_dev)); - - /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_8freenect_28update_tilt_state(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_DevPtr *__pyx_v_dev) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("update_tilt_state", 0); - - /* "freenect.pyx":268 - * - * def update_tilt_state(DevPtr dev): - * return freenect_update_tilt_state(dev._ptr) # <<<<<<<<<<<<<< - * - * def get_tilt_state(DevPtr dev): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(freenect_update_tilt_state(__pyx_v_dev->_ptr)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "freenect.pyx":267 - * return freenect_set_led(dev._ptr, option) - * - * def update_tilt_state(DevPtr dev): # <<<<<<<<<<<<<< - * return freenect_update_tilt_state(dev._ptr) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("freenect.update_tilt_state", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "freenect.pyx":270 - * return freenect_update_tilt_state(dev._ptr) - * - * def get_tilt_state(DevPtr dev): # <<<<<<<<<<<<<< - * cdef freenect_raw_tilt_state* state = freenect_get_tilt_state(dev._ptr) - * cdef StatePtr state_out = StatePtr.__new__(StatePtr) - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_8freenect_31get_tilt_state(PyObject *__pyx_self, PyObject *__pyx_v_dev); /*proto*/ -static PyMethodDef __pyx_mdef_8freenect_31get_tilt_state = {__Pyx_NAMESTR("get_tilt_state"), (PyCFunction)__pyx_pw_8freenect_31get_tilt_state, METH_O, __Pyx_DOCSTR(0)}; -static PyObject *__pyx_pw_8freenect_31get_tilt_state(PyObject *__pyx_self, PyObject *__pyx_v_dev) { - CYTHON_UNUSED int __pyx_lineno = 0; - CYTHON_UNUSED const char *__pyx_filename = NULL; - CYTHON_UNUSED int __pyx_clineno = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("get_tilt_state (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dev), __pyx_ptype_8freenect_DevPtr, 1, "dev", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = __pyx_pf_8freenect_30get_tilt_state(__pyx_self, ((struct __pyx_obj_8freenect_DevPtr *)__pyx_v_dev)); - - /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_8freenect_30get_tilt_state(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_DevPtr *__pyx_v_dev) { - freenect_raw_tilt_state *__pyx_v_state; - struct __pyx_obj_8freenect_StatePtr *__pyx_v_state_out = 0; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("get_tilt_state", 0); - - /* "freenect.pyx":271 - * - * def get_tilt_state(DevPtr dev): - * cdef freenect_raw_tilt_state* state = freenect_get_tilt_state(dev._ptr) # <<<<<<<<<<<<<< - * cdef StatePtr state_out = StatePtr.__new__(StatePtr) - * state_out._ptr = state - */ - __pyx_v_state = freenect_get_tilt_state(__pyx_v_dev->_ptr); - - /* "freenect.pyx":272 - * def get_tilt_state(DevPtr dev): - * cdef freenect_raw_tilt_state* state = freenect_get_tilt_state(dev._ptr) - * cdef StatePtr state_out = StatePtr.__new__(StatePtr) # <<<<<<<<<<<<<< - * state_out._ptr = state - * return state_out - */ - __pyx_t_1 = __pyx_tp_new_8freenect_StatePtr(((PyTypeObject *)((PyObject*)__pyx_ptype_8freenect_StatePtr)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_8freenect_StatePtr)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_state_out = ((struct __pyx_obj_8freenect_StatePtr *)__pyx_t_1); - __pyx_t_1 = 0; - - /* "freenect.pyx":273 - * cdef freenect_raw_tilt_state* state = freenect_get_tilt_state(dev._ptr) - * cdef StatePtr state_out = StatePtr.__new__(StatePtr) - * state_out._ptr = state # <<<<<<<<<<<<<< - * return state_out - * - */ - __pyx_v_state_out->_ptr = __pyx_v_state; - - /* "freenect.pyx":274 - * cdef StatePtr state_out = StatePtr.__new__(StatePtr) - * state_out._ptr = state - * return state_out # <<<<<<<<<<<<<< - * - * def get_mks_accel(StatePtr state): - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(((PyObject *)__pyx_v_state_out)); - __pyx_r = ((PyObject *)__pyx_v_state_out); - goto __pyx_L0; - - /* "freenect.pyx":270 - * return freenect_update_tilt_state(dev._ptr) - * - * def get_tilt_state(DevPtr dev): # <<<<<<<<<<<<<< - * cdef freenect_raw_tilt_state* state = freenect_get_tilt_state(dev._ptr) - * cdef StatePtr state_out = StatePtr.__new__(StatePtr) - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("freenect.get_tilt_state", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XDECREF((PyObject *)__pyx_v_state_out); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "freenect.pyx":276 - * return state_out - * - * def get_mks_accel(StatePtr state): # <<<<<<<<<<<<<< - * cdef double x, y, z - * freenect_get_mks_accel(state._ptr, &x, &y, &z) - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_8freenect_33get_mks_accel(PyObject *__pyx_self, PyObject *__pyx_v_state); /*proto*/ -static PyMethodDef __pyx_mdef_8freenect_33get_mks_accel = {__Pyx_NAMESTR("get_mks_accel"), (PyCFunction)__pyx_pw_8freenect_33get_mks_accel, METH_O, __Pyx_DOCSTR(0)}; -static PyObject *__pyx_pw_8freenect_33get_mks_accel(PyObject *__pyx_self, PyObject *__pyx_v_state) { - CYTHON_UNUSED int __pyx_lineno = 0; - CYTHON_UNUSED const char *__pyx_filename = NULL; - CYTHON_UNUSED int __pyx_clineno = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("get_mks_accel (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_state), __pyx_ptype_8freenect_StatePtr, 1, "state", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = __pyx_pf_8freenect_32get_mks_accel(__pyx_self, ((struct __pyx_obj_8freenect_StatePtr *)__pyx_v_state)); - - /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_8freenect_32get_mks_accel(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_StatePtr *__pyx_v_state) { - double __pyx_v_x; - double __pyx_v_y; - double __pyx_v_z; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("get_mks_accel", 0); - - /* "freenect.pyx":278 - * def get_mks_accel(StatePtr state): - * cdef double x, y, z - * freenect_get_mks_accel(state._ptr, &x, &y, &z) # <<<<<<<<<<<<<< - * return x, y, z - * - */ - freenect_get_mks_accel(__pyx_v_state->_ptr, (&__pyx_v_x), (&__pyx_v_y), (&__pyx_v_z)); - - /* "freenect.pyx":279 - * cdef double x, y, z - * freenect_get_mks_accel(state._ptr, &x, &y, &z) - * return x, y, z # <<<<<<<<<<<<<< - * - * def get_accel(DevPtr dev): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyFloat_FromDouble(__pyx_v_x); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyFloat_FromDouble(__pyx_v_y); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyFloat_FromDouble(__pyx_v_z); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_3); - __Pyx_GIVEREF(__pyx_t_3); - __pyx_t_1 = 0; - __pyx_t_2 = 0; - __pyx_t_3 = 0; - __pyx_r = __pyx_t_4; - __pyx_t_4 = 0; - goto __pyx_L0; - - /* "freenect.pyx":276 - * return state_out - * - * def get_mks_accel(StatePtr state): # <<<<<<<<<<<<<< - * cdef double x, y, z - * freenect_get_mks_accel(state._ptr, &x, &y, &z) - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_AddTraceback("freenect.get_mks_accel", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "freenect.pyx":281 - * return x, y, z - * - * def get_accel(DevPtr dev): # <<<<<<<<<<<<<< - * """MKS Accelerometer helper - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_8freenect_35get_accel(PyObject *__pyx_self, PyObject *__pyx_v_dev); /*proto*/ -static char __pyx_doc_8freenect_34get_accel[] = "MKS Accelerometer helper\n\n Args:\n dev:\n\n Returns:\n (x, y, z) accelerometer values\n "; -static PyMethodDef __pyx_mdef_8freenect_35get_accel = {__Pyx_NAMESTR("get_accel"), (PyCFunction)__pyx_pw_8freenect_35get_accel, METH_O, __Pyx_DOCSTR(__pyx_doc_8freenect_34get_accel)}; -static PyObject *__pyx_pw_8freenect_35get_accel(PyObject *__pyx_self, PyObject *__pyx_v_dev) { - CYTHON_UNUSED int __pyx_lineno = 0; - CYTHON_UNUSED const char *__pyx_filename = NULL; - CYTHON_UNUSED int __pyx_clineno = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("get_accel (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dev), __pyx_ptype_8freenect_DevPtr, 1, "dev", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 281; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = __pyx_pf_8freenect_34get_accel(__pyx_self, ((struct __pyx_obj_8freenect_DevPtr *)__pyx_v_dev)); - - /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_8freenect_34get_accel(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_DevPtr *__pyx_v_dev) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("get_accel", 0); - - /* "freenect.pyx":290 - * (x, y, z) accelerometer values - * """ - * update_tilt_state(dev) # <<<<<<<<<<<<<< - * return get_mks_accel(get_tilt_state(dev)) - * - */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_update_tilt_state); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_INCREF(((PyObject *)__pyx_v_dev)); - PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_dev)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_dev)); - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - - /* "freenect.pyx":291 - * """ - * update_tilt_state(dev) - * return get_mks_accel(get_tilt_state(dev)) # <<<<<<<<<<<<<< - * - * - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_mks_accel); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_tilt_state); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_INCREF(((PyObject *)__pyx_v_dev)); - PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_dev)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_dev)); - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_4); - __Pyx_GIVEREF(__pyx_t_4); - __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_r = __pyx_t_4; - __pyx_t_4 = 0; - goto __pyx_L0; - - /* "freenect.pyx":281 - * return x, y, z - * - * def get_accel(DevPtr dev): # <<<<<<<<<<<<<< - * """MKS Accelerometer helper - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_AddTraceback("freenect.get_accel", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "freenect.pyx":294 - * - * - * def get_tilt_degs(StatePtr state): # <<<<<<<<<<<<<< - * return freenect_get_tilt_degs(state._ptr) - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_8freenect_37get_tilt_degs(PyObject *__pyx_self, PyObject *__pyx_v_state); /*proto*/ -static PyMethodDef __pyx_mdef_8freenect_37get_tilt_degs = {__Pyx_NAMESTR("get_tilt_degs"), (PyCFunction)__pyx_pw_8freenect_37get_tilt_degs, METH_O, __Pyx_DOCSTR(0)}; -static PyObject *__pyx_pw_8freenect_37get_tilt_degs(PyObject *__pyx_self, PyObject *__pyx_v_state) { - CYTHON_UNUSED int __pyx_lineno = 0; - CYTHON_UNUSED const char *__pyx_filename = NULL; - CYTHON_UNUSED int __pyx_clineno = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("get_tilt_degs (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_state), __pyx_ptype_8freenect_StatePtr, 1, "state", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = __pyx_pf_8freenect_36get_tilt_degs(__pyx_self, ((struct __pyx_obj_8freenect_StatePtr *)__pyx_v_state)); - - /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_8freenect_36get_tilt_degs(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_StatePtr *__pyx_v_state) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("get_tilt_degs", 0); - - /* "freenect.pyx":295 - * - * def get_tilt_degs(StatePtr state): - * return freenect_get_tilt_degs(state._ptr) # <<<<<<<<<<<<<< - * - * - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyFloat_FromDouble(freenect_get_tilt_degs(__pyx_v_state->_ptr)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "freenect.pyx":294 - * - * - * def get_tilt_degs(StatePtr state): # <<<<<<<<<<<<<< - * return freenect_get_tilt_degs(state._ptr) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("freenect.get_tilt_degs", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "freenect.pyx":298 - * - * - * def error_open_device(): # <<<<<<<<<<<<<< - * print("Error: Can't open device. 1.) is it plugged in? 2.) Read the README") - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_8freenect_39error_open_device(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyMethodDef __pyx_mdef_8freenect_39error_open_device = {__Pyx_NAMESTR("error_open_device"), (PyCFunction)__pyx_pw_8freenect_39error_open_device, METH_NOARGS, __Pyx_DOCSTR(0)}; -static PyObject *__pyx_pw_8freenect_39error_open_device(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("error_open_device (wrapper)", 0); - __pyx_r = __pyx_pf_8freenect_38error_open_device(__pyx_self); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_8freenect_38error_open_device(CYTHON_UNUSED PyObject *__pyx_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("error_open_device", 0); - - /* "freenect.pyx":299 - * - * def error_open_device(): - * print("Error: Can't open device. 1.) is it plugged in? 2.) Read the README") # <<<<<<<<<<<<<< - * - * cpdef init(): - */ - if (__Pyx_PrintOne(0, __pyx_kp_s_Error_Can_t_open_device_1_is_it) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - - /* "freenect.pyx":298 - * - * - * def error_open_device(): # <<<<<<<<<<<<<< - * print("Error: Can't open device. 1.) is it plugged in? 2.) Read the README") - * - */ - - /* function exit code */ - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_AddTraceback("freenect.error_open_device", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "freenect.pyx":301 - * print("Error: Can't open device. 1.) is it plugged in? 2.) Read the README") - * - * cpdef init(): # <<<<<<<<<<<<<< - * cdef freenect_context* ctx - * if freenect_init(&ctx, NULL) < 0: - */ - -static PyObject *__pyx_pw_8freenect_41init(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_f_8freenect_init(CYTHON_UNUSED int __pyx_skip_dispatch) { - freenect_context *__pyx_v_ctx; - struct __pyx_obj_8freenect_CtxPtr *__pyx_v_ctx_out = 0; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("init", 0); - - /* "freenect.pyx":303 - * cpdef init(): - * cdef freenect_context* ctx - * if freenect_init(&ctx, NULL) < 0: # <<<<<<<<<<<<<< - * return - * # We take both the motor and camera devices here, since we provide access - */ - __pyx_t_1 = ((freenect_init((&__pyx_v_ctx), NULL) < 0) != 0); - if (__pyx_t_1) { - - /* "freenect.pyx":304 - * cdef freenect_context* ctx - * if freenect_init(&ctx, NULL) < 0: - * return # <<<<<<<<<<<<<< - * # We take both the motor and camera devices here, since we provide access - * # to both but haven't wrapped the python API for selecting subdevices yet. - */ - __Pyx_XDECREF(__pyx_r); - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - } - - /* "freenect.pyx":309 - * # Also, we don't support audio in the python wrapper yet, so no sense claiming - * # the device. - * freenect_select_subdevices(ctx, (FREENECT_DEVICE_MOTOR | FREENECT_DEVICE_CAMERA)) # <<<<<<<<<<<<<< - * cdef CtxPtr ctx_out = CtxPtr.__new__(CtxPtr) - * ctx_out._ptr = ctx - */ - freenect_select_subdevices(__pyx_v_ctx, ((freenect_device_flags)(FREENECT_DEVICE_MOTOR | FREENECT_DEVICE_CAMERA))); - - /* "freenect.pyx":310 - * # the device. - * freenect_select_subdevices(ctx, (FREENECT_DEVICE_MOTOR | FREENECT_DEVICE_CAMERA)) - * cdef CtxPtr ctx_out = CtxPtr.__new__(CtxPtr) # <<<<<<<<<<<<<< - * ctx_out._ptr = ctx - * return ctx_out - */ - __pyx_t_2 = __pyx_tp_new_8freenect_CtxPtr(((PyTypeObject *)((PyObject*)__pyx_ptype_8freenect_CtxPtr)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - if (!(likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_8freenect_CtxPtr)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_ctx_out = ((struct __pyx_obj_8freenect_CtxPtr *)__pyx_t_2); - __pyx_t_2 = 0; - - /* "freenect.pyx":311 - * freenect_select_subdevices(ctx, (FREENECT_DEVICE_MOTOR | FREENECT_DEVICE_CAMERA)) - * cdef CtxPtr ctx_out = CtxPtr.__new__(CtxPtr) - * ctx_out._ptr = ctx # <<<<<<<<<<<<<< - * return ctx_out - * - */ - __pyx_v_ctx_out->_ptr = __pyx_v_ctx; - - /* "freenect.pyx":312 - * cdef CtxPtr ctx_out = CtxPtr.__new__(CtxPtr) - * ctx_out._ptr = ctx - * return ctx_out # <<<<<<<<<<<<<< - * - * cpdef open_device(CtxPtr ctx, int index): - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(((PyObject *)__pyx_v_ctx_out)); - __pyx_r = ((PyObject *)__pyx_v_ctx_out); - goto __pyx_L0; - - /* "freenect.pyx":301 - * print("Error: Can't open device. 1.) is it plugged in? 2.) Read the README") - * - * cpdef init(): # <<<<<<<<<<<<<< - * cdef freenect_context* ctx - * if freenect_init(&ctx, NULL) < 0: - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("freenect.init", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XDECREF((PyObject *)__pyx_v_ctx_out); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* Python wrapper */ -static PyObject *__pyx_pw_8freenect_41init(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw_8freenect_41init(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("init (wrapper)", 0); - __pyx_r = __pyx_pf_8freenect_40init(__pyx_self); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_8freenect_40init(CYTHON_UNUSED PyObject *__pyx_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("init", 0); - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_8freenect_init(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("freenect.init", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "freenect.pyx":314 - * return ctx_out - * - * cpdef open_device(CtxPtr ctx, int index): # <<<<<<<<<<<<<< - * cdef freenect_device* dev - * if freenect_open_device(ctx._ptr, &dev, index) < 0: - */ - -static PyObject *__pyx_pw_8freenect_43open_device(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_f_8freenect_open_device(struct __pyx_obj_8freenect_CtxPtr *__pyx_v_ctx, int __pyx_v_index, CYTHON_UNUSED int __pyx_skip_dispatch) { - freenect_device *__pyx_v_dev; - struct __pyx_obj_8freenect_DevPtr *__pyx_v_dev_out = 0; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("open_device", 0); - - /* "freenect.pyx":316 - * cpdef open_device(CtxPtr ctx, int index): - * cdef freenect_device* dev - * if freenect_open_device(ctx._ptr, &dev, index) < 0: # <<<<<<<<<<<<<< - * return - * cdef DevPtr dev_out = DevPtr.__new__(DevPtr) - */ - __pyx_t_1 = ((freenect_open_device(__pyx_v_ctx->_ptr, (&__pyx_v_dev), __pyx_v_index) < 0) != 0); - if (__pyx_t_1) { - - /* "freenect.pyx":317 - * cdef freenect_device* dev - * if freenect_open_device(ctx._ptr, &dev, index) < 0: - * return # <<<<<<<<<<<<<< - * cdef DevPtr dev_out = DevPtr.__new__(DevPtr) - * dev_out._ptr = dev - */ - __Pyx_XDECREF(__pyx_r); - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - } - - /* "freenect.pyx":318 - * if freenect_open_device(ctx._ptr, &dev, index) < 0: - * return - * cdef DevPtr dev_out = DevPtr.__new__(DevPtr) # <<<<<<<<<<<<<< - * dev_out._ptr = dev - * dev_out.ctx = ctx - */ - __pyx_t_2 = __pyx_tp_new_8freenect_DevPtr(((PyTypeObject *)((PyObject*)__pyx_ptype_8freenect_DevPtr)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - if (!(likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_8freenect_DevPtr)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_dev_out = ((struct __pyx_obj_8freenect_DevPtr *)__pyx_t_2); - __pyx_t_2 = 0; - - /* "freenect.pyx":319 - * return - * cdef DevPtr dev_out = DevPtr.__new__(DevPtr) - * dev_out._ptr = dev # <<<<<<<<<<<<<< - * dev_out.ctx = ctx - * return dev_out - */ - __pyx_v_dev_out->_ptr = __pyx_v_dev; - - /* "freenect.pyx":320 - * cdef DevPtr dev_out = DevPtr.__new__(DevPtr) - * dev_out._ptr = dev - * dev_out.ctx = ctx # <<<<<<<<<<<<<< - * return dev_out - * - */ - __Pyx_INCREF(((PyObject *)__pyx_v_ctx)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_ctx)); - __Pyx_GOTREF(__pyx_v_dev_out->ctx); - __Pyx_DECREF(((PyObject *)__pyx_v_dev_out->ctx)); - __pyx_v_dev_out->ctx = __pyx_v_ctx; - - /* "freenect.pyx":321 - * dev_out._ptr = dev - * dev_out.ctx = ctx - * return dev_out # <<<<<<<<<<<<<< - * - * _depth_cb, _video_cb = None, None - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(((PyObject *)__pyx_v_dev_out)); - __pyx_r = ((PyObject *)__pyx_v_dev_out); - goto __pyx_L0; - - /* "freenect.pyx":314 - * return ctx_out - * - * cpdef open_device(CtxPtr ctx, int index): # <<<<<<<<<<<<<< - * cdef freenect_device* dev - * if freenect_open_device(ctx._ptr, &dev, index) < 0: - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("freenect.open_device", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XDECREF((PyObject *)__pyx_v_dev_out); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* Python wrapper */ -static PyObject *__pyx_pw_8freenect_43open_device(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_pw_8freenect_43open_device(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - struct __pyx_obj_8freenect_CtxPtr *__pyx_v_ctx = 0; - int __pyx_v_index; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("open_device (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_ctx,&__pyx_n_s_index,0}; - PyObject* values[2] = {0,0}; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ctx)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - case 1: - if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_index)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("open_device", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "open_device") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - } - __pyx_v_ctx = ((struct __pyx_obj_8freenect_CtxPtr *)values[0]); - __pyx_v_index = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_index == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("open_device", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_L3_error:; - __Pyx_AddTraceback("freenect.open_device", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_ctx), __pyx_ptype_8freenect_CtxPtr, 1, "ctx", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = __pyx_pf_8freenect_42open_device(__pyx_self, __pyx_v_ctx, __pyx_v_index); - - /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_8freenect_42open_device(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_CtxPtr *__pyx_v_ctx, int __pyx_v_index) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("open_device", 0); - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_8freenect_open_device(__pyx_v_ctx, __pyx_v_index, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("freenect.open_device", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "freenect.pyx":325 - * _depth_cb, _video_cb = None, None - * - * cdef void depth_cb(freenect_device *dev, void *data, uint32_t timestamp) with gil: # <<<<<<<<<<<<<< - * cdef freenect_frame_mode mode = freenect_get_current_depth_mode(dev) - * if not mode.is_valid: - */ - -static void __pyx_f_8freenect_depth_cb(freenect_device *__pyx_v_dev, void *__pyx_v_data, uint32_t __pyx_v_timestamp) { - freenect_frame_mode __pyx_v_mode; - struct __pyx_obj_8freenect_DevPtr *__pyx_v_dev_out = 0; - PyObject *__pyx_v_pydata = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - int __pyx_t_3; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - #ifdef WITH_THREAD - PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); - #endif - __Pyx_RefNannySetupContext("depth_cb", 0); - - /* "freenect.pyx":326 - * - * cdef void depth_cb(freenect_device *dev, void *data, uint32_t timestamp) with gil: - * cdef freenect_frame_mode mode = freenect_get_current_depth_mode(dev) # <<<<<<<<<<<<<< - * if not mode.is_valid: - * return - */ - __pyx_v_mode = freenect_get_current_depth_mode(__pyx_v_dev); - - /* "freenect.pyx":327 - * cdef void depth_cb(freenect_device *dev, void *data, uint32_t timestamp) with gil: - * cdef freenect_frame_mode mode = freenect_get_current_depth_mode(dev) - * if not mode.is_valid: # <<<<<<<<<<<<<< - * return - * if not _depth_cb: - */ - __pyx_t_1 = ((!(__pyx_v_mode.is_valid != 0)) != 0); - if (__pyx_t_1) { - - /* "freenect.pyx":328 - * cdef freenect_frame_mode mode = freenect_get_current_depth_mode(dev) - * if not mode.is_valid: - * return # <<<<<<<<<<<<<< - * if not _depth_cb: - * return - */ - goto __pyx_L0; - } - - /* "freenect.pyx":329 - * if not mode.is_valid: - * return - * if not _depth_cb: # <<<<<<<<<<<<<< - * return - * cdef DevPtr dev_out = DevPtr.__new__(DevPtr) - */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_depth_cb); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_3 = ((!__pyx_t_1) != 0); - if (__pyx_t_3) { - - /* "freenect.pyx":330 - * return - * if not _depth_cb: - * return # <<<<<<<<<<<<<< - * cdef DevPtr dev_out = DevPtr.__new__(DevPtr) - * dev_out._ptr = dev - */ - goto __pyx_L0; - } - - /* "freenect.pyx":331 - * if not _depth_cb: - * return - * cdef DevPtr dev_out = DevPtr.__new__(DevPtr) # <<<<<<<<<<<<<< - * dev_out._ptr = dev - * pydata = _depth_cb_np(data, &mode) - */ - __pyx_t_2 = __pyx_tp_new_8freenect_DevPtr(((PyTypeObject *)((PyObject*)__pyx_ptype_8freenect_DevPtr)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - if (!(likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_8freenect_DevPtr)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_dev_out = ((struct __pyx_obj_8freenect_DevPtr *)__pyx_t_2); - __pyx_t_2 = 0; - - /* "freenect.pyx":332 - * return - * cdef DevPtr dev_out = DevPtr.__new__(DevPtr) - * dev_out._ptr = dev # <<<<<<<<<<<<<< - * pydata = _depth_cb_np(data, &mode) - * _depth_cb(dev_out, pydata, timestamp) - */ - __pyx_v_dev_out->_ptr = __pyx_v_dev; - - /* "freenect.pyx":333 - * cdef DevPtr dev_out = DevPtr.__new__(DevPtr) - * dev_out._ptr = dev - * pydata = _depth_cb_np(data, &mode) # <<<<<<<<<<<<<< - * _depth_cb(dev_out, pydata, timestamp) - * - */ - __pyx_t_2 = __pyx_f_8freenect__depth_cb_np(__pyx_v_data, (&__pyx_v_mode)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_v_pydata = __pyx_t_2; - __pyx_t_2 = 0; - - /* "freenect.pyx":334 - * dev_out._ptr = dev - * pydata = _depth_cb_np(data, &mode) - * _depth_cb(dev_out, pydata, timestamp) # <<<<<<<<<<<<<< - * - * cdef void video_cb(freenect_device *dev, void *data, uint32_t timestamp) with gil: - */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_depth_cb); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = __Pyx_PyInt_From_uint32_t(__pyx_v_timestamp); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __Pyx_INCREF(((PyObject *)__pyx_v_dev_out)); - PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_dev_out)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_dev_out)); - __Pyx_INCREF(__pyx_v_pydata); - PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_pydata); - __Pyx_GIVEREF(__pyx_v_pydata); - PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_4); - __Pyx_GIVEREF(__pyx_t_4); - __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - - /* "freenect.pyx":325 - * _depth_cb, _video_cb = None, None - * - * cdef void depth_cb(freenect_device *dev, void *data, uint32_t timestamp) with gil: # <<<<<<<<<<<<<< - * cdef freenect_frame_mode mode = freenect_get_current_depth_mode(dev) - * if not mode.is_valid: - */ - - /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_WriteUnraisable("freenect.depth_cb", __pyx_clineno, __pyx_lineno, __pyx_filename, 0); - __pyx_L0:; - __Pyx_XDECREF((PyObject *)__pyx_v_dev_out); - __Pyx_XDECREF(__pyx_v_pydata); - __Pyx_RefNannyFinishContext(); - #ifdef WITH_THREAD - PyGILState_Release(__pyx_gilstate_save); - #endif -} - -/* "freenect.pyx":336 - * _depth_cb(dev_out, pydata, timestamp) - * - * cdef void video_cb(freenect_device *dev, void *data, uint32_t timestamp) with gil: # <<<<<<<<<<<<<< - * cdef freenect_frame_mode mode = freenect_get_current_video_mode(dev) - * if not mode.is_valid: - */ - -static void __pyx_f_8freenect_video_cb(freenect_device *__pyx_v_dev, void *__pyx_v_data, uint32_t __pyx_v_timestamp) { - freenect_frame_mode __pyx_v_mode; - struct __pyx_obj_8freenect_DevPtr *__pyx_v_dev_out = 0; - PyObject *__pyx_v_pydata = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - int __pyx_t_3; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - #ifdef WITH_THREAD - PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); - #endif - __Pyx_RefNannySetupContext("video_cb", 0); - - /* "freenect.pyx":337 - * - * cdef void video_cb(freenect_device *dev, void *data, uint32_t timestamp) with gil: - * cdef freenect_frame_mode mode = freenect_get_current_video_mode(dev) # <<<<<<<<<<<<<< - * if not mode.is_valid: - * return - */ - __pyx_v_mode = freenect_get_current_video_mode(__pyx_v_dev); - - /* "freenect.pyx":338 - * cdef void video_cb(freenect_device *dev, void *data, uint32_t timestamp) with gil: - * cdef freenect_frame_mode mode = freenect_get_current_video_mode(dev) - * if not mode.is_valid: # <<<<<<<<<<<<<< - * return - * if not _video_cb: - */ - __pyx_t_1 = ((!(__pyx_v_mode.is_valid != 0)) != 0); - if (__pyx_t_1) { - - /* "freenect.pyx":339 - * cdef freenect_frame_mode mode = freenect_get_current_video_mode(dev) - * if not mode.is_valid: - * return # <<<<<<<<<<<<<< - * if not _video_cb: - * return - */ - goto __pyx_L0; - } - - /* "freenect.pyx":340 - * if not mode.is_valid: - * return - * if not _video_cb: # <<<<<<<<<<<<<< - * return - * cdef DevPtr dev_out = DevPtr.__new__(DevPtr) - */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_video_cb); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 340; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 340; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_3 = ((!__pyx_t_1) != 0); - if (__pyx_t_3) { - - /* "freenect.pyx":341 - * return - * if not _video_cb: - * return # <<<<<<<<<<<<<< - * cdef DevPtr dev_out = DevPtr.__new__(DevPtr) - * dev_out._ptr = dev - */ - goto __pyx_L0; - } - - /* "freenect.pyx":342 - * if not _video_cb: - * return - * cdef DevPtr dev_out = DevPtr.__new__(DevPtr) # <<<<<<<<<<<<<< - * dev_out._ptr = dev - * pydata = _video_cb_np(data, &mode) - */ - __pyx_t_2 = __pyx_tp_new_8freenect_DevPtr(((PyTypeObject *)((PyObject*)__pyx_ptype_8freenect_DevPtr)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - if (!(likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_8freenect_DevPtr)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_dev_out = ((struct __pyx_obj_8freenect_DevPtr *)__pyx_t_2); - __pyx_t_2 = 0; - - /* "freenect.pyx":343 - * return - * cdef DevPtr dev_out = DevPtr.__new__(DevPtr) - * dev_out._ptr = dev # <<<<<<<<<<<<<< - * pydata = _video_cb_np(data, &mode) - * _video_cb(dev_out, pydata, timestamp) - */ - __pyx_v_dev_out->_ptr = __pyx_v_dev; - - /* "freenect.pyx":344 - * cdef DevPtr dev_out = DevPtr.__new__(DevPtr) - * dev_out._ptr = dev - * pydata = _video_cb_np(data, &mode) # <<<<<<<<<<<<<< - * _video_cb(dev_out, pydata, timestamp) - * - */ - __pyx_t_2 = __pyx_f_8freenect__video_cb_np(__pyx_v_data, (&__pyx_v_mode)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_v_pydata = __pyx_t_2; - __pyx_t_2 = 0; - - /* "freenect.pyx":345 - * dev_out._ptr = dev - * pydata = _video_cb_np(data, &mode) - * _video_cb(dev_out, pydata, timestamp) # <<<<<<<<<<<<<< - * - * def set_depth_callback(DevPtr dev, cb): - */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_video_cb); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = __Pyx_PyInt_From_uint32_t(__pyx_v_timestamp); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __Pyx_INCREF(((PyObject *)__pyx_v_dev_out)); - PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_dev_out)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_dev_out)); - __Pyx_INCREF(__pyx_v_pydata); - PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_pydata); - __Pyx_GIVEREF(__pyx_v_pydata); - PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_4); - __Pyx_GIVEREF(__pyx_t_4); - __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - - /* "freenect.pyx":336 - * _depth_cb(dev_out, pydata, timestamp) - * - * cdef void video_cb(freenect_device *dev, void *data, uint32_t timestamp) with gil: # <<<<<<<<<<<<<< - * cdef freenect_frame_mode mode = freenect_get_current_video_mode(dev) - * if not mode.is_valid: - */ - - /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_WriteUnraisable("freenect.video_cb", __pyx_clineno, __pyx_lineno, __pyx_filename, 0); - __pyx_L0:; - __Pyx_XDECREF((PyObject *)__pyx_v_dev_out); - __Pyx_XDECREF(__pyx_v_pydata); - __Pyx_RefNannyFinishContext(); - #ifdef WITH_THREAD - PyGILState_Release(__pyx_gilstate_save); - #endif -} - -/* "freenect.pyx":347 - * _video_cb(dev_out, pydata, timestamp) - * - * def set_depth_callback(DevPtr dev, cb): # <<<<<<<<<<<<<< - * global _depth_cb - * if cb is not None: - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_8freenect_45set_depth_callback(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyMethodDef __pyx_mdef_8freenect_45set_depth_callback = {__Pyx_NAMESTR("set_depth_callback"), (PyCFunction)__pyx_pw_8freenect_45set_depth_callback, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}; -static PyObject *__pyx_pw_8freenect_45set_depth_callback(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - struct __pyx_obj_8freenect_DevPtr *__pyx_v_dev = 0; - PyObject *__pyx_v_cb = 0; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("set_depth_callback (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_dev,&__pyx_n_s_cb,0}; - PyObject* values[2] = {0,0}; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dev)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - case 1: - if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_cb)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("set_depth_callback", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "set_depth_callback") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - } - __pyx_v_dev = ((struct __pyx_obj_8freenect_DevPtr *)values[0]); - __pyx_v_cb = values[1]; - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("set_depth_callback", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_L3_error:; - __Pyx_AddTraceback("freenect.set_depth_callback", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dev), __pyx_ptype_8freenect_DevPtr, 1, "dev", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = __pyx_pf_8freenect_44set_depth_callback(__pyx_self, __pyx_v_dev, __pyx_v_cb); - - /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_8freenect_44set_depth_callback(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_DevPtr *__pyx_v_dev, PyObject *__pyx_v_cb) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - int __pyx_t_2; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("set_depth_callback", 0); - - /* "freenect.pyx":349 - * def set_depth_callback(DevPtr dev, cb): - * global _depth_cb - * if cb is not None: # <<<<<<<<<<<<<< - * _depth_cb = cb - * freenect_set_depth_callback(dev._ptr, depth_cb) - */ - __pyx_t_1 = (__pyx_v_cb != Py_None); - __pyx_t_2 = (__pyx_t_1 != 0); - if (__pyx_t_2) { - - /* "freenect.pyx":350 - * global _depth_cb - * if cb is not None: - * _depth_cb = cb # <<<<<<<<<<<<<< - * freenect_set_depth_callback(dev._ptr, depth_cb) - * else: - */ - if (PyDict_SetItem(__pyx_d, __pyx_n_s_depth_cb, __pyx_v_cb) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - - /* "freenect.pyx":351 - * if cb is not None: - * _depth_cb = cb - * freenect_set_depth_callback(dev._ptr, depth_cb) # <<<<<<<<<<<<<< - * else: - * _depth_cb = None - */ - freenect_set_depth_callback(__pyx_v_dev->_ptr, __pyx_f_8freenect_depth_cb); - goto __pyx_L3; - } - /*else*/ { - - /* "freenect.pyx":353 - * freenect_set_depth_callback(dev._ptr, depth_cb) - * else: - * _depth_cb = None # <<<<<<<<<<<<<< - * freenect_set_depth_callback(dev._ptr, NULL) - * - */ - if (PyDict_SetItem(__pyx_d, __pyx_n_s_depth_cb, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - - /* "freenect.pyx":354 - * else: - * _depth_cb = None - * freenect_set_depth_callback(dev._ptr, NULL) # <<<<<<<<<<<<<< - * - * def set_video_callback(DevPtr dev, cb): - */ - freenect_set_depth_callback(__pyx_v_dev->_ptr, NULL); - } - __pyx_L3:; - - /* "freenect.pyx":347 - * _video_cb(dev_out, pydata, timestamp) - * - * def set_depth_callback(DevPtr dev, cb): # <<<<<<<<<<<<<< - * global _depth_cb - * if cb is not None: - */ - - /* function exit code */ - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_AddTraceback("freenect.set_depth_callback", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "freenect.pyx":356 - * freenect_set_depth_callback(dev._ptr, NULL) - * - * def set_video_callback(DevPtr dev, cb): # <<<<<<<<<<<<<< - * global _video_cb - * if cb is not None: - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_8freenect_47set_video_callback(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyMethodDef __pyx_mdef_8freenect_47set_video_callback = {__Pyx_NAMESTR("set_video_callback"), (PyCFunction)__pyx_pw_8freenect_47set_video_callback, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}; -static PyObject *__pyx_pw_8freenect_47set_video_callback(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - struct __pyx_obj_8freenect_DevPtr *__pyx_v_dev = 0; - PyObject *__pyx_v_cb = 0; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("set_video_callback (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_dev,&__pyx_n_s_cb,0}; - PyObject* values[2] = {0,0}; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dev)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - case 1: - if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_cb)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("set_video_callback", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "set_video_callback") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - } - __pyx_v_dev = ((struct __pyx_obj_8freenect_DevPtr *)values[0]); - __pyx_v_cb = values[1]; - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("set_video_callback", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_L3_error:; - __Pyx_AddTraceback("freenect.set_video_callback", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dev), __pyx_ptype_8freenect_DevPtr, 1, "dev", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = __pyx_pf_8freenect_46set_video_callback(__pyx_self, __pyx_v_dev, __pyx_v_cb); - - /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_8freenect_46set_video_callback(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_DevPtr *__pyx_v_dev, PyObject *__pyx_v_cb) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - int __pyx_t_2; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("set_video_callback", 0); - - /* "freenect.pyx":358 - * def set_video_callback(DevPtr dev, cb): - * global _video_cb - * if cb is not None: # <<<<<<<<<<<<<< - * _video_cb = cb - * freenect_set_video_callback(dev._ptr, video_cb) - */ - __pyx_t_1 = (__pyx_v_cb != Py_None); - __pyx_t_2 = (__pyx_t_1 != 0); - if (__pyx_t_2) { - - /* "freenect.pyx":359 - * global _video_cb - * if cb is not None: - * _video_cb = cb # <<<<<<<<<<<<<< - * freenect_set_video_callback(dev._ptr, video_cb) - * else: - */ - if (PyDict_SetItem(__pyx_d, __pyx_n_s_video_cb, __pyx_v_cb) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - - /* "freenect.pyx":360 - * if cb is not None: - * _video_cb = cb - * freenect_set_video_callback(dev._ptr, video_cb) # <<<<<<<<<<<<<< - * else: - * _video_cb = None - */ - freenect_set_video_callback(__pyx_v_dev->_ptr, __pyx_f_8freenect_video_cb); - goto __pyx_L3; - } - /*else*/ { - - /* "freenect.pyx":362 - * freenect_set_video_callback(dev._ptr, video_cb) - * else: - * _video_cb = None # <<<<<<<<<<<<<< - * freenect_set_video_callback(dev._ptr, NULL) - * - */ - if (PyDict_SetItem(__pyx_d, __pyx_n_s_video_cb, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - - /* "freenect.pyx":363 - * else: - * _video_cb = None - * freenect_set_video_callback(dev._ptr, NULL) # <<<<<<<<<<<<<< - * - * - */ - freenect_set_video_callback(__pyx_v_dev->_ptr, NULL); - } - __pyx_L3:; - - /* "freenect.pyx":356 - * freenect_set_depth_callback(dev._ptr, NULL) - * - * def set_video_callback(DevPtr dev, cb): # <<<<<<<<<<<<<< - * global _video_cb - * if cb is not None: - */ - - /* function exit code */ - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_AddTraceback("freenect.set_video_callback", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "freenect.pyx":370 - * - * - * def runloop(depth=None, video=None, body=None, dev=None): # <<<<<<<<<<<<<< - * """Sets up the kinect and maintains a runloop - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_8freenect_49runloop(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_8freenect_48runloop[] = "Sets up the kinect and maintains a runloop\n\n This is where most of the action happens. You can get the dev pointer from the callback\n and let this function do all of the setup for you. You may want to use threads to perform\n computation externally as the callbacks should really just be used for copying data.\n\n Args:\n depth: A function that takes (dev, depth, timestamp), corresponding to C function.\n If None (default), then you won't get a callback for depth.\n video: A function that takes (dev, video, timestamp), corresponding to C function.\n If None (default), then you won't get a callback for video.\n body: A function that takes (dev, ctx) and is called in the body of process_events\n dev: Optional freenect device context. If supplied, this function will use it instead\n of creating and destroying its own..\n "; -static PyMethodDef __pyx_mdef_8freenect_49runloop = {__Pyx_NAMESTR("runloop"), (PyCFunction)__pyx_pw_8freenect_49runloop, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_8freenect_48runloop)}; -static PyObject *__pyx_pw_8freenect_49runloop(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_depth = 0; - PyObject *__pyx_v_video = 0; - PyObject *__pyx_v_body = 0; - PyObject *__pyx_v_dev = 0; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("runloop (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_depth,&__pyx_n_s_video,&__pyx_n_s_body,&__pyx_n_s_dev,0}; - PyObject* values[4] = {0,0,0,0}; - values[0] = ((PyObject *)Py_None); - values[1] = ((PyObject *)Py_None); - values[2] = ((PyObject *)Py_None); - values[3] = ((PyObject *)Py_None); - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_depth); - if (value) { values[0] = value; kw_args--; } - } - case 1: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_video); - if (value) { values[1] = value; kw_args--; } - } - case 2: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_body); - if (value) { values[2] = value; kw_args--; } - } - case 3: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dev); - if (value) { values[3] = value; kw_args--; } - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "runloop") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - } else { - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - } - __pyx_v_depth = values[0]; - __pyx_v_video = values[1]; - __pyx_v_body = values[2]; - __pyx_v_dev = values[3]; - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("runloop", 0, 0, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_L3_error:; - __Pyx_AddTraceback("freenect.runloop", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_8freenect_48runloop(__pyx_self, __pyx_v_depth, __pyx_v_video, __pyx_v_body, __pyx_v_dev); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_8freenect_48runloop(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_depth, PyObject *__pyx_v_video, PyObject *__pyx_v_body, PyObject *__pyx_v_dev) { - struct __pyx_obj_8freenect_DevPtr *__pyx_v_mdev = 0; - struct __pyx_obj_8freenect_CtxPtr *__pyx_v_ctx = 0; - freenect_device *__pyx_v_devp; - freenect_context *__pyx_v_ctxp; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - int __pyx_t_2; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - freenect_device *__pyx_t_5; - freenect_context *__pyx_t_6; - PyObject *__pyx_t_7 = NULL; - PyObject *__pyx_t_8 = NULL; - PyObject *__pyx_t_9 = NULL; - int __pyx_t_10; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("runloop", 0); - - /* "freenect.pyx":387 - * """ - * global _depth_cb, _video_cb - * if depth: # <<<<<<<<<<<<<< - * _depth_cb = depth - * if video: - */ - __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_depth); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__pyx_t_1) { - - /* "freenect.pyx":388 - * global _depth_cb, _video_cb - * if depth: - * _depth_cb = depth # <<<<<<<<<<<<<< - * if video: - * _video_cb = video - */ - if (PyDict_SetItem(__pyx_d, __pyx_n_s_depth_cb, __pyx_v_depth) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L3; - } - __pyx_L3:; - - /* "freenect.pyx":389 - * if depth: - * _depth_cb = depth - * if video: # <<<<<<<<<<<<<< - * _video_cb = video - * cdef DevPtr mdev - */ - __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_video); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__pyx_t_1) { - - /* "freenect.pyx":390 - * _depth_cb = depth - * if video: - * _video_cb = video # <<<<<<<<<<<<<< - * cdef DevPtr mdev - * cdef CtxPtr ctx - */ - if (PyDict_SetItem(__pyx_d, __pyx_n_s_video_cb, __pyx_v_video) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L4; - } - __pyx_L4:; - - /* "freenect.pyx":395 - * cdef freenect_device* devp - * cdef freenect_context* ctxp - * if dev is None: # <<<<<<<<<<<<<< - * ctx = init() - * if not ctx: - */ - __pyx_t_1 = (__pyx_v_dev == Py_None); - __pyx_t_2 = (__pyx_t_1 != 0); - if (__pyx_t_2) { - - /* "freenect.pyx":396 - * cdef freenect_context* ctxp - * if dev is None: - * ctx = init() # <<<<<<<<<<<<<< - * if not ctx: - * error_open_device() - */ - __pyx_t_3 = __pyx_f_8freenect_init(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_8freenect_CtxPtr))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_ctx = ((struct __pyx_obj_8freenect_CtxPtr *)__pyx_t_3); - __pyx_t_3 = 0; - - /* "freenect.pyx":397 - * if dev is None: - * ctx = init() - * if not ctx: # <<<<<<<<<<<<<< - * error_open_device() - * return - */ - __pyx_t_2 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_ctx)); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_1 = ((!__pyx_t_2) != 0); - if (__pyx_t_1) { - - /* "freenect.pyx":398 - * ctx = init() - * if not ctx: - * error_open_device() # <<<<<<<<<<<<<< - * return - * mdev = open_device(ctx, 0) - */ - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_error_open_device); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - - /* "freenect.pyx":399 - * if not ctx: - * error_open_device() - * return # <<<<<<<<<<<<<< - * mdev = open_device(ctx, 0) - * if not mdev: - */ - __Pyx_XDECREF(__pyx_r); - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - } - - /* "freenect.pyx":400 - * error_open_device() - * return - * mdev = open_device(ctx, 0) # <<<<<<<<<<<<<< - * if not mdev: - * error_open_device() - */ - __pyx_t_4 = __pyx_f_8freenect_open_device(__pyx_v_ctx, 0, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_8freenect_DevPtr))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_mdev = ((struct __pyx_obj_8freenect_DevPtr *)__pyx_t_4); - __pyx_t_4 = 0; - - /* "freenect.pyx":401 - * return - * mdev = open_device(ctx, 0) - * if not mdev: # <<<<<<<<<<<<<< - * error_open_device() - * return - */ - __pyx_t_1 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_mdev)); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_2 = ((!__pyx_t_1) != 0); - if (__pyx_t_2) { - - /* "freenect.pyx":402 - * mdev = open_device(ctx, 0) - * if not mdev: - * error_open_device() # <<<<<<<<<<<<<< - * return - * if depth is not None: - */ - __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_error_open_device); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - - /* "freenect.pyx":403 - * if not mdev: - * error_open_device() - * return # <<<<<<<<<<<<<< - * if depth is not None: - * freenect_set_depth_mode(mdev._ptr, freenect_find_depth_mode(FREENECT_RESOLUTION_MEDIUM, FREENECT_DEPTH_11BIT)) - */ - __Pyx_XDECREF(__pyx_r); - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - } - - /* "freenect.pyx":404 - * error_open_device() - * return - * if depth is not None: # <<<<<<<<<<<<<< - * freenect_set_depth_mode(mdev._ptr, freenect_find_depth_mode(FREENECT_RESOLUTION_MEDIUM, FREENECT_DEPTH_11BIT)) - * if video is not None: - */ - __pyx_t_2 = (__pyx_v_depth != Py_None); - __pyx_t_1 = (__pyx_t_2 != 0); - if (__pyx_t_1) { - - /* "freenect.pyx":405 - * return - * if depth is not None: - * freenect_set_depth_mode(mdev._ptr, freenect_find_depth_mode(FREENECT_RESOLUTION_MEDIUM, FREENECT_DEPTH_11BIT)) # <<<<<<<<<<<<<< - * if video is not None: - * freenect_set_video_mode(mdev._ptr, freenect_find_video_mode(FREENECT_RESOLUTION_MEDIUM, FREENECT_VIDEO_RGB)) - */ - freenect_set_depth_mode(__pyx_v_mdev->_ptr, freenect_find_depth_mode(FREENECT_RESOLUTION_MEDIUM, FREENECT_DEPTH_11BIT)); - goto __pyx_L8; - } - __pyx_L8:; - - /* "freenect.pyx":406 - * if depth is not None: - * freenect_set_depth_mode(mdev._ptr, freenect_find_depth_mode(FREENECT_RESOLUTION_MEDIUM, FREENECT_DEPTH_11BIT)) - * if video is not None: # <<<<<<<<<<<<<< - * freenect_set_video_mode(mdev._ptr, freenect_find_video_mode(FREENECT_RESOLUTION_MEDIUM, FREENECT_VIDEO_RGB)) - * - */ - __pyx_t_1 = (__pyx_v_video != Py_None); - __pyx_t_2 = (__pyx_t_1 != 0); - if (__pyx_t_2) { - - /* "freenect.pyx":407 - * freenect_set_depth_mode(mdev._ptr, freenect_find_depth_mode(FREENECT_RESOLUTION_MEDIUM, FREENECT_DEPTH_11BIT)) - * if video is not None: - * freenect_set_video_mode(mdev._ptr, freenect_find_video_mode(FREENECT_RESOLUTION_MEDIUM, FREENECT_VIDEO_RGB)) # <<<<<<<<<<<<<< - * - * else: - */ - freenect_set_video_mode(__pyx_v_mdev->_ptr, freenect_find_video_mode(FREENECT_RESOLUTION_MEDIUM, FREENECT_VIDEO_RGB)); - goto __pyx_L9; - } - __pyx_L9:; - goto __pyx_L5; - } - /*else*/ { - - /* "freenect.pyx":410 - * - * else: - * mdev = dev # <<<<<<<<<<<<<< - * devp = mdev._ptr - * ctxp = mdev.ctx._ptr - */ - if (!(likely(((__pyx_v_dev) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_dev, __pyx_ptype_8freenect_DevPtr))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_3 = __pyx_v_dev; - __Pyx_INCREF(__pyx_t_3); - __pyx_v_mdev = ((struct __pyx_obj_8freenect_DevPtr *)__pyx_t_3); - __pyx_t_3 = 0; - } - __pyx_L5:; - - /* "freenect.pyx":411 - * else: - * mdev = dev - * devp = mdev._ptr # <<<<<<<<<<<<<< - * ctxp = mdev.ctx._ptr - * if depth is not None: - */ - __pyx_t_5 = __pyx_v_mdev->_ptr; - __pyx_v_devp = __pyx_t_5; - - /* "freenect.pyx":412 - * mdev = dev - * devp = mdev._ptr - * ctxp = mdev.ctx._ptr # <<<<<<<<<<<<<< - * if depth is not None: - * freenect_start_depth(devp) - */ - __pyx_t_6 = __pyx_v_mdev->ctx->_ptr; - __pyx_v_ctxp = __pyx_t_6; - - /* "freenect.pyx":413 - * devp = mdev._ptr - * ctxp = mdev.ctx._ptr - * if depth is not None: # <<<<<<<<<<<<<< - * freenect_start_depth(devp) - * freenect_set_depth_callback(devp, depth_cb) - */ - __pyx_t_2 = (__pyx_v_depth != Py_None); - __pyx_t_1 = (__pyx_t_2 != 0); - if (__pyx_t_1) { - - /* "freenect.pyx":414 - * ctxp = mdev.ctx._ptr - * if depth is not None: - * freenect_start_depth(devp) # <<<<<<<<<<<<<< - * freenect_set_depth_callback(devp, depth_cb) - * if video is not None: - */ - freenect_start_depth(__pyx_v_devp); - - /* "freenect.pyx":415 - * if depth is not None: - * freenect_start_depth(devp) - * freenect_set_depth_callback(devp, depth_cb) # <<<<<<<<<<<<<< - * if video is not None: - * freenect_start_video(devp) - */ - freenect_set_depth_callback(__pyx_v_devp, __pyx_f_8freenect_depth_cb); - goto __pyx_L10; - } - __pyx_L10:; - - /* "freenect.pyx":416 - * freenect_start_depth(devp) - * freenect_set_depth_callback(devp, depth_cb) - * if video is not None: # <<<<<<<<<<<<<< - * freenect_start_video(devp) - * freenect_set_video_callback(devp, video_cb) - */ - __pyx_t_1 = (__pyx_v_video != Py_None); - __pyx_t_2 = (__pyx_t_1 != 0); - if (__pyx_t_2) { - - /* "freenect.pyx":417 - * freenect_set_depth_callback(devp, depth_cb) - * if video is not None: - * freenect_start_video(devp) # <<<<<<<<<<<<<< - * freenect_set_video_callback(devp, video_cb) - * try: - */ - freenect_start_video(__pyx_v_devp); - - /* "freenect.pyx":418 - * if video is not None: - * freenect_start_video(devp) - * freenect_set_video_callback(devp, video_cb) # <<<<<<<<<<<<<< - * try: - * while True: - */ - freenect_set_video_callback(__pyx_v_devp, __pyx_f_8freenect_video_cb); - goto __pyx_L11; - } - __pyx_L11:; - - /* "freenect.pyx":419 - * freenect_start_video(devp) - * freenect_set_video_callback(devp, video_cb) - * try: # <<<<<<<<<<<<<< - * while True: - * with nogil: - */ - { - __Pyx_ExceptionSave(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9); - __Pyx_XGOTREF(__pyx_t_7); - __Pyx_XGOTREF(__pyx_t_8); - __Pyx_XGOTREF(__pyx_t_9); - /*try:*/ { - - /* "freenect.pyx":420 - * freenect_set_video_callback(devp, video_cb) - * try: - * while True: # <<<<<<<<<<<<<< - * with nogil: - * if freenect_process_events(ctxp) < 0: - */ - while (1) { - - /* "freenect.pyx":421 - * try: - * while True: - * with nogil: # <<<<<<<<<<<<<< - * if freenect_process_events(ctxp) < 0: - * break - */ - { - #ifdef WITH_THREAD - PyThreadState *_save; - Py_UNBLOCK_THREADS - #endif - /*try:*/ { - - /* "freenect.pyx":422 - * while True: - * with nogil: - * if freenect_process_events(ctxp) < 0: # <<<<<<<<<<<<<< - * break - * if body: - */ - __pyx_t_2 = ((freenect_process_events(__pyx_v_ctxp) < 0) != 0); - if (__pyx_t_2) { - - /* "freenect.pyx":423 - * with nogil: - * if freenect_process_events(ctxp) < 0: - * break # <<<<<<<<<<<<<< - * if body: - * body(mdev, mdev.ctx) - */ - goto __pyx_L23_break; - } - } - - /* "freenect.pyx":421 - * try: - * while True: - * with nogil: # <<<<<<<<<<<<<< - * if freenect_process_events(ctxp) < 0: - * break - */ - /*finally:*/ { - /*normal exit:*/{ - #ifdef WITH_THREAD - Py_BLOCK_THREADS - #endif - goto __pyx_L26; - } - __pyx_L23_break: { - #ifdef WITH_THREAD - Py_BLOCK_THREADS - #endif - goto __pyx_L21_break; - } - __pyx_L26:; - } - } - - /* "freenect.pyx":424 - * if freenect_process_events(ctxp) < 0: - * break - * if body: # <<<<<<<<<<<<<< - * body(mdev, mdev.ctx) - * except Kill: - */ - __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_body); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L12_error;} - if (__pyx_t_2) { - - /* "freenect.pyx":425 - * break - * if body: - * body(mdev, mdev.ctx) # <<<<<<<<<<<<<< - * except Kill: - * pass - */ - __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __pyx_L12_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_INCREF(((PyObject *)__pyx_v_mdev)); - PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_mdev)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_mdev)); - __Pyx_INCREF(((PyObject *)__pyx_v_mdev->ctx)); - PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_v_mdev->ctx)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_mdev->ctx)); - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_v_body, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __pyx_L12_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - goto __pyx_L28; - } - __pyx_L28:; - } - __pyx_L21_break:; - } - __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; - __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; - __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; - goto __pyx_L19_try_end; - __pyx_L12_error:; - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - - /* "freenect.pyx":426 - * if body: - * body(mdev, mdev.ctx) - * except Kill: # <<<<<<<<<<<<<< - * pass - * freenect_stop_depth(devp) - */ - __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_Kill); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L14_except_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_10 = PyErr_ExceptionMatches(__pyx_t_4); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (__pyx_t_10) { - PyErr_Restore(0,0,0); - goto __pyx_L13_exception_handled; - } - goto __pyx_L14_except_error; - __pyx_L14_except_error:; - __Pyx_XGIVEREF(__pyx_t_7); - __Pyx_XGIVEREF(__pyx_t_8); - __Pyx_XGIVEREF(__pyx_t_9); - __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9); - goto __pyx_L1_error; - __pyx_L13_exception_handled:; - __Pyx_XGIVEREF(__pyx_t_7); - __Pyx_XGIVEREF(__pyx_t_8); - __Pyx_XGIVEREF(__pyx_t_9); - __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9); - __pyx_L19_try_end:; - } - - /* "freenect.pyx":428 - * except Kill: - * pass - * freenect_stop_depth(devp) # <<<<<<<<<<<<<< - * freenect_stop_video(devp) - * if dev is None: - */ - freenect_stop_depth(__pyx_v_devp); - - /* "freenect.pyx":429 - * pass - * freenect_stop_depth(devp) - * freenect_stop_video(devp) # <<<<<<<<<<<<<< - * if dev is None: - * freenect_close_device(devp) - */ - freenect_stop_video(__pyx_v_devp); - - /* "freenect.pyx":430 - * freenect_stop_depth(devp) - * freenect_stop_video(devp) - * if dev is None: # <<<<<<<<<<<<<< - * freenect_close_device(devp) - * freenect_shutdown(ctxp) - */ - __pyx_t_2 = (__pyx_v_dev == Py_None); - __pyx_t_1 = (__pyx_t_2 != 0); - if (__pyx_t_1) { - - /* "freenect.pyx":431 - * freenect_stop_video(devp) - * if dev is None: - * freenect_close_device(devp) # <<<<<<<<<<<<<< - * freenect_shutdown(ctxp) - * - */ - freenect_close_device(__pyx_v_devp); - - /* "freenect.pyx":432 - * if dev is None: - * freenect_close_device(devp) - * freenect_shutdown(ctxp) # <<<<<<<<<<<<<< - * - * def base_runloop(CtxPtr ctx, body=None): - */ - freenect_shutdown(__pyx_v_ctxp); - goto __pyx_L29; - } - __pyx_L29:; - - /* "freenect.pyx":370 - * - * - * def runloop(depth=None, video=None, body=None, dev=None): # <<<<<<<<<<<<<< - * """Sets up the kinect and maintains a runloop - * - */ - - /* function exit code */ - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_AddTraceback("freenect.runloop", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XDECREF((PyObject *)__pyx_v_mdev); - __Pyx_XDECREF((PyObject *)__pyx_v_ctx); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "freenect.pyx":434 - * freenect_shutdown(ctxp) - * - * def base_runloop(CtxPtr ctx, body=None): # <<<<<<<<<<<<<< - * """Starts a runloop - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_8freenect_51base_runloop(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_8freenect_50base_runloop[] = "Starts a runloop\n\n This function can be used instead of runloop() to allow the Python code to\n perform all setup steps independently. This simply calls process_events in\n a loop, optionally calling a body function in between. Raise the Kill\n exception to break out of the runloop.\n\n Args:\n ctx: Freenect library context\n body: A function that takes (ctx) and is called in the body of process_events\n "; -static PyMethodDef __pyx_mdef_8freenect_51base_runloop = {__Pyx_NAMESTR("base_runloop"), (PyCFunction)__pyx_pw_8freenect_51base_runloop, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_8freenect_50base_runloop)}; -static PyObject *__pyx_pw_8freenect_51base_runloop(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - struct __pyx_obj_8freenect_CtxPtr *__pyx_v_ctx = 0; - PyObject *__pyx_v_body = 0; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("base_runloop (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_ctx,&__pyx_n_s_body,0}; - PyObject* values[2] = {0,0}; - values[1] = ((PyObject *)Py_None); - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ctx)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - case 1: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_body); - if (value) { values[1] = value; kw_args--; } - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "base_runloop") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - } else { - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - break; - default: goto __pyx_L5_argtuple_error; - } - } - __pyx_v_ctx = ((struct __pyx_obj_8freenect_CtxPtr *)values[0]); - __pyx_v_body = values[1]; - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("base_runloop", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_L3_error:; - __Pyx_AddTraceback("freenect.base_runloop", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_ctx), __pyx_ptype_8freenect_CtxPtr, 1, "ctx", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = __pyx_pf_8freenect_50base_runloop(__pyx_self, __pyx_v_ctx, __pyx_v_body); - - /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_8freenect_50base_runloop(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_CtxPtr *__pyx_v_ctx, PyObject *__pyx_v_body) { - freenect_context *__pyx_v_ctxp; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - freenect_context *__pyx_t_1; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - int __pyx_t_5; - PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; - int __pyx_t_8; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("base_runloop", 0); - - /* "freenect.pyx":447 - * """ - * cdef freenect_context* ctxp - * ctxp = ctx._ptr # <<<<<<<<<<<<<< - * try: - * while True: - */ - __pyx_t_1 = __pyx_v_ctx->_ptr; - __pyx_v_ctxp = __pyx_t_1; - - /* "freenect.pyx":448 - * cdef freenect_context* ctxp - * ctxp = ctx._ptr - * try: # <<<<<<<<<<<<<< - * while True: - * with nogil: - */ - { - __Pyx_ExceptionSave(&__pyx_t_2, &__pyx_t_3, &__pyx_t_4); - __Pyx_XGOTREF(__pyx_t_2); - __Pyx_XGOTREF(__pyx_t_3); - __Pyx_XGOTREF(__pyx_t_4); - /*try:*/ { - - /* "freenect.pyx":449 - * ctxp = ctx._ptr - * try: - * while True: # <<<<<<<<<<<<<< - * with nogil: - * if freenect_process_events(ctxp) < 0: - */ - while (1) { - - /* "freenect.pyx":450 - * try: - * while True: - * with nogil: # <<<<<<<<<<<<<< - * if freenect_process_events(ctxp) < 0: - * break - */ - { - #ifdef WITH_THREAD - PyThreadState *_save; - Py_UNBLOCK_THREADS - #endif - /*try:*/ { - - /* "freenect.pyx":451 - * while True: - * with nogil: - * if freenect_process_events(ctxp) < 0: # <<<<<<<<<<<<<< - * break - * if body: - */ - __pyx_t_5 = ((freenect_process_events(__pyx_v_ctxp) < 0) != 0); - if (__pyx_t_5) { - - /* "freenect.pyx":452 - * with nogil: - * if freenect_process_events(ctxp) < 0: - * break # <<<<<<<<<<<<<< - * if body: - * body(ctx) - */ - goto __pyx_L14_break; - } - } - - /* "freenect.pyx":450 - * try: - * while True: - * with nogil: # <<<<<<<<<<<<<< - * if freenect_process_events(ctxp) < 0: - * break - */ - /*finally:*/ { - /*normal exit:*/{ - #ifdef WITH_THREAD - Py_BLOCK_THREADS - #endif - goto __pyx_L17; - } - __pyx_L14_break: { - #ifdef WITH_THREAD - Py_BLOCK_THREADS - #endif - goto __pyx_L12_break; - } - __pyx_L17:; - } - } - - /* "freenect.pyx":453 - * if freenect_process_events(ctxp) < 0: - * break - * if body: # <<<<<<<<<<<<<< - * body(ctx) - * except Kill: - */ - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_body); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - if (__pyx_t_5) { - - /* "freenect.pyx":454 - * break - * if body: - * body(ctx) # <<<<<<<<<<<<<< - * except Kill: - * pass - */ - __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __Pyx_GOTREF(__pyx_t_6); - __Pyx_INCREF(((PyObject *)__pyx_v_ctx)); - PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_v_ctx)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_ctx)); - __pyx_t_7 = __Pyx_PyObject_Call(__pyx_v_body, __pyx_t_6, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __Pyx_GOTREF(__pyx_t_7); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - goto __pyx_L19; - } - __pyx_L19:; - } - __pyx_L12_break:; - } - __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - goto __pyx_L10_try_end; - __pyx_L3_error:; - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; - - /* "freenect.pyx":455 - * if body: - * body(ctx) - * except Kill: # <<<<<<<<<<<<<< - * pass - * - */ - __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_Kill); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;} - __Pyx_GOTREF(__pyx_t_7); - __pyx_t_8 = PyErr_ExceptionMatches(__pyx_t_7); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - if (__pyx_t_8) { - PyErr_Restore(0,0,0); - goto __pyx_L4_exception_handled; - } - goto __pyx_L5_except_error; - __pyx_L5_except_error:; - __Pyx_XGIVEREF(__pyx_t_2); - __Pyx_XGIVEREF(__pyx_t_3); - __Pyx_XGIVEREF(__pyx_t_4); - __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4); - goto __pyx_L1_error; - __pyx_L4_exception_handled:; - __Pyx_XGIVEREF(__pyx_t_2); - __Pyx_XGIVEREF(__pyx_t_3); - __Pyx_XGIVEREF(__pyx_t_4); - __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4); - __pyx_L10_try_end:; - } - - /* "freenect.pyx":434 - * freenect_shutdown(ctxp) - * - * def base_runloop(CtxPtr ctx, body=None): # <<<<<<<<<<<<<< - * """Starts a runloop - * - */ - - /* function exit code */ - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_AddTraceback("freenect.base_runloop", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "freenect.pyx":460 - * import_array() - * - * cdef object _depth_cb_np(void *data, freenect_frame_mode *mode): # <<<<<<<<<<<<<< - * cdef npc.npy_intp dims[2] - * - */ - -static PyObject *__pyx_f_8freenect__depth_cb_np(void *__pyx_v_data, freenect_frame_mode *__pyx_v_mode) { - npy_intp __pyx_v_dims[2]; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int32_t __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - int __pyx_t_5; - int __pyx_t_6; - int __pyx_t_7; - int16_t __pyx_t_8; - int16_t __pyx_t_9; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("_depth_cb_np", 0); - - /* "freenect.pyx":463 - * cdef npc.npy_intp dims[2] - * - * if mode.video_format in (DEPTH_11BIT, DEPTH_10BIT, DEPTH_REGISTERED, DEPTH_MM): # <<<<<<<<<<<<<< - * dims[0], dims[1] = mode.height, mode.width - * return PyArray_SimpleNewFromData(2, dims, npc.NPY_UINT16, data) - */ - __pyx_t_1 = __pyx_v_mode->video_format; - __pyx_t_2 = __Pyx_PyInt_From_int32_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_DEPTH_11BIT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (!__pyx_t_5) { - __pyx_t_4 = __Pyx_PyInt_From_int32_t(__pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_DEPTH_10BIT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_2 = PyObject_RichCompare(__pyx_t_4, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_7 = __pyx_t_6; - } else { - __pyx_t_7 = __pyx_t_5; - } - if (!__pyx_t_7) { - __pyx_t_2 = __Pyx_PyInt_From_int32_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_DEPTH_REGISTERED); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __pyx_t_5; - } else { - __pyx_t_6 = __pyx_t_7; - } - if (!__pyx_t_6) { - __pyx_t_4 = __Pyx_PyInt_From_int32_t(__pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_DEPTH_MM); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_2 = PyObject_RichCompare(__pyx_t_4, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_5 = __pyx_t_7; - } else { - __pyx_t_5 = __pyx_t_6; - } - __pyx_t_6 = (__pyx_t_5 != 0); - if (__pyx_t_6) { - - /* "freenect.pyx":464 - * - * if mode.video_format in (DEPTH_11BIT, DEPTH_10BIT, DEPTH_REGISTERED, DEPTH_MM): - * dims[0], dims[1] = mode.height, mode.width # <<<<<<<<<<<<<< - * return PyArray_SimpleNewFromData(2, dims, npc.NPY_UINT16, data) - * else: - */ - __pyx_t_8 = __pyx_v_mode->height; - __pyx_t_9 = __pyx_v_mode->width; - (__pyx_v_dims[0]) = __pyx_t_8; - (__pyx_v_dims[1]) = __pyx_t_9; - - /* "freenect.pyx":465 - * if mode.video_format in (DEPTH_11BIT, DEPTH_10BIT, DEPTH_REGISTERED, DEPTH_MM): - * dims[0], dims[1] = mode.height, mode.width - * return PyArray_SimpleNewFromData(2, dims, npc.NPY_UINT16, data) # <<<<<<<<<<<<<< - * else: - * return (data)[:mode.bytes] - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = PyArray_SimpleNewFromData(2, __pyx_v_dims, NPY_UINT16, __pyx_v_data); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 465; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - goto __pyx_L0; - } - /*else*/ { - - /* "freenect.pyx":467 - * return PyArray_SimpleNewFromData(2, dims, npc.NPY_UINT16, data) - * else: - * return (data)[:mode.bytes] # <<<<<<<<<<<<<< - * - * - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __Pyx_PyBytes_FromStringAndSize(((char *)__pyx_v_data) + 0, __pyx_v_mode->bytes - 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 467; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - goto __pyx_L0; - } - - /* "freenect.pyx":460 - * import_array() - * - * cdef object _depth_cb_np(void *data, freenect_frame_mode *mode): # <<<<<<<<<<<<<< - * cdef npc.npy_intp dims[2] - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_AddTraceback("freenect._depth_cb_np", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "freenect.pyx":470 - * - * - * cdef _video_cb_np(void *data, freenect_frame_mode *mode): # <<<<<<<<<<<<<< - * cdef npc.npy_intp dims[3] - * - */ - -static PyObject *__pyx_f_8freenect__video_cb_np(void *__pyx_v_data, freenect_frame_mode *__pyx_v_mode) { - npy_intp __pyx_v_dims[3]; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int32_t __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - int __pyx_t_5; - int __pyx_t_6; - int __pyx_t_7; - int16_t __pyx_t_8; - int16_t __pyx_t_9; - npy_intp __pyx_t_10; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("_video_cb_np", 0); - - /* "freenect.pyx":473 - * cdef npc.npy_intp dims[3] - * - * if mode.video_format in (VIDEO_RGB, VIDEO_YUV_RGB): # <<<<<<<<<<<<<< - * dims[0], dims[1], dims[2] = mode.height, mode.width, 3 - * return PyArray_SimpleNewFromData(3, dims, npc.NPY_UINT8, data) - */ - __pyx_t_1 = __pyx_v_mode->video_format; - __pyx_t_2 = __Pyx_PyInt_From_int32_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 473; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_VIDEO_RGB); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 473; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 473; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 473; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (!__pyx_t_5) { - __pyx_t_4 = __Pyx_PyInt_From_int32_t(__pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 473; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_VIDEO_YUV_RGB); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 473; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_2 = PyObject_RichCompare(__pyx_t_4, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 473; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 473; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_7 = __pyx_t_6; - } else { - __pyx_t_7 = __pyx_t_5; - } - __pyx_t_5 = (__pyx_t_7 != 0); - if (__pyx_t_5) { - - /* "freenect.pyx":474 - * - * if mode.video_format in (VIDEO_RGB, VIDEO_YUV_RGB): - * dims[0], dims[1], dims[2] = mode.height, mode.width, 3 # <<<<<<<<<<<<<< - * return PyArray_SimpleNewFromData(3, dims, npc.NPY_UINT8, data) - * elif mode.video_format == VIDEO_IR_8BIT: - */ - __pyx_t_8 = __pyx_v_mode->height; - __pyx_t_9 = __pyx_v_mode->width; - __pyx_t_10 = 3; - (__pyx_v_dims[0]) = __pyx_t_8; - (__pyx_v_dims[1]) = __pyx_t_9; - (__pyx_v_dims[2]) = __pyx_t_10; - - /* "freenect.pyx":475 - * if mode.video_format in (VIDEO_RGB, VIDEO_YUV_RGB): - * dims[0], dims[1], dims[2] = mode.height, mode.width, 3 - * return PyArray_SimpleNewFromData(3, dims, npc.NPY_UINT8, data) # <<<<<<<<<<<<<< - * elif mode.video_format == VIDEO_IR_8BIT: - * dims[0], dims[1] = mode.height, mode.width - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = PyArray_SimpleNewFromData(3, __pyx_v_dims, NPY_UINT8, __pyx_v_data); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 475; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - goto __pyx_L0; - } - - /* "freenect.pyx":476 - * dims[0], dims[1], dims[2] = mode.height, mode.width, 3 - * return PyArray_SimpleNewFromData(3, dims, npc.NPY_UINT8, data) - * elif mode.video_format == VIDEO_IR_8BIT: # <<<<<<<<<<<<<< - * dims[0], dims[1] = mode.height, mode.width - * return PyArray_SimpleNewFromData(2, dims, npc.NPY_UINT8, data) - */ - __pyx_t_2 = __Pyx_PyInt_From_int32_t(__pyx_v_mode->video_format); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_VIDEO_IR_8BIT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (__pyx_t_5) { - - /* "freenect.pyx":477 - * return PyArray_SimpleNewFromData(3, dims, npc.NPY_UINT8, data) - * elif mode.video_format == VIDEO_IR_8BIT: - * dims[0], dims[1] = mode.height, mode.width # <<<<<<<<<<<<<< - * return PyArray_SimpleNewFromData(2, dims, npc.NPY_UINT8, data) - * elif mode.video_format == VIDEO_IR_10BIT: - */ - __pyx_t_9 = __pyx_v_mode->height; - __pyx_t_8 = __pyx_v_mode->width; - (__pyx_v_dims[0]) = __pyx_t_9; - (__pyx_v_dims[1]) = __pyx_t_8; - - /* "freenect.pyx":478 - * elif mode.video_format == VIDEO_IR_8BIT: - * dims[0], dims[1] = mode.height, mode.width - * return PyArray_SimpleNewFromData(2, dims, npc.NPY_UINT8, data) # <<<<<<<<<<<<<< - * elif mode.video_format == VIDEO_IR_10BIT: - * dims[0], dims[1] = mode.height, mode.width - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_4 = PyArray_SimpleNewFromData(2, __pyx_v_dims, NPY_UINT8, __pyx_v_data); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_r = __pyx_t_4; - __pyx_t_4 = 0; - goto __pyx_L0; - } - - /* "freenect.pyx":479 - * dims[0], dims[1] = mode.height, mode.width - * return PyArray_SimpleNewFromData(2, dims, npc.NPY_UINT8, data) - * elif mode.video_format == VIDEO_IR_10BIT: # <<<<<<<<<<<<<< - * dims[0], dims[1] = mode.height, mode.width - * return PyArray_SimpleNewFromData(2, dims, npc.NPY_UINT16, data) - */ - __pyx_t_4 = __Pyx_PyInt_From_int32_t(__pyx_v_mode->video_format); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 479; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_VIDEO_IR_10BIT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 479; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_2 = PyObject_RichCompare(__pyx_t_4, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 479; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 479; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (__pyx_t_5) { - - /* "freenect.pyx":480 - * return PyArray_SimpleNewFromData(2, dims, npc.NPY_UINT8, data) - * elif mode.video_format == VIDEO_IR_10BIT: - * dims[0], dims[1] = mode.height, mode.width # <<<<<<<<<<<<<< - * return PyArray_SimpleNewFromData(2, dims, npc.NPY_UINT16, data) - * else: - */ - __pyx_t_8 = __pyx_v_mode->height; - __pyx_t_9 = __pyx_v_mode->width; - (__pyx_v_dims[0]) = __pyx_t_8; - (__pyx_v_dims[1]) = __pyx_t_9; - - /* "freenect.pyx":481 - * elif mode.video_format == VIDEO_IR_10BIT: - * dims[0], dims[1] = mode.height, mode.width - * return PyArray_SimpleNewFromData(2, dims, npc.NPY_UINT16, data) # <<<<<<<<<<<<<< - * else: - * return (data)[:mode.bytes] - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = PyArray_SimpleNewFromData(2, __pyx_v_dims, NPY_UINT16, __pyx_v_data); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 481; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - goto __pyx_L0; - } - /*else*/ { - - /* "freenect.pyx":483 - * return PyArray_SimpleNewFromData(2, dims, npc.NPY_UINT16, data) - * else: - * return (data)[:mode.bytes] # <<<<<<<<<<<<<< - * - * def sync_get_depth(index=0, format=DEPTH_11BIT): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __Pyx_PyBytes_FromStringAndSize(((char *)__pyx_v_data) + 0, __pyx_v_mode->bytes - 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - goto __pyx_L0; - } - - /* "freenect.pyx":470 - * - * - * cdef _video_cb_np(void *data, freenect_frame_mode *mode): # <<<<<<<<<<<<<< - * cdef npc.npy_intp dims[3] - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_AddTraceback("freenect._video_cb_np", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "freenect.pyx":485 - * return (data)[:mode.bytes] - * - * def sync_get_depth(index=0, format=DEPTH_11BIT): # <<<<<<<<<<<<<< - * """Get the next available depth frame from the kinect, as a numpy array. - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_8freenect_53sync_get_depth(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_8freenect_52sync_get_depth[] = "Get the next available depth frame from the kinect, as a numpy array.\n\n Args:\n index: Kinect device index (default: 0)\n format: Depth format (default: DEPTH_11BIT)\n\n Returns:\n (depth, timestamp) or None on error\n depth: A numpy array, shape:(640,480) dtype:np.uint16\n timestamp: int representing the time\n "; -static PyMethodDef __pyx_mdef_8freenect_53sync_get_depth = {__Pyx_NAMESTR("sync_get_depth"), (PyCFunction)__pyx_pw_8freenect_53sync_get_depth, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_8freenect_52sync_get_depth)}; -static PyObject *__pyx_pw_8freenect_53sync_get_depth(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_index = 0; - PyObject *__pyx_v_format = 0; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("sync_get_depth (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_index,&__pyx_n_s_format,0}; - PyObject* values[2] = {0,0}; - values[0] = ((PyObject *)__pyx_int_0); - values[1] = __pyx_k__5; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_index); - if (value) { values[0] = value; kw_args--; } - } - case 1: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_format); - if (value) { values[1] = value; kw_args--; } - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "sync_get_depth") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 485; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - } else { - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - } - __pyx_v_index = values[0]; - __pyx_v_format = values[1]; - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("sync_get_depth", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 485; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_L3_error:; - __Pyx_AddTraceback("freenect.sync_get_depth", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_8freenect_52sync_get_depth(__pyx_self, __pyx_v_index, __pyx_v_format); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_8freenect_52sync_get_depth(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_index, PyObject *__pyx_v_format) { - void *__pyx_v_data; - uint32_t __pyx_v_timestamp; - npy_intp __pyx_v_dims[2]; - int __pyx_v_out; - int __pyx_v__index; - freenect_depth_format __pyx_v__format; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - freenect_depth_format __pyx_t_2; - int __pyx_t_3; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - int __pyx_t_7; - int __pyx_t_8; - npy_intp __pyx_t_9; - npy_intp __pyx_t_10; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("sync_get_depth", 0); - - /* "freenect.pyx":501 - * cdef npc.npy_intp dims[2] - * cdef int out - * cdef int _index = index # <<<<<<<<<<<<<< - * cdef freenect_depth_format _format = format - * with nogil: - */ - __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_index); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 501; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v__index = __pyx_t_1; - - /* "freenect.pyx":502 - * cdef int out - * cdef int _index = index - * cdef freenect_depth_format _format = format # <<<<<<<<<<<<<< - * with nogil: - * out = freenect_sync_get_depth(&data, ×tamp, _index, _format) - */ - __pyx_t_2 = ((freenect_depth_format)PyInt_AsLong(__pyx_v_format)); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v__format = __pyx_t_2; - - /* "freenect.pyx":503 - * cdef int _index = index - * cdef freenect_depth_format _format = format - * with nogil: # <<<<<<<<<<<<<< - * out = freenect_sync_get_depth(&data, ×tamp, _index, _format) - * if out: - */ - { - #ifdef WITH_THREAD - PyThreadState *_save; - Py_UNBLOCK_THREADS - #endif - /*try:*/ { - - /* "freenect.pyx":504 - * cdef freenect_depth_format _format = format - * with nogil: - * out = freenect_sync_get_depth(&data, ×tamp, _index, _format) # <<<<<<<<<<<<<< - * if out: - * error_open_device() - */ - __pyx_v_out = freenect_sync_get_depth((&__pyx_v_data), (&__pyx_v_timestamp), __pyx_v__index, __pyx_v__format); - } - - /* "freenect.pyx":503 - * cdef int _index = index - * cdef freenect_depth_format _format = format - * with nogil: # <<<<<<<<<<<<<< - * out = freenect_sync_get_depth(&data, ×tamp, _index, _format) - * if out: - */ - /*finally:*/ { - /*normal exit:*/{ - #ifdef WITH_THREAD - Py_BLOCK_THREADS - #endif - goto __pyx_L5; - } - __pyx_L5:; - } - } - - /* "freenect.pyx":505 - * with nogil: - * out = freenect_sync_get_depth(&data, ×tamp, _index, _format) - * if out: # <<<<<<<<<<<<<< - * error_open_device() - * return - */ - __pyx_t_3 = (__pyx_v_out != 0); - if (__pyx_t_3) { - - /* "freenect.pyx":506 - * out = freenect_sync_get_depth(&data, ×tamp, _index, _format) - * if out: - * error_open_device() # <<<<<<<<<<<<<< - * return - * if format in [DEPTH_11BIT, DEPTH_10BIT, DEPTH_MM, DEPTH_REGISTERED]: - */ - __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_error_open_device); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 506; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 506; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - - /* "freenect.pyx":507 - * if out: - * error_open_device() - * return # <<<<<<<<<<<<<< - * if format in [DEPTH_11BIT, DEPTH_10BIT, DEPTH_MM, DEPTH_REGISTERED]: - * dims[0], dims[1] = 480, 640 - */ - __Pyx_XDECREF(__pyx_r); - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - } - - /* "freenect.pyx":508 - * error_open_device() - * return - * if format in [DEPTH_11BIT, DEPTH_10BIT, DEPTH_MM, DEPTH_REGISTERED]: # <<<<<<<<<<<<<< - * dims[0], dims[1] = 480, 640 - * return PyArray_SimpleNewFromData(2, dims, npc.NPY_UINT16, data), timestamp - */ - __Pyx_INCREF(__pyx_v_format); - __pyx_t_5 = __pyx_v_format; - __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_DEPTH_11BIT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_6 = PyObject_RichCompare(__pyx_t_5, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - if (!__pyx_t_3) { - __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_DEPTH_10BIT); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_4 = PyObject_RichCompare(__pyx_t_5, __pyx_t_6, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_8 = __pyx_t_7; - } else { - __pyx_t_8 = __pyx_t_3; - } - if (!__pyx_t_8) { - __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_DEPTH_MM); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_6 = PyObject_RichCompare(__pyx_t_5, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_7 = __pyx_t_3; - } else { - __pyx_t_7 = __pyx_t_8; - } - if (!__pyx_t_7) { - __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_DEPTH_REGISTERED); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_4 = PyObject_RichCompare(__pyx_t_5, __pyx_t_6, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_3 = __pyx_t_8; - } else { - __pyx_t_3 = __pyx_t_7; - } - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_7 = (__pyx_t_3 != 0); - if (__pyx_t_7) { - - /* "freenect.pyx":509 - * return - * if format in [DEPTH_11BIT, DEPTH_10BIT, DEPTH_MM, DEPTH_REGISTERED]: - * dims[0], dims[1] = 480, 640 # <<<<<<<<<<<<<< - * return PyArray_SimpleNewFromData(2, dims, npc.NPY_UINT16, data), timestamp - * else: - */ - __pyx_t_9 = 480; - __pyx_t_10 = 640; - (__pyx_v_dims[0]) = __pyx_t_9; - (__pyx_v_dims[1]) = __pyx_t_10; - - /* "freenect.pyx":510 - * if format in [DEPTH_11BIT, DEPTH_10BIT, DEPTH_MM, DEPTH_REGISTERED]: - * dims[0], dims[1] = 480, 640 - * return PyArray_SimpleNewFromData(2, dims, npc.NPY_UINT16, data), timestamp # <<<<<<<<<<<<<< - * else: - * raise TypeError('Conversion not implemented for type [%d]' % (format)) - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_5 = PyArray_SimpleNewFromData(2, __pyx_v_dims, NPY_UINT16, __pyx_v_data); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_4 = __Pyx_PyInt_From_uint32_t(__pyx_v_timestamp); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); - __Pyx_GIVEREF(__pyx_t_5); - PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_4); - __Pyx_GIVEREF(__pyx_t_4); - __pyx_t_5 = 0; - __pyx_t_4 = 0; - __pyx_r = __pyx_t_6; - __pyx_t_6 = 0; - goto __pyx_L0; - } - /*else*/ { - - /* "freenect.pyx":512 - * return PyArray_SimpleNewFromData(2, dims, npc.NPY_UINT16, data), timestamp - * else: - * raise TypeError('Conversion not implemented for type [%d]' % (format)) # <<<<<<<<<<<<<< - * - * - */ - __pyx_t_6 = __Pyx_PyString_Format(__pyx_kp_s_Conversion_not_implemented_for_t, __pyx_v_format); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); - __Pyx_GIVEREF(__pyx_t_6); - __pyx_t_6 = 0; - __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_Raise(__pyx_t_6, 0, 0, 0); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - - /* "freenect.pyx":485 - * return (data)[:mode.bytes] - * - * def sync_get_depth(index=0, format=DEPTH_11BIT): # <<<<<<<<<<<<<< - * """Get the next available depth frame from the kinect, as a numpy array. - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_AddTraceback("freenect.sync_get_depth", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "freenect.pyx":515 - * - * - * def sync_get_video(index=0, format=VIDEO_RGB): # <<<<<<<<<<<<<< - * """Get the next available rgb frame from the kinect, as a numpy array. - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_8freenect_55sync_get_video(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_8freenect_54sync_get_video[] = "Get the next available rgb frame from the kinect, as a numpy array.\n\n Args:\n index: Kinect device index (default: 0)\n format: Depth format (default: VIDEO_RGB)\n\n Returns:\n (depth, timestamp) or None on error\n depth: A numpy array, shape:(480, 640, 3) dtype:np.uint8\n timestamp: int representing the time\n "; -static PyMethodDef __pyx_mdef_8freenect_55sync_get_video = {__Pyx_NAMESTR("sync_get_video"), (PyCFunction)__pyx_pw_8freenect_55sync_get_video, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_8freenect_54sync_get_video)}; -static PyObject *__pyx_pw_8freenect_55sync_get_video(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_index = 0; - PyObject *__pyx_v_format = 0; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("sync_get_video (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_index,&__pyx_n_s_format,0}; - PyObject* values[2] = {0,0}; - values[0] = ((PyObject *)__pyx_int_0); - values[1] = __pyx_k__6; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_index); - if (value) { values[0] = value; kw_args--; } - } - case 1: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_format); - if (value) { values[1] = value; kw_args--; } - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "sync_get_video") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 515; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - } else { - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - } - __pyx_v_index = values[0]; - __pyx_v_format = values[1]; - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("sync_get_video", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 515; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_L3_error:; - __Pyx_AddTraceback("freenect.sync_get_video", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_8freenect_54sync_get_video(__pyx_self, __pyx_v_index, __pyx_v_format); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_8freenect_54sync_get_video(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_index, PyObject *__pyx_v_format) { - void *__pyx_v_data; - uint32_t __pyx_v_timestamp; - npy_intp __pyx_v_dims[3]; - int __pyx_v_out; - int __pyx_v__index; - freenect_video_format __pyx_v__format; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - freenect_video_format __pyx_t_2; - int __pyx_t_3; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - npy_intp __pyx_t_6; - npy_intp __pyx_t_7; - npy_intp __pyx_t_8; - PyObject *__pyx_t_9 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("sync_get_video", 0); - - /* "freenect.pyx":531 - * cdef npc.npy_intp dims[3] - * cdef int out - * cdef int _index = index # <<<<<<<<<<<<<< - * cdef freenect_video_format _format = format - * with nogil: - */ - __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_index); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 531; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v__index = __pyx_t_1; - - /* "freenect.pyx":532 - * cdef int out - * cdef int _index = index - * cdef freenect_video_format _format = format # <<<<<<<<<<<<<< - * with nogil: - * out = freenect_sync_get_video(&data, ×tamp, _index, _format) - */ - __pyx_t_2 = ((freenect_video_format)PyInt_AsLong(__pyx_v_format)); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 532; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v__format = __pyx_t_2; - - /* "freenect.pyx":533 - * cdef int _index = index - * cdef freenect_video_format _format = format - * with nogil: # <<<<<<<<<<<<<< - * out = freenect_sync_get_video(&data, ×tamp, _index, _format) - * if out: - */ - { - #ifdef WITH_THREAD - PyThreadState *_save; - Py_UNBLOCK_THREADS - #endif - /*try:*/ { - - /* "freenect.pyx":534 - * cdef freenect_video_format _format = format - * with nogil: - * out = freenect_sync_get_video(&data, ×tamp, _index, _format) # <<<<<<<<<<<<<< - * if out: - * error_open_device() - */ - __pyx_v_out = freenect_sync_get_video((&__pyx_v_data), (&__pyx_v_timestamp), __pyx_v__index, __pyx_v__format); - } - - /* "freenect.pyx":533 - * cdef int _index = index - * cdef freenect_video_format _format = format - * with nogil: # <<<<<<<<<<<<<< - * out = freenect_sync_get_video(&data, ×tamp, _index, _format) - * if out: - */ - /*finally:*/ { - /*normal exit:*/{ - #ifdef WITH_THREAD - Py_BLOCK_THREADS - #endif - goto __pyx_L5; - } - __pyx_L5:; - } - } - - /* "freenect.pyx":535 - * with nogil: - * out = freenect_sync_get_video(&data, ×tamp, _index, _format) - * if out: # <<<<<<<<<<<<<< - * error_open_device() - * return - */ - __pyx_t_3 = (__pyx_v_out != 0); - if (__pyx_t_3) { - - /* "freenect.pyx":536 - * out = freenect_sync_get_video(&data, ×tamp, _index, _format) - * if out: - * error_open_device() # <<<<<<<<<<<<<< - * return - * if format == VIDEO_RGB: - */ - __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_error_open_device); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 536; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 536; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - - /* "freenect.pyx":537 - * if out: - * error_open_device() - * return # <<<<<<<<<<<<<< - * if format == VIDEO_RGB: - * dims[0], dims[1], dims[2] = 480, 640, 3 - */ - __Pyx_XDECREF(__pyx_r); - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - } - - /* "freenect.pyx":538 - * error_open_device() - * return - * if format == VIDEO_RGB: # <<<<<<<<<<<<<< - * dims[0], dims[1], dims[2] = 480, 640, 3 - * return PyArray_SimpleNewFromData(3, dims, npc.NPY_UINT8, data), timestamp - */ - __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_VIDEO_RGB); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_format, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (__pyx_t_3) { - - /* "freenect.pyx":539 - * return - * if format == VIDEO_RGB: - * dims[0], dims[1], dims[2] = 480, 640, 3 # <<<<<<<<<<<<<< - * return PyArray_SimpleNewFromData(3, dims, npc.NPY_UINT8, data), timestamp - * elif format == VIDEO_IR_8BIT: - */ - __pyx_t_6 = 480; - __pyx_t_7 = 640; - __pyx_t_8 = 3; - (__pyx_v_dims[0]) = __pyx_t_6; - (__pyx_v_dims[1]) = __pyx_t_7; - (__pyx_v_dims[2]) = __pyx_t_8; - - /* "freenect.pyx":540 - * if format == VIDEO_RGB: - * dims[0], dims[1], dims[2] = 480, 640, 3 - * return PyArray_SimpleNewFromData(3, dims, npc.NPY_UINT8, data), timestamp # <<<<<<<<<<<<<< - * elif format == VIDEO_IR_8BIT: - * dims[0], dims[1] = 480, 640 - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_4 = PyArray_SimpleNewFromData(3, __pyx_v_dims, NPY_UINT8, __pyx_v_data); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __Pyx_PyInt_From_uint32_t(__pyx_v_timestamp); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_4); - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_5); - __Pyx_GIVEREF(__pyx_t_5); - __pyx_t_4 = 0; - __pyx_t_5 = 0; - __pyx_r = __pyx_t_9; - __pyx_t_9 = 0; - goto __pyx_L0; - } - - /* "freenect.pyx":541 - * dims[0], dims[1], dims[2] = 480, 640, 3 - * return PyArray_SimpleNewFromData(3, dims, npc.NPY_UINT8, data), timestamp - * elif format == VIDEO_IR_8BIT: # <<<<<<<<<<<<<< - * dims[0], dims[1] = 480, 640 - * return PyArray_SimpleNewFromData(2, dims, npc.NPY_UINT8, data), timestamp - */ - __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_VIDEO_IR_8BIT); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 541; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_5 = PyObject_RichCompare(__pyx_v_format, __pyx_t_9, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 541; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 541; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (__pyx_t_3) { - - /* "freenect.pyx":542 - * return PyArray_SimpleNewFromData(3, dims, npc.NPY_UINT8, data), timestamp - * elif format == VIDEO_IR_8BIT: - * dims[0], dims[1] = 480, 640 # <<<<<<<<<<<<<< - * return PyArray_SimpleNewFromData(2, dims, npc.NPY_UINT8, data), timestamp - * elif format == VIDEO_IR_10BIT: - */ - __pyx_t_8 = 480; - __pyx_t_7 = 640; - (__pyx_v_dims[0]) = __pyx_t_8; - (__pyx_v_dims[1]) = __pyx_t_7; - - /* "freenect.pyx":543 - * elif format == VIDEO_IR_8BIT: - * dims[0], dims[1] = 480, 640 - * return PyArray_SimpleNewFromData(2, dims, npc.NPY_UINT8, data), timestamp # <<<<<<<<<<<<<< - * elif format == VIDEO_IR_10BIT: - * dims[0], dims[1] = 480, 640 - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_5 = PyArray_SimpleNewFromData(2, __pyx_v_dims, NPY_UINT8, __pyx_v_data); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_9 = __Pyx_PyInt_From_uint32_t(__pyx_v_timestamp); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); - __Pyx_GIVEREF(__pyx_t_5); - PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_9); - __Pyx_GIVEREF(__pyx_t_9); - __pyx_t_5 = 0; - __pyx_t_9 = 0; - __pyx_r = __pyx_t_4; - __pyx_t_4 = 0; - goto __pyx_L0; - } - - /* "freenect.pyx":544 - * dims[0], dims[1] = 480, 640 - * return PyArray_SimpleNewFromData(2, dims, npc.NPY_UINT8, data), timestamp - * elif format == VIDEO_IR_10BIT: # <<<<<<<<<<<<<< - * dims[0], dims[1] = 480, 640 - * return PyArray_SimpleNewFromData(2, dims, npc.NPY_UINT16, data), timestamp - */ - __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_VIDEO_IR_10BIT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 544; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_9 = PyObject_RichCompare(__pyx_v_format, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 544; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 544; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - if (__pyx_t_3) { - - /* "freenect.pyx":545 - * return PyArray_SimpleNewFromData(2, dims, npc.NPY_UINT8, data), timestamp - * elif format == VIDEO_IR_10BIT: - * dims[0], dims[1] = 480, 640 # <<<<<<<<<<<<<< - * return PyArray_SimpleNewFromData(2, dims, npc.NPY_UINT16, data), timestamp - * else: - */ - __pyx_t_7 = 480; - __pyx_t_8 = 640; - (__pyx_v_dims[0]) = __pyx_t_7; - (__pyx_v_dims[1]) = __pyx_t_8; - - /* "freenect.pyx":546 - * elif format == VIDEO_IR_10BIT: - * dims[0], dims[1] = 480, 640 - * return PyArray_SimpleNewFromData(2, dims, npc.NPY_UINT16, data), timestamp # <<<<<<<<<<<<<< - * else: - * raise TypeError('Conversion not implemented for type [%d]' % (format)) - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_9 = PyArray_SimpleNewFromData(2, __pyx_v_dims, NPY_UINT16, __pyx_v_data); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_4 = __Pyx_PyInt_From_uint32_t(__pyx_v_timestamp); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_9); - __Pyx_GIVEREF(__pyx_t_9); - PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4); - __Pyx_GIVEREF(__pyx_t_4); - __pyx_t_9 = 0; - __pyx_t_4 = 0; - __pyx_r = __pyx_t_5; - __pyx_t_5 = 0; - goto __pyx_L0; - } - /*else*/ { - - /* "freenect.pyx":548 - * return PyArray_SimpleNewFromData(2, dims, npc.NPY_UINT16, data), timestamp - * else: - * raise TypeError('Conversion not implemented for type [%d]' % (format)) # <<<<<<<<<<<<<< - * - * - */ - __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Conversion_not_implemented_for_t, __pyx_v_format); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); - __Pyx_GIVEREF(__pyx_t_5); - __pyx_t_5 = 0; - __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_Raise(__pyx_t_5, 0, 0, 0); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - - /* "freenect.pyx":515 - * - * - * def sync_get_video(index=0, format=VIDEO_RGB): # <<<<<<<<<<<<<< - * """Get the next available rgb frame from the kinect, as a numpy array. - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_9); - __Pyx_AddTraceback("freenect.sync_get_video", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "freenect.pyx":551 - * - * - * def sync_stop(): # <<<<<<<<<<<<<< - * """Terminate the synchronous runloop if running, else this is a NOP - * """ - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_8freenect_57sync_stop(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static char __pyx_doc_8freenect_56sync_stop[] = "Terminate the synchronous runloop if running, else this is a NOP\n "; -static PyMethodDef __pyx_mdef_8freenect_57sync_stop = {__Pyx_NAMESTR("sync_stop"), (PyCFunction)__pyx_pw_8freenect_57sync_stop, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_8freenect_56sync_stop)}; -static PyObject *__pyx_pw_8freenect_57sync_stop(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("sync_stop (wrapper)", 0); - __pyx_r = __pyx_pf_8freenect_56sync_stop(__pyx_self); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_8freenect_56sync_stop(CYTHON_UNUSED PyObject *__pyx_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("sync_stop", 0); - - /* "freenect.pyx":554 - * """Terminate the synchronous runloop if running, else this is a NOP - * """ - * freenect_sync_stop() # <<<<<<<<<<<<<< - */ - freenect_sync_stop(); - - /* "freenect.pyx":551 - * - * - * def sync_stop(): # <<<<<<<<<<<<<< - * """Terminate the synchronous runloop if running, else this is a NOP - * """ - */ - - /* function exit code */ - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":194 - * # experimental exception made for __getbuffer__ and __releasebuffer__ - * # -- the details of this may change. - * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<< - * # This implementation of getbuffer is geared towards Cython - * # requirements, and does not yet fullfill the PEP. - */ - -/* Python wrapper */ -static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/ -static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0); - __pyx_r = __pyx_pf_5numpy_7ndarray___getbuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { - int __pyx_v_copy_shape; - int __pyx_v_i; - int __pyx_v_ndim; - int __pyx_v_endian_detector; - int __pyx_v_little_endian; - int __pyx_v_t; - char *__pyx_v_f; - PyArray_Descr *__pyx_v_descr = 0; - int __pyx_v_offset; - int __pyx_v_hasfields; - int __pyx_r; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - int __pyx_t_2; - int __pyx_t_3; - PyObject *__pyx_t_4 = NULL; - int __pyx_t_5; - int __pyx_t_6; - int __pyx_t_7; - PyObject *__pyx_t_8 = NULL; - char *__pyx_t_9; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__getbuffer__", 0); - if (__pyx_v_info != NULL) { - __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None); - __Pyx_GIVEREF(__pyx_v_info->obj); - } - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":200 - * # of flags - * - * if info == NULL: return # <<<<<<<<<<<<<< - * - * cdef int copy_shape, i, ndim - */ - __pyx_t_1 = ((__pyx_v_info == NULL) != 0); - if (__pyx_t_1) { - __pyx_r = 0; - goto __pyx_L0; - } - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":203 - * - * cdef int copy_shape, i, ndim - * cdef int endian_detector = 1 # <<<<<<<<<<<<<< - * cdef bint little_endian = ((&endian_detector)[0] != 0) - * - */ - __pyx_v_endian_detector = 1; - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":204 - * cdef int copy_shape, i, ndim - * cdef int endian_detector = 1 - * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< - * - * ndim = PyArray_NDIM(self) - */ - __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":206 - * cdef bint little_endian = ((&endian_detector)[0] != 0) - * - * ndim = PyArray_NDIM(self) # <<<<<<<<<<<<<< - * - * if sizeof(npy_intp) != sizeof(Py_ssize_t): - */ - __pyx_v_ndim = PyArray_NDIM(__pyx_v_self); - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":208 - * ndim = PyArray_NDIM(self) - * - * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< - * copy_shape = 1 - * else: - */ - __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); - if (__pyx_t_1) { - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":209 - * - * if sizeof(npy_intp) != sizeof(Py_ssize_t): - * copy_shape = 1 # <<<<<<<<<<<<<< - * else: - * copy_shape = 0 - */ - __pyx_v_copy_shape = 1; - goto __pyx_L4; - } - /*else*/ { - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":211 - * copy_shape = 1 - * else: - * copy_shape = 0 # <<<<<<<<<<<<<< - * - * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) - */ - __pyx_v_copy_shape = 0; - } - __pyx_L4:; - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":213 - * copy_shape = 0 - * - * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< - * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): - * raise ValueError(u"ndarray is not C contiguous") - */ - __pyx_t_1 = (((__pyx_v_flags & PyBUF_C_CONTIGUOUS) == PyBUF_C_CONTIGUOUS) != 0); - if (__pyx_t_1) { - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":214 - * - * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) - * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): # <<<<<<<<<<<<<< - * raise ValueError(u"ndarray is not C contiguous") - * - */ - __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_C_CONTIGUOUS) != 0)) != 0); - __pyx_t_3 = __pyx_t_2; - } else { - __pyx_t_3 = __pyx_t_1; - } - if (__pyx_t_3) { - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":215 - * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) - * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): - * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< - * - * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) - */ - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_Raise(__pyx_t_4, 0, 0, 0); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - {__pyx_filename = __pyx_f[1]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":217 - * raise ValueError(u"ndarray is not C contiguous") - * - * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< - * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): - * raise ValueError(u"ndarray is not Fortran contiguous") - */ - __pyx_t_3 = (((__pyx_v_flags & PyBUF_F_CONTIGUOUS) == PyBUF_F_CONTIGUOUS) != 0); - if (__pyx_t_3) { - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":218 - * - * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) - * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): # <<<<<<<<<<<<<< - * raise ValueError(u"ndarray is not Fortran contiguous") - * - */ - __pyx_t_1 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_F_CONTIGUOUS) != 0)) != 0); - __pyx_t_2 = __pyx_t_1; - } else { - __pyx_t_2 = __pyx_t_3; - } - if (__pyx_t_2) { - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":219 - * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) - * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): - * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< - * - * info.buf = PyArray_DATA(self) - */ - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_Raise(__pyx_t_4, 0, 0, 0); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - {__pyx_filename = __pyx_f[1]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":221 - * raise ValueError(u"ndarray is not Fortran contiguous") - * - * info.buf = PyArray_DATA(self) # <<<<<<<<<<<<<< - * info.ndim = ndim - * if copy_shape: - */ - __pyx_v_info->buf = PyArray_DATA(__pyx_v_self); - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":222 - * - * info.buf = PyArray_DATA(self) - * info.ndim = ndim # <<<<<<<<<<<<<< - * if copy_shape: - * # Allocate new buffer for strides and shape info. - */ - __pyx_v_info->ndim = __pyx_v_ndim; - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":223 - * info.buf = PyArray_DATA(self) - * info.ndim = ndim - * if copy_shape: # <<<<<<<<<<<<<< - * # Allocate new buffer for strides and shape info. - * # This is allocated as one block, strides first. - */ - __pyx_t_2 = (__pyx_v_copy_shape != 0); - if (__pyx_t_2) { - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":226 - * # Allocate new buffer for strides and shape info. - * # This is allocated as one block, strides first. - * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) # <<<<<<<<<<<<<< - * info.shape = info.strides + ndim - * for i in range(ndim): - */ - __pyx_v_info->strides = ((Py_ssize_t *)malloc((((sizeof(Py_ssize_t)) * ((size_t)__pyx_v_ndim)) * 2))); - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":227 - * # This is allocated as one block, strides first. - * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) - * info.shape = info.strides + ndim # <<<<<<<<<<<<<< - * for i in range(ndim): - * info.strides[i] = PyArray_STRIDES(self)[i] - */ - __pyx_v_info->shape = (__pyx_v_info->strides + __pyx_v_ndim); - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":228 - * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) - * info.shape = info.strides + ndim - * for i in range(ndim): # <<<<<<<<<<<<<< - * info.strides[i] = PyArray_STRIDES(self)[i] - * info.shape[i] = PyArray_DIMS(self)[i] - */ - __pyx_t_5 = __pyx_v_ndim; - for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { - __pyx_v_i = __pyx_t_6; - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":229 - * info.shape = info.strides + ndim - * for i in range(ndim): - * info.strides[i] = PyArray_STRIDES(self)[i] # <<<<<<<<<<<<<< - * info.shape[i] = PyArray_DIMS(self)[i] - * else: - */ - (__pyx_v_info->strides[__pyx_v_i]) = (PyArray_STRIDES(__pyx_v_self)[__pyx_v_i]); - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":230 - * for i in range(ndim): - * info.strides[i] = PyArray_STRIDES(self)[i] - * info.shape[i] = PyArray_DIMS(self)[i] # <<<<<<<<<<<<<< - * else: - * info.strides = PyArray_STRIDES(self) - */ - (__pyx_v_info->shape[__pyx_v_i]) = (PyArray_DIMS(__pyx_v_self)[__pyx_v_i]); - } - goto __pyx_L7; - } - /*else*/ { - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":232 - * info.shape[i] = PyArray_DIMS(self)[i] - * else: - * info.strides = PyArray_STRIDES(self) # <<<<<<<<<<<<<< - * info.shape = PyArray_DIMS(self) - * info.suboffsets = NULL - */ - __pyx_v_info->strides = ((Py_ssize_t *)PyArray_STRIDES(__pyx_v_self)); - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":233 - * else: - * info.strides = PyArray_STRIDES(self) - * info.shape = PyArray_DIMS(self) # <<<<<<<<<<<<<< - * info.suboffsets = NULL - * info.itemsize = PyArray_ITEMSIZE(self) - */ - __pyx_v_info->shape = ((Py_ssize_t *)PyArray_DIMS(__pyx_v_self)); - } - __pyx_L7:; - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":234 - * info.strides = PyArray_STRIDES(self) - * info.shape = PyArray_DIMS(self) - * info.suboffsets = NULL # <<<<<<<<<<<<<< - * info.itemsize = PyArray_ITEMSIZE(self) - * info.readonly = not PyArray_ISWRITEABLE(self) - */ - __pyx_v_info->suboffsets = NULL; - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":235 - * info.shape = PyArray_DIMS(self) - * info.suboffsets = NULL - * info.itemsize = PyArray_ITEMSIZE(self) # <<<<<<<<<<<<<< - * info.readonly = not PyArray_ISWRITEABLE(self) - * - */ - __pyx_v_info->itemsize = PyArray_ITEMSIZE(__pyx_v_self); - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":236 - * info.suboffsets = NULL - * info.itemsize = PyArray_ITEMSIZE(self) - * info.readonly = not PyArray_ISWRITEABLE(self) # <<<<<<<<<<<<<< - * - * cdef int t - */ - __pyx_v_info->readonly = (!(PyArray_ISWRITEABLE(__pyx_v_self) != 0)); - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":239 - * - * cdef int t - * cdef char* f = NULL # <<<<<<<<<<<<<< - * cdef dtype descr = self.descr - * cdef list stack - */ - __pyx_v_f = NULL; - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":240 - * cdef int t - * cdef char* f = NULL - * cdef dtype descr = self.descr # <<<<<<<<<<<<<< - * cdef list stack - * cdef int offset - */ - __pyx_t_4 = ((PyObject *)__pyx_v_self->descr); - __Pyx_INCREF(__pyx_t_4); - __pyx_v_descr = ((PyArray_Descr *)__pyx_t_4); - __pyx_t_4 = 0; - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":244 - * cdef int offset - * - * cdef bint hasfields = PyDataType_HASFIELDS(descr) # <<<<<<<<<<<<<< - * - * if not hasfields and not copy_shape: - */ - __pyx_v_hasfields = PyDataType_HASFIELDS(__pyx_v_descr); - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":246 - * cdef bint hasfields = PyDataType_HASFIELDS(descr) - * - * if not hasfields and not copy_shape: # <<<<<<<<<<<<<< - * # do not call releasebuffer - * info.obj = None - */ - __pyx_t_2 = ((!(__pyx_v_hasfields != 0)) != 0); - if (__pyx_t_2) { - __pyx_t_3 = ((!(__pyx_v_copy_shape != 0)) != 0); - __pyx_t_1 = __pyx_t_3; - } else { - __pyx_t_1 = __pyx_t_2; - } - if (__pyx_t_1) { - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":248 - * if not hasfields and not copy_shape: - * # do not call releasebuffer - * info.obj = None # <<<<<<<<<<<<<< - * else: - * # need to call releasebuffer - */ - __Pyx_INCREF(Py_None); - __Pyx_GIVEREF(Py_None); - __Pyx_GOTREF(__pyx_v_info->obj); - __Pyx_DECREF(__pyx_v_info->obj); - __pyx_v_info->obj = Py_None; - goto __pyx_L10; - } - /*else*/ { - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":251 - * else: - * # need to call releasebuffer - * info.obj = self # <<<<<<<<<<<<<< - * - * if not hasfields: - */ - __Pyx_INCREF(((PyObject *)__pyx_v_self)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); - __Pyx_GOTREF(__pyx_v_info->obj); - __Pyx_DECREF(__pyx_v_info->obj); - __pyx_v_info->obj = ((PyObject *)__pyx_v_self); - } - __pyx_L10:; - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":253 - * info.obj = self - * - * if not hasfields: # <<<<<<<<<<<<<< - * t = descr.type_num - * if ((descr.byteorder == c'>' and little_endian) or - */ - __pyx_t_1 = ((!(__pyx_v_hasfields != 0)) != 0); - if (__pyx_t_1) { - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":254 - * - * if not hasfields: - * t = descr.type_num # <<<<<<<<<<<<<< - * if ((descr.byteorder == c'>' and little_endian) or - * (descr.byteorder == c'<' and not little_endian)): - */ - __pyx_t_5 = __pyx_v_descr->type_num; - __pyx_v_t = __pyx_t_5; - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":255 - * if not hasfields: - * t = descr.type_num - * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< - * (descr.byteorder == c'<' and not little_endian)): - * raise ValueError(u"Non-native byte order not supported") - */ - __pyx_t_1 = ((__pyx_v_descr->byteorder == '>') != 0); - if (__pyx_t_1) { - __pyx_t_2 = (__pyx_v_little_endian != 0); - } else { - __pyx_t_2 = __pyx_t_1; - } - if (!__pyx_t_2) { - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":256 - * t = descr.type_num - * if ((descr.byteorder == c'>' and little_endian) or - * (descr.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< - * raise ValueError(u"Non-native byte order not supported") - * if t == NPY_BYTE: f = "b" - */ - __pyx_t_1 = ((__pyx_v_descr->byteorder == '<') != 0); - if (__pyx_t_1) { - __pyx_t_3 = ((!(__pyx_v_little_endian != 0)) != 0); - __pyx_t_7 = __pyx_t_3; - } else { - __pyx_t_7 = __pyx_t_1; - } - __pyx_t_1 = __pyx_t_7; - } else { - __pyx_t_1 = __pyx_t_2; - } - if (__pyx_t_1) { - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":257 - * if ((descr.byteorder == c'>' and little_endian) or - * (descr.byteorder == c'<' and not little_endian)): - * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< - * if t == NPY_BYTE: f = "b" - * elif t == NPY_UBYTE: f = "B" - */ - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_Raise(__pyx_t_4, 0, 0, 0); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - {__pyx_filename = __pyx_f[1]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":274 - * elif t == NPY_CDOUBLE: f = "Zd" - * elif t == NPY_CLONGDOUBLE: f = "Zg" - * elif t == NPY_OBJECT: f = "O" # <<<<<<<<<<<<<< - * else: - * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) - */ - switch (__pyx_v_t) { - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":258 - * (descr.byteorder == c'<' and not little_endian)): - * raise ValueError(u"Non-native byte order not supported") - * if t == NPY_BYTE: f = "b" # <<<<<<<<<<<<<< - * elif t == NPY_UBYTE: f = "B" - * elif t == NPY_SHORT: f = "h" - */ - case NPY_BYTE: - __pyx_v_f = __pyx_k_b; - break; - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":259 - * raise ValueError(u"Non-native byte order not supported") - * if t == NPY_BYTE: f = "b" - * elif t == NPY_UBYTE: f = "B" # <<<<<<<<<<<<<< - * elif t == NPY_SHORT: f = "h" - * elif t == NPY_USHORT: f = "H" - */ - case NPY_UBYTE: - __pyx_v_f = __pyx_k_B; - break; - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":260 - * if t == NPY_BYTE: f = "b" - * elif t == NPY_UBYTE: f = "B" - * elif t == NPY_SHORT: f = "h" # <<<<<<<<<<<<<< - * elif t == NPY_USHORT: f = "H" - * elif t == NPY_INT: f = "i" - */ - case NPY_SHORT: - __pyx_v_f = __pyx_k_h; - break; - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":261 - * elif t == NPY_UBYTE: f = "B" - * elif t == NPY_SHORT: f = "h" - * elif t == NPY_USHORT: f = "H" # <<<<<<<<<<<<<< - * elif t == NPY_INT: f = "i" - * elif t == NPY_UINT: f = "I" - */ - case NPY_USHORT: - __pyx_v_f = __pyx_k_H; - break; - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":262 - * elif t == NPY_SHORT: f = "h" - * elif t == NPY_USHORT: f = "H" - * elif t == NPY_INT: f = "i" # <<<<<<<<<<<<<< - * elif t == NPY_UINT: f = "I" - * elif t == NPY_LONG: f = "l" - */ - case NPY_INT: - __pyx_v_f = __pyx_k_i; - break; - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":263 - * elif t == NPY_USHORT: f = "H" - * elif t == NPY_INT: f = "i" - * elif t == NPY_UINT: f = "I" # <<<<<<<<<<<<<< - * elif t == NPY_LONG: f = "l" - * elif t == NPY_ULONG: f = "L" - */ - case NPY_UINT: - __pyx_v_f = __pyx_k_I; - break; - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":264 - * elif t == NPY_INT: f = "i" - * elif t == NPY_UINT: f = "I" - * elif t == NPY_LONG: f = "l" # <<<<<<<<<<<<<< - * elif t == NPY_ULONG: f = "L" - * elif t == NPY_LONGLONG: f = "q" - */ - case NPY_LONG: - __pyx_v_f = __pyx_k_l; - break; - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":265 - * elif t == NPY_UINT: f = "I" - * elif t == NPY_LONG: f = "l" - * elif t == NPY_ULONG: f = "L" # <<<<<<<<<<<<<< - * elif t == NPY_LONGLONG: f = "q" - * elif t == NPY_ULONGLONG: f = "Q" - */ - case NPY_ULONG: - __pyx_v_f = __pyx_k_L; - break; - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":266 - * elif t == NPY_LONG: f = "l" - * elif t == NPY_ULONG: f = "L" - * elif t == NPY_LONGLONG: f = "q" # <<<<<<<<<<<<<< - * elif t == NPY_ULONGLONG: f = "Q" - * elif t == NPY_FLOAT: f = "f" - */ - case NPY_LONGLONG: - __pyx_v_f = __pyx_k_q; - break; - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":267 - * elif t == NPY_ULONG: f = "L" - * elif t == NPY_LONGLONG: f = "q" - * elif t == NPY_ULONGLONG: f = "Q" # <<<<<<<<<<<<<< - * elif t == NPY_FLOAT: f = "f" - * elif t == NPY_DOUBLE: f = "d" - */ - case NPY_ULONGLONG: - __pyx_v_f = __pyx_k_Q; - break; - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":268 - * elif t == NPY_LONGLONG: f = "q" - * elif t == NPY_ULONGLONG: f = "Q" - * elif t == NPY_FLOAT: f = "f" # <<<<<<<<<<<<<< - * elif t == NPY_DOUBLE: f = "d" - * elif t == NPY_LONGDOUBLE: f = "g" - */ - case NPY_FLOAT: - __pyx_v_f = __pyx_k_f; - break; - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":269 - * elif t == NPY_ULONGLONG: f = "Q" - * elif t == NPY_FLOAT: f = "f" - * elif t == NPY_DOUBLE: f = "d" # <<<<<<<<<<<<<< - * elif t == NPY_LONGDOUBLE: f = "g" - * elif t == NPY_CFLOAT: f = "Zf" - */ - case NPY_DOUBLE: - __pyx_v_f = __pyx_k_d; - break; - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":270 - * elif t == NPY_FLOAT: f = "f" - * elif t == NPY_DOUBLE: f = "d" - * elif t == NPY_LONGDOUBLE: f = "g" # <<<<<<<<<<<<<< - * elif t == NPY_CFLOAT: f = "Zf" - * elif t == NPY_CDOUBLE: f = "Zd" - */ - case NPY_LONGDOUBLE: - __pyx_v_f = __pyx_k_g; - break; - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":271 - * elif t == NPY_DOUBLE: f = "d" - * elif t == NPY_LONGDOUBLE: f = "g" - * elif t == NPY_CFLOAT: f = "Zf" # <<<<<<<<<<<<<< - * elif t == NPY_CDOUBLE: f = "Zd" - * elif t == NPY_CLONGDOUBLE: f = "Zg" - */ - case NPY_CFLOAT: - __pyx_v_f = __pyx_k_Zf; - break; - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":272 - * elif t == NPY_LONGDOUBLE: f = "g" - * elif t == NPY_CFLOAT: f = "Zf" - * elif t == NPY_CDOUBLE: f = "Zd" # <<<<<<<<<<<<<< - * elif t == NPY_CLONGDOUBLE: f = "Zg" - * elif t == NPY_OBJECT: f = "O" - */ - case NPY_CDOUBLE: - __pyx_v_f = __pyx_k_Zd; - break; - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":273 - * elif t == NPY_CFLOAT: f = "Zf" - * elif t == NPY_CDOUBLE: f = "Zd" - * elif t == NPY_CLONGDOUBLE: f = "Zg" # <<<<<<<<<<<<<< - * elif t == NPY_OBJECT: f = "O" - * else: - */ - case NPY_CLONGDOUBLE: - __pyx_v_f = __pyx_k_Zg; - break; - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":274 - * elif t == NPY_CDOUBLE: f = "Zd" - * elif t == NPY_CLONGDOUBLE: f = "Zg" - * elif t == NPY_OBJECT: f = "O" # <<<<<<<<<<<<<< - * else: - * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) - */ - case NPY_OBJECT: - __pyx_v_f = __pyx_k_O; - break; - default: - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":276 - * elif t == NPY_OBJECT: f = "O" - * else: - * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< - * info.format = f - * return - */ - __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_t); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_8 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_t_4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_8); - __Pyx_GIVEREF(__pyx_t_8); - __pyx_t_8 = 0; - __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_Raise(__pyx_t_8, 0, 0, 0); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - {__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - break; - } - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":277 - * else: - * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) - * info.format = f # <<<<<<<<<<<<<< - * return - * else: - */ - __pyx_v_info->format = __pyx_v_f; - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":278 - * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) - * info.format = f - * return # <<<<<<<<<<<<<< - * else: - * info.format = stdlib.malloc(_buffer_format_string_len) - */ - __pyx_r = 0; - goto __pyx_L0; - } - /*else*/ { - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":280 - * return - * else: - * info.format = stdlib.malloc(_buffer_format_string_len) # <<<<<<<<<<<<<< - * info.format[0] = c'^' # Native data types, manual alignment - * offset = 0 - */ - __pyx_v_info->format = ((char *)malloc(255)); - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":281 - * else: - * info.format = stdlib.malloc(_buffer_format_string_len) - * info.format[0] = c'^' # Native data types, manual alignment # <<<<<<<<<<<<<< - * offset = 0 - * f = _util_dtypestring(descr, info.format + 1, - */ - (__pyx_v_info->format[0]) = '^'; - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":282 - * info.format = stdlib.malloc(_buffer_format_string_len) - * info.format[0] = c'^' # Native data types, manual alignment - * offset = 0 # <<<<<<<<<<<<<< - * f = _util_dtypestring(descr, info.format + 1, - * info.format + _buffer_format_string_len, - */ - __pyx_v_offset = 0; - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":283 - * info.format[0] = c'^' # Native data types, manual alignment - * offset = 0 - * f = _util_dtypestring(descr, info.format + 1, # <<<<<<<<<<<<<< - * info.format + _buffer_format_string_len, - * &offset) - */ - __pyx_t_9 = __pyx_f_5numpy__util_dtypestring(__pyx_v_descr, (__pyx_v_info->format + 1), (__pyx_v_info->format + 255), (&__pyx_v_offset)); if (unlikely(__pyx_t_9 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_f = __pyx_t_9; - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":286 - * info.format + _buffer_format_string_len, - * &offset) - * f[0] = c'\0' # Terminate format string # <<<<<<<<<<<<<< - * - * def __releasebuffer__(ndarray self, Py_buffer* info): - */ - (__pyx_v_f[0]) = '\x00'; - } - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":194 - * # experimental exception made for __getbuffer__ and __releasebuffer__ - * # -- the details of this may change. - * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<< - * # This implementation of getbuffer is geared towards Cython - * # requirements, and does not yet fullfill the PEP. - */ - - /* function exit code */ - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_8); - __Pyx_AddTraceback("numpy.ndarray.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; - if (__pyx_v_info != NULL && __pyx_v_info->obj != NULL) { - __Pyx_GOTREF(__pyx_v_info->obj); - __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = NULL; - } - goto __pyx_L2; - __pyx_L0:; - if (__pyx_v_info != NULL && __pyx_v_info->obj == Py_None) { - __Pyx_GOTREF(Py_None); - __Pyx_DECREF(Py_None); __pyx_v_info->obj = NULL; - } - __pyx_L2:; - __Pyx_XDECREF((PyObject *)__pyx_v_descr); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":288 - * f[0] = c'\0' # Terminate format string - * - * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<< - * if PyArray_HASFIELDS(self): - * stdlib.free(info.format) - */ - -/* Python wrapper */ -static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info); /*proto*/ -static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__releasebuffer__ (wrapper)", 0); - __pyx_pf_5numpy_7ndarray_2__releasebuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); -} - -static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info) { - __Pyx_RefNannyDeclarations - int __pyx_t_1; - __Pyx_RefNannySetupContext("__releasebuffer__", 0); - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":289 - * - * def __releasebuffer__(ndarray self, Py_buffer* info): - * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<< - * stdlib.free(info.format) - * if sizeof(npy_intp) != sizeof(Py_ssize_t): - */ - __pyx_t_1 = (PyArray_HASFIELDS(__pyx_v_self) != 0); - if (__pyx_t_1) { - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":290 - * def __releasebuffer__(ndarray self, Py_buffer* info): - * if PyArray_HASFIELDS(self): - * stdlib.free(info.format) # <<<<<<<<<<<<<< - * if sizeof(npy_intp) != sizeof(Py_ssize_t): - * stdlib.free(info.strides) - */ - free(__pyx_v_info->format); - goto __pyx_L3; - } - __pyx_L3:; - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":291 - * if PyArray_HASFIELDS(self): - * stdlib.free(info.format) - * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< - * stdlib.free(info.strides) - * # info.shape was stored after info.strides in the same block - */ - __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); - if (__pyx_t_1) { - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":292 - * stdlib.free(info.format) - * if sizeof(npy_intp) != sizeof(Py_ssize_t): - * stdlib.free(info.strides) # <<<<<<<<<<<<<< - * # info.shape was stored after info.strides in the same block - * - */ - free(__pyx_v_info->strides); - goto __pyx_L4; - } - __pyx_L4:; - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":288 - * f[0] = c'\0' # Terminate format string - * - * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<< - * if PyArray_HASFIELDS(self): - * stdlib.free(info.format) - */ - - /* function exit code */ - __Pyx_RefNannyFinishContext(); -} - -/* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":768 - * ctypedef npy_cdouble complex_t - * - * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(1, a) - * - */ - -static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__pyx_v_a) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0); - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":769 - * - * cdef inline object PyArray_MultiIterNew1(a): - * return PyArray_MultiIterNew(1, a) # <<<<<<<<<<<<<< - * - * cdef inline object PyArray_MultiIterNew2(a, b): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 769; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":768 - * ctypedef npy_cdouble complex_t - * - * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(1, a) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("numpy.PyArray_MultiIterNew1", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":771 - * return PyArray_MultiIterNew(1, a) - * - * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(2, a, b) - * - */ - -static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__pyx_v_a, PyObject *__pyx_v_b) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0); - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":772 - * - * cdef inline object PyArray_MultiIterNew2(a, b): - * return PyArray_MultiIterNew(2, a, b) # <<<<<<<<<<<<<< - * - * cdef inline object PyArray_MultiIterNew3(a, b, c): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 772; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":771 - * return PyArray_MultiIterNew(1, a) - * - * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(2, a, b) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("numpy.PyArray_MultiIterNew2", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":774 - * return PyArray_MultiIterNew(2, a, b) - * - * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(3, a, b, c) - * - */ - -static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0); - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":775 - * - * cdef inline object PyArray_MultiIterNew3(a, b, c): - * return PyArray_MultiIterNew(3, a, b, c) # <<<<<<<<<<<<<< - * - * cdef inline object PyArray_MultiIterNew4(a, b, c, d): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(3, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 775; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":774 - * return PyArray_MultiIterNew(2, a, b) - * - * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(3, a, b, c) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("numpy.PyArray_MultiIterNew3", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":777 - * return PyArray_MultiIterNew(3, a, b, c) - * - * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(4, a, b, c, d) - * - */ - -static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0); - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":778 - * - * cdef inline object PyArray_MultiIterNew4(a, b, c, d): - * return PyArray_MultiIterNew(4, a, b, c, d) # <<<<<<<<<<<<<< - * - * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(4, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":777 - * return PyArray_MultiIterNew(3, a, b, c) - * - * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(4, a, b, c, d) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("numpy.PyArray_MultiIterNew4", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":780 - * return PyArray_MultiIterNew(4, a, b, c, d) - * - * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(5, a, b, c, d, e) - * - */ - -static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d, PyObject *__pyx_v_e) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0); - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":781 - * - * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): - * return PyArray_MultiIterNew(5, a, b, c, d, e) # <<<<<<<<<<<<<< - * - * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(5, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d), ((void *)__pyx_v_e)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 781; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":780 - * return PyArray_MultiIterNew(4, a, b, c, d) - * - * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(5, a, b, c, d, e) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("numpy.PyArray_MultiIterNew5", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":783 - * return PyArray_MultiIterNew(5, a, b, c, d, e) - * - * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<< - * # Recursive utility function used in __getbuffer__ to get format - * # string. The new location in the format string is returned. - */ - -static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_descr, char *__pyx_v_f, char *__pyx_v_end, int *__pyx_v_offset) { - PyArray_Descr *__pyx_v_child = 0; - int __pyx_v_endian_detector; - int __pyx_v_little_endian; - PyObject *__pyx_v_fields = 0; - PyObject *__pyx_v_childname = NULL; - PyObject *__pyx_v_new_offset = NULL; - PyObject *__pyx_v_t = NULL; - char *__pyx_r; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - Py_ssize_t __pyx_t_2; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - int __pyx_t_5; - int __pyx_t_6; - int __pyx_t_7; - int __pyx_t_8; - int __pyx_t_9; - long __pyx_t_10; - char *__pyx_t_11; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("_util_dtypestring", 0); - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":790 - * cdef int delta_offset - * cdef tuple i - * cdef int endian_detector = 1 # <<<<<<<<<<<<<< - * cdef bint little_endian = ((&endian_detector)[0] != 0) - * cdef tuple fields - */ - __pyx_v_endian_detector = 1; - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":791 - * cdef tuple i - * cdef int endian_detector = 1 - * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< - * cdef tuple fields - * - */ - __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":794 - * cdef tuple fields - * - * for childname in descr.names: # <<<<<<<<<<<<<< - * fields = descr.fields[childname] - * child, new_offset = fields - */ - if (unlikely(__pyx_v_descr->names == Py_None)) { - PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); - {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - __pyx_t_1 = __pyx_v_descr->names; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; - for (;;) { - if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break; - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - #else - __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - #endif - __Pyx_XDECREF_SET(__pyx_v_childname, __pyx_t_3); - __pyx_t_3 = 0; - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":795 - * - * for childname in descr.names: - * fields = descr.fields[childname] # <<<<<<<<<<<<<< - * child, new_offset = fields - * - */ - __pyx_t_3 = PyObject_GetItem(__pyx_v_descr->fields, __pyx_v_childname); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - __Pyx_GOTREF(__pyx_t_3); - if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_XDECREF_SET(__pyx_v_fields, ((PyObject*)__pyx_t_3)); - __pyx_t_3 = 0; - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":796 - * for childname in descr.names: - * fields = descr.fields[childname] - * child, new_offset = fields # <<<<<<<<<<<<<< - * - * if (end - f) - (new_offset - offset[0]) < 15: - */ - if (likely(__pyx_v_fields != Py_None)) { - PyObject* sequence = __pyx_v_fields; - #if CYTHON_COMPILING_IN_CPYTHON - Py_ssize_t size = Py_SIZE(sequence); - #else - Py_ssize_t size = PySequence_Size(sequence); - #endif - if (unlikely(size != 2)) { - if (size > 2) __Pyx_RaiseTooManyValuesError(2); - else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); - __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); - __Pyx_INCREF(__pyx_t_3); - __Pyx_INCREF(__pyx_t_4); - #else - __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - #endif - } else { - __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_dtype))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_XDECREF_SET(__pyx_v_child, ((PyArray_Descr *)__pyx_t_3)); - __pyx_t_3 = 0; - __Pyx_XDECREF_SET(__pyx_v_new_offset, __pyx_t_4); - __pyx_t_4 = 0; - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":798 - * child, new_offset = fields - * - * if (end - f) - (new_offset - offset[0]) < 15: # <<<<<<<<<<<<<< - * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") - * - */ - __pyx_t_4 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyNumber_Subtract(__pyx_v_new_offset, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = ((((__pyx_v_end - __pyx_v_f) - ((int)__pyx_t_5)) < 15) != 0); - if (__pyx_t_6) { - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":799 - * - * if (end - f) - (new_offset - offset[0]) < 15: - * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< - * - * if ((child.byteorder == c'>' and little_endian) or - */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_Raise(__pyx_t_3, 0, 0, 0); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":801 - * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") - * - * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< - * (child.byteorder == c'<' and not little_endian)): - * raise ValueError(u"Non-native byte order not supported") - */ - __pyx_t_6 = ((__pyx_v_child->byteorder == '>') != 0); - if (__pyx_t_6) { - __pyx_t_7 = (__pyx_v_little_endian != 0); - } else { - __pyx_t_7 = __pyx_t_6; - } - if (!__pyx_t_7) { - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":802 - * - * if ((child.byteorder == c'>' and little_endian) or - * (child.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< - * raise ValueError(u"Non-native byte order not supported") - * # One could encode it in the format string and have Cython - */ - __pyx_t_6 = ((__pyx_v_child->byteorder == '<') != 0); - if (__pyx_t_6) { - __pyx_t_8 = ((!(__pyx_v_little_endian != 0)) != 0); - __pyx_t_9 = __pyx_t_8; - } else { - __pyx_t_9 = __pyx_t_6; - } - __pyx_t_6 = __pyx_t_9; - } else { - __pyx_t_6 = __pyx_t_7; - } - if (__pyx_t_6) { - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":803 - * if ((child.byteorder == c'>' and little_endian) or - * (child.byteorder == c'<' and not little_endian)): - * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< - * # One could encode it in the format string and have Cython - * # complain instead, BUT: < and > in format strings also imply - */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__11, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_Raise(__pyx_t_3, 0, 0, 0); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - {__pyx_filename = __pyx_f[1]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":813 - * - * # Output padding bytes - * while offset[0] < new_offset: # <<<<<<<<<<<<<< - * f[0] = 120 # "x"; pad byte - * f += 1 - */ - while (1) { - __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_t_3, __pyx_v_new_offset, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (!__pyx_t_6) break; - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":814 - * # Output padding bytes - * while offset[0] < new_offset: - * f[0] = 120 # "x"; pad byte # <<<<<<<<<<<<<< - * f += 1 - * offset[0] += 1 - */ - (__pyx_v_f[0]) = 120; - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":815 - * while offset[0] < new_offset: - * f[0] = 120 # "x"; pad byte - * f += 1 # <<<<<<<<<<<<<< - * offset[0] += 1 - * - */ - __pyx_v_f = (__pyx_v_f + 1); - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":816 - * f[0] = 120 # "x"; pad byte - * f += 1 - * offset[0] += 1 # <<<<<<<<<<<<<< - * - * offset[0] += child.itemsize - */ - __pyx_t_10 = 0; - (__pyx_v_offset[__pyx_t_10]) = ((__pyx_v_offset[__pyx_t_10]) + 1); - } - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":818 - * offset[0] += 1 - * - * offset[0] += child.itemsize # <<<<<<<<<<<<<< - * - * if not PyDataType_HASFIELDS(child): - */ - __pyx_t_10 = 0; - (__pyx_v_offset[__pyx_t_10]) = ((__pyx_v_offset[__pyx_t_10]) + __pyx_v_child->elsize); - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":820 - * offset[0] += child.itemsize - * - * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<< - * t = child.type_num - * if end - f < 5: - */ - __pyx_t_6 = ((!(PyDataType_HASFIELDS(__pyx_v_child) != 0)) != 0); - if (__pyx_t_6) { - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":821 - * - * if not PyDataType_HASFIELDS(child): - * t = child.type_num # <<<<<<<<<<<<<< - * if end - f < 5: - * raise RuntimeError(u"Format string allocated too short.") - */ - __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_child->type_num); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_4); - __pyx_t_4 = 0; - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":822 - * if not PyDataType_HASFIELDS(child): - * t = child.type_num - * if end - f < 5: # <<<<<<<<<<<<<< - * raise RuntimeError(u"Format string allocated too short.") - * - */ - __pyx_t_6 = (((__pyx_v_end - __pyx_v_f) < 5) != 0); - if (__pyx_t_6) { - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":823 - * t = child.type_num - * if end - f < 5: - * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< - * - * # Until ticket #99 is fixed, use integers to avoid warnings - */ - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__12, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_Raise(__pyx_t_4, 0, 0, 0); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":826 - * - * # Until ticket #99 is fixed, use integers to avoid warnings - * if t == NPY_BYTE: f[0] = 98 #"b" # <<<<<<<<<<<<<< - * elif t == NPY_UBYTE: f[0] = 66 #"B" - * elif t == NPY_SHORT: f[0] = 104 #"h" - */ - __pyx_t_4 = PyInt_FromLong(NPY_BYTE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 98; - goto __pyx_L11; - } - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":827 - * # Until ticket #99 is fixed, use integers to avoid warnings - * if t == NPY_BYTE: f[0] = 98 #"b" - * elif t == NPY_UBYTE: f[0] = 66 #"B" # <<<<<<<<<<<<<< - * elif t == NPY_SHORT: f[0] = 104 #"h" - * elif t == NPY_USHORT: f[0] = 72 #"H" - */ - __pyx_t_3 = PyInt_FromLong(NPY_UBYTE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 66; - goto __pyx_L11; - } - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":828 - * if t == NPY_BYTE: f[0] = 98 #"b" - * elif t == NPY_UBYTE: f[0] = 66 #"B" - * elif t == NPY_SHORT: f[0] = 104 #"h" # <<<<<<<<<<<<<< - * elif t == NPY_USHORT: f[0] = 72 #"H" - * elif t == NPY_INT: f[0] = 105 #"i" - */ - __pyx_t_4 = PyInt_FromLong(NPY_SHORT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 104; - goto __pyx_L11; - } - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":829 - * elif t == NPY_UBYTE: f[0] = 66 #"B" - * elif t == NPY_SHORT: f[0] = 104 #"h" - * elif t == NPY_USHORT: f[0] = 72 #"H" # <<<<<<<<<<<<<< - * elif t == NPY_INT: f[0] = 105 #"i" - * elif t == NPY_UINT: f[0] = 73 #"I" - */ - __pyx_t_3 = PyInt_FromLong(NPY_USHORT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 72; - goto __pyx_L11; - } - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":830 - * elif t == NPY_SHORT: f[0] = 104 #"h" - * elif t == NPY_USHORT: f[0] = 72 #"H" - * elif t == NPY_INT: f[0] = 105 #"i" # <<<<<<<<<<<<<< - * elif t == NPY_UINT: f[0] = 73 #"I" - * elif t == NPY_LONG: f[0] = 108 #"l" - */ - __pyx_t_4 = PyInt_FromLong(NPY_INT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 105; - goto __pyx_L11; - } - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":831 - * elif t == NPY_USHORT: f[0] = 72 #"H" - * elif t == NPY_INT: f[0] = 105 #"i" - * elif t == NPY_UINT: f[0] = 73 #"I" # <<<<<<<<<<<<<< - * elif t == NPY_LONG: f[0] = 108 #"l" - * elif t == NPY_ULONG: f[0] = 76 #"L" - */ - __pyx_t_3 = PyInt_FromLong(NPY_UINT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 73; - goto __pyx_L11; - } - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":832 - * elif t == NPY_INT: f[0] = 105 #"i" - * elif t == NPY_UINT: f[0] = 73 #"I" - * elif t == NPY_LONG: f[0] = 108 #"l" # <<<<<<<<<<<<<< - * elif t == NPY_ULONG: f[0] = 76 #"L" - * elif t == NPY_LONGLONG: f[0] = 113 #"q" - */ - __pyx_t_4 = PyInt_FromLong(NPY_LONG); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 108; - goto __pyx_L11; - } - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":833 - * elif t == NPY_UINT: f[0] = 73 #"I" - * elif t == NPY_LONG: f[0] = 108 #"l" - * elif t == NPY_ULONG: f[0] = 76 #"L" # <<<<<<<<<<<<<< - * elif t == NPY_LONGLONG: f[0] = 113 #"q" - * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" - */ - __pyx_t_3 = PyInt_FromLong(NPY_ULONG); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 76; - goto __pyx_L11; - } - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":834 - * elif t == NPY_LONG: f[0] = 108 #"l" - * elif t == NPY_ULONG: f[0] = 76 #"L" - * elif t == NPY_LONGLONG: f[0] = 113 #"q" # <<<<<<<<<<<<<< - * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" - * elif t == NPY_FLOAT: f[0] = 102 #"f" - */ - __pyx_t_4 = PyInt_FromLong(NPY_LONGLONG); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 113; - goto __pyx_L11; - } - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":835 - * elif t == NPY_ULONG: f[0] = 76 #"L" - * elif t == NPY_LONGLONG: f[0] = 113 #"q" - * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" # <<<<<<<<<<<<<< - * elif t == NPY_FLOAT: f[0] = 102 #"f" - * elif t == NPY_DOUBLE: f[0] = 100 #"d" - */ - __pyx_t_3 = PyInt_FromLong(NPY_ULONGLONG); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 81; - goto __pyx_L11; - } - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":836 - * elif t == NPY_LONGLONG: f[0] = 113 #"q" - * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" - * elif t == NPY_FLOAT: f[0] = 102 #"f" # <<<<<<<<<<<<<< - * elif t == NPY_DOUBLE: f[0] = 100 #"d" - * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" - */ - __pyx_t_4 = PyInt_FromLong(NPY_FLOAT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 102; - goto __pyx_L11; - } - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":837 - * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" - * elif t == NPY_FLOAT: f[0] = 102 #"f" - * elif t == NPY_DOUBLE: f[0] = 100 #"d" # <<<<<<<<<<<<<< - * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" - * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf - */ - __pyx_t_3 = PyInt_FromLong(NPY_DOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 100; - goto __pyx_L11; - } - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":838 - * elif t == NPY_FLOAT: f[0] = 102 #"f" - * elif t == NPY_DOUBLE: f[0] = 100 #"d" - * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" # <<<<<<<<<<<<<< - * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf - * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd - */ - __pyx_t_4 = PyInt_FromLong(NPY_LONGDOUBLE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 103; - goto __pyx_L11; - } - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":839 - * elif t == NPY_DOUBLE: f[0] = 100 #"d" - * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" - * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf # <<<<<<<<<<<<<< - * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd - * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg - */ - __pyx_t_3 = PyInt_FromLong(NPY_CFLOAT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 90; - (__pyx_v_f[1]) = 102; - __pyx_v_f = (__pyx_v_f + 1); - goto __pyx_L11; - } - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":840 - * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" - * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf - * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd # <<<<<<<<<<<<<< - * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg - * elif t == NPY_OBJECT: f[0] = 79 #"O" - */ - __pyx_t_4 = PyInt_FromLong(NPY_CDOUBLE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 90; - (__pyx_v_f[1]) = 100; - __pyx_v_f = (__pyx_v_f + 1); - goto __pyx_L11; - } - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":841 - * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf - * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd - * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg # <<<<<<<<<<<<<< - * elif t == NPY_OBJECT: f[0] = 79 #"O" - * else: - */ - __pyx_t_3 = PyInt_FromLong(NPY_CLONGDOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 90; - (__pyx_v_f[1]) = 103; - __pyx_v_f = (__pyx_v_f + 1); - goto __pyx_L11; - } - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":842 - * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd - * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg - * elif t == NPY_OBJECT: f[0] = 79 #"O" # <<<<<<<<<<<<<< - * else: - * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) - */ - __pyx_t_4 = PyInt_FromLong(NPY_OBJECT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 79; - goto __pyx_L11; - } - /*else*/ { - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":844 - * elif t == NPY_OBJECT: f[0] = 79 #"O" - * else: - * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< - * f += 1 - * else: - */ - __pyx_t_3 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_v_t); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); - __Pyx_GIVEREF(__pyx_t_3); - __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_Raise(__pyx_t_3, 0, 0, 0); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - __pyx_L11:; - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":845 - * else: - * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) - * f += 1 # <<<<<<<<<<<<<< - * else: - * # Cython ignores struct boundary information ("T{...}"), - */ - __pyx_v_f = (__pyx_v_f + 1); - goto __pyx_L9; - } - /*else*/ { - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":849 - * # Cython ignores struct boundary information ("T{...}"), - * # so don't output it - * f = _util_dtypestring(child, f, end, offset) # <<<<<<<<<<<<<< - * return f - * - */ - __pyx_t_11 = __pyx_f_5numpy__util_dtypestring(__pyx_v_child, __pyx_v_f, __pyx_v_end, __pyx_v_offset); if (unlikely(__pyx_t_11 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_f = __pyx_t_11; - } - __pyx_L9:; - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":850 - * # so don't output it - * f = _util_dtypestring(child, f, end, offset) - * return f # <<<<<<<<<<<<<< - * - * - */ - __pyx_r = __pyx_v_f; - goto __pyx_L0; - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":783 - * return PyArray_MultiIterNew(5, a, b, c, d, e) - * - * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<< - * # Recursive utility function used in __getbuffer__ to get format - * # string. The new location in the format string is returned. - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_AddTraceback("numpy._util_dtypestring", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XDECREF((PyObject *)__pyx_v_child); - __Pyx_XDECREF(__pyx_v_fields); - __Pyx_XDECREF(__pyx_v_childname); - __Pyx_XDECREF(__pyx_v_new_offset); - __Pyx_XDECREF(__pyx_v_t); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":966 - * - * - * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< - * cdef PyObject* baseptr - * if base is None: - */ - -static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_arr, PyObject *__pyx_v_base) { - PyObject *__pyx_v_baseptr; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - int __pyx_t_2; - __Pyx_RefNannySetupContext("set_array_base", 0); - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":968 - * cdef inline void set_array_base(ndarray arr, object base): - * cdef PyObject* baseptr - * if base is None: # <<<<<<<<<<<<<< - * baseptr = NULL - * else: - */ - __pyx_t_1 = (__pyx_v_base == Py_None); - __pyx_t_2 = (__pyx_t_1 != 0); - if (__pyx_t_2) { - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":969 - * cdef PyObject* baseptr - * if base is None: - * baseptr = NULL # <<<<<<<<<<<<<< - * else: - * Py_INCREF(base) # important to do this before decref below! - */ - __pyx_v_baseptr = NULL; - goto __pyx_L3; - } - /*else*/ { - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":971 - * baseptr = NULL - * else: - * Py_INCREF(base) # important to do this before decref below! # <<<<<<<<<<<<<< - * baseptr = base - * Py_XDECREF(arr.base) - */ - Py_INCREF(__pyx_v_base); - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":972 - * else: - * Py_INCREF(base) # important to do this before decref below! - * baseptr = base # <<<<<<<<<<<<<< - * Py_XDECREF(arr.base) - * arr.base = baseptr - */ - __pyx_v_baseptr = ((PyObject *)__pyx_v_base); - } - __pyx_L3:; - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":973 - * Py_INCREF(base) # important to do this before decref below! - * baseptr = base - * Py_XDECREF(arr.base) # <<<<<<<<<<<<<< - * arr.base = baseptr - * - */ - Py_XDECREF(__pyx_v_arr->base); - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":974 - * baseptr = base - * Py_XDECREF(arr.base) - * arr.base = baseptr # <<<<<<<<<<<<<< - * - * cdef inline object get_array_base(ndarray arr): - */ - __pyx_v_arr->base = __pyx_v_baseptr; - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":966 - * - * - * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< - * cdef PyObject* baseptr - * if base is None: - */ - - /* function exit code */ - __Pyx_RefNannyFinishContext(); -} - -/* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":976 - * arr.base = baseptr - * - * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< - * if arr.base is NULL: - * return None - */ - -static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__pyx_v_arr) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - __Pyx_RefNannySetupContext("get_array_base", 0); - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":977 - * - * cdef inline object get_array_base(ndarray arr): - * if arr.base is NULL: # <<<<<<<<<<<<<< - * return None - * else: - */ - __pyx_t_1 = ((__pyx_v_arr->base == NULL) != 0); - if (__pyx_t_1) { - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":978 - * cdef inline object get_array_base(ndarray arr): - * if arr.base is NULL: - * return None # <<<<<<<<<<<<<< - * else: - * return arr.base - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(Py_None); - __pyx_r = Py_None; - goto __pyx_L0; - } - /*else*/ { - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":980 - * return None - * else: - * return arr.base # <<<<<<<<<<<<<< - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(((PyObject *)__pyx_v_arr->base)); - __pyx_r = ((PyObject *)__pyx_v_arr->base); - goto __pyx_L0; - } - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":976 - * arr.base = baseptr - * - * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< - * if arr.base is NULL: - * return None - */ - - /* function exit code */ - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_tp_new_8freenect_CtxPtr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { - PyObject *o; - if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { - o = (*t->tp_alloc)(t, 0); - } else { - o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); - } - if (unlikely(!o)) return 0; - return o; -} - -static void __pyx_tp_dealloc_8freenect_CtxPtr(PyObject *o) { - #if PY_VERSION_HEX >= 0x030400a1 - if (unlikely(Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) { - if (PyObject_CallFinalizerFromDealloc(o)) return; - } - #endif - (*Py_TYPE(o)->tp_free)(o); -} - -static PyMethodDef __pyx_methods_8freenect_CtxPtr[] = { - {0, 0, 0, 0} -}; - -static PyTypeObject __pyx_type_8freenect_CtxPtr = { - PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("freenect.CtxPtr"), /*tp_name*/ - sizeof(struct __pyx_obj_8freenect_CtxPtr), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - __pyx_tp_dealloc_8freenect_CtxPtr, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - #if PY_MAJOR_VERSION < 3 - 0, /*tp_compare*/ - #else - 0, /*reserved*/ - #endif - __pyx_pw_8freenect_6CtxPtr_3__repr__, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ - 0, /*tp_doc*/ - 0, /*tp_traverse*/ - 0, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - __pyx_methods_8freenect_CtxPtr, /*tp_methods*/ - 0, /*tp_members*/ - 0, /*tp_getset*/ - 0, /*tp_base*/ - 0, /*tp_dict*/ - 0, /*tp_descr_get*/ - 0, /*tp_descr_set*/ - 0, /*tp_dictoffset*/ - __pyx_pw_8freenect_6CtxPtr_1__init__, /*tp_init*/ - 0, /*tp_alloc*/ - __pyx_tp_new_8freenect_CtxPtr, /*tp_new*/ - 0, /*tp_free*/ - 0, /*tp_is_gc*/ - 0, /*tp_bases*/ - 0, /*tp_mro*/ - 0, /*tp_cache*/ - 0, /*tp_subclasses*/ - 0, /*tp_weaklist*/ - 0, /*tp_del*/ - #if PY_VERSION_HEX >= 0x02060000 - 0, /*tp_version_tag*/ - #endif - #if PY_VERSION_HEX >= 0x030400a1 - 0, /*tp_finalize*/ - #endif -}; - -static PyObject *__pyx_tp_new_8freenect_DevPtr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { - struct __pyx_obj_8freenect_DevPtr *p; - PyObject *o; - if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { - o = (*t->tp_alloc)(t, 0); - } else { - o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); - } - if (unlikely(!o)) return 0; - p = ((struct __pyx_obj_8freenect_DevPtr *)o); - p->ctx = ((struct __pyx_obj_8freenect_CtxPtr *)Py_None); Py_INCREF(Py_None); - return o; -} - -static void __pyx_tp_dealloc_8freenect_DevPtr(PyObject *o) { - struct __pyx_obj_8freenect_DevPtr *p = (struct __pyx_obj_8freenect_DevPtr *)o; - #if PY_VERSION_HEX >= 0x030400a1 - if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { - if (PyObject_CallFinalizerFromDealloc(o)) return; - } - #endif - PyObject_GC_UnTrack(o); - Py_CLEAR(p->ctx); - (*Py_TYPE(o)->tp_free)(o); -} - -static int __pyx_tp_traverse_8freenect_DevPtr(PyObject *o, visitproc v, void *a) { - int e; - struct __pyx_obj_8freenect_DevPtr *p = (struct __pyx_obj_8freenect_DevPtr *)o; - if (p->ctx) { - e = (*v)(((PyObject*)p->ctx), a); if (e) return e; - } - return 0; -} - -static int __pyx_tp_clear_8freenect_DevPtr(PyObject *o) { - PyObject* tmp; - struct __pyx_obj_8freenect_DevPtr *p = (struct __pyx_obj_8freenect_DevPtr *)o; - tmp = ((PyObject*)p->ctx); - p->ctx = ((struct __pyx_obj_8freenect_CtxPtr *)Py_None); Py_INCREF(Py_None); - Py_XDECREF(tmp); - return 0; -} - -static PyMethodDef __pyx_methods_8freenect_DevPtr[] = { - {0, 0, 0, 0} -}; - -static PyTypeObject __pyx_type_8freenect_DevPtr = { - PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("freenect.DevPtr"), /*tp_name*/ - sizeof(struct __pyx_obj_8freenect_DevPtr), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - __pyx_tp_dealloc_8freenect_DevPtr, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - #if PY_MAJOR_VERSION < 3 - 0, /*tp_compare*/ - #else - 0, /*reserved*/ - #endif - __pyx_pw_8freenect_6DevPtr_3__repr__, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ - 0, /*tp_doc*/ - __pyx_tp_traverse_8freenect_DevPtr, /*tp_traverse*/ - __pyx_tp_clear_8freenect_DevPtr, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - __pyx_methods_8freenect_DevPtr, /*tp_methods*/ - 0, /*tp_members*/ - 0, /*tp_getset*/ - 0, /*tp_base*/ - 0, /*tp_dict*/ - 0, /*tp_descr_get*/ - 0, /*tp_descr_set*/ - 0, /*tp_dictoffset*/ - __pyx_pw_8freenect_6DevPtr_1__init__, /*tp_init*/ - 0, /*tp_alloc*/ - __pyx_tp_new_8freenect_DevPtr, /*tp_new*/ - 0, /*tp_free*/ - 0, /*tp_is_gc*/ - 0, /*tp_bases*/ - 0, /*tp_mro*/ - 0, /*tp_cache*/ - 0, /*tp_subclasses*/ - 0, /*tp_weaklist*/ - 0, /*tp_del*/ - #if PY_VERSION_HEX >= 0x02060000 - 0, /*tp_version_tag*/ - #endif - #if PY_VERSION_HEX >= 0x030400a1 - 0, /*tp_finalize*/ - #endif -}; - -static PyObject *__pyx_tp_new_8freenect_StatePtr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { - PyObject *o; - if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { - o = (*t->tp_alloc)(t, 0); - } else { - o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); - } - if (unlikely(!o)) return 0; - return o; -} - -static void __pyx_tp_dealloc_8freenect_StatePtr(PyObject *o) { - #if PY_VERSION_HEX >= 0x030400a1 - if (unlikely(Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) { - if (PyObject_CallFinalizerFromDealloc(o)) return; - } - #endif - (*Py_TYPE(o)->tp_free)(o); -} - -static PyMethodDef __pyx_methods_8freenect_StatePtr[] = { - {__Pyx_NAMESTR("_get_accelx"), (PyCFunction)__pyx_pw_8freenect_8StatePtr_5_get_accelx, METH_NOARGS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("_get_accely"), (PyCFunction)__pyx_pw_8freenect_8StatePtr_7_get_accely, METH_NOARGS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("_get_accelz"), (PyCFunction)__pyx_pw_8freenect_8StatePtr_9_get_accelz, METH_NOARGS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("_get_tilt_angle"), (PyCFunction)__pyx_pw_8freenect_8StatePtr_11_get_tilt_angle, METH_NOARGS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("_get_tilt_status"), (PyCFunction)__pyx_pw_8freenect_8StatePtr_13_get_tilt_status, METH_NOARGS, __Pyx_DOCSTR(0)}, - {0, 0, 0, 0} -}; - -static PyTypeObject __pyx_type_8freenect_StatePtr = { - PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("freenect.StatePtr"), /*tp_name*/ - sizeof(struct __pyx_obj_8freenect_StatePtr), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - __pyx_tp_dealloc_8freenect_StatePtr, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - #if PY_MAJOR_VERSION < 3 - 0, /*tp_compare*/ - #else - 0, /*reserved*/ - #endif - __pyx_pw_8freenect_8StatePtr_3__repr__, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ - 0, /*tp_doc*/ - 0, /*tp_traverse*/ - 0, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - __pyx_methods_8freenect_StatePtr, /*tp_methods*/ - 0, /*tp_members*/ - 0, /*tp_getset*/ - 0, /*tp_base*/ - 0, /*tp_dict*/ - 0, /*tp_descr_get*/ - 0, /*tp_descr_set*/ - 0, /*tp_dictoffset*/ - __pyx_pw_8freenect_8StatePtr_1__init__, /*tp_init*/ - 0, /*tp_alloc*/ - __pyx_tp_new_8freenect_StatePtr, /*tp_new*/ - 0, /*tp_free*/ - 0, /*tp_is_gc*/ - 0, /*tp_bases*/ - 0, /*tp_mro*/ - 0, /*tp_cache*/ - 0, /*tp_subclasses*/ - 0, /*tp_weaklist*/ - 0, /*tp_del*/ - #if PY_VERSION_HEX >= 0x02060000 - 0, /*tp_version_tag*/ - #endif - #if PY_VERSION_HEX >= 0x030400a1 - 0, /*tp_finalize*/ - #endif -}; - -static PyMethodDef __pyx_methods[] = { - {__Pyx_NAMESTR("init"), (PyCFunction)__pyx_pw_8freenect_41init, METH_NOARGS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("open_device"), (PyCFunction)__pyx_pw_8freenect_43open_device, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, - {0, 0, 0, 0} -}; - -#if PY_MAJOR_VERSION >= 3 -static struct PyModuleDef __pyx_moduledef = { - #if PY_VERSION_HEX < 0x03020000 - { PyObject_HEAD_INIT(NULL) NULL, 0, NULL }, - #else - PyModuleDef_HEAD_INIT, - #endif - __Pyx_NAMESTR("freenect"), - 0, /* m_doc */ - -1, /* m_size */ - __pyx_methods /* m_methods */, - NULL, /* m_reload */ - NULL, /* m_traverse */ - NULL, /* m_clear */ - NULL /* m_free */ -}; -#endif - -static __Pyx_StringTabEntry __pyx_string_tab[] = { - {&__pyx_kp_s_0x_016x, __pyx_k_0x_016x, sizeof(__pyx_k_0x_016x), 0, 0, 1, 0}, - {&__pyx_kp_s_0x_08x, __pyx_k_0x_08x, sizeof(__pyx_k_0x_08x), 0, 0, 1, 0}, - {&__pyx_kp_s_Cannot_create_instances_of_CtxPt, __pyx_k_Cannot_create_instances_of_CtxPt, sizeof(__pyx_k_Cannot_create_instances_of_CtxPt), 0, 0, 1, 0}, - {&__pyx_kp_s_Cannot_create_instances_of_DevPt, __pyx_k_Cannot_create_instances_of_DevPt, sizeof(__pyx_k_Cannot_create_instances_of_DevPt), 0, 0, 1, 0}, - {&__pyx_kp_s_Cannot_create_instances_of_State, __pyx_k_Cannot_create_instances_of_State, sizeof(__pyx_k_Cannot_create_instances_of_State), 0, 0, 1, 0}, - {&__pyx_kp_s_Conversion_not_implemented_for_t, __pyx_k_Conversion_not_implemented_for_t, sizeof(__pyx_k_Conversion_not_implemented_for_t), 0, 0, 1, 0}, - {&__pyx_kp_s_Ctx_Pointer_s, __pyx_k_Ctx_Pointer_s, sizeof(__pyx_k_Ctx_Pointer_s), 0, 0, 1, 0}, - {&__pyx_n_s_DEPTH_10BIT, __pyx_k_DEPTH_10BIT, sizeof(__pyx_k_DEPTH_10BIT), 0, 0, 1, 1}, - {&__pyx_n_s_DEPTH_10BIT_PACKED, __pyx_k_DEPTH_10BIT_PACKED, sizeof(__pyx_k_DEPTH_10BIT_PACKED), 0, 0, 1, 1}, - {&__pyx_n_s_DEPTH_11BIT, __pyx_k_DEPTH_11BIT, sizeof(__pyx_k_DEPTH_11BIT), 0, 0, 1, 1}, - {&__pyx_n_s_DEPTH_11BIT_PACKED, __pyx_k_DEPTH_11BIT_PACKED, sizeof(__pyx_k_DEPTH_11BIT_PACKED), 0, 0, 1, 1}, - {&__pyx_n_s_DEPTH_MM, __pyx_k_DEPTH_MM, sizeof(__pyx_k_DEPTH_MM), 0, 0, 1, 1}, - {&__pyx_n_s_DEPTH_REGISTERED, __pyx_k_DEPTH_REGISTERED, sizeof(__pyx_k_DEPTH_REGISTERED), 0, 0, 1, 1}, - {&__pyx_n_s_DEVICE_AUDIO, __pyx_k_DEVICE_AUDIO, sizeof(__pyx_k_DEVICE_AUDIO), 0, 0, 1, 1}, - {&__pyx_n_s_DEVICE_CAMERA, __pyx_k_DEVICE_CAMERA, sizeof(__pyx_k_DEVICE_CAMERA), 0, 0, 1, 1}, - {&__pyx_n_s_DEVICE_MOTOR, __pyx_k_DEVICE_MOTOR, sizeof(__pyx_k_DEVICE_MOTOR), 0, 0, 1, 1}, - {&__pyx_kp_s_Dev_Pointer_s, __pyx_k_Dev_Pointer_s, sizeof(__pyx_k_Dev_Pointer_s), 0, 0, 1, 0}, - {&__pyx_kp_s_Error_Can_t_open_device_1_is_it, __pyx_k_Error_Can_t_open_device_1_is_it, sizeof(__pyx_k_Error_Can_t_open_device_1_is_it), 0, 0, 1, 0}, - {&__pyx_n_s_Exception, __pyx_k_Exception, sizeof(__pyx_k_Exception), 0, 0, 1, 1}, - {&__pyx_kp_u_Format_string_allocated_too_shor, __pyx_k_Format_string_allocated_too_shor, sizeof(__pyx_k_Format_string_allocated_too_shor), 0, 1, 0, 0}, - {&__pyx_kp_u_Format_string_allocated_too_shor_2, __pyx_k_Format_string_allocated_too_shor_2, sizeof(__pyx_k_Format_string_allocated_too_shor_2), 0, 1, 0, 0}, - {&__pyx_n_s_Kill, __pyx_k_Kill, sizeof(__pyx_k_Kill), 0, 0, 1, 1}, - {&__pyx_n_s_LED_BLINK_GREEN, __pyx_k_LED_BLINK_GREEN, sizeof(__pyx_k_LED_BLINK_GREEN), 0, 0, 1, 1}, - {&__pyx_n_s_LED_BLINK_RED_YELLOW, __pyx_k_LED_BLINK_RED_YELLOW, sizeof(__pyx_k_LED_BLINK_RED_YELLOW), 0, 0, 1, 1}, - {&__pyx_n_s_LED_GREEN, __pyx_k_LED_GREEN, sizeof(__pyx_k_LED_GREEN), 0, 0, 1, 1}, - {&__pyx_n_s_LED_OFF, __pyx_k_LED_OFF, sizeof(__pyx_k_LED_OFF), 0, 0, 1, 1}, - {&__pyx_n_s_LED_RED, __pyx_k_LED_RED, sizeof(__pyx_k_LED_RED), 0, 0, 1, 1}, - {&__pyx_n_s_LED_YELLOW, __pyx_k_LED_YELLOW, sizeof(__pyx_k_LED_YELLOW), 0, 0, 1, 1}, - {&__pyx_kp_u_Non_native_byte_order_not_suppor, __pyx_k_Non_native_byte_order_not_suppor, sizeof(__pyx_k_Non_native_byte_order_not_suppor), 0, 1, 0, 0}, - {&__pyx_n_s_RESOLUTION_HIGH, __pyx_k_RESOLUTION_HIGH, sizeof(__pyx_k_RESOLUTION_HIGH), 0, 0, 1, 1}, - {&__pyx_n_s_RESOLUTION_LOW, __pyx_k_RESOLUTION_LOW, sizeof(__pyx_k_RESOLUTION_LOW), 0, 0, 1, 1}, - {&__pyx_n_s_RESOLUTION_MEDIUM, __pyx_k_RESOLUTION_MEDIUM, sizeof(__pyx_k_RESOLUTION_MEDIUM), 0, 0, 1, 1}, - {&__pyx_n_s_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 0, 0, 1, 1}, - {&__pyx_kp_s_State_Pointer_s, __pyx_k_State_Pointer_s, sizeof(__pyx_k_State_Pointer_s), 0, 0, 1, 0}, - {&__pyx_kp_s_This_kills_the_runloop_raise_fro, __pyx_k_This_kills_the_runloop_raise_fro, sizeof(__pyx_k_This_kills_the_runloop_raise_fro), 0, 0, 1, 0}, - {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1}, - {&__pyx_n_s_VIDEO_BAYER, __pyx_k_VIDEO_BAYER, sizeof(__pyx_k_VIDEO_BAYER), 0, 0, 1, 1}, - {&__pyx_n_s_VIDEO_IR_10BIT, __pyx_k_VIDEO_IR_10BIT, sizeof(__pyx_k_VIDEO_IR_10BIT), 0, 0, 1, 1}, - {&__pyx_n_s_VIDEO_IR_10BIT_PACKED, __pyx_k_VIDEO_IR_10BIT_PACKED, sizeof(__pyx_k_VIDEO_IR_10BIT_PACKED), 0, 0, 1, 1}, - {&__pyx_n_s_VIDEO_IR_8BIT, __pyx_k_VIDEO_IR_8BIT, sizeof(__pyx_k_VIDEO_IR_8BIT), 0, 0, 1, 1}, - {&__pyx_n_s_VIDEO_RGB, __pyx_k_VIDEO_RGB, sizeof(__pyx_k_VIDEO_RGB), 0, 0, 1, 1}, - {&__pyx_n_s_VIDEO_YUV_RAW, __pyx_k_VIDEO_YUV_RAW, sizeof(__pyx_k_VIDEO_YUV_RAW), 0, 0, 1, 1}, - {&__pyx_n_s_VIDEO_YUV_RGB, __pyx_k_VIDEO_YUV_RGB, sizeof(__pyx_k_VIDEO_YUV_RGB), 0, 0, 1, 1}, - {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1}, - {&__pyx_kp_s_What_kind_of_system_are_you_usin, __pyx_k_What_kind_of_system_are_you_usin, sizeof(__pyx_k_What_kind_of_system_are_you_usin), 0, 0, 1, 0}, - {&__pyx_n_s_accelerometer_x, __pyx_k_accelerometer_x, sizeof(__pyx_k_accelerometer_x), 0, 0, 1, 1}, - {&__pyx_n_s_accelerometer_y, __pyx_k_accelerometer_y, sizeof(__pyx_k_accelerometer_y), 0, 0, 1, 1}, - {&__pyx_n_s_accelerometer_z, __pyx_k_accelerometer_z, sizeof(__pyx_k_accelerometer_z), 0, 0, 1, 1}, - {&__pyx_n_s_angle, __pyx_k_angle, sizeof(__pyx_k_angle), 0, 0, 1, 1}, - {&__pyx_n_s_base_runloop, __pyx_k_base_runloop, sizeof(__pyx_k_base_runloop), 0, 0, 1, 1}, - {&__pyx_n_s_body, __pyx_k_body, sizeof(__pyx_k_body), 0, 0, 1, 1}, - {&__pyx_n_s_cb, __pyx_k_cb, sizeof(__pyx_k_cb), 0, 0, 1, 1}, - {&__pyx_n_s_close_device, __pyx_k_close_device, sizeof(__pyx_k_close_device), 0, 0, 1, 1}, - {&__pyx_n_s_ctx, __pyx_k_ctx, sizeof(__pyx_k_ctx), 0, 0, 1, 1}, - {&__pyx_n_s_ctxp, __pyx_k_ctxp, sizeof(__pyx_k_ctxp), 0, 0, 1, 1}, - {&__pyx_n_s_data, __pyx_k_data, sizeof(__pyx_k_data), 0, 0, 1, 1}, - {&__pyx_n_s_depth, __pyx_k_depth, sizeof(__pyx_k_depth), 0, 0, 1, 1}, - {&__pyx_n_s_depth_cb, __pyx_k_depth_cb, sizeof(__pyx_k_depth_cb), 0, 0, 1, 1}, - {&__pyx_n_s_dev, __pyx_k_dev, sizeof(__pyx_k_dev), 0, 0, 1, 1}, - {&__pyx_n_s_devp, __pyx_k_devp, sizeof(__pyx_k_devp), 0, 0, 1, 1}, - {&__pyx_n_s_dims, __pyx_k_dims, sizeof(__pyx_k_dims), 0, 0, 1, 1}, - {&__pyx_n_s_doc, __pyx_k_doc, sizeof(__pyx_k_doc), 0, 0, 1, 1}, - {&__pyx_n_s_end, __pyx_k_end, sizeof(__pyx_k_end), 0, 0, 1, 1}, - {&__pyx_n_s_error_open_device, __pyx_k_error_open_device, sizeof(__pyx_k_error_open_device), 0, 0, 1, 1}, - {&__pyx_n_s_file, __pyx_k_file, sizeof(__pyx_k_file), 0, 0, 1, 1}, - {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1}, - {&__pyx_n_s_format_2, __pyx_k_format_2, sizeof(__pyx_k_format_2), 0, 0, 1, 1}, - {&__pyx_n_s_freenect, __pyx_k_freenect, sizeof(__pyx_k_freenect), 0, 0, 1, 1}, - {&__pyx_kp_s_freenect_pyx, __pyx_k_freenect_pyx, sizeof(__pyx_k_freenect_pyx), 0, 0, 1, 0}, - {&__pyx_n_s_get_accel, __pyx_k_get_accel, sizeof(__pyx_k_get_accel), 0, 0, 1, 1}, - {&__pyx_n_s_get_accelx, __pyx_k_get_accelx, sizeof(__pyx_k_get_accelx), 0, 0, 1, 1}, - {&__pyx_n_s_get_accely, __pyx_k_get_accely, sizeof(__pyx_k_get_accely), 0, 0, 1, 1}, - {&__pyx_n_s_get_accelz, __pyx_k_get_accelz, sizeof(__pyx_k_get_accelz), 0, 0, 1, 1}, - {&__pyx_n_s_get_depth_format, __pyx_k_get_depth_format, sizeof(__pyx_k_get_depth_format), 0, 0, 1, 1}, - {&__pyx_n_s_get_mks_accel, __pyx_k_get_mks_accel, sizeof(__pyx_k_get_mks_accel), 0, 0, 1, 1}, - {&__pyx_n_s_get_tilt_angle, __pyx_k_get_tilt_angle, sizeof(__pyx_k_get_tilt_angle), 0, 0, 1, 1}, - {&__pyx_n_s_get_tilt_degs, __pyx_k_get_tilt_degs, sizeof(__pyx_k_get_tilt_degs), 0, 0, 1, 1}, - {&__pyx_n_s_get_tilt_state, __pyx_k_get_tilt_state, sizeof(__pyx_k_get_tilt_state), 0, 0, 1, 1}, - {&__pyx_n_s_get_tilt_status, __pyx_k_get_tilt_status, sizeof(__pyx_k_get_tilt_status), 0, 0, 1, 1}, - {&__pyx_n_s_get_video_format, __pyx_k_get_video_format, sizeof(__pyx_k_get_video_format), 0, 0, 1, 1}, - {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, - {&__pyx_n_s_index, __pyx_k_index, sizeof(__pyx_k_index), 0, 0, 1, 1}, - {&__pyx_n_s_index_2, __pyx_k_index_2, sizeof(__pyx_k_index_2), 0, 0, 1, 1}, - {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, - {&__pyx_n_s_mdev, __pyx_k_mdev, sizeof(__pyx_k_mdev), 0, 0, 1, 1}, - {&__pyx_n_s_metaclass, __pyx_k_metaclass, sizeof(__pyx_k_metaclass), 0, 0, 1, 1}, - {&__pyx_n_s_mode, __pyx_k_mode, sizeof(__pyx_k_mode), 0, 0, 1, 1}, - {&__pyx_n_s_module, __pyx_k_module, sizeof(__pyx_k_module), 0, 0, 1, 1}, - {&__pyx_kp_u_ndarray_is_not_C_contiguous, __pyx_k_ndarray_is_not_C_contiguous, sizeof(__pyx_k_ndarray_is_not_C_contiguous), 0, 1, 0, 0}, - {&__pyx_kp_u_ndarray_is_not_Fortran_contiguou, __pyx_k_ndarray_is_not_Fortran_contiguou, sizeof(__pyx_k_ndarray_is_not_Fortran_contiguou), 0, 1, 0, 0}, - {&__pyx_n_s_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 0, 1, 1}, - {&__pyx_n_s_num_devices, __pyx_k_num_devices, sizeof(__pyx_k_num_devices), 0, 0, 1, 1}, - {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1}, - {&__pyx_n_s_option, __pyx_k_option, sizeof(__pyx_k_option), 0, 0, 1, 1}, - {&__pyx_n_s_out, __pyx_k_out, sizeof(__pyx_k_out), 0, 0, 1, 1}, - {&__pyx_n_s_prepare, __pyx_k_prepare, sizeof(__pyx_k_prepare), 0, 0, 1, 1}, - {&__pyx_n_s_print, __pyx_k_print, sizeof(__pyx_k_print), 0, 0, 1, 1}, - {&__pyx_n_s_process_events, __pyx_k_process_events, sizeof(__pyx_k_process_events), 0, 0, 1, 1}, - {&__pyx_n_s_property, __pyx_k_property, sizeof(__pyx_k_property), 0, 0, 1, 1}, - {&__pyx_n_s_qualname, __pyx_k_qualname, sizeof(__pyx_k_qualname), 0, 0, 1, 1}, - {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1}, - {&__pyx_n_s_res, __pyx_k_res, sizeof(__pyx_k_res), 0, 0, 1, 1}, - {&__pyx_n_s_runloop, __pyx_k_runloop, sizeof(__pyx_k_runloop), 0, 0, 1, 1}, - {&__pyx_n_s_set_depth_callback, __pyx_k_set_depth_callback, sizeof(__pyx_k_set_depth_callback), 0, 0, 1, 1}, - {&__pyx_n_s_set_depth_mode, __pyx_k_set_depth_mode, sizeof(__pyx_k_set_depth_mode), 0, 0, 1, 1}, - {&__pyx_n_s_set_led, __pyx_k_set_led, sizeof(__pyx_k_set_led), 0, 0, 1, 1}, - {&__pyx_n_s_set_tilt_degs, __pyx_k_set_tilt_degs, sizeof(__pyx_k_set_tilt_degs), 0, 0, 1, 1}, - {&__pyx_n_s_set_video_callback, __pyx_k_set_video_callback, sizeof(__pyx_k_set_video_callback), 0, 0, 1, 1}, - {&__pyx_n_s_set_video_mode, __pyx_k_set_video_mode, sizeof(__pyx_k_set_video_mode), 0, 0, 1, 1}, - {&__pyx_n_s_shutdown, __pyx_k_shutdown, sizeof(__pyx_k_shutdown), 0, 0, 1, 1}, - {&__pyx_n_s_start_depth, __pyx_k_start_depth, sizeof(__pyx_k_start_depth), 0, 0, 1, 1}, - {&__pyx_n_s_start_video, __pyx_k_start_video, sizeof(__pyx_k_start_video), 0, 0, 1, 1}, - {&__pyx_n_s_state, __pyx_k_state, sizeof(__pyx_k_state), 0, 0, 1, 1}, - {&__pyx_n_s_state_out, __pyx_k_state_out, sizeof(__pyx_k_state_out), 0, 0, 1, 1}, - {&__pyx_n_s_stop_depth, __pyx_k_stop_depth, sizeof(__pyx_k_stop_depth), 0, 0, 1, 1}, - {&__pyx_n_s_stop_video, __pyx_k_stop_video, sizeof(__pyx_k_stop_video), 0, 0, 1, 1}, - {&__pyx_n_s_sync_get_depth, __pyx_k_sync_get_depth, sizeof(__pyx_k_sync_get_depth), 0, 0, 1, 1}, - {&__pyx_n_s_sync_get_video, __pyx_k_sync_get_video, sizeof(__pyx_k_sync_get_video), 0, 0, 1, 1}, - {&__pyx_n_s_sync_stop, __pyx_k_sync_stop, sizeof(__pyx_k_sync_stop), 0, 0, 1, 1}, - {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, - {&__pyx_n_s_tilt_angle, __pyx_k_tilt_angle, sizeof(__pyx_k_tilt_angle), 0, 0, 1, 1}, - {&__pyx_n_s_tilt_status, __pyx_k_tilt_status, sizeof(__pyx_k_tilt_status), 0, 0, 1, 1}, - {&__pyx_n_s_timestamp, __pyx_k_timestamp, sizeof(__pyx_k_timestamp), 0, 0, 1, 1}, - {&__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_k_unknown_dtype_code_in_numpy_pxd, sizeof(__pyx_k_unknown_dtype_code_in_numpy_pxd), 0, 1, 0, 0}, - {&__pyx_n_s_update_tilt_state, __pyx_k_update_tilt_state, sizeof(__pyx_k_update_tilt_state), 0, 0, 1, 1}, - {&__pyx_n_s_video, __pyx_k_video, sizeof(__pyx_k_video), 0, 0, 1, 1}, - {&__pyx_n_s_video_cb, __pyx_k_video_cb, sizeof(__pyx_k_video_cb), 0, 0, 1, 1}, - {&__pyx_n_s_x, __pyx_k_x, sizeof(__pyx_k_x), 0, 0, 1, 1}, - {&__pyx_n_s_y, __pyx_k_y, sizeof(__pyx_k_y), 0, 0, 1, 1}, - {&__pyx_n_s_z, __pyx_k_z, sizeof(__pyx_k_z), 0, 0, 1, 1}, - {0, 0, 0, 0, 0, 0, 0} -}; -static int __Pyx_InitCachedBuiltins(void) { - __pyx_builtin_property = __Pyx_GetBuiltinName(__pyx_n_s_property); if (!__pyx_builtin_property) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_Exception = __Pyx_GetBuiltinName(__pyx_n_s_Exception); if (!__pyx_builtin_Exception) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - return 0; - __pyx_L1_error:; - return -1; -} - -static int __Pyx_InitCachedConstants(void) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); - - /* "freenect.pyx":174 - * return "0x%016x" % ptr - * else: - * raise TypeError("What kind of system are you using?!") # <<<<<<<<<<<<<< - * - * cdef class CtxPtr: - */ - __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_What_kind_of_system_are_you_usin); if (unlikely(!__pyx_tuple_)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_tuple_); - __Pyx_GIVEREF(__pyx_tuple_); - - /* "freenect.pyx":180 - * def __init__(self): - * # Safety: do not allow Python to create instances as they would be NULL - * raise TypeError("Cannot create instances of CtxPtr from Python") # <<<<<<<<<<<<<< - * - * def __repr__(self): - */ - __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_Cannot_create_instances_of_CtxPt); if (unlikely(!__pyx_tuple__2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_tuple__2); - __Pyx_GIVEREF(__pyx_tuple__2); - - /* "freenect.pyx":190 - * def __init__(self): - * # Safety: do not allow Python to create instances as they would be NULL - * raise TypeError("Cannot create instances of DevPtr from Python") # <<<<<<<<<<<<<< - * - * def __repr__(self): - */ - __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_s_Cannot_create_instances_of_DevPt); if (unlikely(!__pyx_tuple__3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_tuple__3); - __Pyx_GIVEREF(__pyx_tuple__3); - - /* "freenect.pyx":199 - * def __init__(self): - * # Safety: do not allow Python to create instances as they would be NULL - * raise TypeError("Cannot create instances of StatePtr from Python") # <<<<<<<<<<<<<< - * - * def __repr__(self): - */ - __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_s_Cannot_create_instances_of_State); if (unlikely(!__pyx_tuple__4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_tuple__4); - __Pyx_GIVEREF(__pyx_tuple__4); - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":215 - * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) - * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): - * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< - * - * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) - */ - __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_C_contiguous); if (unlikely(!__pyx_tuple__7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_tuple__7); - __Pyx_GIVEREF(__pyx_tuple__7); - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":219 - * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) - * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): - * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< - * - * info.buf = PyArray_DATA(self) - */ - __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_Fortran_contiguou); if (unlikely(!__pyx_tuple__8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_tuple__8); - __Pyx_GIVEREF(__pyx_tuple__8); - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":257 - * if ((descr.byteorder == c'>' and little_endian) or - * (descr.byteorder == c'<' and not little_endian)): - * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< - * if t == NPY_BYTE: f = "b" - * elif t == NPY_UBYTE: f = "B" - */ - __pyx_tuple__9 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__9)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_tuple__9); - __Pyx_GIVEREF(__pyx_tuple__9); - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":799 - * - * if (end - f) - (new_offset - offset[0]) < 15: - * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< - * - * if ((child.byteorder == c'>' and little_endian) or - */ - __pyx_tuple__10 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor); if (unlikely(!__pyx_tuple__10)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_tuple__10); - __Pyx_GIVEREF(__pyx_tuple__10); - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":803 - * if ((child.byteorder == c'>' and little_endian) or - * (child.byteorder == c'<' and not little_endian)): - * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< - * # One could encode it in the format string and have Cython - * # complain instead, BUT: < and > in format strings also imply - */ - __pyx_tuple__11 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__11)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_tuple__11); - __Pyx_GIVEREF(__pyx_tuple__11); - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":823 - * t = child.type_num - * if end - f < 5: - * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< - * - * # Until ticket #99 is fixed, use integers to avoid warnings - */ - __pyx_tuple__12 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor_2); if (unlikely(!__pyx_tuple__12)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_tuple__12); - __Pyx_GIVEREF(__pyx_tuple__12); - - /* "freenect.pyx":225 - * tilt_status = property(_get_tilt_status) - * - * def set_depth_mode(DevPtr dev, int res, int mode): # <<<<<<<<<<<<<< - * return freenect_set_depth_mode(dev._ptr, freenect_find_depth_mode(res, mode)) - * - */ - __pyx_tuple__13 = PyTuple_Pack(3, __pyx_n_s_dev, __pyx_n_s_res, __pyx_n_s_mode); if (unlikely(!__pyx_tuple__13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_tuple__13); - __Pyx_GIVEREF(__pyx_tuple__13); - __pyx_codeobj__14 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__13, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_freenect_pyx, __pyx_n_s_set_depth_mode, 225, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - - /* "freenect.pyx":228 - * return freenect_set_depth_mode(dev._ptr, freenect_find_depth_mode(res, mode)) - * - * def set_video_mode(DevPtr dev, int res, int mode): # <<<<<<<<<<<<<< - * return freenect_set_video_mode(dev._ptr, freenect_find_video_mode(res, mode)) - * - */ - __pyx_tuple__15 = PyTuple_Pack(3, __pyx_n_s_dev, __pyx_n_s_res, __pyx_n_s_mode); if (unlikely(!__pyx_tuple__15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_tuple__15); - __Pyx_GIVEREF(__pyx_tuple__15); - __pyx_codeobj__16 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__15, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_freenect_pyx, __pyx_n_s_set_video_mode, 228, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - - /* "freenect.pyx":231 - * return freenect_set_video_mode(dev._ptr, freenect_find_video_mode(res, mode)) - * - * def get_depth_format(DevPtr dev): # <<<<<<<<<<<<<< - * return freenect_get_current_depth_mode(dev._ptr).video_format - * - */ - __pyx_tuple__17 = PyTuple_Pack(1, __pyx_n_s_dev); if (unlikely(!__pyx_tuple__17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_tuple__17); - __Pyx_GIVEREF(__pyx_tuple__17); - __pyx_codeobj__18 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__17, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_freenect_pyx, __pyx_n_s_get_depth_format, 231, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - - /* "freenect.pyx":234 - * return freenect_get_current_depth_mode(dev._ptr).video_format - * - * def get_video_format(DevPtr dev): # <<<<<<<<<<<<<< - * return freenect_get_current_video_mode(dev._ptr).video_format - * - */ - __pyx_tuple__19 = PyTuple_Pack(1, __pyx_n_s_dev); if (unlikely(!__pyx_tuple__19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_tuple__19); - __Pyx_GIVEREF(__pyx_tuple__19); - __pyx_codeobj__20 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__19, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_freenect_pyx, __pyx_n_s_get_video_format, 234, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - - /* "freenect.pyx":237 - * return freenect_get_current_video_mode(dev._ptr).video_format - * - * def start_depth(DevPtr dev): # <<<<<<<<<<<<<< - * return freenect_start_depth(dev._ptr) - * - */ - __pyx_tuple__21 = PyTuple_Pack(1, __pyx_n_s_dev); if (unlikely(!__pyx_tuple__21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_tuple__21); - __Pyx_GIVEREF(__pyx_tuple__21); - __pyx_codeobj__22 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__21, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_freenect_pyx, __pyx_n_s_start_depth, 237, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - - /* "freenect.pyx":240 - * return freenect_start_depth(dev._ptr) - * - * def start_video(DevPtr dev): # <<<<<<<<<<<<<< - * return freenect_start_video(dev._ptr) - * - */ - __pyx_tuple__23 = PyTuple_Pack(1, __pyx_n_s_dev); if (unlikely(!__pyx_tuple__23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_tuple__23); - __Pyx_GIVEREF(__pyx_tuple__23); - __pyx_codeobj__24 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__23, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_freenect_pyx, __pyx_n_s_start_video, 240, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__24)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - - /* "freenect.pyx":243 - * return freenect_start_video(dev._ptr) - * - * def stop_depth(DevPtr dev): # <<<<<<<<<<<<<< - * return freenect_stop_depth(dev._ptr) - * - */ - __pyx_tuple__25 = PyTuple_Pack(1, __pyx_n_s_dev); if (unlikely(!__pyx_tuple__25)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_tuple__25); - __Pyx_GIVEREF(__pyx_tuple__25); - __pyx_codeobj__26 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__25, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_freenect_pyx, __pyx_n_s_stop_depth, 243, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__26)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - - /* "freenect.pyx":246 - * return freenect_stop_depth(dev._ptr) - * - * def stop_video(DevPtr dev): # <<<<<<<<<<<<<< - * return freenect_stop_video(dev._ptr) - * - */ - __pyx_tuple__27 = PyTuple_Pack(1, __pyx_n_s_dev); if (unlikely(!__pyx_tuple__27)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_tuple__27); - __Pyx_GIVEREF(__pyx_tuple__27); - __pyx_codeobj__28 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__27, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_freenect_pyx, __pyx_n_s_stop_video, 246, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__28)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - - /* "freenect.pyx":249 - * return freenect_stop_video(dev._ptr) - * - * def shutdown(CtxPtr ctx): # <<<<<<<<<<<<<< - * return freenect_shutdown(ctx._ptr) - * - */ - __pyx_tuple__29 = PyTuple_Pack(1, __pyx_n_s_ctx); if (unlikely(!__pyx_tuple__29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_tuple__29); - __Pyx_GIVEREF(__pyx_tuple__29); - __pyx_codeobj__30 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__29, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_freenect_pyx, __pyx_n_s_shutdown, 249, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__30)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - - /* "freenect.pyx":252 - * return freenect_shutdown(ctx._ptr) - * - * def process_events(CtxPtr ctx): # <<<<<<<<<<<<<< - * return freenect_process_events(ctx._ptr) - * - */ - __pyx_tuple__31 = PyTuple_Pack(1, __pyx_n_s_ctx); if (unlikely(!__pyx_tuple__31)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_tuple__31); - __Pyx_GIVEREF(__pyx_tuple__31); - __pyx_codeobj__32 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__31, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_freenect_pyx, __pyx_n_s_process_events, 252, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__32)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - - /* "freenect.pyx":255 - * return freenect_process_events(ctx._ptr) - * - * def num_devices(CtxPtr ctx): # <<<<<<<<<<<<<< - * return freenect_num_devices(ctx._ptr) - * - */ - __pyx_tuple__33 = PyTuple_Pack(1, __pyx_n_s_ctx); if (unlikely(!__pyx_tuple__33)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_tuple__33); - __Pyx_GIVEREF(__pyx_tuple__33); - __pyx_codeobj__34 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__33, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_freenect_pyx, __pyx_n_s_num_devices, 255, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__34)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - - /* "freenect.pyx":258 - * return freenect_num_devices(ctx._ptr) - * - * def close_device(DevPtr dev): # <<<<<<<<<<<<<< - * return freenect_close_device(dev._ptr) - * - */ - __pyx_tuple__35 = PyTuple_Pack(1, __pyx_n_s_dev); if (unlikely(!__pyx_tuple__35)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 258; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_tuple__35); - __Pyx_GIVEREF(__pyx_tuple__35); - __pyx_codeobj__36 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__35, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_freenect_pyx, __pyx_n_s_close_device, 258, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__36)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 258; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - - /* "freenect.pyx":261 - * return freenect_close_device(dev._ptr) - * - * def set_tilt_degs(DevPtr dev, float angle): # <<<<<<<<<<<<<< - * freenect_set_tilt_degs(dev._ptr, angle) - * - */ - __pyx_tuple__37 = PyTuple_Pack(2, __pyx_n_s_dev, __pyx_n_s_angle); if (unlikely(!__pyx_tuple__37)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_tuple__37); - __Pyx_GIVEREF(__pyx_tuple__37); - __pyx_codeobj__38 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__37, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_freenect_pyx, __pyx_n_s_set_tilt_degs, 261, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__38)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - - /* "freenect.pyx":264 - * freenect_set_tilt_degs(dev._ptr, angle) - * - * def set_led(DevPtr dev, freenect_led_options option): # <<<<<<<<<<<<<< - * return freenect_set_led(dev._ptr, option) - * - */ - __pyx_tuple__39 = PyTuple_Pack(2, __pyx_n_s_dev, __pyx_n_s_option); if (unlikely(!__pyx_tuple__39)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_tuple__39); - __Pyx_GIVEREF(__pyx_tuple__39); - __pyx_codeobj__40 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__39, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_freenect_pyx, __pyx_n_s_set_led, 264, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__40)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - - /* "freenect.pyx":267 - * return freenect_set_led(dev._ptr, option) - * - * def update_tilt_state(DevPtr dev): # <<<<<<<<<<<<<< - * return freenect_update_tilt_state(dev._ptr) - * - */ - __pyx_tuple__41 = PyTuple_Pack(1, __pyx_n_s_dev); if (unlikely(!__pyx_tuple__41)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_tuple__41); - __Pyx_GIVEREF(__pyx_tuple__41); - __pyx_codeobj__42 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__41, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_freenect_pyx, __pyx_n_s_update_tilt_state, 267, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__42)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - - /* "freenect.pyx":270 - * return freenect_update_tilt_state(dev._ptr) - * - * def get_tilt_state(DevPtr dev): # <<<<<<<<<<<<<< - * cdef freenect_raw_tilt_state* state = freenect_get_tilt_state(dev._ptr) - * cdef StatePtr state_out = StatePtr.__new__(StatePtr) - */ - __pyx_tuple__43 = PyTuple_Pack(3, __pyx_n_s_dev, __pyx_n_s_state, __pyx_n_s_state_out); if (unlikely(!__pyx_tuple__43)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_tuple__43); - __Pyx_GIVEREF(__pyx_tuple__43); - __pyx_codeobj__44 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__43, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_freenect_pyx, __pyx_n_s_get_tilt_state, 270, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__44)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - - /* "freenect.pyx":276 - * return state_out - * - * def get_mks_accel(StatePtr state): # <<<<<<<<<<<<<< - * cdef double x, y, z - * freenect_get_mks_accel(state._ptr, &x, &y, &z) - */ - __pyx_tuple__45 = PyTuple_Pack(4, __pyx_n_s_state, __pyx_n_s_x, __pyx_n_s_y, __pyx_n_s_z); if (unlikely(!__pyx_tuple__45)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_tuple__45); - __Pyx_GIVEREF(__pyx_tuple__45); - __pyx_codeobj__46 = (PyObject*)__Pyx_PyCode_New(1, 0, 4, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__45, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_freenect_pyx, __pyx_n_s_get_mks_accel, 276, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__46)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - - /* "freenect.pyx":281 - * return x, y, z - * - * def get_accel(DevPtr dev): # <<<<<<<<<<<<<< - * """MKS Accelerometer helper - * - */ - __pyx_tuple__47 = PyTuple_Pack(1, __pyx_n_s_dev); if (unlikely(!__pyx_tuple__47)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 281; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_tuple__47); - __Pyx_GIVEREF(__pyx_tuple__47); - __pyx_codeobj__48 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__47, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_freenect_pyx, __pyx_n_s_get_accel, 281, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__48)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 281; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - - /* "freenect.pyx":294 - * - * - * def get_tilt_degs(StatePtr state): # <<<<<<<<<<<<<< - * return freenect_get_tilt_degs(state._ptr) - * - */ - __pyx_tuple__49 = PyTuple_Pack(1, __pyx_n_s_state); if (unlikely(!__pyx_tuple__49)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_tuple__49); - __Pyx_GIVEREF(__pyx_tuple__49); - __pyx_codeobj__50 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__49, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_freenect_pyx, __pyx_n_s_get_tilt_degs, 294, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__50)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - - /* "freenect.pyx":298 - * - * - * def error_open_device(): # <<<<<<<<<<<<<< - * print("Error: Can't open device. 1.) is it plugged in? 2.) Read the README") - * - */ - __pyx_codeobj__51 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_freenect_pyx, __pyx_n_s_error_open_device, 298, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__51)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - - /* "freenect.pyx":347 - * _video_cb(dev_out, pydata, timestamp) - * - * def set_depth_callback(DevPtr dev, cb): # <<<<<<<<<<<<<< - * global _depth_cb - * if cb is not None: - */ - __pyx_tuple__52 = PyTuple_Pack(2, __pyx_n_s_dev, __pyx_n_s_cb); if (unlikely(!__pyx_tuple__52)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_tuple__52); - __Pyx_GIVEREF(__pyx_tuple__52); - __pyx_codeobj__53 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__52, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_freenect_pyx, __pyx_n_s_set_depth_callback, 347, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__53)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - - /* "freenect.pyx":356 - * freenect_set_depth_callback(dev._ptr, NULL) - * - * def set_video_callback(DevPtr dev, cb): # <<<<<<<<<<<<<< - * global _video_cb - * if cb is not None: - */ - __pyx_tuple__54 = PyTuple_Pack(2, __pyx_n_s_dev, __pyx_n_s_cb); if (unlikely(!__pyx_tuple__54)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_tuple__54); - __Pyx_GIVEREF(__pyx_tuple__54); - __pyx_codeobj__55 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__54, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_freenect_pyx, __pyx_n_s_set_video_callback, 356, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__55)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - - /* "freenect.pyx":370 - * - * - * def runloop(depth=None, video=None, body=None, dev=None): # <<<<<<<<<<<<<< - * """Sets up the kinect and maintains a runloop - * - */ - __pyx_tuple__56 = PyTuple_Pack(8, __pyx_n_s_depth, __pyx_n_s_video, __pyx_n_s_body, __pyx_n_s_dev, __pyx_n_s_mdev, __pyx_n_s_ctx, __pyx_n_s_devp, __pyx_n_s_ctxp); if (unlikely(!__pyx_tuple__56)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_tuple__56); - __Pyx_GIVEREF(__pyx_tuple__56); - __pyx_codeobj__57 = (PyObject*)__Pyx_PyCode_New(4, 0, 8, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__56, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_freenect_pyx, __pyx_n_s_runloop, 370, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__57)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - - /* "freenect.pyx":434 - * freenect_shutdown(ctxp) - * - * def base_runloop(CtxPtr ctx, body=None): # <<<<<<<<<<<<<< - * """Starts a runloop - * - */ - __pyx_tuple__58 = PyTuple_Pack(3, __pyx_n_s_ctx, __pyx_n_s_body, __pyx_n_s_ctxp); if (unlikely(!__pyx_tuple__58)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_tuple__58); - __Pyx_GIVEREF(__pyx_tuple__58); - __pyx_codeobj__59 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__58, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_freenect_pyx, __pyx_n_s_base_runloop, 434, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__59)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - - /* "freenect.pyx":485 - * return (data)[:mode.bytes] - * - * def sync_get_depth(index=0, format=DEPTH_11BIT): # <<<<<<<<<<<<<< - * """Get the next available depth frame from the kinect, as a numpy array. - * - */ - __pyx_tuple__60 = PyTuple_Pack(8, __pyx_n_s_index, __pyx_n_s_format, __pyx_n_s_data, __pyx_n_s_timestamp, __pyx_n_s_dims, __pyx_n_s_out, __pyx_n_s_index_2, __pyx_n_s_format_2); if (unlikely(!__pyx_tuple__60)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 485; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_tuple__60); - __Pyx_GIVEREF(__pyx_tuple__60); - __pyx_codeobj__61 = (PyObject*)__Pyx_PyCode_New(2, 0, 8, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__60, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_freenect_pyx, __pyx_n_s_sync_get_depth, 485, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__61)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 485; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - - /* "freenect.pyx":515 - * - * - * def sync_get_video(index=0, format=VIDEO_RGB): # <<<<<<<<<<<<<< - * """Get the next available rgb frame from the kinect, as a numpy array. - * - */ - __pyx_tuple__62 = PyTuple_Pack(8, __pyx_n_s_index, __pyx_n_s_format, __pyx_n_s_data, __pyx_n_s_timestamp, __pyx_n_s_dims, __pyx_n_s_out, __pyx_n_s_index_2, __pyx_n_s_format_2); if (unlikely(!__pyx_tuple__62)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 515; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_tuple__62); - __Pyx_GIVEREF(__pyx_tuple__62); - __pyx_codeobj__63 = (PyObject*)__Pyx_PyCode_New(2, 0, 8, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__62, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_freenect_pyx, __pyx_n_s_sync_get_video, 515, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__63)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 515; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - - /* "freenect.pyx":551 - * - * - * def sync_stop(): # <<<<<<<<<<<<<< - * """Terminate the synchronous runloop if running, else this is a NOP - * """ - */ - __pyx_codeobj__64 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_freenect_pyx, __pyx_n_s_sync_stop, 551, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__64)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 551; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_RefNannyFinishContext(); - return 0; - __pyx_L1_error:; - __Pyx_RefNannyFinishContext(); - return -1; -} - -static int __Pyx_InitGlobals(void) { - if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - return 0; - __pyx_L1_error:; - return -1; -} - -#if PY_MAJOR_VERSION < 3 -PyMODINIT_FUNC initfreenect(void); /*proto*/ -PyMODINIT_FUNC initfreenect(void) -#else -PyMODINIT_FUNC PyInit_freenect(void); /*proto*/ -PyMODINIT_FUNC PyInit_freenect(void) -#endif -{ - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannyDeclarations - #if CYTHON_REFNANNY - __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); - if (!__Pyx_RefNanny) { - PyErr_Clear(); - __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); - if (!__Pyx_RefNanny) - Py_FatalError("failed to import 'refnanny' module"); - } - #endif - __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_freenect(void)", 0); - if ( __Pyx_check_binary_version() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - #ifdef __Pyx_CyFunction_USED - if (__Pyx_CyFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - #endif - #ifdef __Pyx_FusedFunction_USED - if (__pyx_FusedFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - #endif - #ifdef __Pyx_Generator_USED - if (__pyx_Generator_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - #endif - /*--- Library function declarations ---*/ - /*--- Threads initialization code ---*/ - #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS - #ifdef WITH_THREAD /* Python build with threading support? */ - PyEval_InitThreads(); - #endif - #endif - /*--- Module creation code ---*/ - #if PY_MAJOR_VERSION < 3 - __pyx_m = Py_InitModule4(__Pyx_NAMESTR("freenect"), __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); - #else - __pyx_m = PyModule_Create(&__pyx_moduledef); - #endif - if (unlikely(!__pyx_m)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - Py_INCREF(__pyx_d); - __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME)); if (unlikely(!__pyx_b)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - #if CYTHON_COMPILING_IN_PYPY - Py_INCREF(__pyx_b); - #endif - if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - /*--- Initialize various global constants etc. ---*/ - if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) - if (__Pyx_init_sys_getdefaultencoding_params() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - #endif - if (__pyx_module_is_main_freenect) { - if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - } - #if PY_MAJOR_VERSION >= 3 - { - PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (!PyDict_GetItemString(modules, "freenect")) { - if (unlikely(PyDict_SetItemString(modules, "freenect", __pyx_m) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - } - #endif - /*--- Builtin init code ---*/ - if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /*--- Constants init code ---*/ - if (unlikely(__Pyx_InitCachedConstants() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /*--- Global init code ---*/ - /*--- Variable export code ---*/ - /*--- Function export code ---*/ - /*--- Type init code ---*/ - if (PyType_Ready(&__pyx_type_8freenect_CtxPtr) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_type_8freenect_CtxPtr.tp_print = 0; - if (__Pyx_SetAttrString(__pyx_m, "CtxPtr", (PyObject *)&__pyx_type_8freenect_CtxPtr) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_ptype_8freenect_CtxPtr = &__pyx_type_8freenect_CtxPtr; - if (PyType_Ready(&__pyx_type_8freenect_DevPtr) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_type_8freenect_DevPtr.tp_print = 0; - if (__Pyx_SetAttrString(__pyx_m, "DevPtr", (PyObject *)&__pyx_type_8freenect_DevPtr) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_ptype_8freenect_DevPtr = &__pyx_type_8freenect_DevPtr; - if (PyType_Ready(&__pyx_type_8freenect_StatePtr) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_type_8freenect_StatePtr.tp_print = 0; - if (__Pyx_SetAttrString(__pyx_m, "StatePtr", (PyObject *)&__pyx_type_8freenect_StatePtr) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_ptype_8freenect_StatePtr = &__pyx_type_8freenect_StatePtr; - /*--- Type import code ---*/ - __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "type", - #if CYTHON_COMPILING_IN_PYPY - sizeof(PyTypeObject), - #else - sizeof(PyHeapTypeObject), - #endif - 0); if (unlikely(!__pyx_ptype_7cpython_4type_type)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_ptype_5numpy_dtype = __Pyx_ImportType("numpy", "dtype", sizeof(PyArray_Descr), 0); if (unlikely(!__pyx_ptype_5numpy_dtype)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_ptype_5numpy_flatiter = __Pyx_ImportType("numpy", "flatiter", sizeof(PyArrayIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_flatiter)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_ptype_5numpy_broadcast = __Pyx_ImportType("numpy", "broadcast", sizeof(PyArrayMultiIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_broadcast)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_ptype_5numpy_ndarray = __Pyx_ImportType("numpy", "ndarray", sizeof(PyArrayObject), 0); if (unlikely(!__pyx_ptype_5numpy_ndarray)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_ptype_5numpy_ufunc = __Pyx_ImportType("numpy", "ufunc", sizeof(PyUFuncObject), 0); if (unlikely(!__pyx_ptype_5numpy_ufunc)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 861; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /*--- Variable import code ---*/ - /*--- Function import code ---*/ - /*--- Execution code ---*/ - - /* "freenect.pyx":26 - * - * from libc.stdint cimport * - * import numpy as np # <<<<<<<<<<<<<< - * cimport numpy as npc - * - */ - __pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "freenect.pyx":142 - * - * - * VIDEO_RGB = FREENECT_VIDEO_RGB # <<<<<<<<<<<<<< - * VIDEO_BAYER = FREENECT_VIDEO_BAYER - * VIDEO_IR_8BIT = FREENECT_VIDEO_IR_8BIT - */ - __pyx_t_1 = PyInt_FromLong(FREENECT_VIDEO_RGB); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_VIDEO_RGB, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "freenect.pyx":143 - * - * VIDEO_RGB = FREENECT_VIDEO_RGB - * VIDEO_BAYER = FREENECT_VIDEO_BAYER # <<<<<<<<<<<<<< - * VIDEO_IR_8BIT = FREENECT_VIDEO_IR_8BIT - * VIDEO_IR_10BIT = FREENECT_VIDEO_IR_10BIT - */ - __pyx_t_1 = PyInt_FromLong(FREENECT_VIDEO_BAYER); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_VIDEO_BAYER, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "freenect.pyx":144 - * VIDEO_RGB = FREENECT_VIDEO_RGB - * VIDEO_BAYER = FREENECT_VIDEO_BAYER - * VIDEO_IR_8BIT = FREENECT_VIDEO_IR_8BIT # <<<<<<<<<<<<<< - * VIDEO_IR_10BIT = FREENECT_VIDEO_IR_10BIT - * VIDEO_IR_10BIT_PACKED = FREENECT_VIDEO_IR_10BIT_PACKED - */ - __pyx_t_1 = PyInt_FromLong(FREENECT_VIDEO_IR_8BIT); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_VIDEO_IR_8BIT, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "freenect.pyx":145 - * VIDEO_BAYER = FREENECT_VIDEO_BAYER - * VIDEO_IR_8BIT = FREENECT_VIDEO_IR_8BIT - * VIDEO_IR_10BIT = FREENECT_VIDEO_IR_10BIT # <<<<<<<<<<<<<< - * VIDEO_IR_10BIT_PACKED = FREENECT_VIDEO_IR_10BIT_PACKED - * VIDEO_YUV_RGB = FREENECT_VIDEO_YUV_RGB - */ - __pyx_t_1 = PyInt_FromLong(FREENECT_VIDEO_IR_10BIT); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_VIDEO_IR_10BIT, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "freenect.pyx":146 - * VIDEO_IR_8BIT = FREENECT_VIDEO_IR_8BIT - * VIDEO_IR_10BIT = FREENECT_VIDEO_IR_10BIT - * VIDEO_IR_10BIT_PACKED = FREENECT_VIDEO_IR_10BIT_PACKED # <<<<<<<<<<<<<< - * VIDEO_YUV_RGB = FREENECT_VIDEO_YUV_RGB - * VIDEO_YUV_RAW = FREENECT_VIDEO_YUV_RAW - */ - __pyx_t_1 = PyInt_FromLong(FREENECT_VIDEO_IR_10BIT_PACKED); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 146; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_VIDEO_IR_10BIT_PACKED, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 146; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "freenect.pyx":147 - * VIDEO_IR_10BIT = FREENECT_VIDEO_IR_10BIT - * VIDEO_IR_10BIT_PACKED = FREENECT_VIDEO_IR_10BIT_PACKED - * VIDEO_YUV_RGB = FREENECT_VIDEO_YUV_RGB # <<<<<<<<<<<<<< - * VIDEO_YUV_RAW = FREENECT_VIDEO_YUV_RAW - * DEPTH_11BIT = FREENECT_DEPTH_11BIT - */ - __pyx_t_1 = PyInt_FromLong(FREENECT_VIDEO_YUV_RGB); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_VIDEO_YUV_RGB, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "freenect.pyx":148 - * VIDEO_IR_10BIT_PACKED = FREENECT_VIDEO_IR_10BIT_PACKED - * VIDEO_YUV_RGB = FREENECT_VIDEO_YUV_RGB - * VIDEO_YUV_RAW = FREENECT_VIDEO_YUV_RAW # <<<<<<<<<<<<<< - * DEPTH_11BIT = FREENECT_DEPTH_11BIT - * DEPTH_10BIT = FREENECT_DEPTH_10BIT - */ - __pyx_t_1 = PyInt_FromLong(FREENECT_VIDEO_YUV_RAW); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_VIDEO_YUV_RAW, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "freenect.pyx":149 - * VIDEO_YUV_RGB = FREENECT_VIDEO_YUV_RGB - * VIDEO_YUV_RAW = FREENECT_VIDEO_YUV_RAW - * DEPTH_11BIT = FREENECT_DEPTH_11BIT # <<<<<<<<<<<<<< - * DEPTH_10BIT = FREENECT_DEPTH_10BIT - * DEPTH_11BIT_PACKED = FREENECT_DEPTH_11BIT_PACKED - */ - __pyx_t_1 = PyInt_FromLong(FREENECT_DEPTH_11BIT); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_DEPTH_11BIT, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "freenect.pyx":150 - * VIDEO_YUV_RAW = FREENECT_VIDEO_YUV_RAW - * DEPTH_11BIT = FREENECT_DEPTH_11BIT - * DEPTH_10BIT = FREENECT_DEPTH_10BIT # <<<<<<<<<<<<<< - * DEPTH_11BIT_PACKED = FREENECT_DEPTH_11BIT_PACKED - * DEPTH_10BIT_PACKED = FREENECT_DEPTH_10BIT_PACKED - */ - __pyx_t_1 = PyInt_FromLong(FREENECT_DEPTH_10BIT); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_DEPTH_10BIT, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "freenect.pyx":151 - * DEPTH_11BIT = FREENECT_DEPTH_11BIT - * DEPTH_10BIT = FREENECT_DEPTH_10BIT - * DEPTH_11BIT_PACKED = FREENECT_DEPTH_11BIT_PACKED # <<<<<<<<<<<<<< - * DEPTH_10BIT_PACKED = FREENECT_DEPTH_10BIT_PACKED - * DEPTH_REGISTERED = FREENECT_DEPTH_REGISTERED - */ - __pyx_t_1 = PyInt_FromLong(FREENECT_DEPTH_11BIT_PACKED); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_DEPTH_11BIT_PACKED, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "freenect.pyx":152 - * DEPTH_10BIT = FREENECT_DEPTH_10BIT - * DEPTH_11BIT_PACKED = FREENECT_DEPTH_11BIT_PACKED - * DEPTH_10BIT_PACKED = FREENECT_DEPTH_10BIT_PACKED # <<<<<<<<<<<<<< - * DEPTH_REGISTERED = FREENECT_DEPTH_REGISTERED - * DEPTH_MM = FREENECT_DEPTH_MM - */ - __pyx_t_1 = PyInt_FromLong(FREENECT_DEPTH_10BIT_PACKED); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_DEPTH_10BIT_PACKED, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "freenect.pyx":153 - * DEPTH_11BIT_PACKED = FREENECT_DEPTH_11BIT_PACKED - * DEPTH_10BIT_PACKED = FREENECT_DEPTH_10BIT_PACKED - * DEPTH_REGISTERED = FREENECT_DEPTH_REGISTERED # <<<<<<<<<<<<<< - * DEPTH_MM = FREENECT_DEPTH_MM - * LED_OFF = FREENECT_LED_OFF - */ - __pyx_t_1 = PyInt_FromLong(FREENECT_DEPTH_REGISTERED); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_DEPTH_REGISTERED, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "freenect.pyx":154 - * DEPTH_10BIT_PACKED = FREENECT_DEPTH_10BIT_PACKED - * DEPTH_REGISTERED = FREENECT_DEPTH_REGISTERED - * DEPTH_MM = FREENECT_DEPTH_MM # <<<<<<<<<<<<<< - * LED_OFF = FREENECT_LED_OFF - * LED_GREEN = FREENECT_LED_GREEN - */ - __pyx_t_1 = PyInt_FromLong(FREENECT_DEPTH_MM); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_DEPTH_MM, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "freenect.pyx":155 - * DEPTH_REGISTERED = FREENECT_DEPTH_REGISTERED - * DEPTH_MM = FREENECT_DEPTH_MM - * LED_OFF = FREENECT_LED_OFF # <<<<<<<<<<<<<< - * LED_GREEN = FREENECT_LED_GREEN - * LED_RED = FREENECT_LED_RED - */ - __pyx_t_1 = PyInt_FromLong(LED_OFF); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_LED_OFF, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "freenect.pyx":156 - * DEPTH_MM = FREENECT_DEPTH_MM - * LED_OFF = FREENECT_LED_OFF - * LED_GREEN = FREENECT_LED_GREEN # <<<<<<<<<<<<<< - * LED_RED = FREENECT_LED_RED - * LED_YELLOW = FREENECT_LED_YELLOW - */ - __pyx_t_1 = PyInt_FromLong(LED_GREEN); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_LED_GREEN, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "freenect.pyx":157 - * LED_OFF = FREENECT_LED_OFF - * LED_GREEN = FREENECT_LED_GREEN - * LED_RED = FREENECT_LED_RED # <<<<<<<<<<<<<< - * LED_YELLOW = FREENECT_LED_YELLOW - * LED_BLINK_GREEN = FREENECT_LED_BLINK_GREEN - */ - __pyx_t_1 = PyInt_FromLong(LED_RED); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_LED_RED, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "freenect.pyx":158 - * LED_GREEN = FREENECT_LED_GREEN - * LED_RED = FREENECT_LED_RED - * LED_YELLOW = FREENECT_LED_YELLOW # <<<<<<<<<<<<<< - * LED_BLINK_GREEN = FREENECT_LED_BLINK_GREEN - * LED_BLINK_RED_YELLOW = FREENECT_LED_BLINK_RED_YELLOW - */ - __pyx_t_1 = PyInt_FromLong(LED_YELLOW); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_LED_YELLOW, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "freenect.pyx":159 - * LED_RED = FREENECT_LED_RED - * LED_YELLOW = FREENECT_LED_YELLOW - * LED_BLINK_GREEN = FREENECT_LED_BLINK_GREEN # <<<<<<<<<<<<<< - * LED_BLINK_RED_YELLOW = FREENECT_LED_BLINK_RED_YELLOW - * RESOLUTION_LOW = FREENECT_RESOLUTION_LOW - */ - __pyx_t_1 = PyInt_FromLong(LED_BLINK_GREEN); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_LED_BLINK_GREEN, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "freenect.pyx":160 - * LED_YELLOW = FREENECT_LED_YELLOW - * LED_BLINK_GREEN = FREENECT_LED_BLINK_GREEN - * LED_BLINK_RED_YELLOW = FREENECT_LED_BLINK_RED_YELLOW # <<<<<<<<<<<<<< - * RESOLUTION_LOW = FREENECT_RESOLUTION_LOW - * RESOLUTION_MEDIUM = FREENECT_RESOLUTION_MEDIUM - */ - __pyx_t_1 = PyInt_FromLong(LED_BLINK_RED_YELLOW); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_LED_BLINK_RED_YELLOW, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "freenect.pyx":161 - * LED_BLINK_GREEN = FREENECT_LED_BLINK_GREEN - * LED_BLINK_RED_YELLOW = FREENECT_LED_BLINK_RED_YELLOW - * RESOLUTION_LOW = FREENECT_RESOLUTION_LOW # <<<<<<<<<<<<<< - * RESOLUTION_MEDIUM = FREENECT_RESOLUTION_MEDIUM - * RESOLUTION_HIGH = FREENECT_RESOLUTION_HIGH - */ - __pyx_t_1 = PyInt_FromLong(FREENECT_RESOLUTION_LOW); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_RESOLUTION_LOW, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "freenect.pyx":162 - * LED_BLINK_RED_YELLOW = FREENECT_LED_BLINK_RED_YELLOW - * RESOLUTION_LOW = FREENECT_RESOLUTION_LOW - * RESOLUTION_MEDIUM = FREENECT_RESOLUTION_MEDIUM # <<<<<<<<<<<<<< - * RESOLUTION_HIGH = FREENECT_RESOLUTION_HIGH - * DEVICE_MOTOR = FREENECT_DEVICE_MOTOR - */ - __pyx_t_1 = PyInt_FromLong(FREENECT_RESOLUTION_MEDIUM); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_RESOLUTION_MEDIUM, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "freenect.pyx":163 - * RESOLUTION_LOW = FREENECT_RESOLUTION_LOW - * RESOLUTION_MEDIUM = FREENECT_RESOLUTION_MEDIUM - * RESOLUTION_HIGH = FREENECT_RESOLUTION_HIGH # <<<<<<<<<<<<<< - * DEVICE_MOTOR = FREENECT_DEVICE_MOTOR - * DEVICE_CAMERA = FREENECT_DEVICE_CAMERA - */ - __pyx_t_1 = PyInt_FromLong(FREENECT_RESOLUTION_HIGH); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_RESOLUTION_HIGH, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "freenect.pyx":164 - * RESOLUTION_MEDIUM = FREENECT_RESOLUTION_MEDIUM - * RESOLUTION_HIGH = FREENECT_RESOLUTION_HIGH - * DEVICE_MOTOR = FREENECT_DEVICE_MOTOR # <<<<<<<<<<<<<< - * DEVICE_CAMERA = FREENECT_DEVICE_CAMERA - * DEVICE_AUDIO = FREENECT_DEVICE_AUDIO - */ - __pyx_t_1 = PyInt_FromLong(FREENECT_DEVICE_MOTOR); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_DEVICE_MOTOR, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "freenect.pyx":165 - * RESOLUTION_HIGH = FREENECT_RESOLUTION_HIGH - * DEVICE_MOTOR = FREENECT_DEVICE_MOTOR - * DEVICE_CAMERA = FREENECT_DEVICE_CAMERA # <<<<<<<<<<<<<< - * DEVICE_AUDIO = FREENECT_DEVICE_AUDIO - * - */ - __pyx_t_1 = PyInt_FromLong(FREENECT_DEVICE_CAMERA); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_DEVICE_CAMERA, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "freenect.pyx":166 - * DEVICE_MOTOR = FREENECT_DEVICE_MOTOR - * DEVICE_CAMERA = FREENECT_DEVICE_CAMERA - * DEVICE_AUDIO = FREENECT_DEVICE_AUDIO # <<<<<<<<<<<<<< - * - * cdef inline str _format_ptr(void *ptr): - */ - __pyx_t_1 = PyInt_FromLong(FREENECT_DEVICE_AUDIO); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_DEVICE_AUDIO, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "freenect.pyx":219 - * return int(self._ptr.tilt_status) - * - * accelerometer_x = property(_get_accelx) # <<<<<<<<<<<<<< - * accelerometer_y = property(_get_accely) - * accelerometer_z = property(_get_accelz) - */ - __pyx_t_1 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_8freenect_StatePtr, __pyx_n_s_get_accelx); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_1); - __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_property, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (PyDict_SetItem((PyObject *)__pyx_ptype_8freenect_StatePtr->tp_dict, __pyx_n_s_accelerometer_x, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - PyType_Modified(__pyx_ptype_8freenect_StatePtr); - - /* "freenect.pyx":220 - * - * accelerometer_x = property(_get_accelx) - * accelerometer_y = property(_get_accely) # <<<<<<<<<<<<<< - * accelerometer_z = property(_get_accelz) - * tilt_angle = property(_get_tilt_angle) - */ - __pyx_t_1 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_8freenect_StatePtr, __pyx_n_s_get_accely); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 220; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 220; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_1); - __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_property, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 220; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (PyDict_SetItem((PyObject *)__pyx_ptype_8freenect_StatePtr->tp_dict, __pyx_n_s_accelerometer_y, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 220; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - PyType_Modified(__pyx_ptype_8freenect_StatePtr); - - /* "freenect.pyx":221 - * accelerometer_x = property(_get_accelx) - * accelerometer_y = property(_get_accely) - * accelerometer_z = property(_get_accelz) # <<<<<<<<<<<<<< - * tilt_angle = property(_get_tilt_angle) - * tilt_status = property(_get_tilt_status) - */ - __pyx_t_1 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_8freenect_StatePtr, __pyx_n_s_get_accelz); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_1); - __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_property, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (PyDict_SetItem((PyObject *)__pyx_ptype_8freenect_StatePtr->tp_dict, __pyx_n_s_accelerometer_z, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - PyType_Modified(__pyx_ptype_8freenect_StatePtr); - - /* "freenect.pyx":222 - * accelerometer_y = property(_get_accely) - * accelerometer_z = property(_get_accelz) - * tilt_angle = property(_get_tilt_angle) # <<<<<<<<<<<<<< - * tilt_status = property(_get_tilt_status) - * - */ - __pyx_t_1 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_8freenect_StatePtr, __pyx_n_s_get_tilt_angle); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_1); - __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_property, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (PyDict_SetItem((PyObject *)__pyx_ptype_8freenect_StatePtr->tp_dict, __pyx_n_s_tilt_angle, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - PyType_Modified(__pyx_ptype_8freenect_StatePtr); - - /* "freenect.pyx":223 - * accelerometer_z = property(_get_accelz) - * tilt_angle = property(_get_tilt_angle) - * tilt_status = property(_get_tilt_status) # <<<<<<<<<<<<<< - * - * def set_depth_mode(DevPtr dev, int res, int mode): - */ - __pyx_t_1 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_8freenect_StatePtr, __pyx_n_s_get_tilt_status); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_1); - __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_property, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (PyDict_SetItem((PyObject *)__pyx_ptype_8freenect_StatePtr->tp_dict, __pyx_n_s_tilt_status, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - PyType_Modified(__pyx_ptype_8freenect_StatePtr); - - /* "freenect.pyx":225 - * tilt_status = property(_get_tilt_status) - * - * def set_depth_mode(DevPtr dev, int res, int mode): # <<<<<<<<<<<<<< - * return freenect_set_depth_mode(dev._ptr, freenect_find_depth_mode(res, mode)) - * - */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_8freenect_1set_depth_mode, NULL, __pyx_n_s_freenect); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_set_depth_mode, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "freenect.pyx":228 - * return freenect_set_depth_mode(dev._ptr, freenect_find_depth_mode(res, mode)) - * - * def set_video_mode(DevPtr dev, int res, int mode): # <<<<<<<<<<<<<< - * return freenect_set_video_mode(dev._ptr, freenect_find_video_mode(res, mode)) - * - */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_8freenect_3set_video_mode, NULL, __pyx_n_s_freenect); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_set_video_mode, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "freenect.pyx":231 - * return freenect_set_video_mode(dev._ptr, freenect_find_video_mode(res, mode)) - * - * def get_depth_format(DevPtr dev): # <<<<<<<<<<<<<< - * return freenect_get_current_depth_mode(dev._ptr).video_format - * - */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_8freenect_5get_depth_format, NULL, __pyx_n_s_freenect); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_depth_format, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "freenect.pyx":234 - * return freenect_get_current_depth_mode(dev._ptr).video_format - * - * def get_video_format(DevPtr dev): # <<<<<<<<<<<<<< - * return freenect_get_current_video_mode(dev._ptr).video_format - * - */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_8freenect_7get_video_format, NULL, __pyx_n_s_freenect); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_video_format, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "freenect.pyx":237 - * return freenect_get_current_video_mode(dev._ptr).video_format - * - * def start_depth(DevPtr dev): # <<<<<<<<<<<<<< - * return freenect_start_depth(dev._ptr) - * - */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_8freenect_9start_depth, NULL, __pyx_n_s_freenect); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_start_depth, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "freenect.pyx":240 - * return freenect_start_depth(dev._ptr) - * - * def start_video(DevPtr dev): # <<<<<<<<<<<<<< - * return freenect_start_video(dev._ptr) - * - */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_8freenect_11start_video, NULL, __pyx_n_s_freenect); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_start_video, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "freenect.pyx":243 - * return freenect_start_video(dev._ptr) - * - * def stop_depth(DevPtr dev): # <<<<<<<<<<<<<< - * return freenect_stop_depth(dev._ptr) - * - */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_8freenect_13stop_depth, NULL, __pyx_n_s_freenect); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_stop_depth, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "freenect.pyx":246 - * return freenect_stop_depth(dev._ptr) - * - * def stop_video(DevPtr dev): # <<<<<<<<<<<<<< - * return freenect_stop_video(dev._ptr) - * - */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_8freenect_15stop_video, NULL, __pyx_n_s_freenect); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_stop_video, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "freenect.pyx":249 - * return freenect_stop_video(dev._ptr) - * - * def shutdown(CtxPtr ctx): # <<<<<<<<<<<<<< - * return freenect_shutdown(ctx._ptr) - * - */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_8freenect_17shutdown, NULL, __pyx_n_s_freenect); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_shutdown, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "freenect.pyx":252 - * return freenect_shutdown(ctx._ptr) - * - * def process_events(CtxPtr ctx): # <<<<<<<<<<<<<< - * return freenect_process_events(ctx._ptr) - * - */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_8freenect_19process_events, NULL, __pyx_n_s_freenect); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_process_events, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "freenect.pyx":255 - * return freenect_process_events(ctx._ptr) - * - * def num_devices(CtxPtr ctx): # <<<<<<<<<<<<<< - * return freenect_num_devices(ctx._ptr) - * - */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_8freenect_21num_devices, NULL, __pyx_n_s_freenect); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_num_devices, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "freenect.pyx":258 - * return freenect_num_devices(ctx._ptr) - * - * def close_device(DevPtr dev): # <<<<<<<<<<<<<< - * return freenect_close_device(dev._ptr) - * - */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_8freenect_23close_device, NULL, __pyx_n_s_freenect); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 258; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_close_device, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 258; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "freenect.pyx":261 - * return freenect_close_device(dev._ptr) - * - * def set_tilt_degs(DevPtr dev, float angle): # <<<<<<<<<<<<<< - * freenect_set_tilt_degs(dev._ptr, angle) - * - */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_8freenect_25set_tilt_degs, NULL, __pyx_n_s_freenect); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_set_tilt_degs, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "freenect.pyx":264 - * freenect_set_tilt_degs(dev._ptr, angle) - * - * def set_led(DevPtr dev, freenect_led_options option): # <<<<<<<<<<<<<< - * return freenect_set_led(dev._ptr, option) - * - */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_8freenect_27set_led, NULL, __pyx_n_s_freenect); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_set_led, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "freenect.pyx":267 - * return freenect_set_led(dev._ptr, option) - * - * def update_tilt_state(DevPtr dev): # <<<<<<<<<<<<<< - * return freenect_update_tilt_state(dev._ptr) - * - */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_8freenect_29update_tilt_state, NULL, __pyx_n_s_freenect); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_update_tilt_state, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "freenect.pyx":270 - * return freenect_update_tilt_state(dev._ptr) - * - * def get_tilt_state(DevPtr dev): # <<<<<<<<<<<<<< - * cdef freenect_raw_tilt_state* state = freenect_get_tilt_state(dev._ptr) - * cdef StatePtr state_out = StatePtr.__new__(StatePtr) - */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_8freenect_31get_tilt_state, NULL, __pyx_n_s_freenect); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_tilt_state, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "freenect.pyx":276 - * return state_out - * - * def get_mks_accel(StatePtr state): # <<<<<<<<<<<<<< - * cdef double x, y, z - * freenect_get_mks_accel(state._ptr, &x, &y, &z) - */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_8freenect_33get_mks_accel, NULL, __pyx_n_s_freenect); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_mks_accel, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "freenect.pyx":281 - * return x, y, z - * - * def get_accel(DevPtr dev): # <<<<<<<<<<<<<< - * """MKS Accelerometer helper - * - */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_8freenect_35get_accel, NULL, __pyx_n_s_freenect); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 281; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_accel, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 281; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "freenect.pyx":294 - * - * - * def get_tilt_degs(StatePtr state): # <<<<<<<<<<<<<< - * return freenect_get_tilt_degs(state._ptr) - * - */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_8freenect_37get_tilt_degs, NULL, __pyx_n_s_freenect); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_tilt_degs, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "freenect.pyx":298 - * - * - * def error_open_device(): # <<<<<<<<<<<<<< - * print("Error: Can't open device. 1.) is it plugged in? 2.) Read the README") - * - */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_8freenect_39error_open_device, NULL, __pyx_n_s_freenect); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_error_open_device, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "freenect.pyx":323 - * return dev_out - * - * _depth_cb, _video_cb = None, None # <<<<<<<<<<<<<< - * - * cdef void depth_cb(freenect_device *dev, void *data, uint32_t timestamp) with gil: - */ - __pyx_t_1 = Py_None; - __Pyx_INCREF(__pyx_t_1); - __pyx_t_2 = Py_None; - __Pyx_INCREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_depth_cb, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (PyDict_SetItem(__pyx_d, __pyx_n_s_video_cb, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "freenect.pyx":347 - * _video_cb(dev_out, pydata, timestamp) - * - * def set_depth_callback(DevPtr dev, cb): # <<<<<<<<<<<<<< - * global _depth_cb - * if cb is not None: - */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_8freenect_45set_depth_callback, NULL, __pyx_n_s_freenect); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_set_depth_callback, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "freenect.pyx":356 - * freenect_set_depth_callback(dev._ptr, NULL) - * - * def set_video_callback(DevPtr dev, cb): # <<<<<<<<<<<<<< - * global _video_cb - * if cb is not None: - */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_8freenect_47set_video_callback, NULL, __pyx_n_s_freenect); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_set_video_callback, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "freenect.pyx":366 - * - * - * class Kill(Exception): # <<<<<<<<<<<<<< - * """This kills the runloop, raise from the body only""" - * - */ - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_INCREF(__pyx_builtin_Exception); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_builtin_Exception); - __Pyx_GIVEREF(__pyx_builtin_Exception); - __pyx_t_1 = __Pyx_CalculateMetaclass(NULL, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = __Pyx_Py3MetaclassPrepare(__pyx_t_1, __pyx_t_2, __pyx_n_s_Kill, __pyx_n_s_Kill, (PyObject *) NULL, __pyx_n_s_freenect, __pyx_kp_s_This_kills_the_runloop_raise_fro); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_Py3ClassCreate(__pyx_t_1, __pyx_n_s_Kill, __pyx_t_2, __pyx_t_3, NULL, 0, 1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_Kill, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "freenect.pyx":370 - * - * - * def runloop(depth=None, video=None, body=None, dev=None): # <<<<<<<<<<<<<< - * """Sets up the kinect and maintains a runloop - * - */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_8freenect_49runloop, NULL, __pyx_n_s_freenect); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_runloop, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "freenect.pyx":434 - * freenect_shutdown(ctxp) - * - * def base_runloop(CtxPtr ctx, body=None): # <<<<<<<<<<<<<< - * """Starts a runloop - * - */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_8freenect_51base_runloop, NULL, __pyx_n_s_freenect); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_base_runloop, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "freenect.pyx":458 - * pass - * - * import_array() # <<<<<<<<<<<<<< - * - * cdef object _depth_cb_np(void *data, freenect_frame_mode *mode): - */ - import_array(); - - /* "freenect.pyx":485 - * return (data)[:mode.bytes] - * - * def sync_get_depth(index=0, format=DEPTH_11BIT): # <<<<<<<<<<<<<< - * """Get the next available depth frame from the kinect, as a numpy array. - * - */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_DEPTH_11BIT); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 485; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_k__5 = __pyx_t_2; - __Pyx_GIVEREF(__pyx_t_2); - __pyx_t_2 = 0; - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_8freenect_53sync_get_depth, NULL, __pyx_n_s_freenect); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 485; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_sync_get_depth, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 485; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "freenect.pyx":515 - * - * - * def sync_get_video(index=0, format=VIDEO_RGB): # <<<<<<<<<<<<<< - * """Get the next available rgb frame from the kinect, as a numpy array. - * - */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_VIDEO_RGB); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 515; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_k__6 = __pyx_t_2; - __Pyx_GIVEREF(__pyx_t_2); - __pyx_t_2 = 0; - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_8freenect_55sync_get_video, NULL, __pyx_n_s_freenect); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 515; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_sync_get_video, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 515; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "freenect.pyx":551 - * - * - * def sync_stop(): # <<<<<<<<<<<<<< - * """Terminate the synchronous runloop if running, else this is a NOP - * """ - */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_8freenect_57sync_stop, NULL, __pyx_n_s_freenect); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 551; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_sync_stop, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 551; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "freenect.pyx":1 - * #!/usr/bin/env python # <<<<<<<<<<<<<< - * # - * # Copyright (c) 2010 Brandyn White (bwhite@dappervision.com) - */ - __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":976 - * arr.base = baseptr - * - * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< - * if arr.base is NULL: - * return None - */ - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - if (__pyx_m) { - __Pyx_AddTraceback("init freenect", __pyx_clineno, __pyx_lineno, __pyx_filename); - Py_DECREF(__pyx_m); __pyx_m = 0; - } else if (!PyErr_Occurred()) { - PyErr_SetString(PyExc_ImportError, "init freenect"); - } - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - #if PY_MAJOR_VERSION < 3 - return; - #else - return __pyx_m; - #endif -} - -/* Runtime support code */ -#if CYTHON_REFNANNY -static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { - PyObject *m = NULL, *p = NULL; - void *r = NULL; - m = PyImport_ImportModule((char *)modname); - if (!m) goto end; - p = PyObject_GetAttrString(m, (char *)"RefNannyAPI"); - if (!p) goto end; - r = PyLong_AsVoidPtr(p); -end: - Py_XDECREF(p); - Py_XDECREF(m); - return (__Pyx_RefNannyAPIStruct *)r; -} -#endif /* CYTHON_REFNANNY */ - -static PyObject *__Pyx_GetBuiltinName(PyObject *name) { - PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name); - if (unlikely(!result)) { - PyErr_Format(PyExc_NameError, -#if PY_MAJOR_VERSION >= 3 - "name '%U' is not defined", name); -#else - "name '%.200s' is not defined", PyString_AS_STRING(name)); -#endif - } - return result; -} - -#if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) { - PyObject *result; - ternaryfunc call = func->ob_type->tp_call; - if (unlikely(!call)) - return PyObject_Call(func, arg, kw); -#if PY_VERSION_HEX >= 0x02060000 - if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) - return NULL; -#endif - result = (*call)(func, arg, kw); -#if PY_VERSION_HEX >= 0x02060000 - Py_LeaveRecursiveCall(); -#endif - if (unlikely(!result) && unlikely(!PyErr_Occurred())) { - PyErr_SetString( - PyExc_SystemError, - "NULL result without error in PyObject_Call"); - } - return result; -} -#endif - -static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) { -#if CYTHON_COMPILING_IN_CPYTHON - PyObject *tmp_type, *tmp_value, *tmp_tb; - PyThreadState *tstate = PyThreadState_GET(); - tmp_type = tstate->curexc_type; - tmp_value = tstate->curexc_value; - tmp_tb = tstate->curexc_traceback; - tstate->curexc_type = type; - tstate->curexc_value = value; - tstate->curexc_traceback = tb; - Py_XDECREF(tmp_type); - Py_XDECREF(tmp_value); - Py_XDECREF(tmp_tb); -#else - PyErr_Restore(type, value, tb); -#endif -} -static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) { -#if CYTHON_COMPILING_IN_CPYTHON - PyThreadState *tstate = PyThreadState_GET(); - *type = tstate->curexc_type; - *value = tstate->curexc_value; - *tb = tstate->curexc_traceback; - tstate->curexc_type = 0; - tstate->curexc_value = 0; - tstate->curexc_traceback = 0; -#else - PyErr_Fetch(type, value, tb); -#endif -} - -#if PY_MAJOR_VERSION < 3 -static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, - CYTHON_UNUSED PyObject *cause) { - Py_XINCREF(type); - if (!value || value == Py_None) - value = NULL; - else - Py_INCREF(value); - if (!tb || tb == Py_None) - tb = NULL; - else { - Py_INCREF(tb); - if (!PyTraceBack_Check(tb)) { - PyErr_SetString(PyExc_TypeError, - "raise: arg 3 must be a traceback or None"); - goto raise_error; - } - } - #if PY_VERSION_HEX < 0x02050000 - if (PyClass_Check(type)) { - #else - if (PyType_Check(type)) { - #endif -#if CYTHON_COMPILING_IN_PYPY - if (!value) { - Py_INCREF(Py_None); - value = Py_None; - } -#endif - PyErr_NormalizeException(&type, &value, &tb); - } else { - if (value) { - PyErr_SetString(PyExc_TypeError, - "instance exception may not have a separate value"); - goto raise_error; - } - value = type; - #if PY_VERSION_HEX < 0x02050000 - if (PyInstance_Check(type)) { - type = (PyObject*) ((PyInstanceObject*)type)->in_class; - Py_INCREF(type); - } else { - type = 0; - PyErr_SetString(PyExc_TypeError, - "raise: exception must be an old-style class or instance"); - goto raise_error; - } - #else - type = (PyObject*) Py_TYPE(type); - Py_INCREF(type); - if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) { - PyErr_SetString(PyExc_TypeError, - "raise: exception class must be a subclass of BaseException"); - goto raise_error; - } - #endif - } - __Pyx_ErrRestore(type, value, tb); - return; -raise_error: - Py_XDECREF(value); - Py_XDECREF(type); - Py_XDECREF(tb); - return; -} -#else /* Python 3+ */ -static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { - PyObject* owned_instance = NULL; - if (tb == Py_None) { - tb = 0; - } else if (tb && !PyTraceBack_Check(tb)) { - PyErr_SetString(PyExc_TypeError, - "raise: arg 3 must be a traceback or None"); - goto bad; - } - if (value == Py_None) - value = 0; - if (PyExceptionInstance_Check(type)) { - if (value) { - PyErr_SetString(PyExc_TypeError, - "instance exception may not have a separate value"); - goto bad; - } - value = type; - type = (PyObject*) Py_TYPE(value); - } else if (PyExceptionClass_Check(type)) { - PyObject *instance_class = NULL; - if (value && PyExceptionInstance_Check(value)) { - instance_class = (PyObject*) Py_TYPE(value); - if (instance_class != type) { - if (PyObject_IsSubclass(instance_class, type)) { - type = instance_class; - } else { - instance_class = NULL; - } - } - } - if (!instance_class) { - PyObject *args; - if (!value) - args = PyTuple_New(0); - else if (PyTuple_Check(value)) { - Py_INCREF(value); - args = value; - } else - args = PyTuple_Pack(1, value); - if (!args) - goto bad; - owned_instance = PyObject_Call(type, args, NULL); - Py_DECREF(args); - if (!owned_instance) - goto bad; - value = owned_instance; - if (!PyExceptionInstance_Check(value)) { - PyErr_Format(PyExc_TypeError, - "calling %R should have returned an instance of " - "BaseException, not %R", - type, Py_TYPE(value)); - goto bad; - } - } - } else { - PyErr_SetString(PyExc_TypeError, - "raise: exception class must be a subclass of BaseException"); - goto bad; - } -#if PY_VERSION_HEX >= 0x03030000 - if (cause) { -#else - if (cause && cause != Py_None) { -#endif - PyObject *fixed_cause; - if (cause == Py_None) { - fixed_cause = NULL; - } else if (PyExceptionClass_Check(cause)) { - fixed_cause = PyObject_CallObject(cause, NULL); - if (fixed_cause == NULL) - goto bad; - } else if (PyExceptionInstance_Check(cause)) { - fixed_cause = cause; - Py_INCREF(fixed_cause); - } else { - PyErr_SetString(PyExc_TypeError, - "exception causes must derive from " - "BaseException"); - goto bad; - } - PyException_SetCause(value, fixed_cause); - } - PyErr_SetObject(type, value); - if (tb) { - PyThreadState *tstate = PyThreadState_GET(); - PyObject* tmp_tb = tstate->curexc_traceback; - if (tb != tmp_tb) { - Py_INCREF(tb); - tstate->curexc_traceback = tb; - Py_XDECREF(tmp_tb); - } - } -bad: - Py_XDECREF(owned_instance); - return; -} -#endif - -static void __Pyx_RaiseArgtupleInvalid( - const char* func_name, - int exact, - Py_ssize_t num_min, - Py_ssize_t num_max, - Py_ssize_t num_found) -{ - Py_ssize_t num_expected; - const char *more_or_less; - if (num_found < num_min) { - num_expected = num_min; - more_or_less = "at least"; - } else { - num_expected = num_max; - more_or_less = "at most"; - } - if (exact) { - more_or_less = "exactly"; - } - PyErr_Format(PyExc_TypeError, - "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)", - func_name, more_or_less, num_expected, - (num_expected == 1) ? "" : "s", num_found); -} - -static CYTHON_INLINE int __Pyx_CheckKeywordStrings( - PyObject *kwdict, - const char* function_name, - int kw_allowed) -{ - PyObject* key = 0; - Py_ssize_t pos = 0; -#if CYTHON_COMPILING_IN_PYPY - if (!kw_allowed && PyDict_Next(kwdict, &pos, &key, 0)) - goto invalid_keyword; - return 1; -#else - while (PyDict_Next(kwdict, &pos, &key, 0)) { - #if PY_MAJOR_VERSION < 3 - if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key))) - #endif - if (unlikely(!PyUnicode_Check(key))) - goto invalid_keyword_type; - } - if ((!kw_allowed) && unlikely(key)) - goto invalid_keyword; - return 1; -invalid_keyword_type: - PyErr_Format(PyExc_TypeError, - "%.200s() keywords must be strings", function_name); - return 0; -#endif -invalid_keyword: - PyErr_Format(PyExc_TypeError, - #if PY_MAJOR_VERSION < 3 - "%.200s() got an unexpected keyword argument '%.200s'", - function_name, PyString_AsString(key)); - #else - "%s() got an unexpected keyword argument '%U'", - function_name, key); - #endif - return 0; -} - -static void __Pyx_RaiseDoubleKeywordsError( - const char* func_name, - PyObject* kw_name) -{ - PyErr_Format(PyExc_TypeError, - #if PY_MAJOR_VERSION >= 3 - "%s() got multiple values for keyword argument '%U'", func_name, kw_name); - #else - "%s() got multiple values for keyword argument '%s'", func_name, - PyString_AsString(kw_name)); - #endif -} - -static int __Pyx_ParseOptionalKeywords( - PyObject *kwds, - PyObject **argnames[], - PyObject *kwds2, - PyObject *values[], - Py_ssize_t num_pos_args, - const char* function_name) -{ - PyObject *key = 0, *value = 0; - Py_ssize_t pos = 0; - PyObject*** name; - PyObject*** first_kw_arg = argnames + num_pos_args; - while (PyDict_Next(kwds, &pos, &key, &value)) { - name = first_kw_arg; - while (*name && (**name != key)) name++; - if (*name) { - values[name-argnames] = value; - continue; - } - name = first_kw_arg; - #if PY_MAJOR_VERSION < 3 - if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) { - while (*name) { - if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key)) - && _PyString_Eq(**name, key)) { - values[name-argnames] = value; - break; - } - name++; - } - if (*name) continue; - else { - PyObject*** argname = argnames; - while (argname != first_kw_arg) { - if ((**argname == key) || ( - (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key)) - && _PyString_Eq(**argname, key))) { - goto arg_passed_twice; - } - argname++; - } - } - } else - #endif - if (likely(PyUnicode_Check(key))) { - while (*name) { - int cmp = (**name == key) ? 0 : - #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 - (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 : - #endif - PyUnicode_Compare(**name, key); - if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; - if (cmp == 0) { - values[name-argnames] = value; - break; - } - name++; - } - if (*name) continue; - else { - PyObject*** argname = argnames; - while (argname != first_kw_arg) { - int cmp = (**argname == key) ? 0 : - #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 - (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 : - #endif - PyUnicode_Compare(**argname, key); - if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; - if (cmp == 0) goto arg_passed_twice; - argname++; - } - } - } else - goto invalid_keyword_type; - if (kwds2) { - if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; - } else { - goto invalid_keyword; - } - } - return 0; -arg_passed_twice: - __Pyx_RaiseDoubleKeywordsError(function_name, key); - goto bad; -invalid_keyword_type: - PyErr_Format(PyExc_TypeError, - "%.200s() keywords must be strings", function_name); - goto bad; -invalid_keyword: - PyErr_Format(PyExc_TypeError, - #if PY_MAJOR_VERSION < 3 - "%.200s() got an unexpected keyword argument '%.200s'", - function_name, PyString_AsString(key)); - #else - "%s() got an unexpected keyword argument '%U'", - function_name, key); - #endif -bad: - return -1; -} - -static void __Pyx_RaiseArgumentTypeInvalid(const char* name, PyObject *obj, PyTypeObject *type) { - PyErr_Format(PyExc_TypeError, - "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)", - name, type->tp_name, Py_TYPE(obj)->tp_name); -} -static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, - const char *name, int exact) -{ - if (unlikely(!type)) { - PyErr_SetString(PyExc_SystemError, "Missing type object"); - return 0; - } - if (none_allowed && obj == Py_None) return 1; - else if (exact) { - if (likely(Py_TYPE(obj) == type)) return 1; - #if PY_MAJOR_VERSION == 2 - else if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1; - #endif - } - else { - if (likely(PyObject_TypeCheck(obj, type))) return 1; - } - __Pyx_RaiseArgumentTypeInvalid(name, obj, type); - return 0; -} - -static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { - if (unlikely(!type)) { - PyErr_SetString(PyExc_SystemError, "Missing type object"); - return 0; - } - if (likely(PyObject_TypeCheck(obj, type))) - return 1; - PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s", - Py_TYPE(obj)->tp_name, type->tp_name); - return 0; -} - -static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) { - PyObject *result; -#if CYTHON_COMPILING_IN_CPYTHON - result = PyDict_GetItem(__pyx_d, name); - if (result) { - Py_INCREF(result); - } else { -#else - result = PyObject_GetItem(__pyx_d, name); - if (!result) { - PyErr_Clear(); -#endif - result = __Pyx_GetBuiltinName(name); - } - return result; -} - -static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno, - CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename, - int full_traceback) { - PyObject *old_exc, *old_val, *old_tb; - PyObject *ctx; - __Pyx_ErrFetch(&old_exc, &old_val, &old_tb); - if (full_traceback) { - Py_XINCREF(old_exc); - Py_XINCREF(old_val); - Py_XINCREF(old_tb); - __Pyx_ErrRestore(old_exc, old_val, old_tb); - PyErr_PrintEx(1); - } - #if PY_MAJOR_VERSION < 3 - ctx = PyString_FromString(name); - #else - ctx = PyUnicode_FromString(name); - #endif - __Pyx_ErrRestore(old_exc, old_val, old_tb); - if (!ctx) { - PyErr_WriteUnraisable(Py_None); - } else { - PyErr_WriteUnraisable(ctx); - Py_DECREF(ctx); - } -} - -static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb) { -#if CYTHON_COMPILING_IN_CPYTHON - PyThreadState *tstate = PyThreadState_GET(); - *type = tstate->exc_type; - *value = tstate->exc_value; - *tb = tstate->exc_traceback; - Py_XINCREF(*type); - Py_XINCREF(*value); - Py_XINCREF(*tb); -#else - PyErr_GetExcInfo(type, value, tb); -#endif -} -static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb) { -#if CYTHON_COMPILING_IN_CPYTHON - PyObject *tmp_type, *tmp_value, *tmp_tb; - PyThreadState *tstate = PyThreadState_GET(); - tmp_type = tstate->exc_type; - tmp_value = tstate->exc_value; - tmp_tb = tstate->exc_traceback; - tstate->exc_type = type; - tstate->exc_value = value; - tstate->exc_traceback = tb; - Py_XDECREF(tmp_type); - Py_XDECREF(tmp_value); - Py_XDECREF(tmp_tb); -#else - PyErr_SetExcInfo(type, value, tb); -#endif -} - -static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { - PyErr_Format(PyExc_ValueError, - "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected); -} - -static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { - PyErr_Format(PyExc_ValueError, - "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack", - index, (index == 1) ? "" : "s"); -} - -static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) { - PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); -} - -static PyObject *__Pyx_GetNameInClass(PyObject *nmspace, PyObject *name) { - PyObject *result; - result = __Pyx_PyObject_GetAttrStr(nmspace, name); - if (!result) - result = __Pyx_GetModuleGlobalName(name); - return result; -} - -static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases) { - Py_ssize_t i, nbases = PyTuple_GET_SIZE(bases); - for (i=0; i < nbases; i++) { - PyTypeObject *tmptype; - PyObject *tmp = PyTuple_GET_ITEM(bases, i); - tmptype = Py_TYPE(tmp); -#if PY_MAJOR_VERSION < 3 - if (tmptype == &PyClass_Type) - continue; -#endif - if (!metaclass) { - metaclass = tmptype; - continue; - } - if (PyType_IsSubtype(metaclass, tmptype)) - continue; - if (PyType_IsSubtype(tmptype, metaclass)) { - metaclass = tmptype; - continue; - } - PyErr_SetString(PyExc_TypeError, - "metaclass conflict: " - "the metaclass of a derived class " - "must be a (non-strict) subclass " - "of the metaclasses of all its bases"); - return NULL; - } - if (!metaclass) { -#if PY_MAJOR_VERSION < 3 - metaclass = &PyClass_Type; -#else - metaclass = &PyType_Type; -#endif - } - Py_INCREF((PyObject*) metaclass); - return (PyObject*) metaclass; -} - -static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, - PyObject *qualname, PyObject *mkw, PyObject *modname, PyObject *doc) { - PyObject *ns; - if (metaclass) { - PyObject *prep = __Pyx_PyObject_GetAttrStr(metaclass, __pyx_n_s_prepare); - if (prep) { - PyObject *pargs = PyTuple_Pack(2, name, bases); - if (unlikely(!pargs)) { - Py_DECREF(prep); - return NULL; - } - ns = PyObject_Call(prep, pargs, mkw); - Py_DECREF(prep); - Py_DECREF(pargs); - } else { - if (unlikely(!PyErr_ExceptionMatches(PyExc_AttributeError))) - return NULL; - PyErr_Clear(); - ns = PyDict_New(); - } - } else { - ns = PyDict_New(); - } - if (unlikely(!ns)) - return NULL; - if (unlikely(PyObject_SetItem(ns, __pyx_n_s_module, modname) < 0)) goto bad; - if (unlikely(PyObject_SetItem(ns, __pyx_n_s_qualname, qualname) < 0)) goto bad; - if (unlikely(doc && PyObject_SetItem(ns, __pyx_n_s_doc, doc) < 0)) goto bad; - return ns; -bad: - Py_DECREF(ns); - return NULL; -} -static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases, - PyObject *dict, PyObject *mkw, - int calculate_metaclass, int allow_py2_metaclass) { - PyObject *result, *margs; - PyObject *owned_metaclass = NULL; - if (allow_py2_metaclass) { - owned_metaclass = PyObject_GetItem(dict, __pyx_n_s_metaclass); - if (owned_metaclass) { - metaclass = owned_metaclass; - } else if (likely(PyErr_ExceptionMatches(PyExc_KeyError))) { - PyErr_Clear(); - } else { - return NULL; - } - } - if (calculate_metaclass && (!metaclass || PyType_Check(metaclass))) { - metaclass = __Pyx_CalculateMetaclass((PyTypeObject*) metaclass, bases); - Py_XDECREF(owned_metaclass); - if (unlikely(!metaclass)) - return NULL; - owned_metaclass = metaclass; - } - margs = PyTuple_Pack(3, name, bases, dict); - if (unlikely(!margs)) { - result = NULL; - } else { - result = PyObject_Call(metaclass, margs, mkw); - Py_DECREF(margs); - } - Py_XDECREF(owned_metaclass); - return result; -} - -static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) { - PyObject *empty_list = 0; - PyObject *module = 0; - PyObject *global_dict = 0; - PyObject *empty_dict = 0; - PyObject *list; - #if PY_VERSION_HEX < 0x03030000 - PyObject *py_import; - py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import); - if (!py_import) - goto bad; - #endif - if (from_list) - list = from_list; - else { - empty_list = PyList_New(0); - if (!empty_list) - goto bad; - list = empty_list; - } - global_dict = PyModule_GetDict(__pyx_m); - if (!global_dict) - goto bad; - empty_dict = PyDict_New(); - if (!empty_dict) - goto bad; - #if PY_VERSION_HEX >= 0x02050000 - { - #if PY_MAJOR_VERSION >= 3 - if (level == -1) { - if (strchr(__Pyx_MODULE_NAME, '.')) { - #if PY_VERSION_HEX < 0x03030000 - PyObject *py_level = PyInt_FromLong(1); - if (!py_level) - goto bad; - module = PyObject_CallFunctionObjArgs(py_import, - name, global_dict, empty_dict, list, py_level, NULL); - Py_DECREF(py_level); - #else - module = PyImport_ImportModuleLevelObject( - name, global_dict, empty_dict, list, 1); - #endif - if (!module) { - if (!PyErr_ExceptionMatches(PyExc_ImportError)) - goto bad; - PyErr_Clear(); - } - } - level = 0; /* try absolute import on failure */ - } - #endif - if (!module) { - #if PY_VERSION_HEX < 0x03030000 - PyObject *py_level = PyInt_FromLong(level); - if (!py_level) - goto bad; - module = PyObject_CallFunctionObjArgs(py_import, - name, global_dict, empty_dict, list, py_level, NULL); - Py_DECREF(py_level); - #else - module = PyImport_ImportModuleLevelObject( - name, global_dict, empty_dict, list, level); - #endif - } - } - #else - if (level>0) { - PyErr_SetString(PyExc_RuntimeError, "Relative import is not supported for Python <=2.4."); - goto bad; - } - module = PyObject_CallFunctionObjArgs(py_import, - name, global_dict, empty_dict, list, NULL); - #endif -bad: - #if PY_VERSION_HEX < 0x03030000 - Py_XDECREF(py_import); - #endif - Py_XDECREF(empty_list); - Py_XDECREF(empty_dict); - return module; -} - -#define __PYX_VERIFY_RETURN_INT(target_type, func_type, func) \ - { \ - func_type value = func(x); \ - if (sizeof(target_type) < sizeof(func_type)) { \ - if (unlikely(value != (func_type) (target_type) value)) { \ - func_type zero = 0; \ - PyErr_SetString(PyExc_OverflowError, \ - (is_unsigned && unlikely(value < zero)) ? \ - "can't convert negative value to " #target_type : \ - "value too large to convert to " #target_type); \ - return (target_type) -1; \ - } \ - } \ - return (target_type) value; \ - } - -#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 - #if CYTHON_USE_PYLONG_INTERNALS - #include "longintrepr.h" - #endif -#endif -static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { - const int neg_one = (int) -1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_Check(x))) { - if (sizeof(int) < sizeof(long)) { - __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG) - } else { - long val = PyInt_AS_LONG(x); - if (is_unsigned && unlikely(val < 0)) { - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to int"); - return (int) -1; - } - return (int) val; - } - } else -#endif - if (likely(PyLong_Check(x))) { - if (is_unsigned) { -#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 - #if CYTHON_USE_PYLONG_INTERNALS - if (sizeof(digit) <= sizeof(int)) { - switch (Py_SIZE(x)) { - case 0: return 0; - case 1: return (int) ((PyLongObject*)x)->ob_digit[0]; - } - } - #endif -#endif - if (unlikely(Py_SIZE(x) < 0)) { - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to int"); - return (int) -1; - } - if (sizeof(int) <= sizeof(unsigned long)) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, PyLong_AsUnsignedLong) - } else if (sizeof(int) <= sizeof(unsigned long long)) { - __PYX_VERIFY_RETURN_INT(int, unsigned long long, PyLong_AsUnsignedLongLong) - } - } else { -#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 - #if CYTHON_USE_PYLONG_INTERNALS - if (sizeof(digit) <= sizeof(int)) { - switch (Py_SIZE(x)) { - case 0: return 0; - case 1: return +(int) ((PyLongObject*)x)->ob_digit[0]; - case -1: return -(int) ((PyLongObject*)x)->ob_digit[0]; - } - } - #endif -#endif - if (sizeof(int) <= sizeof(long)) { - __PYX_VERIFY_RETURN_INT(int, long, PyLong_AsLong) - } else if (sizeof(int) <= sizeof(long long)) { - __PYX_VERIFY_RETURN_INT(int, long long, PyLong_AsLongLong) - } - } - { -#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) - PyErr_SetString(PyExc_RuntimeError, - "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); -#else - int val; - PyObject *v = __Pyx_PyNumber_Int(x); - #if PY_MAJOR_VERSION < 3 - if (likely(v) && !PyLong_Check(v)) { - PyObject *tmp = v; - v = PyNumber_Long(tmp); - Py_DECREF(tmp); - } - #endif - if (likely(v)) { - int one = 1; int is_little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&val; - int ret = _PyLong_AsByteArray((PyLongObject *)v, - bytes, sizeof(val), - is_little, !is_unsigned); - Py_DECREF(v); - if (likely(!ret)) - return val; - } -#endif - return (int) -1; - } - } else { - int val; - PyObject *tmp = __Pyx_PyNumber_Int(x); - if (!tmp) return (int) -1; - val = __Pyx_PyInt_As_int(tmp); - Py_DECREF(tmp); - return val; - } -} - -static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int16_t(int16_t value) { - const int16_t neg_one = (int16_t) -1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; - if (is_unsigned) { - if (sizeof(int16_t) < sizeof(long)) { - return PyInt_FromLong((long) value); - } else if (sizeof(int16_t) <= sizeof(unsigned long)) { - return PyLong_FromUnsignedLong((unsigned long) value); - } else if (sizeof(int16_t) <= sizeof(unsigned long long)) { - return PyLong_FromUnsignedLongLong((unsigned long long) value); - } - } else { - if (sizeof(int16_t) <= sizeof(long)) { - return PyInt_FromLong((long) value); - } else if (sizeof(int16_t) <= sizeof(long long)) { - return PyLong_FromLongLong((long long) value); - } - } - { - int one = 1; int little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&value; - return _PyLong_FromByteArray(bytes, sizeof(int16_t), - little, !is_unsigned); - } -} - -static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int8_t(int8_t value) { - const int8_t neg_one = (int8_t) -1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; - if (is_unsigned) { - if (sizeof(int8_t) < sizeof(long)) { - return PyInt_FromLong((long) value); - } else if (sizeof(int8_t) <= sizeof(unsigned long)) { - return PyLong_FromUnsignedLong((unsigned long) value); - } else if (sizeof(int8_t) <= sizeof(unsigned long long)) { - return PyLong_FromUnsignedLongLong((unsigned long long) value); - } - } else { - if (sizeof(int8_t) <= sizeof(long)) { - return PyInt_FromLong((long) value); - } else if (sizeof(int8_t) <= sizeof(long long)) { - return PyLong_FromLongLong((long long) value); - } - } - { - int one = 1; int little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&value; - return _PyLong_FromByteArray(bytes, sizeof(int8_t), - little, !is_unsigned); - } -} - -static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { - const int neg_one = (int) -1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; - if (is_unsigned) { - if (sizeof(int) < sizeof(long)) { - return PyInt_FromLong((long) value); - } else if (sizeof(int) <= sizeof(unsigned long)) { - return PyLong_FromUnsignedLong((unsigned long) value); - } else if (sizeof(int) <= sizeof(unsigned long long)) { - return PyLong_FromUnsignedLongLong((unsigned long long) value); - } - } else { - if (sizeof(int) <= sizeof(long)) { - return PyInt_FromLong((long) value); - } else if (sizeof(int) <= sizeof(long long)) { - return PyLong_FromLongLong((long long) value); - } - } - { - int one = 1; int little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&value; - return _PyLong_FromByteArray(bytes, sizeof(int), - little, !is_unsigned); - } -} - -static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int32_t(int32_t value) { - const int32_t neg_one = (int32_t) -1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; - if (is_unsigned) { - if (sizeof(int32_t) < sizeof(long)) { - return PyInt_FromLong((long) value); - } else if (sizeof(int32_t) <= sizeof(unsigned long)) { - return PyLong_FromUnsignedLong((unsigned long) value); - } else if (sizeof(int32_t) <= sizeof(unsigned long long)) { - return PyLong_FromUnsignedLongLong((unsigned long long) value); - } - } else { - if (sizeof(int32_t) <= sizeof(long)) { - return PyInt_FromLong((long) value); - } else if (sizeof(int32_t) <= sizeof(long long)) { - return PyLong_FromLongLong((long long) value); - } - } - { - int one = 1; int little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&value; - return _PyLong_FromByteArray(bytes, sizeof(int32_t), - little, !is_unsigned); - } -} - -#if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION < 3 -static PyObject *__Pyx_GetStdout(void) { - PyObject *f = PySys_GetObject((char *)"stdout"); - if (!f) { - PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout"); - } - return f; -} -static int __Pyx_Print(PyObject* f, PyObject *arg_tuple, int newline) { - int i; - if (!f) { - if (!(f = __Pyx_GetStdout())) - return -1; - } - Py_INCREF(f); - for (i=0; i < PyTuple_GET_SIZE(arg_tuple); i++) { - PyObject* v; - if (PyFile_SoftSpace(f, 1)) { - if (PyFile_WriteString(" ", f) < 0) - goto error; - } - v = PyTuple_GET_ITEM(arg_tuple, i); - if (PyFile_WriteObject(v, f, Py_PRINT_RAW) < 0) - goto error; - if (PyString_Check(v)) { - char *s = PyString_AsString(v); - Py_ssize_t len = PyString_Size(v); - if (len > 0) { - switch (s[len-1]) { - case ' ': break; - case '\f': case '\r': case '\n': case '\t': case '\v': - PyFile_SoftSpace(f, 0); - break; - default: break; - } - } - } - } - if (newline) { - if (PyFile_WriteString("\n", f) < 0) - goto error; - PyFile_SoftSpace(f, 0); - } - Py_DECREF(f); - return 0; -error: - Py_DECREF(f); - return -1; -} -#else /* Python 3 has a print function */ -static int __Pyx_Print(PyObject* stream, PyObject *arg_tuple, int newline) { - PyObject* kwargs = 0; - PyObject* result = 0; - PyObject* end_string; - if (unlikely(!__pyx_print)) { - __pyx_print = PyObject_GetAttr(__pyx_b, __pyx_n_s_print); - if (!__pyx_print) - return -1; - } - if (stream) { - kwargs = PyDict_New(); - if (unlikely(!kwargs)) - return -1; - if (unlikely(PyDict_SetItem(kwargs, __pyx_n_s_file, stream) < 0)) - goto bad; - if (!newline) { - end_string = PyUnicode_FromStringAndSize(" ", 1); - if (unlikely(!end_string)) - goto bad; - if (PyDict_SetItem(kwargs, __pyx_n_s_end, end_string) < 0) { - Py_DECREF(end_string); - goto bad; - } - Py_DECREF(end_string); - } - } else if (!newline) { - if (unlikely(!__pyx_print_kwargs)) { - __pyx_print_kwargs = PyDict_New(); - if (unlikely(!__pyx_print_kwargs)) - return -1; - end_string = PyUnicode_FromStringAndSize(" ", 1); - if (unlikely(!end_string)) - return -1; - if (PyDict_SetItem(__pyx_print_kwargs, __pyx_n_s_end, end_string) < 0) { - Py_DECREF(end_string); - return -1; - } - Py_DECREF(end_string); - } - kwargs = __pyx_print_kwargs; - } - result = PyObject_Call(__pyx_print, arg_tuple, kwargs); - if (unlikely(kwargs) && (kwargs != __pyx_print_kwargs)) - Py_DECREF(kwargs); - if (!result) - return -1; - Py_DECREF(result); - return 0; -bad: - if (kwargs != __pyx_print_kwargs) - Py_XDECREF(kwargs); - return -1; -} -#endif - -#if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION < 3 -static int __Pyx_PrintOne(PyObject* f, PyObject *o) { - if (!f) { - if (!(f = __Pyx_GetStdout())) - return -1; - } - Py_INCREF(f); - if (PyFile_SoftSpace(f, 0)) { - if (PyFile_WriteString(" ", f) < 0) - goto error; - } - if (PyFile_WriteObject(o, f, Py_PRINT_RAW) < 0) - goto error; - if (PyFile_WriteString("\n", f) < 0) - goto error; - Py_DECREF(f); - return 0; -error: - Py_DECREF(f); - return -1; - /* the line below is just to avoid C compiler - * warnings about unused functions */ - return __Pyx_Print(f, NULL, 0); -} -#else /* Python 3 has a print function */ -static int __Pyx_PrintOne(PyObject* stream, PyObject *o) { - int res; - PyObject* arg_tuple = PyTuple_Pack(1, o); - if (unlikely(!arg_tuple)) - return -1; - res = __Pyx_Print(stream, arg_tuple, 1); - Py_DECREF(arg_tuple); - return res; -} -#endif - -static CYTHON_INLINE PyObject* __Pyx_PyInt_From_uint32_t(uint32_t value) { - const uint32_t neg_one = (uint32_t) -1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; - if (is_unsigned) { - if (sizeof(uint32_t) < sizeof(long)) { - return PyInt_FromLong((long) value); - } else if (sizeof(uint32_t) <= sizeof(unsigned long)) { - return PyLong_FromUnsignedLong((unsigned long) value); - } else if (sizeof(uint32_t) <= sizeof(unsigned long long)) { - return PyLong_FromUnsignedLongLong((unsigned long long) value); - } - } else { - if (sizeof(uint32_t) <= sizeof(long)) { - return PyInt_FromLong((long) value); - } else if (sizeof(uint32_t) <= sizeof(long long)) { - return PyLong_FromLongLong((long long) value); - } - } - { - int one = 1; int little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&value; - return _PyLong_FromByteArray(bytes, sizeof(uint32_t), - little, !is_unsigned); - } -} - -#if CYTHON_CCOMPLEX - #ifdef __cplusplus - static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { - return ::std::complex< float >(x, y); - } - #else - static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { - return x + y*(__pyx_t_float_complex)_Complex_I; - } - #endif -#else - static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { - __pyx_t_float_complex z; - z.real = x; - z.imag = y; - return z; - } -#endif - -#if CYTHON_CCOMPLEX -#else - static CYTHON_INLINE int __Pyx_c_eqf(__pyx_t_float_complex a, __pyx_t_float_complex b) { - return (a.real == b.real) && (a.imag == b.imag); - } - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sumf(__pyx_t_float_complex a, __pyx_t_float_complex b) { - __pyx_t_float_complex z; - z.real = a.real + b.real; - z.imag = a.imag + b.imag; - return z; - } - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_difff(__pyx_t_float_complex a, __pyx_t_float_complex b) { - __pyx_t_float_complex z; - z.real = a.real - b.real; - z.imag = a.imag - b.imag; - return z; - } - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prodf(__pyx_t_float_complex a, __pyx_t_float_complex b) { - __pyx_t_float_complex z; - z.real = a.real * b.real - a.imag * b.imag; - z.imag = a.real * b.imag + a.imag * b.real; - return z; - } - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quotf(__pyx_t_float_complex a, __pyx_t_float_complex b) { - __pyx_t_float_complex z; - float denom = b.real * b.real + b.imag * b.imag; - z.real = (a.real * b.real + a.imag * b.imag) / denom; - z.imag = (a.imag * b.real - a.real * b.imag) / denom; - return z; - } - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_negf(__pyx_t_float_complex a) { - __pyx_t_float_complex z; - z.real = -a.real; - z.imag = -a.imag; - return z; - } - static CYTHON_INLINE int __Pyx_c_is_zerof(__pyx_t_float_complex a) { - return (a.real == 0) && (a.imag == 0); - } - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conjf(__pyx_t_float_complex a) { - __pyx_t_float_complex z; - z.real = a.real; - z.imag = -a.imag; - return z; - } - #if 1 - static CYTHON_INLINE float __Pyx_c_absf(__pyx_t_float_complex z) { - #if !defined(HAVE_HYPOT) || defined(_MSC_VER) - return sqrtf(z.real*z.real + z.imag*z.imag); - #else - return hypotf(z.real, z.imag); - #endif - } - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_powf(__pyx_t_float_complex a, __pyx_t_float_complex b) { - __pyx_t_float_complex z; - float r, lnr, theta, z_r, z_theta; - if (b.imag == 0 && b.real == (int)b.real) { - if (b.real < 0) { - float denom = a.real * a.real + a.imag * a.imag; - a.real = a.real / denom; - a.imag = -a.imag / denom; - b.real = -b.real; - } - switch ((int)b.real) { - case 0: - z.real = 1; - z.imag = 0; - return z; - case 1: - return a; - case 2: - z = __Pyx_c_prodf(a, a); - return __Pyx_c_prodf(a, a); - case 3: - z = __Pyx_c_prodf(a, a); - return __Pyx_c_prodf(z, a); - case 4: - z = __Pyx_c_prodf(a, a); - return __Pyx_c_prodf(z, z); - } - } - if (a.imag == 0) { - if (a.real == 0) { - return a; - } - r = a.real; - theta = 0; - } else { - r = __Pyx_c_absf(a); - theta = atan2f(a.imag, a.real); - } - lnr = logf(r); - z_r = expf(lnr * b.real - theta * b.imag); - z_theta = theta * b.real + lnr * b.imag; - z.real = z_r * cosf(z_theta); - z.imag = z_r * sinf(z_theta); - return z; - } - #endif -#endif - -#if CYTHON_CCOMPLEX - #ifdef __cplusplus - static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { - return ::std::complex< double >(x, y); - } - #else - static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { - return x + y*(__pyx_t_double_complex)_Complex_I; - } - #endif -#else - static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { - __pyx_t_double_complex z; - z.real = x; - z.imag = y; - return z; - } -#endif - -#if CYTHON_CCOMPLEX -#else - static CYTHON_INLINE int __Pyx_c_eq(__pyx_t_double_complex a, __pyx_t_double_complex b) { - return (a.real == b.real) && (a.imag == b.imag); - } - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum(__pyx_t_double_complex a, __pyx_t_double_complex b) { - __pyx_t_double_complex z; - z.real = a.real + b.real; - z.imag = a.imag + b.imag; - return z; - } - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff(__pyx_t_double_complex a, __pyx_t_double_complex b) { - __pyx_t_double_complex z; - z.real = a.real - b.real; - z.imag = a.imag - b.imag; - return z; - } - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod(__pyx_t_double_complex a, __pyx_t_double_complex b) { - __pyx_t_double_complex z; - z.real = a.real * b.real - a.imag * b.imag; - z.imag = a.real * b.imag + a.imag * b.real; - return z; - } - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot(__pyx_t_double_complex a, __pyx_t_double_complex b) { - __pyx_t_double_complex z; - double denom = b.real * b.real + b.imag * b.imag; - z.real = (a.real * b.real + a.imag * b.imag) / denom; - z.imag = (a.imag * b.real - a.real * b.imag) / denom; - return z; - } - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg(__pyx_t_double_complex a) { - __pyx_t_double_complex z; - z.real = -a.real; - z.imag = -a.imag; - return z; - } - static CYTHON_INLINE int __Pyx_c_is_zero(__pyx_t_double_complex a) { - return (a.real == 0) && (a.imag == 0); - } - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj(__pyx_t_double_complex a) { - __pyx_t_double_complex z; - z.real = a.real; - z.imag = -a.imag; - return z; - } - #if 1 - static CYTHON_INLINE double __Pyx_c_abs(__pyx_t_double_complex z) { - #if !defined(HAVE_HYPOT) || defined(_MSC_VER) - return sqrt(z.real*z.real + z.imag*z.imag); - #else - return hypot(z.real, z.imag); - #endif - } - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow(__pyx_t_double_complex a, __pyx_t_double_complex b) { - __pyx_t_double_complex z; - double r, lnr, theta, z_r, z_theta; - if (b.imag == 0 && b.real == (int)b.real) { - if (b.real < 0) { - double denom = a.real * a.real + a.imag * a.imag; - a.real = a.real / denom; - a.imag = -a.imag / denom; - b.real = -b.real; - } - switch ((int)b.real) { - case 0: - z.real = 1; - z.imag = 0; - return z; - case 1: - return a; - case 2: - z = __Pyx_c_prod(a, a); - return __Pyx_c_prod(a, a); - case 3: - z = __Pyx_c_prod(a, a); - return __Pyx_c_prod(z, a); - case 4: - z = __Pyx_c_prod(a, a); - return __Pyx_c_prod(z, z); - } - } - if (a.imag == 0) { - if (a.real == 0) { - return a; - } - r = a.real; - theta = 0; - } else { - r = __Pyx_c_abs(a); - theta = atan2(a.imag, a.real); - } - lnr = log(r); - z_r = exp(lnr * b.real - theta * b.imag); - z_theta = theta * b.real + lnr * b.imag; - z.real = z_r * cos(z_theta); - z.imag = z_r * sin(z_theta); - return z; - } - #endif -#endif - -static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { - const long neg_one = (long) -1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; - if (is_unsigned) { - if (sizeof(long) < sizeof(long)) { - return PyInt_FromLong((long) value); - } else if (sizeof(long) <= sizeof(unsigned long)) { - return PyLong_FromUnsignedLong((unsigned long) value); - } else if (sizeof(long) <= sizeof(unsigned long long)) { - return PyLong_FromUnsignedLongLong((unsigned long long) value); - } - } else { - if (sizeof(long) <= sizeof(long)) { - return PyInt_FromLong((long) value); - } else if (sizeof(long) <= sizeof(long long)) { - return PyLong_FromLongLong((long long) value); - } - } - { - int one = 1; int little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&value; - return _PyLong_FromByteArray(bytes, sizeof(long), - little, !is_unsigned); - } -} - -#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 - #if CYTHON_USE_PYLONG_INTERNALS - #include "longintrepr.h" - #endif -#endif -static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { - const long neg_one = (long) -1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_Check(x))) { - if (sizeof(long) < sizeof(long)) { - __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG) - } else { - long val = PyInt_AS_LONG(x); - if (is_unsigned && unlikely(val < 0)) { - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to long"); - return (long) -1; - } - return (long) val; - } - } else -#endif - if (likely(PyLong_Check(x))) { - if (is_unsigned) { -#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 - #if CYTHON_USE_PYLONG_INTERNALS - if (sizeof(digit) <= sizeof(long)) { - switch (Py_SIZE(x)) { - case 0: return 0; - case 1: return (long) ((PyLongObject*)x)->ob_digit[0]; - } - } - #endif -#endif - if (unlikely(Py_SIZE(x) < 0)) { - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to long"); - return (long) -1; - } - if (sizeof(long) <= sizeof(unsigned long)) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, PyLong_AsUnsignedLong) - } else if (sizeof(long) <= sizeof(unsigned long long)) { - __PYX_VERIFY_RETURN_INT(long, unsigned long long, PyLong_AsUnsignedLongLong) - } - } else { -#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 - #if CYTHON_USE_PYLONG_INTERNALS - if (sizeof(digit) <= sizeof(long)) { - switch (Py_SIZE(x)) { - case 0: return 0; - case 1: return +(long) ((PyLongObject*)x)->ob_digit[0]; - case -1: return -(long) ((PyLongObject*)x)->ob_digit[0]; - } - } - #endif -#endif - if (sizeof(long) <= sizeof(long)) { - __PYX_VERIFY_RETURN_INT(long, long, PyLong_AsLong) - } else if (sizeof(long) <= sizeof(long long)) { - __PYX_VERIFY_RETURN_INT(long, long long, PyLong_AsLongLong) - } - } - { -#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) - PyErr_SetString(PyExc_RuntimeError, - "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); -#else - long val; - PyObject *v = __Pyx_PyNumber_Int(x); - #if PY_MAJOR_VERSION < 3 - if (likely(v) && !PyLong_Check(v)) { - PyObject *tmp = v; - v = PyNumber_Long(tmp); - Py_DECREF(tmp); - } - #endif - if (likely(v)) { - int one = 1; int is_little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&val; - int ret = _PyLong_AsByteArray((PyLongObject *)v, - bytes, sizeof(val), - is_little, !is_unsigned); - Py_DECREF(v); - if (likely(!ret)) - return val; - } -#endif - return (long) -1; - } - } else { - long val; - PyObject *tmp = __Pyx_PyNumber_Int(x); - if (!tmp) return (long) -1; - val = __Pyx_PyInt_As_long(tmp); - Py_DECREF(tmp); - return val; - } -} - -static int __Pyx_check_binary_version(void) { - char ctversion[4], rtversion[4]; - PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); - PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion()); - if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) { - char message[200]; - PyOS_snprintf(message, sizeof(message), - "compiletime version %s of module '%.100s' " - "does not match runtime version %s", - ctversion, __Pyx_MODULE_NAME, rtversion); - #if PY_VERSION_HEX < 0x02050000 - return PyErr_Warn(NULL, message); - #else - return PyErr_WarnEx(NULL, message, 1); - #endif - } - return 0; -} - -#ifndef __PYX_HAVE_RT_ImportModule -#define __PYX_HAVE_RT_ImportModule -static PyObject *__Pyx_ImportModule(const char *name) { - PyObject *py_name = 0; - PyObject *py_module = 0; - py_name = __Pyx_PyIdentifier_FromString(name); - if (!py_name) - goto bad; - py_module = PyImport_Import(py_name); - Py_DECREF(py_name); - return py_module; -bad: - Py_XDECREF(py_name); - return 0; -} -#endif - -#ifndef __PYX_HAVE_RT_ImportType -#define __PYX_HAVE_RT_ImportType -static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, - size_t size, int strict) -{ - PyObject *py_module = 0; - PyObject *result = 0; - PyObject *py_name = 0; - char warning[200]; - Py_ssize_t basicsize; -#ifdef Py_LIMITED_API - PyObject *py_basicsize; -#endif - py_module = __Pyx_ImportModule(module_name); - if (!py_module) - goto bad; - py_name = __Pyx_PyIdentifier_FromString(class_name); - if (!py_name) - goto bad; - result = PyObject_GetAttr(py_module, py_name); - Py_DECREF(py_name); - py_name = 0; - Py_DECREF(py_module); - py_module = 0; - if (!result) - goto bad; - if (!PyType_Check(result)) { - PyErr_Format(PyExc_TypeError, - "%.200s.%.200s is not a type object", - module_name, class_name); - goto bad; - } -#ifndef Py_LIMITED_API - basicsize = ((PyTypeObject *)result)->tp_basicsize; -#else - py_basicsize = PyObject_GetAttrString(result, "__basicsize__"); - if (!py_basicsize) - goto bad; - basicsize = PyLong_AsSsize_t(py_basicsize); - Py_DECREF(py_basicsize); - py_basicsize = 0; - if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred()) - goto bad; -#endif - if (!strict && (size_t)basicsize > size) { - PyOS_snprintf(warning, sizeof(warning), - "%s.%s size changed, may indicate binary incompatibility", - module_name, class_name); - #if PY_VERSION_HEX < 0x02050000 - if (PyErr_Warn(NULL, warning) < 0) goto bad; - #else - if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad; - #endif - } - else if ((size_t)basicsize != size) { - PyErr_Format(PyExc_ValueError, - "%.200s.%.200s has the wrong size, try recompiling", - module_name, class_name); - goto bad; - } - return (PyTypeObject *)result; -bad: - Py_XDECREF(py_module); - Py_XDECREF(result); - return NULL; -} -#endif - -static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { - int start = 0, mid = 0, end = count - 1; - if (end >= 0 && code_line > entries[end].code_line) { - return count; - } - while (start < end) { - mid = (start + end) / 2; - if (code_line < entries[mid].code_line) { - end = mid; - } else if (code_line > entries[mid].code_line) { - start = mid + 1; - } else { - return mid; - } - } - if (code_line <= entries[mid].code_line) { - return mid; - } else { - return mid + 1; - } -} -static PyCodeObject *__pyx_find_code_object(int code_line) { - PyCodeObject* code_object; - int pos; - if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) { - return NULL; - } - pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); - if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) { - return NULL; - } - code_object = __pyx_code_cache.entries[pos].code_object; - Py_INCREF(code_object); - return code_object; -} -static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { - int pos, i; - __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries; - if (unlikely(!code_line)) { - return; - } - if (unlikely(!entries)) { - entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry)); - if (likely(entries)) { - __pyx_code_cache.entries = entries; - __pyx_code_cache.max_count = 64; - __pyx_code_cache.count = 1; - entries[0].code_line = code_line; - entries[0].code_object = code_object; - Py_INCREF(code_object); - } - return; - } - pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); - if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) { - PyCodeObject* tmp = entries[pos].code_object; - entries[pos].code_object = code_object; - Py_DECREF(tmp); - return; - } - if (__pyx_code_cache.count == __pyx_code_cache.max_count) { - int new_max = __pyx_code_cache.max_count + 64; - entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( - __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry)); - if (unlikely(!entries)) { - return; - } - __pyx_code_cache.entries = entries; - __pyx_code_cache.max_count = new_max; - } - for (i=__pyx_code_cache.count; i>pos; i--) { - entries[i] = entries[i-1]; - } - entries[pos].code_line = code_line; - entries[pos].code_object = code_object; - __pyx_code_cache.count++; - Py_INCREF(code_object); -} - -#include "compile.h" -#include "frameobject.h" -#include "traceback.h" -static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( - const char *funcname, int c_line, - int py_line, const char *filename) { - PyCodeObject *py_code = 0; - PyObject *py_srcfile = 0; - PyObject *py_funcname = 0; - #if PY_MAJOR_VERSION < 3 - py_srcfile = PyString_FromString(filename); - #else - py_srcfile = PyUnicode_FromString(filename); - #endif - if (!py_srcfile) goto bad; - if (c_line) { - #if PY_MAJOR_VERSION < 3 - py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); - #else - py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); - #endif - } - else { - #if PY_MAJOR_VERSION < 3 - py_funcname = PyString_FromString(funcname); - #else - py_funcname = PyUnicode_FromString(funcname); - #endif - } - if (!py_funcname) goto bad; - py_code = __Pyx_PyCode_New( - 0, /*int argcount,*/ - 0, /*int kwonlyargcount,*/ - 0, /*int nlocals,*/ - 0, /*int stacksize,*/ - 0, /*int flags,*/ - __pyx_empty_bytes, /*PyObject *code,*/ - __pyx_empty_tuple, /*PyObject *consts,*/ - __pyx_empty_tuple, /*PyObject *names,*/ - __pyx_empty_tuple, /*PyObject *varnames,*/ - __pyx_empty_tuple, /*PyObject *freevars,*/ - __pyx_empty_tuple, /*PyObject *cellvars,*/ - py_srcfile, /*PyObject *filename,*/ - py_funcname, /*PyObject *name,*/ - py_line, /*int firstlineno,*/ - __pyx_empty_bytes /*PyObject *lnotab*/ - ); - Py_DECREF(py_srcfile); - Py_DECREF(py_funcname); - return py_code; -bad: - Py_XDECREF(py_srcfile); - Py_XDECREF(py_funcname); - return NULL; -} -static void __Pyx_AddTraceback(const char *funcname, int c_line, - int py_line, const char *filename) { - PyCodeObject *py_code = 0; - PyObject *py_globals = 0; - PyFrameObject *py_frame = 0; - py_code = __pyx_find_code_object(c_line ? c_line : py_line); - if (!py_code) { - py_code = __Pyx_CreateCodeObjectForTraceback( - funcname, c_line, py_line, filename); - if (!py_code) goto bad; - __pyx_insert_code_object(c_line ? c_line : py_line, py_code); - } - py_globals = PyModule_GetDict(__pyx_m); - if (!py_globals) goto bad; - py_frame = PyFrame_New( - PyThreadState_GET(), /*PyThreadState *tstate,*/ - py_code, /*PyCodeObject *code,*/ - py_globals, /*PyObject *globals,*/ - 0 /*PyObject *locals*/ - ); - if (!py_frame) goto bad; - py_frame->f_lineno = py_line; - PyTraceBack_Here(py_frame); -bad: - Py_XDECREF(py_code); - Py_XDECREF(py_frame); -} - -static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { - while (t->p) { - #if PY_MAJOR_VERSION < 3 - if (t->is_unicode) { - *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL); - } else if (t->intern) { - *t->p = PyString_InternFromString(t->s); - } else { - *t->p = PyString_FromStringAndSize(t->s, t->n - 1); - } - #else /* Python 3+ has unicode identifiers */ - if (t->is_unicode | t->is_str) { - if (t->intern) { - *t->p = PyUnicode_InternFromString(t->s); - } else if (t->encoding) { - *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL); - } else { - *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1); - } - } else { - *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1); - } - #endif - if (!*t->p) - return -1; - ++t; - } - return 0; -} - -static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) { - return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str)); -} -static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) { - Py_ssize_t ignore; - return __Pyx_PyObject_AsStringAndSize(o, &ignore); -} -static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { -#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT - if ( -#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - __Pyx_sys_getdefaultencoding_not_ascii && -#endif - PyUnicode_Check(o)) { -#if PY_VERSION_HEX < 0x03030000 - char* defenc_c; - PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); - if (!defenc) return NULL; - defenc_c = PyBytes_AS_STRING(defenc); -#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - { - char* end = defenc_c + PyBytes_GET_SIZE(defenc); - char* c; - for (c = defenc_c; c < end; c++) { - if ((unsigned char) (*c) >= 128) { - PyUnicode_AsASCIIString(o); - return NULL; - } - } - } -#endif /*__PYX_DEFAULT_STRING_ENCODING_IS_ASCII*/ - *length = PyBytes_GET_SIZE(defenc); - return defenc_c; -#else /* PY_VERSION_HEX < 0x03030000 */ - if (PyUnicode_READY(o) == -1) return NULL; -#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - if (PyUnicode_IS_ASCII(o)) { - *length = PyUnicode_GET_LENGTH(o); - return PyUnicode_AsUTF8(o); - } else { - PyUnicode_AsASCIIString(o); - return NULL; - } -#else /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII */ - return PyUnicode_AsUTF8AndSize(o, length); -#endif /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII */ -#endif /* PY_VERSION_HEX < 0x03030000 */ - } else -#endif /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT */ -#if !CYTHON_COMPILING_IN_PYPY -#if PY_VERSION_HEX >= 0x02060000 - if (PyByteArray_Check(o)) { - *length = PyByteArray_GET_SIZE(o); - return PyByteArray_AS_STRING(o); - } else -#endif -#endif - { - char* result; - int r = PyBytes_AsStringAndSize(o, &result, length); - if (unlikely(r < 0)) { - return NULL; - } else { - return result; - } - } -} -static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { - int is_true = x == Py_True; - if (is_true | (x == Py_False) | (x == Py_None)) return is_true; - else return PyObject_IsTrue(x); -} -static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) { - PyNumberMethods *m; - const char *name = NULL; - PyObject *res = NULL; -#if PY_MAJOR_VERSION < 3 - if (PyInt_Check(x) || PyLong_Check(x)) -#else - if (PyLong_Check(x)) -#endif - return Py_INCREF(x), x; - m = Py_TYPE(x)->tp_as_number; -#if PY_MAJOR_VERSION < 3 - if (m && m->nb_int) { - name = "int"; - res = PyNumber_Int(x); - } - else if (m && m->nb_long) { - name = "long"; - res = PyNumber_Long(x); - } -#else - if (m && m->nb_int) { - name = "int"; - res = PyNumber_Long(x); - } -#endif - if (res) { -#if PY_MAJOR_VERSION < 3 - if (!PyInt_Check(res) && !PyLong_Check(res)) { -#else - if (!PyLong_Check(res)) { -#endif - PyErr_Format(PyExc_TypeError, - "__%.4s__ returned non-%.4s (type %.200s)", - name, name, Py_TYPE(res)->tp_name); - Py_DECREF(res); - return NULL; - } - } - else if (!PyErr_Occurred()) { - PyErr_SetString(PyExc_TypeError, - "an integer is required"); - } - return res; -} -#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 - #if CYTHON_USE_PYLONG_INTERNALS - #include "longintrepr.h" - #endif -#endif -static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { - Py_ssize_t ival; - PyObject *x; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_CheckExact(b))) - return PyInt_AS_LONG(b); -#endif - if (likely(PyLong_CheckExact(b))) { - #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 - #if CYTHON_USE_PYLONG_INTERNALS - switch (Py_SIZE(b)) { - case -1: return -(sdigit)((PyLongObject*)b)->ob_digit[0]; - case 0: return 0; - case 1: return ((PyLongObject*)b)->ob_digit[0]; - } - #endif - #endif - #if PY_VERSION_HEX < 0x02060000 - return PyInt_AsSsize_t(b); - #else - return PyLong_AsSsize_t(b); - #endif - } - x = PyNumber_Index(b); - if (!x) return -1; - ival = PyInt_AsSsize_t(x); - Py_DECREF(x); - return ival; -} -static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { -#if PY_VERSION_HEX < 0x02050000 - if (ival <= LONG_MAX) - return PyInt_FromLong((long)ival); - else { - unsigned char *bytes = (unsigned char *) &ival; - int one = 1; int little = (int)*(unsigned char*)&one; - return _PyLong_FromByteArray(bytes, sizeof(size_t), little, 0); - } -#else - return PyInt_FromSize_t(ival); -#endif -} - - -#endif /* Py_PYTHON_H */ diff --git a/wrappers/python/freenect.cython0.pyx b/wrappers/python/freenect.cython0.pyx new file mode 100644 index 00000000..e6f88c33 --- /dev/null +++ b/wrappers/python/freenect.cython0.pyx @@ -0,0 +1,553 @@ +#!/usr/bin/env python +# +# Copyright (c) 2010 Brandyn White (bwhite@dappervision.com) +# Andrew Miller (amiller@dappervision.com) +# +# 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. + +from libc.stdint cimport * +import numpy as np +cimport numpy as npc + +cdef extern from "numpy/arrayobject.h": + cdef object PyArray_SimpleNewFromData(int nd, npc.npy_intp *dims, + int typenum, void *data) + +cdef extern from "stdlib.h": + void free(void *ptr) + +cdef extern from "libfreenect.h": + ctypedef enum freenect_video_format: + FREENECT_VIDEO_RGB + FREENECT_VIDEO_BAYER + FREENECT_VIDEO_IR_8BIT + FREENECT_VIDEO_IR_10BIT + FREENECT_VIDEO_IR_10BIT_PACKED + FREENECT_VIDEO_YUV_RGB + FREENECT_VIDEO_YUV_RAW + + ctypedef enum freenect_depth_format: + FREENECT_DEPTH_11BIT + FREENECT_DEPTH_10BIT + FREENECT_DEPTH_11BIT_PACKED + FREENECT_DEPTH_10BIT_PACKED + FREENECT_DEPTH_REGISTERED + FREENECT_DEPTH_MM + + ctypedef enum freenect_led_options: + FREENECT_LED_OFF "LED_OFF" + FREENECT_LED_GREEN "LED_GREEN" + FREENECT_LED_RED "LED_RED" + FREENECT_LED_YELLOW "LED_YELLOW" + FREENECT_LED_BLINK_GREEN "LED_BLINK_GREEN" + FREENECT_LED_BLINK_RED_YELLOW "LED_BLINK_RED_YELLOW" + + ctypedef enum freenect_resolution: + FREENECT_RESOLUTION_LOW + FREENECT_RESOLUTION_MEDIUM + FREENECT_RESOLUTION_HIGH + + ctypedef enum freenect_device_flags: + FREENECT_DEVICE_MOTOR + FREENECT_DEVICE_CAMERA + FREENECT_DEVICE_AUDIO + + ctypedef enum freenect_tilt_status_code: + TILT_STATUS_STOPPED + TILT_STATUS_LIMIT + TILT_STATUS_MOVING + + ctypedef struct freenect_raw_tilt_state: + int16_t accelerometer_x + int16_t accelerometer_y + int16_t accelerometer_z + int8_t tilt_angle + freenect_tilt_status_code tilt_status + + ctypedef struct freenect_frame_mode: + uint32_t reserved + freenect_resolution resolution + int32_t video_format # we chose one of video_format/depth_format arbitrarily, since they are in a union + int32_t bytes + int16_t width + int16_t height + int8_t data_bits_per_pixel + int8_t padding_bits_per_pixel + int8_t framerate + int8_t is_valid + + ctypedef struct freenect_context + ctypedef struct freenect_device + + ctypedef void (*freenect_depth_cb)(freenect_device *dev, void *depth, uint32_t timestamp) + ctypedef void (*freenect_video_cb)(freenect_device *dev, void *video, uint32_t timestamp) + int freenect_init(freenect_context **ctx, void *usb_ctx) + int freenect_shutdown(freenect_context *ctx) + int freenect_process_events(freenect_context *ctx) nogil + int freenect_num_devices(freenect_context *ctx) + int freenect_select_subdevices(freenect_context *ctx, freenect_device_flags subdevs) + int freenect_open_device(freenect_context *ctx, freenect_device **dev, int index) + int freenect_close_device(freenect_device *dev) + void freenect_set_depth_callback(freenect_device *dev, freenect_depth_cb cb) + void freenect_set_video_callback(freenect_device *dev, freenect_video_cb cb) + + int freenect_get_video_mode_count() + freenect_frame_mode freenect_get_video_mode(int mode_num) + freenect_frame_mode freenect_get_current_video_mode(void *dev) + freenect_frame_mode freenect_find_video_mode(int res, int fmt) + int freenect_set_video_mode(freenect_device *dev, freenect_frame_mode mode) + + int freenect_get_depth_mode_count() + freenect_frame_mode freenect_get_depth_mode(int mode_num) + freenect_frame_mode freenect_get_current_depth_mode(void *dev) + freenect_frame_mode freenect_find_depth_mode(int res, int fmt) + int freenect_set_depth_mode(freenect_device *dev, freenect_frame_mode mode) + + int freenect_start_depth(freenect_device *dev) + int freenect_start_video(freenect_device *dev) + int freenect_stop_depth(freenect_device *dev) + int freenect_stop_video(freenect_device *dev) + int freenect_set_tilt_degs(freenect_device *dev, double angle) + int freenect_set_led(freenect_device *dev, freenect_led_options option) + int freenect_update_tilt_state(freenect_device *dev) + freenect_raw_tilt_state* freenect_get_tilt_state(freenect_device *dev) + void freenect_get_mks_accel(freenect_raw_tilt_state *state, double* x, double* y, double* z) + double freenect_get_tilt_degs(freenect_raw_tilt_state *state) + + +cdef extern from "libfreenect_sync.h": + int freenect_sync_get_video(void **video, uint32_t *timestamp, int index, freenect_video_format fmt) nogil + int freenect_sync_get_depth(void **depth, uint32_t *timestamp, int index, freenect_depth_format fmt) nogil + void freenect_sync_stop() + + +VIDEO_RGB = FREENECT_VIDEO_RGB +VIDEO_BAYER = FREENECT_VIDEO_BAYER +VIDEO_IR_8BIT = FREENECT_VIDEO_IR_8BIT +VIDEO_IR_10BIT = FREENECT_VIDEO_IR_10BIT +VIDEO_IR_10BIT_PACKED = FREENECT_VIDEO_IR_10BIT_PACKED +VIDEO_YUV_RGB = FREENECT_VIDEO_YUV_RGB +VIDEO_YUV_RAW = FREENECT_VIDEO_YUV_RAW +DEPTH_11BIT = FREENECT_DEPTH_11BIT +DEPTH_10BIT = FREENECT_DEPTH_10BIT +DEPTH_11BIT_PACKED = FREENECT_DEPTH_11BIT_PACKED +DEPTH_10BIT_PACKED = FREENECT_DEPTH_10BIT_PACKED +DEPTH_REGISTERED = FREENECT_DEPTH_REGISTERED +DEPTH_MM = FREENECT_DEPTH_MM +LED_OFF = FREENECT_LED_OFF +LED_GREEN = FREENECT_LED_GREEN +LED_RED = FREENECT_LED_RED +LED_YELLOW = FREENECT_LED_YELLOW +LED_BLINK_GREEN = FREENECT_LED_BLINK_GREEN +LED_BLINK_RED_YELLOW = FREENECT_LED_BLINK_RED_YELLOW +RESOLUTION_LOW = FREENECT_RESOLUTION_LOW +RESOLUTION_MEDIUM = FREENECT_RESOLUTION_MEDIUM +RESOLUTION_HIGH = FREENECT_RESOLUTION_HIGH +DEVICE_MOTOR = FREENECT_DEVICE_MOTOR +DEVICE_CAMERA = FREENECT_DEVICE_CAMERA +DEVICE_AUDIO = FREENECT_DEVICE_AUDIO + +cdef inline str _format_ptr(void *ptr): + if sizeof(void *) == 4: + return "0x%08x" % ptr + elif sizeof(void *) == 8: + return "0x%016x" % ptr + else: + raise TypeError("What kind of system are you using?!") + +cdef class CtxPtr: + cdef freenect_context* _ptr + def __init__(self): + # Safety: do not allow Python to create instances as they would be NULL + raise TypeError("Cannot create instances of CtxPtr from Python") + + def __repr__(self): + return "" % _format_ptr(self._ptr) + +cdef class DevPtr: + cdef freenect_device* _ptr + cdef CtxPtr ctx + def __init__(self): + # Safety: do not allow Python to create instances as they would be NULL + raise TypeError("Cannot create instances of DevPtr from Python") + + def __repr__(self): + return "" % _format_ptr(self._ptr) + +cdef class StatePtr: + cdef freenect_raw_tilt_state* _ptr + def __init__(self): + # Safety: do not allow Python to create instances as they would be NULL + raise TypeError("Cannot create instances of StatePtr from Python") + + def __repr__(self): + return "" % _format_ptr(self._ptr) + + def _get_accelx(self): + return int(self._ptr.accelerometer_x) + + def _get_accely(self): + return int(self._ptr.accelerometer_y) + + def _get_accelz(self): + return int(self._ptr.accelerometer_z) + + def _get_tilt_angle(self): + return int(self._ptr.tilt_angle) + + def _get_tilt_status(self): + return int(self._ptr.tilt_status) + + accelerometer_x = property(_get_accelx) + accelerometer_y = property(_get_accely) + accelerometer_z = property(_get_accelz) + tilt_angle = property(_get_tilt_angle) + tilt_status = property(_get_tilt_status) + +def set_depth_mode(DevPtr dev, int res, int mode): + return freenect_set_depth_mode(dev._ptr, freenect_find_depth_mode(res, mode)) + +def set_video_mode(DevPtr dev, int res, int mode): + return freenect_set_video_mode(dev._ptr, freenect_find_video_mode(res, mode)) + +def get_depth_format(DevPtr dev): + return freenect_get_current_depth_mode(dev._ptr).video_format + +def get_video_format(DevPtr dev): + return freenect_get_current_video_mode(dev._ptr).video_format + +def start_depth(DevPtr dev): + return freenect_start_depth(dev._ptr) + +def start_video(DevPtr dev): + return freenect_start_video(dev._ptr) + +def stop_depth(DevPtr dev): + return freenect_stop_depth(dev._ptr) + +def stop_video(DevPtr dev): + return freenect_stop_video(dev._ptr) + +def shutdown(CtxPtr ctx): + return freenect_shutdown(ctx._ptr) + +def process_events(CtxPtr ctx): + return freenect_process_events(ctx._ptr) + +def num_devices(CtxPtr ctx): + return freenect_num_devices(ctx._ptr) + +def close_device(DevPtr dev): + return freenect_close_device(dev._ptr) + +def set_tilt_degs(DevPtr dev, float angle): + freenect_set_tilt_degs(dev._ptr, angle) + +def set_led(DevPtr dev, freenect_led_options option): + return freenect_set_led(dev._ptr, option) + +def update_tilt_state(DevPtr dev): + return freenect_update_tilt_state(dev._ptr) + +def get_tilt_state(DevPtr dev): + cdef freenect_raw_tilt_state* state = freenect_get_tilt_state(dev._ptr) + cdef StatePtr state_out = StatePtr.__new__(StatePtr) + state_out._ptr = state + return state_out + +def get_mks_accel(StatePtr state): + cdef double x, y, z + freenect_get_mks_accel(state._ptr, &x, &y, &z) + return x, y, z + +def get_accel(DevPtr dev): + """MKS Accelerometer helper + + Args: + dev: + + Returns: + (x, y, z) accelerometer values + """ + update_tilt_state(dev) + return get_mks_accel(get_tilt_state(dev)) + + +def get_tilt_degs(StatePtr state): + return freenect_get_tilt_degs(state._ptr) + + +def error_open_device(): + print("Error: Can't open device. 1.) is it plugged in? 2.) Read the README") + +cpdef init(): + cdef freenect_context* ctx + if freenect_init(&ctx, NULL) < 0: + return + # We take both the motor and camera devices here, since we provide access + # to both but haven't wrapped the python API for selecting subdevices yet. + # Also, we don't support audio in the python wrapper yet, so no sense claiming + # the device. + freenect_select_subdevices(ctx, (FREENECT_DEVICE_MOTOR | FREENECT_DEVICE_CAMERA)) + cdef CtxPtr ctx_out = CtxPtr.__new__(CtxPtr) + ctx_out._ptr = ctx + return ctx_out + +cpdef open_device(CtxPtr ctx, int index): + cdef freenect_device* dev + if freenect_open_device(ctx._ptr, &dev, index) < 0: + return + cdef DevPtr dev_out = DevPtr.__new__(DevPtr) + dev_out._ptr = dev + dev_out.ctx = ctx + return dev_out + +_depth_cb, _video_cb = None, None + +cdef void depth_cb(freenect_device *dev, void *data, uint32_t timestamp) with gil: + cdef freenect_frame_mode mode = freenect_get_current_depth_mode(dev) + if not mode.is_valid: + return + if not _depth_cb: + return + cdef DevPtr dev_out = DevPtr.__new__(DevPtr) + dev_out._ptr = dev + pydata = _depth_cb_np(data, &mode) + _depth_cb(dev_out, pydata, timestamp) + +cdef void video_cb(freenect_device *dev, void *data, uint32_t timestamp) with gil: + cdef freenect_frame_mode mode = freenect_get_current_video_mode(dev) + if not mode.is_valid: + return + if not _video_cb: + return + cdef DevPtr dev_out = DevPtr.__new__(DevPtr) + dev_out._ptr = dev + pydata = _video_cb_np(data, &mode) + _video_cb(dev_out, pydata, timestamp) + +def set_depth_callback(DevPtr dev, cb): + global _depth_cb + if cb is not None: + _depth_cb = cb + freenect_set_depth_callback(dev._ptr, depth_cb) + else: + _depth_cb = None + freenect_set_depth_callback(dev._ptr, NULL) + +def set_video_callback(DevPtr dev, cb): + global _video_cb + if cb is not None: + _video_cb = cb + freenect_set_video_callback(dev._ptr, video_cb) + else: + _video_cb = None + freenect_set_video_callback(dev._ptr, NULL) + + +class Kill(Exception): + """This kills the runloop, raise from the body only""" + + +def runloop(depth=None, video=None, body=None, dev=None): + """Sets up the kinect and maintains a runloop + + This is where most of the action happens. You can get the dev pointer from the callback + and let this function do all of the setup for you. You may want to use threads to perform + computation externally as the callbacks should really just be used for copying data. + + Args: + depth: A function that takes (dev, depth, timestamp), corresponding to C function. + If None (default), then you won't get a callback for depth. + video: A function that takes (dev, video, timestamp), corresponding to C function. + If None (default), then you won't get a callback for video. + body: A function that takes (dev, ctx) and is called in the body of process_events + dev: Optional freenect device context. If supplied, this function will use it instead + of creating and destroying its own.. + """ + global _depth_cb, _video_cb + if depth: + _depth_cb = depth + if video: + _video_cb = video + cdef DevPtr mdev + cdef CtxPtr ctx + cdef freenect_device* devp + cdef freenect_context* ctxp + if dev is None: + ctx = init() + if not ctx: + error_open_device() + return + mdev = open_device(ctx, 0) + if not mdev: + error_open_device() + return + if depth is not None: + freenect_set_depth_mode(mdev._ptr, freenect_find_depth_mode(FREENECT_RESOLUTION_MEDIUM, FREENECT_DEPTH_11BIT)) + if video is not None: + freenect_set_video_mode(mdev._ptr, freenect_find_video_mode(FREENECT_RESOLUTION_MEDIUM, FREENECT_VIDEO_RGB)) + + else: + mdev = dev + devp = mdev._ptr + ctxp = mdev.ctx._ptr + if depth is not None: + freenect_start_depth(devp) + freenect_set_depth_callback(devp, depth_cb) + if video is not None: + freenect_start_video(devp) + freenect_set_video_callback(devp, video_cb) + try: + while True: + with nogil: + if freenect_process_events(ctxp) < 0: + break + if body: + body(mdev, mdev.ctx) + except Kill: + pass + freenect_stop_depth(devp) + freenect_stop_video(devp) + if dev is None: + freenect_close_device(devp) + freenect_shutdown(ctxp) + +def base_runloop(CtxPtr ctx, body=None): + """Starts a runloop + + This function can be used instead of runloop() to allow the Python code to + perform all setup steps independently. This simply calls process_events in + a loop, optionally calling a body function in between. Raise the Kill + exception to break out of the runloop. + + Args: + ctx: Freenect library context + body: A function that takes (ctx) and is called in the body of process_events + """ + cdef freenect_context* ctxp + ctxp = ctx._ptr + try: + while True: + with nogil: + if freenect_process_events(ctxp) < 0: + break + if body: + body(ctx) + except Kill: + pass + +npc.import_array() + +cdef object _depth_cb_np(void *data, freenect_frame_mode *mode): + cdef npc.npy_intp dims[2] + + if mode.video_format in (DEPTH_11BIT, DEPTH_10BIT, DEPTH_REGISTERED, DEPTH_MM): + dims[0], dims[1] = mode.height, mode.width + return PyArray_SimpleNewFromData(2, dims, npc.NPY_UINT16, data) + else: + return (data)[:mode.bytes] + + +cdef _video_cb_np(void *data, freenect_frame_mode *mode): + cdef npc.npy_intp dims[3] + + if mode.video_format in (VIDEO_RGB, VIDEO_YUV_RGB): + dims[0], dims[1], dims[2] = mode.height, mode.width, 3 + return PyArray_SimpleNewFromData(3, dims, npc.NPY_UINT8, data) + elif mode.video_format == VIDEO_IR_8BIT: + dims[0], dims[1] = mode.height, mode.width + return PyArray_SimpleNewFromData(2, dims, npc.NPY_UINT8, data) + elif mode.video_format == VIDEO_IR_10BIT: + dims[0], dims[1] = mode.height, mode.width + return PyArray_SimpleNewFromData(2, dims, npc.NPY_UINT16, data) + else: + return (data)[:mode.bytes] + +def sync_get_depth(index=0, format=DEPTH_11BIT): + """Get the next available depth frame from the kinect, as a numpy array. + + Args: + index: Kinect device index (default: 0) + format: Depth format (default: DEPTH_11BIT) + + Returns: + (depth, timestamp) or None on error + depth: A numpy array, shape:(480,640) dtype:np.uint16 + timestamp: int representing the time + """ + cdef void* data + cdef uint32_t timestamp + cdef npc.npy_intp dims[2] + cdef int out + cdef int _index = index + cdef freenect_depth_format _format = format + with nogil: + out = freenect_sync_get_depth(&data, ×tamp, _index, _format) + if out: + error_open_device() + return + if format in [DEPTH_11BIT, DEPTH_10BIT, DEPTH_MM, DEPTH_REGISTERED]: + dims[0], dims[1] = 480, 640 + return PyArray_SimpleNewFromData(2, dims, npc.NPY_UINT16, data), timestamp + else: + raise TypeError('Conversion not implemented for type [%d]' % (format)) + + +def sync_get_video(index=0, format=VIDEO_RGB): + """Get the next available rgb frame from the kinect, as a numpy array. + + Args: + index: Kinect device index (default: 0) + format: Depth format (default: VIDEO_RGB) + + Returns: + (depth, timestamp) or None on error + depth: A numpy array, shape:(480, 640, 3) dtype:np.uint8 + timestamp: int representing the time + """ + cdef void* data + cdef uint32_t timestamp + cdef npc.npy_intp dims[3] + cdef int out + cdef int _index = index + cdef freenect_video_format _format = format + with nogil: + out = freenect_sync_get_video(&data, ×tamp, _index, _format) + if out: + error_open_device() + return + if format == VIDEO_RGB: + dims[0], dims[1], dims[2] = 480, 640, 3 + return PyArray_SimpleNewFromData(3, dims, npc.NPY_UINT8, data), timestamp + elif format == VIDEO_IR_8BIT: + dims[0], dims[1] = 480, 640 + return PyArray_SimpleNewFromData(2, dims, npc.NPY_UINT8, data), timestamp + elif format == VIDEO_IR_10BIT: + dims[0], dims[1] = 480, 640 + return PyArray_SimpleNewFromData(2, dims, npc.NPY_UINT16, data), timestamp + else: + raise TypeError('Conversion not implemented for type [%d]' % (format)) + + +def sync_stop(): + """Terminate the synchronous runloop if running, else this is a NOP + """ + freenect_sync_stop() diff --git a/wrappers/python/freenect.pyx b/wrappers/python/freenect.pyx index 99b1ab89..f69483d4 100644 --- a/wrappers/python/freenect.pyx +++ b/wrappers/python/freenect.pyx @@ -27,7 +27,6 @@ import numpy as np cimport numpy as npc cdef extern from "numpy/arrayobject.h": - void import_array() cdef object PyArray_SimpleNewFromData(int nd, npc.npy_intp *dims, int typenum, void *data) @@ -322,7 +321,7 @@ cpdef open_device(CtxPtr ctx, int index): _depth_cb, _video_cb = None, None -cdef void depth_cb(freenect_device *dev, void *data, uint32_t timestamp) with gil: +cdef void depth_cb(freenect_device *dev, void *data, uint32_t timestamp) noexcept with gil: cdef freenect_frame_mode mode = freenect_get_current_depth_mode(dev) if not mode.is_valid: return @@ -333,7 +332,7 @@ cdef void depth_cb(freenect_device *dev, void *data, uint32_t timestamp) with gi pydata = _depth_cb_np(data, &mode) _depth_cb(dev_out, pydata, timestamp) -cdef void video_cb(freenect_device *dev, void *data, uint32_t timestamp) with gil: +cdef void video_cb(freenect_device *dev, void *data, uint32_t timestamp) noexcept with gil: cdef freenect_frame_mode mode = freenect_get_current_video_mode(dev) if not mode.is_valid: return @@ -455,7 +454,7 @@ def base_runloop(CtxPtr ctx, body=None): except Kill: pass -import_array() +npc.import_array() cdef object _depth_cb_np(void *data, freenect_frame_mode *mode): cdef npc.npy_intp dims[2] @@ -491,7 +490,7 @@ def sync_get_depth(index=0, format=DEPTH_11BIT): Returns: (depth, timestamp) or None on error - depth: A numpy array, shape:(640,480) dtype:np.uint16 + depth: A numpy array, shape:(480,640) dtype:np.uint16 timestamp: int representing the time """ cdef void* data