From 461d64f5f0d3eb8f233f64640d0b433aef7906cb Mon Sep 17 00:00:00 2001 From: Daniel Patrick Johnson Date: Sat, 4 Jun 2011 01:07:41 -0700 Subject: [PATCH 01/84] Added a feature to use accelerometer data to rotate camera view in software when the camera is physically rotated such that the view on the screen is always upright even when the camera is upside down. Enabling it, and disabling it is done with the "r" key. Not on by default. I enabled several things that were disabled in the last patch, but only when rotation mode is toggled on. I uploaded a youtube video of this feature http://www.youtube.com/watch?v=JSjV1Y1eC8M Signed-off-by: Daniel Patrick Johnson (teknotus) --- examples/glview.c | 86 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 68 insertions(+), 18 deletions(-) diff --git a/examples/glview.c b/examples/glview.c index eced853b..011a9752 100644 --- a/examples/glview.c +++ b/examples/glview.c @@ -63,6 +63,9 @@ uint8_t *rgb_back, *rgb_mid, *rgb_front; GLuint gl_depth_tex; GLuint gl_rgb_tex; +GLfloat camera_angle = 0.0; +int camera_rotate = 0; +int tilt_changed = 0; freenect_context *f_ctx; freenect_device *f_dev; @@ -113,17 +116,40 @@ void DrawGLScene() } pthread_mutex_unlock(&gl_backbuf_mutex); - glBindTexture(GL_TEXTURE_2D, gl_depth_tex); glTexImage2D(GL_TEXTURE_2D, 0, 3, 640, 480, 0, GL_RGB, GL_UNSIGNED_BYTE, depth_front); + if(camera_rotate){ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + freenect_raw_tilt_state* state; + freenect_update_tilt_state(f_dev); + state = freenect_get_tilt_state(f_dev); + GLfloat x_accel_raw, x_accel,y_accel_raw,y_accel; + x_accel_raw = (GLfloat)state->accelerometer_x/819.0; + y_accel_raw = (GLfloat)state->accelerometer_y/819.0; + + // sloppy acceleration vector cleanup + GLfloat accel_length = sqrt(x_accel_raw * x_accel_raw + y_accel_raw * y_accel_raw); + x_accel = x_accel_raw/accel_length; + y_accel = y_accel_raw/accel_length; + camera_angle = atan2(y_accel,x_accel)*180/M_PI -90.0; + } + else + {camera_angle = 0;} + + glLoadIdentity(); + glPushMatrix(); + glTranslatef((640.0/2.0),(480.0/2.0) ,0.0); + glRotatef(camera_angle, 0.0, 0.0, 1.0); + glTranslatef(-(640.0/2.0),-(480.0/2.0) ,0.0); glBegin(GL_TRIANGLE_FAN); glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glTexCoord2f(0, 0); glVertex3f(0,0,0); - glTexCoord2f(1, 0); glVertex3f(640,0,0); - glTexCoord2f(1, 1); glVertex3f(640,480,0); - glTexCoord2f(0, 1); glVertex3f(0,480,0); + glTexCoord2f(0, 1); glVertex3f(0,0,1.0); + glTexCoord2f(1, 1); glVertex3f(640,0,1.0); + glTexCoord2f(1, 0); glVertex3f(640,480,1.0); + glTexCoord2f(0, 0); glVertex3f(0,480,1.0); glEnd(); + glPopMatrix(); glBindTexture(GL_TEXTURE_2D, gl_rgb_tex); if (current_format == FREENECT_VIDEO_RGB || current_format == FREENECT_VIDEO_YUV_RGB) @@ -131,14 +157,19 @@ void DrawGLScene() else glTexImage2D(GL_TEXTURE_2D, 0, 1, 640, 480, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, rgb_front+640*4); + glPushMatrix(); + glTranslatef(640+(640.0/2.0),(480.0/2.0) ,0.0); + glRotatef(camera_angle, 0.0, 0.0, 1.0); + glTranslatef(-(640+(640.0/2.0)),-(480.0/2.0) ,0.0); + glBegin(GL_TRIANGLE_FAN); glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glTexCoord2f(0, 0); glVertex3f(640,0,0); - glTexCoord2f(1, 0); glVertex3f(1280,0,0); - glTexCoord2f(1, 1); glVertex3f(1280,480,0); - glTexCoord2f(0, 1); glVertex3f(640,480,0); + glTexCoord2f(0, 1); glVertex3f(640,0,0); + glTexCoord2f(1, 1); glVertex3f(1280,0,0); + glTexCoord2f(1, 0); glVertex3f(1280,480,0); + glTexCoord2f(0, 0); glVertex3f(640,480,0); glEnd(); - + glPopMatrix(); glutSwapBuffers(); } @@ -160,9 +191,11 @@ void keyPressed(unsigned char key, int x, int y) if (freenect_angle > 30) { freenect_angle = 30; } + tilt_changed++; } if (key == 's') { freenect_angle = 0; + tilt_changed++; } if (key == 'f') { if (requested_format == FREENECT_VIDEO_IR_8BIT) @@ -177,6 +210,7 @@ void keyPressed(unsigned char key, int x, int y) if (freenect_angle < -30) { freenect_angle = -30; } + tilt_changed++; } if (key == '1') { freenect_set_led(f_dev,LED_GREEN); @@ -200,7 +234,22 @@ void keyPressed(unsigned char key, int x, int y) if (key == '0') { freenect_set_led(f_dev,LED_OFF); } - freenect_set_tilt_degs(f_dev,freenect_angle); + if (key == 'r') { + if(camera_rotate) + { + camera_rotate = 0; + glDisable(GL_DEPTH_TEST); + } + else + { + camera_rotate = 1; + glEnable(GL_DEPTH_TEST); + } + } + if(tilt_changed){ + freenect_set_tilt_degs(f_dev,freenect_angle); + tilt_changed = 0; + } } void ReSizeGLScene(int Width, int Height) @@ -208,21 +257,22 @@ void ReSizeGLScene(int Width, int Height) glViewport(0,0,Width,Height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); - glOrtho (0, 1280, 480, 0, -1.0f, 1.0f); + glOrtho (0, 1280, 0, 480, -5.0f, 5.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); + } void InitGL(int Width, int Height) { glClearColor(0.0f, 0.0f, 0.0f, 0.0f); - glClearDepth(1.0); - glDepthFunc(GL_LESS); - glDepthMask(GL_FALSE); + //glClearDepth(0.0); + //glDepthFunc(GL_LESS); + //glDepthMask(GL_FALSE); glDisable(GL_DEPTH_TEST); glDisable(GL_BLEND); - glDisable(GL_ALPHA_TEST); - glEnable(GL_TEXTURE_2D); + glDisable(GL_ALPHA_TEST); + glEnable(GL_TEXTURE_2D); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glShadeModel(GL_FLAT); @@ -347,7 +397,7 @@ void *freenect_threadfunc(void *arg) freenect_start_depth(f_dev); freenect_start_video(f_dev); - printf("'w'-tilt up, 's'-level, 'x'-tilt down, '0'-'6'-select LED mode, 'f'-video format\n"); + printf("'w'-tilt up, 's'-level, 'x'-tilt down, '0'-'6'-select LED mode, 'f'-video format, 'r'-rotate camera video\n"); while (!die && freenect_process_events(f_ctx) >= 0) { //Throttle the text output From 2c8f4625bdbde912e21f88d090832216c18949b1 Mon Sep 17 00:00:00 2001 From: Alejandro Dubrovsky Date: Tue, 27 Dec 2011 01:26:42 +1100 Subject: [PATCH 02/84] Make it compile on Cython 0.15.1 Add support for DEPTH_10BIT, DEPTH_REGISTERED and DEPTH_MM Don't initialise depth and video on runloop if device is passed in Signed-off-by: Alejandro Dubrovsky --- wrappers/python/freenect.pyx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/wrappers/python/freenect.pyx b/wrappers/python/freenect.pyx index 8e28dd56..ca99d832 100644 --- a/wrappers/python/freenect.pyx +++ b/wrappers/python/freenect.pyx @@ -49,6 +49,8 @@ cdef extern from "libfreenect.h": 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" @@ -148,6 +150,8 @@ 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 @@ -278,7 +282,7 @@ cpdef init(): # 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) + freenect_select_subdevices(ctx, (FREENECT_DEVICE_MOTOR | FREENECT_DEVICE_CAMERA)) cdef CtxPtr ctx_out ctx_out = CtxPtr() ctx_out._ptr = ctx @@ -369,16 +373,19 @@ def runloop(depth=None, video=None, body=None, dev=None): 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_set_depth_mode(devp, freenect_find_depth_mode(FREENECT_RESOLUTION_MEDIUM, FREENECT_DEPTH_11BIT)) freenect_start_depth(devp) freenect_set_depth_callback(devp, depth_cb) if video is not None: - freenect_set_video_mode(devp, freenect_find_video_mode(FREENECT_RESOLUTION_MEDIUM, FREENECT_VIDEO_RGB)) freenect_start_video(devp) freenect_set_video_callback(devp, video_cb) try: @@ -476,7 +483,7 @@ def sync_get_depth(index=0, format=DEPTH_11BIT): if out: error_open_device() return - if format == DEPTH_11BIT: + 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: From f13ffdbeb38ee916bde77661d6ed1c188416840b Mon Sep 17 00:00:00 2001 From: JD Cole Date: Wed, 15 Feb 2012 11:43:37 -0800 Subject: [PATCH 03/84] Added error reporting for failed subdevice initialization. The error was encountered on Win32 when *only* the Camera subdevice had a proper driver installed. This caused a silent failure. Signed-off-by: JD Cole --- src/usb_libusb10.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/usb_libusb10.c b/src/usb_libusb10.c index b53d6f89..43575d09 100644 --- a/src/usb_libusb10.c +++ b/src/usb_libusb10.c @@ -377,15 +377,23 @@ int fnusb_open_subdevices(freenect_device *dev, int index) if (dev->usb_cam.dev) { 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."); } + if (dev->usb_motor.dev) { 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."); } + #ifdef BUILD_AUDIO if (dev->usb_audio.dev) { 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."); } #endif return -1; From c851717317d04be67e87971f589a825b19344941 Mon Sep 17 00:00:00 2001 From: Nicolas Bourdaud Date: Thu, 22 Mar 2012 11:17:56 +0100 Subject: [PATCH 04/84] Rename record binary of fakenect as fakenect-record Signed-off-by: Nicolas Bourdaud --- fakenect/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fakenect/CMakeLists.txt b/fakenect/CMakeLists.txt index 9d6aea8b..b1a22a00 100644 --- a/fakenect/CMakeLists.txt +++ b/fakenect/CMakeLists.txt @@ -13,9 +13,9 @@ target_link_libraries(fakenect ${MATH_LIB}) install (TARGETS fakenect DESTINATION "${PROJECT_LIBRARY_INSTALL_DIR}/fakenect") -add_executable(record record.c) -target_link_libraries(record freenect) -install (TARGETS record +add_executable(fakenect-record record.c) +target_link_libraries(fakenect-record freenect m) +install (TARGETS fakenect-record DESTINATION bin) CONFIGURE_FILE("fakenect.sh.in" From bf5c87e84c058b01c4f3d7e3ab0b03c31e73f537 Mon Sep 17 00:00:00 2001 From: Nicolas Bourdaud Date: Thu, 22 Mar 2012 11:32:34 +0100 Subject: [PATCH 05/84] Prefix freenect- to the name of the installed demos This prefix is added to avoid name clashes with other binaries installed on the system. Signed-off-by: Nicolas Bourdaud --- examples/CMakeLists.txt | 56 +++++++++++++++++----------------- wrappers/cpp/CMakeLists.txt | 8 ++--- wrappers/opencv/CMakeLists.txt | 6 ++-- 3 files changed, 35 insertions(+), 35 deletions(-) mode change 100755 => 100644 examples/CMakeLists.txt diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt old mode 100755 new mode 100644 index 13c98fc4..2cee5fc7 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -17,18 +17,18 @@ if (WIN32) include_directories(${THREADS_PTHREADS_INCLUDE_DIR}) endif() -add_executable(glview glview.c) -add_executable(regview regview.c) -add_executable(hiview hiview.c) +add_executable(freenect-glview glview.c) +add_executable(freenect-regview regview.c) +add_executable(freenect-hiview hiview.c) if(BUILD_AUDIO) - add_executable(wavrecord wavrecord.c) - add_executable(micview micview.c) + add_executable(freenect-wavrecord wavrecord.c) + add_executable(freenect-micview micview.c) endif() if (BUILD_C_SYNC) - add_executable(glpclview glpclview.c) - add_executable(tiltdemo tiltdemo.c) - add_executable(regtest regtest.c) + add_executable(freenect-glpclview glpclview.c) + add_executable(freenect-tiltdemo tiltdemo.c) + add_executable(freenect-regtest regtest.c) endif() # We need to include libfreenect_sync.h for glpclview @@ -37,17 +37,17 @@ include_directories (../wrappers/c_sync/) # Mac just has everything already if(APPLE) set(CMAKE_EXE_LINKER_FLAGS "-framework OpenGL -framework GLUT") - target_link_libraries(glview freenect) - target_link_libraries(regview freenect) - target_link_libraries(hiview freenect) + target_link_libraries(freenect-glview freenect) + target_link_libraries(freenect-regview freenect) + target_link_libraries(freenect-hiview freenect) if (BUILD_AUDIO) - target_link_libraries(wavrecord freenect) - target_link_libraries(micview freenect) + target_link_libraries(freenect-wavrecord freenect) + target_link_libraries(freenect-micview freenect) endif() if (BUILD_C_SYNC) - target_link_libraries(glpclview freenect_sync) - target_link_libraries(tiltdemo freenect_sync) - target_link_libraries(regtest freenect_sync) + target_link_libraries(freenect-glpclview freenect_sync) + target_link_libraries(freenect-tiltdemo freenect_sync) + target_link_libraries(freenect-regtest freenect_sync) endif() # Linux, not so much else() @@ -58,31 +58,31 @@ else() include_directories(${OPENGL_INCLUDE_DIRS} ${GLUT_INCLUDE_DIRS} ${USB_INCLUDE_DIRS}) - target_link_libraries(glview freenect ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB}) - target_link_libraries(regview freenect ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB}) - target_link_libraries(hiview freenect ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB}) + 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}) if (BUILD_AUDIO) - target_link_libraries(wavrecord freenect ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB}) - target_link_libraries(micview freenect ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB}) + target_link_libraries(freenect-wavrecord freenect ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB}) + target_link_libraries(freenect-micview freenect ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB}) endif() if (BUILD_C_SYNC) - target_link_libraries(glpclview freenect_sync ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} + target_link_libraries(freenect-glpclview freenect_sync ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB}) - target_link_libraries(tiltdemo freenect_sync ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB}) - target_link_libraries(regtest freenect_sync ${CMAKE_THREAD_LIBS_INIT}) + target_link_libraries(freenect-tiltdemo freenect_sync ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB}) + target_link_libraries(freenect-regtest freenect_sync ${CMAKE_THREAD_LIBS_INIT}) endif() endif() -install (TARGETS glview regview hiview +install (TARGETS freenect-glview freenect-regview freenect-hiview DESTINATION bin) if (BUILD_C_SYNC) - install (TARGETS glpclview tiltdemo + install (TARGETS freenect-glpclview freenect-tiltdemo DESTINATION bin) endif() if (BUILD_AUDIO) - install (TARGETS wavrecord DESTINATION bin) - install (TARGETS micview DESTINATION bin) + install (TARGETS freenect-wavrecord DESTINATION bin) + install (TARGETS freenect-micview DESTINATION bin) endif() diff --git a/wrappers/cpp/CMakeLists.txt b/wrappers/cpp/CMakeLists.txt index bb9c53cb..da0ce29c 100644 --- a/wrappers/cpp/CMakeLists.txt +++ b/wrappers/cpp/CMakeLists.txt @@ -14,12 +14,12 @@ endif() include_directories(.) -add_executable(cppview cppview.cpp) +add_executable(freenect-cppview cppview.cpp) # Mac just has everything already if(APPLE) set(CMAKE_EXE_LINKER_FLAGS "-framework OpenGL -framework GLUT") - target_link_libraries(cppview freenect) + target_link_libraries(freenect-cppview freenect) else() find_package(Threads REQUIRED) find_package(OpenGL REQUIRED) @@ -27,10 +27,10 @@ else() include_directories(${OPENGL_INCLUDE_DIRS} ${GLUT_INCLUDE_DIRS} ${USB_INCLUDE_DIRS}) - target_link_libraries(cppview freenect ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB}) + target_link_libraries(freenect-cppview freenect ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB}) endif() -install (TARGETS cppview +install (TARGETS freenect-cppview DESTINATION bin) ENDIF() diff --git a/wrappers/opencv/CMakeLists.txt b/wrappers/opencv/CMakeLists.txt index 542ff84c..02390752 100644 --- a/wrappers/opencv/CMakeLists.txt +++ b/wrappers/opencv/CMakeLists.txt @@ -16,7 +16,7 @@ install (TARGETS freenect_cv install (FILES "libfreenect_cv.h" DESTINATION ${PROJECT_INCLUDE_INSTALL_DIR}) -add_executable(cvdemo cvdemo.c) -target_link_libraries(cvdemo freenect freenect_sync freenect_cv ${OpenCV_LIBS}) -install (TARGETS cvdemo +add_executable(freenect-cvdemo cvdemo.c) +target_link_libraries(freenect-cvdemo freenect freenect_sync freenect_cv ${OpenCV_LIBS}) +install (TARGETS freenect-cvdemo DESTINATION bin) From 55adb4a18be547ded5730280974dbb01f128d596 Mon Sep 17 00:00:00 2001 From: Nicolas Bourdaud Date: Thu, 22 Mar 2012 11:41:31 +0100 Subject: [PATCH 06/84] Add manpages for fakenect and fakenect-record Signed-off-by: Nicolas Bourdaud --- cmake_modules/SetupDirectories.cmake | 1 + fakenect/CMakeLists.txt | 3 ++ fakenect/fakenect-record.1 | 53 ++++++++++++++++++++++++++++ fakenect/fakenect.1 | 18 ++++++++++ 4 files changed, 75 insertions(+) create mode 100644 fakenect/fakenect-record.1 create mode 100644 fakenect/fakenect.1 diff --git a/cmake_modules/SetupDirectories.cmake b/cmake_modules/SetupDirectories.cmake index 99b3e5d5..0ae7de5a 100644 --- a/cmake_modules/SetupDirectories.cmake +++ b/cmake_modules/SetupDirectories.cmake @@ -10,6 +10,7 @@ MESSAGE (STATUS "${PROJECT_NAME} will be installed to ${CMAKE_INSTALL_PREFIX}") # Installation prefix for include files STRING (TOLOWER ${PROJECT_NAME} projectNameLower) SET (PROJECT_INCLUDE_INSTALL_DIR "include/${projectNameLower}") +SET (PROJECT_MANPAGE_INSTALL_DIR "share/man") IF (PROJECT_PROC_64BIT) SET (LIB_SUFFIX "64" CACHE STRING "Suffix for library installation directory") diff --git a/fakenect/CMakeLists.txt b/fakenect/CMakeLists.txt index b1a22a00..bc156309 100644 --- a/fakenect/CMakeLists.txt +++ b/fakenect/CMakeLists.txt @@ -24,3 +24,6 @@ CONFIGURE_FILE("fakenect.sh.in" install (PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/fakenect.sh DESTINATION bin RENAME fakenect) + +install(FILES fakenect.1 fakenect-record.1 + DESTINATION ${PROJECT_MANPAGE_INSTALL_DIR}/man1) diff --git a/fakenect/fakenect-record.1 b/fakenect/fakenect-record.1 new file mode 100644 index 00000000..e2d29c9f --- /dev/null +++ b/fakenect/fakenect-record.1 @@ -0,0 +1,53 @@ +.TH FAKENECT-RECORD 1 2012-01-29 "libfreenect" "libfreenect manual" +.SH NAME +fakenect-record - program to save dumps from kinect to file +.SH SYNOPSIS +.SY fakenect-record +.OP \-h +.OP \-ffmpeg +.OP \-ffmpeg-opts \fIoptions\fP +.I outputdir +.br +.SH DESCRIPTION +.LP +\fBfakenect-record\fP dumps the output of the kinect in \fIoutputdir\fP +folder. It saves the acceleration, depth, and rgb data as individual files +with names in the form "TYPE-CURRENTIME-TIMESTAMP" where: +.IP " *" 3 +TYPE is either (a)ccel, (d)epth, or (r)gb +.IP " *" 3 +TIMESTAMP corresponds to the timestamp associated with the observation (or +in the case of accel, the last timestamp seen) +.IP " *" 3 +CURRENTTIME corresponds to a floating point version of the time in seconds. +.LP +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). +.LP +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). +.LP +Once started, the program will continue to acquire data from the kinect. +When you want to stop it, hit Ctrl-C and the signal will be caught, runloop +stopped, and everything will be stored cleanly. +.SH OPTIONS +.TP +.B \-ffmpeg +If present, send the the video stream to ffmpeg +. +.TP +.B \-ffmpeg-opts \fIoptions\fP +When using ffmpeg, specify the options to be used with it. If unspecified, +it will use the options "\-aspect 4:3 \-r 20 \-vcodec msmpeg4 \-b 30000k" +. +.TP +.B \-h +Display the command-line help +.SH "SEE ALSO" +.BR fakenect (1) + diff --git a/fakenect/fakenect.1 b/fakenect/fakenect.1 new file mode 100644 index 00000000..ebfb576a --- /dev/null +++ b/fakenect/fakenect.1 @@ -0,0 +1,18 @@ +.TH FAKENECT 1 2012-01-29 "libfreenect" "libfreenect manual" +.SH NAME +fakenect - Run a program by faking the Kinect +.SH SYNOPSIS +.SY fakenect +.I database +.I application +.I args +.br +.SH DESCRIPTION +.LP +\fBfakenect\fP runs \fIapplication\fP with the arguments \fIargs\fP using +the data contained in the folder \fIdatabase\fP. These data should have been +recorded using \fIfakenect-record\fP(1). +.SH "SEE ALSO" +.BR fakenect-record (1) + + From a1233ca81281db4734a7ab51dbc684c5b7af3f1a Mon Sep 17 00:00:00 2001 From: mcteo Date: Mon, 30 Jul 2012 00:35:54 +0100 Subject: [PATCH 07/84] Tweaked C_Sync wrapper to allow for resolution to be set Signed-off-by: Thomas Dunne --- wrappers/c_sync/libfreenect_sync.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/wrappers/c_sync/libfreenect_sync.c b/wrappers/c_sync/libfreenect_sync.c index 6fe55bd7..b48304b1 100644 --- a/wrappers/c_sync/libfreenect_sync.c +++ b/wrappers/c_sync/libfreenect_sync.c @@ -56,6 +56,8 @@ static pthread_mutex_t runloop_lock = PTHREAD_MUTEX_INITIALIZER; static int pending_runloop_tasks = 0; static pthread_mutex_t pending_runloop_tasks_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t pending_runloop_tasks_cond = PTHREAD_COND_INITIALIZER; +static freenect_resolution m_video_resolution = FREENECT_RESOLUTION_MEDIUM; +static freenect_resolution m_depth_resolution = FREENECT_RESOLUTION_MEDIUM; /* Locking Convention Rules: @@ -76,7 +78,7 @@ static int alloc_buffer_ring_video(freenect_video_format fmt, buffer_ring_t *buf case FREENECT_VIDEO_IR_8BIT: case FREENECT_VIDEO_IR_10BIT: case FREENECT_VIDEO_IR_10BIT_PACKED: - sz = freenect_find_video_mode(FREENECT_RESOLUTION_MEDIUM, fmt).bytes; + sz = freenect_find_video_mode(m_video_resolution, fmt).bytes; break; default: printf("Invalid video format %d\n", fmt); @@ -100,7 +102,7 @@ static int alloc_buffer_ring_depth(freenect_depth_format fmt, buffer_ring_t *buf case FREENECT_DEPTH_10BIT_PACKED: case FREENECT_DEPTH_REGISTERED: case FREENECT_DEPTH_MM: - sz = freenect_find_depth_mode(FREENECT_RESOLUTION_MEDIUM, fmt).bytes; + sz = freenect_find_depth_mode(m_depth_resolution, fmt).bytes; break; default: printf("Invalid depth format %d\n", fmt); @@ -217,27 +219,29 @@ static void init_thread(void) pthread_create(&thread, NULL, init, NULL); } -static int change_video_format(sync_kinect_t *kinect, freenect_video_format fmt) +static int change_video_format(sync_kinect_t *kinect, freenect_video_format fmt, freenect_resolution requested_resolution) { freenect_stop_video(kinect->dev); free_buffer_ring(&kinect->video); if (alloc_buffer_ring_video(fmt, &kinect->video)) return -1; - freenect_set_video_mode(kinect->dev, freenect_find_video_mode(FREENECT_RESOLUTION_MEDIUM, fmt)); + freenect_set_video_mode(kinect->dev, freenect_find_video_mode(requested_resolution, fmt)); freenect_set_video_buffer(kinect->dev, kinect->video.bufs[2]); freenect_start_video(kinect->dev); + m_video_resolution = requested_resolution; return 0; } -static int change_depth_format(sync_kinect_t *kinect, freenect_depth_format fmt) +static int change_depth_format(sync_kinect_t *kinect, freenect_depth_format fmt, freenect_resolution requested_resolution) { freenect_stop_depth(kinect->dev); free_buffer_ring(&kinect->depth); if (alloc_buffer_ring_depth(fmt, &kinect->depth)) return -1; - freenect_set_depth_mode(kinect->dev, freenect_find_depth_mode(FREENECT_RESOLUTION_MEDIUM, fmt)); + freenect_set_depth_mode(kinect->dev, freenect_find_depth_mode(requested_resolution, fmt)); freenect_set_depth_buffer(kinect->dev, kinect->depth.bufs[2]); freenect_start_depth(kinect->dev); + m_depth_resolution = requested_resolution; return 0; } @@ -297,9 +301,9 @@ static int setup_kinect(int index, int fmt, int is_depth) pthread_mutex_lock(&buf->lock); if (buf->fmt != fmt) { if (is_depth) - change_depth_format(kinects[index], (freenect_depth_format)fmt); + change_depth_format(kinects[index], (freenect_depth_format)fmt, m_video_resolution); else - change_video_format(kinects[index], (freenect_video_format)fmt); + change_video_format(kinects[index], (freenect_video_format)fmt, m_video_resolution); } pthread_mutex_unlock(&buf->lock); pthread_mutex_unlock(&runloop_lock); From ae32bfb7291dd2442914c55b33ee9831373e5a0d Mon Sep 17 00:00:00 2001 From: mcteo Date: Wed, 1 Aug 2012 10:28:44 +0100 Subject: [PATCH 08/84] A slightly more aggressive form of allowing resolution to be set through c_sync wrapper Signed-off-by: Thomas Dunne --- examples/glpclview.c | 4 +-- examples/regtest.c | 8 ++--- wrappers/c_sync/libfreenect_sync.c | 58 ++++++++++++++++-------------- wrappers/c_sync/libfreenect_sync.h | 7 ++-- 4 files changed, 42 insertions(+), 35 deletions(-) diff --git a/examples/glpclview.c b/examples/glpclview.c index 40b59c42..dd535333 100644 --- a/examples/glpclview.c +++ b/examples/glpclview.c @@ -117,9 +117,9 @@ void DrawGLScene() short *depth = 0; char *rgb = 0; uint32_t ts; - if (freenect_sync_get_depth((void**)&depth, &ts, 0, FREENECT_DEPTH_11BIT) < 0) + if (freenect_sync_get_depth((void**)&depth, &ts, 0, FREENECT_RESOLUTION_MEDIUM, FREENECT_DEPTH_11BIT) < 0) no_kinect_quit(); - if (freenect_sync_get_video((void**)&rgb, &ts, 0, FREENECT_VIDEO_RGB) < 0) + if (freenect_sync_get_video((void**)&rgb, &ts, 0, FREENECT_RESOLUTION_MEDIUM, FREENECT_VIDEO_RGB) < 0) no_kinect_quit(); static unsigned int indices[480][640]; diff --git a/examples/regtest.c b/examples/regtest.c index ecae9be7..08391ae5 100644 --- a/examples/regtest.c +++ b/examples/regtest.c @@ -67,7 +67,7 @@ int main(void) FILE *fp; int ret; - ret = freenect_sync_get_video((void**)&rgb, &ts, 0, FREENECT_VIDEO_RGB); + ret = freenect_sync_get_video((void**)&rgb, &ts, 0, FREENECT_RESOLUTION_MEDIUM, FREENECT_VIDEO_RGB); if (ret < 0) no_kinect_quit(); @@ -75,7 +75,7 @@ int main(void) dump_rgb(fp, rgb, 640, 480); fclose(fp); - ret = freenect_sync_get_depth((void**)&depth, &ts, 0, FREENECT_DEPTH_11BIT); + ret = freenect_sync_get_depth((void**)&depth, &ts, 0, FREENECT_RESOLUTION_MEDIUM, FREENECT_DEPTH_11BIT); if (ret < 0) no_kinect_quit(); @@ -83,7 +83,7 @@ int main(void) dump_depth(fp, depth, 640, 480); fclose(fp); - ret = freenect_sync_get_depth((void**)&depth, &ts, 0, FREENECT_DEPTH_REGISTERED); + ret = freenect_sync_get_depth((void**)&depth, &ts, 0, FREENECT_RESOLUTION_MEDIUM, FREENECT_DEPTH_REGISTERED); if (ret < 0) no_kinect_quit(); @@ -91,7 +91,7 @@ int main(void) dump_depth(fp, depth, 640, 480); fclose(fp); - ret = freenect_sync_get_depth((void**)&depth, &ts, 0, FREENECT_DEPTH_MM); + ret = freenect_sync_get_depth((void**)&depth, &ts, 0, FREENECT_RESOLUTION_MEDIUM, FREENECT_DEPTH_MM); if (ret < 0) no_kinect_quit(); diff --git a/wrappers/c_sync/libfreenect_sync.c b/wrappers/c_sync/libfreenect_sync.c index b48304b1..ca59370d 100644 --- a/wrappers/c_sync/libfreenect_sync.c +++ b/wrappers/c_sync/libfreenect_sync.c @@ -37,6 +37,7 @@ typedef struct buffer_ring { uint32_t timestamp; int valid; // True if middle buffer is valid int fmt; + int res; } buffer_ring_t; typedef struct sync_kinect { @@ -56,8 +57,6 @@ static pthread_mutex_t runloop_lock = PTHREAD_MUTEX_INITIALIZER; static int pending_runloop_tasks = 0; static pthread_mutex_t pending_runloop_tasks_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t pending_runloop_tasks_cond = PTHREAD_COND_INITIALIZER; -static freenect_resolution m_video_resolution = FREENECT_RESOLUTION_MEDIUM; -static freenect_resolution m_depth_resolution = FREENECT_RESOLUTION_MEDIUM; /* Locking Convention Rules: @@ -69,7 +68,7 @@ static freenect_resolution m_depth_resolution = FREENECT_RESOLUTION_MEDIUM; - runloop_lock, buffer_ring_t.lock (NOTE: You may only have one) */ -static int alloc_buffer_ring_video(freenect_video_format fmt, buffer_ring_t *buf) +static int alloc_buffer_ring_video(freenect_resolution res, freenect_video_format fmt, buffer_ring_t *buf) { int sz, i; switch (fmt) { @@ -78,7 +77,7 @@ static int alloc_buffer_ring_video(freenect_video_format fmt, buffer_ring_t *buf case FREENECT_VIDEO_IR_8BIT: case FREENECT_VIDEO_IR_10BIT: case FREENECT_VIDEO_IR_10BIT_PACKED: - sz = freenect_find_video_mode(m_video_resolution, fmt).bytes; + sz = freenect_find_video_mode(res, fmt).bytes; break; default: printf("Invalid video format %d\n", fmt); @@ -89,10 +88,11 @@ static int alloc_buffer_ring_video(freenect_video_format fmt, buffer_ring_t *buf buf->timestamp = 0; buf->valid = 0; buf->fmt = fmt; + buf->res = res; return 0; } -static int alloc_buffer_ring_depth(freenect_depth_format fmt, buffer_ring_t *buf) +static int alloc_buffer_ring_depth(freenect_resolution res, freenect_depth_format fmt, buffer_ring_t *buf) { int sz, i; switch (fmt) { @@ -102,7 +102,7 @@ static int alloc_buffer_ring_depth(freenect_depth_format fmt, buffer_ring_t *buf case FREENECT_DEPTH_10BIT_PACKED: case FREENECT_DEPTH_REGISTERED: case FREENECT_DEPTH_MM: - sz = freenect_find_depth_mode(m_depth_resolution, fmt).bytes; + sz = freenect_find_depth_mode(res, fmt).bytes; break; default: printf("Invalid depth format %d\n", fmt); @@ -113,6 +113,7 @@ static int alloc_buffer_ring_depth(freenect_depth_format fmt, buffer_ring_t *buf buf->timestamp = 0; buf->valid = 0; buf->fmt = fmt; + buf->res = res; return 0; } @@ -126,6 +127,7 @@ static void free_buffer_ring(buffer_ring_t *buf) buf->timestamp = 0; buf->valid = 0; buf->fmt = -1; + buf->res = -1; } static void producer_cb_inner(freenect_device *dev, void *data, uint32_t timestamp, buffer_ring_t *buf, set_buffer_t set_buffer) @@ -219,29 +221,27 @@ static void init_thread(void) pthread_create(&thread, NULL, init, NULL); } -static int change_video_format(sync_kinect_t *kinect, freenect_video_format fmt, freenect_resolution requested_resolution) +static int change_video_format(sync_kinect_t *kinect, freenect_resolution res, freenect_video_format fmt) { freenect_stop_video(kinect->dev); free_buffer_ring(&kinect->video); - if (alloc_buffer_ring_video(fmt, &kinect->video)) + if (alloc_buffer_ring_video(res, fmt, &kinect->video)) return -1; - freenect_set_video_mode(kinect->dev, freenect_find_video_mode(requested_resolution, fmt)); + freenect_set_video_mode(kinect->dev, freenect_find_video_mode(res, fmt)); freenect_set_video_buffer(kinect->dev, kinect->video.bufs[2]); freenect_start_video(kinect->dev); - m_video_resolution = requested_resolution; return 0; } -static int change_depth_format(sync_kinect_t *kinect, freenect_depth_format fmt, freenect_resolution requested_resolution) +static int change_depth_format(sync_kinect_t *kinect, freenect_resolution res, freenect_depth_format fmt) { freenect_stop_depth(kinect->dev); free_buffer_ring(&kinect->depth); - if (alloc_buffer_ring_depth(fmt, &kinect->depth)) + if (alloc_buffer_ring_depth(res, fmt, &kinect->depth)) return -1; - freenect_set_depth_mode(kinect->dev, freenect_find_depth_mode(requested_resolution, fmt)); + freenect_set_depth_mode(kinect->dev, freenect_find_depth_mode(res, fmt)); freenect_set_depth_buffer(kinect->dev, kinect->depth.bufs[2]); freenect_start_depth(kinect->dev); - m_depth_resolution = requested_resolution; return 0; } @@ -258,7 +258,9 @@ static sync_kinect_t *alloc_kinect(int index) kinect->depth.bufs[i] = NULL; } kinect->video.fmt = -1; + kinect->video.res = -1; kinect->depth.fmt = -1; + kinect->depth.res = -1; freenect_set_video_callback(kinect->dev, video_producer_cb); freenect_set_depth_callback(kinect->dev, depth_producer_cb); pthread_mutex_init(&kinect->video.lock, NULL); @@ -268,7 +270,7 @@ static sync_kinect_t *alloc_kinect(int index) return kinect; } -static int setup_kinect(int index, int fmt, int is_depth) +static int setup_kinect(int index, int res, int fmt, int is_depth) { pending_runloop_tasks_inc(); pthread_mutex_lock(&runloop_lock); @@ -299,12 +301,12 @@ static int setup_kinect(int index, int fmt, int is_depth) else buf = &kinects[index]->video; pthread_mutex_lock(&buf->lock); - if (buf->fmt != fmt) { + if ((buf->fmt != fmt) || (buf->res != res)) { if (is_depth) - change_depth_format(kinects[index], (freenect_depth_format)fmt, m_video_resolution); + change_depth_format(kinects[index], (freenect_resolution)res, (freenect_depth_format)fmt); else - change_video_format(kinects[index], (freenect_video_format)fmt, m_video_resolution); - } + change_video_format(kinects[index], (freenect_resolution)res, (freenect_video_format)fmt); + } pthread_mutex_unlock(&buf->lock); pthread_mutex_unlock(&runloop_lock); pending_runloop_tasks_dec(); @@ -343,7 +345,7 @@ static int runloop_enter(int index) return -1; } if (!thread_running || !kinects[index]) - if (setup_kinect(index, FREENECT_DEPTH_11BIT, 1)) + if (setup_kinect(index, FREENECT_RESOLUTION_MEDIUM, FREENECT_DEPTH_11BIT, 1)) return -1; pending_runloop_tasks_inc(); @@ -357,27 +359,31 @@ static void runloop_exit() pending_runloop_tasks_dec(); } -int freenect_sync_get_video(void **video, uint32_t *timestamp, int index, freenect_video_format fmt) +int freenect_sync_get_video(void **video, uint32_t *timestamp, int index, + freenect_resolution res, freenect_video_format fmt) { if (index < 0 || index >= MAX_KINECTS) { printf("Error: Invalid index [%d]\n", index); return -1; } - if (!thread_running || !kinects[index] || kinects[index]->video.fmt != fmt) - if (setup_kinect(index, fmt, 0)) + if (!thread_running || !kinects[index] || kinects[index]->video.fmt != fmt + || kinects[index]->video.res != res) + if (setup_kinect(index, res, fmt, 0)) return -1; sync_get(video, timestamp, &kinects[index]->video); return 0; } -int freenect_sync_get_depth(void **depth, uint32_t *timestamp, int index, freenect_depth_format fmt) +int freenect_sync_get_depth(void **depth, uint32_t *timestamp, int index, + freenect_resolution res, freenect_depth_format fmt) { if (index < 0 || index >= MAX_KINECTS) { printf("Error: Invalid index [%d]\n", index); return -1; } - if (!thread_running || !kinects[index] || kinects[index]->depth.fmt != fmt) - if (setup_kinect(index, fmt, 1)) + if (!thread_running || !kinects[index] || kinects[index]->depth.fmt != fmt + || kinects[index]->depth.res != res) + if (setup_kinect(index, res, fmt, 1)) return -1; sync_get(depth, timestamp, &kinects[index]->depth); return 0; diff --git a/wrappers/c_sync/libfreenect_sync.h b/wrappers/c_sync/libfreenect_sync.h index 35e76c40..64214265 100644 --- a/wrappers/c_sync/libfreenect_sync.h +++ b/wrappers/c_sync/libfreenect_sync.h @@ -33,7 +33,8 @@ extern "C" { #endif -int freenect_sync_get_video(void **video, uint32_t *timestamp, int index, freenect_video_format fmt); +int freenect_sync_get_video(void **video, uint32_t *timestamp, int index, + freenect_resolution res, freenect_video_format fmt); /* Synchronous video function, starts the runloop if it isn't running The returned buffer is valid until this function is called again, after which the buffer must not @@ -49,8 +50,8 @@ int freenect_sync_get_video(void **video, uint32_t *timestamp, int index, freene Nonzero on error. */ - -int freenect_sync_get_depth(void **depth, uint32_t *timestamp, int index, freenect_depth_format fmt); +int freenect_sync_get_depth(void **depth, uint32_t *timestamp, int index, + freenect_resolution res, freenect_depth_format fmt); /* Synchronous depth function, starts the runloop if it isn't running The returned buffer is valid until this function is called again, after which the buffer must not From 36eae29fca143b9bee0ab47954ff7baef9d62463 Mon Sep 17 00:00:00 2001 From: mcteo Date: Wed, 1 Aug 2012 15:44:07 +0100 Subject: [PATCH 09/84] Changed the names of the modified functions, and added wrapper functions (under original names) that maintain backwards compatibilty, and functionality Signed-off-by: Thomas Dunne --- examples/glpclview.c | 4 +-- examples/regtest.c | 8 +++--- wrappers/c_sync/libfreenect_sync.c | 44 +++++++++++++++++++++++------- wrappers/c_sync/libfreenect_sync.h | 18 ++++++++++-- 4 files changed, 56 insertions(+), 18 deletions(-) diff --git a/examples/glpclview.c b/examples/glpclview.c index dd535333..40b59c42 100644 --- a/examples/glpclview.c +++ b/examples/glpclview.c @@ -117,9 +117,9 @@ void DrawGLScene() short *depth = 0; char *rgb = 0; uint32_t ts; - if (freenect_sync_get_depth((void**)&depth, &ts, 0, FREENECT_RESOLUTION_MEDIUM, FREENECT_DEPTH_11BIT) < 0) + if (freenect_sync_get_depth((void**)&depth, &ts, 0, FREENECT_DEPTH_11BIT) < 0) no_kinect_quit(); - if (freenect_sync_get_video((void**)&rgb, &ts, 0, FREENECT_RESOLUTION_MEDIUM, FREENECT_VIDEO_RGB) < 0) + if (freenect_sync_get_video((void**)&rgb, &ts, 0, FREENECT_VIDEO_RGB) < 0) no_kinect_quit(); static unsigned int indices[480][640]; diff --git a/examples/regtest.c b/examples/regtest.c index 08391ae5..ecae9be7 100644 --- a/examples/regtest.c +++ b/examples/regtest.c @@ -67,7 +67,7 @@ int main(void) FILE *fp; int ret; - ret = freenect_sync_get_video((void**)&rgb, &ts, 0, FREENECT_RESOLUTION_MEDIUM, FREENECT_VIDEO_RGB); + ret = freenect_sync_get_video((void**)&rgb, &ts, 0, FREENECT_VIDEO_RGB); if (ret < 0) no_kinect_quit(); @@ -75,7 +75,7 @@ int main(void) dump_rgb(fp, rgb, 640, 480); fclose(fp); - ret = freenect_sync_get_depth((void**)&depth, &ts, 0, FREENECT_RESOLUTION_MEDIUM, FREENECT_DEPTH_11BIT); + ret = freenect_sync_get_depth((void**)&depth, &ts, 0, FREENECT_DEPTH_11BIT); if (ret < 0) no_kinect_quit(); @@ -83,7 +83,7 @@ int main(void) dump_depth(fp, depth, 640, 480); fclose(fp); - ret = freenect_sync_get_depth((void**)&depth, &ts, 0, FREENECT_RESOLUTION_MEDIUM, FREENECT_DEPTH_REGISTERED); + ret = freenect_sync_get_depth((void**)&depth, &ts, 0, FREENECT_DEPTH_REGISTERED); if (ret < 0) no_kinect_quit(); @@ -91,7 +91,7 @@ int main(void) dump_depth(fp, depth, 640, 480); fclose(fp); - ret = freenect_sync_get_depth((void**)&depth, &ts, 0, FREENECT_RESOLUTION_MEDIUM, FREENECT_DEPTH_MM); + ret = freenect_sync_get_depth((void**)&depth, &ts, 0, FREENECT_DEPTH_MM); if (ret < 0) no_kinect_quit(); diff --git a/wrappers/c_sync/libfreenect_sync.c b/wrappers/c_sync/libfreenect_sync.c index ca59370d..34ecfd94 100644 --- a/wrappers/c_sync/libfreenect_sync.c +++ b/wrappers/c_sync/libfreenect_sync.c @@ -221,7 +221,7 @@ static void init_thread(void) pthread_create(&thread, NULL, init, NULL); } -static int change_video_format(sync_kinect_t *kinect, freenect_resolution res, freenect_video_format fmt) +static int change_video_format_with_res(sync_kinect_t *kinect, freenect_resolution res, freenect_video_format fmt) { freenect_stop_video(kinect->dev); free_buffer_ring(&kinect->video); @@ -233,7 +233,12 @@ static int change_video_format(sync_kinect_t *kinect, freenect_resolution res, f return 0; } -static int change_depth_format(sync_kinect_t *kinect, freenect_resolution res, freenect_depth_format fmt) +static int change_video_format(sync_kinect_t *kinect, freenect_resolution res, freenect_video_format fmt) +{ + return change_video_format_with_res(kinect, FREENECT_RESOLUTION_MEDIUM, fmt); +} + +static int change_depth_format_with_res(sync_kinect_t *kinect, freenect_resolution res, freenect_depth_format fmt) { freenect_stop_depth(kinect->dev); free_buffer_ring(&kinect->depth); @@ -245,6 +250,11 @@ static int change_depth_format(sync_kinect_t *kinect, freenect_resolution res, f return 0; } +static int change_depth_format(sync_kinect_t *kinect, freenect_resolution res, freenect_depth_format fmt) +{ + return change_depth_format_with_res(kinect, FREENECT_RESOLUTION_MEDIUM, fmt); +} + static sync_kinect_t *alloc_kinect(int index) { sync_kinect_t *kinect = (sync_kinect_t*)malloc(sizeof(sync_kinect_t)); @@ -270,7 +280,7 @@ static sync_kinect_t *alloc_kinect(int index) return kinect; } -static int setup_kinect(int index, int res, int fmt, int is_depth) +static int setup_kinect_with_res(int index, int res, int fmt, int is_depth) { pending_runloop_tasks_inc(); pthread_mutex_lock(&runloop_lock); @@ -303,9 +313,9 @@ static int setup_kinect(int index, int res, int fmt, int is_depth) pthread_mutex_lock(&buf->lock); if ((buf->fmt != fmt) || (buf->res != res)) { if (is_depth) - change_depth_format(kinects[index], (freenect_resolution)res, (freenect_depth_format)fmt); + change_depth_format_with_res(kinects[index], (freenect_resolution)res, (freenect_depth_format)fmt); else - change_video_format(kinects[index], (freenect_resolution)res, (freenect_video_format)fmt); + change_video_format_with_res(kinects[index], (freenect_resolution)res, (freenect_video_format)fmt); } pthread_mutex_unlock(&buf->lock); pthread_mutex_unlock(&runloop_lock); @@ -313,6 +323,10 @@ static int setup_kinect(int index, int res, int fmt, int is_depth) return 0; } +static int setup_kinect(int index, int fmt, int is_depth) { + return setup_kinect_with_res(index, FREENECT_RESOLUTION_MEDIUM, fmt, is_depth); +} + static int sync_get(void **data, uint32_t *timestamp, buffer_ring_t *buf) { pthread_mutex_lock(&buf->lock); @@ -345,7 +359,7 @@ static int runloop_enter(int index) return -1; } if (!thread_running || !kinects[index]) - if (setup_kinect(index, FREENECT_RESOLUTION_MEDIUM, FREENECT_DEPTH_11BIT, 1)) + if (setup_kinect_with_res(index, FREENECT_RESOLUTION_MEDIUM, FREENECT_DEPTH_11BIT, 1)) return -1; pending_runloop_tasks_inc(); @@ -359,7 +373,7 @@ static void runloop_exit() pending_runloop_tasks_dec(); } -int freenect_sync_get_video(void **video, uint32_t *timestamp, int index, +int freenect_sync_get_video_with_res(void **video, uint32_t *timestamp, int index, freenect_resolution res, freenect_video_format fmt) { if (index < 0 || index >= MAX_KINECTS) { @@ -368,13 +382,18 @@ int freenect_sync_get_video(void **video, uint32_t *timestamp, int index, } if (!thread_running || !kinects[index] || kinects[index]->video.fmt != fmt || kinects[index]->video.res != res) - if (setup_kinect(index, res, fmt, 0)) + if (setup_kinect_with_res(index, res, fmt, 0)) return -1; sync_get(video, timestamp, &kinects[index]->video); return 0; } -int freenect_sync_get_depth(void **depth, uint32_t *timestamp, int index, +int freenect_sync_get_video(void **video, uint32_t *timestamp, int index, freenect_video_format fmt) +{ + return freenect_sync_get_video_with_res(video, timestamp, index, FREENECT_RESOLUTION_MEDIUM, fmt); +} + +int freenect_sync_get_depth_with_res(void **depth, uint32_t *timestamp, int index, freenect_resolution res, freenect_depth_format fmt) { if (index < 0 || index >= MAX_KINECTS) { @@ -383,12 +402,17 @@ int freenect_sync_get_depth(void **depth, uint32_t *timestamp, int index, } if (!thread_running || !kinects[index] || kinects[index]->depth.fmt != fmt || kinects[index]->depth.res != res) - if (setup_kinect(index, res, fmt, 1)) + if (setup_kinect_with_res(index, res, fmt, 1)) return -1; sync_get(depth, timestamp, &kinects[index]->depth); return 0; } +int freenect_sync_get_depth(void **depth, uint32_t *timestamp, int index, freenect_depth_format fmt) +{ + return freenect_sync_get_depth_with_res(depth, timestamp, index, FREENECT_RESOLUTION_MEDIUM, fmt); +} + int freenect_sync_get_tilt_state(freenect_raw_tilt_state **state, int index) { if (runloop_enter(index)) return -1; diff --git a/wrappers/c_sync/libfreenect_sync.h b/wrappers/c_sync/libfreenect_sync.h index 64214265..ef2680e0 100644 --- a/wrappers/c_sync/libfreenect_sync.h +++ b/wrappers/c_sync/libfreenect_sync.h @@ -33,7 +33,7 @@ extern "C" { #endif -int freenect_sync_get_video(void **video, uint32_t *timestamp, int index, +int freenect_sync_get_video_with_res(void **video, uint32_t *timestamp, int index, freenect_resolution res, freenect_video_format fmt); /* Synchronous video function, starts the runloop if it isn't running @@ -44,13 +44,20 @@ int freenect_sync_get_video(void **video, uint32_t *timestamp, int index, video: Populated with a pointer to a video buffer with a size of the requested type timestamp: Populated with the associated timestamp index: Device index (0 is the first) + res: Valid resolution fmt: Valid format Returns: Nonzero on error. */ -int freenect_sync_get_depth(void **depth, uint32_t *timestamp, int index, +int freenect_sync_get_video(void **video, uint32_t *timestamp, int index, freenect_video_format fmt); +/* Does the exact same as above, but with a default resolution, + so backwards compatibilty is maintained. + The Resolution is kept at the default FREENECT_RESOLUTION_MEDIUM +*/ + +int freenect_sync_get_depth_with_res(void **depth, uint32_t *timestamp, int index, freenect_resolution res, freenect_depth_format fmt); /* Synchronous depth function, starts the runloop if it isn't running @@ -61,12 +68,19 @@ int freenect_sync_get_depth(void **depth, uint32_t *timestamp, int index, depth: Populated with a pointer to a depth buffer with a size of the requested type timestamp: Populated with the associated timestamp index: Device index (0 is the first) + res: Valid resolution fmt: Valid format Returns: Nonzero on error. */ +int freenect_sync_get_depth(void **depth, uint32_t *timestamp, int index, freenect_depth_format fmt); +/* Again, a wrapper function to keep backward compatibility. + The Resolution is kept at the default FREENECT_RESOLUTION_MEDIUM + +*/ + int freenect_sync_set_tilt_degs(int angle, int index); /* Tilt function, starts the runloop if it isn't running From 6ab505fcd85f2bba3f2fd0428b8f8661cf2770bb Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Tue, 30 Jul 2013 23:13:20 -0400 Subject: [PATCH 10/84] Added Gentoo Linux ebuilds Signed-off-by: Benn Snyder --- .../portage/dev-libs/libfreenect/Manifest | 2 + .../libfreenect/libfreenect-0.2.0.ebuild | 77 +++++++++++++++++++ .../libfreenect/libfreenect-9999.ebuild | 76 ++++++++++++++++++ 3 files changed, 155 insertions(+) create mode 100644 platform/linux/portage/dev-libs/libfreenect/Manifest create mode 100644 platform/linux/portage/dev-libs/libfreenect/libfreenect-0.2.0.ebuild create mode 100644 platform/linux/portage/dev-libs/libfreenect/libfreenect-9999.ebuild diff --git a/platform/linux/portage/dev-libs/libfreenect/Manifest b/platform/linux/portage/dev-libs/libfreenect/Manifest new file mode 100644 index 00000000..ca654cf4 --- /dev/null +++ b/platform/linux/portage/dev-libs/libfreenect/Manifest @@ -0,0 +1,2 @@ +EBUILD libfreenect-0.2.0.ebuild 1929 SHA256 7f9636faccdb3b4c15abb7c318e2a50b8819f501fdee8d86050d06611743af94 SHA512 bc2705628b0e99fe8cac00950f7cc89509b4db62988e37a2124e3afa5777b4b5fc9e6424453b770ae6c00101cf08e2378b2301a2b9e10dac64a4389827a1c52e WHIRLPOOL c10b7ca722806a5ac566df071dab529c22bffbf34f5ad8f3a13d530585f7833fff93c5bfa02dbe605f4087bd353c2f6597cc412746429a0fb4c237108b2f809f +EBUILD libfreenect-9999.ebuild 1897 SHA256 dd1d9696332c6e1ac6d88fb7dd5b221d491d0b44931f6d0f13df8d8387735d77 SHA512 5551562cf5624ad1b83e3d9dbc114fd2a8e98d5f976beda30fab03366ad66a8ea0146dcaa1ebceec489fa9b89fc6f3fed2bd16c97d48352e70f2d6497d9f8d9c WHIRLPOOL 90bb889cd533a2ffddda04cc9b6262dfa634d1d8ae7706245c6372876b51d23914adb44c26106b34d907327672c5e46118126c4aa8b0a17546bc2400347fc4c1 diff --git a/platform/linux/portage/dev-libs/libfreenect/libfreenect-0.2.0.ebuild b/platform/linux/portage/dev-libs/libfreenect/libfreenect-0.2.0.ebuild new file mode 100644 index 00000000..68c4fc84 --- /dev/null +++ b/platform/linux/portage/dev-libs/libfreenect/libfreenect-0.2.0.ebuild @@ -0,0 +1,77 @@ +# Copyright 1999-2013 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + +EAPI="5" + +inherit cmake-utils git-2 multilib + + +DESCRIPTION="Core library for accessing the Microsoft Kinect." +HOMEPAGE="https://github.com/OpenKinect/${PN}" +EGIT_REPO_URI="git://github.com/OpenKinect/${PN}.git" +EGIT_COMMIT="v0.2.0" + +LICENSE="Apache-2.0 GPL-2" +SLOT="0" +KEYWORDS="~amd64 ~x86" +IUSE="bindist +c_sync +cpp doc examples fakenect opencv python" + +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 BUILD_REDIST_PACKAGE) + $(cmake-utils_use_build c_sync BUILD_C_SYNC) + $(cmake-utils_use_build cpp BUILD_CPP) + $(cmake-utils_use_build examples BUILD_EXAMPLES) + $(cmake-utils_use_build fakenect BUILD_FAKENECT) + $(cmake-utils_use_build opencv BUILD_CV) + $(cmake-utils_use_build python BUILD_PYTHON) + ) + cmake-utils_src_configure +} + +src_install() { + cmake-utils_src_install + # Rename record example so it does not collide with xawtv + if use examples; then + mv "${D}"/usr/bin/record "${D}"/usr/bin/frecord || die + fi + + # udev rules + insinto /lib/udev/rules.d/ + doins "${S}"/platform/linux/udev/51-kinect.rules + + # documentation + dodoc HACKING README.asciidoc + 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 "You have enabled audio via the bindist USE flag. 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/platform/linux/portage/dev-libs/libfreenect/libfreenect-9999.ebuild b/platform/linux/portage/dev-libs/libfreenect/libfreenect-9999.ebuild new file mode 100644 index 00000000..11dce607 --- /dev/null +++ b/platform/linux/portage/dev-libs/libfreenect/libfreenect-9999.ebuild @@ -0,0 +1,76 @@ +# Copyright 1999-2013 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + +EAPI="5" + +inherit cmake-utils git-2 multilib + + +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 python" + +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 BUILD_REDIST_PACKAGE) + $(cmake-utils_use_build c_sync BUILD_C_SYNC) + $(cmake-utils_use_build cpp BUILD_CPP) + $(cmake-utils_use_build examples BUILD_EXAMPLES) + $(cmake-utils_use_build fakenect BUILD_FAKENECT) + $(cmake-utils_use_build opencv BUILD_CV) + $(cmake-utils_use_build python BUILD_PYTHON) + ) + cmake-utils_src_configure +} + +src_install() { + cmake-utils_src_install + # Rename record example so it does not collide with xawtv + if use examples; then + mv "${D}"/usr/bin/record "${D}"/usr/bin/frecord || die + fi + + # udev rules + insinto /lib/udev/rules.d/ + doins "${S}"/platform/linux/udev/51-kinect.rules + + # documentation + dodoc HACKING README.asciidoc + 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 "You have enabled audio via the bindist USE flag. 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." +} From b5c9a1ce392329cc842fb1a1e99027eec7101ed2 Mon Sep 17 00:00:00 2001 From: Robert Xiao Date: Sun, 15 Sep 2013 12:18:01 -0400 Subject: [PATCH 11/84] Make freenect_flags an actual flag enum Signed-off-by: Robert Xiao --- include/libfreenect.h | 4 ++-- src/flags.c | 20 +++++++++++++++++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/include/libfreenect.h b/include/libfreenect.h index 4aec563a..8ed84dcb 100644 --- a/include/libfreenect.h +++ b/include/libfreenect.h @@ -113,8 +113,8 @@ typedef enum { FREENECT_AUTO_WHITE_BALANCE = 1 << 1, FREENECT_RAW_COLOR = 1 << 4, // registers to be written with 0 or 1 - FREENECT_MIRROR_DEPTH = 0x0017, - FREENECT_MIRROR_VIDEO = 0x0047, + FREENECT_MIRROR_DEPTH = 1 << 16, + FREENECT_MIRROR_VIDEO = 1 << 17, } freenect_flag; /// Possible values for setting each `freenect_flag` diff --git a/src/flags.c b/src/flags.c index 85c6d0e0..fcee3e11 100644 --- a/src/flags.c +++ b/src/flags.c @@ -32,12 +32,26 @@ // freenect_set_flag is the only function exposed in libfreenect.h // The rest are available internally via #include flags.h +static int register_for_flag(int flag) { + switch(flag) { + case FREENECT_MIRROR_DEPTH: + return 0x17; + case FREENECT_MIRROR_VIDEO: + return 0x47; + default: + return -1; + } +} int freenect_set_flag(freenect_device *dev, freenect_flag flag, freenect_flag_value value) { - if (flag == FREENECT_MIRROR_DEPTH || flag == FREENECT_MIRROR_VIDEO) - return write_register(dev, flag, value); - + if (flag >= (1<<16)) { + int reg = register_for_flag(flag); + if(reg < 0) + return -1; + return write_register(dev, reg, value); + } + uint16_t reg = read_cmos_register(dev, 0x0106); if (reg < 0) return reg; From a8f7a4de51dd5b71a1090893cbd0992e747784e2 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Fri, 1 Nov 2013 16:35:41 -0400 Subject: [PATCH 12/84] Fix include of libusb.h in wrappers/cpp/libfreenect.hpp Otherwise fails to build on systems with libusb.h provided outside of versioned directory, e.g. on kFreeBSD. This "bug" was introduced after initial changes of similar kind in e.g. 713c715 and 8219750 Signed-off-by: Yaroslav Halchenko --- wrappers/cpp/libfreenect.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wrappers/cpp/libfreenect.hpp b/wrappers/cpp/libfreenect.hpp index d24dfeda..675e39b1 100644 --- a/wrappers/cpp/libfreenect.hpp +++ b/wrappers/cpp/libfreenect.hpp @@ -31,7 +31,7 @@ #include #include #include -#include +#include namespace Freenect { class Noncopyable { From e2446a28a6263e546457a74e4c0fb6b35f133aa7 Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Sat, 16 Nov 2013 00:33:26 -0500 Subject: [PATCH 13/84] Tweaks to freenect_flag commit Signed-off-by: Benn Snyder --- include/libfreenect.h | 2 +- src/flags.c | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/libfreenect.h b/include/libfreenect.h index 8ed84dcb..fd19a128 100644 --- a/include/libfreenect.h +++ b/include/libfreenect.h @@ -112,7 +112,7 @@ typedef enum { FREENECT_AUTO_EXPOSURE = 1 << 14, FREENECT_AUTO_WHITE_BALANCE = 1 << 1, FREENECT_RAW_COLOR = 1 << 4, - // registers to be written with 0 or 1 + // arbitrary bitfields to support flag combination FREENECT_MIRROR_DEPTH = 1 << 16, FREENECT_MIRROR_VIDEO = 1 << 17, } freenect_flag; diff --git a/src/flags.c b/src/flags.c index fcee3e11..169c771a 100644 --- a/src/flags.c +++ b/src/flags.c @@ -32,23 +32,23 @@ // freenect_set_flag is the only function exposed in libfreenect.h // The rest are available internally via #include flags.h -static int register_for_flag(int flag) { +FN_INTERNAL static int register_for_flag(int flag) { switch(flag) { - case FREENECT_MIRROR_DEPTH: - return 0x17; - case FREENECT_MIRROR_VIDEO: - return 0x47; - default: - return -1; + case FREENECT_MIRROR_DEPTH: + return 0x17; + case FREENECT_MIRROR_VIDEO: + return 0x47; + default: + return -1; } } int freenect_set_flag(freenect_device *dev, freenect_flag flag, freenect_flag_value value) { - if (flag >= (1<<16)) { + if (flag >= (1 << 16)) { int reg = register_for_flag(flag); - if(reg < 0) - return -1; + if (reg < 0) + return reg; return write_register(dev, reg, value); } From 90eea5a9f3571e9d164ef87ce5f621aaa8ccec87 Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Sat, 16 Nov 2013 00:40:09 -0500 Subject: [PATCH 14/84] csharp: Update Enumerations.cs - fixes #285 Signed-off-by: Benn Snyder --- wrappers/csharp/src/lib/Enumerations.cs | 50 +++++++++++++------------ 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/wrappers/csharp/src/lib/Enumerations.cs b/wrappers/csharp/src/lib/Enumerations.cs index 4079284d..9f82bea3 100644 --- a/wrappers/csharp/src/lib/Enumerations.cs +++ b/wrappers/csharp/src/lib/Enumerations.cs @@ -37,13 +37,13 @@ namespace freenect /// public enum VideoFormat : int { - RGB = 0, - Bayer = 1, - Infrared8Bit = 2, - Infrared10Bit = 3, + RGB = 0, + Bayer = 1, + Infrared8Bit = 2, + Infrared10Bit = 3, InfraredPacked10Bit = 4, - YUVRGB = 5, - YUVRaw = 6 + YUVRGB = 5, + YUVRaw = 6 } /// @@ -51,10 +51,12 @@ public enum VideoFormat : int /// public enum DepthFormat : int { - Depth11Bit = 0, - Depth10Bit = 1, - DepthPacked11Bit = 2, - DepthPacked10Bit = 3 + Depth11Bit = 0, + Depth10Bit = 1, + DepthPacked11Bit = 2, + DepthPacked10Bit = 3, + DepthRegistered = 4, + DepthMM = 5 } /// @@ -66,9 +68,9 @@ public enum DepthFormat : int /// public enum Resolution : int { - Low = 0, - Medium = 1, - High = 2 + Low = 0, + Medium = 1, + High = 2 } /// @@ -76,13 +78,13 @@ public enum Resolution : int /// public enum LEDColor : int { - None = 0, - Green = 1, - Red = 2, - Yellow = 3, - BlinkYellow = 4, - BlinkGreen = 5, - BlinkRedYellow = 6 + None = 0, + Green = 1, + Red = 2, + Yellow = 3, + BlinkYellow = 4, + BlinkGreen = 5, + BlinkRedYellow = 6 } /// @@ -90,9 +92,9 @@ public enum LEDColor : int /// public enum MotorTiltStatus : int { - Stopped = 0x00, - AtLimit = 0x01, - Moving = 0x04 + Stopped = 0x00, + AtLimit = 0x01, + Moving = 0x04 } /// @@ -109,4 +111,4 @@ public enum LoggingLevel : int Spew, Flood, } -} \ No newline at end of file +} From 0d7575085db6e7a20cc1d31b8b5850f5a8fa3e65 Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Sat, 16 Nov 2013 00:55:37 -0500 Subject: [PATCH 15/84] fakenect: Fix memory leaks - fixes #205 Signed-off-by: Benn Snyder --- fakenect/fakenect.c | 5 +++-- fakenect/record.c | 13 +++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/fakenect/fakenect.c b/fakenect/fakenect.c index 3f8e34b6..3f704fa9 100644 --- a/fakenect/fakenect.c +++ b/fakenect/fakenect.c @@ -138,17 +138,18 @@ static int parse_line(char *type, double *cur_time, unsigned int *timestamp, uns exit(1); } // Parse data from file name + int ret = 0; *data_size = get_data_size(cur_fp); sscanf(line, "%c-%lf-%u-%*s", type, cur_time, timestamp); *data = malloc(*data_size); if (fread(*data, *data_size, 1, cur_fp) != 1) { printf("Error: Couldn't read entire file.\n"); - return -1; + ret = -1; } fclose(cur_fp); free(line); free(file_path); - return 0; + return ret; } static void open_index() diff --git a/fakenect/record.c b/fakenect/record.c index 9546995f..5bbd8f33 100644 --- a/fakenect/record.c +++ b/fakenect/record.c @@ -303,9 +303,10 @@ int main(int argc, char **argv) char *index_fn = malloc(strlen(out_dir) + 50); sprintf(index_fn, "%s-index.txt", out_dir); - index_fp = open_index(index_fn); - if (!index_fp) return 1; + index_fp = open_index(index_fn); free(index_fn); + if (!index_fp) + return 1; depth_name = malloc(strlen(out_dir) + 50); rgb_name = malloc(strlen(out_dir) + 50); @@ -340,9 +341,13 @@ int main(int argc, char **argv) #endif char *fn = malloc(strlen(out_dir) + 50); sprintf(fn, "%s/INDEX.txt", out_dir); - index_fp = open_index(fn); - if (!index_fp) return 1; + index_fp = open_index(fn); free(fn); + if (!index_fp) { + fclose(index_fp) + return 1; + } + init(); fclose(index_fp); } From 15deb1da24d4cf47fff3c035ef9d4f50d9dcfd7d Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Sat, 18 Jan 2014 12:23:56 -0500 Subject: [PATCH 16/84] OpenNI2-FreenectDriver: initial commit Signed-off-by: Benn Snyder --- CMakeLists.txt | 5 + OpenNI2-FreenectDriver/CMakeLists.txt | 22 + OpenNI2-FreenectDriver/README.md | 46 + .../Android-Arm/OniPlatformAndroid-Arm.h | 43 + .../Include/Driver/OniDriverAPI.h | 378 +++ .../Include/Driver/OniDriverTypes.h | 54 + .../Include/Linux-Arm/OniPlatformLinux-Arm.h | 36 + .../Include/Linux-x86/OniPlatformLinux-x86.h | 102 + .../Include/MacOSX/OniPlatformMacOSX.h | 42 + .../Include/OniCAPI.h | 259 ++ .../Include/OniCEnums.h | 84 + .../Include/OniCProperties.h | 68 + .../Include/OniCTypes.h | 193 ++ .../Include/OniEnums.h | 86 + .../Include/OniPlatform.h | 72 + .../Include/OniProperties.h | 73 + .../Include/OniVersion.h | 43 + .../Include/OpenNI.h | 2750 +++++++++++++++++ .../Include/PS1080.h | 632 ++++ .../Include/PSLink.h | 199 ++ .../Include/PrimeSense.h | 229 ++ .../Include/Win32/OniPlatformWin32.h | 139 + OpenNI2-FreenectDriver/src/ColorStream.cpp | 90 + OpenNI2-FreenectDriver/src/ColorStream.hpp | 70 + OpenNI2-FreenectDriver/src/D2S.h | 1003 ++++++ OpenNI2-FreenectDriver/src/DepthStream.cpp | 131 + OpenNI2-FreenectDriver/src/DepthStream.hpp | 190 ++ OpenNI2-FreenectDriver/src/DeviceDriver.cpp | 293 ++ OpenNI2-FreenectDriver/src/S2D.h | 207 ++ OpenNI2-FreenectDriver/src/VideoStream.hpp | 219 ++ wrappers/cpp/libfreenect.hpp | 9 +- 31 files changed, 7764 insertions(+), 3 deletions(-) create mode 100644 OpenNI2-FreenectDriver/CMakeLists.txt create mode 100644 OpenNI2-FreenectDriver/README.md create mode 100644 OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Android-Arm/OniPlatformAndroid-Arm.h create mode 100644 OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Driver/OniDriverAPI.h create mode 100644 OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Driver/OniDriverTypes.h create mode 100644 OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Linux-Arm/OniPlatformLinux-Arm.h create mode 100644 OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Linux-x86/OniPlatformLinux-x86.h create mode 100644 OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/MacOSX/OniPlatformMacOSX.h create mode 100644 OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCAPI.h create mode 100644 OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCEnums.h create mode 100644 OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCProperties.h create mode 100644 OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCTypes.h create mode 100644 OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniEnums.h create mode 100644 OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniPlatform.h create mode 100644 OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniProperties.h create mode 100644 OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniVersion.h create mode 100644 OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OpenNI.h create mode 100644 OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PS1080.h create mode 100644 OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PSLink.h create mode 100644 OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PrimeSense.h create mode 100644 OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Win32/OniPlatformWin32.h create mode 100644 OpenNI2-FreenectDriver/src/ColorStream.cpp create mode 100644 OpenNI2-FreenectDriver/src/ColorStream.hpp create mode 100644 OpenNI2-FreenectDriver/src/D2S.h create mode 100644 OpenNI2-FreenectDriver/src/DepthStream.cpp create mode 100644 OpenNI2-FreenectDriver/src/DepthStream.hpp create mode 100644 OpenNI2-FreenectDriver/src/DeviceDriver.cpp create mode 100644 OpenNI2-FreenectDriver/src/S2D.h create mode 100644 OpenNI2-FreenectDriver/src/VideoStream.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 272a410f..5ea2cb26 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,6 +57,7 @@ OPTION(BUILD_CPP "Build C++ Library (currently header only)" ON) OPTION(BUILD_CV "Build OpenCV wrapper" OFF) OPTION(BUILD_AS3_SERVER "Build the Actionscript 3 Server Example" OFF) OPTION(BUILD_PYTHON "Build Python extension" OFF) +OPTION(BUILD_OPENNI2_DRIVER "Build libfreenect driver for OpenNI2" ON) IF(PROJECT_OS_LINUX) OPTION(BUILD_CPACK "Build an RPM or DEB using CPack" OFF) ENDIF(PROJECT_OS_LINUX) @@ -153,6 +154,10 @@ IF(BUILD_PYTHON) add_subdirectory (wrappers/python) ENDIF() +IF(BUILD_OPENNI2_DRIVER) + add_subdirectory(OpenNI2-FreenectDriver) +ENDIF() + ###################################################################################### # Extras ###################################################################################### diff --git a/OpenNI2-FreenectDriver/CMakeLists.txt b/OpenNI2-FreenectDriver/CMakeLists.txt new file mode 100644 index 00000000..d90e8e95 --- /dev/null +++ b/OpenNI2-FreenectDriver/CMakeLists.txt @@ -0,0 +1,22 @@ +###################################################################################### +# OpenNI2-FreenectDriver +###################################################################################### + +file(GLOB SOURCES src/*.cpp) +add_library(FreenectDriver SHARED ${SOURCES}) + +set(CMAKE_CXX_FLAGS "-w") # todo + +set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib/OpenNI2-FreenectDriver) +set_target_properties( FreenectDriver PROPERTIES + VERSION ${PROJECT_VER} + SOVERSION ${PROJECT_APIVER} + OUTPUT_NAME FreenectDriver) + +include_directories(extern/OpenNI-Linux-x64-2.2.0.33/Include) +include_directories(${PROJECT_SOURCE_DIR}/wrappers/cpp) + +target_link_libraries(FreenectDriver freenectstatic ${MATH_LIB}) + +install (TARGETS FreenectDriver + DESTINATION "${PROJECT_LIBRARY_INSTALL_DIR}/OpenNI2-FreenectDriver") diff --git a/OpenNI2-FreenectDriver/README.md b/OpenNI2-FreenectDriver/README.md new file mode 100644 index 00000000..8d6f72d1 --- /dev/null +++ b/OpenNI2-FreenectDriver/README.md @@ -0,0 +1,46 @@ +OpenNI2-FreenectDriver +====================== + +OpenNI2-FreenectDriver is a bridge to libfreenect implemented as an OpenNI2 driver. +It allows OpenNI2 to use Kinect hardware on Linux and OSX. +It was originally a [separate project](https://github.com/piedar/OpenNI2-FreenectDriver) but is now distributed with libfreenect. +OpenNI2-FreenectDriver is distributed under the Apache 2 license. + +Install +------- +1. Download and unpack [OpenNI](http://www.openni.org/openni-sdk/) 2.2.0.33 or higher. +2. Build libfreenect with the OpenNI2 driver. + + mkdir build && cd build + cmake .. -DBUILD_OPENNI2_DRIVER=ON + make + +3. Copy the driver to your OpenNI2 driver repository. + + Repository="/example/path/to/Samples/Bin/OpenNI2/Drivers/" + cp -L lib/OpenNI2-FreenectDriver/libFreenectDriver.{so,dylib} ${Repository} + +OpenNI2-FreenectDriver is built with a static libfreenect, so you do not need to include libfreenect when deploying. +However, you will need to make sure target systems have libusb and all other libfreenect dependencies. + +__________________________________________________ + +Structure +--------- +This driver is modeled on TestDevice.cpp and Drivers/Kinect/. In the FreenectDriver namespace, it ties together the C++ interfaces of OpenNI2 and libfreenect using multiple inheritance. + +Driver inherits publically from oni::driver::DriverBase and privately from Freenect::Freenect. A custom libfreenect.hpp allows protected access to the Freenect context, so that FreenectDriver can call the Freenect's C API. As a DriverBase, FreenectDriver manages devices and sets up device state callbacks. + +Device inherits publically from oni::driver::DeviceBase and Freenect::FreenectDevice. Because of this, it can be built by Freenect::Freenect::createDevice() and it can define Device's depth and video callbacks. Those callbacks trigger acquireFrame() in FreenectStream. + +VideoStream is a virtual base class inheriting from oni::driver::StreamBase. It does generic frame setup in buildFrame() and then calls pure virtual populateFrame() to let derived classes finish the frame. It also provides the base skeleton for setting and getting properties, which cascades down the inheritance tree. + +DepthStream and ColorStream are nearly identical in definition and implementation, both inheriting from VideoStream. They differ mostly in the formats they use to process data and the video modes they support. These two classes offer a system to store and report supported video modes. To implement a new mode, simply add it to getSupportedVideoModes() and modify populateFrame() if necessary. + +__________________________________________________ + +Todo +---- +* support more FREENECT_RESOLUTION_\*, FREENECT_VIDEO_\*, and FREENECT_DEPTH_\* +* provide more OniVideoMode and OniStreamProperty +* implement remaining derived functions diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Android-Arm/OniPlatformAndroid-Arm.h b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Android-Arm/OniPlatformAndroid-Arm.h new file mode 100644 index 00000000..1a3bca12 --- /dev/null +++ b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Android-Arm/OniPlatformAndroid-Arm.h @@ -0,0 +1,43 @@ +/***************************************************************************** +* * +* OpenNI 2.x Alpha * +* Copyright (C) 2012 PrimeSense Ltd. * +* * +* This file is part of OpenNI. * +* * +* Licensed under the Apache License, Version 2.0 (the "License"); * +* you may not use this file except in compliance with the License. * +* You may obtain a copy of the License at * +* * +* http://www.apache.org/licenses/LICENSE-2.0 * +* * +* Unless required by applicable law or agreed to in writing, software * +* distributed under the License is distributed on an "AS IS" BASIS, * +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * +* See the License for the specific language governing permissions and * +* limitations under the License. * +* * +*****************************************************************************/ +#ifndef _ONI_PLATFORM_ANDROID_ARM_H_ +#define _ONI_PLATFORM_ANDROID_ARM_H_ + +// Start with Linux-x86, and override what's different +#include "../Linux-x86/OniPlatformLinux-x86.h" + +//--------------------------------------------------------------------------- +// Platform Basic Definition +//--------------------------------------------------------------------------- +#undef ONI_PLATFORM +#undef ONI_PLATFORM_STRING + +#define ONI_PLATFORM ONI_PLATFORM_ANDROID_ARM +#define ONI_PLATFORM_STRING "Android-Arm" + +#ifdef HAVE_ANDROID_OS + #define ONI_PLATFORM_ANDROID_OS + + #undef ONI_PLATFORM_STRING + #define ONI_PLATFORM_STRING "AndroidOS-Arm" +#endif + +#endif //_ONI_PLATFORM_LINUX_ARM_H_ diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Driver/OniDriverAPI.h b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Driver/OniDriverAPI.h new file mode 100644 index 00000000..c41e1f66 --- /dev/null +++ b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Driver/OniDriverAPI.h @@ -0,0 +1,378 @@ +/***************************************************************************** +* * +* OpenNI 2.x Alpha * +* Copyright (C) 2012 PrimeSense Ltd. * +* * +* This file is part of OpenNI. * +* * +* Licensed under the Apache License, Version 2.0 (the "License"); * +* you may not use this file except in compliance with the License. * +* You may obtain a copy of the License at * +* * +* http://www.apache.org/licenses/LICENSE-2.0 * +* * +* Unless required by applicable law or agreed to in writing, software * +* distributed under the License is distributed on an "AS IS" BASIS, * +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * +* See the License for the specific language governing permissions and * +* limitations under the License. * +* * +*****************************************************************************/ +#ifndef _ONI_DRIVER_API_H_ +#define _ONI_DRIVER_API_H_ + +#include "OniPlatform.h" +#include "OniCTypes.h" +#include "OniCProperties.h" +#include "OniDriverTypes.h" +#include + +namespace oni { namespace driver { + +class DeviceBase; +class StreamBase; + +typedef void (ONI_CALLBACK_TYPE* DeviceConnectedCallback)(const OniDeviceInfo*, void* pCookie); +typedef void (ONI_CALLBACK_TYPE* DeviceDisconnectedCallback)(const OniDeviceInfo*, void* pCookie); +typedef void (ONI_CALLBACK_TYPE* DeviceStateChangedCallback)(const OniDeviceInfo* deviceId, int errorState, void* pCookie); +typedef void (ONI_CALLBACK_TYPE* NewFrameCallback)(StreamBase* streamId, OniFrame*, void* pCookie); +typedef void (ONI_CALLBACK_TYPE* PropertyChangedCallback)(void* sender, int propertyId, const void* data, int dataSize, void* pCookie); + +class StreamServices : public OniStreamServices +{ +public: + int getDefaultRequiredFrameSize() + { + return OniStreamServices::getDefaultRequiredFrameSize(streamServices); + } + + OniFrame* acquireFrame() + { + return OniStreamServices::acquireFrame(streamServices); + } + + void addFrameRef(OniFrame* pFrame) + { + OniStreamServices::addFrameRef(streamServices, pFrame); + } + + void releaseFrame(OniFrame* pFrame) + { + OniStreamServices::releaseFrame(streamServices, pFrame); + } +}; + +class StreamBase +{ +public: + StreamBase() : m_newFrameCallback(NULL), m_propertyChangedCallback(NULL) {} + virtual ~StreamBase() {} + + virtual void setServices(StreamServices* pStreamServices) { m_pServices = pStreamServices; } + + virtual OniStatus setProperty(int /*propertyId*/, const void* /*data*/, int /*dataSize*/) {return ONI_STATUS_NOT_IMPLEMENTED;} + virtual OniStatus getProperty(int /*propertyId*/, void* /*data*/, int* /*pDataSize*/) {return ONI_STATUS_NOT_IMPLEMENTED;} + virtual OniBool isPropertySupported(int /*propertyId*/) {return FALSE;} + virtual OniStatus invoke(int /*commandId*/, void* /*data*/, int /*dataSize*/) {return ONI_STATUS_NOT_IMPLEMENTED;} + virtual OniBool isCommandSupported(int /*commandId*/) {return FALSE;} + + virtual int getRequiredFrameSize() { return getServices().getDefaultRequiredFrameSize(); } + + virtual OniStatus start() = 0; + virtual void stop() = 0; + + virtual void setNewFrameCallback(NewFrameCallback handler, void* pCookie) { m_newFrameCallback = handler; m_newFrameCallbackCookie = pCookie; } + virtual void setPropertyChangedCallback(PropertyChangedCallback handler, void* pCookie) { m_propertyChangedCallback = handler; m_propertyChangedCookie = pCookie; } + + virtual void notifyAllProperties() { return; } + + virtual OniStatus convertDepthToColorCoordinates(StreamBase* /*colorStream*/, int /*depthX*/, int /*depthY*/, OniDepthPixel /*depthZ*/, int* /*pColorX*/, int* /*pColorY*/) { return ONI_STATUS_NOT_SUPPORTED; } + +protected: + void raiseNewFrame(OniFrame* pFrame) { (*m_newFrameCallback)(this, pFrame, m_newFrameCallbackCookie); } + void raisePropertyChanged(int propertyId, const void* data, int dataSize) { (*m_propertyChangedCallback)(this, propertyId, data, dataSize, m_propertyChangedCookie); } + + StreamServices& getServices() { return *m_pServices; } + +private: + StreamServices* m_pServices; + NewFrameCallback m_newFrameCallback; + void* m_newFrameCallbackCookie; + PropertyChangedCallback m_propertyChangedCallback; + void* m_propertyChangedCookie; +}; + +class DeviceBase +{ +public: + DeviceBase() {} + virtual ~DeviceBase() {} + + virtual OniStatus getSensorInfoList(OniSensorInfo** pSensorInfos, int* numSensors) = 0; + + virtual StreamBase* createStream(OniSensorType) = 0; + virtual void destroyStream(StreamBase* pStream) = 0; + + virtual OniStatus setProperty(int /*propertyId*/, const void* /*data*/, int /*dataSize*/) {return ONI_STATUS_NOT_IMPLEMENTED;} + virtual OniStatus getProperty(int /*propertyId*/, void* /*data*/, int* /*pDataSize*/) {return ONI_STATUS_NOT_IMPLEMENTED;} + virtual OniBool isPropertySupported(int /*propertyId*/) {return FALSE;} + virtual OniStatus invoke(int /*commandId*/, void* /*data*/, int /*dataSize*/) {return ONI_STATUS_NOT_IMPLEMENTED;} + virtual OniBool isCommandSupported(int /*commandId*/) {return FALSE;} + virtual OniStatus tryManualTrigger() {return ONI_STATUS_OK;} + + virtual void setPropertyChangedCallback(PropertyChangedCallback handler, void* pCookie) { m_propertyChangedCallback = handler; m_propertyChangedCookie = pCookie; } + virtual void notifyAllProperties() { return; } + + virtual OniBool isImageRegistrationModeSupported(OniImageRegistrationMode mode) { return (mode == ONI_IMAGE_REGISTRATION_OFF); } + +protected: + void raisePropertyChanged(int propertyId, const void* data, int dataSize) { (*m_propertyChangedCallback)(this, propertyId, data, dataSize, m_propertyChangedCookie); } + +private: + PropertyChangedCallback m_propertyChangedCallback; + void* m_propertyChangedCookie; +}; + +class DriverServices +{ +public: + DriverServices(OniDriverServices* pDriverServices) : m_pDriverServices(pDriverServices) {} + + void errorLoggerAppend(const char* format, ...) + { + va_list args; + va_start(args, format); + m_pDriverServices->errorLoggerAppend(m_pDriverServices->driverServices, format, args); + va_end(args); + } + + void errorLoggerClear() + { + m_pDriverServices->errorLoggerClear(m_pDriverServices->driverServices); + } + + void log(int severity, const char* file, int line, const char* mask, const char* message) + { + m_pDriverServices->log(m_pDriverServices->driverServices, severity, file, line, mask, message); + } + +private: + OniDriverServices* m_pDriverServices; +}; + +class DriverBase +{ +public: + DriverBase(OniDriverServices* pDriverServices) : m_services(pDriverServices) + {} + + virtual ~DriverBase() {} + + virtual OniStatus initialize(DeviceConnectedCallback connectedCallback, DeviceDisconnectedCallback disconnectedCallback, DeviceStateChangedCallback deviceStateChangedCallback, void* pCookie) + { + m_deviceConnectedEvent = connectedCallback; + m_deviceDisconnectedEvent = disconnectedCallback; + m_deviceStateChangedEvent = deviceStateChangedCallback; + m_pCookie = pCookie; + return ONI_STATUS_OK; + } + + virtual DeviceBase* deviceOpen(const char* uri, const char* mode) = 0; + virtual void deviceClose(DeviceBase* pDevice) = 0; + + virtual void shutdown() = 0; + + virtual OniStatus tryDevice(const char* /*uri*/) { return ONI_STATUS_ERROR;} + + virtual void* enableFrameSync(StreamBase** /*pStreams*/, int /*streamCount*/) { return NULL; } + virtual void disableFrameSync(void* /*frameSyncGroup*/) {} + +protected: + void deviceConnected(const OniDeviceInfo* pInfo) { (m_deviceConnectedEvent)(pInfo, m_pCookie); } + void deviceDisconnected(const OniDeviceInfo* pInfo) { (m_deviceDisconnectedEvent)(pInfo, m_pCookie); } + void deviceStateChanged(const OniDeviceInfo* pInfo, int errorState) { (m_deviceStateChangedEvent)(pInfo, errorState, m_pCookie); } + + DriverServices& getServices() { return m_services; } + +private: + DeviceConnectedCallback m_deviceConnectedEvent; + DeviceDisconnectedCallback m_deviceDisconnectedEvent; + DeviceStateChangedCallback m_deviceStateChangedEvent; + void* m_pCookie; + + DriverServices m_services; +}; + +}} // oni::driver + +#define ONI_EXPORT_DRIVER(DriverClass) \ + \ +oni::driver::DriverBase* g_pDriver = NULL; \ + \ +/* As Driver */ \ +ONI_C_API_EXPORT void oniDriverCreate(OniDriverServices* driverServices) { \ + g_pDriver = XN_NEW(DriverClass, driverServices); \ +} \ +ONI_C_API_EXPORT void oniDriverDestroy() \ +{ \ + g_pDriver->shutdown(); \ + XN_DELETE(g_pDriver); g_pDriver = NULL; \ +} \ +ONI_C_API_EXPORT OniStatus oniDriverInitialize(oni::driver::DeviceConnectedCallback deviceConnectedCallback, \ + oni::driver::DeviceDisconnectedCallback deviceDisconnectedCallback, \ + oni::driver::DeviceStateChangedCallback deviceStateChangedCallback, \ + void* pCookie) \ +{ \ + return g_pDriver->initialize(deviceConnectedCallback, deviceDisconnectedCallback, deviceStateChangedCallback, pCookie); \ +} \ + \ +ONI_C_API_EXPORT OniStatus oniDriverTryDevice(const char* uri) \ +{ \ + return g_pDriver->tryDevice(uri); \ +} \ + \ +/* As Device */ \ +ONI_C_API_EXPORT oni::driver::DeviceBase* oniDriverDeviceOpen(const char* uri, const char* mode) \ +{ \ + return g_pDriver->deviceOpen(uri, mode); \ +} \ +ONI_C_API_EXPORT void oniDriverDeviceClose(oni::driver::DeviceBase* pDevice) \ +{ \ + g_pDriver->deviceClose(pDevice); \ +} \ + \ +ONI_C_API_EXPORT OniStatus oniDriverDeviceGetSensorInfoList(oni::driver::DeviceBase* pDevice, OniSensorInfo** pSensorInfos, \ + int* numSensors) \ +{ \ + return pDevice->getSensorInfoList(pSensorInfos, numSensors); \ +} \ + \ +ONI_C_API_EXPORT oni::driver::StreamBase* oniDriverDeviceCreateStream(oni::driver::DeviceBase* pDevice, \ + OniSensorType sensorType) \ +{ \ + return pDevice->createStream(sensorType); \ +} \ + \ +ONI_C_API_EXPORT void oniDriverDeviceDestroyStream(oni::driver::DeviceBase* pDevice, oni::driver::StreamBase* pStream) \ +{ \ + return pDevice->destroyStream(pStream); \ +} \ + \ +ONI_C_API_EXPORT OniStatus oniDriverDeviceSetProperty(oni::driver::DeviceBase* pDevice, int propertyId, \ + const void* data, int dataSize) \ +{ \ + return pDevice->setProperty(propertyId, data, dataSize); \ +} \ +ONI_C_API_EXPORT OniStatus oniDriverDeviceGetProperty(oni::driver::DeviceBase* pDevice, int propertyId, \ + void* data, int* pDataSize) \ +{ \ + return pDevice->getProperty(propertyId, data, pDataSize); \ +} \ +ONI_C_API_EXPORT OniBool oniDriverDeviceIsPropertySupported(oni::driver::DeviceBase* pDevice, int propertyId) \ +{ \ + return pDevice->isPropertySupported(propertyId); \ +} \ +ONI_C_API_EXPORT void oniDriverDeviceSetPropertyChangedCallback(oni::driver::DeviceBase* pDevice, \ + oni::driver::PropertyChangedCallback handler, void* pCookie) \ +{ \ + pDevice->setPropertyChangedCallback(handler, pCookie); \ +} \ +ONI_C_API_EXPORT void oniDriverDeviceNotifyAllProperties(oni::driver::DeviceBase* pDevice) \ +{ \ + pDevice->notifyAllProperties(); \ +} \ +ONI_C_API_EXPORT OniStatus oniDriverDeviceInvoke(oni::driver::DeviceBase* pDevice, int commandId, \ + void* data, int dataSize) \ +{ \ + return pDevice->invoke(commandId, data, dataSize); \ +} \ +ONI_C_API_EXPORT OniBool oniDriverDeviceIsCommandSupported(oni::driver::DeviceBase* pDevice, int commandId) \ +{ \ + return pDevice->isCommandSupported(commandId); \ +} \ +ONI_C_API_EXPORT OniStatus oniDriverDeviceTryManualTrigger(oni::driver::DeviceBase* pDevice) \ +{ \ + return pDevice->tryManualTrigger(); \ +} \ +ONI_C_API_EXPORT OniBool oniDriverDeviceIsImageRegistrationModeSupported(oni::driver::DeviceBase* pDevice, \ + OniImageRegistrationMode mode) \ +{ \ + return pDevice->isImageRegistrationModeSupported(mode); \ +} \ + \ +/* As Stream */ \ +ONI_C_API_EXPORT void oniDriverStreamSetServices(oni::driver::StreamBase* pStream, OniStreamServices* pServices) \ +{ \ + pStream->setServices((oni::driver::StreamServices*)pServices); \ +} \ + \ +ONI_C_API_EXPORT OniStatus oniDriverStreamSetProperty(oni::driver::StreamBase* pStream, int propertyId, \ + const void* data, int dataSize) \ +{ \ + return pStream->setProperty(propertyId, data, dataSize); \ +} \ +ONI_C_API_EXPORT OniStatus oniDriverStreamGetProperty(oni::driver::StreamBase* pStream, int propertyId, void* data, \ + int* pDataSize) \ +{ \ + return pStream->getProperty(propertyId, data, pDataSize); \ +} \ +ONI_C_API_EXPORT OniBool oniDriverStreamIsPropertySupported(oni::driver::StreamBase* pStream, int propertyId) \ +{ \ + return pStream->isPropertySupported(propertyId); \ +} \ +ONI_C_API_EXPORT void oniDriverStreamSetPropertyChangedCallback(oni::driver::StreamBase* pStream, \ + oni::driver::PropertyChangedCallback handler, void* pCookie) \ +{ \ + pStream->setPropertyChangedCallback(handler, pCookie); \ +} \ +ONI_C_API_EXPORT void oniDriverStreamNotifyAllProperties(oni::driver::StreamBase* pStream) \ +{ \ + pStream->notifyAllProperties(); \ +} \ +ONI_C_API_EXPORT OniStatus oniDriverStreamInvoke(oni::driver::StreamBase* pStream, int commandId, \ + void* data, int dataSize) \ +{ \ + return pStream->invoke(commandId, data, dataSize); \ +} \ +ONI_C_API_EXPORT OniBool oniDriverStreamIsCommandSupported(oni::driver::StreamBase* pStream, int commandId) \ +{ \ + return pStream->isCommandSupported(commandId); \ +} \ + \ +ONI_C_API_EXPORT OniStatus oniDriverStreamStart(oni::driver::StreamBase* pStream) \ +{ \ + return pStream->start(); \ +} \ +ONI_C_API_EXPORT void oniDriverStreamStop(oni::driver::StreamBase* pStream) \ +{ \ + pStream->stop(); \ +} \ + \ +ONI_C_API_EXPORT int oniDriverStreamGetRequiredFrameSize(oni::driver::StreamBase* pStream) \ +{ \ + return pStream->getRequiredFrameSize(); \ +} \ + \ +ONI_C_API_EXPORT void oniDriverStreamSetNewFrameCallback(oni::driver::StreamBase* pStream, \ + oni::driver::NewFrameCallback handler, void* pCookie) \ +{ \ + pStream->setNewFrameCallback(handler, pCookie); \ +} \ + \ +ONI_C_API_EXPORT OniStatus oniDriverStreamConvertDepthToColorCoordinates(oni::driver::StreamBase* pDepthStream, \ + oni::driver::StreamBase* pColorStream, int depthX, int depthY, OniDepthPixel depthZ, int* pColorX, int* pColorY) \ +{ \ + return pDepthStream->convertDepthToColorCoordinates(pColorStream, depthX, depthY, depthZ, pColorX, pColorY); \ +} \ + \ +ONI_C_API_EXPORT void* oniDriverEnableFrameSync(oni::driver::StreamBase** pStreams, int streamCount) \ +{ \ + return g_pDriver->enableFrameSync(pStreams, streamCount); \ +} \ + \ +ONI_C_API_EXPORT void oniDriverDisableFrameSync(void* frameSyncGroup) \ +{ \ + return g_pDriver->disableFrameSync(frameSyncGroup); \ +} \ + +#endif // _ONI_DRIVER_API_H_ diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Driver/OniDriverTypes.h b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Driver/OniDriverTypes.h new file mode 100644 index 00000000..fe8cd44c --- /dev/null +++ b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Driver/OniDriverTypes.h @@ -0,0 +1,54 @@ +/***************************************************************************** +* * +* OpenNI 2.x Alpha * +* Copyright (C) 2012 PrimeSense Ltd. * +* * +* This file is part of OpenNI. * +* * +* Licensed under the Apache License, Version 2.0 (the "License"); * +* you may not use this file except in compliance with the License. * +* You may obtain a copy of the License at * +* * +* http://www.apache.org/licenses/LICENSE-2.0 * +* * +* Unless required by applicable law or agreed to in writing, software * +* distributed under the License is distributed on an "AS IS" BASIS, * +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * +* See the License for the specific language governing permissions and * +* limitations under the License. * +* * +*****************************************************************************/ +#ifndef _ONI_DRIVER_TYPES_H_ +#define _ONI_DRIVER_TYPES_H_ + +#include +#include + +#define ONI_STREAM_PROPERTY_PRIVATE_BASE XN_MAX_UINT16 + +typedef struct +{ + int dataSize; + void* data; +} OniGeneralBuffer; + +/////// DriverServices +struct OniDriverServices +{ + void* driverServices; + void (ONI_CALLBACK_TYPE* errorLoggerAppend)(void* driverServices, const char* format, va_list args); + void (ONI_CALLBACK_TYPE* errorLoggerClear)(void* driverServices); + void (ONI_CALLBACK_TYPE* log)(void* driverServices, int severity, const char* file, int line, const char* mask, const char* message); +}; + +struct OniStreamServices +{ + void* streamServices; + int (ONI_CALLBACK_TYPE* getDefaultRequiredFrameSize)(void* streamServices); + OniFrame* (ONI_CALLBACK_TYPE* acquireFrame)(void* streamServices); // returns a frame with size corresponding to getRequiredFrameSize() + void (ONI_CALLBACK_TYPE* addFrameRef)(void* streamServices, OniFrame* pframe); + void (ONI_CALLBACK_TYPE* releaseFrame)(void* streamServices, OniFrame* pframe); +}; + + +#endif // _ONI_DRIVER_TYPES_H_ diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Linux-Arm/OniPlatformLinux-Arm.h b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Linux-Arm/OniPlatformLinux-Arm.h new file mode 100644 index 00000000..fb96323b --- /dev/null +++ b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Linux-Arm/OniPlatformLinux-Arm.h @@ -0,0 +1,36 @@ +/***************************************************************************** +* * +* OpenNI 2.x Alpha * +* Copyright (C) 2012 PrimeSense Ltd. * +* * +* This file is part of OpenNI. * +* * +* Licensed under the Apache License, Version 2.0 (the "License"); * +* you may not use this file except in compliance with the License. * +* You may obtain a copy of the License at * +* * +* http://www.apache.org/licenses/LICENSE-2.0 * +* * +* Unless required by applicable law or agreed to in writing, software * +* distributed under the License is distributed on an "AS IS" BASIS, * +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * +* See the License for the specific language governing permissions and * +* limitations under the License. * +* * +*****************************************************************************/ +#ifndef _ONI_PLATFORM_LINUX_ARM_H_ +#define _ONI_PLATFORM_LINUX_ARM_H_ + +// Start with Linux-x86, and override what's different +#include "../Linux-x86/OniPlatformLinux-x86.h" + +//--------------------------------------------------------------------------- +// Platform Basic Definition +//--------------------------------------------------------------------------- +#undef ONI_PLATFORM +#undef ONI_PLATFORM_STRING +#define ONI_PLATFORM ONI_PLATFORM_LINUX_ARM +#define ONI_PLATFORM_STRING "Linux-Arm" + +#endif //_ONI_PLATFORM_LINUX_ARM_H_ + diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Linux-x86/OniPlatformLinux-x86.h b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Linux-x86/OniPlatformLinux-x86.h new file mode 100644 index 00000000..e5980f35 --- /dev/null +++ b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Linux-x86/OniPlatformLinux-x86.h @@ -0,0 +1,102 @@ +/***************************************************************************** +* * +* OpenNI 2.x Alpha * +* Copyright (C) 2012 PrimeSense Ltd. * +* * +* This file is part of OpenNI. * +* * +* Licensed under the Apache License, Version 2.0 (the "License"); * +* you may not use this file except in compliance with the License. * +* You may obtain a copy of the License at * +* * +* http://www.apache.org/licenses/LICENSE-2.0 * +* * +* Unless required by applicable law or agreed to in writing, software * +* distributed under the License is distributed on an "AS IS" BASIS, * +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * +* See the License for the specific language governing permissions and * +* limitations under the License. * +* * +*****************************************************************************/ +#ifndef _ONI_PLATFORM_LINUX_X86_H_ +#define _ONI_PLATFORM_LINUX_X86_H_ + +//--------------------------------------------------------------------------- +// Prerequisites +//--------------------------------------------------------------------------- + +//--------------------------------------------------------------------------- +// Includes +//--------------------------------------------------------------------------- +#include +#include +#include +#include +#include +#include +#include + +//--------------------------------------------------------------------------- +// Platform Basic Definition +//--------------------------------------------------------------------------- +#define ONI_PLATFORM ONI_PLATFORM_LINUX_X86 +#define ONI_PLATFORM_STRING "Linux-x86" + +//--------------------------------------------------------------------------- +// Platform Capabilities +//--------------------------------------------------------------------------- +#define ONI_PLATFORM_ENDIAN_TYPE ONI_PLATFORM_IS_LITTLE_ENDIAN + +#define ONI_PLATFORM_SUPPORTS_DYNAMIC_LIBS 1 + +//--------------------------------------------------------------------------- +// Memory +//--------------------------------------------------------------------------- +/** The default memory alignment. */ +#define ONI_DEFAULT_MEM_ALIGN 16 + +/** The thread static declarator (using TLS). */ +#define ONI_THREAD_STATIC __thread + +//--------------------------------------------------------------------------- +// Files +//--------------------------------------------------------------------------- +/** The maximum allowed file path size (in bytes). */ +#define ONI_FILE_MAX_PATH 256 + +//--------------------------------------------------------------------------- +// Call back +//--------------------------------------------------------------------------- +/** The std call type. */ +#define ONI_STDCALL __stdcall + +/** The call back calling convention. */ +#define ONI_CALLBACK_TYPE + +/** The C and C++ calling convension. */ +#define ONI_C_DECL + +//--------------------------------------------------------------------------- +// Macros +//--------------------------------------------------------------------------- +/** Returns the date and time at compile time. */ +#define ONI_TIMESTAMP __DATE__ " " __TIME__ + +/** Converts n into a pre-processor string. */ +#define ONI_STRINGIFY(n) ONI_STRINGIFY_HELPER(n) +#define ONI_STRINGIFY_HELPER(n) #n + +//--------------------------------------------------------------------------- +// API Export/Import Macros +//--------------------------------------------------------------------------- +/** Indicates an exported shared library function. */ +#define ONI_API_EXPORT __attribute__ ((visibility("default"))) + +/** Indicates an imported shared library function. */ +#define ONI_API_IMPORT + +/** Indicates a deprecated function */ +#define ONI_API_DEPRECATED(msg) __attribute__((warning("This function is deprecated: " msg))) + +#endif //_ONI_PLATFORM_LINUX_X86_H_ + diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/MacOSX/OniPlatformMacOSX.h b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/MacOSX/OniPlatformMacOSX.h new file mode 100644 index 00000000..251256eb --- /dev/null +++ b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/MacOSX/OniPlatformMacOSX.h @@ -0,0 +1,42 @@ +/***************************************************************************** +* * +* PrimeSense PSCommon Library * +* Copyright (C) 2012 PrimeSense Ltd. * +* * +* This file is part of PSCommon. * +* * +* Licensed under the Apache License, Version 2.0 (the "License"); * +* you may not use this file except in compliance with the License. * +* You may obtain a copy of the License at * +* * +* http://www.apache.org/licenses/LICENSE-2.0 * +* * +* Unless required by applicable law or agreed to in writing, software * +* distributed under the License is distributed on an "AS IS" BASIS, * +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * +* See the License for the specific language governing permissions and * +* limitations under the License. * +* * +*****************************************************************************/ +#ifndef _ONI_PLATFORM_MACOSX_H_ +#define _ONI_PLATFORM_MACOSX_H_ + +// Start with Linux-x86, and override what's different +#include "../Linux-x86/OniPlatformLinux-x86.h" + +#include + +#undef ONI_PLATFORM +#undef ONI_PLATFORM_STRING +#define ONI_PLATFORM ONI_PLATFORM_MACOSX +#define ONI_PLATFORM_STRING "MacOSX" + +#define ONI_PLATFORM_HAS_NO_TIMED_OPS +#define ONI_PLATFORM_HAS_NO_CLOCK_GETTIME +#define ONI_PLATFORM_HAS_NO_SCHED_PARAM +#define ONI_PLATFORM_HAS_BUILTIN_SEMUN + +#undef ONI_THREAD_STATIC +#define ONI_THREAD_STATIC + +#endif //_ONI_PLATFORM_MACOSX_H_ diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCAPI.h b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCAPI.h new file mode 100644 index 00000000..aea426d4 --- /dev/null +++ b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCAPI.h @@ -0,0 +1,259 @@ +/***************************************************************************** +* * +* OpenNI 2.x Alpha * +* Copyright (C) 2012 PrimeSense Ltd. * +* * +* This file is part of OpenNI. * +* * +* Licensed under the Apache License, Version 2.0 (the "License"); * +* you may not use this file except in compliance with the License. * +* You may obtain a copy of the License at * +* * +* http://www.apache.org/licenses/LICENSE-2.0 * +* * +* Unless required by applicable law or agreed to in writing, software * +* distributed under the License is distributed on an "AS IS" BASIS, * +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * +* See the License for the specific language governing permissions and * +* limitations under the License. * +* * +*****************************************************************************/ +#ifndef _ONI_C_API_H_ +#define _ONI_C_API_H_ + +#include "OniPlatform.h" +#include "OniCTypes.h" +#include "OniCProperties.h" +#include "OniVersion.h" + +/******************************************** General APIs */ + +/** Initialize OpenNI2. Use ONI_API_VERSION as the version. */ +ONI_C_API OniStatus oniInitialize(int apiVersion); +/** Shutdown OpenNI2 */ +ONI_C_API void oniShutdown(); + +/** + * Get the list of currently connected device. + * Each device is represented by its OniDeviceInfo. + * pDevices will be allocated inside. + */ +ONI_C_API OniStatus oniGetDeviceList(OniDeviceInfo** pDevices, int* pNumDevices); +/** Release previously allocated device list */ +ONI_C_API OniStatus oniReleaseDeviceList(OniDeviceInfo* pDevices); + +ONI_C_API OniStatus oniRegisterDeviceCallbacks(OniDeviceCallbacks* pCallbacks, void* pCookie, OniCallbackHandle* pHandle); +ONI_C_API void oniUnregisterDeviceCallbacks(OniCallbackHandle handle); + +/** Wait for any of the streams to have a new frame */ +ONI_C_API OniStatus oniWaitForAnyStream(OniStreamHandle* pStreams, int numStreams, int* pStreamIndex, int timeout); + +/** Get the current version of OpenNI2 */ +ONI_C_API OniVersion oniGetVersion(); + +/** Translate from format to number of bytes per pixel. Will return 0 for formats in which the number of bytes per pixel isn't fixed. */ +ONI_C_API int oniFormatBytesPerPixel(OniPixelFormat format); + +/** Get internal error */ +ONI_C_API const char* oniGetExtendedError(); + +/******************************************** Device APIs */ + +/** Open a device. Uri can be taken from the matching OniDeviceInfo. */ +ONI_C_API OniStatus oniDeviceOpen(const char* uri, OniDeviceHandle* pDevice); +/** Close a device */ +ONI_C_API OniStatus oniDeviceClose(OniDeviceHandle device); + +/** Get the possible configurations available for a specific source, or NULL if the source does not exist. */ +ONI_C_API const OniSensorInfo* oniDeviceGetSensorInfo(OniDeviceHandle device, OniSensorType sensorType); + +/** Get the OniDeviceInfo of a certain device. */ +ONI_C_API OniStatus oniDeviceGetInfo(OniDeviceHandle device, OniDeviceInfo* pInfo); + +/** Create a new stream in the device. The stream will originate from the source. */ +ONI_C_API OniStatus oniDeviceCreateStream(OniDeviceHandle device, OniSensorType sensorType, OniStreamHandle* pStream); + +ONI_C_API OniStatus oniDeviceEnableDepthColorSync(OniDeviceHandle device); +ONI_C_API void oniDeviceDisableDepthColorSync(OniDeviceHandle device); +ONI_C_API OniBool oniDeviceGetDepthColorSyncEnabled(OniDeviceHandle device); + +/** Set property in the device. Use the properties listed in OniTypes.h: ONI_DEVICE_PROPERTY_..., or specific ones supplied by the device. */ +ONI_C_API OniStatus oniDeviceSetProperty(OniDeviceHandle device, int propertyId, const void* data, int dataSize); +/** Get property in the device. Use the properties listed in OniTypes.h: ONI_DEVICE_PROPERTY_..., or specific ones supplied by the device. */ +ONI_C_API OniStatus oniDeviceGetProperty(OniDeviceHandle device, int propertyId, void* data, int* pDataSize); +/** Check if the property is supported by the device. Use the properties listed in OniTypes.h: ONI_DEVICE_PROPERTY_..., or specific ones supplied by the device. */ +ONI_C_API OniBool oniDeviceIsPropertySupported(OniDeviceHandle device, int propertyId); +/** Invoke an internal functionality of the device. */ +ONI_C_API OniStatus oniDeviceInvoke(OniDeviceHandle device, int commandId, void* data, int dataSize); +/** Check if a command is supported, for invoke */ +ONI_C_API OniBool oniDeviceIsCommandSupported(OniDeviceHandle device, int commandId); + +ONI_C_API OniBool oniDeviceIsImageRegistrationModeSupported(OniDeviceHandle device, OniImageRegistrationMode mode); + +/** @internal */ +ONI_C_API OniStatus oniDeviceOpenEx(const char* uri, const char* mode, OniDeviceHandle* pDevice); + +/******************************************** Stream APIs */ + +/** Destroy an existing stream */ +ONI_C_API void oniStreamDestroy(OniStreamHandle stream); + +/** Get the OniSensorInfo of the certain stream. */ +ONI_C_API const OniSensorInfo* oniStreamGetSensorInfo(OniStreamHandle stream); + +/** Start generating data from the stream. */ +ONI_C_API OniStatus oniStreamStart(OniStreamHandle stream); +/** Stop generating data from the stream. */ +ONI_C_API void oniStreamStop(OniStreamHandle stream); + +/** Get the next frame from the stream. This function is blocking until there is a new frame from the stream. For timeout, use oniWaitForStreams() first */ +ONI_C_API OniStatus oniStreamReadFrame(OniStreamHandle stream, OniFrame** pFrame); + +/** Register a callback to when the stream has a new frame. */ +ONI_C_API OniStatus oniStreamRegisterNewFrameCallback(OniStreamHandle stream, OniNewFrameCallback handler, void* pCookie, OniCallbackHandle* pHandle); +/** Unregister a previously registered callback to when the stream has a new frame. */ +ONI_C_API void oniStreamUnregisterNewFrameCallback(OniStreamHandle stream, OniCallbackHandle handle); + +/** Set property in the stream. Use the properties listed in OniTypes.h: ONI_STREAM_PROPERTY_..., or specific ones supplied by the device for its streams. */ +ONI_C_API OniStatus oniStreamSetProperty(OniStreamHandle stream, int propertyId, const void* data, int dataSize); +/** Get property in the stream. Use the properties listed in OniTypes.h: ONI_STREAM_PROPERTY_..., or specific ones supplied by the device for its streams. */ +ONI_C_API OniStatus oniStreamGetProperty(OniStreamHandle stream, int propertyId, void* data, int* pDataSize); +/** Check if the property is supported the stream. Use the properties listed in OniTypes.h: ONI_STREAM_PROPERTY_..., or specific ones supplied by the device for its streams. */ +ONI_C_API OniBool oniStreamIsPropertySupported(OniStreamHandle stream, int propertyId); +/** Invoke an internal functionality of the stream. */ +ONI_C_API OniStatus oniStreamInvoke(OniStreamHandle stream, int commandId, void* data, int dataSize); +/** Check if a command is supported, for invoke */ +ONI_C_API OniBool oniStreamIsCommandSupported(OniStreamHandle stream, int commandId); +/** Sets the stream buffer allocation functions. Note that this function may only be called while stream is not started. */ +ONI_C_API OniStatus oniStreamSetFrameBuffersAllocator(OniStreamHandle stream, OniFrameAllocBufferCallback alloc, OniFrameFreeBufferCallback free, void* pCookie); + +//// +/** Mark another user of the frame. */ +ONI_C_API void oniFrameAddRef(OniFrame* pFrame); +/** Mark that the frame is no longer needed. */ +ONI_C_API void oniFrameRelease(OniFrame* pFrame); + +// ONI_C_API OniStatus oniConvertRealWorldToProjective(OniStreamHandle stream, OniFloatPoint3D* pRealWorldPoint, OniFloatPoint3D* pProjectivePoint); +// ONI_C_API OniStatus oniConvertProjectiveToRealWorld(OniStreamHandle stream, OniFloatPoint3D* pProjectivePoint, OniFloatPoint3D* pRealWorldPoint); + +/** + * Creates a recorder that records to a file. + * @param [in] fileName The name of the file that will contain the recording. + * @param [out] pRecorder Points to the handle to the newly created recorder. + * @retval ONI_STATUS_OK Upon successful completion. + * @retval ONI_STATUS_ERROR Upon any kind of failure. + */ +ONI_C_API OniStatus oniCreateRecorder(const char* fileName, OniRecorderHandle* pRecorder); + +/** + * Attaches a stream to a recorder. The amount of attached streams is virtually + * infinite. You cannot attach a stream after you have started a recording, if + * you do: an error will be returned by oniRecorderAttachStream. + * @param [in] recorder The handle to the recorder. + * @param [in] stream The handle to the stream. + * @param [in] allowLossyCompression Allows/denies lossy compression + * @retval ONI_STATUS_OK Upon successful completion. + * @retval ONI_STATUS_ERROR Upon any kind of failure. + */ +ONI_C_API OniStatus oniRecorderAttachStream( + OniRecorderHandle recorder, + OniStreamHandle stream, + OniBool allowLossyCompression); + +/** + * Starts recording. There must be at least one stream attached to the recorder, + * if not: oniRecorderStart will return an error. + * @param[in] recorder The handle to the recorder. + * @retval ONI_STATUS_OK Upon successful completion. + * @retval ONI_STATUS_ERROR Upon any kind of failure. + */ +ONI_C_API OniStatus oniRecorderStart(OniRecorderHandle recorder); + +/** + * Stops recording. You can resume recording via oniRecorderStart. + * @param[in] recorder The handle to the recorder. + * @retval ONI_STATUS_OK Upon successful completion. + * @retval ONI_STATUS_ERROR Upon any kind of failure. + */ +ONI_C_API void oniRecorderStop(OniRecorderHandle recorder); + +/** + * Stops recording if needed, and destroys a recorder. + * @param [in,out] recorder The handle to the recorder, the handle will be + * invalidated (nullified) when the function returns. + * @retval ONI_STATUS_OK Upon successful completion. + * @retval ONI_STATUS_ERROR Upon any kind of failure. + */ +ONI_C_API OniStatus oniRecorderDestroy(OniRecorderHandle* pRecorder); + +ONI_C_API OniStatus oniCoordinateConverterDepthToWorld(OniStreamHandle depthStream, float depthX, float depthY, float depthZ, float* pWorldX, float* pWorldY, float* pWorldZ); + +ONI_C_API OniStatus oniCoordinateConverterWorldToDepth(OniStreamHandle depthStream, float worldX, float worldY, float worldZ, float* pDepthX, float* pDepthY, float* pDepthZ); + +ONI_C_API OniStatus oniCoordinateConverterDepthToColor(OniStreamHandle depthStream, OniStreamHandle colorStream, int depthX, int depthY, OniDepthPixel depthZ, int* pColorX, int* pColorY); + +/******************************************** Log APIs */ + +/** + * Change the log output folder + + * @param const char * strOutputFolder [in] path to the desirebale folder + * + * @retval ONI_STATUS_OK Upon successful completion. + * @retval ONI_STATUS_ERROR Upon any kind of failure. + */ +ONI_C_API OniStatus oniSetLogOutputFolder(const char* strOutputFolder); + +/** + * Get the current log file name + + * @param char * strFileName [out] hold the returned file name + * @param int nBufferSize [in] size of strFileName + * + * @retval ONI_STATUS_OK Upon successful completion. + * @retval ONI_STATUS_ERROR Upon any kind of failure. + */ +ONI_C_API OniStatus oniGetLogFileName(char* strFileName, int nBufferSize); + +/** + * Set the Minimum severity for log produce + + * @param const char * strMask [in] Name of the logger + * + * @retval ONI_STATUS_OK Upon successful completion. + * @retval ONI_STATUS_ERROR Upon any kind of failure. + */ +ONI_C_API OniStatus oniSetLogMinSeverity(int nMinSeverity); + +/** + * Configures if log entries will be printed to console. + + * @param OniBool bConsoleOutput [in] TRUE to print log entries to console, FALSE otherwise. + * + * @retval ONI_STATUS_OK Upon successful completion. + * @retval ONI_STATUS_ERROR Upon any kind of failure. + */ +ONI_C_API OniStatus oniSetLogConsoleOutput(OniBool bConsoleOutput); + +/** + * Configures if log entries will be printed to a log file. + + * @param OniBool bFileOutput [in] TRUE to print log entries to the file, FALSE otherwise. + * + * @retval ONI_STATUS_OK Upon successful completion. + * @retval ONI_STATUS_ERROR Upon any kind of failure. + */ +ONI_C_API OniStatus oniSetLogFileOutput(OniBool bFileOutput); + +#if ONI_PLATFORM == ONI_PLATFORM_ANDROID_ARM +/** + * Configures if log entries will be printed to the Android log. + + * @param OniBool bAndroidOutput [in] TRUE to print log entries to the Android log, FALSE otherwise. + * + * @retval ONI_STATUS_OK Upon successful completion. + * @retval ONI_STATUS_ERROR Upon any kind of failure. + */ +ONI_C_API OniStatus oniSetLogAndroidOutput(OniBool bAndroidOutput); +#endif +#endif // _ONI_C_API_H_ diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCEnums.h b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCEnums.h new file mode 100644 index 00000000..d7f513b8 --- /dev/null +++ b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCEnums.h @@ -0,0 +1,84 @@ +/***************************************************************************** +* * +* OpenNI 2.x Alpha * +* Copyright (C) 2012 PrimeSense Ltd. * +* * +* This file is part of OpenNI. * +* * +* Licensed under the Apache License, Version 2.0 (the "License"); * +* you may not use this file except in compliance with the License. * +* You may obtain a copy of the License at * +* * +* http://www.apache.org/licenses/LICENSE-2.0 * +* * +* Unless required by applicable law or agreed to in writing, software * +* distributed under the License is distributed on an "AS IS" BASIS, * +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * +* See the License for the specific language governing permissions and * +* limitations under the License. * +* * +*****************************************************************************/ +#ifndef _ONI_C_ENUMS_H_ +#define _ONI_C_ENUMS_H_ + +/** Possible failure values */ +typedef enum +{ + ONI_STATUS_OK = 0, + ONI_STATUS_ERROR = 1, + ONI_STATUS_NOT_IMPLEMENTED = 2, + ONI_STATUS_NOT_SUPPORTED = 3, + ONI_STATUS_BAD_PARAMETER = 4, + ONI_STATUS_OUT_OF_FLOW = 5, + ONI_STATUS_NO_DEVICE = 6, + ONI_STATUS_TIME_OUT = 102, +} OniStatus; + +/** The source of the stream */ +typedef enum +{ + ONI_SENSOR_IR = 1, + ONI_SENSOR_COLOR = 2, + ONI_SENSOR_DEPTH = 3, + +} OniSensorType; + +/** All available formats of the output of a stream */ +typedef enum +{ + // Depth + ONI_PIXEL_FORMAT_DEPTH_1_MM = 100, + ONI_PIXEL_FORMAT_DEPTH_100_UM = 101, + ONI_PIXEL_FORMAT_SHIFT_9_2 = 102, + ONI_PIXEL_FORMAT_SHIFT_9_3 = 103, + + // Color + ONI_PIXEL_FORMAT_RGB888 = 200, + ONI_PIXEL_FORMAT_YUV422 = 201, + ONI_PIXEL_FORMAT_GRAY8 = 202, + ONI_PIXEL_FORMAT_GRAY16 = 203, + ONI_PIXEL_FORMAT_JPEG = 204, + ONI_PIXEL_FORMAT_YUYV = 205, +} OniPixelFormat; + +typedef enum +{ + ONI_DEVICE_STATE_OK = 0, + ONI_DEVICE_STATE_ERROR = 1, + ONI_DEVICE_STATE_NOT_READY = 2, + ONI_DEVICE_STATE_EOF = 3 +} OniDeviceState; + +typedef enum +{ + ONI_IMAGE_REGISTRATION_OFF = 0, + ONI_IMAGE_REGISTRATION_DEPTH_TO_COLOR = 1, +} OniImageRegistrationMode; + +enum +{ + ONI_TIMEOUT_NONE = 0, + ONI_TIMEOUT_FOREVER = -1, +}; + +#endif // _ONI_C_ENUMS_H_ diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCProperties.h b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCProperties.h new file mode 100644 index 00000000..da13d58e --- /dev/null +++ b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCProperties.h @@ -0,0 +1,68 @@ +/***************************************************************************** +* * +* OpenNI 2.x Alpha * +* Copyright (C) 2012 PrimeSense Ltd. * +* * +* This file is part of OpenNI. * +* * +* Licensed under the Apache License, Version 2.0 (the "License"); * +* you may not use this file except in compliance with the License. * +* You may obtain a copy of the License at * +* * +* http://www.apache.org/licenses/LICENSE-2.0 * +* * +* Unless required by applicable law or agreed to in writing, software * +* distributed under the License is distributed on an "AS IS" BASIS, * +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * +* See the License for the specific language governing permissions and * +* limitations under the License. * +* * +*****************************************************************************/ +#ifndef _ONI_C_PROPERTIES_H_ +#define _ONI_C_PROPERTIES_H_ + +// Device properties +enum +{ + ONI_DEVICE_PROPERTY_FIRMWARE_VERSION = 0, // By implementation + ONI_DEVICE_PROPERTY_DRIVER_VERSION = 1, // OniVersion + ONI_DEVICE_PROPERTY_HARDWARE_VERSION = 2, // int + ONI_DEVICE_PROPERTY_SERIAL_NUMBER = 3, // string + ONI_DEVICE_PROPERTY_ERROR_STATE = 4, // ?? + ONI_DEVICE_PROPERTY_IMAGE_REGISTRATION = 5, // OniImageRegistrationMode + + // Files + ONI_DEVICE_PROPERTY_PLAYBACK_SPEED = 100, // float + ONI_DEVICE_PROPERTY_PLAYBACK_REPEAT_ENABLED = 101, // OniBool +}; + +// Stream properties +enum +{ + ONI_STREAM_PROPERTY_CROPPING = 0, // OniCropping* + ONI_STREAM_PROPERTY_HORIZONTAL_FOV = 1, // float: radians + ONI_STREAM_PROPERTY_VERTICAL_FOV = 2, // float: radians + ONI_STREAM_PROPERTY_VIDEO_MODE = 3, // OniVideoMode* + + ONI_STREAM_PROPERTY_MAX_VALUE = 4, // int + ONI_STREAM_PROPERTY_MIN_VALUE = 5, // int + + ONI_STREAM_PROPERTY_STRIDE = 6, // int + ONI_STREAM_PROPERTY_MIRRORING = 7, // OniBool + + ONI_STREAM_PROPERTY_NUMBER_OF_FRAMES = 8, // int + + // Camera + ONI_STREAM_PROPERTY_AUTO_WHITE_BALANCE = 100, // OniBool + ONI_STREAM_PROPERTY_AUTO_EXPOSURE = 101, // OniBool + ONI_STREAM_PROPERTY_EXPOSURE = 102, // int + ONI_STREAM_PROPERTY_GAIN = 103, // int +}; + +// Device commands (for Invoke) +enum +{ + ONI_DEVICE_COMMAND_SEEK = 1, // OniSeek +}; + +#endif // _ONI_C_PROPERTIES_H_ diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCTypes.h b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCTypes.h new file mode 100644 index 00000000..12246949 --- /dev/null +++ b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCTypes.h @@ -0,0 +1,193 @@ +/***************************************************************************** +* * +* OpenNI 2.x Alpha * +* Copyright (C) 2012 PrimeSense Ltd. * +* * +* This file is part of OpenNI. * +* * +* Licensed under the Apache License, Version 2.0 (the "License"); * +* you may not use this file except in compliance with the License. * +* You may obtain a copy of the License at * +* * +* http://www.apache.org/licenses/LICENSE-2.0 * +* * +* Unless required by applicable law or agreed to in writing, software * +* distributed under the License is distributed on an "AS IS" BASIS, * +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * +* See the License for the specific language governing permissions and * +* limitations under the License. * +* * +*****************************************************************************/ +#ifndef _ONI_TYPES_H_ +#define _ONI_TYPES_H_ + +#include "OniPlatform.h" +#include "OniCEnums.h" + +/** Basic types **/ +typedef int OniBool; + +#ifndef TRUE +#define TRUE 1 +#endif //TRUE +#ifndef FALSE +#define FALSE 0 +#endif //FALSE + +#define ONI_MAX_STR 256 +#define ONI_MAX_SENSORS 10 + +struct OniCallbackHandleImpl; +typedef struct OniCallbackHandleImpl* OniCallbackHandle; + +/** Holds an OpenNI version number, which consists of four separate numbers in the format: @c major.minor.maintenance.build. For example: 2.0.0.20. */ +typedef struct +{ + /** Major version number, incremented for major API restructuring. */ + int major; + /** Minor version number, incremented when significant new features added. */ + int minor; + /** Maintenance build number, incremented for new releases that primarily provide minor bug fixes. */ + int maintenance; + /** Build number. Incremented for each new API build. Generally not shown on the installer and download site. */ + int build; +} OniVersion; + +typedef int OniHardwareVersion; + +/** Description of the output: format and resolution */ +typedef struct +{ + OniPixelFormat pixelFormat; + int resolutionX; + int resolutionY; + int fps; +} OniVideoMode; + +/** List of supported video modes by a specific source */ +typedef struct +{ + OniSensorType sensorType; + int numSupportedVideoModes; + OniVideoMode *pSupportedVideoModes; +} OniSensorInfo; + +/** Basic description of a device */ +typedef struct +{ + char uri[ONI_MAX_STR]; + char vendor[ONI_MAX_STR]; + char name[ONI_MAX_STR]; + uint16_t usbVendorId; + uint16_t usbProductId; +} OniDeviceInfo; + +struct _OniDevice; +typedef _OniDevice* OniDeviceHandle; + +struct _OniStream; +typedef _OniStream* OniStreamHandle; + +struct _OniRecorder; +typedef _OniRecorder* OniRecorderHandle; + +/** All information of the current frame */ +typedef struct +{ + int dataSize; + void* data; + + OniSensorType sensorType; + uint64_t timestamp; + int frameIndex; + + int width; + int height; + + OniVideoMode videoMode; + OniBool croppingEnabled; + int cropOriginX; + int cropOriginY; + + int stride; +} OniFrame; + +typedef void (ONI_CALLBACK_TYPE* OniNewFrameCallback)(OniStreamHandle stream, void* pCookie); +typedef void (ONI_CALLBACK_TYPE* OniGeneralCallback)(void* pCookie); +typedef void (ONI_CALLBACK_TYPE* OniDeviceInfoCallback)(const OniDeviceInfo* pInfo, void* pCookie); +typedef void (ONI_CALLBACK_TYPE* OniDeviceStateCallback)(const OniDeviceInfo* pInfo, OniDeviceState deviceState, void* pCookie); + +typedef void* (ONI_CALLBACK_TYPE* OniFrameAllocBufferCallback)(int size, void* pCookie); +typedef void (ONI_CALLBACK_TYPE* OniFrameFreeBufferCallback)(void* data, void* pCookie); + +typedef struct +{ + OniDeviceInfoCallback deviceConnected; + OniDeviceInfoCallback deviceDisconnected; + OniDeviceStateCallback deviceStateChanged; +} OniDeviceCallbacks; + +typedef struct +{ + int enabled; + int originX; + int originY; + int width; + int height; +} OniCropping; + +// Pixel types +/** +Pixel type used to store depth images. +*/ +typedef uint16_t OniDepthPixel; + +/** +Pixel type used to store 16-bit grayscale images +*/ +typedef uint16_t OniGrayscale16Pixel; + +/** +Pixel type used to store 8-bit grayscale/bayer images +*/ +typedef uint8_t OniGrayscale8Pixel; + +#pragma pack (push, 1) + +/** Holds the value of a single color image pixel in 24-bit RGB format. */ +typedef struct +{ + /* Red value of this pixel. */ + uint8_t r; + /* Green value of this pixel. */ + uint8_t g; + /* Blue value of this pixel. */ + uint8_t b; +} OniRGB888Pixel; + +/** + Holds the value of two pixels in YUV422 format (Luminance/Chrominance,16-bits/pixel). + The first pixel has the values y1, u, v. + The second pixel has the values y2, u, v. +*/ +typedef struct +{ + /** First chrominance value for two pixels, stored as blue luminance difference signal. */ + uint8_t u; + /** Overall luminance value of first pixel. */ + uint8_t y1; + /** Second chrominance value for two pixels, stored as red luminance difference signal. */ + uint8_t v; + /** Overall luminance value of second pixel. */ + uint8_t y2; +} OniYUV422DoublePixel; + +#pragma pack (pop) + +typedef struct +{ + int frameIndex; + OniStreamHandle stream; +} OniSeek; + +#endif // _ONI_TYPES_H_ diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniEnums.h b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniEnums.h new file mode 100644 index 00000000..018f2227 --- /dev/null +++ b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniEnums.h @@ -0,0 +1,86 @@ +/***************************************************************************** +* * +* OpenNI 2.x Alpha * +* Copyright (C) 2012 PrimeSense Ltd. * +* * +* This file is part of OpenNI. * +* * +* Licensed under the Apache License, Version 2.0 (the "License"); * +* you may not use this file except in compliance with the License. * +* You may obtain a copy of the License at * +* * +* http://www.apache.org/licenses/LICENSE-2.0 * +* * +* Unless required by applicable law or agreed to in writing, software * +* distributed under the License is distributed on an "AS IS" BASIS, * +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * +* See the License for the specific language governing permissions and * +* limitations under the License. * +* * +*****************************************************************************/ +#ifndef _ONI_ENUMS_H_ +#define _ONI_ENUMS_H_ + +namespace openni +{ + +/** Possible failure values */ +typedef enum +{ + STATUS_OK = 0, + STATUS_ERROR = 1, + STATUS_NOT_IMPLEMENTED = 2, + STATUS_NOT_SUPPORTED = 3, + STATUS_BAD_PARAMETER = 4, + STATUS_OUT_OF_FLOW = 5, + STATUS_NO_DEVICE = 6, + STATUS_TIME_OUT = 102, +} Status; + +/** The source of the stream */ +typedef enum +{ + SENSOR_IR = 1, + SENSOR_COLOR = 2, + SENSOR_DEPTH = 3, + +} SensorType; + +/** All available formats of the output of a stream */ +typedef enum +{ + // Depth + PIXEL_FORMAT_DEPTH_1_MM = 100, + PIXEL_FORMAT_DEPTH_100_UM = 101, + PIXEL_FORMAT_SHIFT_9_2 = 102, + PIXEL_FORMAT_SHIFT_9_3 = 103, + + // Color + PIXEL_FORMAT_RGB888 = 200, + PIXEL_FORMAT_YUV422 = 201, + PIXEL_FORMAT_GRAY8 = 202, + PIXEL_FORMAT_GRAY16 = 203, + PIXEL_FORMAT_JPEG = 204, + PIXEL_FORMAT_YUYV = 205, +} PixelFormat; + +typedef enum +{ + DEVICE_STATE_OK = 0, + DEVICE_STATE_ERROR = 1, + DEVICE_STATE_NOT_READY = 2, + DEVICE_STATE_EOF = 3 +} DeviceState; + +typedef enum +{ + IMAGE_REGISTRATION_OFF = 0, + IMAGE_REGISTRATION_DEPTH_TO_COLOR = 1, +} ImageRegistrationMode; + +static const int TIMEOUT_NONE = 0; +static const int TIMEOUT_FOREVER = -1; + +} // namespace openni + +#endif // _ONI_ENUMS_H_ diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniPlatform.h b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniPlatform.h new file mode 100644 index 00000000..65f6904d --- /dev/null +++ b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniPlatform.h @@ -0,0 +1,72 @@ +/***************************************************************************** +* * +* OpenNI 2.x Alpha * +* Copyright (C) 2012 PrimeSense Ltd. * +* * +* This file is part of OpenNI. * +* * +* Licensed under the Apache License, Version 2.0 (the "License"); * +* you may not use this file except in compliance with the License. * +* You may obtain a copy of the License at * +* * +* http://www.apache.org/licenses/LICENSE-2.0 * +* * +* Unless required by applicable law or agreed to in writing, software * +* distributed under the License is distributed on an "AS IS" BASIS, * +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * +* See the License for the specific language governing permissions and * +* limitations under the License. * +* * +*****************************************************************************/ +#ifndef _ONI_PLATFORM_H_ +#define _ONI_PLATFORM_H_ + +// Supported platforms +#define ONI_PLATFORM_WIN32 1 +#define ONI_PLATFORM_LINUX_X86 2 +#define ONI_PLATFORM_LINUX_ARM 3 +#define ONI_PLATFORM_MACOSX 4 +#define ONI_PLATFORM_ANDROID_ARM 5 + +#if (defined _WIN32) +# ifndef RC_INVOKED +# if _MSC_VER < 1300 +# error OpenNI Platform Abstraction Layer - Win32 - Microsoft Visual Studio version below 2003 (7.0) are not supported! +# endif +# endif +# include "Win32/OniPlatformWin32.h" +#elif defined (ANDROID) && defined (__arm__) +# include "Android-Arm/OniPlatformAndroid-Arm.h" +#elif (__linux__ && (__i386__ || __x86_64__)) +# include "Linux-x86/OniPlatformLinux-x86.h" +#elif (__linux__ && __arm__) +# include "Linux-Arm/OniPlatformLinux-Arm.h" +#elif _ARC +# include "ARC/OniPlaformARC.h" +#elif (__APPLE__) +# include "MacOSX/OniPlatformMacOSX.h" +#else +# error Xiron Platform Abstraction Layer - Unsupported Platform! +#endif + +#ifdef __cplusplus +# define ONI_C extern "C" +# define ONI_C_API_EXPORT ONI_C ONI_API_EXPORT +# define ONI_C_API_IMPORT ONI_C ONI_API_IMPORT +# define ONI_CPP_API_EXPORT ONI_API_EXPORT +# define ONI_CPP_API_IMPORT ONI_API_IMPORT +#else // __cplusplus +# define ONI_C_API_EXPORT ONI_API_EXPORT +# define ONI_C_API_IMPORT ONI_API_IMPORT +#endif // __cplusplus + +#ifdef OPENNI2_EXPORT +# define ONI_C_API ONI_C_API_EXPORT +# define ONI_CPP_API ONI_CPP_API_EXPORT +#else // OPENNI2_EXPORT +# define ONI_C_API ONI_C_API_IMPORT +# define ONI_CPP_API ONI_CPP_API_IMPORT +#endif // OPENNI2_EXPORT + + +#endif // _ONI_PLATFORM_H_ diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniProperties.h b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniProperties.h new file mode 100644 index 00000000..19b0805a --- /dev/null +++ b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniProperties.h @@ -0,0 +1,73 @@ +/***************************************************************************** +* * +* OpenNI 2.x Alpha * +* Copyright (C) 2012 PrimeSense Ltd. * +* * +* This file is part of OpenNI. * +* * +* Licensed under the Apache License, Version 2.0 (the "License"); * +* you may not use this file except in compliance with the License. * +* You may obtain a copy of the License at * +* * +* http://www.apache.org/licenses/LICENSE-2.0 * +* * +* Unless required by applicable law or agreed to in writing, software * +* distributed under the License is distributed on an "AS IS" BASIS, * +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * +* See the License for the specific language governing permissions and * +* limitations under the License. * +* * +*****************************************************************************/ +#ifndef _ONI_PROPERTIES_H_ +#define _ONI_PROPERTIES_H_ + +namespace openni +{ + +// Device properties +enum +{ + DEVICE_PROPERTY_FIRMWARE_VERSION = 0, // string + DEVICE_PROPERTY_DRIVER_VERSION = 1, // OniVersion + DEVICE_PROPERTY_HARDWARE_VERSION = 2, // int + DEVICE_PROPERTY_SERIAL_NUMBER = 3, // string + DEVICE_PROPERTY_ERROR_STATE = 4, // ?? + DEVICE_PROPERTY_IMAGE_REGISTRATION = 5, // OniImageRegistrationMode + + // Files + DEVICE_PROPERTY_PLAYBACK_SPEED = 100, // float + DEVICE_PROPERTY_PLAYBACK_REPEAT_ENABLED = 101, // OniBool +}; + +// Stream properties +enum +{ + STREAM_PROPERTY_CROPPING = 0, // OniCropping* + STREAM_PROPERTY_HORIZONTAL_FOV = 1, // float: radians + STREAM_PROPERTY_VERTICAL_FOV = 2, // float: radians + STREAM_PROPERTY_VIDEO_MODE = 3, // OniVideoMode* + + STREAM_PROPERTY_MAX_VALUE = 4, // int + STREAM_PROPERTY_MIN_VALUE = 5, // int + + STREAM_PROPERTY_STRIDE = 6, // int + STREAM_PROPERTY_MIRRORING = 7, // OniBool + + STREAM_PROPERTY_NUMBER_OF_FRAMES = 8, // int + + // Camera + STREAM_PROPERTY_AUTO_WHITE_BALANCE = 100, // OniBool + STREAM_PROPERTY_AUTO_EXPOSURE = 101, // OniBool + STREAM_PROPERTY_EXPOSURE = 102, // int + STREAM_PROPERTY_GAIN = 103, // int + +}; + +// Device commands (for Invoke) +enum +{ + DEVICE_COMMAND_SEEK = 1, // OniSeek +}; + +} // namespace openni +#endif // _ONI_PROPERTIES_H_ diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniVersion.h b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniVersion.h new file mode 100644 index 00000000..7aa13ed5 --- /dev/null +++ b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniVersion.h @@ -0,0 +1,43 @@ +/***************************************************************************** +* * +* OpenNI 2.x Alpha * +* Copyright (C) 2012 PrimeSense Ltd. * +* * +* This file is part of OpenNI. * +* * +* Licensed under the Apache License, Version 2.0 (the "License"); * +* you may not use this file except in compliance with the License. * +* You may obtain a copy of the License at * +* * +* http://www.apache.org/licenses/LICENSE-2.0 * +* * +* Unless required by applicable law or agreed to in writing, software * +* distributed under the License is distributed on an "AS IS" BASIS, * +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * +* See the License for the specific language governing permissions and * +* limitations under the License. * +* * +*****************************************************************************/ +#include "OniPlatform.h" + +#define ONI_VERSION_MAJOR 2 +#define ONI_VERSION_MINOR 2 +#define ONI_VERSION_MAINTENANCE 0 +#define ONI_VERSION_BUILD 33 + +/** OpenNI version (in brief string format): "Major.Minor.Maintenance (Build)" */ +#define ONI_BRIEF_VERSION_STRING \ + ONI_STRINGIFY(ONI_VERSION_MAJOR) "." \ + ONI_STRINGIFY(ONI_VERSION_MINOR) "." \ + ONI_STRINGIFY(ONI_VERSION_MAINTENANCE) \ + " (Build " ONI_STRINGIFY(ONI_VERSION_BUILD) ")" + +/** OpenNI version (in numeric format): (OpenNI major version * 100000000 + OpenNI minor version * 1000000 + OpenNI maintenance version * 10000 + OpenNI build version). */ +#define ONI_VERSION (ONI_VERSION_MAJOR*100000000 + ONI_VERSION_MINOR*1000000 + ONI_VERSION_MAINTENANCE*10000 + ONI_VERSION_BUILD) +#define ONI_CREATE_API_VERSION(major, minor) ((major)*1000 + (minor)) +#define ONI_API_VERSION ONI_CREATE_API_VERSION(ONI_VERSION_MAJOR, ONI_VERSION_MINOR) + +/** OpenNI version (in string format): "Major.Minor.Maintenance.Build-Platform (MMM DD YYYY HH:MM:SS)". */ +#define ONI_VERSION_STRING \ + ONI_BRIEF_VERSION_STRING "-" \ + ONI_PLATFORM_STRING " (" ONI_TIMESTAMP ")" diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OpenNI.h b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OpenNI.h new file mode 100644 index 00000000..52324b4e --- /dev/null +++ b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OpenNI.h @@ -0,0 +1,2750 @@ +/***************************************************************************** +* * +* OpenNI 2.x Alpha * +* Copyright (C) 2012 PrimeSense Ltd. * +* * +* This file is part of OpenNI. * +* * +* Licensed under the Apache License, Version 2.0 (the "License"); * +* you may not use this file except in compliance with the License. * +* You may obtain a copy of the License at * +* * +* http://www.apache.org/licenses/LICENSE-2.0 * +* * +* Unless required by applicable law or agreed to in writing, software * +* distributed under the License is distributed on an "AS IS" BASIS, * +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * +* See the License for the specific language governing permissions and * +* limitations under the License. * +* * +*****************************************************************************/ +#ifndef _OPENNI_H_ +#define _OPENNI_H_ + +#include "OniPlatform.h" +#include "OniProperties.h" +#include "OniEnums.h" + +#include "OniCAPI.h" +#include "OniCProperties.h" + +/** +openni is the namespace of the entire C++ API of OpenNI +*/ +namespace openni +{ + +/** Pixel type used to store depth images. */ +typedef uint16_t DepthPixel; + +/** Pixel type used to store IR images. */ +typedef uint16_t Grayscale16Pixel; + +// structs +/** Holds an OpenNI version number, which consists of four separate numbers in the format: @c major.minor.maintenance.build. For example: 2.0.0.20. */ +typedef struct +{ + /** Major version number, incremented for major API restructuring. */ + int major; + /** Minor version number, incremented when significant new features added. */ + int minor; + /** Maintenance build number, incremented for new releases that primarily provide minor bug fixes. */ + int maintenance; + /** Build number. Incremented for each new API build. Generally not shown on the installer and download site. */ + int build; +} Version; + +/** Holds the value of a single color image pixel in 24-bit RGB format. */ +typedef struct +{ + /* Red value of this pixel. */ + uint8_t r; + /* Green value of this pixel. */ + uint8_t g; + /* Blue value of this pixel. */ + uint8_t b; +} RGB888Pixel; + +/** + Holds the value of two pixels in YUV422 format (Luminance/Chrominance,16-bits/pixel). + The first pixel has the values y1, u, v. + The second pixel has the values y2, u, v. +*/ +typedef struct +{ + /** First chrominance value for two pixels, stored as blue luminance difference signal. */ + uint8_t u; + /** Overall luminance value of first pixel. */ + uint8_t y1; + /** Second chrominance value for two pixels, stored as red luminance difference signal. */ + uint8_t v; + /** Overall luminance value of second pixel. */ + uint8_t y2; +} YUV422DoublePixel; + +/** This special URI can be passed to @ref Device::open() when the application has no concern for a specific device. */ +#if ONI_PLATFORM != ONI_PLATFORM_WIN32 +#pragma GCC diagnostic ignored "-Wunused-variable" +#pragma GCC diagnostic push +#endif +static const char* ANY_DEVICE = NULL; +#if ONI_PLATFORM != ONI_PLATFORM_WIN32 +#pragma GCC diagnostic pop +#endif + +/** +Provides a simple array class used throughout the API. Wraps a primitive array +of objects, holding the elements and their count. +*/ +template +class Array +{ +public: + /** + Default constructor. Creates an empty Array and sets the element count to zero. + */ + Array() : m_data(NULL), m_count(0), m_owner(false) {} + + /** + Constructor. Creates new Array from an existing primitive array of known size. + + @tparam [in] T Object type this Array will contain. + @param [in] data Pointer to a primitive array of objects of type T. + @param [in] count Number of elements in the primitive array pointed to by data. + */ + Array(const T* data, int count) : m_owner(false) { _setData(data, count); } + + /** + Destructor. Destroys the Array object. + */ + ~Array() + { + clear(); + } + + /** + Getter function for the Array size. + @returns Current number of elements in the Array. + */ + int getSize() const { return m_count; } + + /** + Implements the array indexing operator for the Array class. + */ + const T& operator[](int index) const {return m_data[index];} + + /** + @internal + Setter function for data. Causes this array to wrap an existing primitive array + of specified type. The optional data ownership flag controls whether the primitive + array this Array wraps will be destroyed when this Array is deconstructed. + @param [in] T Type of objects array will contain. + @param [in] data Pointer to first object in list. + @param [in] count Number of objects in list. + @param [in] isOwner Optional flag to indicate data ownership + */ + void _setData(const T* data, int count, bool isOwner = false) + { + clear(); + m_count = count; + m_owner = isOwner; + if (!isOwner) + { + m_data = data; + } + else + { + m_data = new T[count]; + memcpy((void*)m_data, data, count*sizeof(T)); + } + } + +private: + Array(const Array&); + Array& operator=(const Array&); + + void clear() + { + if (m_owner && m_data != NULL) + delete []m_data; + m_owner = false; + m_data = NULL; + m_count = 0; + } + + const T* m_data; + int m_count; + bool m_owner; +}; + +// Forward declaration of all +class SensorInfo; +class VideoStream; +class VideoFrameRef; +class Device; +class OpenNI; +class CameraSettings; +class PlaybackControl; + +/** +Encapsulates a group of settings for a @ref VideoStream. Settings stored include +frame rate, resolution, and pixel format. + +This class is used as an input for changing the settings of a @ref VideoStream, +as well as an output for reporting the current settings of that class. It is also used +by @ref SensorInfo to report available video modes of a stream. + +Recommended practice is to use @ref SensorInfo::getSupportedVideoModes() +to obtain a list of valid video modes, and then to use items from that list to pass +new settings to @ref VideoStream. This is much less likely to produce an +invalid video mode than instantiating and manually changing objects of this +class. +*/ +class VideoMode : private OniVideoMode +{ +public: + /** + Default constructor, creates an empty VideoMode object. Application programs should, in most + cases, use the copy constructor to copy an existing valid video mode. This is much less + error prone that creating and attempting to configure a new VideoMode from scratch. + */ + VideoMode() + {} + + /** + Copy constructor, creates a new VideoMode identical to an existing VideoMode. + + @param [in] other Existing VideoMode to copy. + */ + VideoMode(const VideoMode& other) + { + *this = other; + } + + /** + Assignment operator. Sets the pixel format, frame rate, and resolution of this + VideoMode to equal that of a different VideoMode. + + @param [in] other Existing VideoMode to copy settings from. + */ + VideoMode& operator=(const VideoMode& other) + { + setPixelFormat(other.getPixelFormat()); + setResolution(other.getResolutionX(), other.getResolutionY()); + setFps(other.getFps()); + + return *this; + } + + /** + Getter function for the pixel format of this VideoMode. + @returns Current pixel format setting of this VideoMode. + */ + PixelFormat getPixelFormat() const { return (PixelFormat)pixelFormat; } + + /** + Getter function for the X resolution of this VideoMode. + @returns Current horizontal resolution of this VideoMode, in pixels. + */ + int getResolutionX() const { return resolutionX; } + + /** + Getter function for the Y resolution of this VideoMode. + @returns Current vertical resolution of this VideoMode, in pixels. + */ + int getResolutionY() const {return resolutionY;} + + /** + Getter function for the frame rate of this VideoMode. + @returns Current frame rate, measured in frames per second. + */ + int getFps() const { return fps; } + + /** + Setter function for the pixel format of this VideoMode. Application use of this + function is not recommended. Instead, use @ref SensorInfo::getSupportedVideoModes() + to obtain a list of valid video modes. + @param [in] format Desired new pixel format for this VideoMode. + */ + void setPixelFormat(PixelFormat format) { this->pixelFormat = (OniPixelFormat)format; } + + /** + Setter function for the resolution of this VideoMode. Application use of this + function is not recommended. Instead, use @ref SensorInfo::getSupportedVideoModes() to + obtain a list of valid video modes. + @param [in] resolutionX Desired new horizontal resolution in pixels. + @param [in] resolutionY Desired new vertical resolution in pixels. + */ + void setResolution(int resolutionX, int resolutionY) + { + this->resolutionX = resolutionX; + this->resolutionY = resolutionY; + } + + /** + Setter function for the frame rate. Application use of this function is not recommended. + Instead, use @ref SensorInfo::getSupportedVideoModes() to obtain a list of valid + video modes. + @param [in] fps Desired new frame rate, measured in frames per second. + */ + void setFps(int fps) { this->fps = fps; } + + friend class SensorInfo; + friend class VideoStream; + friend class VideoFrameRef; +}; + +/** +The SensorInfo class encapsulates all info related to a specific sensor in a specific +device. +A @ref Device object holds a SensorInfo object for each sensor it contains. +A @ref VideoStream object holds one SensorInfo object, describing the sensor used to produce that stream. + +A given SensorInfo object will contain the type of the sensor (Depth, IR or Color), and +a list of all video modes that the sensor can support. Each available video mode will have a single +VideoMode object that can be queried to get the details of that mode. + +SensorInfo objects should be the only source of VideoMode objects for the vast majority of +application programs. + +Application programs will never directly instantiate objects of type SensorInfo. In fact, no +public constructors are provided. SensorInfo objects should be obtained either from a Device or @ref VideoStream, +and in turn be used to provide available video modes for that sensor. +*/ +class SensorInfo +{ +public: + /** + Provides the sensor type of the sensor this object is associated with. + @returns Type of the sensor. + */ + SensorType getSensorType() const { return (SensorType)m_pInfo->sensorType; } + + /** + Provides a list of video modes that this sensor can support. This function is the + recommended method to be used by applications to obtain @ref VideoMode objects. + + @returns Reference to an array of @ref VideoMode objects, one for each supported + video mode. + */ + const Array& getSupportedVideoModes() const { return m_videoModes; } + +private: + SensorInfo(const SensorInfo&); + SensorInfo& operator=(const SensorInfo&); + + SensorInfo() : m_pInfo(NULL), m_videoModes(NULL, 0) {} + + SensorInfo(const OniSensorInfo* pInfo) : m_pInfo(NULL), m_videoModes(NULL, 0) + { + _setInternal(pInfo); + } + + void _setInternal(const OniSensorInfo* pInfo) + { + m_pInfo = pInfo; + if (pInfo == NULL) + { + m_videoModes._setData(NULL, 0); + } + else + { + m_videoModes._setData(static_cast(pInfo->pSupportedVideoModes), pInfo->numSupportedVideoModes); + } + } + + const OniSensorInfo* m_pInfo; + Array m_videoModes; + + friend class VideoStream; + friend class Device; +}; + +/** +The DeviceInfo class encapsulates info related to a specific device. + +Applications will generally obtain objects of this type via calls to @ref OpenNI::enumerateDevices() or +@ref openni::Device::getDeviceInfo(), and then use the various accessor functions to obtain specific +information on that device. + +There should be no reason for application code to instantiate this object directly. +*/ +class DeviceInfo : private OniDeviceInfo +{ +public: + /** + Returns the device URI. URI can be used by @ref Device::open to open a specific device. + The URI string format is determined by the driver. + */ + const char* getUri() const { return uri; } + /** Returns a the vendor name for this device. */ + const char* getVendor() const { return vendor; } + /** Returns the device name for this device. */ + const char* getName() const { return name; } + /** Returns the USB VID code for this device. */ + uint16_t getUsbVendorId() const { return usbVendorId; } + /** Returns the USB PID code for this device. */ + uint16_t getUsbProductId() const { return usbProductId; } + + friend class Device; + friend class OpenNI; +}; + +/** +The @ref VideoFrameRef class encapsulates a single video frame - the output of a @ref VideoStream at a specific time. +The data contained will be a single frame of color, IR, or depth video, along with associated meta data. + +An object of type @ref VideoFrameRef does not actually hold the data of the frame, but only a reference to it. The +reference can be released by destroying the @ref VideoFrameRef object, or by calling the @ref release() method. The +actual data of the frame is freed when the last reference to it is released. + +The usual way to obtain @ref VideoFrameRef objects is by a call to @ref VideoStream.:readFrame(). + +All data references by a @ref VideoFrameRef is stored as a primitive array of pixels. Each pixel will be +of a type according to the configured pixel format (see @ref VideoMode). +*/ +class VideoFrameRef +{ +public: + /** + Default constructor. Creates a new empty @ref VideoFrameRef object. + This object will be invalid until initialized by a call to @ref VideoStream::readFrame(). + */ + VideoFrameRef() + { + m_pFrame = NULL; + } + + /** + Destroy this object and release the reference to the frame. + */ + ~VideoFrameRef() + { + release(); + } + + /** + Copy constructor. Creates a new @ref VideoFrameRef object. The newly created + object will reference the same frame current object references. + @param [in] other Another @ref VideoFrameRef object. + */ + VideoFrameRef(const VideoFrameRef& other) : m_pFrame(NULL) + { + _setFrame(other.m_pFrame); + } + + /** + Make this @ref VideoFrameRef object reference the same frame that the @c other frame references. + If this object referenced another frame before calling this method, the previous frame will be released. + @param [in] other Another @ref VideoFrameRef object. + */ + VideoFrameRef& operator=(const VideoFrameRef& other) + { + _setFrame(other.m_pFrame); + return *this; + } + + /** + Getter function for the size of the data contained by this object. Useful primarily + when allocating buffers. + @returns Current size of data pointed to by this object, measured in bytes. + */ + inline int getDataSize() const + { + return m_pFrame->dataSize; + } + + /** + Getter function for the array of data pointed to by this object. + @returns Pointer to the actual frame data array. Type of data + pointed to can be determined according to the pixel format (can be obtained by calling @ref getVideoMode()). + */ + inline const void* getData() const + { + return m_pFrame->data; + } + + /** + Getter function for the sensor type used to produce this frame. Used to determine whether + this is an IR, Color or Depth frame. See the @ref SensorType enumeration for all possible return + values from this function. + @returns The type of sensor used to produce this frame. + */ + inline SensorType getSensorType() const + { + return (SensorType)m_pFrame->sensorType; + } + + /** + Returns a reference to the @ref VideoMode object assigned to this frame. This object describes + the video mode the sensor was configured to when the frame was produced and can be used + to determine the pixel format and resolution of the data. It will also provide the frame rate + that the sensor was running at when it recorded this frame. + @returns Reference to the @ref VideoMode assigned to this frame. + */ + inline const VideoMode& getVideoMode() const + { + return static_cast(m_pFrame->videoMode); + } + + /** + Provides a timestamp for the frame. The 'zero' point for this stamp + is implementation specific, but all streams from the same device are guaranteed to use the same zero. + This value can therefore be used to compute time deltas between frames from the same device, + regardless of whether they are from the same stream. + @returns Timestamp of frame, measured in microseconds from an arbitrary zero + */ + inline uint64_t getTimestamp() const + { + return m_pFrame->timestamp; + } + + /** + Frames are provided sequential frame ID numbers by the sensor that produced them. If frame + synchronization has been enabled for a device via @ref Device::setDepthColorSyncEnabled(), then frame + numbers for corresponding frames of depth and color are guaranteed to match. + + If frame synchronization is not enabled, then there is no guarantee of matching frame indexes between + @ref VideoStream "VideoStreams". In the latter case, applications should use timestamps instead of frame indexes to + align frames in time. + @returns Index number for this frame. + */ + inline int getFrameIndex() const + { + return m_pFrame->frameIndex; + } + + /** + Gives the current width of this frame, measured in pixels. If cropping is enabled, this will be + the width of the cropping window. If cropping is not enabled, then this will simply be equal to + the X resolution of the @ref VideoMode used to produce this frame. + @returns Width of this frame in pixels. + */ + inline int getWidth() const + { + return m_pFrame->width; + } + + /** + Gives the current height of this frame, measured in pixels. If cropping is enabled, this will + be the length of the cropping window. If cropping is not enabled, then this will simply be equal + to the Y resolution of the @ref VideoMode used to produce this frame. + */ + inline int getHeight() const + { + return m_pFrame->height; + } + + /** + Indicates whether cropping was enabled when the frame was produced. + @return true if cropping is enabled, false otherwise + */ + inline bool getCroppingEnabled() const + { + return m_pFrame->croppingEnabled == TRUE; + } + + /** + Indicates the X coordinate of the upper left corner of the crop window. + @return Distance of crop origin from left side of image, in pixels. + */ + inline int getCropOriginX() const + { + return m_pFrame->cropOriginX; + } + + /** + Indicates the Y coordinate of the upper left corner of the crop window. + @return Distance of crop origin from top of image, in pixels. + */ + inline int getCropOriginY() const + { + return m_pFrame->cropOriginY; + } + + /** + Gives the length of one row of pixels, measured in bytes. Primarily useful + for indexing the array which contains the data. + @returns Stride of the array which contains the image for this frame, in bytes + */ + inline int getStrideInBytes() const + { + return m_pFrame->stride; + } + + /** + Check if this object references an actual frame. + */ + inline bool isValid() const + { + return m_pFrame != NULL; + } + + /** + Release the reference to the frame. Once this method is called, the object becomes invalid, and no method + should be called other than the assignment operator, or passing this object to a @ref VideoStream::readFrame() call. + */ + void release() + { + if (m_pFrame != NULL) + { + oniFrameRelease(m_pFrame); + m_pFrame = NULL; + } + } + + /** @internal */ + void _setFrame(OniFrame* pFrame) + { + setReference(pFrame); + if (pFrame != NULL) + { + oniFrameAddRef(pFrame); + } + } + + /** @internal */ + OniFrame* _getFrame() + { + return m_pFrame; + } + +private: + friend class VideoStream; + inline void setReference(OniFrame* pFrame) + { + // Initial - don't addref. This is the reference from OpenNI + release(); + m_pFrame = pFrame; + } + + OniFrame* m_pFrame; // const!!? +}; + +/** +The @ref VideoStream object encapsulates a single video stream from a device. Once created, it is used to start data flow +from the device, and to read individual frames of data. This is the central class used to obtain data in OpenNI. It +provides the ability to manually read data in a polling loop, as well as providing events and a Listener class that can be +used to implement event-driven data acquisition. + +Aside from the video data frames themselves, the class offers a number of functions used for obtaining information about a +@ref VideoStream. Field of view, available video modes, and minimum and maximum valid pixel values can all be obtained. + +In addition to obtaining data, the @ref VideoStream object is used to set all configuration properties that apply to a specific +stream (rather than to an entire device). In particular, it is used to control cropping, mirroring, and video modes. + +A pointer to a valid, initialized device that provides the desired stream type is required to create a stream. + +Several video streams can be created to stream data from the same sensor. This is useful if several components of an application +need to read frames separately. + +While some device might allow different streams +from the same sensor to have different configurations, most devices will have a single configuration for the sensor, +shared by all streams. +*/ +class VideoStream +{ +public: + /** + The @ref VideoStream::NewFrameListener class is provided to allow the implementation of event driven frame reading. To use + it, create a class that inherits from it and implement override the onNewFrame() method. Then, register + your created class with an active @ref VideoStream using the @ref VideoStream::addNewFrameListener() function. Once this is done, the + event handler function you implemented will be called whenever a new frame becomes available. You may call + @ref VideoStream::readFrame() from within the event handler. + */ + class NewFrameListener + { + public: + /** + Default constructor. + */ + NewFrameListener() : m_callbackHandle(NULL) + { + } + + virtual ~NewFrameListener() + { + } + + /** + Derived classes should implement this function to handle new frames. + */ + virtual void onNewFrame(VideoStream&) = 0; + + private: + friend class VideoStream; + + static void ONI_CALLBACK_TYPE callback(OniStreamHandle streamHandle, void* pCookie) + { + NewFrameListener* pListener = (NewFrameListener*)pCookie; + VideoStream stream; + stream._setHandle(streamHandle); + pListener->onNewFrame(stream); + stream._setHandle(NULL); + } + OniCallbackHandle m_callbackHandle; + }; + + class FrameAllocator + { + public: + virtual ~FrameAllocator() {} + virtual void* allocateFrameBuffer(int size) = 0; + virtual void freeFrameBuffer(void* data) = 0; + + private: + friend class VideoStream; + + static void* ONI_CALLBACK_TYPE allocateFrameBufferCallback(int size, void* pCookie) + { + FrameAllocator* pThis = (FrameAllocator*)pCookie; + return pThis->allocateFrameBuffer(size); + } + + static void ONI_CALLBACK_TYPE freeFrameBufferCallback(void* data, void* pCookie) + { + FrameAllocator* pThis = (FrameAllocator*)pCookie; + pThis->freeFrameBuffer(data); + } + }; + + /** + Default constructor. Creates a new, non-valid @ref VideoStream object. The object created will be invalid until its create() function + is called with a valid Device. + */ + VideoStream() : m_stream(NULL), m_sensorInfo(), m_pCameraSettings(NULL), m_isOwner(true) + {} + + /** + Handle constructor. Creates a VideoStream object based on the given initialized handle. + This object will not destroy the underlying handle when @ref destroy() or destructor is called + */ + explicit VideoStream(OniStreamHandle handle) : m_stream(NULL), m_sensorInfo(), m_pCameraSettings(NULL), m_isOwner(false) + { + _setHandle(handle); + } + + /** + Destructor. The destructor calls the destroy() function, but it is considered a best practice for applications to + call destroy() manually on any @ref VideoStream that they run create() on. + */ + ~VideoStream() + { + destroy(); + } + + /** + Checks to see if this object has been properly initialized and currently points to a valid stream. + @returns true if this object has been previously initialized, false otherwise. + */ + bool isValid() const + { + return m_stream != NULL; + } + + /** + Creates a stream of frames from a specific sensor type of a specific device. You must supply a reference to a + Device that supplies the sensor type requested. You can use @ref Device::hasSensor() to check whether a + given sensor is available on your target device before calling create(). + + @param [in] device A reference to the @ref Device you want to create the stream on. + @param [in] sensorType The type of sensor the stream should produce data from. + @returns Status code indicating success or failure for this operation. + */ + inline Status create(const Device& device, SensorType sensorType); + + /** + Destroy this stream. This function is currently called automatically by the destructor, but it is + considered a best practice for applications to manually call this function on any @ref VideoStream that they + call create() for. + */ + inline void destroy(); + + /** + Provides the @ref SensorInfo object associated with the sensor that is producing this @ref VideoStream. Note that + this function will return NULL if the stream has not yet been initialized with the create() function. + + @ref SensorInfo is useful primarily as a means of learning which video modes are valid for this VideoStream. + + @returns Reference to the SensorInfo object associated with the sensor providing this stream. + */ + const SensorInfo& getSensorInfo() const + { + return m_sensorInfo; + } + + /** + Starts data generation from this video stream. + */ + Status start() + { + if (!isValid()) + { + return STATUS_ERROR; + } + + return (Status)oniStreamStart(m_stream); + } + + /** + Stops data generation from this video stream. + */ + void stop() + { + if (!isValid()) + { + return; + } + + oniStreamStop(m_stream); + } + + /** + Read the next frame from this video stream, delivered as a @ref VideoFrameRef. This is the primary + method for manually obtaining frames of video data. + If no new frame is available, the call will block until one is available. + To avoid blocking, use @ref VideoStream::Listener to implement an event driven architecture. Another + alternative is to use @ref OpenNI::waitForAnyStream() to wait for new frames from several streams. + + @param [out] pFrame Pointer to a @ref VideoFrameRef object to hold the reference to the new frame. + @returns Status code to indicated success or failure of this function. + */ + Status readFrame(VideoFrameRef* pFrame) + { + if (!isValid()) + { + return STATUS_ERROR; + } + + OniFrame* pOniFrame; + Status rc = (Status)oniStreamReadFrame(m_stream, &pOniFrame); + + pFrame->setReference(pOniFrame); + return rc; + } + + /** + Adds a new Listener to receive this VideoStream onNewFrame event. See @ref VideoStream::NewFrameListener for + more information on implementing an event driven frame reading architecture. An instance of a listener can be added to only one source. + + @param [in] pListener Pointer to a @ref VideoStream::NewFrameListener object (or a derivative) that will respond to this event. + @returns Status code indicating success or failure of the operation. + */ + Status addNewFrameListener(NewFrameListener* pListener) + { + if (!isValid()) + { + return STATUS_ERROR; + } + + return (Status)oniStreamRegisterNewFrameCallback(m_stream, pListener->callback, pListener, &pListener->m_callbackHandle); + } + + /** + Removes a Listener from this video stream list. The listener removed will no longer receive new frame events from this stream. + @param [in] pListener Pointer to the listener object to be removed. + */ + void removeNewFrameListener(NewFrameListener* pListener) + { + if (!isValid()) + { + return; + } + + oniStreamUnregisterNewFrameCallback(m_stream, pListener->m_callbackHandle); + pListener->m_callbackHandle = NULL; + } + + /** + Sets the frame buffers allocator for this video stream. + @param [in] pAllocator Pointer to the frame buffers allocator object. Pass NULL to return to default frame allocator. + @returns ONI_STATUS_OUT_OF_FLOW The frame buffers allocator cannot be set while stream is streaming. + */ + Status setFrameBuffersAllocator(FrameAllocator* pAllocator) + { + if (!isValid()) + { + return STATUS_ERROR; + } + + if (pAllocator == NULL) + { + return (Status)oniStreamSetFrameBuffersAllocator(m_stream, NULL, NULL, NULL); + } + else + { + return (Status)oniStreamSetFrameBuffersAllocator(m_stream, pAllocator->allocateFrameBufferCallback, pAllocator->freeFrameBufferCallback, pAllocator); + } + } + + /** + @internal + Get an internal handle. This handle can be used via the C API. + */ + OniStreamHandle _getHandle() const + { + return m_stream; + } + + /** + Gets an object through which several camera settings can be configured. + @returns NULL if the stream doesn't support camera settings. + */ + CameraSettings* getCameraSettings() {return m_pCameraSettings;} + + /** + General function for obtaining the value of stream specific properties. + There are convenience functions available for all commonly used properties, so it is not + expected that applications will make direct use of the getProperty function very often. + + @param [in] propertyId The numerical ID of the property to be queried. + @param [out] data Place to store the value of the property. + @param [in,out] dataSize IN: Size of the buffer passed in the @c data argument. OUT: the actual written size. + @returns Status code indicating success or failure of this operation. + */ + Status getProperty(int propertyId, void* data, int* dataSize) const + { + if (!isValid()) + { + return STATUS_ERROR; + } + + return (Status)oniStreamGetProperty(m_stream, propertyId, data, dataSize); + } + + /** + General function for setting the value of stream specific properties. + There are convenience functions available for all commonly used properties, so it is not + expected that applications will make direct use of the setProperty function very often. + + @param [in] propertyId The numerical ID of the property to be set. + @param [in] data Place to store the data to be written to the property. + @param [in] dataSize Size of the data to be written to the property. + @returns Status code indicating success or failure of this operation. + */ + Status setProperty(int propertyId, const void* data, int dataSize) + { + if (!isValid()) + { + return STATUS_ERROR; + } + + return (Status)oniStreamSetProperty(m_stream, propertyId, data, dataSize); + } + + /** + Get the current video mode information for this video stream. + This includes its resolution, fps and stream format. + + @returns Current video mode information for this video stream. + */ + VideoMode getVideoMode() const + { + VideoMode videoMode; + getProperty(STREAM_PROPERTY_VIDEO_MODE, static_cast(&videoMode)); + return videoMode; + } + + /** + Changes the current video mode of this stream. Recommended practice is to use @ref Device::getSensorInfo(), and + then @ref SensorInfo::getSupportedVideoModes() to obtain a list of valid video mode settings for this stream. Then, + pass a valid @ref VideoMode to @ref setVideoMode to ensure correct operation. + + @param [in] videoMode Desired new video mode for this stream. + returns Status code indicating success or failure of this operation. + */ + Status setVideoMode(const VideoMode& videoMode) + { + return setProperty(STREAM_PROPERTY_VIDEO_MODE, static_cast(videoMode)); + } + + /** + Provides the maximum possible value for pixels obtained by this stream. This is most useful for + getting the maximum possible value of depth streams. + @returns Maximum possible pixel value. + */ + int getMaxPixelValue() const + { + int maxValue; + Status rc = getProperty(STREAM_PROPERTY_MAX_VALUE, &maxValue); + if (rc != STATUS_OK) + { + return 0; + } + return maxValue; + } + + /** + Provides the smallest possible value for pixels obtains by this VideoStream. This is most useful + for getting the minimum possible value that will be reported by a depth stream. + @returns Minimum possible pixel value that can come from this stream. + */ + int getMinPixelValue() const + { + int minValue; + Status rc = getProperty(STREAM_PROPERTY_MIN_VALUE, &minValue); + if (rc != STATUS_OK) + { + return 0; + } + return minValue; + } + + /** + Checks whether this stream supports cropping. + @returns true if the stream supports cropping, false if it does not. + */ + bool isCroppingSupported() const + { + return isPropertySupported(STREAM_PROPERTY_CROPPING); + } + + /** + Obtains the current cropping settings for this stream. + @param [out] pOriginX X coordinate of the upper left corner of the cropping window + @param [out] pOriginY Y coordinate of the upper left corner of the cropping window + @param [out] pWidth Horizontal width of the cropping window, in pixels + @param [out] pHeight Vertical width of the cropping window, in pixels + returns true if cropping is currently enabled, false if it is not. + */ + bool getCropping(int* pOriginX, int* pOriginY, int* pWidth, int* pHeight) const + { + OniCropping cropping; + bool enabled = false; + + Status rc = getProperty(STREAM_PROPERTY_CROPPING, &cropping); + + if (rc == STATUS_OK) + { + *pOriginX = cropping.originX; + *pOriginY = cropping.originY; + *pWidth = cropping.width; + *pHeight = cropping.height; + enabled = (cropping.enabled == TRUE); + } + + return enabled; + } + + /** + Changes the cropping settings for this stream. You can use the @ref isCroppingSupported() + function to make sure cropping is supported before calling this function. + @param [in] originX New X coordinate of the upper left corner of the cropping window. + @param [in] originY New Y coordinate of the upper left corner of the cropping window. + @param [in] width New horizontal width for the cropping window, in pixels. + @param [in] height New vertical height for the cropping window, in pixels. + @returns Status code indicating success or failure of this operation. + */ + Status setCropping(int originX, int originY, int width, int height) + { + OniCropping cropping; + cropping.enabled = true; + cropping.originX = originX; + cropping.originY = originY; + cropping.width = width; + cropping.height = height; + return setProperty(STREAM_PROPERTY_CROPPING, cropping); + } + + /** + Disables cropping. + @returns Status code indicating success or failure of this operation. + */ + Status resetCropping() + { + OniCropping cropping; + cropping.enabled = false; + return setProperty(STREAM_PROPERTY_CROPPING, cropping); + } + + /** + Check whether mirroring is currently turned on for this stream. + @returns true if mirroring is currently enabled, false otherwise. + */ + bool getMirroringEnabled() const + { + OniBool enabled; + Status rc = getProperty(STREAM_PROPERTY_MIRRORING, &enabled); + if (rc != STATUS_OK) + { + return false; + } + return enabled == TRUE; + } + + /** + Enable or disable mirroring for this stream. + @param [in] isEnabled true to enable mirroring, false to disable it. + @returns Status code indicating the success or failure of this operation. + */ + Status setMirroringEnabled(bool isEnabled) + { + return setProperty(STREAM_PROPERTY_MIRRORING, isEnabled ? TRUE : FALSE); + } + + /** + Gets the horizontal field of view of frames received from this stream. + @returns Horizontal field of view, in radians. + */ + float getHorizontalFieldOfView() const + { + float horizontal = 0; + getProperty(STREAM_PROPERTY_HORIZONTAL_FOV, &horizontal); + return horizontal; + } + + /** + Gets the vertical field of view of frames received from this stream. + @returns Vertical field of view, in radians. + */ + float getVerticalFieldOfView() const + { + float vertical = 0; + getProperty(STREAM_PROPERTY_VERTICAL_FOV, &vertical); + return vertical; + } + + /** + Function for setting a value of a stream property using an arbitrary input type. + There are convenience functions available for all commonly used properties, so it is not + expected that applications will make direct use of this function very often. + @tparam [in] T Data type of the value to be passed to the property. + @param [in] propertyId The numerical ID of the property to be set. + @param [in] value Data to be sent to the property. + @returns Status code indicating success or failure of this operation. + */ + template + Status setProperty(int propertyId, const T& value) + { + return setProperty(propertyId, &value, sizeof(T)); + } + + /** + Function for getting the value from a property using an arbitrary output type. + There are convenience functions available for all commonly used properties, so it is not + expected that applications will make direct use of this function very often. + @tparam [in] T Data type of the value to be read. + @param [in] propertyId The numerical ID of the property to be read. + @param [in, out] value Pointer to a place to store the value read from the property. + @returns Status code indicating success or failure of this operation. + */ + template + Status getProperty(int propertyId, T* value) const + { + int size = sizeof(T); + return getProperty(propertyId, value, &size); + } + + /** + Checks if a specific property is supported by the video stream. + @param [in] propertyId Property to be checked. + @returns true if the property is supported, false otherwise. + */ + bool isPropertySupported(int propertyId) const + { + if (!isValid()) + { + return false; + } + + return oniStreamIsPropertySupported(m_stream, propertyId) == TRUE; + } + + /** + Invokes a command that takes an arbitrary data type as its input. It is not expected that + application code will need this function frequently, as all commonly used properties have + higher level functions provided. + @param [in] commandId Numerical code of the property to be invoked. + @param [in] data Data to be passed to the property. + @param [in] dataSize size of the buffer passed in @c data. + @returns Status code indicating success or failure of this operation. + */ + Status invoke(int commandId, void* data, int dataSize) + { + if (!isValid()) + { + return STATUS_ERROR; + } + + return (Status)oniStreamInvoke(m_stream, commandId, data, dataSize); + } + + /** + Invokes a command that takes an arbitrary data type as its input. It is not expected that + application code will need this function frequently, as all commonly used properties have + higher level functions provided. + @tparam [in] T Type of data to be passed to the property. + @param [in] commandId Numerical code of the property to be invoked. + @param [in] value Data to be passed to the property. + @returns Status code indicating success or failure of this operation. + */ + template + Status invoke(int commandId, T& value) + { + return invoke(commandId, &value, sizeof(T)); + } + + /** + Checks if a specific command is supported by the video stream. + @param [in] commandId Command to be checked. + @returns true if the command is supported, false otherwise. + */ + bool isCommandSupported(int commandId) const + { + if (!isValid()) + { + return false; + } + + return (Status)oniStreamIsCommandSupported(m_stream, commandId) == TRUE; + } + +private: + friend class Device; + + void _setHandle(OniStreamHandle stream) + { + m_sensorInfo._setInternal(NULL); + m_stream = stream; + + if (stream != NULL) + { + m_sensorInfo._setInternal(oniStreamGetSensorInfo(m_stream)); + } + } + +private: + VideoStream(const VideoStream& other); + VideoStream& operator=(const VideoStream& other); + + OniStreamHandle m_stream; + SensorInfo m_sensorInfo; + CameraSettings* m_pCameraSettings; + bool m_isOwner; +}; + +/** +The Device object abstracts a specific device; either a single hardware device, or a file +device holding a recording from a hardware device. It offers the ability to connect to +the device, and obtain information about its configuration and the data streams it can offer. + +It provides the means to query and change all configuration parameters that apply to the +device as a whole. This includes enabling depth/color image registration and frame +synchronization. + +Devices are used when creating and initializing @ref VideoStream "VideoStreams" -- you will need a valid pointer to +a Device in order to use the VideoStream.create() function. This, along with configuration, is +the primary use of this class for application developers. + +Before devices can be created, @ref OpenNI::initialize() must have been run to make the device drivers +on the system available to the API. +*/ +class Device +{ +public: + /** + Default constructor. Creates a new empty Device object. This object will be invalid until it is initialized by + calling its open() function. + */ + Device() : m_pPlaybackControl(NULL), m_device(NULL), m_isOwner(true) + { + clearSensors(); + } + + /** + Handle constructor. Creates a Device object based on the given initialized handle. + This object will not destroy the underlying handle when @ref close() or destructor is called + */ + explicit Device(OniDeviceHandle handle) : m_pPlaybackControl(NULL), m_device(NULL), m_isOwner(false) + { + _setHandle(handle); + } + + /** + The destructor calls the @ref close() function, but it is considered a best practice for applications to + call @ref close() manually on any @ref Device that they run @ref open() on. + */ + ~Device() + { + if (m_device != NULL) + { + close(); + } + } + + /** + Opens a device. This can either open a device chosen arbitrarily from all devices + on the system, or open a specific device selected by passing this function the device URI. + + To open any device, simply pass the constant@ref ANY_DEVICE to this function. If multiple + devices are connected to the system, then one of them will be opened. This procedure is most + useful when it is known that exactly one device is (or can be) connected to the system. In that case, + requesting a list of all devices and iterating through it would be a waste of effort. + + If multiple devices are (or may be) connected to a system, then a URI will be required to select + a specific device to open. There are two ways to obtain a URI: from a DeviceConnected event, or + by calling @ref OpenNI::enumerateDevices(). + + In the case of a DeviceConnected event, the @ref OpenNI::Listener will be provided with a DeviceInfo object + as an argument to its @ref OpenNI::Listener::onDeviceConnected "onDeviceConnected()" function. + The DeviceInfo.getUri() function can then be used to obtain the URI. + + If the application is not using event handlers, then it can also call the static function + @ref OpenNI::enumerateDevices(). This will return an array of @ref DeviceInfo objects, one for each device + currently available to the system. The application can then iterate through this list and + select the desired device. The URI is again obtained via the @ref DeviceInfo::getUri() function. + + Standard codes of type Status are returned indicating whether opening was successful. + + @param [in] uri String containing the URI of the device to be opened, or @ref ANY_DEVICE. + @returns Status code with the outcome of the open operation. + + @remark For opening a recording file, pass the file path as a uri. + */ + inline Status open(const char* uri); + + /** + Closes the device. This properly closes any files or shuts down hardware, as appropriate. This + function is currently called by the destructor if not called manually by application code, but it + is considered a best practice to manually close any device that was opened. + */ + inline void close(); + + /** + Provides information about this device in the form of a DeviceInfo object. This object can + be used to access the URI of the device, as well as various USB descriptor strings that might + be useful to an application. + + Note that valid device info will not be available if this device has not yet been opened. If you are + trying to obtain a URI to open a device, use OpenNI::enumerateDevices() instead. + @returns DeviceInfo object for this Device + */ + const DeviceInfo& getDeviceInfo() const + { + return m_deviceInfo; + } + + /** + This function checks to see if one of the specific sensor types defined in @ref SensorType is + available on this device. This allows an application to, for example, query for the presence + of a depth sensor, or color sensor. + @param [in] sensorType of sensor to query for + @returns true if the Device supports the sensor queried, false otherwise. + */ + bool hasSensor(SensorType sensorType) + { + int i; + for (i = 0; (i < ONI_MAX_SENSORS) && (m_aSensorInfo[i].m_pInfo != NULL); ++i) + { + if (m_aSensorInfo[i].getSensorType() == sensorType) + { + return true; + } + } + + if (i == ONI_MAX_SENSORS) + { + return false; + } + + const OniSensorInfo* pInfo = oniDeviceGetSensorInfo(m_device, (OniSensorType)sensorType); + + if (pInfo == NULL) + { + return false; + } + + m_aSensorInfo[i]._setInternal(pInfo); + + return true; + } + + /** + Get the @ref SensorInfo for a specific sensor type on this device. The @ref SensorInfo + is useful primarily for determining which video modes are supported by the sensor. + @param [in] sensorType of sensor to get information about. + @returns SensorInfo object corresponding to the sensor type specified, or NULL if such a sensor + is not available from this device. + */ + const SensorInfo* getSensorInfo(SensorType sensorType) + { + int i; + for (i = 0; (i < ONI_MAX_SENSORS) && (m_aSensorInfo[i].m_pInfo != NULL); ++i) + { + if (m_aSensorInfo[i].getSensorType() == sensorType) + { + return &m_aSensorInfo[i]; + } + } + + // not found. check to see we have additional space + if (i == ONI_MAX_SENSORS) + { + return NULL; + } + + const OniSensorInfo* pInfo = oniDeviceGetSensorInfo(m_device, (OniSensorType)sensorType); + if (pInfo == NULL) + { + return NULL; + } + + m_aSensorInfo[i]._setInternal(pInfo); + return &m_aSensorInfo[i]; + } + + /** + @internal + Get an internal handle. This handle can be used via the C API. + */ + OniDeviceHandle _getHandle() const + { + return m_device; + } + + /** + Gets an object through which playback of a file device can be controlled. + @returns NULL if this device is not a file device. + */ + PlaybackControl* getPlaybackControl() {return m_pPlaybackControl;} + + /** + Get the value of a general property of the device. + There are convenience functions for all the commonly used properties, such as + image registration and frame synchronization. It is expected for this reason + that this function will rarely be directly used by applications. + + @param [in] propertyId Numerical ID of the property you would like to check. + @param [out] data Place to store the value of the property. + @param [in,out] dataSize IN: Size of the buffer passed in the @c data argument. OUT: the actual written size. + @returns Status code indicating results of this operation. + */ + Status getProperty(int propertyId, void* data, int* dataSize) const + { + return (Status)oniDeviceGetProperty(m_device, propertyId, data, dataSize); + } + + /** + Sets the value of a general property of the device. + There are convenience functions for all the commonly used properties, such as + image registration and frame synchronization. It is expected for this reason + that this function will rarely be directly used by applications. + + @param [in] propertyId The numerical ID of the property to be set. + @param [in] data Place to store the data to be written to the property. + @param [in] dataSize Size of the data to be written to the property. + @returns Status code indicating results of this operation. + */ + Status setProperty(int propertyId, const void* data, int dataSize) + { + return (Status)oniDeviceSetProperty(m_device, propertyId, data, dataSize); + } + + /** + Checks to see if this device can support registration of color video and depth video. + Image registration is used to properly superimpose two images from cameras located at different + points in space. Please see the OpenNi 2.0 Programmer's Guide for more information about + registration. + @returns true if image registration is supported by this device, false otherwise. + */ + bool isImageRegistrationModeSupported(ImageRegistrationMode mode) const + { + return (oniDeviceIsImageRegistrationModeSupported(m_device, (OniImageRegistrationMode)mode) == TRUE); + } + + /** + Gets the current image registration mode of this device. + Image registration is used to properly superimpose two images from cameras located at different + points in space. Please see the OpenNi 2.0 Programmer's Guide for more information about + registration. + @returns Current image registration mode. See @ref ImageRegistrationMode for possible return values. + */ + ImageRegistrationMode getImageRegistrationMode() const + { + ImageRegistrationMode mode; + Status rc = getProperty(DEVICE_PROPERTY_IMAGE_REGISTRATION, &mode); + if (rc != STATUS_OK) + { + return IMAGE_REGISTRATION_OFF; + } + return mode; + } + + /** + Sets the image registration on this device. + Image registration is used to properly superimpose two images from cameras located at different + points in space. Please see the OpenNi 2.0 Programmer's Guide for more information about + registration. + + See @ref ImageRegistrationMode for a list of valid settings to pass to this function. + + It is a good practice to first check if the mode is supported by calling @ref isImageRegistrationModeSupported(). + + @param [in] mode Desired new value for the image registration mode. + @returns Status code for the operation. + */ + Status setImageRegistrationMode(ImageRegistrationMode mode) + { + return setProperty(DEVICE_PROPERTY_IMAGE_REGISTRATION, mode); + } + + /** + Checks whether this Device object is currently connected to an actual file or hardware device. + @returns true if the Device is connected, false otherwise. + */ + bool isValid() const + { + return m_device != NULL; + } + + /** + Checks whether this device is a file device (i.e. a recording). + @returns true if this is a file device, false otherwise. + */ + bool isFile() const + { + return isPropertySupported(DEVICE_PROPERTY_PLAYBACK_SPEED) && + isPropertySupported(DEVICE_PROPERTY_PLAYBACK_REPEAT_ENABLED) && + isCommandSupported(DEVICE_COMMAND_SEEK); + } + + /** + Used to turn the depth/color frame synchronization feature on and off. When frame synchronization + is enabled, the device will deliver depth and image frames that are separated in time + by some maximum value. When disabled, the phase difference between depth and image frame + generation cannot be guaranteed. + @param [in] isEnabled Set to TRUE to enable synchronization, FALSE to disable it + @returns Status code indicating success or failure of this operation + */ + Status setDepthColorSyncEnabled(bool isEnabled) + { + Status rc = STATUS_OK; + + if (isEnabled) + { + rc = (Status)oniDeviceEnableDepthColorSync(m_device); + } + else + { + oniDeviceDisableDepthColorSync(m_device); + } + + return rc; + } + + bool getDepthColorSyncEnabled() + { + return oniDeviceGetDepthColorSyncEnabled(m_device) == TRUE; + } + + /** + Sets a property that takes an arbitrary data type as its input. It is not expected that + application code will need this function frequently, as all commonly used properties have + higher level functions provided. + + @tparam T Type of data to be passed to the property. + @param [in] propertyId The numerical ID of the property to be set. + @param [in] value Place to store the data to be written to the property. + @returns Status code indicating success or failure of this operation. + */ + template + Status setProperty(int propertyId, const T& value) + { + return setProperty(propertyId, &value, sizeof(T)); + } + + /** + Checks a property that provides an arbitrary data type as its output. It is not expected that + application code will need this function frequently, as all commonly used properties have + higher level functions provided. + @tparam [in] T Data type of the value to be read. + @param [in] propertyId The numerical ID of the property to be read. + @param [in, out] value Pointer to a place to store the value read from the property. + @returns Status code indicating success or failure of this operation. + */ + template + Status getProperty(int propertyId, T* value) const + { + int size = sizeof(T); + return getProperty(propertyId, value, &size); + } + + /** + Checks if a specific property is supported by the device. + @param [in] propertyId Property to be checked. + @returns true if the property is supported, false otherwise. + */ + bool isPropertySupported(int propertyId) const + { + return oniDeviceIsPropertySupported(m_device, propertyId) == TRUE; + } + + /** + Invokes a command that takes an arbitrary data type as its input. It is not expected that + application code will need this function frequently, as all commonly used properties have + higher level functions provided. + @param [in] commandId Numerical code of the property to be invoked. + @param [in] data Data to be passed to the property. + @param [in] dataSize size of the buffer passed in @c data. + @returns Status code indicating success or failure of this operation. + */ + Status invoke(int commandId, void* data, int dataSize) + { + return (Status)oniDeviceInvoke(m_device, commandId, data, dataSize); + } + + /** + Invokes a command that takes an arbitrary data type as its input. It is not expected that + application code will need this function frequently, as all commonly used properties have + higher level functions provided. + @tparam [in] T Type of data to be passed to the property. + @param [in] propertyId Numerical code of the property to be invoked. + @param [in] value Data to be passed to the property. + @returns Status code indicating success or failure of this operation. + */ + template + Status invoke(int propertyId, T& value) + { + return invoke(propertyId, &value, sizeof(T)); + } + + /** + Checks if a specific command is supported by the device. + @param [in] commandId Command to be checked. + @returns true if the command is supported, false otherwise. + */ + bool isCommandSupported(int commandId) const + { + return oniDeviceIsCommandSupported(m_device, commandId) == TRUE; + } + + /** @internal **/ + inline Status _openEx(const char* uri, const char* mode); + +private: + Device(const Device&); + Device& operator=(const Device&); + + void clearSensors() + { + for (int i = 0; i < ONI_MAX_SENSORS; ++i) + { + m_aSensorInfo[i]._setInternal(NULL); + } + } + + inline Status _setHandle(OniDeviceHandle deviceHandle); + +private: + PlaybackControl* m_pPlaybackControl; + + OniDeviceHandle m_device; + DeviceInfo m_deviceInfo; + SensorInfo m_aSensorInfo[ONI_MAX_SENSORS]; + + bool m_isOwner; +}; + +/** + * The PlaybackControl class provides access to a series of specific to playing back + * a recording from a file device. + * + * When playing a stream back from a recording instead of playing from a live device, + * it is possible to vary playback speed, change the current time location (ie + * fast forward / rewind / seek), specify whether the playback should be repeated at the end + * of the recording, and query the total size of the recording. + * + * Since none of these functions make sense in the context of a physical device, they are + * split out into a seperate playback control class. To use, simply create your file device, + * create a PlaybackControl, and then attach the PlaybackControl to the file device. + */ +class PlaybackControl +{ +public: + + /** + * Deconstructor. Destroys a PlaybackControl class. The deconstructor presently detaches + * from its recording automatically, but it is considered a best practice for applications to + * manually detach from any stream that was attached to. + */ + ~PlaybackControl() + { + detach(); + } + + /** + * Getter function for the current playback speed of this device. + * + * This value is expressed as a multiple of the speed the original + * recording was taken at. For example, if the original recording was at 30fps, and + * playback speed is set to 0.5, then the recording will play at 15fps. If playback speed + * is set to 2.0, then the recording would playback at 60fps. + * + * In addition, there are two "special" values. A playback speed of 0.0 indicates that the + * playback should occur as fast as the system is capable of returning frames. This is + * most useful when testing algorithms on large datasets, as it enables playback to be + * done at a much higher rate than would otherwise be possible. + * + * A value of -1 indicates that speed is "manual". In this mode, new frames will only + * become available when an application manually reads them. If used in a polling loop, + * this setting also enables systems to read and process frames limited only by + * available processing speeds. + * + * @returns Current playback speed of the device, measured as ratio of recording speed. + */ + float getSpeed() const + { + if (!isValid()) + { + return 0.0f; + } + float speed; + Status rc = m_pDevice->getProperty(DEVICE_PROPERTY_PLAYBACK_SPEED, &speed); + if (rc != STATUS_OK) + { + return 1.0f; + } + return speed; + } + /** + * Setter function for the playback speed of the device. For a full explaination of + * what this value means @see PlaybackControl::getSpeed(). + * + * @param [in] speed Desired new value of playback speed, as ratio of original recording. + * @returns Status code indicating success or failure of this operation. + */ + Status setSpeed(float speed) + { + if (!isValid()) + { + return STATUS_NO_DEVICE; + } + return m_pDevice->setProperty(DEVICE_PROPERTY_PLAYBACK_SPEED, speed); + } + + /** + * Gets the current repeat setting of the file device. + * + * @returns true if repeat is enabled, false if not enabled. + */ + bool getRepeatEnabled() const + { + if (!isValid()) + { + return false; + } + + OniBool repeat; + Status rc = m_pDevice->getProperty(DEVICE_PROPERTY_PLAYBACK_REPEAT_ENABLED, &repeat); + if (rc != STATUS_OK) + { + return false; + } + + return repeat == TRUE; + } + + /** + * Changes the current repeat mode of the device. If repeat mode is turned on, then the recording will + * begin playback again at the beginning after the last frame is read. If turned off, no more frames + * will become available after last frame is read. + * + * @param [in] repeat New value for repeat -- true to enable, false to disable + * @returns Status code indicating success or failure of this operations. + */ + Status setRepeatEnabled(bool repeat) + { + if (!isValid()) + { + return STATUS_NO_DEVICE; + } + + return m_pDevice->setProperty(DEVICE_PROPERTY_PLAYBACK_REPEAT_ENABLED, repeat ? TRUE : FALSE); + } + + /** + * Seeks within a VideoStream to a given FrameID. Note that when this function is called on one + * stream, all other streams will also be changed to the corresponding place in the recording. The FrameIDs + * of different streams may not match, since FrameIDs may differ for streams that are not synchronized, but + * the recording will set all streams to the same moment in time. + * + * @param [in] stream Stream for which the frameIndex value is valid. + * @param [in] frameIndex Frame index to move playback to + * @returns Status code indicating success or failure of this operation + */ + Status seek(const VideoStream& stream, int frameIndex) + { + if (!isValid()) + { + return STATUS_NO_DEVICE; + } + OniSeek seek; + seek.frameIndex = frameIndex; + seek.stream = stream._getHandle(); + return m_pDevice->invoke(DEVICE_COMMAND_SEEK, seek); + } + + /** + * Provides the a count of frames that this recording contains for a given stream. This is useful + * both to determine the length of the recording, and to ensure that a valid Frame Index is set when using + * the @ref PlaybackControl::seek() function. + * + * @param [in] stream The video stream to count frames for + * @returns Number of frames in provided @ref VideoStream, or 0 if the stream is not part of the recording + */ + int getNumberOfFrames(const VideoStream& stream) const + { + int numOfFrames = -1; + Status rc = stream.getProperty(STREAM_PROPERTY_NUMBER_OF_FRAMES, &numOfFrames); + if (rc != STATUS_OK) + { + return 0; + } + return numOfFrames; + } + + bool isValid() const + { + return m_pDevice != NULL; + } +private: + Status attach(Device* device) + { + if (!device->isValid() || !device->isFile()) + { + return STATUS_ERROR; + } + + detach(); + m_pDevice = device; + + return STATUS_OK; + } + void detach() + { + m_pDevice = NULL; + } + + friend class Device; + PlaybackControl(Device* pDevice) : m_pDevice(NULL) + { + if (pDevice != NULL) + { + attach(pDevice); + } + } + + Device* m_pDevice; +}; + +class CameraSettings +{ +public: + // setters + Status setAutoExposureEnabled(bool enabled) + { + return setProperty(STREAM_PROPERTY_AUTO_EXPOSURE, enabled ? TRUE : FALSE); + } + Status setAutoWhiteBalanceEnabled(bool enabled) + { + return setProperty(STREAM_PROPERTY_AUTO_WHITE_BALANCE, enabled ? TRUE : FALSE); + } + + bool getAutoExposureEnabled() const + { + OniBool enabled = FALSE; + + Status rc = getProperty(STREAM_PROPERTY_AUTO_EXPOSURE, &enabled); + return rc == STATUS_OK && enabled == TRUE; + } + bool getAutoWhiteBalanceEnabled() const + { + OniBool enabled = FALSE; + + Status rc = getProperty(STREAM_PROPERTY_AUTO_WHITE_BALANCE, &enabled); + return rc == STATUS_OK && enabled == TRUE; + } + + Status setGain(int gain) + { + return setProperty(STREAM_PROPERTY_GAIN, gain); + } + Status setExposure(int exposure) + { + return setProperty(STREAM_PROPERTY_EXPOSURE, exposure); + } + int getGain() + { + int gain; + Status rc = getProperty(STREAM_PROPERTY_GAIN, &gain); + if (rc != STATUS_OK) + { + return 100; + } + return gain; + } + int getExposure() + { + int exposure; + Status rc = getProperty(STREAM_PROPERTY_EXPOSURE, &exposure); + if (rc != STATUS_OK) + { + return 0; + } + return exposure; + } + + bool isValid() const {return m_pStream != NULL;} +private: + template + Status getProperty(int propertyId, T* value) const + { + if (!isValid()) return STATUS_NOT_SUPPORTED; + + return m_pStream->getProperty(propertyId, value); + } + template + Status setProperty(int propertyId, const T& value) + { + if (!isValid()) return STATUS_NOT_SUPPORTED; + + return m_pStream->setProperty(propertyId, value); + } + + friend class VideoStream; + CameraSettings(VideoStream* pStream) + { + m_pStream = pStream; + } + + VideoStream* m_pStream; +}; + + +/** + * The OpenNI class is a static entry point to the library. It is used by every OpenNI 2.0 + * application to initialize the SDK and drivers to enable creation of valid device objects. + * + * It also defines a listener class and events that enable for event driven notification of + * device connection, device disconnection, and device configuration changes. + * + * In addition, it gives access to SDK version information and provides a function that allows + * you to wait for data to become available on any one of a list of streams (as opposed to + * waiting for data on one specific stream with functions provided by the VideoStream class) + * +*/ +class OpenNI +{ +public: + + /** + * The OpenNI::DeviceConnectedListener class provides a means of registering for, and responding to + * when a device is connected. + * + * onDeviceConnected is called whenever a new device is connected to the system (ie this event + * would be triggered when a new sensor is manually plugged into the host system running the + * application) + * + * To use this class, you should write a new class that inherits from it, and override the + * onDeviceConnected method. Once you instantiate your class, use the + * OpenNI::addDeviceConnectedListener() function to add your listener object to OpenNI's list of listeners. Your + * handler function will then be called whenever the event occurs. A OpenNI::removeDeviceConnectedListener() + * function is also provided, if you want to have your class stop listening to these events for any + * reason. + */ + class DeviceConnectedListener + { + public: + DeviceConnectedListener() + { + m_deviceConnectedCallbacks.deviceConnected = deviceConnectedCallback; + m_deviceConnectedCallbacks.deviceDisconnected = NULL; + m_deviceConnectedCallbacks.deviceStateChanged = NULL; + m_deviceConnectedCallbacksHandle = NULL; + } + + virtual ~DeviceConnectedListener() + { + } + + /** + * Callback function for the onDeviceConnected event. This function will be + * called whenever this event occurs. When this happens, a pointer to the @ref DeviceInfo + * object for the newly connected device will be supplied. Note that once a + * device is removed, if it was opened by a @ref Device object, that object can no longer be + * used to access the device, even if it was reconnected. Once a device was reconnected, + * @ref Device::open() should be called again in order to use this device. + * + * If you wish to open the new device as it is connected, simply query the provided DeviceInfo + * object to obtain the URI of the device, and pass this URI to the Device.Open() function. + */ + virtual void onDeviceConnected(const DeviceInfo*) = 0; + private: + static void ONI_CALLBACK_TYPE deviceConnectedCallback(const OniDeviceInfo* pInfo, void* pCookie) + { + DeviceConnectedListener* pListener = (DeviceConnectedListener*)pCookie; + pListener->onDeviceConnected(static_cast(pInfo)); + } + + friend class OpenNI; + OniDeviceCallbacks m_deviceConnectedCallbacks; + OniCallbackHandle m_deviceConnectedCallbacksHandle; + + }; + /** + * The OpenNI::DeviceDisconnectedListener class provides a means of registering for, and responding to + * when a device is disconnected. + * + * onDeviceDisconnected is called when a device is removed from the system. Note that once a + * device is removed, if it was opened by a @ref Device object, that object can no longer be + * used to access the device, even if it was reconnected. Once a device was reconnected, + * @ref Device::open() should be called again in order to use this device. + * + * To use this class, you should write a new class that inherits from it, and override the + * onDeviceDisconnected method. Once you instantiate your class, use the + * OpenNI::addDeviceDisconnectedListener() function to add your listener object to OpenNI's list of listeners. Your + * handler function will then be called whenever the event occurs. A OpenNI::removeDeviceDisconnectedListener() + * function is also provided, if you want to have your class stop listening to these events for any + * reason. + */ + class DeviceDisconnectedListener + { + public: + DeviceDisconnectedListener() + { + m_deviceDisconnectedCallbacks.deviceConnected = NULL; + m_deviceDisconnectedCallbacks.deviceDisconnected = deviceDisconnectedCallback; + m_deviceDisconnectedCallbacks.deviceStateChanged = NULL; + m_deviceDisconnectedCallbacksHandle = NULL; + } + + virtual ~DeviceDisconnectedListener() + { + } + + /** + * Callback function for the onDeviceDisconnected event. This function will be + * called whenever this event occurs. When this happens, a pointer to the DeviceInfo + * object for the newly disconnected device will be supplied. Note that once a + * device is removed, if it was opened by a @ref Device object, that object can no longer be + * used to access the device, even if it was reconnected. Once a device was reconnected, + * @ref Device::open() should be called again in order to use this device. + */ + virtual void onDeviceDisconnected(const DeviceInfo*) = 0; + private: + static void ONI_CALLBACK_TYPE deviceDisconnectedCallback(const OniDeviceInfo* pInfo, void* pCookie) + { + DeviceDisconnectedListener* pListener = (DeviceDisconnectedListener*)pCookie; + pListener->onDeviceDisconnected(static_cast(pInfo)); + } + + friend class OpenNI; + OniDeviceCallbacks m_deviceDisconnectedCallbacks; + OniCallbackHandle m_deviceDisconnectedCallbacksHandle; + }; + /** + * The OpenNI::DeviceStateChangedListener class provides a means of registering for, and responding to + * when a device's state is changed. + * + * onDeviceStateChanged is triggered whenever the state of a connected device is changed. + * + * To use this class, you should write a new class that inherits from it, and override the + * onDeviceStateChanged method. Once you instantiate your class, use the + * OpenNI::addDeviceStateChangedListener() function to add your listener object to OpenNI's list of listeners. Your + * handler function will then be called whenever the event occurs. A OpenNI::removeDeviceStateChangedListener() + * function is also provided, if you want to have your class stop listening to these events for any + * reason. + */ + class DeviceStateChangedListener + { + public: + DeviceStateChangedListener() + { + m_deviceStateChangedCallbacks.deviceConnected = NULL; + m_deviceStateChangedCallbacks.deviceDisconnected = NULL; + m_deviceStateChangedCallbacks.deviceStateChanged = deviceStateChangedCallback; + m_deviceStateChangedCallbacksHandle = NULL; + } + + virtual ~DeviceStateChangedListener() + { + } + + /** + * Callback function for the onDeviceStateChanged event. This function will be + * called whenever this event occurs. When this happens, a pointer to a DeviceInfo + * object for the affected device will be supplied, as well as the new DeviceState + * value of that device. + */ + virtual void onDeviceStateChanged(const DeviceInfo*, DeviceState) = 0; + private: + static void ONI_CALLBACK_TYPE deviceStateChangedCallback(const OniDeviceInfo* pInfo, OniDeviceState state, void* pCookie) + { + DeviceStateChangedListener* pListener = (DeviceStateChangedListener*)pCookie; + pListener->onDeviceStateChanged(static_cast(pInfo), DeviceState(state)); + } + + friend class OpenNI; + OniDeviceCallbacks m_deviceStateChangedCallbacks; + OniCallbackHandle m_deviceStateChangedCallbacksHandle; + }; + + /** + Initialize the library. + This will load all available drivers, and see which devices are available + It is forbidden to call any other method in OpenNI before calling @ref initialize(). + */ + static Status initialize() + { + return (Status)oniInitialize(ONI_API_VERSION); // provide version of API, to make sure proper struct sizes are used + } + + /** + Stop using the library. Unload all drivers, close all streams and devices. + Once @ref shutdown was called, no other calls to OpenNI is allowed. + */ + static void shutdown() + { + oniShutdown(); + } + + /** + * Returns the version of OpenNI + */ + static Version getVersion() + { + OniVersion oniVersion = oniGetVersion(); + Version version; + version.major = oniVersion.major; + version.minor = oniVersion.minor; + version.maintenance = oniVersion.maintenance; + version.build = oniVersion.build; + return version; + } + + /** + * Retrieves the calling thread's last extended error information. The last extended error information is maintained + * on a per-thread basis. Multiple threads do not overwrite each other's last extended error information. + * + * The extended error information is cleared on every call to an OpenNI method, so you should call this method + * immediately after a call to an OpenNI method which have failed. + */ + static const char* getExtendedError() + { + return oniGetExtendedError(); + } + + /** + Fills up an array of @ref DeviceInfo objects with devices that are available. + @param [in,out] deviceInfoList An array to be filled with devices. + */ + static void enumerateDevices(Array* deviceInfoList) + { + OniDeviceInfo* m_pDeviceInfos; + int m_deviceInfoCount; + oniGetDeviceList(&m_pDeviceInfos, &m_deviceInfoCount); + deviceInfoList->_setData((DeviceInfo*)m_pDeviceInfos, m_deviceInfoCount, true); + oniReleaseDeviceList(m_pDeviceInfos); + } + + /** + Wait for a new frame from any of the streams provided. The function blocks until any of the streams + has a new frame available, or the timeout has passed. + @param [in] pStreams An array of streams to wait for. + @param [in] streamCount The number of streams in @c pStreams + @param [out] pReadyStreamIndex The index of the first stream that has new frame available. + @param [in] timeout [Optional] A timeout before returning if no stream has new data. Default value is @ref TIMEOUT_FOREVER. + */ + static Status waitForAnyStream(VideoStream** pStreams, int streamCount, int* pReadyStreamIndex, int timeout = TIMEOUT_FOREVER) + { + static const int ONI_MAX_STREAMS = 50; + OniStreamHandle streams[ONI_MAX_STREAMS]; + + if (streamCount > ONI_MAX_STREAMS) + { + printf("Too many streams for wait: %d > %d\n", streamCount, ONI_MAX_STREAMS); + return STATUS_BAD_PARAMETER; + } + + *pReadyStreamIndex = -1; + for (int i = 0; i < streamCount; ++i) + { + if (pStreams[i] != NULL) + { + streams[i] = pStreams[i]->_getHandle(); + } + else + { + streams[i] = NULL; + } + } + Status rc = (Status)oniWaitForAnyStream(streams, streamCount, pReadyStreamIndex, timeout); + + return rc; + } + + /** + * Add a listener to the list of objects that receive the event when a device is connected. See the + * @ref OpenNI::DeviceConnectedListener class for details on utilizing the events provided by OpenNI. + * + * @param pListener Pointer to the Listener to be added to the list + * @returns Status code indicating success or failure of this operation. + */ + static Status addDeviceConnectedListener(DeviceConnectedListener* pListener) + { + if (pListener->m_deviceConnectedCallbacksHandle != NULL) + { + return STATUS_ERROR; + } + return (Status)oniRegisterDeviceCallbacks(&pListener->m_deviceConnectedCallbacks, pListener, &pListener->m_deviceConnectedCallbacksHandle); + } + /** + * Add a listener to the list of objects that receive the event when a device is disconnected. See the + * @ref OpenNI::DeviceDisconnectedListener class for details on utilizing the events provided by OpenNI. + * + * @param pListener Pointer to the Listener to be added to the list + * @returns Status code indicating success or failure of this operation. + */ + static Status addDeviceDisconnectedListener(DeviceDisconnectedListener* pListener) + { + if (pListener->m_deviceDisconnectedCallbacksHandle != NULL) + { + return STATUS_ERROR; + } + return (Status)oniRegisterDeviceCallbacks(&pListener->m_deviceDisconnectedCallbacks, pListener, &pListener->m_deviceDisconnectedCallbacksHandle); + } + /** + * Add a listener to the list of objects that receive the event when a device's state changes. See the + * @ref OpenNI::DeviceStateChangedListener class for details on utilizing the events provided by OpenNI. + * + * @param pListener Pointer to the Listener to be added to the list + * @returns Status code indicating success or failure of this operation. + */ + static Status addDeviceStateChangedListener(DeviceStateChangedListener* pListener) + { + if (pListener->m_deviceStateChangedCallbacksHandle != NULL) + { + return STATUS_ERROR; + } + return (Status)oniRegisterDeviceCallbacks(&pListener->m_deviceStateChangedCallbacks, pListener, &pListener->m_deviceStateChangedCallbacksHandle); + } + /** + * Remove a listener from the list of objects that receive the event when a device is connected. See + * the @ref OpenNI::DeviceConnectedListener class for details on utilizing the events provided by OpenNI. + * + * @param pListener Pointer to the Listener to be removed from the list + * @returns Status code indicating the success or failure of this operation. + */ + static void removeDeviceConnectedListener(DeviceConnectedListener* pListener) + { + oniUnregisterDeviceCallbacks(pListener->m_deviceConnectedCallbacksHandle); + pListener->m_deviceConnectedCallbacksHandle = NULL; + } + /** + * Remove a listener from the list of objects that receive the event when a device is disconnected. See + * the @ref OpenNI::DeviceDisconnectedListener class for details on utilizing the events provided by OpenNI. + * + * @param pListener Pointer to the Listener to be removed from the list + * @returns Status code indicating the success or failure of this operation. + */ + static void removeDeviceDisconnectedListener(DeviceDisconnectedListener* pListener) + { + oniUnregisterDeviceCallbacks(pListener->m_deviceDisconnectedCallbacksHandle); + pListener->m_deviceDisconnectedCallbacksHandle = NULL; + } + /** + * Remove a listener from the list of objects that receive the event when a device's state changes. See + * the @ref OpenNI::DeviceStateChangedListener class for details on utilizing the events provided by OpenNI. + * + * @param pListener Pointer to the Listener to be removed from the list + * @returns Status code indicating the success or failure of this operation. + */ + static void removeDeviceStateChangedListener(DeviceStateChangedListener* pListener) + { + oniUnregisterDeviceCallbacks(pListener->m_deviceStateChangedCallbacksHandle); + pListener->m_deviceStateChangedCallbacksHandle = NULL; + } + + /** + * Change the log output folder + + * @param const char * strLogOutputFolder [in] log required folder + * + * @retval STATUS_OK Upon successful completion. + * @retval STATUS_ERROR Upon any kind of failure. + */ + static Status setLogOutputFolder(const char *strLogOutputFolder) + { + return (Status)oniSetLogOutputFolder(strLogOutputFolder); + } + + /** + * Get current log file name + + * @param char * strFileName [out] returned file name buffer + * @param int nBufferSize [in] Buffer size + * + * @retval STATUS_OK Upon successful completion. + * @retval STATUS_ERROR Upon any kind of failure. + */ + static Status getLogFileName(char *strFileName, int nBufferSize) + { + return (Status)oniGetLogFileName(strFileName, nBufferSize); + } + + /** + * Set minimum severity for log produce + + * @param const char * strMask [in] Logger name + * @param int nMinSeverity [in] Logger severity + * + * @retval STATUS_OK Upon successful completion. + * @retval STATUS_ERROR Upon any kind of failure. + */ + static Status setLogMinSeverity(int nMinSeverity) + { + return(Status) oniSetLogMinSeverity(nMinSeverity); + } + + /** + * Configures if log entries will be printed to console. + + * @param const OniBool bConsoleOutput [in] TRUE to print log entries to console, FALSE otherwise. + * + * @retval STATUS_OK Upon successful completion. + * @retval STATUS_ERROR Upon any kind of failure. + */ + static Status setLogConsoleOutput(bool bConsoleOutput) + { + return (Status)oniSetLogConsoleOutput(bConsoleOutput); + } + + /** + * Configures if log entries will be printed to file. + + * @param const OniBool bConsoleOutput [in] TRUE to print log entries to file, FALSE otherwise. + * + * @retval STATUS_OK Upon successful completion. + * @retval STATUS_ERROR Upon any kind of failure. + */ + static Status setLogFileOutput(bool bFileOutput) + { + return (Status)oniSetLogFileOutput(bFileOutput); + } + + #if ONI_PLATFORM == ONI_PLATFORM_ANDROID_ARM + /** + * Configures if log entries will be printed to the Android log. + + * @param OniBool bAndroidOutput bAndroidOutput [in] TRUE to print log entries to the Android log, FALSE otherwise. + * + * @retval STATUS_OK Upon successful completion. + * @retval STATUS_ERROR Upon any kind of failure. + */ + + static Status setLogAndroidOutput(bool bAndroidOutput) + { + return (Status)oniSetLogAndroidOutput(bAndroidOutput); + } + #endif + +private: + OpenNI() + { + } +}; + +/** +The CoordinateConverter class converts points between the different coordinate systems. + +Depth and World coordinate systems + +OpenNI applications commonly use two different coordinate systems to represent depth. These two systems are referred to as Depth +and World representation. + +Depth coordinates are the native data representation. In this system, the frame is a map (two dimensional array), and each pixel is +assigned a depth value. This depth value represents the distance between the camera plane and whatever object is in the given +pixel. The X and Y coordinates are simply the location in the map, where the origin is the top-left corner of the field of view. + +World coordinates superimpose a more familiar 3D Cartesian coordinate system on the world, with the camera lens at the origin. +In this system, every point is specified by 3 points -- x, y and z. The x axis of this system is along a line that passes +through the infrared projector and CMOS imager of the camera. The y axis is parallel to the front face of the camera, and +perpendicular to the x axis (it will also be perpendicular to the ground if the camera is upright and level). The z axis +runs into the scene, perpendicular to both the x and y axis. From the perspective of the camera, an object moving from +left to right is moving along the increasing x axis. An object moving up is moving along the increasing y axis, and an object +moving away from the camera is moving along the increasing z axis. + +Mathematically, the Depth coordinate system is the projection of the scene on the CMOS. If the sensor's angular field of view and +resolution are known, then an angular size can be calculated for each pixel. This is how the conversion algorithms work. The +dependence of this calculation on FoV and resolution is the reason that a @ref VideoStream pointer must be provided to these +functions. The @ref VideoStream pointer is used to determine parameters for the specific points to be converted. + +Since Depth coordinates are a projective, the apparent size of objects in depth coordinates (measured in pixels) +will increase as an object moves closer to the sensor. The size of objects in the World coordinate system is independent of +distance from the sensor. + +Note that converting from Depth to World coordinates is relatively expensive computationally. It is generally not practical to convert +the entire raw depth map to World coordinates. A better approach is to have your computer vision algorithm work in Depth +coordinates for as long as possible, and only converting a few specific points to World coordinates right before output. + +Note that when converting from Depth to World or vice versa, the Z value remains the same. +*/ +class CoordinateConverter +{ +public: + /** + Converts a single point from the World coordinate system to the Depth coordinate system. + @param [in] depthStream Reference to an openni::VideoStream that will be used to determine the format of the Depth coordinates + @param [in] worldX The X coordinate of the point to be converted, measured in millimeters in World coordinates + @param [in] worldY The Y coordinate of the point to be converted, measured in millimeters in World coordinates + @param [in] worldZ The Z coordinate of the point to be converted, measured in millimeters in World coordinates + @param [out] pDepthX Pointer to a place to store the X coordinate of the output value, measured in pixels with 0 at far left of image + @param [out] pDepthY Pointer to a place to store the Y coordinate of the output value, measured in pixels with 0 at top of image + @param [out] pDepthZ Pointer to a place to store the Z(depth) coordinate of the output value, measured in the @ref PixelFormat of depthStream + */ + static Status convertWorldToDepth(const VideoStream& depthStream, float worldX, float worldY, float worldZ, int* pDepthX, int* pDepthY, DepthPixel* pDepthZ) + { + float depthX, depthY, depthZ; + Status rc = (Status)oniCoordinateConverterWorldToDepth(depthStream._getHandle(), worldX, worldY, worldZ, &depthX, &depthY, &depthZ); + *pDepthX = (int)depthX; + *pDepthY = (int)depthY; + *pDepthZ = (DepthPixel)depthZ; + return rc; + } + + /** + Converts a single point from the World coordinate system to a floating point representation of the Depth coordinate system + @param [in] depthStream Reference to an openni::VideoStream that will be used to determine the format of the Depth coordinates + @param [in] worldX The X coordinate of the point to be converted, measured in millimeters in World coordinates + @param [in] worldY The Y coordinate of the point to be converted, measured in millimeters in World coordinates + @param [in] worldZ The Z coordinate of the point to be converted, measured in millimeters in World coordinates + @param [out] pDepthX Pointer to a place to store the X coordinate of the output value, measured in pixels with 0.0 at far left of the image + @param [out] pDepthY Pointer to a place to store the Y coordinate of the output value, measured in pixels with 0.0 at the top of the image + @param [out] pDepthZ Pointer to a place to store the Z(depth) coordinate of the output value, measured in millimeters with 0.0 at the camera lens + */ + static Status convertWorldToDepth(const VideoStream& depthStream, float worldX, float worldY, float worldZ, float* pDepthX, float* pDepthY, float* pDepthZ) + { + return (Status)oniCoordinateConverterWorldToDepth(depthStream._getHandle(), worldX, worldY, worldZ, pDepthX, pDepthY, pDepthZ); + } + + /** + Converts a single point from the Depth coordinate system to the World coordinate system. + @param [in] depthStream Reference to an openi::VideoStream that will be used to determine the format of the Depth coordinates + @param [in] depthX The X coordinate of the point to be converted, measured in pixels with 0 at the far left of the image + @param [in] depthY The Y coordinate of the point to be converted, measured in pixels with 0 at the top of the image + @param [in] depthZ the Z(depth) coordinate of the point to be converted, measured in the @ref PixelFormat of depthStream + @param [out] pWorldX Pointer to a place to store the X coordinate of the output value, measured in millimeters in World coordinates + @param [out] pWorldY Pointer to a place to store the Y coordinate of the output value, measured in millimeters in World coordinates + @param [out] pWorldZ Pointer to a place to store the Z coordinate of the output value, measured in millimeters in World coordinates + */ + static Status convertDepthToWorld(const VideoStream& depthStream, int depthX, int depthY, DepthPixel depthZ, float* pWorldX, float* pWorldY, float* pWorldZ) + { + return (Status)oniCoordinateConverterDepthToWorld(depthStream._getHandle(), float(depthX), float(depthY), float(depthZ), pWorldX, pWorldY, pWorldZ); + } + + /** + Converts a single point from a floating point representation of the Depth coordinate system to the World coordinate system. + @param [in] depthStream Reference to an openi::VideoStream that will be used to determine the format of the Depth coordinates + @param [in] depthX The X coordinate of the point to be converted, measured in pixels with 0.0 at the far left of the image + @param [in] depthY The Y coordinate of the point to be converted, measured in pixels with 0.0 at the top of the image + @param [in] depthZ Z(depth) coordinate of the point to be converted, measured in the @ref PixelFormat of depthStream + @param [out] pWorldX Pointer to a place to store the X coordinate of the output value, measured in millimeters in World coordinates + @param [out] pWorldY Pointer to a place to store the Y coordinate of the output value, measured in millimeters in World coordinates + @param [out] pWorldZ Pointer to a place to store the Z coordinate of the output value, measured in millimeters in World coordinates + */ + static Status convertDepthToWorld(const VideoStream& depthStream, float depthX, float depthY, float depthZ, float* pWorldX, float* pWorldY, float* pWorldZ) + { + return (Status)oniCoordinateConverterDepthToWorld(depthStream._getHandle(), depthX, depthY, depthZ, pWorldX, pWorldY, pWorldZ); + } + + /** + For a given depth point, provides the coordinates of the corresponding color value. Useful for superimposing the depth and color images. + This operation is the same as turning on registration, but is performed on a single pixel rather than the whole image. + @param [in] depthStream Reference to a openni::VideoStream that produced the depth value + @param [in] colorStream Reference to a openni::VideoStream that we want to find the appropriate color pixel in + @param [in] depthX X value of the depth point, given in Depth coordinates and measured in pixels + @param [in] depthY Y value of the depth point, given in Depth coordinates and measured in pixels + @param [in] depthZ Z(depth) value of the depth point, given in the @ref PixelFormat of depthStream + @param [out] pColorX The X coordinate of the color pixel that overlaps the given depth pixel, measured in pixels + @param [out] pColorY The Y coordinate of the color pixel that overlaps the given depth pixel, measured in pixels + */ + static Status convertDepthToColor(const VideoStream& depthStream, const VideoStream& colorStream, int depthX, int depthY, DepthPixel depthZ, int* pColorX, int* pColorY) + { + return (Status)oniCoordinateConverterDepthToColor(depthStream._getHandle(), colorStream._getHandle(), depthX, depthY, depthZ, pColorX, pColorY); + } +}; + +/** + * The Recorder class is used to record streams to an ONI file. + * + * After a recorder is instantiated, it must be initialized with a specific filename where + * the recording will be stored. The recorder is then attached to one or more streams. Once + * this is complete, the recorder can be told to start recording. The recorder will store + * every frame from every stream to the specified file. Later, this file can be used to + * initialize a file Device, and used to play back the same data that was recorded. + * + * Opening a file device is done by passing its path as the uri to the @ref Device::open() method. + * + * @see PlaybackControl for options available to play a reorded file. + * + */ +class Recorder +{ +public: + /** + * Creates a recorder. The recorder is not valid, i.e. @ref isValid() returns + * false. You must initialize the recorder before use with @ref create(). + */ + Recorder() : m_recorder(NULL) + { + } + + /** + * Destroys a recorder. This will also stop recording. + */ + ~Recorder() + { + destroy(); + } + + /** + * Initializes a recorder. You can initialize the recorder only once. Attempts + * to intialize more than once will result in an error code being returned. + * + * Initialization assigns the recorder to an output file that will be used for + * recording. Before use, the @ref attach() function must also be used to assign input + * data to the Recorder. + * + * @param [in] fileName The name of a file which will contain the recording. + * @returns Status code which indicates success or failure of the operation. + */ + Status create(const char* fileName) + { + if (!isValid()) + { + return (Status)oniCreateRecorder(fileName, &m_recorder); + } + return STATUS_ERROR; + } + + /** + * Verifies if the recorder is valid, i.e. if one can record with this recorder. A + * recorder object is not valid until the @ref create() method is called. + * + * @returns true if the recorder has been intialized, false otherwise. + */ + bool isValid() const + { + return NULL != getHandle(); + } + + /** + * Attaches a stream to the recorder. Note, this won't start recording, you + * should explicitly start it using @ref start() method. As soon as the recording + * process has been started, no more streams can be attached to the recorder. + * + * @param [in] stream The stream to be recorded. + * @param [in] allowLossyCompression [Optional] If this value is true, the recorder might use + * a lossy compression, which means that when the recording will be played-back, there might + * be small differences from the original frame. Default value is false. + */ + Status attach(VideoStream& stream, bool allowLossyCompression = false) + { + if (!isValid() || !stream.isValid()) + { + return STATUS_ERROR; + } + return (Status)oniRecorderAttachStream( + m_recorder, + stream._getHandle(), + allowLossyCompression); + } + + /** + * Starts recording. + * Once this method is called, the recorder will take all subsequent frames from the attached streams + * and store them in the file. + * You may not attach additional streams once recording was started. + */ + Status start() + { + if (!isValid()) + { + return STATUS_ERROR; + } + return (Status)oniRecorderStart(m_recorder); + } + + /** + * Stops recording. You may use @ref start() to resume the recording. + */ + void stop() + { + if (isValid()) + { + oniRecorderStop(m_recorder); + } + } + + /** + Destroys the recorder object. + */ + void destroy() + { + if (isValid()) + { + oniRecorderDestroy(&m_recorder); + } + } + +private: + Recorder(const Recorder&); + Recorder& operator=(const Recorder&); + + /** + * Returns a handle of this recorder. + */ + OniRecorderHandle getHandle() const + { + return m_recorder; + } + + + OniRecorderHandle m_recorder; +}; + +// Implemetation +Status VideoStream::create(const Device& device, SensorType sensorType) +{ + OniStreamHandle streamHandle; + Status rc = (Status)oniDeviceCreateStream(device._getHandle(), (OniSensorType)sensorType, &streamHandle); + if (rc != STATUS_OK) + { + return rc; + } + + m_isOwner = true; + _setHandle(streamHandle); + + if (isPropertySupported(STREAM_PROPERTY_AUTO_WHITE_BALANCE) && isPropertySupported(STREAM_PROPERTY_AUTO_EXPOSURE)) + { + m_pCameraSettings = new CameraSettings(this); + } + + return STATUS_OK; +} + +void VideoStream::destroy() +{ + if (!isValid()) + { + return; + } + + if (m_pCameraSettings != NULL) + { + delete m_pCameraSettings; + m_pCameraSettings = NULL; + } + + if (m_stream != NULL) + { + if(m_isOwner) + oniStreamDestroy(m_stream); + m_stream = NULL; + } +} + +Status Device::open(const char* uri) +{ + //If we are not the owners, we stick with our own device + if(!m_isOwner) + { + if(isValid()){ + return STATUS_OK; + }else{ + return STATUS_OUT_OF_FLOW; + } + } + + OniDeviceHandle deviceHandle; + Status rc = (Status)oniDeviceOpen(uri, &deviceHandle); + if (rc != STATUS_OK) + { + return rc; + } + + _setHandle(deviceHandle); + + return STATUS_OK; +} + +Status Device::_openEx(const char* uri, const char* mode) +{ + //If we are not the owners, we stick with our own device + if(!m_isOwner) + { + if(isValid()){ + return STATUS_OK; + }else{ + return STATUS_OUT_OF_FLOW; + } + } + + OniDeviceHandle deviceHandle; + Status rc = (Status)oniDeviceOpenEx(uri, mode, &deviceHandle); + if (rc != STATUS_OK) + { + return rc; + } + + _setHandle(deviceHandle); + + return STATUS_OK; +} + +Status Device::_setHandle(OniDeviceHandle deviceHandle) +{ + if (m_device == NULL) + { + m_device = deviceHandle; + + clearSensors(); + + oniDeviceGetInfo(m_device, &m_deviceInfo); + + if (isFile()) + { + m_pPlaybackControl = new PlaybackControl(this); + } + + // Read deviceInfo + return STATUS_OK; + } + + return STATUS_OUT_OF_FLOW; +} + +void Device::close() +{ + if (m_pPlaybackControl != NULL) + { + delete m_pPlaybackControl; + m_pPlaybackControl = NULL; + } + + if (m_device != NULL) + { + if(m_isOwner) + { + oniDeviceClose(m_device); + } + + m_device = NULL; + } +} + + +} + +#endif // _OPEN_NI_HPP_ diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PS1080.h b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PS1080.h new file mode 100644 index 00000000..561f7664 --- /dev/null +++ b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PS1080.h @@ -0,0 +1,632 @@ +/***************************************************************************** +* * +* OpenNI 2.x Alpha * +* Copyright (C) 2012 PrimeSense Ltd. * +* * +* This file is part of OpenNI. * +* * +* Licensed under the Apache License, Version 2.0 (the "License"); * +* you may not use this file except in compliance with the License. * +* You may obtain a copy of the License at * +* * +* http://www.apache.org/licenses/LICENSE-2.0 * +* * +* Unless required by applicable law or agreed to in writing, software * +* distributed under the License is distributed on an "AS IS" BASIS, * +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * +* See the License for the specific language governing permissions and * +* limitations under the License. * +* * +*****************************************************************************/ +#ifndef _PS1080_H_ +#define _PS1080_H_ + +#include + +/** The maximum permitted Xiron device name string length. */ +#define XN_DEVICE_MAX_STRING_LENGTH 200 + +/* + * private properties of PS1080 devices. + * + * @remarks + * properties structure is 0x1080XXYY where XX is range and YY is code. + * range values: + * F0 - device properties + * E0 - device commands + * 00 - common stream properties + * 10 - depth stream properties + * 20 - color stream properties + */ +enum +{ + /*******************************************************************/ + /* Device properties */ + /*******************************************************************/ + + /** unsigned long long (XnSensorUsbInterface) */ + XN_MODULE_PROPERTY_USB_INTERFACE = 0x1080F001, // "UsbInterface" + /** Boolean */ + XN_MODULE_PROPERTY_MIRROR = 0x1080F002, // "Mirror" + /** unsigned long long, get only */ + XN_MODULE_PROPERTY_RESET_SENSOR_ON_STARTUP = 0x1080F004, // "ResetSensorOnStartup" + /** unsigned long long, get only */ + XN_MODULE_PROPERTY_LEAN_INIT = 0x1080F005, // "LeanInit" + /** char[XN_DEVICE_MAX_STRING_LENGTH], get only */ + XN_MODULE_PROPERTY_SERIAL_NUMBER = 0x1080F006, // "ID" + /** XnVersions, get only */ + XN_MODULE_PROPERTY_VERSION = 0x1080F007, // "Version" + /** Boolean */ + XN_MODULE_PROPERTY_FIRMWARE_FRAME_SYNC = 0x1080F008, + /** Boolean */ + XN_MODULE_PROPERTY_HOST_TIMESTAMPS = 0x1080FF77, // "HostTimestamps" + /** Boolean */ + XN_MODULE_PROPERTY_CLOSE_STREAMS_ON_SHUTDOWN = 0x1080FF78, // "CloseStreamsOnShutdown" + /** Integer */ + XN_MODULE_PROPERTY_FIRMWARE_LOG_INTERVAL = 0x1080FF7F, // "FirmwareLogInterval" + /** Boolean */ + XN_MODULE_PROPERTY_PRINT_FIRMWARE_LOG = 0x1080FF80, // "FirmwareLogPrint" + /** Integer */ + XN_MODULE_PROPERTY_FIRMWARE_LOG_FILTER = 0x1080FF81, // "FirmwareLogFilter" + /** String, get only */ + XN_MODULE_PROPERTY_FIRMWARE_LOG = 0x1080FF82, // "FirmwareLog" + /** Integer */ + XN_MODULE_PROPERTY_FIRMWARE_CPU_INTERVAL = 0x1080FF83, // "FirmwareCPUInterval" + /** String, get only */ + XN_MODULE_PROPERTY_PHYSICAL_DEVICE_NAME = 0x1080FF7A, // "PhysicalDeviceName" + /** String, get only */ + XN_MODULE_PROPERTY_VENDOR_SPECIFIC_DATA = 0x1080FF7B, // "VendorSpecificData" + /** String, get only */ + XN_MODULE_PROPERTY_SENSOR_PLATFORM_STRING = 0x1080FF7C, // "SensorPlatformString" + + /*******************************************************************/ + /* Device commands (activated via SetProperty/GetProperty) */ + /*******************************************************************/ + + /** XnInnerParam */ + XN_MODULE_PROPERTY_FIRMWARE_PARAM = 0x1080E001, // "FirmwareParam" + /** unsigned long long, set only */ + XN_MODULE_PROPERTY_RESET = 0x1080E002, // "Reset" + /** XnControlProcessingData */ + XN_MODULE_PROPERTY_IMAGE_CONTROL = 0x1080E003, // "ImageControl" + /** XnControlProcessingData */ + XN_MODULE_PROPERTY_DEPTH_CONTROL = 0x1080E004, // "DepthControl" + /** XnAHBData */ + XN_MODULE_PROPERTY_AHB = 0x1080E005, // "AHB" + /** XnLedState */ + XN_MODULE_PROPERTY_LED_STATE = 0x1080E006, // "LedState" + /** Boolean */ + XN_MODULE_PROPERTY_EMITTER_STATE = 0x1080E007, // "EmitterState" + + /** XnCmosBlankingUnits */ + XN_MODULE_PROPERTY_CMOS_BLANKING_UNITS = 0x1080FF74, // "CmosBlankingUnits" + /** XnCmosBlankingTime */ + XN_MODULE_PROPERTY_CMOS_BLANKING_TIME = 0x1080FF75, // "CmosBlankingTime" + /** XnFlashFileList, get only */ + XN_MODULE_PROPERTY_FILE_LIST = 0x1080FF84, // "FileList" + /** XnParamFlashData, get only */ + XN_MODULE_PROPERTY_FLASH_CHUNK = 0x1080FF85, // "FlashChunk" + XN_MODULE_PROPERTY_FILE = 0x1080FF86, // "FlashFile" + /** Integer */ + XN_MODULE_PROPERTY_DELETE_FILE = 0x1080FF87, // "DeleteFile" + XN_MODULE_PROPERTY_FILE_ATTRIBUTES = 0x1080FF88, // "FileAttributes" + XN_MODULE_PROPERTY_TEC_SET_POINT = 0x1080FF89, // "TecSetPoint" + /** get only */ + XN_MODULE_PROPERTY_TEC_STATUS = 0x1080FF8A, // "TecStatus" + /** get only */ + XN_MODULE_PROPERTY_TEC_FAST_CONVERGENCE_STATUS = 0x1080FF8B, // "TecFastConvergenceStatus" + XN_MODULE_PROPERTY_EMITTER_SET_POINT = 0x1080FF8C, // "EmitterSetPoint" + /** get only */ + XN_MODULE_PROPERTY_EMITTER_STATUS = 0x1080FF8D, // "EmitterStatus" + XN_MODULE_PROPERTY_I2C = 0x1080FF8E, // "I2C" + /** Integer, set only */ + XN_MODULE_PROPERTY_BIST = 0x1080FF8F, // "BIST" + /** XnProjectorFaultData, set only */ + XN_MODULE_PROPERTY_PROJECTOR_FAULT = 0x1080FF90, // "ProjectorFault" + /** Boolean, set only */ + XN_MODULE_PROPERTY_APC_ENABLED = 0x1080FF91, // "APCEnabled" + /** Boolean */ + XN_MODULE_PROPERTY_FIRMWARE_TEC_DEBUG_PRINT = 0x1080FF92, // "TecDebugPrint" + + /*******************************************************************/ + /* Common stream properties */ + /*******************************************************************/ + + /** unsigned long long */ + XN_STREAM_PROPERTY_INPUT_FORMAT = 0x10800001, // "InputFormat" + /** unsigned long long (XnCroppingMode) */ + XN_STREAM_PROPERTY_CROPPING_MODE = 0x10800002, // "CroppingMode" + + /*******************************************************************/ + /* Depth stream properties */ + /*******************************************************************/ + + /** unsigned long long */ + XN_STREAM_PROPERTY_CLOSE_RANGE = 0x1080F003, // "CloseRange" + /** XnPixelRegistration - get only */ + XN_STREAM_PROPERTY_PIXEL_REGISTRATION = 0x10801001, // "PixelRegistration" + /** unsigned long long */ + XN_STREAM_PROPERTY_WHITE_BALANCE_ENABLED = 0x10801002, // "WhiteBalancedEnabled" + /** unsigned long long */ + XN_STREAM_PROPERTY_GAIN = 0x10801003, // "Gain" + /** unsigned long long */ + XN_STREAM_PROPERTY_HOLE_FILTER = 0x10801004, // "HoleFilter" + /** unsigned long long (XnProcessingType) */ + XN_STREAM_PROPERTY_REGISTRATION_TYPE = 0x10801005, // "RegistrationType" + /** XnDepthAGCBin* */ + XN_STREAM_PROPERTY_AGC_BIN = 0x10801006, // "AGCBin" + /** unsigned long long, get only */ + XN_STREAM_PROPERTY_CONST_SHIFT = 0x10801007, // "ConstShift" + /** unsigned long long, get only */ + XN_STREAM_PROPERTY_PIXEL_SIZE_FACTOR = 0x10801008, // "PixelSizeFactor" + /** unsigned long long, get only */ + XN_STREAM_PROPERTY_MAX_SHIFT = 0x10801009, // "MaxShift" + /** unsigned long long, get only */ + XN_STREAM_PROPERTY_PARAM_COEFF = 0x1080100A, // "ParamCoeff" + /** unsigned long long, get only */ + XN_STREAM_PROPERTY_SHIFT_SCALE = 0x1080100B, // "ShiftScale" + /** unsigned long long, get only */ + XN_STREAM_PROPERTY_ZERO_PLANE_DISTANCE = 0x1080100C, // "ZPD" + /** double, get only */ + XN_STREAM_PROPERTY_ZERO_PLANE_PIXEL_SIZE = 0x1080100D, // "ZPPS" + /** double, get only */ + XN_STREAM_PROPERTY_EMITTER_DCMOS_DISTANCE = 0x1080100E, // "LDDIS" + /** double, get only */ + XN_STREAM_PROPERTY_DCMOS_RCMOS_DISTANCE = 0x1080100F, // "DCRCDIS" + /** OniDepthPixel[], get only */ + XN_STREAM_PROPERTY_S2D_TABLE = 0x10801010, // "S2D" + /** unsigned short[], get only */ + XN_STREAM_PROPERTY_D2S_TABLE = 0x10801011, // "D2S" + /** get only */ + XN_STREAM_PROPERTY_DEPTH_SENSOR_CALIBRATION_INFO = 0x10801012, + /** Boolean */ + XN_STREAM_PROPERTY_GMC_MODE = 0x1080FF44, // "GmcMode" + /** Boolean */ + XN_STREAM_PROPERTY_GMC_DEBUG = 0x1080FF45, // "GmcDebug" + /** Boolean */ + XN_STREAM_PROPERTY_WAVELENGTH_CORRECTION = 0x1080FF46, // "WavelengthCorrection" + /** Boolean */ + XN_STREAM_PROPERTY_WAVELENGTH_CORRECTION_DEBUG = 0x1080FF47, // "WavelengthCorrectionDebug" + + /*******************************************************************/ + /* Color stream properties */ + /*******************************************************************/ + /** Integer */ + XN_STREAM_PROPERTY_FLICKER = 0x10802001, // "Flicker" +}; + +typedef enum +{ + XN_SENSOR_FW_VER_UNKNOWN = 0, + XN_SENSOR_FW_VER_0_17 = 1, + XN_SENSOR_FW_VER_1_1 = 2, + XN_SENSOR_FW_VER_1_2 = 3, + XN_SENSOR_FW_VER_3_0 = 4, + XN_SENSOR_FW_VER_4_0 = 5, + XN_SENSOR_FW_VER_5_0 = 6, + XN_SENSOR_FW_VER_5_1 = 7, + XN_SENSOR_FW_VER_5_2 = 8, + XN_SENSOR_FW_VER_5_3 = 9, + XN_SENSOR_FW_VER_5_4 = 10, + XN_SENSOR_FW_VER_5_5 = 11, + XN_SENSOR_FW_VER_5_6 = 12, + XN_SENSOR_FW_VER_5_7 = 13, + XN_SENSOR_FW_VER_5_8 = 14, +} XnFWVer; + +typedef enum { + XN_SENSOR_VER_UNKNOWN = 0, + XN_SENSOR_VER_2_0 = 1, + XN_SENSOR_VER_3_0 = 2, + XN_SENSOR_VER_4_0 = 3, + XN_SENSOR_VER_5_0 = 4 +} XnSensorVer; + +typedef enum { + XN_SENSOR_HW_VER_UNKNOWN = 0, + XN_SENSOR_HW_VER_FPDB_10 = 1, + XN_SENSOR_HW_VER_CDB_10 = 2, + XN_SENSOR_HW_VER_RD_3 = 3, + XN_SENSOR_HW_VER_RD_5 = 4, + XN_SENSOR_HW_VER_RD1081 = 5, + XN_SENSOR_HW_VER_RD1082 = 6, + XN_SENSOR_HW_VER_RD109 = 7 +} XnHWVer; + +typedef enum { + XN_SENSOR_CHIP_VER_UNKNOWN = 0, + XN_SENSOR_CHIP_VER_PS1000 = 1, + XN_SENSOR_CHIP_VER_PS1080 = 2, + XN_SENSOR_CHIP_VER_PS1080A6 = 3 +} XnChipVer; + +typedef enum +{ + XN_CMOS_TYPE_IMAGE = 0, + XN_CMOS_TYPE_DEPTH = 1, + + XN_CMOS_COUNT +} XnCMOSType; + +typedef enum +{ + XN_IO_IMAGE_FORMAT_BAYER = 0, + XN_IO_IMAGE_FORMAT_YUV422 = 1, + XN_IO_IMAGE_FORMAT_JPEG = 2, + XN_IO_IMAGE_FORMAT_JPEG_420 = 3, + XN_IO_IMAGE_FORMAT_JPEG_MONO = 4, + XN_IO_IMAGE_FORMAT_UNCOMPRESSED_YUV422 = 5, + XN_IO_IMAGE_FORMAT_UNCOMPRESSED_BAYER = 6, + XN_IO_IMAGE_FORMAT_UNCOMPRESSED_YUYV = 7, +} XnIOImageFormats; + +typedef enum +{ + XN_IO_DEPTH_FORMAT_UNCOMPRESSED_16_BIT = 0, + XN_IO_DEPTH_FORMAT_COMPRESSED_PS = 1, + XN_IO_DEPTH_FORMAT_UNCOMPRESSED_10_BIT = 2, + XN_IO_DEPTH_FORMAT_UNCOMPRESSED_11_BIT = 3, + XN_IO_DEPTH_FORMAT_UNCOMPRESSED_12_BIT = 4, +} XnIODepthFormats; + +typedef enum +{ + XN_RESET_TYPE_POWER = 0, + XN_RESET_TYPE_SOFT = 1, + XN_RESET_TYPE_SOFT_FIRST = 2, +} XnParamResetType; + +typedef enum XnSensorUsbInterface +{ + XN_SENSOR_USB_INTERFACE_DEFAULT = 0, + XN_SENSOR_USB_INTERFACE_ISO_ENDPOINTS = 1, + XN_SENSOR_USB_INTERFACE_BULK_ENDPOINTS = 2, + XN_SENSOR_USB_INTERFACE_ISO_ENDPOINTS_LOW_DEPTH = 3, +} XnSensorUsbInterface; + +typedef enum XnProcessingType +{ + XN_PROCESSING_DONT_CARE = 0, + XN_PROCESSING_HARDWARE = 1, + XN_PROCESSING_SOFTWARE = 2, +} XnProcessingType; + +typedef enum XnCroppingMode +{ + XN_CROPPING_MODE_NORMAL = 1, + XN_CROPPING_MODE_INCREASED_FPS = 2, + XN_CROPPING_MODE_SOFTWARE_ONLY = 3, +} XnCroppingMode; + +enum +{ + XN_ERROR_STATE_OK = 0, + XN_ERROR_STATE_DEVICE_PROJECTOR_FAULT = 1, + XN_ERROR_STATE_DEVICE_OVERHEAT = 2, +}; + +typedef enum XnFirmwareCroppingMode +{ + XN_FIRMWARE_CROPPING_MODE_DISABLED = 0, + XN_FIRMWARE_CROPPING_MODE_NORMAL = 1, + XN_FIRMWARE_CROPPING_MODE_INCREASED_FPS = 2, +} XnFirmwareCroppingMode; + +typedef enum +{ + XnLogFilterDebug = 0x0001, + XnLogFilterInfo = 0x0002, + XnLogFilterError = 0x0004, + XnLogFilterProtocol = 0x0008, + XnLogFilterAssert = 0x0010, + XnLogFilterConfig = 0x0020, + XnLogFilterFrameSync = 0x0040, + XnLogFilterAGC = 0x0080, + XnLogFilterTelems = 0x0100, + + XnLogFilterAll = 0xFFFF +} XnLogFilter; + +typedef enum +{ + XnFileAttributeReadOnly = 0x8000 +} XnFilePossibleAttributes; + +typedef enum +{ + XnFlashFileTypeFileTable = 0x00, + XnFlashFileTypeScratchFile = 0x01, + XnFlashFileTypeBootSector = 0x02, + XnFlashFileTypeBootManager = 0x03, + XnFlashFileTypeCodeDownloader = 0x04, + XnFlashFileTypeMonitor = 0x05, + XnFlashFileTypeApplication = 0x06, + XnFlashFileTypeFixedParams = 0x07, + XnFlashFileTypeDescriptors = 0x08, + XnFlashFileTypeDefaultParams = 0x09, + XnFlashFileTypeImageCmos = 0x0A, + XnFlashFileTypeDepthCmos = 0x0B, + XnFlashFileTypeAlgorithmParams = 0x0C, + XnFlashFileTypeReferenceQVGA = 0x0D, + XnFlashFileTypeReferenceVGA = 0x0E, + XnFlashFileTypeMaintenance = 0x0F, + XnFlashFileTypeDebugParams = 0x10, + XnFlashFileTypePrimeProcessor = 0x11, + XnFlashFileTypeGainControl = 0x12, + XnFlashFileTypeRegistartionParams = 0x13, + XnFlashFileTypeIDParams = 0x14, + XnFlashFileTypeSensorTECParams = 0x15, + XnFlashFileTypeSensorAPCParams = 0x16, + XnFlashFileTypeSensorProjectorFaultParams = 0x17, + XnFlashFileTypeProductionFile = 0x18, + XnFlashFileTypeUpgradeInProgress = 0x19, + XnFlashFileTypeWavelengthCorrection = 0x1A, + XnFlashFileTypeGMCReferenceOffset = 0x1B, + XnFlashFileTypeSensorNESAParams = 0x1C, + XnFlashFileTypeSensorFault = 0x1D, + XnFlashFileTypeVendorData = 0x1E, +} XnFlashFileType; + +typedef enum XnBistType +{ + //Auto tests + XN_BIST_IMAGE_CMOS = 1 << 0, + XN_BIST_IR_CMOS = 1 << 1, + XN_BIST_POTENTIOMETER = 1 << 2, + XN_BIST_FLASH = 1 << 3, + XN_BIST_FULL_FLASH = 1 << 4, + XN_BIST_PROJECTOR_TEST_MASK = 1 << 5, + XN_BIST_TEC_TEST_MASK = 1 << 6, + + // Manual tests + XN_BIST_NESA_TEST_MASK = 1 << 7, + XN_BIST_NESA_UNLIMITED_TEST_MASK = 1 << 8, + + // Mask of all the auto tests + XN_BIST_ALL = (0xFFFFFFFF & ~XN_BIST_NESA_TEST_MASK & ~XN_BIST_NESA_UNLIMITED_TEST_MASK), + +} XnBistType; + +typedef enum XnBistError +{ + XN_BIST_RAM_TEST_FAILURE = 1 << 0, + XN_BIST_IR_CMOS_CONTROL_BUS_FAILURE = 1 << 1, + XN_BIST_IR_CMOS_DATA_BUS_FAILURE = 1 << 2, + XN_BIST_IR_CMOS_BAD_VERSION = 1 << 3, + XN_BIST_IR_CMOS_RESET_FAILUE = 1 << 4, + XN_BIST_IR_CMOS_TRIGGER_FAILURE = 1 << 5, + XN_BIST_IR_CMOS_STROBE_FAILURE = 1 << 6, + XN_BIST_COLOR_CMOS_CONTROL_BUS_FAILURE = 1 << 7, + XN_BIST_COLOR_CMOS_DATA_BUS_FAILURE = 1 << 8, + XN_BIST_COLOR_CMOS_BAD_VERSION = 1 << 9, + XN_BIST_COLOR_CMOS_RESET_FAILUE = 1 << 10, + XN_BIST_FLASH_WRITE_LINE_FAILURE = 1 << 11, + XN_BIST_FLASH_TEST_FAILURE = 1 << 12, + XN_BIST_POTENTIOMETER_CONTROL_BUS_FAILURE = 1 << 13, + XN_BIST_POTENTIOMETER_FAILURE = 1 << 14, + XN_BIST_AUDIO_TEST_FAILURE = 1 << 15, + XN_BIST_PROJECTOR_TEST_LD_FAIL = 1 << 16, + XN_BIST_PROJECTOR_TEST_LD_FAILSAFE_TRIG_FAIL = 1 << 17, + XN_BIST_PROJECTOR_TEST_FAILSAFE_HIGH_FAIL = 1 << 18, + XN_BIST_PROJECTOR_TEST_FAILSAFE_LOW_FAIL = 1 << 19, + XN_TEC_TEST_HEATER_CROSSED = 1 << 20, + XN_TEC_TEST_HEATER_DISCONNETED = 1 << 21, + XN_TEC_TEST_TEC_CROSSED = 1 << 22, + XN_TEC_TEST_TEC_FAULT = 1 << 23, +} XnBistError; + +typedef enum XnDepthCMOSType +{ + XN_DEPTH_CMOS_NONE = 0, + XN_DEPTH_CMOS_MT9M001 = 1, + XN_DEPTH_CMOS_AR130 = 2, +} XnDepthCMOSType; + +typedef enum XnImageCMOSType +{ + XN_IMAGE_CMOS_NONE = 0, + XN_IMAGE_CMOS_MT9M112 = 1, + XN_IMAGE_CMOS_MT9D131 = 2, + XN_IMAGE_CMOS_MT9M114 = 3, +} XnImageCMOSType; + +#define XN_IO_MAX_I2C_BUFFER_SIZE 10 +#define XN_MAX_LOG_SIZE (6*1024) + +#pragma pack (push, 1) + +typedef struct XnSDKVersion +{ + unsigned char nMajor; + unsigned char nMinor; + unsigned char nMaintenance; + unsigned short nBuild; +} XnSDKVersion; + +typedef struct { + unsigned char nMajor; + unsigned char nMinor; + unsigned short nBuild; + unsigned int nChip; + unsigned short nFPGA; + unsigned short nSystemVersion; + + XnSDKVersion SDK; + + XnHWVer HWVer; + XnFWVer FWVer; + XnSensorVer SensorVer; + XnChipVer ChipVer; +} XnVersions; + +typedef struct +{ + unsigned short nParam; + unsigned short nValue; +} XnInnerParamData; + +typedef struct XnDepthAGCBin +{ + unsigned short nBin; + unsigned short nMin; + unsigned short nMax; +} XnDepthAGCBin; + +typedef struct XnControlProcessingData +{ + unsigned short nRegister; + unsigned short nValue; +} XnControlProcessingData; + +typedef struct XnAHBData +{ + unsigned int nRegister; + unsigned int nValue; + unsigned int nMask; +} XnAHBData; + +typedef struct XnPixelRegistration +{ + unsigned int nDepthX; + unsigned int nDepthY; + uint16_t nDepthValue; + unsigned int nImageXRes; + unsigned int nImageYRes; + unsigned int nImageX; // out + unsigned int nImageY; // out +} XnPixelRegistration; + +typedef struct XnLedState +{ + uint16_t nLedID; + uint16_t nState; +} XnLedState; + +typedef struct XnCmosBlankingTime +{ + XnCMOSType nCmosID; + float nTimeInMilliseconds; + uint16_t nNumberOfFrames; +} XnCmosBlankingTime; + +typedef struct XnCmosBlankingUnits +{ + XnCMOSType nCmosID; + uint16_t nUnits; + uint16_t nNumberOfFrames; +} XnCmosBlankingUnits; + +typedef struct XnI2CWriteData +{ + uint16_t nBus; + uint16_t nSlaveAddress; + uint16_t cpWriteBuffer[XN_IO_MAX_I2C_BUFFER_SIZE]; + uint16_t nWriteSize; +} XnI2CWriteData; + +typedef struct XnI2CReadData +{ + uint16_t nBus; + uint16_t nSlaveAddress; + uint16_t cpReadBuffer[XN_IO_MAX_I2C_BUFFER_SIZE]; + uint16_t cpWriteBuffer[XN_IO_MAX_I2C_BUFFER_SIZE]; + uint16_t nReadSize; + uint16_t nWriteSize; +} XnI2CReadData; + +typedef struct XnTecData +{ + uint16_t m_SetPointVoltage; + uint16_t m_CompensationVoltage; + uint16_t m_TecDutyCycle; //duty cycle on heater/cooler + uint16_t m_HeatMode; //TRUE - heat, FALSE - cool + int32_t m_ProportionalError; + int32_t m_IntegralError; + int32_t m_DerivativeError; + uint16_t m_ScanMode; //0 - crude, 1 - precise +} XnTecData; + +typedef struct XnTecFastConvergenceData +{ + int16_t m_SetPointTemperature; // set point temperature in celsius, + // scaled by factor of 100 (extra precision) + int16_t m_MeasuredTemperature; // measured temperature in celsius, + // scaled by factor of 100 (extra precision) + int32_t m_ProportionalError; // proportional error in system clocks + int32_t m_IntegralError; // integral error in system clocks + int32_t m_DerivativeError; // derivative error in system clocks + uint16_t m_ScanMode; // 0 - initial, 1 - crude, 2 - precise + uint16_t m_HeatMode; // 0 - idle, 1 - heat, 2 - cool + uint16_t m_TecDutyCycle; // duty cycle on heater/cooler in percents + uint16_t m_TemperatureRange; // 0 - cool, 1 - room, 2 - warm +} XnTecFastConvergenceData; + +typedef struct XnEmitterData +{ + uint16_t m_State; //idle, calibrating + uint16_t m_SetPointVoltage; //this is what should be written to the XML + uint16_t m_SetPointClocks; //target cross duty cycle + uint16_t m_PD_Reading; //current cross duty cycle in system clocks(high time) + uint16_t m_EmitterSet; //duty cycle on emitter set in system clocks (high time). + uint16_t m_EmitterSettingLogic; //TRUE = positive logic, FALSE = negative logic + uint16_t m_LightMeasureLogic; //TRUE - positive logic, FALSE - negative logic + uint16_t m_IsAPCEnabled; + uint16_t m_EmitterSetStepSize; // in MilliVolts + uint16_t m_ApcTolerance; // in system clocks (only valid up till v5.2) + uint16_t m_SubClocking; //in system clocks (only valid from v5.3) + uint16_t m_Precision; // (only valid from v5.3) +} XnEmitterData; + +typedef struct +{ + uint16_t nId; + uint16_t nAttribs; +} XnFileAttributes; + +typedef struct +{ + uint32_t nOffset; + const char* strFileName; + uint16_t nAttributes; +} XnParamFileData; + +typedef struct +{ + uint32_t nOffset; + uint32_t nSize; + unsigned char* pData; +} XnParamFlashData; + +typedef struct { + uint16_t nId; + uint16_t nType; + uint32_t nVersion; + uint32_t nOffset; + uint32_t nSize; + uint16_t nCrc; + uint16_t nAttributes; + uint16_t nReserve; +} XnFlashFile; + +typedef struct +{ + XnFlashFile* pFiles; + uint16_t nFiles; +} XnFlashFileList; + +typedef struct XnProjectorFaultData +{ + uint16_t nMinThreshold; + uint16_t nMaxThreshold; + int32_t bProjectorFaultEvent; +} XnProjectorFaultData; + +typedef struct XnBist +{ + uint32_t nTestsMask; + uint32_t nFailures; +} XnBist; + +#pragma pack (pop) + +#endif //_PS1080_H_ \ No newline at end of file diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PSLink.h b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PSLink.h new file mode 100644 index 00000000..dd4d8992 --- /dev/null +++ b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PSLink.h @@ -0,0 +1,199 @@ +#ifndef __XN_PRIME_CLIENT_PROPS_H__ +#define __XN_PRIME_CLIENT_PROPS_H__ + +#include + +enum +{ + /**** Device properties ****/ + + /* XnDetailedVersion, get only */ + LINK_PROP_FW_VERSION = 0x12000001, // "FWVersion" + /* Int, get only */ + LINK_PROP_VERSIONS_INFO_COUNT = 0x12000002, // "VersionsInfoCount" + /* General - array - XnComponentVersion * count elements, get only */ + LINK_PROP_VERSIONS_INFO = 0x12000003, // "VersionsInfo" + /* Int - 0 means off, 1 means on. */ + LINK_PROP_EMITTER_ACTIVE = 0x12000008, // "EmitterActive" + /* String. Set only */ + LINK_PROP_PRESET_FILE = 0x1200000a, // "PresetFile" + /* Get only */ + LINK_PROP_BOOT_STATUS = 0x1200000b, + + /**** Device commands ****/ + /* XnCommandGetFwStreams */ + LINK_COMMAND_GET_FW_STREAM_LIST = 0x1200F001, + /* XnCommandCreateStream */ + LINK_COMMAND_CREATE_FW_STREAM = 0x1200F002, + /* XnCommandDestroyStream */ + LINK_COMMAND_DESTROY_FW_STREAM = 0x1200F003, + /* XnCommandStartStream */ + LINK_COMMAND_START_FW_STREAM = 0x1200F004, + /* XnCommandStopStream */ + LINK_COMMAND_STOP_FW_STREAM = 0x1200F005, + /* XnCommandGetFwStreamVideoModeList */ + LINK_COMMAND_GET_FW_STREAM_VIDEO_MODE_LIST = 0x1200F006, + /* XnCommandSetFwStreamVideoMode */ + LINK_COMMAND_SET_FW_STREAM_VIDEO_MODE = 0x1200F007, + /* XnCommandGetFwStreamVideoMode */ + LINK_COMMAND_GET_FW_STREAM_VIDEO_MODE = 0x1200F008, + + /**** Stream properties ****/ + /* Int. 1 - Shifts 9.3, 2 - Grayscale16, 3 - YUV422, 4 - Bayer8 */ + LINK_PROP_PIXEL_FORMAT = 0x12001001, // "PixelFormat" + /* Int. 0 - None, 1 - 8z, 2 - 16z, 3 - 24z, 4 - 6-bit, 5 - 10-bit, 6 - 11-bit, 7 - 12-bit */ + LINK_PROP_COMPRESSION = 0x12001002, // "Compression" + + /**** Depth Stream properties ****/ + /* Real, get only */ + LINK_PROP_DEPTH_SCALE = 0x1200000b, // "DepthScale" + /* Int, get only */ + LINK_PROP_MAX_SHIFT = 0x12002001, // "MaxShift" + /* Int, get only */ + LINK_PROP_ZERO_PLANE_DISTANCE = 0x12002002, // "ZPD" + /* Int, get only */ + LINK_PROP_CONST_SHIFT = 0x12002003, // "ConstShift" + /* Int, get only */ + LINK_PROP_PARAM_COEFF = 0x12002004, // "ParamCoeff" + /* Int, get only */ + LINK_PROP_SHIFT_SCALE = 0x12002005, // "ShiftScale" + /* Real, get only */ + LINK_PROP_ZERO_PLANE_PIXEL_SIZE = 0x12002006, // "ZPPS" + /* Real, get only */ + LINK_PROP_ZERO_PLANE_OUTPUT_PIXEL_SIZE = 0x12002007, // "ZPOPS" + /* Real, get only */ + LINK_PROP_EMITTER_DEPTH_CMOS_DISTANCE = 0x12002008, // "LDDIS" + /* General - array - MaxShift * XnDepthPixel elements, get only */ + LINK_PROP_SHIFT_TO_DEPTH_TABLE = 0x12002009, // "S2D" + /* General - array - MaxDepth * uint16_t elements, get only */ + LINK_PROP_DEPTH_TO_SHIFT_TABLE = 0x1200200a, // "D2S" +}; + +typedef enum XnFileZone +{ + XN_ZONE_FACTORY = 0x0000, + XN_ZONE_UPDATE = 0x0001, +} XnFileZone; + +typedef enum XnBootErrorCode +{ + XN_BOOT_OK = 0x0000, + XN_BOOT_BAD_CRC = 0x0001, + XN_BOOT_UPLOAD_IN_PROGRESS = 0x0002, + XN_BOOT_FW_LOAD_FAILED = 0x0003, +} XnBootErrorCode; + +typedef enum XnFwStreamType +{ + XN_FW_STREAM_TYPE_COLOR = 0x0001, + XN_FW_STREAM_TYPE_IR = 0x0002, + XN_FW_STREAM_TYPE_SHIFTS = 0x0003, + XN_FW_STREAM_TYPE_AUDIO = 0x0004, + XN_FW_STREAM_TYPE_DY = 0x0005, + XN_FW_STREAM_TYPE_LOG = 0x0008, +} XnFwStreamType; + +typedef enum XnFwPixelFormat +{ + XN_FW_PIXEL_FORMAT_NONE = 0x0000, + XN_FW_PIXEL_FORMAT_SHIFTS_9_3 = 0x0001, + XN_FW_PIXEL_FORMAT_GRAYSCALE16 = 0x0002, + XN_FW_PIXEL_FORMAT_YUV422 = 0x0003, + XN_FW_PIXEL_FORMAT_BAYER8 = 0x0004, +} XnFwPixelFormat; + +typedef enum XnFwCompressionType +{ + XN_FW_COMPRESSION_NONE = 0x0000, + XN_FW_COMPRESSION_8Z = 0x0001, + XN_FW_COMPRESSION_16Z = 0x0002, + XN_FW_COMPRESSION_24Z = 0x0003, + XN_FW_COMPRESSION_6_BIT_PACKED = 0x0004, + XN_FW_COMPRESSION_10_BIT_PACKED = 0x0005, + XN_FW_COMPRESSION_11_BIT_PACKED = 0x0006, + XN_FW_COMPRESSION_12_BIT_PACKED = 0x0007, +} XnFwCompressionType; + +#pragma pack (push, 1) + +#define XN_MAX_VERSION_MODIFIER_LENGTH 16 +typedef struct XnDetailedVersion +{ + uint8_t m_nMajor; + uint8_t m_nMinor; + uint16_t m_nMaintenance; + uint32_t m_nBuild; + char m_strModifier[XN_MAX_VERSION_MODIFIER_LENGTH]; +} XnDetailedVersion; + +typedef struct XnBootStatus +{ + XnFileZone zone; + XnBootErrorCode errorCode; +} XnBootStatus; + +typedef struct XnFwStreamInfo +{ + XnFwStreamType type; + char creationInfo[80]; +} XnFwStreamInfo; + +typedef struct XnFwStreamVideoMode +{ + uint32_t m_nXRes; + uint32_t m_nYRes; + uint32_t m_nFPS; + XnFwPixelFormat m_nPixelFormat; + XnFwCompressionType m_nCompression; +} XnFwStreamVideoMode; + +typedef struct XnCommandGetFwStreamList +{ + uint32_t count; // in: number of allocated elements in streams array. out: number of written elements in the array + XnFwStreamInfo* streams; +} XnCommandGetFwStreamList; + +typedef struct XnCommandCreateStream +{ + XnFwStreamType type; + const char* creationInfo; + uint32_t id; // out +} XnCommandCreateStream; + +typedef struct XnCommandDestroyStream +{ + uint32_t id; +} XnCommandDestroyStream; + +typedef struct XnCommandStartStream +{ + uint32_t id; +} XnCommandStartStream; + +typedef struct XnCommandStopStream +{ + uint32_t id; +} XnCommandStopStream; + +typedef struct XnCommandGetFwStreamVideoModeList +{ + int streamId; + uint32_t count; // in: number of allocated elements in videoModes array. out: number of written elements in the array + XnFwStreamVideoMode* videoModes; +} XnCommandGetFwStreamVideoModeList; + +typedef struct XnCommandSetFwStreamVideoMode +{ + int streamId; + XnFwStreamVideoMode videoMode; +} XnCommandSetFwStreamVideoMode; + +typedef struct XnCommandGetFwStreamVideoMode +{ + int streamId; + XnFwStreamVideoMode videoMode; // out +} XnCommandGetFwStreamVideoMode; + +#pragma pack (pop) + +#endif //__XN_PRIME_CLIENT_PROPS_H__ diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PrimeSense.h b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PrimeSense.h new file mode 100644 index 00000000..1517bddb --- /dev/null +++ b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PrimeSense.h @@ -0,0 +1,229 @@ +/***************************************************************************** +* * +* OpenNI 2.x Alpha * +* Copyright (C) 2012 PrimeSense Ltd. * +* * +* This file is part of OpenNI. * +* * +* Licensed under the Apache License, Version 2.0 (the "License"); * +* you may not use this file except in compliance with the License. * +* You may obtain a copy of the License at * +* * +* http://www.apache.org/licenses/LICENSE-2.0 * +* * +* Unless required by applicable law or agreed to in writing, software * +* distributed under the License is distributed on an "AS IS" BASIS, * +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * +* See the License for the specific language governing permissions and * +* limitations under the License. * +* * +*****************************************************************************/ +#ifndef _PRIME_SENSE_H_ +#define _PRIME_SENSE_H_ + +#include + +/** +* Additional properties for PrimeSense devices +* +* @remarks +* properties structure is 0x1D27XXYY where XX is range and YY is code. +* range values: +* 00 - common stream properties +* 10 - depth stream properties +* E0 - device commands +* F0 - device properties +*/ +enum +{ + // Stream Properties + PS_PROPERTY_DUMP_DATA = 0x1d270001, // boolean + + // Device Properties + PS_PROPERTY_USB_INTERFACE = 0x1d27F001, // values from XnUsbInterfaceType +}; + +/** +* Additional commands for PrimeSense devices +* +* @remarks +* Commands structure is 0x1D27XXYY where XX is range and YY is code. +* range values: +* E0 - device commands +*/ +enum +{ + // Device Commands - use via invoke() + PS_COMMAND_AHB_READ = 0x1d27E001, // XnCommandAHB + PS_COMMAND_AHB_WRITE = 0x1d27E002, // XnCommandAHB + PS_COMMAND_I2C_READ = 0x1d27E003, // XnCommandI2C + PS_COMMAND_I2C_WRITE = 0x1d27E004, // XnCommandI2C + PS_COMMAND_SOFT_RESET = 0x1d27E005, // no arguments + PS_COMMAND_POWER_RESET = 0x1d27E006, // no arguments + PS_COMMAND_BEGIN_FIRMWARE_UPDATE = 0x1d27E007, // no arguments + PS_COMMAND_END_FIRMWARE_UPDATE = 0x1d27E008, // no arguments + PS_COMMAND_UPLOAD_FILE = 0x1d27E009, // XnCommandUploadFile + PS_COMMAND_DOWNLOAD_FILE = 0x1d27E00A, // XnCommandDownloadFile + PS_COMMAND_GET_FILE_LIST = 0x1d27E00B, // an array of XnFileEntry + PS_COMMAND_FORMAT_ZONE = 0x1d27E00C, // XnCommandFormatZone + PS_COMMAND_DUMP_ENDPOINT = 0x1d27E00D, // XnCommandDumpEndpoint + PS_COMMAND_GET_I2C_DEVICE_LIST = 0x1d27E00E, // XnCommandGetI2CDevices + PS_COMMAND_GET_BIST_LIST = 0x1d27E00F, // XnCommandGetBistList + PS_COMMAND_EXECUTE_BIST = 0x1d27E010, // XnCommandExecuteBist + PS_COMMAND_USB_TEST = 0x1d27E011, // XnCommandUsbTest + PS_COMMAND_GET_LOG_MASK_LIST = 0x1d27E012, // XnCommandGetLogMaskList + PS_COMMAND_SET_LOG_MASK_STATE = 0x1d27E013, // XnCommandSetLogMaskState + PS_COMMAND_START_LOG = 0x1d27E014, // no arguments + PS_COMMAND_STOP_LOG = 0x1d27E015, // no arguments +}; + +typedef enum XnUsbInterfaceType +{ + PS_USB_INTERFACE_DONT_CARE = 0, + PS_USB_INTERFACE_ISO_ENDPOINTS = 1, + PS_USB_INTERFACE_BULK_ENDPOINTS = 2, +} XnUsbInterfaceType; + +#pragma pack (push, 1) + +// Data Types +typedef struct XnFwFileVersion +{ + uint8_t major; + uint8_t minor; + uint8_t maintenance; + uint8_t build; +} XnFwFileVersion; + +typedef enum XnFwFileFlags +{ + XN_FILE_FLAG_BAD_CRC = 0x0001, +} XnFwFileFlags; + +typedef struct XnFwFileEntry +{ + char name[32]; + XnFwFileVersion version; + uint32_t address; + uint32_t size; + uint16_t crc; + uint16_t zone; + XnFwFileFlags flags; // bitmap +} XnFwFileEntry; + +typedef struct XnI2CDeviceInfo +{ + uint32_t id; + char name[32]; +} XnI2CDeviceInfo; + +typedef struct XnBistInfo +{ + uint32_t id; + char name[32]; +} XnBistInfo; + +typedef struct XnFwLogMask +{ + uint32_t id; + char name[32]; +} XnFwLogMask; + +typedef struct XnUsbTestEndpointResult +{ + double averageBytesPerSecond; + uint32_t lostPackets; +} XnUsbTestEndpointResult; + +// Commands + +typedef struct XnCommandAHB +{ + uint32_t address; // Address of this register + uint32_t offsetInBits; // Offset of the field in bits within address + uint32_t widthInBits; // Width of the field in bits + uint32_t value; // For read requests, this is where the actual value will be filled. For write requests, the value to write. +} XnCommandAHB; + +typedef struct XnCommandI2C +{ + uint32_t deviceID; // Device to communicate with + uint32_t addressSize; // Size of the address, in bytes (1-4) + uint32_t address; // Address + uint32_t valueSize; // Size of the value, in bytes (1-4) + uint32_t mask; // For write request - a mask to be applied to the value. For read requests - ignored. + uint32_t value; // For write request - the value to be written. For read requests - the place where the actual value is written to +} XnCommandI2C; + +typedef struct XnCommandUploadFile +{ + const char* filePath; + uint32_t uploadToFactory; +} XnCommandUploadFile; + +typedef struct XnCommandDownloadFile +{ + uint16_t zone; + const char* firmwareFileName; + const char* targetPath; +} XnCommandDownloadFile; + +typedef struct XnCommandGetFileList +{ + uint32_t count; // in: number of allocated elements in files array. out: number of written elements in the array + XnFwFileEntry* files; +} XnCommandGetFileList; + +typedef struct XnCommandFormatZone +{ + uint8_t zone; +} XnCommandFormatZone; + +typedef struct XnCommandDumpEndpoint +{ + uint8_t endpoint; + bool enabled; +} XnCommandDumpEndpoint; + +typedef struct XnCommandGetI2CDeviceList +{ + uint32_t count; // in: number of allocated elements in devices array. out: number of written elements in the array + XnI2CDeviceInfo* devices; +} XnCommandGetI2CDeviceList; + +typedef struct XnCommandGetBistList +{ + uint32_t count; // in: number of allocated elements in tests array. out: number of written elements in the array + XnBistInfo* tests; +} XnCommandGetBistList; + +typedef struct XnCommandExecuteBist +{ + uint32_t id; + uint32_t errorCode; + uint32_t extraDataSize; // in: number of allocated bytes in extraData. out: number of written bytes in extraData + uint8_t* extraData; +} XnCommandExecuteBist; + +typedef struct XnCommandUsbTest +{ + uint32_t seconds; + uint32_t endpointCount; // in: number of allocated bytes in endpoints array. out: number of written bytes in array + XnUsbTestEndpointResult* endpoints; +} XnCommandUsbTest; + +typedef struct XnCommandGetLogMaskList +{ + uint32_t count; // in: number of allocated elements in masks array. out: number of written elements in the array + XnFwLogMask* masks; +} XnCommandGetLogMaskList; + +typedef struct XnCommandSetLogMaskState +{ + uint32_t mask; + bool enabled; +} XnCommandSetLogMaskState; + +#pragma pack (pop) + +#endif //_PRIME_SENSE_H_ \ No newline at end of file diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Win32/OniPlatformWin32.h b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Win32/OniPlatformWin32.h new file mode 100644 index 00000000..23bd81db --- /dev/null +++ b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Win32/OniPlatformWin32.h @@ -0,0 +1,139 @@ +/***************************************************************************** +* * +* OpenNI 2.x Alpha * +* Copyright (C) 2012 PrimeSense Ltd. * +* * +* This file is part of OpenNI. * +* * +* Licensed under the Apache License, Version 2.0 (the "License"); * +* you may not use this file except in compliance with the License. * +* You may obtain a copy of the License at * +* * +* http://www.apache.org/licenses/LICENSE-2.0 * +* * +* Unless required by applicable law or agreed to in writing, software * +* distributed under the License is distributed on an "AS IS" BASIS, * +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * +* See the License for the specific language governing permissions and * +* limitations under the License. * +* * +*****************************************************************************/ +#ifndef _ONI_PLATFORM_WIN32_H_ +#define _ONI_PLATFORM_WIN32_H_ + +//--------------------------------------------------------------------------- +// Prerequisites +//--------------------------------------------------------------------------- +#ifndef WINVER // Allow use of features specific to Windows XP or later + #define WINVER 0x0501 +#endif +#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later + #define _WIN32_WINNT 0x0501 +#endif +#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later + #define _WIN32_WINDOWS 0x0410 +#endif +#ifndef _WIN32_IE // Allow use of features specific to IE 6.0 or later + #define _WIN32_IE 0x0600 +#endif +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers + +// Undeprecate CRT functions +#ifndef _CRT_SECURE_NO_DEPRECATE + #define _CRT_SECURE_NO_DEPRECATE 1 +#endif + +//--------------------------------------------------------------------------- +// Includes +//--------------------------------------------------------------------------- +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if _MSC_VER < 1600 // Visual Studio 2008 and older doesn't have stdint.h... +typedef signed char int8_t; +typedef short int16_t; +typedef int int32_t; +typedef __int64 int64_t; + +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned int uint32_t; +typedef unsigned __int64 uint64_t; +#else +#include +#endif + +//--------------------------------------------------------------------------- +// Platform Basic Definition +//--------------------------------------------------------------------------- +#define ONI_PLATFORM ONI_PLATFORM_WIN32 +#define ONI_PLATFORM_STRING "Win32" + +//--------------------------------------------------------------------------- +// Platform Capabilities +//--------------------------------------------------------------------------- +#define ONI_PLATFORM_ENDIAN_TYPE ONI_PLATFORM_IS_LITTLE_ENDIAN + +#define ONI_PLATFORM_SUPPORTS_DYNAMIC_LIBS 1 + +//--------------------------------------------------------------------------- +// Memory +//--------------------------------------------------------------------------- +/** The default memory alignment. */ +#define ONI_DEFAULT_MEM_ALIGN 16 + +/** The thread static declarator (using TLS). */ +#define ONI_THREAD_STATIC __declspec(thread) + +//--------------------------------------------------------------------------- +// Files +//--------------------------------------------------------------------------- +/** The maximum allowed file path size (in bytes). */ +#define ONI_FILE_MAX_PATH MAX_PATH + +//--------------------------------------------------------------------------- +// Call backs +//--------------------------------------------------------------------------- +/** The std call type. */ +#define ONI_STDCALL __stdcall + +/** The call back calling convention. */ +#define ONI_CALLBACK_TYPE ONI_STDCALL + +/** The C and C++ calling convension. */ +#define ONI_C_DECL __cdecl + +//--------------------------------------------------------------------------- +// Macros +//--------------------------------------------------------------------------- +/** Returns the date and time at compile time. */ +#define ONI_TIMESTAMP __DATE__ " " __TIME__ + +/** Converts n into a pre-processor string. */ +#define ONI_STRINGIFY(n) ONI_STRINGIFY_HELPER(n) +#define ONI_STRINGIFY_HELPER(n) #n + +//--------------------------------------------------------------------------- +// API Export/Import Macros +//--------------------------------------------------------------------------- +/** Indicates an exported shared library function. */ +#define ONI_API_EXPORT __declspec(dllexport) + +/** Indicates an imported shared library function. */ +#define ONI_API_IMPORT __declspec(dllimport) + +/** Indicates a deprecated function */ +#if _MSC_VER < 1400 // Before VS2005 there was no support for declspec deprecated... + #define ONI_API_DEPRECATED(msg) +#else + #define ONI_API_DEPRECATED(msg) __declspec(deprecated(msg)) +#endif + +#endif //_ONI_PLATFORM_WIN32_H_ diff --git a/OpenNI2-FreenectDriver/src/ColorStream.cpp b/OpenNI2-FreenectDriver/src/ColorStream.cpp new file mode 100644 index 00000000..a0b4c1bb --- /dev/null +++ b/OpenNI2-FreenectDriver/src/ColorStream.cpp @@ -0,0 +1,90 @@ +#include "ColorStream.hpp" + +using namespace FreenectDriver; + + +ColorStream::ColorStream(Freenect::FreenectDevice* pDevice) : VideoStream(pDevice) { + video_mode = makeOniVideoMode(ONI_PIXEL_FORMAT_RGB888, 640, 480, 30); + setVideoMode(video_mode); +} + +// Add video modes here as you implement them +ColorStream::FreenectVideoModeMap ColorStream::getSupportedVideoModes() { + FreenectVideoModeMap modes; + // pixelFormat, resolutionX, resolutionY, fps freenect_video_format, freenect_resolution + modes[makeOniVideoMode(ONI_PIXEL_FORMAT_RGB888, 640, 480, 30)] = std::pair(FREENECT_VIDEO_RGB, FREENECT_RESOLUTION_MEDIUM); + + + return modes; + + /* working format possiblities + FREENECT_VIDEO_RGB + FREENECT_VIDEO_YUV_RGB + FREENECT_VIDEO_YUV_RAW + */ +} + +OniStatus ColorStream::setVideoMode(OniVideoMode requested_mode) { + FreenectVideoModeMap supported_video_modes = getSupportedVideoModes(); + FreenectVideoModeMap::const_iterator matched_mode_iter = supported_video_modes.find(requested_mode); + if (matched_mode_iter == supported_video_modes.end()) + return ONI_STATUS_NOT_SUPPORTED; + + freenect_video_format format = matched_mode_iter->second.first; + freenect_resolution resolution = matched_mode_iter->second.second; + + try { device->setVideoFormat(format, resolution); } + catch (std::runtime_error e) { + printf("format-resolution combination not supported by libfreenect: %d-%d\n", format, resolution); + return ONI_STATUS_NOT_SUPPORTED; + } + video_mode = requested_mode; + return ONI_STATUS_OK; +} + +void ColorStream::populateFrame(void* data, OniFrame* frame) const { + frame->sensorType = sensor_type; + frame->stride = video_mode.resolutionX*3; + frame->cropOriginX = frame->cropOriginY = 0; + frame->croppingEnabled = FALSE; + + // copy stream buffer from freenect + switch (video_mode.pixelFormat) { + default: + printf("pixelFormat %d not supported by populateFrame\n", video_mode.pixelFormat); + return; + + case ONI_PIXEL_FORMAT_RGB888: + unsigned char* data_ptr = static_cast(data); + unsigned char* frame_data = static_cast(frame->data); + if (mirroring) { + for (int i = 0; i < frame->dataSize; i += 3) { + // find corresponding mirrored pixel + unsigned int pixel = i / 3; + unsigned int row = pixel / video_mode.resolutionX; + unsigned int col = video_mode.resolutionX - (pixel % video_mode.resolutionX); + unsigned int target = 3 * (row * video_mode.resolutionX + col); + // copy it to this pixel + frame_data[i] = data_ptr[target]; + frame_data[i+1] = data_ptr[target+1]; + frame_data[i+2] = data_ptr[target+2]; + } + } + else + std::copy(data_ptr, data_ptr+frame->dataSize, frame_data); + + return; + } +} + +/* color video modes reference + +FREENECT_VIDEO_RGB = 0, //< Decompressed RGB mode (demosaicing done by libfreenect) +FREENECT_VIDEO_BAYER = 1, //< Bayer compressed mode (raw information from camera) +FREENECT_VIDEO_YUV_RGB = 5, //< YUV RGB mode +FREENECT_VIDEO_YUV_RAW = 6, //< YUV Raw mode + +ONI_PIXEL_FORMAT_RGB888 = 200, +ONI_PIXEL_FORMAT_YUV422 = 201, +ONI_PIXEL_FORMAT_JPEG = 204, +*/ diff --git a/OpenNI2-FreenectDriver/src/ColorStream.hpp b/OpenNI2-FreenectDriver/src/ColorStream.hpp new file mode 100644 index 00000000..489b32d5 --- /dev/null +++ b/OpenNI2-FreenectDriver/src/ColorStream.hpp @@ -0,0 +1,70 @@ +#pragma once + +#include // for transform() +#include // for M_PI +#include "libfreenect.hpp" +#include "Driver/OniDriverAPI.h" +#include "VideoStream.hpp" + + +namespace FreenectDriver { + class ColorStream : public VideoStream { + public: + // from NUI library & converted to radians - please check + static const float DIAGONAL_FOV = 73.9 * (M_PI / 180); + static const float HORIZONTAL_FOV = 62 * (M_PI / 180); + static const float VERTICAL_FOV = 48.6 * (M_PI / 180); + + private: + typedef std::map< OniVideoMode, std::pair > FreenectVideoModeMap; + static const OniSensorType sensor_type = ONI_SENSOR_COLOR; + + static FreenectVideoModeMap getSupportedVideoModes(); + OniStatus setVideoMode(OniVideoMode requested_mode); + void populateFrame(void* data, OniFrame* frame) const; + + public: + ColorStream(Freenect::FreenectDevice* pDevice); + //~ColorStream() { } + + static OniSensorInfo getSensorInfo() { + FreenectVideoModeMap supported_modes = getSupportedVideoModes(); + OniVideoMode* modes = new OniVideoMode[supported_modes.size()]; + std::transform(supported_modes.begin(), supported_modes.end(), modes, RetrieveKey()); + return { sensor_type, SIZE(modes), modes }; // sensorType, numSupportedVideoModes, pSupportedVideoModes + } + + // from StreamBase + OniBool isPropertySupported(int propertyId) { + switch(propertyId) { + default: + return VideoStream::isPropertySupported(propertyId); + case ONI_STREAM_PROPERTY_HORIZONTAL_FOV: + case ONI_STREAM_PROPERTY_VERTICAL_FOV: + return true; + } + } + + OniStatus getProperty(int propertyId, void* data, int* pDataSize) { + switch (propertyId) { + default: + return VideoStream::getProperty(propertyId, data, pDataSize); + + case ONI_STREAM_PROPERTY_HORIZONTAL_FOV: // float (radians) + if (*pDataSize != sizeof(float)) { + printf("Unexpected size: %d != %lu\n", *pDataSize, sizeof(float)); + return ONI_STATUS_ERROR; + } + *(static_cast(data)) = HORIZONTAL_FOV; + return ONI_STATUS_OK; + case ONI_STREAM_PROPERTY_VERTICAL_FOV: // float (radians) + if (*pDataSize != sizeof(float)) { + printf("Unexpected size: %d != %lu\n", *pDataSize, sizeof(float)); + return ONI_STATUS_ERROR; + } + *(static_cast(data)) = VERTICAL_FOV; + return ONI_STATUS_OK; + } + } + }; +} diff --git a/OpenNI2-FreenectDriver/src/D2S.h b/OpenNI2-FreenectDriver/src/D2S.h new file mode 100644 index 00000000..636d7bfa --- /dev/null +++ b/OpenNI2-FreenectDriver/src/D2S.h @@ -0,0 +1,1003 @@ +const unsigned short D2S[] = { +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 3, 7, 10, 13, 17, +20, 23, 27, 30, 33, 36, 40, 43, 46, 49, +52, 55, 59, 62, 65, 68, 71, 74, 77, 80, +83, 86, 88, 91, 94, 97, 100, 103, 106, 108, +111, 114, 117, 119, 122, 125, 128, 130, 133, 136, +138, 141, 143, 146, 149, 151, 154, 156, 159, 161, +164, 166, 169, 171, 174, 176, 178, 181, 183, 186, +188, 190, 193, 195, 197, 200, 202, 204, 206, 209, +211, 213, 215, 218, 220, 222, 224, 226, 229, 231, +233, 235, 237, 239, 241, 243, 245, 247, 249, 252, +254, 256, 258, 260, 262, 264, 266, 267, 269, 271, +273, 275, 277, 279, 281, 283, 285, 287, 288, 290, +292, 294, 296, 298, 299, 301, 303, 305, 307, 308, +310, 312, 314, 315, 317, 319, 321, 322, 324, 326, +327, 329, 331, 332, 334, 336, 337, 339, 341, 342, +344, 345, 347, 349, 350, 352, 353, 355, 357, 358, +360, 361, 363, 364, 366, 367, 369, 370, 372, 373, +375, 376, 378, 379, 381, 382, 383, 385, 386, 388, +389, 391, 392, 393, 395, 396, 398, 399, 400, 402, +403, 404, 406, 407, 409, 410, 411, 413, 414, 415, +416, 418, 419, 420, 422, 423, 424, 426, 427, 428, +429, 431, 432, 433, 434, 436, 437, 438, 439, 441, +442, 443, 444, 445, 447, 448, 449, 450, 451, 452, +454, 455, 456, 457, 458, 459, 461, 462, 463, 464, +465, 466, 467, 468, 470, 471, 472, 473, 474, 475, +476, 477, 478, 479, 480, 482, 483, 484, 485, 486, +487, 488, 489, 490, 491, 492, 493, 494, 495, 496, +497, 498, 499, 500, 501, 502, 503, 504, 505, 506, +507, 508, 509, 510, 511, 512, 513, 514, 515, 516, +517, 518, 519, 520, 521, 521, 522, 523, 524, 525, +526, 527, 528, 529, 530, 531, 532, 532, 533, 534, +535, 536, 537, 538, 539, 540, 540, 541, 542, 543, +544, 545, 546, 546, 547, 548, 549, 550, 551, 551, +552, 553, 554, 555, 556, 556, 557, 558, 559, 560, +561, 561, 562, 563, 564, 565, 565, 566, 567, 568, +568, 569, 570, 571, 572, 572, 573, 574, 575, 575, +576, 577, 578, 578, 579, 580, 581, 581, 582, 583, +584, 584, 585, 586, 587, 587, 588, 589, 590, 590, +591, 592, 592, 593, 594, 594, 595, 596, 597, 597, +598, 599, 599, 600, 601, 601, 602, 603, 604, 604, +605, 606, 606, 607, 608, 608, 609, 610, 610, 611, +612, 612, 613, 614, 614, 615, 615, 616, 617, 617, +618, 619, 619, 620, 621, 621, 622, 622, 623, 624, +624, 625, 626, 626, 627, 627, 628, 629, 629, 630, +631, 631, 632, 632, 633, 634, 634, 635, 635, 636, +636, 637, 638, 638, 639, 639, 640, 641, 641, 642, +642, 643, 643, 644, 645, 645, 646, 646, 647, 647, +648, 649, 649, 650, 650, 651, 651, 652, 652, 653, +654, 654, 655, 655, 656, 656, 657, 657, 658, 658, +659, 659, 660, 661, 661, 662, 662, 663, 663, 664, +664, 665, 665, 666, 666, 667, 667, 668, 668, 669, +669, 670, 670, 671, 671, 672, 672, 673, 673, 674, +674, 675, 675, 676, 676, 677, 677, 678, 678, 679, +679, 680, 680, 681, 681, 682, 682, 683, 683, 684, +684, 685, 685, 685, 686, 686, 687, 687, 688, 688, +689, 689, 690, 690, 691, 691, 691, 692, 692, 693, +693, 694, 694, 695, 695, 696, 696, 696, 697, 697, +698, 698, 699, 699, 699, 700, 700, 701, 701, 702, +702, 703, 703, 703, 704, 704, 705, 705, 706, 706, +706, 707, 707, 708, 708, 708, 709, 709, 710, 710, +711, 711, 711, 712, 712, 713, 713, 713, 714, 714, +715, 715, 715, 716, 716, 717, 717, 717, 718, 718, +719, 719, 719, 720, 720, 721, 721, 721, 722, 722, +723, 723, 723, 724, 724, 724, 725, 725, 726, 726, +726, 727, 727, 727, 728, 728, 729, 729, 729, 730, +730, 730, 731, 731, 732, 732, 732, 733, 733, 733, +734, 734, 734, 735, 735, 736, 736, 736, 737, 737, +737, 738, 738, 738, 739, 739, 739, 740, 740, 741, +741, 741, 742, 742, 742, 743, 743, 743, 744, 744, +744, 745, 745, 745, 746, 746, 746, 747, 747, 747, +748, 748, 748, 749, 749, 749, 750, 750, 750, 751, +751, 751, 752, 752, 752, 753, 753, 753, 754, 754, +754, 755, 755, 755, 756, 756, 756, 756, 757, 757, +757, 758, 758, 758, 759, 759, 759, 760, 760, 760, +761, 761, 761, 761, 762, 762, 762, 763, 763, 763, +764, 764, 764, 765, 765, 765, 765, 766, 766, 766, +767, 767, 767, 768, 768, 768, 768, 769, 769, 769, +770, 770, 770, 770, 771, 771, 771, 772, 772, 772, +773, 773, 773, 773, 774, 774, 774, 775, 775, 775, +775, 776, 776, 776, 776, 777, 777, 777, 778, 778, +778, 778, 779, 779, 779, 780, 780, 780, 780, 781, +781, 781, 781, 782, 782, 782, 783, 783, 783, 783, +784, 784, 784, 784, 785, 785, 785, 785, 786, 786, +786, 787, 787, 787, 787, 788, 788, 788, 788, 789, +789, 789, 789, 790, 790, 790, 790, 791, 791, 791, +791, 792, 792, 792, 792, 793, 793, 793, 793, 794, +794, 794, 794, 795, 795, 795, 795, 796, 796, 796, +796, 797, 797, 797, 797, 798, 798, 798, 798, 799, +799, 799, 799, 800, 800, 800, 800, 801, 801, 801, +801, 801, 802, 802, 802, 802, 803, 803, 803, 803, +804, 804, 804, 804, 805, 805, 805, 805, 805, 806, +806, 806, 806, 807, 807, 807, 807, 808, 808, 808, +808, 808, 809, 809, 809, 809, 810, 810, 810, 810, +810, 811, 811, 811, 811, 812, 812, 812, 812, 812, +813, 813, 813, 813, 813, 814, 814, 814, 814, 815, +815, 815, 815, 815, 816, 816, 816, 816, 817, 817, +817, 817, 817, 818, 818, 818, 818, 818, 819, 819, +819, 819, 819, 820, 820, 820, 820, 820, 821, 821, +821, 821, 822, 822, 822, 822, 822, 823, 823, 823, +823, 823, 824, 824, 824, 824, 824, 825, 825, 825, +825, 825, 826, 826, 826, 826, 826, 827, 827, 827, +827, 827, 828, 828, 828, 828, 828, 828, 829, 829, +829, 829, 829, 830, 830, 830, 830, 830, 831, 831, +831, 831, 831, 832, 832, 832, 832, 832, 832, 833, +833, 833, 833, 833, 834, 834, 834, 834, 834, 835, +835, 835, 835, 835, 835, 836, 836, 836, 836, 836, +837, 837, 837, 837, 837, 837, 838, 838, 838, 838, +838, 839, 839, 839, 839, 839, 839, 840, 840, 840, +840, 840, 841, 841, 841, 841, 841, 841, 842, 842, +842, 842, 842, 842, 843, 843, 843, 843, 843, 843, +844, 844, 844, 844, 844, 845, 845, 845, 845, 845, +845, 846, 846, 846, 846, 846, 846, 847, 847, 847, +847, 847, 847, 848, 848, 848, 848, 848, 848, 849, +849, 849, 849, 849, 849, 850, 850, 850, 850, 850, +850, 850, 851, 851, 851, 851, 851, 851, 852, 852, +852, 852, 852, 852, 853, 853, 853, 853, 853, 853, +854, 854, 854, 854, 854, 854, 854, 855, 855, 855, +855, 855, 855, 856, 856, 856, 856, 856, 856, 857, +857, 857, 857, 857, 857, 857, 858, 858, 858, 858, +858, 858, 858, 859, 859, 859, 859, 859, 859, 860, +860, 860, 860, 860, 860, 860, 861, 861, 861, 861, +861, 861, 861, 862, 862, 862, 862, 862, 862, 863, +863, 863, 863, 863, 863, 863, 864, 864, 864, 864, +864, 864, 864, 865, 865, 865, 865, 865, 865, 865, +866, 866, 866, 866, 866, 866, 866, 867, 867, 867, +867, 867, 867, 867, 868, 868, 868, 868, 868, 868, +868, 868, 869, 869, 869, 869, 869, 869, 869, 870, +870, 870, 870, 870, 870, 870, 871, 871, 871, 871, +871, 871, 871, 871, 872, 872, 872, 872, 872, 872, +872, 873, 873, 873, 873, 873, 873, 873, 873, 874, +874, 874, 874, 874, 874, 874, 875, 875, 875, 875, +875, 875, 875, 875, 876, 876, 876, 876, 876, 876, +876, 876, 877, 877, 877, 877, 877, 877, 877, 878, +878, 878, 878, 878, 878, 878, 878, 879, 879, 879, +879, 879, 879, 879, 879, 880, 880, 880, 880, 880, +880, 880, 880, 881, 881, 881, 881, 881, 881, 881, +881, 882, 882, 882, 882, 882, 882, 882, 882, 882, +883, 883, 883, 883, 883, 883, 883, 883, 884, 884, +884, 884, 884, 884, 884, 884, 885, 885, 885, 885, +885, 885, 885, 885, 885, 886, 886, 886, 886, 886, +886, 886, 886, 887, 887, 887, 887, 887, 887, 887, +887, 887, 888, 888, 888, 888, 888, 888, 888, 888, +888, 889, 889, 889, 889, 889, 889, 889, 889, 890, +890, 890, 890, 890, 890, 890, 890, 890, 891, 891, +891, 891, 891, 891, 891, 891, 891, 892, 892, 892, +892, 892, 892, 892, 892, 892, 893, 893, 893, 893, +893, 893, 893, 893, 893, 893, 894, 894, 894, 894, +894, 894, 894, 894, 894, 895, 895, 895, 895, 895, +895, 895, 895, 895, 896, 896, 896, 896, 896, 896, +896, 896, 896, 896, 897, 897, 897, 897, 897, 897, +897, 897, 897, 898, 898, 898, 898, 898, 898, 898, +898, 898, 898, 899, 899, 899, 899, 899, 899, 899, +899, 899, 899, 900, 900, 900, 900, 900, 900, 900, +900, 900, 900, 901, 901, 901, 901, 901, 901, 901, +901, 901, 901, 902, 902, 902, 902, 902, 902, 902, +902, 902, 902, 903, 903, 903, 903, 903, 903, 903, +903, 903, 903, 904, 904, 904, 904, 904, 904, 904, +904, 904, 904, 905, 905, 905, 905, 905, 905, 905, +905, 905, 905, 905, 906, 906, 906, 906, 906, 906, +906, 906, 906, 906, 907, 907, 907, 907, 907, 907, +907, 907, 907, 907, 907, 908, 908, 908, 908, 908, +908, 908, 908, 908, 908, 908, 909, 909, 909, 909, +909, 909, 909, 909, 909, 909, 910, 910, 910, 910, +910, 910, 910, 910, 910, 910, 910, 911, 911, 911, +911, 911, 911, 911, 911, 911, 911, 911, 911, 912, +912, 912, 912, 912, 912, 912, 912, 912, 912, 912, +913, 913, 913, 913, 913, 913, 913, 913, 913, 913, +913, 914, 914, 914, 914, 914, 914, 914, 914, 914, +914, 914, 914, 915, 915, 915, 915, 915, 915, 915, +915, 915, 915, 915, 915, 916, 916, 916, 916, 916, +916, 916, 916, 916, 916, 916, 917, 917, 917, 917, +917, 917, 917, 917, 917, 917, 917, 917, 918, 918, +918, 918, 918, 918, 918, 918, 918, 918, 918, 918, +919, 919, 919, 919, 919, 919, 919, 919, 919, 919, +919, 919, 919, 920, 920, 920, 920, 920, 920, 920, +920, 920, 920, 920, 920, 921, 921, 921, 921, 921, +921, 921, 921, 921, 921, 921, 921, 921, 922, 922, +922, 922, 922, 922, 922, 922, 922, 922, 922, 922, +923, 923, 923, 923, 923, 923, 923, 923, 923, 923, +923, 923, 923, 924, 924, 924, 924, 924, 924, 924, +924, 924, 924, 924, 924, 924, 925, 925, 925, 925, +925, 925, 925, 925, 925, 925, 925, 925, 925, 926, +926, 926, 926, 926, 926, 926, 926, 926, 926, 926, +926, 926, 926, 927, 927, 927, 927, 927, 927, 927, +927, 927, 927, 927, 927, 927, 928, 928, 928, 928, +928, 928, 928, 928, 928, 928, 928, 928, 928, 928, +929, 929, 929, 929, 929, 929, 929, 929, 929, 929, +929, 929, 929, 929, 930, 930, 930, 930, 930, 930, +930, 930, 930, 930, 930, 930, 930, 930, 931, 931, +931, 931, 931, 931, 931, 931, 931, 931, 931, 931, +931, 931, 932, 932, 932, 932, 932, 932, 932, 932, +932, 932, 932, 932, 932, 932, 933, 933, 933, 933, +933, 933, 933, 933, 933, 933, 933, 933, 933, 933, +933, 934, 934, 934, 934, 934, 934, 934, 934, 934, +934, 934, 934, 934, 934, 934, 935, 935, 935, 935, +935, 935, 935, 935, 935, 935, 935, 935, 935, 935, +935, 936, 936, 936, 936, 936, 936, 936, 936, 936, +936, 936, 936, 936, 936, 936, 937, 937, 937, 937, +937, 937, 937, 937, 937, 937, 937, 937, 937, 937, +937, 938, 938, 938, 938, 938, 938, 938, 938, 938, +938, 938, 938, 938, 938, 938, 938, 939, 939, 939, +939, 939, 939, 939, 939, 939, 939, 939, 939, 939, +939, 939, 939, 940, 940, 940, 940, 940, 940, 940, +940, 940, 940, 940, 940, 940, 940, 940, 940, 941, +941, 941, 941, 941, 941, 941, 941, 941, 941, 941, +941, 941, 941, 941, 941, 942, 942, 942, 942, 942, +942, 942, 942, 942, 942, 942, 942, 942, 942, 942, +942, 943, 943, 943, 943, 943, 943, 943, 943, 943, +943, 943, 943, 943, 943, 943, 943, 943, 944, 944, +944, 944, 944, 944, 944, 944, 944, 944, 944, 944, +944, 944, 944, 944, 944, 945, 945, 945, 945, 945, +945, 945, 945, 945, 945, 945, 945, 945, 945, 945, +945, 945, 946, 946, 946, 946, 946, 946, 946, 946, +946, 946, 946, 946, 946, 946, 946, 946, 946, 946, +947, 947, 947, 947, 947, 947, 947, 947, 947, 947, +947, 947, 947, 947, 947, 947, 947, 948, 948, 948, +948, 948, 948, 948, 948, 948, 948, 948, 948, 948, +948, 948, 948, 948, 948, 949, 949, 949, 949, 949, +949, 949, 949, 949, 949, 949, 949, 949, 949, 949, +949, 949, 949, 950, 950, 950, 950, 950, 950, 950, +950, 950, 950, 950, 950, 950, 950, 950, 950, 950, +950, 950, 951, 951, 951, 951, 951, 951, 951, 951, +951, 951, 951, 951, 951, 951, 951, 951, 951, 951, +951, 952, 952, 952, 952, 952, 952, 952, 952, 952, +952, 952, 952, 952, 952, 952, 952, 952, 952, 952, +953, 953, 953, 953, 953, 953, 953, 953, 953, 953, +953, 953, 953, 953, 953, 953, 953, 953, 953, 954, +954, 954, 954, 954, 954, 954, 954, 954, 954, 954, +954, 954, 954, 954, 954, 954, 954, 954, 955, 955, +955, 955, 955, 955, 955, 955, 955, 955, 955, 955, +955, 955, 955, 955, 955, 955, 955, 955, 956, 956, +956, 956, 956, 956, 956, 956, 956, 956, 956, 956, +956, 956, 956, 956, 956, 956, 956, 956, 956, 957, +957, 957, 957, 957, 957, 957, 957, 957, 957, 957, +957, 957, 957, 957, 957, 957, 957, 957, 957, 958, +958, 958, 958, 958, 958, 958, 958, 958, 958, 958, +958, 958, 958, 958, 958, 958, 958, 958, 958, 958, +959, 959, 959, 959, 959, 959, 959, 959, 959, 959, +959, 959, 959, 959, 959, 959, 959, 959, 959, 959, +959, 960, 960, 960, 960, 960, 960, 960, 960, 960, +960, 960, 960, 960, 960, 960, 960, 960, 960, 960, +960, 960, 960, 961, 961, 961, 961, 961, 961, 961, +961, 961, 961, 961, 961, 961, 961, 961, 961, 961, +961, 961, 961, 961, 962, 962, 962, 962, 962, 962, +962, 962, 962, 962, 962, 962, 962, 962, 962, 962, +962, 962, 962, 962, 962, 962, 962, 963, 963, 963, +963, 963, 963, 963, 963, 963, 963, 963, 963, 963, +963, 963, 963, 963, 963, 963, 963, 963, 963, 964, +964, 964, 964, 964, 964, 964, 964, 964, 964, 964, +964, 964, 964, 964, 964, 964, 964, 964, 964, 964, +964, 964, 965, 965, 965, 965, 965, 965, 965, 965, +965, 965, 965, 965, 965, 965, 965, 965, 965, 965, +965, 965, 965, 965, 965, 966, 966, 966, 966, 966, +966, 966, 966, 966, 966, 966, 966, 966, 966, 966, +966, 966, 966, 966, 966, 966, 966, 966, 966, 967, +967, 967, 967, 967, 967, 967, 967, 967, 967, 967, +967, 967, 967, 967, 967, 967, 967, 967, 967, 967, +967, 967, 967, 968, 968, 968, 968, 968, 968, 968, +968, 968, 968, 968, 968, 968, 968, 968, 968, 968, +968, 968, 968, 968, 968, 968, 968, 968, 969, 969, +969, 969, 969, 969, 969, 969, 969, 969, 969, 969, +969, 969, 969, 969, 969, 969, 969, 969, 969, 969, +969, 969, 969, 970, 970, 970, 970, 970, 970, 970, +970, 970, 970, 970, 970, 970, 970, 970, 970, 970, +970, 970, 970, 970, 970, 970, 970, 970, 971, 971, +971, 971, 971, 971, 971, 971, 971, 971, 971, 971, +971, 971, 971, 971, 971, 971, 971, 971, 971, 971, +971, 971, 971, 971, 972, 972, 972, 972, 972, 972, +972, 972, 972, 972, 972, 972, 972, 972, 972, 972, +972, 972, 972, 972, 972, 972, 972, 972, 972, 972, +973, 973, 973, 973, 973, 973, 973, 973, 973, 973, +973, 973, 973, 973, 973, 973, 973, 973, 973, 973, +973, 973, 973, 973, 973, 973, 973, 974, 974, 974, +974, 974, 974, 974, 974, 974, 974, 974, 974, 974, +974, 974, 974, 974, 974, 974, 974, 974, 974, 974, +974, 974, 974, 974, 975, 975, 975, 975, 975, 975, +975, 975, 975, 975, 975, 975, 975, 975, 975, 975, +975, 975, 975, 975, 975, 975, 975, 975, 975, 975, +975, 975, 976, 976, 976, 976, 976, 976, 976, 976, +976, 976, 976, 976, 976, 976, 976, 976, 976, 976, +976, 976, 976, 976, 976, 976, 976, 976, 976, 976, +977, 977, 977, 977, 977, 977, 977, 977, 977, 977, +977, 977, 977, 977, 977, 977, 977, 977, 977, 977, +977, 977, 977, 977, 977, 977, 977, 977, 977, 978, +978, 978, 978, 978, 978, 978, 978, 978, 978, 978, +978, 978, 978, 978, 978, 978, 978, 978, 978, 978, +978, 978, 978, 978, 978, 978, 978, 978, 979, 979, +979, 979, 979, 979, 979, 979, 979, 979, 979, 979, +979, 979, 979, 979, 979, 979, 979, 979, 979, 979, +979, 979, 979, 979, 979, 979, 979, 979, 980, 980, +980, 980, 980, 980, 980, 980, 980, 980, 980, 980, +980, 980, 980, 980, 980, 980, 980, 980, 980, 980, +980, 980, 980, 980, 980, 980, 980, 980, 981, 981, +981, 981, 981, 981, 981, 981, 981, 981, 981, 981, +981, 981, 981, 981, 981, 981, 981, 981, 981, 981, +981, 981, 981, 981, 981, 981, 981, 981, 981, 982, +982, 982, 982, 982, 982, 982, 982, 982, 982, 982, +982, 982, 982, 982, 982, 982, 982, 982, 982, 982, +982, 982, 982, 982, 982, 982, 982, 982, 982, 982, +983, 983, 983, 983, 983, 983, 983, 983, 983, 983, +983, 983, 983, 983, 983, 983, 983, 983, 983, 983, +983, 983, 983, 983, 983, 983, 983, 983, 983, 983, +983, 983, 983, 984, 984, 984, 984, 984, 984, 984, +984, 984, 984, 984, 984, 984, 984, 984, 984, 984, +984, 984, 984, 984, 984, 984, 984, 984, 984, 984, +984, 984, 984, 984, 984, 985, 985, 985, 985, 985, +985, 985, 985, 985, 985, 985, 985, 985, 985, 985, +985, 985, 985, 985, 985, 985, 985, 985, 985, 985, +985, 985, 985, 985, 985, 985, 985, 985, 985, 986, +986, 986, 986, 986, 986, 986, 986, 986, 986, 986, +986, 986, 986, 986, 986, 986, 986, 986, 986, 986, +986, 986, 986, 986, 986, 986, 986, 986, 986, 986, +986, 986, 986, 987, 987, 987, 987, 987, 987, 987, +987, 987, 987, 987, 987, 987, 987, 987, 987, 987, +987, 987, 987, 987, 987, 987, 987, 987, 987, 987, +987, 987, 987, 987, 987, 987, 987, 987, 988, 988, +988, 988, 988, 988, 988, 988, 988, 988, 988, 988, +988, 988, 988, 988, 988, 988, 988, 988, 988, 988, +988, 988, 988, 988, 988, 988, 988, 988, 988, 988, +988, 988, 988, 989, 989, 989, 989, 989, 989, 989, +989, 989, 989, 989, 989, 989, 989, 989, 989, 989, +989, 989, 989, 989, 989, 989, 989, 989, 989, 989, +989, 989, 989, 989, 989, 989, 989, 989, 989, 990, +990, 990, 990, 990, 990, 990, 990, 990, 990, 990, +990, 990, 990, 990, 990, 990, 990, 990, 990, 990, +990, 990, 990, 990, 990, 990, 990, 990, 990, 990, +990, 990, 990, 990, 990, 990, 991, 991, 991, 991, +991, 991, 991, 991, 991, 991, 991, 991, 991, 991, +991, 991, 991, 991, 991, 991, 991, 991, 991, 991, +991, 991, 991, 991, 991, 991, 991, 991, 991, 991, +991, 991, 991, 991, 992, 992, 992, 992, 992, 992, +992, 992, 992, 992, 992, 992, 992, 992, 992, 992, +992, 992, 992, 992, 992, 992, 992, 992, 992, 992, +992, 992, 992, 992, 992, 992, 992, 992, 992, 992, +992, 992, 992, 993, 993, 993, 993, 993, 993, 993, +993, 993, 993, 993, 993, 993, 993, 993, 993, 993, +993, 993, 993, 993, 993, 993, 993, 993, 993, 993, +993, 993, 993, 993, 993, 993, 993, 993, 993, 993, +993, 993, 994, 994, 994, 994, 994, 994, 994, 994, +994, 994, 994, 994, 994, 994, 994, 994, 994, 994, +994, 994, 994, 994, 994, 994, 994, 994, 994, 994, +994, 994, 994, 994, 994, 994, 994, 994, 994, 994, +994, 994, 995, 995, 995, 995, 995, 995, 995, 995, +995, 995, 995, 995, 995, 995, 995, 995, 995, 995, +995, 995, 995, 995, 995, 995, 995, 995, 995, 995, +995, 995, 995, 995, 995, 995, 995, 995, 995, 995, +995, 995, 995, 995, 996, 996, 996, 996, 996, 996, +996, 996, 996, 996, 996, 996, 996, 996, 996, 996, +996, 996, 996, 996, 996, 996, 996, 996, 996, 996, +996, 996, 996, 996, 996, 996, 996, 996, 996, 996, +996, 996, 996, 996, 996, 996, 997, 997, 997, 997, +997, 997, 997, 997, 997, 997, 997, 997, 997, 997, +997, 997, 997, 997, 997, 997, 997, 997, 997, 997, +997, 997, 997, 997, 997, 997, 997, 997, 997, 997, +997, 997, 997, 997, 997, 997, 997, 997, 997, 998, +998, 998, 998, 998, 998, 998, 998, 998, 998, 998, +998, 998, 998, 998, 998, 998, 998, 998, 998, 998, +998, 998, 998, 998, 998, 998, 998, 998, 998, 998, +998, 998, 998, 998, 998, 998, 998, 998, 998, 998, +998, 998, 998, 999, 999, 999, 999, 999, 999, 999, +999, 999, 999, 999, 999, 999, 999, 999, 999, 999, +999, 999, 999, 999, 999, 999, 999, 999, 999, 999, +999, 999, 999, 999, 999, 999, 999, 999, 999, 999, +999, 999, 999, 999, 999, 999, 999, 999, 1000, 1000, +1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, +1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, +1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, +1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, +1000, 1000, 1000, 1000, 1001, 1001, 1001, 1001, 1001, 1001, +1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, +1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, +1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, +1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, +1001, 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, +1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, +1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, +1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, +1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1003, +1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, +1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, +1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, +1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, +1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1004, +1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, +1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, +1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, +1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, +1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, +1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, +1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, +1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, +1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, +1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, +1005, 1006, 1006, 1006, 1006, 1006, 1006, 1006, 1006, 1006, +1006, 1006, 1006, 1006, 1006, 1006, 1006, 1006, 1006, 1006, +1006, 1006, 1006, 1006, 1006, 1006, 1006, 1006, 1006, 1006, +1006, 1006, 1006, 1006, 1006, 1006, 1006, 1006, 1006, 1006, +1006, 1006, 1006, 1006, 1006, 1006, 1006, 1006, 1006, 1006, +1006, 1006, 1006, 1006, 1006, 1007, 1007, 1007, 1007, 1007, +1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, +1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, +1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, +1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, +1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1008, +1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, +1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, +1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, +1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, +1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, +1008, 1008, 1008, 1008, 1008, 1009, 1009, 1009, 1009, 1009, +1009, 1009, 1009, 1009, 1009, 1009, 1009, 1009, 1009, 1009, +1009, 1009, 1009, 1009, 1009, 1009, 1009, 1009, 1009, 1009, +1009, 1009, 1009, 1009, 1009, 1009, 1009, 1009, 1009, 1009, +1009, 1009, 1009, 1009, 1009, 1009, 1009, 1009, 1009, 1009, +1009, 1009, 1009, 1009, 1009, 1009, 1009, 1009, 1009, 1009, +1009, 1009, 1009, 1010, 1010, 1010, 1010, 1010, 1010, 1010, +1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, +1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, +1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, +1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, +1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, +1010, 1010, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, +1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, +1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, +1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, +1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, +1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, +1011, 1011, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, +1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, +1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, +1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, +1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, +1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, +1012, 1012, 1012, 1012, 1012, 1013, 1013, 1013, 1013, 1013, +1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, +1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, +1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, +1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, +1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, +1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1014, 1014, +1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, +1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, +1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, +1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, +1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, +1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, +1014, 1014, 1014, 1014, 1015, 1015, 1015, 1015, 1015, 1015, +1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, +1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, +1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, +1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, +1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, +1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, +1015, 1015, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, +1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, +1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, +1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, +1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, +1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, +1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, +1016, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, +1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, +1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, +1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, +1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, +1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, +1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, +1017, 1017, 1017, 1018, 1018, 1018, 1018, 1018, 1018, 1018, +1018, 1018, 1018, 1018, 1018, 1018, 1018, 1018, 1018, 1018, +1018, 1018, 1018, 1018, 1018, 1018, 1018, 1018, 1018, 1018, +1018, 1018, 1018, 1018, 1018, 1018, 1018, 1018, 1018, 1018, +1018, 1018, 1018, 1018, 1018, 1018, 1018, 1018, 1018, 1018, +1018, 1018, 1018, 1018, 1018, 1018, 1018, 1018, 1018, 1018, +1018, 1018, 1018, 1018, 1018, 1018, 1018, 1018, 1018, 1018, +1018, 1018, 1018, 1018, 1018, 1018, 1019, 1019, 1019, 1019, +1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, +1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, +1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, +1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, +1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, +1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, +1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, +1019, 1019, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, +1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, +1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, +1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, +1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, +1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, +1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, +1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, +1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, +1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, +1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, +1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, +1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, +1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, +1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, +1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, +1021, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, +1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, +1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, +1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, +1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, +1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, +1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, +1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, +1022, 1022, 1022, 1022, 1023, 1023, 1023, 1023, 1023, 1023, +1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, +1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, +1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, +1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, +1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, +1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, +1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, +1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, +1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, +1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, +1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, +1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, +1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, +1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, +1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, +1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, +1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1025, 1025, +1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, +1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, +1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, +1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, +1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, +1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, +1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, +1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, +1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, +1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, +1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, +1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, +1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, +1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, +1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, +1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, +1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, +1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, +1026, 1026, 1026, 1026, 1027, 1027, 1027, 1027, 1027, 1027, +1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, +1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, +1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, +1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, +1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, +1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, +1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, +1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, +1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, +1027, 1027, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, +1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, +1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, +1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, +1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, +1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, +1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, +1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, +1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, +1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, +1028, 1028, 1028, 1029, 1029, 1029, 1029, 1029, 1029, 1029, +1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, +1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, +1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, +1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, +1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, +1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, +1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, +1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, +1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, +1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1030, 1030, +1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, +1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, +1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, +1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, +1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, +1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, +1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, +1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, +1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, +1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, +1030, 1030, 1030, 1030, 1030, 1030, 1031, 1031, 1031, 1031, +1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, +1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, +1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, +1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, +1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, +1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, +1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, +1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, +1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, +1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, +1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1032, +1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, +1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, +1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, +1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, +1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, +1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, +1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, +1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, +1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, +1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, +1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, +1032, 1032, 1032, 1032, 1032, 1033, 1033, 1033, 1033, 1033, +1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, +1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, +1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, +1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, +1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, +1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, +1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, +1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, +1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, +1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, +1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, +1033, 1033, 1033, 1033, 1033, 1033, 1033, 1034, 1034, 1034, +1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, +1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, +1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, +1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, +1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, +1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, +1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, +1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, +1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, +1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, +1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, +1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, +1034, 1034, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, +1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, +1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, +1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, +1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, +1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, +1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, +1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, +1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, +1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, +1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, +1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, +1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, +1035, 1035, 1035, 1036, 1036, 1036, 1036, 1036, 1036, 1036, +1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, +1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, +1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, +1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, +1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, +1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, +1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, +1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, +1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, +1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, +1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, +1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, +1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1037, +1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, +1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, +1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, +1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, +1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, +1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, +1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, +1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, +1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, +1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, +1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, +1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, +1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, +1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, +1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, +1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, +1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, +1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, +1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, +1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, +1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, +1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, +1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, +1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, +1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, +1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, +1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, +1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, +1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1039, 1039, +1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, +1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, +1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, +1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, +1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, +1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, +1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, +1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, +1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, +1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, +1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, +1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, +1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, +1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, +1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, +1039, 1039, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, +1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, +1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, +1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, +1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, +1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, +1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, +1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, +1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, +1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, +1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, +1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, +1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, +1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, +1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, +1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, +1040, 1040, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, +1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, +1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, +1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, +1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, +1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, +1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, +1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, +1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, +1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, +1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, +1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, +1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, +1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, +1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, +1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, +1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, +1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, +1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, +1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, +1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, +1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, +1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, +1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, +1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, +1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, +1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, +1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, +1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, +1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, +1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, +1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, +1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, +1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, +1042, 1042, 1042, 1042, 1042, 1043, 1043, 1043, 1043, 1043, +1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, +1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, +1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, +1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, +1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, +1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, +1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, +1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, +1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, +1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, +1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, +1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, +1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, +1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, +1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, +1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, +1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, +1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1044, +1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, +1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, +1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, +1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, +1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, +1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, +1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, +1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, +1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, +1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, +1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, +1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, +1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, +1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, +1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, +1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, +1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, +1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, +1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, +1044, 1044, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, +1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, +1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, +1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, +1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, +1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, +1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, +1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, +1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, +1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, +1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, +1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, +1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, +1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, +1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, +1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, +1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, +1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, +1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, +1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, +1045, 1045, 1045, 1046, 1046, 1046, 1046, 1046, 1046, 1046, +1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, +1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, +1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, +1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, +1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, +1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, +1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, +1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, +1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, +1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, +1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, +1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, +1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, +1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, +1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, +1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, +1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, +1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, +1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, +1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, +1046, 1046, 1046, 1046, 1046, 1046, 1047, 1047, 1047, 1047, +1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, +1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, +1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, +1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, +1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, +1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, +1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, +1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, +1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, +1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, +1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, +1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, +1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, +1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, +1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, +1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, +1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, +1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, +1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, +1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, +1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, +1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1048, +1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, +1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, +1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, +1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, +1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, +1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, +1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, +1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, +1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, +1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, +1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, +1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, +1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, +1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, +1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, +1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, +1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, +1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, +1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, +1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, +1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, +1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, +1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, +1048, 1048, 1048, 1048, 1049, 1049, 1049, 1049, 1049, 1049, +1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, +1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, +1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, +1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, +1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, +1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, +1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, +1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, +1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, +1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, +1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, +1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, +1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, +1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, +1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, +1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, +1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, +1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, +1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, +1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, +1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, +1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, +1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, +1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, +1049, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, +1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, +1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, +1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, +1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, +1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, +1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, +1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, +1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, +1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, +1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, +1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, +1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, +1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, +1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, +1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, +1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, +1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, +1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, +1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, +1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, +1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, +1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, +1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, +1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, +1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, +1050, 1050, 1050, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, +1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, +1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, +1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, +1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, +1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, +1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, +1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, +1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, +1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, +1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, +1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, +1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, +1052}; + diff --git a/OpenNI2-FreenectDriver/src/DepthStream.cpp b/OpenNI2-FreenectDriver/src/DepthStream.cpp new file mode 100644 index 00000000..dbab61da --- /dev/null +++ b/OpenNI2-FreenectDriver/src/DepthStream.cpp @@ -0,0 +1,131 @@ +#include "DepthStream.hpp" + +using namespace FreenectDriver; + + +DepthStream::DepthStream(Freenect::FreenectDevice* pDevice) : VideoStream(pDevice) { + video_mode = makeOniVideoMode(ONI_PIXEL_FORMAT_DEPTH_1_MM, 640, 480, 30); + image_registration_mode = ONI_IMAGE_REGISTRATION_OFF; + setVideoMode(video_mode); +} + +// Add video modes here as you implement them +// Note: if image_registration_mode == ONI_IMAGE_REGISTRATION_DEPTH_TO_COLOR, +// setVideoFormat() will try FREENECT_DEPTH_REGISTERED first then fall back on what is set here. +DepthStream::FreenectDepthModeMap DepthStream::getSupportedVideoModes() { + FreenectDepthModeMap modes; + // pixelFormat, resolutionX, resolutionY, fps + modes[makeOniVideoMode(ONI_PIXEL_FORMAT_DEPTH_1_MM, 640, 480, 30)] = std::pair(FREENECT_DEPTH_MM, FREENECT_RESOLUTION_MEDIUM); + + + return modes; +} + +OniStatus DepthStream::setVideoMode(OniVideoMode requested_mode) { + FreenectDepthModeMap supported_video_modes = getSupportedVideoModes(); + FreenectDepthModeMap::const_iterator matched_mode_iter = supported_video_modes.find(requested_mode); + if (matched_mode_iter == supported_video_modes.end()) + return ONI_STATUS_NOT_SUPPORTED; + + freenect_depth_format format = matched_mode_iter->second.first; + freenect_resolution resolution = matched_mode_iter->second.second; + if (image_registration_mode == ONI_IMAGE_REGISTRATION_DEPTH_TO_COLOR) // try forcing registration mode + format = FREENECT_DEPTH_REGISTERED; + + try { device->setDepthFormat(format, resolution); } + catch (std::runtime_error e) { + printf("format-resolution combination not supported by libfreenect: %d-%d\n", format, resolution); + if (image_registration_mode == ONI_IMAGE_REGISTRATION_DEPTH_TO_COLOR) { + printf("could not use image registration format; disabling registration and falling back to format defined in getSupportedVideoModes()\n"); + image_registration_mode = ONI_IMAGE_REGISTRATION_OFF; + return setVideoMode(requested_mode); + } + return ONI_STATUS_NOT_SUPPORTED; + } + video_mode = requested_mode; + return ONI_STATUS_OK; +} + +void DepthStream::populateFrame(void* data, OniFrame* frame) const { + frame->sensorType = sensor_type; + frame->stride = video_mode.resolutionX * sizeof(uint16_t); + + if (cropping.enabled) { + frame->height = cropping.height; + frame->width = cropping.width; + frame->cropOriginX = cropping.originX; + frame->cropOriginY = cropping.originY; + frame->croppingEnabled = true; + } + else { + frame->cropOriginX = frame->cropOriginY = 0; + frame->croppingEnabled = false; + } + + + // copy stream buffer from freenect + + unsigned short* source = static_cast(data) + frame->cropOriginX + frame->cropOriginY * video_mode.resolutionX; + unsigned short* target = static_cast(frame->data); + const unsigned int skipWidth = video_mode.resolutionX - frame->width; + + if (mirroring) { + target += frame->width; + + for (int y = 0; y < frame->height; y++) { + for (int x = 0; x < frame->width; x++) { + unsigned short value = *(source++); + *(target--) = value < DepthStream::MAX_VALUE ? value : 0; + } + + source += skipWidth; + target += 2 * frame->width; + } + } + else { + for (int y = 0; y < frame->height; y++) { + for (int x = 0; x < frame->width; x++) { + unsigned short value = *(source++); + *(target++) = value < DepthStream::MAX_VALUE ? value : 0; + } + + source += skipWidth; + } + } + + /* + uint16_t* data_ptr = static_cast(data); + uint16_t* frame_data = static_cast(frame->data); + if (mirroring) + { + for (unsigned int i = 0; i < frame->dataSize / 2; i++) + { + // find corresponding mirrored pixel + unsigned int row = i / video_mode.resolutionX; + unsigned int col = video_mode.resolutionX - (i % video_mode.resolutionX); + unsigned int target = (row * video_mode.resolutionX) + col; + // copy it to this pixel + frame_data[i] = data_ptr[target]; + } + } + else + std::copy(data_ptr, data_ptr+frame->dataSize / 2, frame_data); + */ +} + + +/* depth video modes reference + +FREENECT_DEPTH_11BIT = 0, //< 11 bit depth information in one uint16_t/pixel +FREENECT_DEPTH_10BIT = 1, //< 10 bit depth information in one uint16_t/pixel +FREENECT_DEPTH_11BIT_PACKED = 2, //< 11 bit packed depth information +FREENECT_DEPTH_10BIT_PACKED = 3, //< 10 bit packed depth information +FREENECT_DEPTH_REGISTERED = 4, //< processed depth data in mm, aligned to 640x480 RGB +FREENECT_DEPTH_MM = 5, //< depth to each pixel in mm, but left unaligned to RGB image +FREENECT_DEPTH_DUMMY = 2147483647, //< Dummy value to force enum to be 32 bits wide + +ONI_PIXEL_FORMAT_DEPTH_1_MM = 100, +ONI_PIXEL_FORMAT_DEPTH_100_UM = 101, +ONI_PIXEL_FORMAT_SHIFT_9_2 = 102, +ONI_PIXEL_FORMAT_SHIFT_9_3 = 103, +*/ diff --git a/OpenNI2-FreenectDriver/src/DepthStream.hpp b/OpenNI2-FreenectDriver/src/DepthStream.hpp new file mode 100644 index 00000000..aa761a80 --- /dev/null +++ b/OpenNI2-FreenectDriver/src/DepthStream.hpp @@ -0,0 +1,190 @@ +#pragma once + +#include // for transform() +#include // for M_PI +#include // fror memcpy +#include "libfreenect.hpp" +#include "Driver/OniDriverAPI.h" +#include "PS1080.h" +#include "VideoStream.hpp" +#include "S2D.h" +#include "D2S.h" + + +namespace FreenectDriver { + class DepthStream : public VideoStream { + public: + // from NUI library and converted to radians - please check + static const float DIAGONAL_FOV = 70 * (M_PI / 180); + static const float HORIZONTAL_FOV = 58.5 * (M_PI / 180); + static const float VERTICAL_FOV = 45.6 * (M_PI / 180); + // from DepthKinectStream.cpp - please check + static const int MAX_VALUE = 10000; + static const unsigned long long GAIN_VAL = 42; + static const unsigned long long CONST_SHIFT_VAL = 200; + static const unsigned long long MAX_SHIFT_VAL = 2047; + static const unsigned long long PARAM_COEFF_VAL = 4; + static const unsigned long long SHIFT_SCALE_VAL = 10; + static const unsigned long long ZERO_PLANE_DISTANCE_VAL = 120; + static const double ZERO_PLANE_PIXEL_SIZE_VAL = 0.10520000010728836; + static const double EMITTER_DCMOS_DISTANCE_VAL = 7.5; + + private: + typedef std::map< OniVideoMode, std::pair > FreenectDepthModeMap; + static const OniSensorType sensor_type = ONI_SENSOR_DEPTH; + OniImageRegistrationMode image_registration_mode; + + static FreenectDepthModeMap getSupportedVideoModes(); + OniStatus setVideoMode(OniVideoMode requested_mode); + void populateFrame(void* data, OniFrame* frame) const; + + public: + DepthStream(Freenect::FreenectDevice* pDevice); + //~DepthStream() { } + + static OniSensorInfo getSensorInfo() { + FreenectDepthModeMap supported_modes = getSupportedVideoModes(); + OniVideoMode* modes = new OniVideoMode[supported_modes.size()]; + std::transform(supported_modes.begin(), supported_modes.end(), modes, RetrieveKey()); + return { sensor_type, SIZE(modes), modes }; // sensorType, numSupportedVideoModes, pSupportedVideoModes + } + + OniImageRegistrationMode getImageRegistrationMode() const { return image_registration_mode; } + OniStatus setImageRegistrationMode(OniImageRegistrationMode mode) { + if (!isImageRegistrationModeSupported(mode)) + return ONI_STATUS_NOT_SUPPORTED; + image_registration_mode = mode; + return setVideoMode(video_mode); + } + + // from StreamBase + OniBool isImageRegistrationModeSupported(OniImageRegistrationMode mode) { return (mode == ONI_IMAGE_REGISTRATION_OFF || mode == ONI_IMAGE_REGISTRATION_DEPTH_TO_COLOR); } + + OniBool isPropertySupported(int propertyId) { + switch(propertyId) { + default: + return VideoStream::isPropertySupported(propertyId); + case ONI_STREAM_PROPERTY_HORIZONTAL_FOV: + case ONI_STREAM_PROPERTY_VERTICAL_FOV: + case ONI_STREAM_PROPERTY_MAX_VALUE: + case XN_STREAM_PROPERTY_GAIN: + case XN_STREAM_PROPERTY_CONST_SHIFT: + case XN_STREAM_PROPERTY_MAX_SHIFT: + case XN_STREAM_PROPERTY_PARAM_COEFF: + case XN_STREAM_PROPERTY_SHIFT_SCALE: + case XN_STREAM_PROPERTY_ZERO_PLANE_DISTANCE: + case XN_STREAM_PROPERTY_ZERO_PLANE_PIXEL_SIZE: + case XN_STREAM_PROPERTY_EMITTER_DCMOS_DISTANCE: + case XN_STREAM_PROPERTY_S2D_TABLE: + case XN_STREAM_PROPERTY_D2S_TABLE: + return true; + } + } + + OniStatus getProperty(int propertyId, void* data, int* pDataSize) { + switch (propertyId) { + default: + return VideoStream::getProperty(propertyId, data, pDataSize); + + case ONI_STREAM_PROPERTY_HORIZONTAL_FOV: // float (radians) + if (*pDataSize != sizeof(float)) { + printf("Unexpected size: %d != %lu\n", *pDataSize, sizeof(float)); + return ONI_STATUS_ERROR; + } + *(static_cast(data)) = HORIZONTAL_FOV; + return ONI_STATUS_OK; + case ONI_STREAM_PROPERTY_VERTICAL_FOV: // float (radians) + if (*pDataSize != sizeof(float)) { + printf("Unexpected size: %d != %lu\n", *pDataSize, sizeof(float)); + return ONI_STATUS_ERROR; + } + *(static_cast(data)) = VERTICAL_FOV; + return ONI_STATUS_OK; + case ONI_STREAM_PROPERTY_MAX_VALUE: // int + if (*pDataSize != sizeof(int)) { + printf("Unexpected size: %d != %lu\n", *pDataSize, sizeof(int)); + return ONI_STATUS_ERROR; + } + *(static_cast(data)) = MAX_VALUE; + return ONI_STATUS_OK; + + case XN_STREAM_PROPERTY_PIXEL_REGISTRATION: // XnPixelRegistration (get only) + case XN_STREAM_PROPERTY_WHITE_BALANCE_ENABLED: // unsigned long long + case XN_STREAM_PROPERTY_HOLE_FILTER: // unsigned long long + case XN_STREAM_PROPERTY_REGISTRATION_TYPE: // XnProcessingType + case XN_STREAM_PROPERTY_AGC_BIN: // XnDepthAGCBin* + case XN_STREAM_PROPERTY_PIXEL_SIZE_FACTOR: // unsigned long long + case XN_STREAM_PROPERTY_DCMOS_RCMOS_DISTANCE: // double + case XN_STREAM_PROPERTY_CLOSE_RANGE: // unsigned long long + return ONI_STATUS_NOT_SUPPORTED; + + case XN_STREAM_PROPERTY_GAIN: // unsigned long long + if (*pDataSize != sizeof(unsigned long long)) { + printf("Unexpected size: %d != %lu\n", *pDataSize, sizeof(unsigned long long)); + return ONI_STATUS_ERROR; + } + *(static_cast(data)) = GAIN_VAL; + return ONI_STATUS_OK; + case XN_STREAM_PROPERTY_CONST_SHIFT: // unsigned long long + if (*pDataSize != sizeof(unsigned long long)) { + printf("Unexpected size: %d != %lu\n", *pDataSize, sizeof(unsigned long long)); + return ONI_STATUS_ERROR; + } + *(static_cast(data)) = CONST_SHIFT_VAL; + return ONI_STATUS_OK; + case XN_STREAM_PROPERTY_MAX_SHIFT: // unsigned long long + if (*pDataSize != sizeof(unsigned long long)) { + printf("Unexpected size: %d != %lu\n", *pDataSize, sizeof(unsigned long long)); + return ONI_STATUS_ERROR; + } + *(static_cast(data)) = MAX_SHIFT_VAL; + return ONI_STATUS_OK; + case XN_STREAM_PROPERTY_PARAM_COEFF: // unsigned long long + if (*pDataSize != sizeof(unsigned long long)) { + printf("Unexpected size: %d != %lu\n", *pDataSize, sizeof(unsigned long long)); + return ONI_STATUS_ERROR; + } + *(static_cast(data)) = PARAM_COEFF_VAL; + return ONI_STATUS_OK; + case XN_STREAM_PROPERTY_SHIFT_SCALE: // unsigned long long + if (*pDataSize != sizeof(unsigned long long)) { + printf("Unexpected size: %d != %lu\n", *pDataSize, sizeof(unsigned long long)); + return ONI_STATUS_ERROR; + } + *(static_cast(data)) = SHIFT_SCALE_VAL; + return ONI_STATUS_OK; + case XN_STREAM_PROPERTY_ZERO_PLANE_DISTANCE: // unsigned long long + if (*pDataSize != sizeof(unsigned long long)) { + printf("Unexpected size: %d != %lu\n", *pDataSize, sizeof(unsigned long long)); + return ONI_STATUS_ERROR; + } + *(static_cast(data)) = ZERO_PLANE_DISTANCE_VAL; + return ONI_STATUS_OK; + case XN_STREAM_PROPERTY_ZERO_PLANE_PIXEL_SIZE: // double + if (*pDataSize != sizeof(double)) { + printf("Unexpected size: %d != %lu\n", *pDataSize, sizeof(double)); + return ONI_STATUS_ERROR; + } + *(static_cast(data)) = ZERO_PLANE_PIXEL_SIZE_VAL; + return ONI_STATUS_OK; + case XN_STREAM_PROPERTY_EMITTER_DCMOS_DISTANCE: // double + if (*pDataSize != sizeof(double)) { + printf("Unexpected size: %d != %lu\n", *pDataSize, sizeof(double)); + return ONI_STATUS_ERROR; + } + *(static_cast(data)) = EMITTER_DCMOS_DISTANCE_VAL; + return ONI_STATUS_OK; + case XN_STREAM_PROPERTY_S2D_TABLE: // OniDepthPixel[] + *pDataSize = sizeof(S2D); + //std::copy(S2D, S2D+1, static_cast(data)); + memcpy(data, S2D, *pDataSize); + return ONI_STATUS_OK; + case XN_STREAM_PROPERTY_D2S_TABLE: // unsigned short[] + *pDataSize = sizeof(D2S); + //std::copy(D2S, D2S+1, static_cast(data)); + memcpy(data, D2S, *pDataSize); + return ONI_STATUS_OK; + } + } + }; +} diff --git a/OpenNI2-FreenectDriver/src/DeviceDriver.cpp b/OpenNI2-FreenectDriver/src/DeviceDriver.cpp new file mode 100644 index 00000000..5e34f793 --- /dev/null +++ b/OpenNI2-FreenectDriver/src/DeviceDriver.cpp @@ -0,0 +1,293 @@ +/** +* FreenectDriver +* Copyright 2013 Benn Snyder +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#include +#include +#include "Driver/OniDriverAPI.h" +#include "libfreenect.hpp" +#include "DepthStream.hpp" +#include "ColorStream.hpp" + + +static bool operator<(const OniDeviceInfo& left, const OniDeviceInfo& right) { return (strcmp(left.uri, right.uri) < 0); } // for std::map + +namespace FreenectDriver { + class Device : public oni::driver::DeviceBase, public Freenect::FreenectDevice { + private: + ColorStream* color; + DepthStream* depth; + + // for Freenect::FreenectDevice + void DepthCallback(void* data, uint32_t timestamp) { + depth->buildFrame(data, timestamp); + } + void VideoCallback(void* data, uint32_t timestamp) { + color->buildFrame(data, timestamp); + } + + public: + Device(freenect_context* fn_ctx, int index) : Freenect::FreenectDevice(fn_ctx, index), + color(NULL), + depth(NULL) { } + ~Device() { + destroyStream(color); + destroyStream(depth); + } + + // for DeviceBase + + OniBool isImageRegistrationModeSupported(OniImageRegistrationMode mode) { return depth->isImageRegistrationModeSupported(mode); } + + OniStatus getSensorInfoList(OniSensorInfo** pSensors, int* numSensors) { + *numSensors = 2; + OniSensorInfo * sensors = new OniSensorInfo[*numSensors]; + sensors[0] = depth->getSensorInfo(); + sensors[1] = color->getSensorInfo(); + *pSensors = sensors; + return ONI_STATUS_OK; + } + + oni::driver::StreamBase* createStream(OniSensorType sensorType) { + switch (sensorType) { + default: + //m_driverServices.errorLoggerAppend("FreenectDeviceNI: Can't create a stream of type %d", sensorType); + return NULL; + case ONI_SENSOR_COLOR: + Freenect::FreenectDevice::startVideo(); + if (! color) + color = new ColorStream(this); + return color; + case ONI_SENSOR_DEPTH: + Freenect::FreenectDevice::startDepth(); + if (! depth) + depth = new DepthStream(this); + return depth; + // todo: IR + } + } + + void destroyStream(oni::driver::StreamBase* pStream) { + if (! pStream) + return; + + if (pStream == color) { + Freenect::FreenectDevice::stopVideo(); + delete color; + color = NULL; + } + if (pStream == depth) { + Freenect::FreenectDevice::stopDepth(); + delete depth; + depth = NULL; + } + } + + // todo: fill out properties + OniBool isPropertySupported(int propertyId) + { + if(propertyId == ONI_DEVICE_PROPERTY_IMAGE_REGISTRATION) + return true; + return false; + } + + OniStatus getProperty(int propertyId, void* data, int* pDataSize) + { + switch (propertyId) { + default: + case ONI_DEVICE_PROPERTY_FIRMWARE_VERSION: // string + case ONI_DEVICE_PROPERTY_DRIVER_VERSION: // OniVersion + case ONI_DEVICE_PROPERTY_HARDWARE_VERSION: // int + case ONI_DEVICE_PROPERTY_SERIAL_NUMBER: // string + case ONI_DEVICE_PROPERTY_ERROR_STATE: // ? + // files + case ONI_DEVICE_PROPERTY_PLAYBACK_SPEED: // float + case ONI_DEVICE_PROPERTY_PLAYBACK_REPEAT_ENABLED: // OniBool + // xn + case XN_MODULE_PROPERTY_USB_INTERFACE: // XnSensorUsbInterface + case XN_MODULE_PROPERTY_MIRROR: // bool + case XN_MODULE_PROPERTY_RESET_SENSOR_ON_STARTUP: // unsigned long long + case XN_MODULE_PROPERTY_LEAN_INIT: // unsigned long long + case XN_MODULE_PROPERTY_SERIAL_NUMBER: // unsigned long long + case XN_MODULE_PROPERTY_VERSION: // XnVersions + return ONI_STATUS_NOT_SUPPORTED; + + case ONI_DEVICE_PROPERTY_IMAGE_REGISTRATION: // OniImageRegistrationMode + if (*pDataSize != sizeof(OniImageRegistrationMode)) { + printf("Unexpected size: %d != %lu\n", *pDataSize, sizeof(OniImageRegistrationMode)); + return ONI_STATUS_ERROR; + } + *(static_cast(data)) = depth->getImageRegistrationMode(); + return ONI_STATUS_OK; + } + } + OniStatus setProperty(int propertyId, const void* data, int dataSize) + { + switch (propertyId) { + default: + case ONI_DEVICE_PROPERTY_FIRMWARE_VERSION: // By implementation + case ONI_DEVICE_PROPERTY_DRIVER_VERSION: // OniVersion + case ONI_DEVICE_PROPERTY_HARDWARE_VERSION: // int + case ONI_DEVICE_PROPERTY_SERIAL_NUMBER: // string + case ONI_DEVICE_PROPERTY_ERROR_STATE: // ? + // files + case ONI_DEVICE_PROPERTY_PLAYBACK_SPEED: // float + case ONI_DEVICE_PROPERTY_PLAYBACK_REPEAT_ENABLED: // OniBool + // xn + case XN_MODULE_PROPERTY_USB_INTERFACE: // XnSensorUsbInterface + case XN_MODULE_PROPERTY_MIRROR: // bool + case XN_MODULE_PROPERTY_RESET_SENSOR_ON_STARTUP: // unsigned long long + case XN_MODULE_PROPERTY_LEAN_INIT: // unsigned long long + case XN_MODULE_PROPERTY_SERIAL_NUMBER: // unsigned long long + case XN_MODULE_PROPERTY_VERSION: // XnVersions + // xn commands + case XN_MODULE_PROPERTY_FIRMWARE_PARAM: // XnInnerParam + case XN_MODULE_PROPERTY_RESET: // unsigned long long + case XN_MODULE_PROPERTY_IMAGE_CONTROL: // XnControlProcessingData + case XN_MODULE_PROPERTY_DEPTH_CONTROL: // XnControlProcessingData + case XN_MODULE_PROPERTY_AHB: // XnAHBData + case XN_MODULE_PROPERTY_LED_STATE: // XnLedState + return ONI_STATUS_NOT_SUPPORTED; + + case ONI_DEVICE_PROPERTY_IMAGE_REGISTRATION: // OniImageRegistrationMode + if (dataSize != sizeof(OniImageRegistrationMode)) { + printf("Unexpected size: %d != %lu\n", dataSize, sizeof(OniImageRegistrationMode)); + return ONI_STATUS_ERROR; + } + return depth->setImageRegistrationMode(*(static_cast(data))); + } + } + + OniBool isCommandSupported(int commandId) //{ return (invoke(propertyId, NULL, sizeof(NULL)) != ONI_STATUS_NOT_SUPPORTED); } + { + switch (commandId) + { + default: + case ONI_DEVICE_COMMAND_SEEK: + return false; + } + } + + OniStatus invoke(int commandId, void* data, int dataSize) + { + switch (commandId) + { + default: + case ONI_DEVICE_COMMAND_SEEK: // OniSeek + return ONI_STATUS_NOT_SUPPORTED; + } + } + + + /* todo: for DeviceBase + virtual OniStatus tryManualTrigger() {return ONI_STATUS_OK;} + */ + }; + + + class Driver : public oni::driver::DriverBase, private Freenect::Freenect { + private: + std::map devices; + + public: + Driver(OniDriverServices* pDriverServices) : DriverBase(pDriverServices) { + //freenect_set_log_level(m_ctx, FREENECT_LOG_NOTICE); + freenect_select_subdevices(m_ctx, FREENECT_DEVICE_CAMERA); // OpenNI2 doesn't use MOTOR + } + ~Driver() { shutdown(); } + + // for DriverBase + + OniStatus initialize(oni::driver::DeviceConnectedCallback connectedCallback, oni::driver::DeviceDisconnectedCallback disconnectedCallback, oni::driver::DeviceStateChangedCallback deviceStateChangedCallback, void* pCookie) { + DriverBase::initialize(connectedCallback, disconnectedCallback, deviceStateChangedCallback, pCookie); + for (int i = 0; i < Freenect::deviceCount(); ++i) { + std::ostringstream uri; + uri << "freenect://" << i; + OniDeviceInfo info; + strncpy(info.uri, uri.str().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); + } + return ONI_STATUS_OK; + } + + oni::driver::DeviceBase* deviceOpen(const char* uri, const char* mode = NULL) { + for (std::map::iterator iter = devices.begin(); iter != devices.end(); ++iter) { + if (strcmp(iter->first.uri, uri) == 0) { // found + if (iter->second) // already open + return iter->second; + else { + unsigned int id; + std::istringstream is(iter->first.uri); + is.seekg(strlen("freenect://")); + is >> id; + Device* device = &createDevice(id); + iter->second = device; + return device; + } + } + } + + getServices().errorLoggerAppend("Could not find device '%s'", uri); + return NULL; + } + + void deviceClose(oni::driver::DeviceBase* pDevice) { + for (std::map::iterator iter = devices.begin(); iter != devices.end(); ++iter) { + if (iter->second == pDevice) { + iter->second = NULL; + unsigned int id; + std::istringstream is(iter->first.uri); + is.seekg(strlen("freenect://")); + is >> id; + deleteDevice(id); + return; + } + } + + getServices().errorLoggerAppend("Could not close unrecognized device"); + } + + OniStatus tryDevice(const char* uri) { + oni::driver::DeviceBase* device = deviceOpen(uri); + if (! device) + return ONI_STATUS_ERROR; + deviceClose(device); + return ONI_STATUS_OK; + } + + void shutdown() { + for (std::map::iterator iter = devices.begin(); iter != devices.end(); ++iter) + deviceClose(iter->second); + } + + + /* todo: for DriverBase + virtual void* enableFrameSync(oni::driver::StreamBase** pStreams, int streamCount); + virtual void disableFrameSync(void* frameSyncGroup); + */ + }; +} + + +// macros defined in XnLib (not included) - workaround +#define XN_NEW(type, arg...) new type(arg) +#define XN_DELETE(p) delete(p) +ONI_EXPORT_DRIVER(FreenectDriver::Driver); +#undef XN_NEW +#undef XN_DELETE diff --git a/OpenNI2-FreenectDriver/src/S2D.h b/OpenNI2-FreenectDriver/src/S2D.h new file mode 100644 index 00000000..ab90f3a1 --- /dev/null +++ b/OpenNI2-FreenectDriver/src/S2D.h @@ -0,0 +1,207 @@ +const uint16_t S2D[] = { +0, 315, 315, 315, 316, 316, 316, 316, 317, 317, +317, 318, 318, 318, 319, 319, 319, 319, 320, 320, +320, 321, 321, 321, 322, 322, 322, 322, 323, 323, +323, 324, 324, 324, 325, 325, 325, 326, 326, 326, +326, 327, 327, 327, 328, 328, 328, 329, 329, 329, +330, 330, 330, 331, 331, 331, 332, 332, 332, 332, +333, 333, 333, 334, 334, 334, 335, 335, 335, 336, +336, 336, 337, 337, 337, 338, 338, 338, 339, 339, +339, 340, 340, 340, 341, 341, 341, 342, 342, 343, +343, 343, 344, 344, 344, 345, 345, 345, 346, 346, +346, 347, 347, 347, 348, 348, 348, 349, 349, 350, +350, 350, 351, 351, 351, 352, 352, 352, 353, 353, +354, 354, 354, 355, 355, 355, 356, 356, 356, 357, +357, 358, 358, 358, 359, 359, 359, 360, 360, 361, +361, 361, 362, 362, 363, 363, 363, 364, 364, 364, +365, 365, 366, 366, 366, 367, 367, 368, 368, 368, +369, 369, 370, 370, 370, 371, 371, 372, 372, 372, +373, 373, 374, 374, 374, 375, 375, 376, 376, 377, +377, 377, 378, 378, 379, 379, 379, 380, 380, 381, +381, 382, 382, 382, 383, 383, 384, 384, 385, 385, +385, 386, 386, 387, 387, 388, 388, 389, 389, 389, +390, 390, 391, 391, 392, 392, 393, 393, 393, 394, +394, 395, 395, 396, 396, 397, 397, 398, 398, 398, +399, 399, 400, 400, 401, 401, 402, 402, 403, 403, +404, 404, 405, 405, 406, 406, 407, 407, 408, 408, +409, 409, 409, 410, 410, 411, 411, 412, 412, 413, +413, 414, 414, 415, 415, 416, 416, 417, 418, 418, +419, 419, 420, 420, 421, 421, 422, 422, 423, 423, +424, 424, 425, 425, 426, 426, 427, 427, 428, 429, +429, 430, 430, 431, 431, 432, 432, 433, 433, 434, +435, 435, 436, 436, 437, 437, 438, 438, 439, 440, +440, 441, 441, 442, 442, 443, 444, 444, 445, 445, +446, 446, 447, 448, 448, 449, 449, 450, 451, 451, +452, 452, 453, 454, 454, 455, 455, 456, 457, 457, +458, 458, 459, 460, 460, 461, 462, 462, 463, 463, +464, 465, 465, 466, 467, 467, 468, 468, 469, 470, +470, 471, 472, 472, 473, 474, 474, 475, 476, 476, +477, 478, 478, 479, 480, 480, 481, 482, 482, 483, +484, 484, 485, 486, 487, 487, 488, 489, 489, 490, +491, 491, 492, 493, 494, 494, 495, 496, 496, 497, +498, 499, 499, 500, 501, 502, 502, 503, 504, 504, +505, 506, 507, 507, 508, 509, 510, 511, 511, 512, +513, 514, 514, 515, 516, 517, 517, 518, 519, 520, +521, 521, 522, 523, 524, 525, 525, 526, 527, 528, +529, 529, 530, 531, 532, 533, 534, 534, 535, 536, +537, 538, 539, 540, 540, 541, 542, 543, 544, 545, +546, 546, 547, 548, 549, 550, 551, 552, 553, 554, +554, 555, 556, 557, 558, 559, 560, 561, 562, 563, +564, 565, 565, 566, 567, 568, 569, 570, 571, 572, +573, 574, 575, 576, 577, 578, 579, 580, 581, 582, +583, 584, 585, 586, 587, 588, 589, 590, 591, 592, +593, 594, 595, 596, 597, 598, 599, 600, 601, 602, +603, 604, 606, 607, 608, 609, 610, 611, 612, 613, +614, 615, 616, 618, 619, 620, 621, 622, 623, 624, +625, 627, 628, 629, 630, 631, 632, 634, 635, 636, +637, 638, 640, 641, 642, 643, 644, 646, 647, 648, +649, 650, 652, 653, 654, 655, 657, 658, 659, 661, +662, 663, 664, 666, 667, 668, 670, 671, 672, 674, +675, 676, 678, 679, 680, 682, 683, 684, 686, 687, +688, 690, 691, 693, 694, 696, 697, 698, 700, 701, +703, 704, 706, 707, 708, 710, 711, 713, 714, 716, +717, 719, 720, 722, 723, 725, 727, 728, 730, 731, +733, 734, 736, 738, 739, 741, 742, 744, 746, 747, +749, 750, 752, 754, 755, 757, 759, 761, 762, 764, +766, 767, 769, 771, 773, 774, 776, 778, 780, 781, +783, 785, 787, 789, 790, 792, 794, 796, 798, 800, +802, 803, 805, 807, 809, 811, 813, 815, 817, 819, +821, 823, 825, 827, 829, 831, 833, 835, 837, 839, +841, 843, 845, 847, 849, 851, 854, 856, 858, 860, +862, 864, 867, 869, 871, 873, 875, 878, 880, 882, +885, 887, 889, 891, 894, 896, 898, 901, 903, 906, +908, 910, 913, 915, 918, 920, 923, 925, 928, 930, +933, 935, 938, 940, 943, 946, 948, 951, 954, 956, +959, 962, 964, 967, 970, 973, 975, 978, 981, 984, +987, 989, 992, 995, 998, 1001, 1004, 1007, 1010, 1013, +1016, 1019, 1022, 1025, 1028, 1031, 1034, 1038, 1041, 1044, +1047, 1050, 1054, 1057, 1060, 1063, 1067, 1070, 1073, 1077, +1080, 1084, 1087, 1090, 1094, 1097, 1101, 1105, 1108, 1112, +1115, 1119, 1123, 1126, 1130, 1134, 1138, 1141, 1145, 1149, +1153, 1157, 1161, 1165, 1169, 1173, 1177, 1181, 1185, 1189, +1193, 1197, 1202, 1206, 1210, 1214, 1219, 1223, 1227, 1232, +1236, 1241, 1245, 1250, 1255, 1259, 1264, 1268, 1273, 1278, +1283, 1288, 1292, 1297, 1302, 1307, 1312, 1317, 1322, 1328, +1333, 1338, 1343, 1349, 1354, 1359, 1365, 1370, 1376, 1381, +1387, 1392, 1398, 1404, 1410, 1415, 1421, 1427, 1433, 1439, +1445, 1452, 1458, 1464, 1470, 1477, 1483, 1489, 1496, 1503, +1509, 1516, 1523, 1529, 1536, 1543, 1550, 1557, 1564, 1572, +1579, 1586, 1594, 1601, 1609, 1616, 1624, 1632, 1639, 1647, +1655, 1663, 1671, 1680, 1688, 1696, 1705, 1713, 1722, 1731, +1739, 1748, 1757, 1766, 1776, 1785, 1794, 1804, 1813, 1823, +1833, 1843, 1853, 1863, 1873, 1883, 1894, 1904, 1915, 1926, +1936, 1947, 1959, 1970, 1981, 1993, 2005, 2016, 2028, 2040, +2053, 2065, 2078, 2090, 2103, 2116, 2129, 2143, 2156, 2170, +2184, 2198, 2212, 2226, 2241, 2256, 2271, 2286, 2301, 2317, +2333, 2349, 2365, 2381, 2398, 2415, 2432, 2450, 2467, 2485, +2503, 2522, 2541, 2560, 2579, 2598, 2618, 2639, 2659, 2680, +2701, 2723, 2744, 2767, 2789, 2812, 2835, 2859, 2883, 2908, +2933, 2958, 2984, 3010, 3037, 3064, 3092, 3120, 3149, 3178, +3208, 3238, 3269, 3300, 3333, 3365, 3399, 3433, 3468, 3503, +3539, 3576, 3614, 3653, 3692, 3732, 3774, 3816, 3859, 3903, +3948, 3994, 4041, 4089, 4139, 4190, 4241, 4295, 4349, 4405, +4463, 4522, 4582, 4645, 4708, 4774, 4842, 4911, 4983, 5056, +5132, 5210, 5291, 5374, 5460, 5548, 5640, 5734, 5832, 5933, +6038, 6146, 6259, 6375, 6497, 6622, 6753, 6889, 7030, 7178, +7332, 7492, 7660, 7835, 8019, 8212, 8413, 8626, 8849, 9084, +9331, 9593, 9870, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0}; + diff --git a/OpenNI2-FreenectDriver/src/VideoStream.hpp b/OpenNI2-FreenectDriver/src/VideoStream.hpp new file mode 100644 index 00000000..67df3063 --- /dev/null +++ b/OpenNI2-FreenectDriver/src/VideoStream.hpp @@ -0,0 +1,219 @@ +#pragma once + +#include +#include "libfreenect.hpp" +#include "Driver/OniDriverAPI.h" +#include "PS1080.h" + + +#define SIZE(array) sizeof array / sizeof 0[array] + +struct RetrieveKey { + template typename T::first_type + operator()(T pair) const { + return pair.first; + } +}; + +struct FreenectStreamFrameCookie { + int refCount; + + FreenectStreamFrameCookie() : + refCount(1) { } +}; + +// "extension constructor" for OniVideoMode struct +static OniVideoMode makeOniVideoMode(OniPixelFormat pixel_format, int resolution_x, int resolution_y, int frames_per_second) { + OniVideoMode mode; + mode.pixelFormat = pixel_format; + mode.resolutionX = resolution_x; + mode.resolutionY = resolution_y; + mode.fps = frames_per_second; + return mode; +} + +static bool operator==(const OniVideoMode& left, const OniVideoMode& right) { + return (left.pixelFormat == right.pixelFormat && left.resolutionX == right.resolutionX + && left.resolutionY == right.resolutionY && left.fps == right.fps); +} +static bool operator<(const OniVideoMode& left, const OniVideoMode& right) { return (left.resolutionX*left.resolutionY < right.resolutionX*right.resolutionY); } + +namespace FreenectDriver { + class VideoStream : public oni::driver::StreamBase { + private: + unsigned int frame_id; // number each frame + + virtual OniStatus setVideoMode(OniVideoMode requested_mode) = 0; + virtual void populateFrame(void* data, OniFrame* frame) const = 0; + + protected: + static const OniSensorType sensor_type; + Freenect::FreenectDevice* device; + bool running; // acquireFrame() does something iff true + OniVideoMode video_mode; + OniCropping cropping; + bool mirroring; + + public: + VideoStream(Freenect::FreenectDevice* device) : + device(device), + frame_id(1), + mirroring(false), + cropping() { } + //~VideoStream() { stop(); } + + void buildFrame(void* data, uint32_t timestamp) { + if (!running) + return; + + OniFrame* frame = getServices().acquireFrame(); + frame->frameIndex = frame_id++; + frame->timestamp = timestamp; + frame->videoMode = video_mode; + frame->width = video_mode.resolutionX; + frame->height = video_mode.resolutionY; + + populateFrame(data, frame); + raiseNewFrame(frame); + getServices().releaseFrame(frame); + } + + // from StreamBase + + OniStatus start() { + running = true; + return ONI_STATUS_OK; + } + void stop() { running = false; } + + // only add to property handlers if the property is generic to all children + // otherwise, implement in child and call these in default case + OniBool isPropertySupported(int propertyId) { + switch(propertyId) { + case ONI_STREAM_PROPERTY_VIDEO_MODE: + case ONI_STREAM_PROPERTY_CROPPING: + case ONI_STREAM_PROPERTY_MIRRORING: + return true; + default: + return false; + } + } + + virtual OniStatus getProperty(int propertyId, void* data, int* pDataSize) { + switch (propertyId) { + default: + case ONI_STREAM_PROPERTY_HORIZONTAL_FOV: // float: radians + case ONI_STREAM_PROPERTY_VERTICAL_FOV: // float: radians + case ONI_STREAM_PROPERTY_MAX_VALUE: // int + case ONI_STREAM_PROPERTY_MIN_VALUE: // int + case ONI_STREAM_PROPERTY_STRIDE: // int + case ONI_STREAM_PROPERTY_NUMBER_OF_FRAMES: // int + // camera + case ONI_STREAM_PROPERTY_AUTO_WHITE_BALANCE: // OniBool + case ONI_STREAM_PROPERTY_AUTO_EXPOSURE: // OniBool + // xn + case XN_STREAM_PROPERTY_INPUT_FORMAT: // unsigned long long + case XN_STREAM_PROPERTY_CROPPING_MODE: // XnCroppingMode + return ONI_STATUS_NOT_SUPPORTED; + + case ONI_STREAM_PROPERTY_VIDEO_MODE: // OniVideoMode* + if (*pDataSize != sizeof(OniVideoMode)) { + printf("Unexpected size: %d != %lu\n", *pDataSize, sizeof(OniVideoMode)); + return ONI_STATUS_ERROR; + } + *(static_cast(data)) = video_mode; + return ONI_STATUS_OK; + + case ONI_STREAM_PROPERTY_CROPPING: // OniCropping* + std::cout << "get cropping" << std::endl; + if (*pDataSize != sizeof(OniCropping)) { + printf("Unexptected size: %d != %lu\n", *pDataSize, sizeof(OniVideoMode)); + return ONI_STATUS_ERROR; + } + *(static_cast(data)) = cropping; + return ONI_STATUS_OK; + + case ONI_STREAM_PROPERTY_MIRRORING: // OniBool + if (*pDataSize != sizeof(OniBool)) + { + printf("Unexpected size: %d != %lu\n", *pDataSize, sizeof(OniBool)); + return ONI_STATUS_ERROR; + } + *(static_cast(data)) = mirroring; + return ONI_STATUS_OK; + } + } + virtual OniStatus setProperty(int propertyId, const void* data, int dataSize) { + switch (propertyId) { + default: + case ONI_STREAM_PROPERTY_HORIZONTAL_FOV: // float: radians + case ONI_STREAM_PROPERTY_VERTICAL_FOV: // float: radians + case ONI_STREAM_PROPERTY_MAX_VALUE: // int + case ONI_STREAM_PROPERTY_MIN_VALUE: // int + case ONI_STREAM_PROPERTY_STRIDE: // int + case ONI_STREAM_PROPERTY_NUMBER_OF_FRAMES: // int + // camera + case ONI_STREAM_PROPERTY_AUTO_WHITE_BALANCE: // OniBool + case ONI_STREAM_PROPERTY_AUTO_EXPOSURE: // OniBool + // xn + case XN_STREAM_PROPERTY_INPUT_FORMAT: // unsigned long long + case XN_STREAM_PROPERTY_CROPPING_MODE: // XnCroppingMode + return ONI_STATUS_NOT_SUPPORTED; + + case ONI_STREAM_PROPERTY_VIDEO_MODE: // OniVideoMode* + if (dataSize != sizeof(OniVideoMode)) { + printf("Unexpected size: %d != %lu\n", dataSize, sizeof(OniVideoMode)); + return ONI_STATUS_ERROR; + } + if (ONI_STATUS_OK != setVideoMode(*(static_cast(data)))) + return ONI_STATUS_NOT_SUPPORTED; + raisePropertyChanged(propertyId, data, dataSize); + return ONI_STATUS_OK; + + case ONI_STREAM_PROPERTY_CROPPING: // OniCropping* + std::cout << "set cropping" << std::endl; + if (dataSize != sizeof(OniCropping)) { + printf("Unexpected size: %d != %lu\n", dataSize, sizeof(OniCropping)); + return ONI_STATUS_ERROR; + } + cropping = *(static_cast(data)); + + raisePropertyChanged(propertyId, data, dataSize); + return ONI_STATUS_OK; + + case ONI_STREAM_PROPERTY_MIRRORING: // OniBool + if (dataSize != sizeof(OniBool)) { + printf("Unexpected size: %d != %lu\n", dataSize, sizeof(OniBool)); + return ONI_STATUS_ERROR; + } + mirroring = *(static_cast(data)); + raisePropertyChanged(propertyId, data, dataSize); + return ONI_STATUS_OK; + } + } + + + /* todo : from StreamBase + virtual OniStatus convertDepthToColorCoordinates(StreamBase* colorStream, int depthX, int depthY, OniDepthPixel depthZ, int* pColorX, int* pColorY) { return ONI_STATUS_NOT_SUPPORTED; } + */ + }; +} + + +/* image video modes reference + +FREENECT_VIDEO_RGB = 0, //< Decompressed RGB mode (demosaicing done by libfreenect) +FREENECT_VIDEO_BAYER = 1, //< Bayer compressed mode (raw information from camera) +FREENECT_VIDEO_IR_8BIT = 2, //< 8-bit IR mode +FREENECT_VIDEO_IR_10BIT = 3, //< 10-bit IR mode +FREENECT_VIDEO_IR_10BIT_PACKED = 4, //< 10-bit packed IR mode +FREENECT_VIDEO_YUV_RGB = 5, //< YUV RGB mode +FREENECT_VIDEO_YUV_RAW = 6, //< YUV Raw mode +FREENECT_VIDEO_DUMMY = 2147483647, //< Dummy value to force enum to be 32 bits wide + +ONI_PIXEL_FORMAT_RGB888 = 200, +ONI_PIXEL_FORMAT_YUV422 = 201, +ONI_PIXEL_FORMAT_GRAY8 = 202, +ONI_PIXEL_FORMAT_GRAY16 = 203, +ONI_PIXEL_FORMAT_JPEG = 204, +*/ diff --git a/wrappers/cpp/libfreenect.hpp b/wrappers/cpp/libfreenect.hpp index d24dfeda..90b8ccd8 100644 --- a/wrappers/cpp/libfreenect.hpp +++ b/wrappers/cpp/libfreenect.hpp @@ -213,8 +213,10 @@ namespace Freenect { } // Do not call directly, thread runs here void operator()() { - while(!m_stop) { - int res = freenect_process_events(m_ctx); + static timeval timeout = {0, 33333}; // 30 fps + while (!m_stop) { + // use of timeout prevents hang on exit (no more events) + int res = freenect_process_events_timeout(m_ctx, &timeout); if (res < 0) { // libusb signals an error has occurred @@ -235,8 +237,9 @@ namespace Freenect { (*freenect)(); return NULL; } + protected: + freenect_context *m_ctx; private: - freenect_context *m_ctx; volatile bool m_stop; pthread_t m_thread; DeviceMap m_devices; From cd5de9006ff321f42085bfba12da032680eefae6 Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Sat, 18 Jan 2014 12:57:05 -0500 Subject: [PATCH 17/84] wrappers/cpp: Stop loop before clearing devices (prevents hang on exit) - fixes #295 Signed-off-by: Benn Snyder --- wrappers/cpp/libfreenect.hpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/wrappers/cpp/libfreenect.hpp b/wrappers/cpp/libfreenect.hpp index 90b8ccd8..98dc0082 100644 --- a/wrappers/cpp/libfreenect.hpp +++ b/wrappers/cpp/libfreenect.hpp @@ -31,7 +31,7 @@ #include #include #include -#include +#include namespace Freenect { class Noncopyable { @@ -187,10 +187,10 @@ namespace Freenect { if(pthread_create(&m_thread, NULL, pthread_callback, (void*)this) != 0) throw std::runtime_error("Cannot initialize freenect thread"); } ~Freenect() { + m_stop = true; for(DeviceMap::iterator it = m_devices.begin() ; it != m_devices.end() ; ++it) { delete it->second; } - m_stop = true; pthread_join(m_thread, NULL); if(freenect_shutdown(m_ctx) < 0){} //FN_WARNING("Freenect did not shutdown in a clean fashion"); } @@ -213,10 +213,8 @@ namespace Freenect { } // Do not call directly, thread runs here void operator()() { - static timeval timeout = {0, 33333}; // 30 fps while (!m_stop) { - // use of timeout prevents hang on exit (no more events) - int res = freenect_process_events_timeout(m_ctx, &timeout); + int res = freenect_process_events(m_ctx); if (res < 0) { // libusb signals an error has occurred From cf316e023039ac450953d389d4258327cc612eb2 Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Sat, 18 Jan 2014 13:08:08 -0500 Subject: [PATCH 18/84] wrappers/cpp: replace std::make_pair with and more compatible assignment - fixes #339 Signed-off-by: Benn Snyder --- wrappers/cpp/libfreenect.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wrappers/cpp/libfreenect.hpp b/wrappers/cpp/libfreenect.hpp index 98dc0082..631fb959 100644 --- a/wrappers/cpp/libfreenect.hpp +++ b/wrappers/cpp/libfreenect.hpp @@ -199,7 +199,7 @@ namespace Freenect { DeviceMap::iterator it = m_devices.find(_index); if (it != m_devices.end()) delete it->second; ConcreteDevice * device = new ConcreteDevice(m_ctx, _index); - m_devices.insert(std::make_pair(_index, device)); + m_devices[_index] = device; return *device; } void deleteDevice(int _index) { From e26a7ea2884782b421a1edff62b1a10d729c1a59 Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Sat, 18 Jan 2014 13:38:21 -0500 Subject: [PATCH 19/84] Update CMakeLists.txt for v0.2.1 Signed-off-by: Benn Snyder --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 272a410f..c1f4c02c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,7 +42,7 @@ PROJECT(libfreenect) set (PROJECT_VER_MAJOR 0) set (PROJECT_VER_MINOR 2) -set (PROJECT_VER_PATCH 0) +set (PROJECT_VER_PATCH 1) set (PROJECT_VER "${PROJECT_VER_MAJOR}.${PROJECT_VER_MINOR}.${PROJECT_VER_PATCH}") set (PROJECT_APIVER From a1b8a2638a291ee97c7a2ad2db5a783614bc676a Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Sat, 18 Jan 2014 14:19:38 -0500 Subject: [PATCH 20/84] wrappers/cpp: Remove pureness from virtual callbacks - fixes #286 Signed-off-by: Benn Snyder --- wrappers/cpp/libfreenect.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wrappers/cpp/libfreenect.hpp b/wrappers/cpp/libfreenect.hpp index 675e39b1..a6258c1b 100644 --- a/wrappers/cpp/libfreenect.hpp +++ b/wrappers/cpp/libfreenect.hpp @@ -138,9 +138,9 @@ namespace Freenect { return m_dev; } // Do not call directly even in child - virtual void VideoCallback(void *video, uint32_t timestamp) = 0; + virtual void VideoCallback(void *video, uint32_t timestamp) { } // Do not call directly even in child - virtual void DepthCallback(void *depth, uint32_t timestamp) = 0; + virtual void DepthCallback(void *depth, uint32_t timestamp) { } protected: int getVideoBufferSize(){ switch(m_video_format) { From 93696487830c301dd5e0027625278d5ab4256883 Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Sat, 18 Jan 2014 14:35:42 -0500 Subject: [PATCH 21/84] Fix missing semicolon in fakenect/record.c Signed-off-by: Benn Snyder --- fakenect/record.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fakenect/record.c b/fakenect/record.c index 5bbd8f33..73603361 100644 --- a/fakenect/record.c +++ b/fakenect/record.c @@ -344,7 +344,7 @@ int main(int argc, char **argv) index_fp = open_index(fn); free(fn); if (!index_fp) { - fclose(index_fp) + fclose(index_fp); return 1; } From 2d4d053996f4efb6f2e2782ec7245fa9947ace25 Mon Sep 17 00:00:00 2001 From: Yannis Gravezas Date: Tue, 12 Nov 2013 23:06:23 +0200 Subject: [PATCH 22/84] Added chunk processing callbacks for depth and video streams - fixes #351 Signed-off-by: Yannis Gravezas (cherry picked from commit 0350c79ddfeb039f05a59f969c9137c2ea0e47b0) Reviewed-by: Benn Snyder --- examples/CMakeLists.txt | 6 +- examples/chunkview.c | 408 ++++++++++++++++++++++++++++++++++++++++ include/libfreenect.h | 19 ++ src/cameras.c | 25 ++- src/freenect_internal.h | 2 + 5 files changed, 454 insertions(+), 6 deletions(-) create mode 100644 examples/chunkview.c diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 3ae566e8..53acc46c 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -10,6 +10,7 @@ if (WIN32) set_source_files_properties(glpclview.c PROPERTIES LANGUAGE CXX) set_source_files_properties(hiview.c PROPERTIES LANGUAGE CXX) set_source_files_properties(tiltdemo.c PROPERTIES LANGUAGE CXX) + set_source_files_properties(chunkview.c PROPERTIES LANGUAGE CXX) set(THREADS_USE_PTHREADS_WIN32 true) find_package(Threads REQUIRED) @@ -20,6 +21,7 @@ endif() add_executable(glview glview.c) add_executable(regview regview.c) add_executable(hiview hiview.c) +add_executable(chunkview chunkview.c) if(BUILD_AUDIO) add_executable(wavrecord wavrecord.c) add_executable(micview micview.c) @@ -40,6 +42,7 @@ if(APPLE) target_link_libraries(glview freenect) target_link_libraries(regview freenect) target_link_libraries(hiview freenect) + target_link_libraries(chunkview freenect) if (BUILD_AUDIO) target_link_libraries(wavrecord freenect) target_link_libraries(micview freenect) @@ -61,6 +64,7 @@ else() target_link_libraries(glview freenect ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB}) target_link_libraries(regview freenect ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB}) target_link_libraries(hiview freenect ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB}) + target_link_libraries(chunkview freenect ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB}) if (BUILD_AUDIO) target_link_libraries(wavrecord freenect ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB}) target_link_libraries(micview freenect ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB}) @@ -74,7 +78,7 @@ else() endif() -install (TARGETS glview regview hiview +install (TARGETS glview regview hiview chunkview DESTINATION bin) if (BUILD_C_SYNC) diff --git a/examples/chunkview.c b/examples/chunkview.c new file mode 100644 index 00000000..92e89426 --- /dev/null +++ b/examples/chunkview.c @@ -0,0 +1,408 @@ +/* + * This file is part of the OpenKinect Project. http://www.openkinect.org + * + * Copyright (c) 2013 individual OpenKinect contributors. See the CONTRIB file + * for details. + * + * This code is licensed to you under the terms of the Apache License, version + * 2.0, or, at your option, the terms of the GNU General Public License, + * version 2.0. See the APACHE20 and GPL2 files for the text of the licenses, + * or the following URLs: + * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.gnu.org/licenses/gpl-2.0.txt + * + * If you redistribute this file in source form, modified or unmodified, you + * may: + * 1) Leave this header intact and distribute it under the same terms, + * accompanying it with the APACHE20 and GPL20 files, or + * 2) Delete the Apache 2.0 clause and accompany it with the GPL2 file, or + * 3) Delete the GPL v2 clause and accompany it with the APACHE20 file + * In all cases you must keep the copyright notice intact and include a copy + * of the CONTRIB file. + * + * Binary distributions must follow the binary distribution requirements of + * either License. + */ + + +#include +#include +#include +#include +#include "libfreenect.h" + +#include + +#if defined(__APPLE__) +#include +#include +#include +#else +#include +#include +#include +#endif + +#include + +pthread_t freenect_thread; +volatile int die = 0; + +int g_argc; +char **g_argv; + +int window; + +pthread_mutex_t gl_backbuf_mutex = PTHREAD_MUTEX_INITIALIZER; + +// back: owned by libfreenect (implicit for depth) +// mid: owned by callbacks, "latest frame ready" +// front: owned by GL, "currently being drawn" +uint8_t *depth_mid, *depth_front; + +GLuint gl_depth_tex; + +freenect_context *f_ctx; +freenect_device *f_dev; +int freenect_angle = 0; +int freenect_led; + + +pthread_cond_t gl_frame_cond = PTHREAD_COND_INITIALIZER; +int got_depth = 0; + +/* +Downsample and unpack pixels to 320*240 on the fly. Mind that even though +we setup libfreenect to return packed data, When we process them with the +chunk callback they will end up in unpacked form. Converting to mm is also +an option. The best way to do it is by passing a lookup table for raw->mm +as the argument to freenect_set_user. You can then access it here as the ud. +*/ + +void chunk_cb(void *buffer, void *pkt_data, int pkt_num, int pkt_size,void *ud) +{ + if(pkt_num == 73 || pkt_num == 146) return; + uint8_t *raw = (uint8_t *) pkt_data; + uint16_t *frame=(uint16_t *)buffer; + if(pkt_num > 219){ + raw += (pkt_num-220) * 12; + frame += 320 * (pkt_num-2); + }else if(pkt_num > 146){ + raw += (pkt_num-147) * 12 + 4; + frame += 320 * (pkt_num-2); + }else if(pkt_num > 73){ + raw += (pkt_num-74) * 12 + 8; + frame += 320 * (pkt_num-1); + }else{ + raw += pkt_num * 12; + frame += 320 * pkt_num; + } + + int n = 0; + while(n != 40){ + frame[0] = (raw[0]<<3) | (raw[1]>>5); + frame[1] = ((raw[2]<<9) | (raw[3]<<1) | (raw[4]>>7) ) & 2047; + frame[2] = ((raw[5]<<7) | (raw[6]>>1) ) & 2047; + frame[3] = ((raw[8]<<5) | (raw[9]>>3) ) & 2047; + frame[4] = (raw[11]<<3) | (raw[12]>>5); + frame[5] = ((raw[13]<<9) | (raw[14]<<1) | (raw[15]>>7) ) & 2047; + frame[6] = ((raw[16]<<7) | (raw[17]>>1) ) & 2047; + frame[7] = ((raw[19]<<5) | (raw[20]>>3) ) & 2047; + frame+=8; + raw+=22; + n++; + } + +} + +void DrawGLScene() +{ + pthread_mutex_lock(&gl_backbuf_mutex); + + while (!got_depth) { + pthread_cond_wait(&gl_frame_cond, &gl_backbuf_mutex); + } + + + uint8_t *tmp; + + if (got_depth) { + tmp = depth_front; + depth_front = depth_mid; + depth_mid = tmp; + got_depth = 0; + } + + pthread_mutex_unlock(&gl_backbuf_mutex); + + glBindTexture(GL_TEXTURE_2D, gl_depth_tex); + glTexImage2D(GL_TEXTURE_2D, 0, 3, 320, 240, 0, GL_RGB, GL_UNSIGNED_BYTE, depth_front); + + glBegin(GL_TRIANGLE_FAN); + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + glTexCoord2f(0, 0); glVertex3f(0,0,0); + glTexCoord2f(1, 0); glVertex3f(320,0,0); + glTexCoord2f(1, 1); glVertex3f(320,240,0); + glTexCoord2f(0, 1); glVertex3f(0,240,0); + glEnd(); + + glutSwapBuffers(); +} + +void keyPressed(unsigned char key, int x, int y) +{ + if (key == 27) { + die = 1; + pthread_join(freenect_thread, NULL); + glutDestroyWindow(window); + free(depth_mid); + free(depth_front); + // Not pthread_exit because OSX leaves a thread lying around and doesn't exit + exit(0); + } + if (key == 'w') { + freenect_angle++; + if (freenect_angle > 30) { + freenect_angle = 30; + } + } + if (key == 's') { + freenect_angle = 0; + } + if (key == 'x') { + freenect_angle--; + if (freenect_angle < -30) { + freenect_angle = -30; + } + } + if (key == '1') { + freenect_set_led(f_dev,LED_GREEN); + } + if (key == '2') { + freenect_set_led(f_dev,LED_RED); + } + if (key == '3') { + freenect_set_led(f_dev,LED_YELLOW); + } + if (key == '4') { + freenect_set_led(f_dev,LED_BLINK_GREEN); + } + if (key == '5') { + // 5 is the same as 4 + freenect_set_led(f_dev,LED_BLINK_GREEN); + } + if (key == '6') { + freenect_set_led(f_dev,LED_BLINK_RED_YELLOW); + } + if (key == '0') { + freenect_set_led(f_dev,LED_OFF); + } + freenect_set_tilt_degs(f_dev,freenect_angle); +} + +void ReSizeGLScene(int Width, int Height) +{ + glViewport(0,0,Width,Height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho (0, 320, 240, 0, -1.0f, 1.0f); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + +void InitGL(int Width, int Height) +{ + glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + glClearDepth(1.0); + glDepthFunc(GL_LESS); + glDepthMask(GL_FALSE); + glDisable(GL_DEPTH_TEST); + glDisable(GL_BLEND); + glDisable(GL_ALPHA_TEST); + glEnable(GL_TEXTURE_2D); + glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glShadeModel(GL_FLAT); + + glGenTextures(1, &gl_depth_tex); + glBindTexture(GL_TEXTURE_2D, gl_depth_tex); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + + ReSizeGLScene(Width, Height); +} + +void *gl_threadfunc(void *arg) +{ + printf("GL thread\n"); + + glutInit(&g_argc, g_argv); + + glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH); + glutInitWindowSize(320, 240); + glutInitWindowPosition(0, 0); + + window = glutCreateWindow("LibFreenect"); + + glutDisplayFunc(&DrawGLScene); + glutIdleFunc(&DrawGLScene); + glutReshapeFunc(&ReSizeGLScene); + glutKeyboardFunc(&keyPressed); + + InitGL(320, 240); + + glutMainLoop(); + + return NULL; +} + +uint16_t t_gamma[2048]; + + +void depth_cb(freenect_device *dev, void *v_depth, uint32_t timestamp) +{ + int i; + uint16_t *depth = (uint16_t*)v_depth; + pthread_mutex_lock(&gl_backbuf_mutex); + for (i=0; i<320*240; i++) { + int pval = t_gamma[depth[i]]; + int lb = pval & 0xff; + switch (pval>>8) { + case 0: + depth_mid[3*i+0] = 255; + depth_mid[3*i+1] = 255-lb; + depth_mid[3*i+2] = 255-lb; + break; + case 1: + depth_mid[3*i+0] = 255; + depth_mid[3*i+1] = lb; + depth_mid[3*i+2] = 0; + break; + case 2: + depth_mid[3*i+0] = 255-lb; + depth_mid[3*i+1] = 255; + depth_mid[3*i+2] = 0; + break; + case 3: + depth_mid[3*i+0] = 0; + depth_mid[3*i+1] = 255; + depth_mid[3*i+2] = lb; + break; + case 4: + depth_mid[3*i+0] = 0; + depth_mid[3*i+1] = 255-lb; + depth_mid[3*i+2] = 255; + break; + case 5: + depth_mid[3*i+0] = 0; + depth_mid[3*i+1] = 0; + depth_mid[3*i+2] = 255-lb; + break; + default: + depth_mid[3*i+0] = 0; + depth_mid[3*i+1] = 0; + depth_mid[3*i+2] = 0; + break; + } + } + got_depth++; + pthread_cond_signal(&gl_frame_cond); + pthread_mutex_unlock(&gl_backbuf_mutex); +} + +void *freenect_threadfunc(void *arg) +{ + int accelCount = 0; + + freenect_set_tilt_degs(f_dev,freenect_angle); + freenect_set_led(f_dev,LED_RED); + freenect_set_depth_callback(f_dev, depth_cb); + freenect_set_depth_mode(f_dev, freenect_find_depth_mode(FREENECT_RESOLUTION_MEDIUM, FREENECT_DEPTH_11BIT_PACKED)); + freenect_set_depth_chunk_callback(f_dev,chunk_cb); + freenect_start_depth(f_dev); + + printf("'w'-tilt up, 's'-level, 'x'-tilt down, '0'-'6'-select LED mode\n"); + + while (!die && freenect_process_events(f_ctx) >= 0) { + //Throttle the text output + if (accelCount++ >= 2000) + { + accelCount = 0; + freenect_raw_tilt_state* state; + freenect_update_tilt_state(f_dev); + state = freenect_get_tilt_state(f_dev); + double dx,dy,dz; + freenect_get_mks_accel(state, &dx, &dy, &dz); + printf("\r raw acceleration: %4d %4d %4d mks acceleration: %4f %4f %4f", state->accelerometer_x, state->accelerometer_y, state->accelerometer_z, dx, dy, dz); + fflush(stdout); + } + + } + + printf("\nshutting down streams...\n"); + + freenect_stop_depth(f_dev); + + freenect_close_device(f_dev); + freenect_shutdown(f_ctx); + + printf("-- done!\n"); + return NULL; +} + +int main(int argc, char **argv) +{ + int res; + + depth_mid = (uint8_t*)malloc(320*240*3); + depth_front = (uint8_t*)malloc(320*240*3); + + printf("Kinect camera test\n"); + + int i; + for (i=0; i<2048; i++) { + float v = i/2048.0; + v = powf(v, 3)* 6; + t_gamma[i] = v*6*256; + } + + g_argc = argc; + g_argv = argv; + + if (freenect_init(&f_ctx, NULL) < 0) { + printf("freenect_init() failed\n"); + return 1; + } + + freenect_set_log_level(f_ctx, FREENECT_LOG_DEBUG); + freenect_select_subdevices(f_ctx, (freenect_device_flags)(FREENECT_DEVICE_MOTOR | FREENECT_DEVICE_CAMERA)); + + int nr_devices = freenect_num_devices (f_ctx); + printf ("Number of devices found: %d\n", nr_devices); + + int user_device_number = 0; + if (argc > 1) + user_device_number = atoi(argv[1]); + + if (nr_devices < 1) { + freenect_shutdown(f_ctx); + return 1; + } + + if (freenect_open_device(f_ctx, &f_dev, user_device_number) < 0) { + printf("Could not open device\n"); + freenect_shutdown(f_ctx); + return 1; + } + + res = pthread_create(&freenect_thread, NULL, freenect_threadfunc, NULL); + if (res) { + printf("pthread_create failed\n"); + freenect_shutdown(f_ctx); + return 1; + } + + // OS X requires GLUT to run on the main thread + gl_threadfunc(NULL); + + return 0; +} diff --git a/include/libfreenect.h b/include/libfreenect.h index fd19a128..b3f30168 100644 --- a/include/libfreenect.h +++ b/include/libfreenect.h @@ -385,6 +385,9 @@ FREENECTAPI void *freenect_get_user(freenect_device *dev); typedef void (*freenect_depth_cb)(freenect_device *dev, void *depth, uint32_t timestamp); /// Typedef for video image received event callbacks typedef void (*freenect_video_cb)(freenect_device *dev, void *video, uint32_t timestamp); +/// Typedef for stream chunk processing callbacks +typedef void (*freenect_chunk_cb)(void *buffer, void *pkt_data, int pkt_num, int datalen, void *user_data); + /** * Set callback for depth information received event @@ -402,6 +405,22 @@ FREENECTAPI void freenect_set_depth_callback(freenect_device *dev, freenect_dept */ FREENECTAPI void freenect_set_video_callback(freenect_device *dev, freenect_video_cb cb); +/** + * Set callback for depth chunk processing + * + * @param dev Device to set callback for + * @param cb Function pointer for processing depth chunk + */ +FREENECTAPI void freenect_set_depth_chunk_callback(freenect_device *dev, freenect_chunk_cb cb); + +/** + * Set callback for video chunk processing + * + * @param dev Device to set callback for + * @param cb Function pointer for processing video chunk + */ +FREENECTAPI void freenect_set_video_chunk_callback(freenect_device *dev, freenect_chunk_cb cb); + /** * Set the buffer to store depth information to. Size of buffer is * dependant on depth format. See FREENECT_DEPTH_*_SIZE defines for diff --git a/src/cameras.c b/src/cameras.c index 4a54d271..99d387d9 100644 --- a/src/cameras.c +++ b/src/cameras.c @@ -84,7 +84,7 @@ struct pkt_hdr { uint32_t timestamp; }; -static int stream_process(freenect_context *ctx, packet_stream *strm, uint8_t *pkt, int len) +static int stream_process(freenect_context *ctx, packet_stream *strm, uint8_t *pkt, int len, freenect_chunk_cb cb, void *user_data) { if (len < 12) return 0; @@ -194,9 +194,13 @@ static int stream_process(freenect_context *ctx, packet_stream *strm, uint8_t *p } } - // copy data + // copy or chunk process the data uint8_t *dbuf = strm->raw_buf + strm->pkt_num * strm->pkt_size; - memcpy(dbuf, data, datalen); + if(cb){ + cb(strm->raw_buf,data,strm->pkt_num,datalen,user_data); + }else{ + memcpy(dbuf, data, datalen); + } strm->pkt_num++; strm->seq++; @@ -374,7 +378,7 @@ static void depth_process(freenect_device *dev, uint8_t *pkt, int len) if (!dev->depth.running) return; - int got_frame_size = stream_process(ctx, &dev->depth, pkt, len); + int got_frame_size = stream_process(ctx, &dev->depth, pkt, len,dev->depth_chunk_cb,dev->user_data); if (!got_frame_size) return; @@ -614,7 +618,7 @@ static void video_process(freenect_device *dev, uint8_t *pkt, int len) if (!dev->video.running) return; - int got_frame_size = stream_process(ctx, &dev->video, pkt, len); + int got_frame_size = stream_process(ctx, &dev->video, pkt, len,dev->video_chunk_cb,dev->user_data); if (!got_frame_size) return; @@ -1088,6 +1092,17 @@ void freenect_set_video_callback(freenect_device *dev, freenect_video_cb cb) dev->video_cb = cb; } + +void freenect_set_depth_chunk_callback(freenect_device *dev, freenect_chunk_cb cb) +{ + dev->depth_chunk_cb = cb; +} + +void freenect_set_video_chunk_callback(freenect_device *dev, freenect_chunk_cb cb) +{ + dev->video_chunk_cb = cb; +} + int freenect_get_video_mode_count() { return video_mode_count; diff --git a/src/freenect_internal.h b/src/freenect_internal.h index 8df4ee22..4aa877a2 100644 --- a/src/freenect_internal.h +++ b/src/freenect_internal.h @@ -212,6 +212,8 @@ struct _freenect_device { freenect_depth_cb depth_cb; freenect_video_cb video_cb; + freenect_chunk_cb depth_chunk_cb; + freenect_chunk_cb video_chunk_cb; freenect_video_format video_format; freenect_depth_format depth_format; freenect_resolution video_resolution; From 218cd0ddbcfd486a2a80a40b786e2a60d0d58ed0 Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Sat, 18 Jan 2014 21:57:27 -0500 Subject: [PATCH 23/84] OpenNI2-FreenectDriver: reduce compiler warnings Signed-off-by: Benn Snyder --- OpenNI2-FreenectDriver/CMakeLists.txt | 2 +- OpenNI2-FreenectDriver/src/ColorStream.hpp | 5 +++-- OpenNI2-FreenectDriver/src/DepthStream.hpp | 7 ++++--- OpenNI2-FreenectDriver/src/VideoStream.hpp | 14 ++------------ 4 files changed, 10 insertions(+), 18 deletions(-) diff --git a/OpenNI2-FreenectDriver/CMakeLists.txt b/OpenNI2-FreenectDriver/CMakeLists.txt index d90e8e95..c0f5532e 100644 --- a/OpenNI2-FreenectDriver/CMakeLists.txt +++ b/OpenNI2-FreenectDriver/CMakeLists.txt @@ -5,7 +5,7 @@ file(GLOB SOURCES src/*.cpp) add_library(FreenectDriver SHARED ${SOURCES}) -set(CMAKE_CXX_FLAGS "-w") # todo +set(CMAKE_CXX_FLAGS "-Wno-gnu-static-float-init -Wno-unused-function") set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib/OpenNI2-FreenectDriver) set_target_properties( FreenectDriver PROPERTIES diff --git a/OpenNI2-FreenectDriver/src/ColorStream.hpp b/OpenNI2-FreenectDriver/src/ColorStream.hpp index 489b32d5..2def528f 100644 --- a/OpenNI2-FreenectDriver/src/ColorStream.hpp +++ b/OpenNI2-FreenectDriver/src/ColorStream.hpp @@ -10,7 +10,7 @@ namespace FreenectDriver { class ColorStream : public VideoStream { public: - // from NUI library & converted to radians - please check + // from NUI library & converted to radians static const float DIAGONAL_FOV = 73.9 * (M_PI / 180); static const float HORIZONTAL_FOV = 62 * (M_PI / 180); static const float VERTICAL_FOV = 48.6 * (M_PI / 180); @@ -31,7 +31,8 @@ namespace FreenectDriver { FreenectVideoModeMap supported_modes = getSupportedVideoModes(); OniVideoMode* modes = new OniVideoMode[supported_modes.size()]; std::transform(supported_modes.begin(), supported_modes.end(), modes, RetrieveKey()); - return { sensor_type, SIZE(modes), modes }; // sensorType, numSupportedVideoModes, pSupportedVideoModes + OniSensorInfo sensors = { sensor_type, static_cast(supported_modes.size()), modes }; + return sensors; } // from StreamBase diff --git a/OpenNI2-FreenectDriver/src/DepthStream.hpp b/OpenNI2-FreenectDriver/src/DepthStream.hpp index aa761a80..49973f41 100644 --- a/OpenNI2-FreenectDriver/src/DepthStream.hpp +++ b/OpenNI2-FreenectDriver/src/DepthStream.hpp @@ -14,11 +14,11 @@ namespace FreenectDriver { class DepthStream : public VideoStream { public: - // from NUI library and converted to radians - please check + // from NUI library and converted to radians static const float DIAGONAL_FOV = 70 * (M_PI / 180); static const float HORIZONTAL_FOV = 58.5 * (M_PI / 180); static const float VERTICAL_FOV = 45.6 * (M_PI / 180); - // from DepthKinectStream.cpp - please check + // from DepthKinectStream.cpp static const int MAX_VALUE = 10000; static const unsigned long long GAIN_VAL = 42; static const unsigned long long CONST_SHIFT_VAL = 200; @@ -46,7 +46,8 @@ namespace FreenectDriver { FreenectDepthModeMap supported_modes = getSupportedVideoModes(); OniVideoMode* modes = new OniVideoMode[supported_modes.size()]; std::transform(supported_modes.begin(), supported_modes.end(), modes, RetrieveKey()); - return { sensor_type, SIZE(modes), modes }; // sensorType, numSupportedVideoModes, pSupportedVideoModes + OniSensorInfo sensors = { sensor_type, static_cast(supported_modes.size()), modes }; + return sensors; } OniImageRegistrationMode getImageRegistrationMode() const { return image_registration_mode; } diff --git a/OpenNI2-FreenectDriver/src/VideoStream.hpp b/OpenNI2-FreenectDriver/src/VideoStream.hpp index 67df3063..20c1aa32 100644 --- a/OpenNI2-FreenectDriver/src/VideoStream.hpp +++ b/OpenNI2-FreenectDriver/src/VideoStream.hpp @@ -6,8 +6,6 @@ #include "PS1080.h" -#define SIZE(array) sizeof array / sizeof 0[array] - struct RetrieveKey { template typename T::first_type operator()(T pair) const { @@ -15,13 +13,6 @@ struct RetrieveKey { } }; -struct FreenectStreamFrameCookie { - int refCount; - - FreenectStreamFrameCookie() : - refCount(1) { } -}; - // "extension constructor" for OniVideoMode struct static OniVideoMode makeOniVideoMode(OniPixelFormat pixel_format, int resolution_x, int resolution_y, int frames_per_second) { OniVideoMode mode; @@ -56,10 +47,9 @@ namespace FreenectDriver { public: VideoStream(Freenect::FreenectDevice* device) : - device(device), frame_id(1), - mirroring(false), - cropping() { } + device(device), + mirroring(false) { } //~VideoStream() { stop(); } void buildFrame(void* data, uint32_t timestamp) { From 7e1857bf736972bdf041dcaf67d0f300b7f126b8 Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Sat, 18 Jan 2014 22:43:48 -0500 Subject: [PATCH 24/84] OpenNI2-FreenectDriver: support ONI_STREAM_PROPERTY_AUTO_WHITE_BALANCE and ONI_STREAM_PROPERTY_AUTO_EXPOSURE Signed-off-by: Benn Snyder --- OpenNI2-FreenectDriver/src/ColorStream.hpp | 81 ++++++++++++++++++++-- OpenNI2-FreenectDriver/src/VideoStream.hpp | 1 - wrappers/cpp/libfreenect.hpp | 4 ++ 3 files changed, 79 insertions(+), 7 deletions(-) diff --git a/OpenNI2-FreenectDriver/src/ColorStream.hpp b/OpenNI2-FreenectDriver/src/ColorStream.hpp index 2def528f..7039c063 100644 --- a/OpenNI2-FreenectDriver/src/ColorStream.hpp +++ b/OpenNI2-FreenectDriver/src/ColorStream.hpp @@ -22,6 +22,9 @@ namespace FreenectDriver { static FreenectVideoModeMap getSupportedVideoModes(); OniStatus setVideoMode(OniVideoMode requested_mode); void populateFrame(void* data, OniFrame* frame) const; + + bool auto_white_balance; + bool auto_exposure; public: ColorStream(Freenect::FreenectDevice* pDevice); @@ -40,31 +43,97 @@ namespace FreenectDriver { switch(propertyId) { default: return VideoStream::isPropertySupported(propertyId); + case ONI_STREAM_PROPERTY_HORIZONTAL_FOV: case ONI_STREAM_PROPERTY_VERTICAL_FOV: + case ONI_STREAM_PROPERTY_AUTO_WHITE_BALANCE: + case ONI_STREAM_PROPERTY_AUTO_EXPOSURE: return true; } } - OniStatus getProperty(int propertyId, void* data, int* pDataSize) { - switch (propertyId) { + OniStatus getProperty(int propertyId, void* data, int* pDataSize) + { + switch (propertyId) + { default: return VideoStream::getProperty(propertyId, data, pDataSize); - case ONI_STREAM_PROPERTY_HORIZONTAL_FOV: // float (radians) - if (*pDataSize != sizeof(float)) { + case ONI_STREAM_PROPERTY_HORIZONTAL_FOV: // float (radians) + { + if (*pDataSize != sizeof(float)) + { printf("Unexpected size: %d != %lu\n", *pDataSize, sizeof(float)); return ONI_STATUS_ERROR; } *(static_cast(data)) = HORIZONTAL_FOV; return ONI_STATUS_OK; - case ONI_STREAM_PROPERTY_VERTICAL_FOV: // float (radians) - if (*pDataSize != sizeof(float)) { + } + case ONI_STREAM_PROPERTY_VERTICAL_FOV: // float (radians) + { + if (*pDataSize != sizeof(float)) + { printf("Unexpected size: %d != %lu\n", *pDataSize, sizeof(float)); return ONI_STATUS_ERROR; } *(static_cast(data)) = VERTICAL_FOV; return ONI_STATUS_OK; + } + + // camera + case ONI_STREAM_PROPERTY_AUTO_WHITE_BALANCE: // OniBool + { + if (*pDataSize != sizeof(OniBool)) + { + printf("Unexpected size: %d != %lu\n", *pDataSize, sizeof(OniBool)); + return ONI_STATUS_ERROR; + } + *(static_cast(data)) = auto_white_balance; + return ONI_STATUS_OK; + } + case ONI_STREAM_PROPERTY_AUTO_EXPOSURE: // OniBool + { + if (*pDataSize != sizeof(OniBool)) + { + printf("Unexpected size: %d != %lu\n", *pDataSize, sizeof(OniBool)); + return ONI_STATUS_ERROR; + } + *(static_cast(data)) = auto_exposure; + return ONI_STATUS_OK; + } + } + } + + OniStatus setProperty(int propertyId, const void* data, int dataSize) + { + switch (propertyId) + { + default: + return VideoStream::setProperty(propertyId, data, dataSize); + + // camera + case ONI_STREAM_PROPERTY_AUTO_WHITE_BALANCE: // OniBool + { + if (dataSize != sizeof(OniBool)) + { + printf("Unexpected size: %d != %lu\n", dataSize, sizeof(OniBool)); + return ONI_STATUS_ERROR; + } + auto_white_balance = *(static_cast(data)); + int ret = device->setFlag(FREENECT_AUTO_WHITE_BALANCE, auto_white_balance); + return (ret == 0) ? ONI_STATUS_OK : ONI_STATUS_ERROR; + } + case ONI_STREAM_PROPERTY_AUTO_EXPOSURE: // OniBool + { + if (dataSize != sizeof(OniBool)) + { + printf("Unexpected size: %d != %lu\n", dataSize, sizeof(OniBool)); + return ONI_STATUS_ERROR; + } + auto_exposure = *(static_cast(data)); + int ret = device->setFlag(FREENECT_AUTO_WHITE_BALANCE, auto_exposure); + return (ret == 0) ? ONI_STATUS_OK : ONI_STATUS_ERROR; + } } } }; diff --git a/OpenNI2-FreenectDriver/src/VideoStream.hpp b/OpenNI2-FreenectDriver/src/VideoStream.hpp index 20c1aa32..40a0d911 100644 --- a/OpenNI2-FreenectDriver/src/VideoStream.hpp +++ b/OpenNI2-FreenectDriver/src/VideoStream.hpp @@ -115,7 +115,6 @@ namespace FreenectDriver { return ONI_STATUS_OK; case ONI_STREAM_PROPERTY_CROPPING: // OniCropping* - std::cout << "get cropping" << std::endl; if (*pDataSize != sizeof(OniCropping)) { printf("Unexptected size: %d != %lu\n", *pDataSize, sizeof(OniVideoMode)); return ONI_STATUS_ERROR; diff --git a/wrappers/cpp/libfreenect.hpp b/wrappers/cpp/libfreenect.hpp index 631fb959..f2094dfb 100644 --- a/wrappers/cpp/libfreenect.hpp +++ b/wrappers/cpp/libfreenect.hpp @@ -134,6 +134,10 @@ namespace Freenect { freenect_resolution getDepthResolution() { return m_depth_resolution; } + int setFlag(freenect_flag flag, bool value) + { + return freenect_set_flag(m_dev, flag, value ? FREENECT_ON : FREENECT_OFF); + } const freenect_device *getDevice() { return m_dev; } From 529958baada243382586a28019bbcde1c9657032 Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Sun, 19 Jan 2014 11:39:03 -0500 Subject: [PATCH 25/84] OpenNI2-FreenectDriver: OFF by default; pass -DBUILD_OPENNI2_DRIVER=ON to cmake to enable Signed-off-by: Benn Snyder --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ea2cb26..8a4f6dec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,7 +57,7 @@ OPTION(BUILD_CPP "Build C++ Library (currently header only)" ON) OPTION(BUILD_CV "Build OpenCV wrapper" OFF) OPTION(BUILD_AS3_SERVER "Build the Actionscript 3 Server Example" OFF) OPTION(BUILD_PYTHON "Build Python extension" OFF) -OPTION(BUILD_OPENNI2_DRIVER "Build libfreenect driver for OpenNI2" ON) +OPTION(BUILD_OPENNI2_DRIVER "Build libfreenect driver for OpenNI2" OFF) IF(PROJECT_OS_LINUX) OPTION(BUILD_CPACK "Build an RPM or DEB using CPack" OFF) ENDIF(PROJECT_OS_LINUX) From 2f80bfab377515e5c6cafad3930b4ac0d206bfa8 Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Sun, 19 Jan 2014 11:56:42 -0500 Subject: [PATCH 26/84] OpenNI2-FreenectDriver: update README.md Signed-off-by: Benn Snyder --- OpenNI2-FreenectDriver/README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/OpenNI2-FreenectDriver/README.md b/OpenNI2-FreenectDriver/README.md index 8d6f72d1..f481a86a 100644 --- a/OpenNI2-FreenectDriver/README.md +++ b/OpenNI2-FreenectDriver/README.md @@ -9,9 +9,10 @@ OpenNI2-FreenectDriver is distributed under the Apache 2 license. Install ------- 1. Download and unpack [OpenNI](http://www.openni.org/openni-sdk/) 2.2.0.33 or higher. -2. Build libfreenect with the OpenNI2 driver. +2. Go to your build directory and build libfreenect with the OpenNI2 driver. - mkdir build && cd build + mkdir build + cd build cmake .. -DBUILD_OPENNI2_DRIVER=ON make @@ -21,7 +22,7 @@ Install cp -L lib/OpenNI2-FreenectDriver/libFreenectDriver.{so,dylib} ${Repository} OpenNI2-FreenectDriver is built with a static libfreenect, so you do not need to include libfreenect when deploying. -However, you will need to make sure target systems have libusb and all other libfreenect dependencies. +However, you will need to make sure target systems have libusb and all other dependencies listed in `ldd libFreenectDriver.so`. __________________________________________________ From 300faffc669684666d0c2fda23667e7702b63541 Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Sun, 19 Jan 2014 11:59:25 -0500 Subject: [PATCH 27/84] Update CMakeLists.txt for v0.3.0 Signed-off-by: Benn Snyder --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index de93b613..064574b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,8 +41,8 @@ cmake_minimum_required(VERSION 2.6) PROJECT(libfreenect) set (PROJECT_VER_MAJOR 0) -set (PROJECT_VER_MINOR 2) -set (PROJECT_VER_PATCH 1) +set (PROJECT_VER_MINOR 3) +set (PROJECT_VER_PATCH 0) set (PROJECT_VER "${PROJECT_VER_MAJOR}.${PROJECT_VER_MINOR}.${PROJECT_VER_PATCH}") set (PROJECT_APIVER From 63a35893ae7538f162d678bc064c05a64afd23b2 Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Sun, 19 Jan 2014 19:34:15 -0500 Subject: [PATCH 28/84] Remove outdated ebuild Signed-off-by: Benn Snyder --- .../portage/dev-libs/libfreenect/Manifest | 1 - .../libfreenect/libfreenect-0.2.0.ebuild | 77 ------------------- 2 files changed, 78 deletions(-) delete mode 100644 platform/linux/portage/dev-libs/libfreenect/libfreenect-0.2.0.ebuild diff --git a/platform/linux/portage/dev-libs/libfreenect/Manifest b/platform/linux/portage/dev-libs/libfreenect/Manifest index ca654cf4..2ba40d95 100644 --- a/platform/linux/portage/dev-libs/libfreenect/Manifest +++ b/platform/linux/portage/dev-libs/libfreenect/Manifest @@ -1,2 +1 @@ -EBUILD libfreenect-0.2.0.ebuild 1929 SHA256 7f9636faccdb3b4c15abb7c318e2a50b8819f501fdee8d86050d06611743af94 SHA512 bc2705628b0e99fe8cac00950f7cc89509b4db62988e37a2124e3afa5777b4b5fc9e6424453b770ae6c00101cf08e2378b2301a2b9e10dac64a4389827a1c52e WHIRLPOOL c10b7ca722806a5ac566df071dab529c22bffbf34f5ad8f3a13d530585f7833fff93c5bfa02dbe605f4087bd353c2f6597cc412746429a0fb4c237108b2f809f EBUILD libfreenect-9999.ebuild 1897 SHA256 dd1d9696332c6e1ac6d88fb7dd5b221d491d0b44931f6d0f13df8d8387735d77 SHA512 5551562cf5624ad1b83e3d9dbc114fd2a8e98d5f976beda30fab03366ad66a8ea0146dcaa1ebceec489fa9b89fc6f3fed2bd16c97d48352e70f2d6497d9f8d9c WHIRLPOOL 90bb889cd533a2ffddda04cc9b6262dfa634d1d8ae7706245c6372876b51d23914adb44c26106b34d907327672c5e46118126c4aa8b0a17546bc2400347fc4c1 diff --git a/platform/linux/portage/dev-libs/libfreenect/libfreenect-0.2.0.ebuild b/platform/linux/portage/dev-libs/libfreenect/libfreenect-0.2.0.ebuild deleted file mode 100644 index 68c4fc84..00000000 --- a/platform/linux/portage/dev-libs/libfreenect/libfreenect-0.2.0.ebuild +++ /dev/null @@ -1,77 +0,0 @@ -# Copyright 1999-2013 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 -# $Header: $ - -EAPI="5" - -inherit cmake-utils git-2 multilib - - -DESCRIPTION="Core library for accessing the Microsoft Kinect." -HOMEPAGE="https://github.com/OpenKinect/${PN}" -EGIT_REPO_URI="git://github.com/OpenKinect/${PN}.git" -EGIT_COMMIT="v0.2.0" - -LICENSE="Apache-2.0 GPL-2" -SLOT="0" -KEYWORDS="~amd64 ~x86" -IUSE="bindist +c_sync +cpp doc examples fakenect opencv python" - -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 BUILD_REDIST_PACKAGE) - $(cmake-utils_use_build c_sync BUILD_C_SYNC) - $(cmake-utils_use_build cpp BUILD_CPP) - $(cmake-utils_use_build examples BUILD_EXAMPLES) - $(cmake-utils_use_build fakenect BUILD_FAKENECT) - $(cmake-utils_use_build opencv BUILD_CV) - $(cmake-utils_use_build python BUILD_PYTHON) - ) - cmake-utils_src_configure -} - -src_install() { - cmake-utils_src_install - # Rename record example so it does not collide with xawtv - if use examples; then - mv "${D}"/usr/bin/record "${D}"/usr/bin/frecord || die - fi - - # udev rules - insinto /lib/udev/rules.d/ - doins "${S}"/platform/linux/udev/51-kinect.rules - - # documentation - dodoc HACKING README.asciidoc - 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 "You have enabled audio via the bindist USE flag. 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." -} From dfc66611be947ed788329c7fd907b84b5ea7d61a Mon Sep 17 00:00:00 2001 From: ofTheo Date: Thu, 23 Jan 2014 12:51:30 -0500 Subject: [PATCH 29/84] This code sets the LED of a 1473 Kinect or K4W Kinect to red on startup. This seems to fix a known issue for OS X users where the device renumerates within a small time period and causes a freeze. Closes #340 and addresses #316. Signed-off-by: Theodore Watson (ofTheo) --- src/keep_alive.c | 191 +++++++++++++++++++++++++++++++++++++++++++++ src/keep_alive.h | 31 ++++++++ src/usb_libusb10.c | 11 +++ 3 files changed, 233 insertions(+) create mode 100644 src/keep_alive.c create mode 100644 src/keep_alive.h diff --git a/src/keep_alive.c b/src/keep_alive.c new file mode 100644 index 00000000..4f9dfe1a --- /dev/null +++ b/src/keep_alive.c @@ -0,0 +1,191 @@ +// +// keep_alive.c +// Created by Theodore Watson on 1/23/14. + +//This file is part of the OpenKinect Project. http://www.openkinect.org +// +// Copyright (c) 2010 individual OpenKinect contributors. See the CONTRIB file +// for details. +// +// This code is licensed to you under the terms of the Apache License, version +// 2.0, or, at your option, the terms of the GNU General Public License, +// version 2.0. See the APACHE20 and GPL20 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 GPL20 file, or +// 3) Delete the GPL v2.0 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. + + +//Based on code provided by Drew Fisher + +/* + * Copyright 2011 Drew Fisher . All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ''AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL DREW FISHER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are + * those of the authors and should not be interpreted as representing official + * policies, either expressed or implied, of Drew Fisher. + */ + + + + +#include "keep_alive.h" + +#include +#include +#include +#include +#include +#include // For usleep() + +#define le32(X) (X) +#define LOG(...) fprintf(stderr, __VA_ARGS__) + +static uint32_t tag_seq = 1; +static uint32_t tag_next_ack = 1; + +typedef struct { + uint32_t magic; + uint32_t tag; + uint32_t status; +} motor_reply; + +typedef struct { + uint32_t magic; + uint32_t tag; + uint32_t arg1; + uint32_t cmd; + uint32_t arg2; +} motor_command; + +static int get_reply(libusb_device_handle* dev){ + unsigned char buffer[512]; + memset(buffer, 0, 512); + int transferred = 0; + int res = 0; + res = libusb_bulk_transfer(dev, 0x81, buffer, 512, &transferred, 0); + if (res != 0) { + LOG("freenect_extra_keep_alive get_reply(): libusb_bulk_transfer failed: %d (transferred = %d)\n", res, transferred); + } else if (transferred != 12) { + LOG("freenect_extra_keep_alive get_reply(): weird - got %d bytes (expected 12)\n", transferred); + } else { + motor_reply reply; + memcpy(&reply, buffer, sizeof(reply)); + if (reply.magic != 0x0a6fe000) { + LOG("freenect_extra_keep_alive Bad magic: %08X (expected 0A6FE000\n", reply.magic); + res = -1; + } + if (reply.tag != tag_next_ack) { + LOG("freenect_extra_keep_alive Reply tag out of order: expected %d, got %d\n", tag_next_ack, reply.tag); + res = -1; + } + if (reply.status != 0) { + LOG("freenect_extra_keep_alive reply status != 0: failure?\n"); + res = -1; + } + tag_next_ack++; +// LOG("freenect_extra_keep_alive get_reply(): got %d bytes:", transferred); +// int i; +// for (i = 0; i < transferred; i++) { +// LOG(" %02X", buffer[i]); +// } +// LOG("\n"); + } + return res; +} + +static int set_led(libusb_device_handle* dev, int state) { + int transferred = 0; + int res = 0; + motor_command cmd; + cmd.magic = le32(0x06022009); + cmd.tag = le32(tag_seq++); + cmd.arg1 = le32(0); + cmd.cmd = le32(0x10); + cmd.arg2 = (uint32_t)(le32((int32_t)state)); + unsigned char buffer[20]; + memcpy(buffer, &cmd, 20); + // Send command to set LED to solid green +// LOG("About to send bulk transfer:"); +// int i; +// for(i = 0; i < 20 ; i++) { +// LOG(" %02X", buffer[i]); +// } +// LOG("\n"); + res = libusb_bulk_transfer(dev, 0x01, buffer, 20, &transferred, 0); + if (res != 0) { + LOG("freenect_extra_keep_alive set_led(): libusb_bulk_transfer failed: %d (transferred = %d)\n", res, transferred); + return res; + } + return get_reply(dev); +} + +//this is for K4W or 1473 devices - pass in the PID of the audio device that needs the LED set. +void freenect_extra_keep_alive(int pid){ + + int res; + int state_to_set = 4; + + libusb_context* ctx = NULL; + libusb_init(&ctx); + + libusb_device_handle* dev = NULL; + dev = libusb_open_device_with_vid_pid(ctx, 0x045e, pid); + if (dev == NULL) { + LOG("freenect extra keepAlive: Failed to open audio device\n"); + libusb_exit(ctx); + return; + } + + res = libusb_claim_interface(dev, 0); + if (res != 0) { + LOG("freenect extra keepAlive: Failed to claim interface 1: %d\n", res); + libusb_close(dev); + libusb_exit(ctx); + return; + } + + res = set_led(dev, state_to_set); + if (res != 0) { + LOG("freenect extra keepAlive: set_led failed\n"); + libusb_close(dev); + libusb_exit(ctx); + return; + } + + libusb_close(dev); + libusb_exit(ctx); +} \ No newline at end of file diff --git a/src/keep_alive.h b/src/keep_alive.h new file mode 100644 index 00000000..61123129 --- /dev/null +++ b/src/keep_alive.h @@ -0,0 +1,31 @@ +// keep_alive.h +// +// Created by Theodore Watson on 1/23/14. + +//This file is part of the OpenKinect Project. http://www.openkinect.org +// +// Copyright (c) 2010 individual OpenKinect contributors. See the CONTRIB file +// for details. +// +// This code is licensed to you under the terms of the Apache License, version +// 2.0, or, at your option, the terms of the GNU General Public License, +// version 2.0. See the APACHE20 and GPL20 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 GPL20 file, or +// 3) Delete the GPL v2.0 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. + + +#pragma once +void freenect_extra_keep_alive(int pid); + diff --git a/src/usb_libusb10.c b/src/usb_libusb10.c index 0584dbdf..9fb4e93e 100644 --- a/src/usb_libusb10.c +++ b/src/usb_libusb10.c @@ -32,6 +32,8 @@ #include "freenect_internal.h" #include "loader.h" +#include "keep_alive.h" + FN_INTERNAL int fnusb_num_devices(fnusb_ctx *ctx) { libusb_device **devs; @@ -203,6 +205,15 @@ FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index) /* Not the old kinect so we only set up the camera*/ ctx->enabled_subdevices = FREENECT_DEVICE_CAMERA; ctx->zero_plane_res = 334; + + //lets also set the LED ON + //this keeps the camera alive for some systems which get freezes + if( desc.idProduct == PID_K4W_CAMERA ){ + freenect_extra_keep_alive(PID_K4W_AUDIO); + }else{ + freenect_extra_keep_alive(PID_NUI_AUDIO); + } + }else{ /* The good old kinect that tilts and tweets */ ctx->zero_plane_res = 322; From 9ac4ab13fd62df25fc2977fef8e839a2a04b03c1 Mon Sep 17 00:00:00 2001 From: ofTheo Date: Mon, 27 Jan 2014 20:06:59 -0500 Subject: [PATCH 30/84] Supports loading audio fw from memory as well as disk. Supports tilt,accel and led for K4W and 1473 device. Adds keep alive for K4W and 1473. Signed-off-by: Theodore Watson theo@openframeworks.cc (ofTheo) --- include/libfreenect.h | 20 ++++ src/audio.c | 3 + src/core.c | 14 +++ src/freenect_internal.h | 16 +++ src/keep_alive.c | 21 +++- src/loader.c | 112 ++++++++++++++++----- src/loader.h | 5 +- src/tilt.c | 218 +++++++++++++++++++++++++++++++++++++++- src/usb_libusb10.c | 70 ++++++++++--- 9 files changed, 438 insertions(+), 41 deletions(-) diff --git a/include/libfreenect.h b/include/libfreenect.h index b3f30168..cc8c6046 100644 --- a/include/libfreenect.h +++ b/include/libfreenect.h @@ -669,6 +669,26 @@ 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); + +/** + * Allows the user to specify a pointer to the audio firmware in memory for the Xbox 360 Kinect + * + * @param ctx Context to open device through + * @param fw_ptr Pointer to audio firmware loaded in memory + * @param num_bytes The size of the firmware in bytes + */ +FREENECTAPI void freenect_set_fw_address_nui(freenect_context * ctx, unsigned char * fw_ptr, unsigned int num_bytes); + +/** + * Allows the user to specify a pointer to the audio firmware in memory for the K4W Kinect + * + * @param ctx Context to open device through + * @param fw_ptr Pointer to audio firmware loaded in memory + * @param num_bytes The size of the firmware in bytes + */ +FREENECTAPI void freenect_set_fw_address_k4w(freenect_context * ctx, unsigned char * fw_ptr, unsigned int num_bytes); + + #ifdef __cplusplus } #endif diff --git a/src/audio.c b/src/audio.c index f9a2e759..ac83d7df 100644 --- a/src/audio.c +++ b/src/audio.c @@ -30,6 +30,8 @@ #include #include +#ifdef BUILD_AUDIO + static void prepare_iso_out_data(freenect_device* dev, uint8_t* buffer) { audio_stream* stream = &dev->audio; if (dev->audio_out_cb) { @@ -238,3 +240,4 @@ int freenect_stop_audio(freenect_device* dev) { return ret; } +#endif diff --git a/src/core.c b/src/core.c index 305c9e18..4ad62255 100644 --- a/src/core.c +++ b/src/core.c @@ -293,3 +293,17 @@ FN_INTERNAL void fn_log(freenect_context *ctx, freenect_loglevel level, const ch va_end(ap); } } + + +FREENECTAPI void freenect_set_fw_address_nui(freenect_context * ctx, unsigned char * fw_ptr, unsigned int num_bytes) +{ + ctx->fn_fw_nui_ptr = fw_ptr; + ctx->fn_fw_nui_size = num_bytes; +} + +FREENECTAPI void freenect_set_fw_address_k4w(freenect_context * ctx, unsigned char * fw_ptr, unsigned int num_bytes) +{ + ctx->fn_fw_k4w_ptr = fw_ptr; + ctx->fn_fw_k4w_size = num_bytes; +} + diff --git a/src/freenect_internal.h b/src/freenect_internal.h index 4aa877a2..5bf98aa1 100644 --- a/src/freenect_internal.h +++ b/src/freenect_internal.h @@ -53,6 +53,13 @@ struct _freenect_context { freenect_device_flags enabled_subdevices; freenect_device *first; int zero_plane_res; + + //if you want to load firmware from memory rather than disk + unsigned char * fn_fw_nui_ptr; + unsigned int fn_fw_nui_size; + + unsigned char * fn_fw_k4w_ptr; + unsigned int fn_fw_k4w_size; }; #define LL_FATAL FREENECT_LOG_FATAL @@ -133,7 +140,13 @@ static inline int32_t fn_le32s(int32_t s) #define PID_NUI_CAMERA 0x02ae #define PID_NUI_MOTOR 0x02b0 #define PID_K4W_CAMERA 0x02bf + +// For K4W: first pid is what it starts out as, +// second is how it appears with lastest firmware from SDK, +// third is from beta SDK firmware ( which is what is unpacked by the fw script and doesn't support motor control ) #define PID_K4W_AUDIO 0x02be +#define PID_K4W_AUDIO_ALT_1 0x02c3 +#define PID_K4W_AUDIO_ALT_2 0x02bb typedef struct { int running; @@ -243,4 +256,7 @@ struct _freenect_device { // Motor fnusb_dev usb_motor; freenect_raw_tilt_state raw_state; + + int device_does_motor_control_with_audio; + int motor_control_with_audio_enabled; }; diff --git a/src/keep_alive.c b/src/keep_alive.c index 4f9dfe1a..5dcce0ff 100644 --- a/src/keep_alive.c +++ b/src/keep_alive.c @@ -63,6 +63,7 @@ #include "keep_alive.h" +#include "freenect_internal.h" #include #include @@ -157,14 +158,30 @@ static int set_led(libusb_device_handle* dev, int state) { void freenect_extra_keep_alive(int pid){ int res; - int state_to_set = 4; + int state_to_set = 3; libusb_context* ctx = NULL; libusb_init(&ctx); libusb_device_handle* dev = NULL; + + //check the default audio device + dev = libusb_open_device_with_vid_pid(ctx, 0x045e, pid); + + //K4W only: + //if the firmware is uploaded the device could have a two different PIDs based on which firmware was uploaded. + //so we have to check for both + //note: it might be better if we pass in the PID of the camera and then find the audio device that is in the same usb tree/hub - might be more reliable when multiple devices are plugged in + if( dev == NULL && pid == PID_K4W_AUDIO ){ + pid = PID_K4W_AUDIO_ALT_1; + dev = libusb_open_device_with_vid_pid(ctx, 0x045e, pid); + } + if( dev == NULL && pid == PID_K4W_AUDIO_ALT_1 ){ + pid = PID_K4W_AUDIO_ALT_2; dev = libusb_open_device_with_vid_pid(ctx, 0x045e, pid); - if (dev == NULL) { + } + + if(dev == NULL) { LOG("freenect extra keepAlive: Failed to open audio device\n"); libusb_exit(ctx); return; diff --git a/src/loader.c b/src/loader.c index 0451b1fb..514fe2a4 100644 --- a/src/loader.c +++ b/src/loader.c @@ -32,6 +32,8 @@ #include #include +#ifdef BUILD_AUDIO + static void dump_bl_cmd(freenect_context* ctx, bootloader_command cmd) { int i; for(i = 0; i < 24; i++) @@ -120,28 +122,28 @@ static int check_version_string(fnusb_dev* dev) { return res; } -FN_INTERNAL int upload_firmware(fnusb_dev* dev) { - freenect_context* ctx = dev->parent->parent; - bootloader_command bootcmd; - memset(&bootcmd, 0, sizeof(bootcmd)); - bootcmd.magic = fn_le32(0x06022009); - - int res; - int transferred; +FN_INTERNAL int upload_firmware(fnusb_dev* dev, char * filename) { + freenect_context* ctx = dev->parent->parent; /* Search for firmware file (audios.bin) in the following places: * $LIBFREENECT_FIRMWARE_PATH * . * ${HOME}/.libfreenect * /usr/local/share/libfreenect * /usr/share/libfreenect + * ./../Resources/ ( for OS X ) */ - const char* fw_filename = "/audios.bin"; + + //need to add a forward slash + char fw_filename[1024]; + sprintf(fw_filename, "/%s", filename); + int filenamelen = strlen(fw_filename); int i; int searchpathcount; FILE* fw = NULL; - for(i = 0, searchpathcount = 5; !fw && i < searchpathcount; i++) { + + for(i = 0, searchpathcount = 6; !fw && i < searchpathcount; i++) { char* fwfile; int needs_free = 0; switch(i) { @@ -157,7 +159,10 @@ FN_INTERNAL int upload_firmware(fnusb_dev* dev) { } break; case 1: - fwfile = "./audios.bin"; + //fwfile = "./audios.bin"; + fwfile = malloc(2048); + needs_free = 1; + sprintf(fwfile, ".%s", fw_filename); break; case 2: { // Construct $HOME/.libfreenect/ @@ -175,10 +180,21 @@ FN_INTERNAL int upload_firmware(fnusb_dev* dev) { } break; case 3: - fwfile = "/usr/local/share/libfreenect/audios.bin"; + //fwfile = "/usr/local/share/libfreenect/audios.bin"; + sprintf(fwfile, "/usr/local/share/libfreenect%s", fw_filename); + break; case 4: - fwfile = "/usr/share/libfreenect/audios.bin"; + //fwfile = "/usr/share/libfreenect/audios.bin"; + fwfile = malloc(2048); + needs_free = 1; + sprintf(fwfile, "/usr/share/libfreenect%s", fw_filename); + break; + case 5: + //fwfile = "./../Resources/audios.bin"; //default for OS X equivilant to: "./audios.bin"; + fwfile = malloc(2048); + needs_free = 1; + sprintf(fwfile, "./../Resources%s", fw_filename); break; default: break; } @@ -192,15 +208,50 @@ FN_INTERNAL int upload_firmware(fnusb_dev* dev) { FN_ERROR("upload_firmware: failed to find firmware file.\n"); return -errno; } - // Now we have an open firmware file handle. + + // get the number of bytes of the file + fseek(fw , 0, SEEK_END); + int fw_num_bytes = ftell(fw); + rewind(fw); + + if( fw_num_bytes <= 0 ){ + FN_ERROR("upload_firmware: failed to find file with any data.\n"); + return -errno; + } + + unsigned char * fw_bytes = malloc(fw_num_bytes); + int numRead = fread(fw_bytes, 1, fw_num_bytes, fw); + fw_num_bytes = numRead; // just in case + + int retVal = upload_firmware_from_memory(dev, fw_bytes, fw_num_bytes); + + fclose(fw); + fw = NULL; + + return retVal; + } + +FN_INTERNAL int upload_firmware_from_memory(fnusb_dev* dev, unsigned char * fw_from_mem, unsigned int fw_size_in_btyes) { + freenect_context* ctx = dev->parent->parent; + bootloader_command bootcmd; + memset(&bootcmd, 0, sizeof(bootcmd)); + bootcmd.magic = fn_le32(0x06022009); + + int res; + int transferred; + firmware_header fwheader; int read = 0; - read = fread(&fwheader, 1, sizeof(firmware_header), fw); - if (read != sizeof(firmware_header)) { + int bytesLeft = fw_size_in_btyes; + unsigned char * readPtr = &fw_from_mem[0]; + + if (fw_size_in_btyes < sizeof(firmware_header)) { FN_ERROR("upload_firmware: firmware image too small, has no header?\n"); - fclose(fw); return -errno; } + + memcpy(&fwheader, readPtr, sizeof(firmware_header)); + // The file is serialized as little endian. fwheader.magic = fn_le32(fwheader.magic); fwheader.ver_major = fn_le16(fwheader.ver_major); @@ -217,16 +268,27 @@ FN_INTERNAL int upload_firmware(fnusb_dev* dev) { FN_INFO("\tsize 0x%08x\n", fwheader.size); FN_INFO("\tentry point 0x%08x\n", fwheader.entry_addr); - rewind(fw); + uint32_t addr = fwheader.base_addr; unsigned char page[0x4000]; + int readIndex = 0; int total_bytes_sent = 0; do { - size_t block_size = (0x4000 > fwheader.size - total_bytes_sent) ? fwheader.size - total_bytes_sent : 0x4000; - read = fread(page, 1, block_size, fw); - if(read <= 0) { + + read = (0x4000 > fwheader.size - total_bytes_sent) ? fwheader.size - total_bytes_sent : 0x4000; + + // sanity check + if( read > bytesLeft ){ + read = bytesLeft; + } + if (read <= 0) { break; } + + memcpy(page, &readPtr[readIndex], read); + readIndex += read; + bytesLeft -= read; + bootcmd.tag = fn_le32(dev->parent->audio_tag); bootcmd.bytes = fn_le32(read); bootcmd.cmd = fn_le32(0x03); @@ -237,7 +299,6 @@ FN_INTERNAL int upload_firmware(fnusb_dev* dev) { res = fnusb_bulk(dev, 1, (unsigned char*)&bootcmd, sizeof(bootcmd), &transferred); if(res != 0 || transferred != sizeof(bootcmd)) { FN_ERROR("upload_firmware(): Error: res: %d\ttransferred: %d (expected %d)\n",res, transferred, (int)(sizeof(bootcmd))); - fclose(fw); return -1; } int bytes_sent = 0; @@ -246,7 +307,6 @@ FN_INTERNAL int upload_firmware(fnusb_dev* dev) { res = fnusb_bulk(dev, 1, &page[bytes_sent], to_send, &transferred); if(res != 0 || transferred != to_send) { FN_ERROR("upload_firmware(): Error: res: %d\ttransferred: %d (expected %d)\n",res, transferred, to_send); - fclose(fw); return -1; } bytes_sent += to_send; @@ -256,8 +316,7 @@ FN_INTERNAL int upload_firmware(fnusb_dev* dev) { addr += (uint32_t)read; dev->parent->audio_tag++; } while (read > 0); - fclose(fw); - fw = NULL; + if (total_bytes_sent != fwheader.size) { FN_ERROR("upload_firmware: firmware image declared %d bytes, but file only contained %d bytes\n", fwheader.size, total_bytes_sent); return -1; @@ -359,3 +418,6 @@ FN_INTERNAL int upload_cemd_data(fnusb_dev* dev) { FN_INFO("CEMD data uploaded successfully.\n"); return 0; } + +#endif + diff --git a/src/loader.h b/src/loader.h index f2fd45c4..d6fe6fca 100644 --- a/src/loader.h +++ b/src/loader.h @@ -29,6 +29,7 @@ #include #include "usb_libusb10.h" + typedef struct { uint32_t magic; uint32_t tag; @@ -64,5 +65,7 @@ typedef struct { uint32_t status; } bootloader_status_code; -int upload_firmware(fnusb_dev* dev); +int upload_firmware(fnusb_dev* dev, char * fw_filename); +int upload_firmware_from_memory(fnusb_dev* dev, unsigned char * fw_from_mem, unsigned int fw_size_in_bytes); + int upload_cemd_data(fnusb_dev* dev); diff --git a/src/tilt.c b/src/tilt.c index 8852e768..198f97d2 100644 --- a/src/tilt.c +++ b/src/tilt.c @@ -39,16 +39,134 @@ #define GRAVITY 9.80665 +// Structs for 1473 and K4W communication +typedef struct { + uint32_t magic; + uint32_t tag; + uint32_t arg1; + uint32_t cmd; + uint32_t arg2; +}fn_alt_motor_command; + +typedef struct { + uint32_t magic; + uint32_t tag; + uint32_t status; +}fn_alt_motor_reply; + +static int tag_seq = 0; +static int tag_next_ack = 0; + +int get_reply(libusb_device_handle* dev, freenect_context *ctx){ + unsigned char buffer[512]; + memset(buffer, 0, 512); + int transferred = 0; + int res = 0; + res = libusb_bulk_transfer(dev, 0x81, buffer, 512, &transferred, 0); + if (res != 0) { + FN_ERROR("get_reply(): libusb_bulk_transfer failed: %d (transferred = %d)\n", res, transferred); + } else if (transferred != 12) { + FN_ERROR("get_reply(): weird - got %d bytes (expected 12)\n", transferred); + } else { + fn_alt_motor_reply reply; + memcpy(&reply, buffer, sizeof(reply)); + if (reply.magic != 0x0a6fe000) { + FN_ERROR("Bad magic: %08X (expected 0A6FE000\n", reply.magic); + res = -1; + } + + //can't really do this as tag_seq is static. with two cameras this is not going to match. could put in as part of libusb_device but I don't think it really matters. +// if (reply.tag != tag_next_ack) { +// FN_ERROR("Reply tag out of order: expected %d, got %d\n", tag_next_ack, reply.tag); +// res = -1; +// } + + if (reply.status != 0) { + FN_ERROR("reply status != 0: failure?\n"); + res = -1; + } + + tag_next_ack++; + } + return res; +} + + freenect_raw_tilt_state* freenect_get_tilt_state(freenect_device *dev) { return &dev->raw_state; } +#ifdef BUILD_AUDIO +int update_tilt_state_alt(freenect_device *dev){ + freenect_context *ctx = dev->parent; + + int transferred = 0; + int res = 0; + fn_alt_motor_command cmd; + cmd.magic = fn_le32(0x06022009); + cmd.tag = fn_le32(tag_seq++); + cmd.arg1 = fn_le32(0x68); // 104. Incidentally, the number of bytes that we expect in the reply. + cmd.cmd = fn_le32(0x8032); + + unsigned char buffer[256]; + memcpy(buffer, &cmd, 16); + + res = libusb_bulk_transfer(dev->usb_audio.dev, 0x01, buffer, 16, &transferred, 0); + if (res != 0) { + return res; + } + + res = libusb_bulk_transfer(dev->usb_audio.dev, 0x81, buffer, 256, &transferred, 0); // 104 bytes + if (res != 0) { + return res; + } else { +// int i; +// for(i = 0 ; i < transferred ; i += 4) { +// int32_t j; +// memcpy(&j, buffer + i, 4); +// printf("\t%d\n", j); +// } +// printf("\n"); + struct { + int32_t x; + int32_t y; + int32_t z; + int32_t tilt; + } accel_and_tilt; + + memcpy(&accel_and_tilt, buffer + 16, sizeof(accel_and_tilt)); + //printf("\tX: %d Y: %d Z:%d - tilt is %d\n", accel_and_tilt.x, accel_and_tilt.y, accel_and_tilt.z, accel_and_tilt.tilt); + + dev->raw_state.accelerometer_x = (int16_t)accel_and_tilt.x; + dev->raw_state.accelerometer_y = (int16_t)accel_and_tilt.y; + dev->raw_state.accelerometer_z = (int16_t)accel_and_tilt.z; + + //this is multiplied by 2 as the older 1414 device reports angles doubled and freenect takes this into account + dev->raw_state.tilt_angle = (int8_t)accel_and_tilt.tilt * 2; + + } + // Reply: skip four uint32_t, then you have three int32_t that give you acceleration in that direction, it seems. + // Units still to be worked out. + return get_reply(dev->usb_audio.dev, ctx); +} +#endif + int freenect_update_tilt_state(freenect_device *dev) { freenect_context *ctx = dev->parent; - if(!(ctx->enabled_subdevices & FREENECT_DEVICE_MOTOR)) + + #ifdef BUILD_AUDIO + //if we have motor control via audio and fw is uploaded - call the alt function + if( dev->motor_control_with_audio_enabled ){ + return update_tilt_state_alt(dev); + } + #endif + + if(!(ctx->enabled_subdevices & FREENECT_DEVICE_MOTOR)) return 0; + + uint8_t buf[10]; uint16_t ux, uy, uz; int ret = fnusb_control(&dev->usb_motor, 0xC0, 0x32, 0x0, 0x0, buf, 10); @@ -70,11 +188,51 @@ int freenect_update_tilt_state(freenect_device *dev) return ret; } +#ifdef BUILD_AUDIO +int freenect_set_tilt_degs_alt(freenect_device *dev, int tilt_degrees) +{ + freenect_context *ctx = dev->parent; + + if (tilt_degrees > 31 || tilt_degrees < -31) { + FN_WARNING("set_tilt(): degrees %d out of safe range [-31, 31]\n", tilt_degrees); + return -1; + } + + fn_alt_motor_command cmd; + cmd.magic = fn_le32(0x06022009); + cmd.tag = fn_le32(tag_seq++); + cmd.arg1 = fn_le32(0); + cmd.cmd = fn_le32(0x803b); + cmd.arg2 = (uint32_t)(fn_le32((int32_t)tilt_degrees)); + int transferred = 0; + int res = 0; + unsigned char buffer[20]; + memcpy(buffer, &cmd, 20); + + res = libusb_bulk_transfer(dev->usb_audio.dev, 0x01, buffer, 20, &transferred, 0); + if (res != 0) { + FN_ERROR("freenect_set_tilt_alt(): libusb_bulk_transfer failed: %d (transferred = %d)\n", res, transferred); + return res; + } + + return get_reply(dev->usb_audio.dev, ctx); +} +#endif + int freenect_set_tilt_degs(freenect_device *dev, double angle) { freenect_context *ctx = dev->parent; + + #ifdef BUILD_AUDIO + //if we have motor control via audio and fw is uploaded - call the alt function + if( dev->motor_control_with_audio_enabled ){ + return freenect_set_tilt_degs_alt(dev, angle); + } + #endif + if(!(ctx->enabled_subdevices & FREENECT_DEVICE_MOTOR)) return 0; + int ret; uint8_t empty[0x1]; @@ -85,11 +243,69 @@ int freenect_set_tilt_degs(freenect_device *dev, double angle) return ret; } +#ifdef BUILD_AUDIO +int freenect_set_led_alt(freenect_device *dev, freenect_led_options state) +{ + freenect_context *ctx = dev->parent; + + typedef enum { + LED_ALT_OFF = 1, + LED_ALT_BLINK_GREEN = 2, + LED_ALT_SOLID_GREEN = 3, + LED_ALT_SOLID_RED = 4, + }led_alt_state; + + int transferred = 0; + int res = 0; + + //The LED states are different between K4W/1473 and older 1414 + if( state == LED_GREEN ){ + state = LED_ALT_SOLID_GREEN; + }else if( state == LED_RED ){ + state = LED_ALT_SOLID_RED; + }else if( state == LED_YELLOW ){ + state = LED_ALT_SOLID_GREEN; + }else if( state == LED_OFF ){ + state = LED_ALT_OFF; + }else if( state == LED_BLINK_GREEN ){ + state = LED_ALT_BLINK_GREEN; + }else{ + state = LED_GREEN; + } + + fn_alt_motor_command cmd; + cmd.magic = fn_le32(0x06022009); + cmd.tag = fn_le32(tag_seq++); + cmd.arg1 = fn_le32(0); + cmd.cmd = fn_le32(0x10); + cmd.arg2 = (uint32_t)(fn_le32((int32_t)state)); + + unsigned char buffer[20]; + memcpy(buffer, &cmd, 20); + + res = libusb_bulk_transfer(dev->usb_audio.dev, 0x01, buffer, 20, &transferred, 0); + if (res != 0) { + FN_WARNING("freenect_set_led_alt(): libusb_bulk_transfer failed: %d (transferred = %d)\n", res, transferred); + return res; + } + return get_reply(dev->usb_audio.dev, ctx); +} +#endif + int freenect_set_led(freenect_device *dev, freenect_led_options option) { freenect_context *ctx = dev->parent; + + //if we have motor control via audio and fw is uploaded - call the alt function + #ifdef BUILD_AUDIO + if( dev->motor_control_with_audio_enabled ){ + return freenect_set_led_alt(dev, option); + } + #endif + if(!(ctx->enabled_subdevices & FREENECT_DEVICE_MOTOR)) return 0; + int ret; uint8_t empty[0x1]; ret = fnusb_control(&dev->usb_motor, 0x40, 0x06, (uint16_t)option, 0x0, empty, 0x0); diff --git a/src/usb_libusb10.c b/src/usb_libusb10.c index 9fb4e93e..801ee121 100644 --- a/src/usb_libusb10.c +++ b/src/usb_libusb10.c @@ -158,10 +158,21 @@ FN_INTERNAL int fnusb_process_events_timeout(fnusb_ctx *ctx, struct timeval* tim return libusb_handle_events_timeout(ctx->ctx, timeout); } +//there are a bunch of different PIDs to check for - this function makes it easier +FN_INTERNAL int fn_is_pid_k4w_audio(int pid){ + if( pid == PID_K4W_AUDIO || pid == PID_K4W_AUDIO_ALT_1 | pid == PID_K4W_AUDIO_ALT_2 ){ + return 0; + } + return -1; +} + FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index) { freenect_context *ctx = dev->parent; + dev->device_does_motor_control_with_audio = 0; + dev->motor_control_with_audio_enabled = 0; + dev->usb_cam.parent = dev; dev->usb_cam.dev = NULL; dev->usb_motor.parent = dev; @@ -205,7 +216,8 @@ FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index) /* Not the old kinect so we only set up the camera*/ ctx->enabled_subdevices = FREENECT_DEVICE_CAMERA; ctx->zero_plane_res = 334; - + dev->device_does_motor_control_with_audio = 1; + //lets also set the LED ON //this keeps the camera alive for some systems which get freezes if( desc.idProduct == PID_K4W_CAMERA ){ @@ -214,6 +226,13 @@ FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index) freenect_extra_keep_alive(PID_NUI_AUDIO); } +#ifdef BUILD_AUDIO + //for newer devices we need to enable the audio device for motor control + if( (ctx->enabled_subdevices & FREENECT_DEVICE_AUDIO) == 0 ){ + ctx->enabled_subdevices |= FREENECT_DEVICE_AUDIO; + } +#endif + }else{ /* The good old kinect that tilts and tweets */ ctx->zero_plane_res = 322; @@ -290,8 +309,9 @@ FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index) #ifdef BUILD_AUDIO // TODO: check that the firmware has already been loaded; if not, upload firmware. // Search for the audio - if ((ctx->enabled_subdevices & FREENECT_DEVICE_AUDIO) && !dev->usb_audio.dev && (desc.idProduct == PID_NUI_AUDIO || desc.idProduct == PID_K4W_AUDIO)) { + if ((ctx->enabled_subdevices & FREENECT_DEVICE_AUDIO) && !dev->usb_audio.dev && (desc.idProduct == PID_NUI_AUDIO || fn_is_pid_k4w_audio(desc.idProduct) != -1 )) { // If the index given by the user matches our audio index + if (nr_audio == index) { res = libusb_open (devs[i], &dev->usb_audio.dev); if (res < 0 || !dev->usb_audio.dev) { @@ -306,6 +326,7 @@ FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index) dev->usb_audio.dev = NULL; break; } + // 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 @@ -313,7 +334,13 @@ FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index) // waiting for a device with the same serial number to // reappear. int num_interfaces = fnusb_num_interfaces(&dev->usb_audio); - if (num_interfaces == 1) { + + 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); @@ -322,10 +349,23 @@ FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index) break; } char* audio_serial = strdup((char*)string_desc); - + FN_SPEW("Uploading firmware to audio device in bootloader state.\n"); - res = upload_firmware(&dev->usb_audio); - if (res < 0) { + + // 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 (res < 0) { FN_ERROR("upload_firmware failed: %d\n", res); break; } @@ -346,7 +386,7 @@ FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index) if (r < 0) 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) { + if (new_dev_desc.idVendor == VID_MICROSOFT && (new_dev_desc.idProduct == PID_NUI_AUDIO || fn_is_pid_k4w_audio(desc.idProduct) != -1) ){ FN_SPEW("Matched VID/PID!\n"); libusb_device_handle* new_dev_handle; // Open device @@ -372,14 +412,20 @@ FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index) } // Save the device handle. dev->usb_audio.dev = new_dev_handle; - // Verify that we've actually found a device running the right firmware. - if (fnusb_num_interfaces(&dev->usb_audio) != 2) { - FN_SPEW("Opened audio with matching serial but too few interfaces.\n"); + + // 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; + } break; } else { FN_SPEW("Got serial %s, expected serial %s\n", (char*)string_desc, audio_serial); } From 82f2b184e87e627f24ed7822fba8fe62c08f3331 Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Mon, 27 Jan 2014 21:52:47 -0500 Subject: [PATCH 31/84] Fix ebuild Signed-off-by: Benn Snyder --- OpenNI2-FreenectDriver/README.md | 2 +- .../linux/portage/dev-libs/libfreenect/Manifest | 2 +- .../libfreenect/libfreenect-9999.ebuild | 17 +++++++++-------- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/OpenNI2-FreenectDriver/README.md b/OpenNI2-FreenectDriver/README.md index f481a86a..e8a69c4a 100644 --- a/OpenNI2-FreenectDriver/README.md +++ b/OpenNI2-FreenectDriver/README.md @@ -9,7 +9,7 @@ OpenNI2-FreenectDriver is distributed under the Apache 2 license. Install ------- 1. Download and unpack [OpenNI](http://www.openni.org/openni-sdk/) 2.2.0.33 or higher. -2. Go to your build directory and build libfreenect with the OpenNI2 driver. +2. Go to the top libfreenect directory and build it with the OpenNI2 driver. mkdir build cd build diff --git a/platform/linux/portage/dev-libs/libfreenect/Manifest b/platform/linux/portage/dev-libs/libfreenect/Manifest index 2ba40d95..25f7a100 100644 --- a/platform/linux/portage/dev-libs/libfreenect/Manifest +++ b/platform/linux/portage/dev-libs/libfreenect/Manifest @@ -1 +1 @@ -EBUILD libfreenect-9999.ebuild 1897 SHA256 dd1d9696332c6e1ac6d88fb7dd5b221d491d0b44931f6d0f13df8d8387735d77 SHA512 5551562cf5624ad1b83e3d9dbc114fd2a8e98d5f976beda30fab03366ad66a8ea0146dcaa1ebceec489fa9b89fc6f3fed2bd16c97d48352e70f2d6497d9f8d9c WHIRLPOOL 90bb889cd533a2ffddda04cc9b6262dfa634d1d8ae7706245c6372876b51d23914adb44c26106b34d907327672c5e46118126c4aa8b0a17546bc2400347fc4c1 +EBUILD libfreenect-9999.ebuild 1926 SHA256 ce96381a0574be42ab0c50e06c647ef0db7a9fe8ed8a9ebf55c9013fb20f8e5f SHA512 ef692429fe0a746a42e3fb4ef39ead0da258ddf418cbb839d9bb4617aa6607490cc2578505a88d1cc5bc01ac90fabcb9d9a27a000f7ab6533a1fb2f75610c2a6 WHIRLPOOL 50bc5c4de88c28df3d94cc2b9bc9f90120ed029f2af43c585c54e0c9ce7b9f96893c74fe6a06f7145a081bbb4ad7893fec940218aa1ddd7dd34d895bd41ef5f5 diff --git a/platform/linux/portage/dev-libs/libfreenect/libfreenect-9999.ebuild b/platform/linux/portage/dev-libs/libfreenect/libfreenect-9999.ebuild index 11dce607..9f014b65 100644 --- a/platform/linux/portage/dev-libs/libfreenect/libfreenect-9999.ebuild +++ b/platform/linux/portage/dev-libs/libfreenect/libfreenect-9999.ebuild @@ -14,7 +14,7 @@ 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 python" +IUSE="bindist +c_sync +cpp doc examples fakenect opencv openni2 python" COMMON_DEP=" virtual/libusb:1 @@ -35,13 +35,14 @@ python? ( dev-python/cython )" src_configure() { local mycmakeargs=( - $(cmake-utils_use_build bindist BUILD_REDIST_PACKAGE) - $(cmake-utils_use_build c_sync BUILD_C_SYNC) - $(cmake-utils_use_build cpp BUILD_CPP) - $(cmake-utils_use_build examples BUILD_EXAMPLES) - $(cmake-utils_use_build fakenect BUILD_FAKENECT) - $(cmake-utils_use_build opencv BUILD_CV) - $(cmake-utils_use_build python BUILD_PYTHON) + $(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 } From f6cb19e3f0607dcb77fd413db64887b17cf2f956 Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Sat, 1 Feb 2014 00:26:09 -0500 Subject: [PATCH 32/84] Removed memset() after free() causing sporadic crashes when unplugging devices Signed-off-by: Benn Snyder --- src/usb_libusb10.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/usb_libusb10.c b/src/usb_libusb10.c index 0584dbdf..87fcc139 100644 --- a/src/usb_libusb10.c +++ b/src/usb_libusb10.c @@ -600,7 +600,6 @@ FN_INTERNAL int fnusb_stop_iso(fnusb_dev *dev, fnusb_isoc_stream *strm) free(strm->xfers); FN_FLOOD("fnusb_stop_iso() freed buffers and stream\n"); - memset(strm, 0, sizeof(*strm)); FN_FLOOD("fnusb_stop_iso() done\n"); return 0; } From 50bd445d4c07f4ad6809676587449388dcfe48c4 Mon Sep 17 00:00:00 2001 From: ofTheo Date: Sun, 2 Feb 2014 17:39:30 -0500 Subject: [PATCH 33/84] small changes to allow compile on windows / visual studio --- src/loader.c | 22 +++++++++++----------- src/tilt.c | 10 +++++----- src/usb_libusb10.c | 13 +++++++++++-- 3 files changed, 27 insertions(+), 18 deletions(-) diff --git a/src/loader.c b/src/loader.c index 514fe2a4..dc2a8ea2 100644 --- a/src/loader.c +++ b/src/loader.c @@ -124,7 +124,7 @@ static int check_version_string(fnusb_dev* dev) { FN_INTERNAL int upload_firmware(fnusb_dev* dev, char * filename) { - freenect_context* ctx = dev->parent->parent; + freenect_context* ctx = dev->parent->parent; /* Search for firmware file (audios.bin) in the following places: * $LIBFREENECT_FIRMWARE_PATH * . @@ -138,7 +138,7 @@ FN_INTERNAL int upload_firmware(fnusb_dev* dev, char * filename) { char fw_filename[1024]; sprintf(fw_filename, "/%s", filename); - int filenamelen = strlen(fw_filename); + int filenamelen = strlen(fw_filename); int i; int searchpathcount; FILE* fw = NULL; @@ -152,7 +152,7 @@ FN_INTERNAL int upload_firmware(fnusb_dev* dev, char * filename) { if (!envpath) continue; int pathlen = strlen(envpath); - fwfile = malloc(pathlen + filenamelen + 1); + fwfile = (char *)malloc(pathlen + filenamelen + 1); strcpy(fwfile, envpath); strcat(fwfile, fw_filename); needs_free = 1; @@ -160,7 +160,7 @@ FN_INTERNAL int upload_firmware(fnusb_dev* dev, char * filename) { break; case 1: //fwfile = "./audios.bin"; - fwfile = malloc(2048); + fwfile = (char *)malloc(2048); needs_free = 1; sprintf(fwfile, ".%s", fw_filename); break; @@ -186,13 +186,13 @@ FN_INTERNAL int upload_firmware(fnusb_dev* dev, char * filename) { break; case 4: //fwfile = "/usr/share/libfreenect/audios.bin"; - fwfile = malloc(2048); + fwfile = (char *)malloc(2048); needs_free = 1; sprintf(fwfile, "/usr/share/libfreenect%s", fw_filename); break; case 5: //fwfile = "./../Resources/audios.bin"; //default for OS X equivilant to: "./audios.bin"; - fwfile = malloc(2048); + fwfile = (char *)malloc(2048); needs_free = 1; sprintf(fwfile, "./../Resources%s", fw_filename); break; @@ -219,7 +219,7 @@ FN_INTERNAL int upload_firmware(fnusb_dev* dev, char * filename) { return -errno; } - unsigned char * fw_bytes = malloc(fw_num_bytes); + unsigned char * fw_bytes = (unsigned char *)malloc(fw_num_bytes); int numRead = fread(fw_bytes, 1, fw_num_bytes, fw); fw_num_bytes = numRead; // just in case @@ -229,7 +229,7 @@ FN_INTERNAL int upload_firmware(fnusb_dev* dev, char * filename) { fw = NULL; return retVal; - } +} FN_INTERNAL int upload_firmware_from_memory(fnusb_dev* dev, unsigned char * fw_from_mem, unsigned int fw_size_in_btyes) { freenect_context* ctx = dev->parent->parent; @@ -269,7 +269,7 @@ FN_INTERNAL int upload_firmware_from_memory(fnusb_dev* dev, unsigned char * fw_f FN_INFO("\tentry point 0x%08x\n", fwheader.entry_addr); - uint32_t addr = fwheader.base_addr; + uint32_t addr = fwheader.base_addr; unsigned char page[0x4000]; int readIndex = 0; int total_bytes_sent = 0; @@ -282,8 +282,8 @@ FN_INTERNAL int upload_firmware_from_memory(fnusb_dev* dev, unsigned char * fw_f read = bytesLeft; } if (read <= 0) { - break; - } + break; + } memcpy(page, &readPtr[readIndex], read); readIndex += read; diff --git a/src/tilt.c b/src/tilt.c index 198f97d2..c9cb5c5f 100644 --- a/src/tilt.c +++ b/src/tilt.c @@ -260,15 +260,15 @@ int freenect_set_led_alt(freenect_device *dev, freenect_led_options state) //The LED states are different between K4W/1473 and older 1414 if( state == LED_GREEN ){ - state = LED_ALT_SOLID_GREEN; + state = (freenect_led_options)LED_ALT_SOLID_GREEN; }else if( state == LED_RED ){ - state = LED_ALT_SOLID_RED; + state = (freenect_led_options)LED_ALT_SOLID_RED; }else if( state == LED_YELLOW ){ - state = LED_ALT_SOLID_GREEN; + state = (freenect_led_options)LED_ALT_SOLID_GREEN; }else if( state == LED_OFF ){ - state = LED_ALT_OFF; + state = (freenect_led_options)LED_ALT_OFF; }else if( state == LED_BLINK_GREEN ){ - state = LED_ALT_BLINK_GREEN; + state = (freenect_led_options)LED_ALT_BLINK_GREEN; }else{ state = LED_GREEN; } diff --git a/src/usb_libusb10.c b/src/usb_libusb10.c index 801ee121..94edcfc1 100644 --- a/src/usb_libusb10.c +++ b/src/usb_libusb10.c @@ -34,6 +34,11 @@ #include "keep_alive.h" + +#ifdef _MSC_VER + # define sleep(x) Sleep((x)*1000) +#endif + FN_INTERNAL int fnusb_num_devices(fnusb_ctx *ctx) { libusb_device **devs; @@ -213,6 +218,9 @@ FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index) break; } if(desc.idProduct == PID_K4W_CAMERA || desc.bcdDevice != fn_le32(267)){ + + freenect_device_flags requested_devices = ctx->enabled_subdevices; + /* Not the old kinect so we only set up the camera*/ ctx->enabled_subdevices = FREENECT_DEVICE_CAMERA; ctx->zero_plane_res = 334; @@ -228,8 +236,9 @@ FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index) #ifdef BUILD_AUDIO //for newer devices we need to enable the audio device for motor control - if( (ctx->enabled_subdevices & FREENECT_DEVICE_AUDIO) == 0 ){ - ctx->enabled_subdevices |= FREENECT_DEVICE_AUDIO; + //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); } #endif From aca4b8f1e4b2acd720f970b92767b011665c2e40 Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Wed, 5 Feb 2014 19:24:55 -0500 Subject: [PATCH 34/84] Post-merge cleanup Signed-off-by: Benn Snyder --- src/CMakeLists.txt | 5 ++--- src/keep_alive.c | 2 +- src/usb_libusb10.c | 24 +++++++++--------------- 3 files changed, 12 insertions(+), 19 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e248ec45..b365076d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -7,11 +7,10 @@ include_directories (${CMAKE_CURRENT_SOURCE_DIR}) set(CMAKE_C_FLAGS "-Wall") include_directories(${LIBUSB_1_INCLUDE_DIRS}) +LIST(APPEND SRC core.c tilt.c cameras.c flags.c usb_libusb10.c registration.c keep_alive.c) IF(WIN32) - LIST(APPEND SRC core.c tilt.c cameras.c flags.c usb_libusb10.c registration.c ../platform/windows/libusb10emu/libusb-1.0/libusbemu.cpp ../platform/windows/libusb10emu/libusb-1.0/failguard.cpp) + LIST(APPEND SRC ../platform/windows/libusb10emu/libusb-1.0/libusbemu.cpp ../platform/windows/libusb10emu/libusb-1.0/failguard.cpp) set_source_files_properties(${SRC} PROPERTIES LANGUAGE CXX) -ELSE(WIN32) - LIST(APPEND SRC core.c tilt.c cameras.c flags.c usb_libusb10.c registration.c) ENDIF(WIN32) IF(BUILD_AUDIO) diff --git a/src/keep_alive.c b/src/keep_alive.c index 5dcce0ff..ca85f8f0 100644 --- a/src/keep_alive.c +++ b/src/keep_alive.c @@ -205,4 +205,4 @@ void freenect_extra_keep_alive(int pid){ libusb_close(dev); libusb_exit(ctx); -} \ No newline at end of file +} diff --git a/src/usb_libusb10.c b/src/usb_libusb10.c index 2e639f0f..1cbfb001 100644 --- a/src/usb_libusb10.c +++ b/src/usb_libusb10.c @@ -31,14 +31,13 @@ #include #include "freenect_internal.h" #include "loader.h" - #include "keep_alive.h" - #ifdef _MSC_VER # define sleep(x) Sleep((x)*1000) #endif + FN_INTERNAL int fnusb_num_devices(fnusb_ctx *ctx) { libusb_device **devs; @@ -163,12 +162,10 @@ FN_INTERNAL int fnusb_process_events_timeout(fnusb_ctx *ctx, struct timeval* tim return libusb_handle_events_timeout(ctx->ctx, timeout); } -//there are a bunch of different PIDs to check for - this function makes it easier -FN_INTERNAL int fn_is_pid_k4w_audio(int pid){ - if( pid == PID_K4W_AUDIO || pid == PID_K4W_AUDIO_ALT_1 | pid == PID_K4W_AUDIO_ALT_2 ){ - return 0; - } - return -1; +// Returns 1 if `pid` identifies K4W audio, 0 otherwise +FN_INTERNAL int fnusb_is_pid_k4w_audio(int pid) +{ + return (pid == PID_K4W_AUDIO || pid == PID_K4W_AUDIO_ALT_1 || pid == PID_K4W_AUDIO_ALT_2); } FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index) @@ -217,11 +214,8 @@ FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index) 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; - - /* Not the old kinect so we only set up the camera*/ + if (desc.idProduct == PID_K4W_CAMERA || desc.bcdDevice != fn_le32(267)) { + // Not the old kinect so we only set up the camera ctx->enabled_subdevices = FREENECT_DEVICE_CAMERA; ctx->zero_plane_res = 334; dev->device_does_motor_control_with_audio = 1; @@ -318,7 +312,7 @@ FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index) #ifdef BUILD_AUDIO // TODO: check that the firmware has already been loaded; if not, upload firmware. // Search for the audio - if ((ctx->enabled_subdevices & FREENECT_DEVICE_AUDIO) && !dev->usb_audio.dev && (desc.idProduct == PID_NUI_AUDIO || fn_is_pid_k4w_audio(desc.idProduct) != -1 )) { + if ((ctx->enabled_subdevices & FREENECT_DEVICE_AUDIO) && !dev->usb_audio.dev && (desc.idProduct == PID_NUI_AUDIO || fnusb_is_pid_k4w_audio(desc.idProduct))) { // If the index given by the user matches our audio index if (nr_audio == index) { @@ -395,7 +389,7 @@ FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index) if (r < 0) 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 || fn_is_pid_k4w_audio(desc.idProduct) != -1) ){ + if (new_dev_desc.idVendor == VID_MICROSOFT && (new_dev_desc.idProduct == PID_NUI_AUDIO || fnusb_is_pid_k4w_audio(desc.idProduct))) { FN_SPEW("Matched VID/PID!\n"); libusb_device_handle* new_dev_handle; // Open device From 9abd65165ee3d66cd6533707753261535ebcbf1f Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Sat, 8 Feb 2014 17:09:08 -0500 Subject: [PATCH 35/84] Replaced missing variable - fixes #366 Signed-off-by: Benn Snyder --- src/usb_libusb10.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/usb_libusb10.c b/src/usb_libusb10.c index 1cbfb001..9fa56087 100644 --- a/src/usb_libusb10.c +++ b/src/usb_libusb10.c @@ -215,6 +215,8 @@ FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index) break; } if (desc.idProduct == PID_K4W_CAMERA || desc.bcdDevice != fn_le32(267)) { + freenect_device_flags requested_devices = ctx->enabled_subdevices; + // Not the old kinect so we only set up the camera ctx->enabled_subdevices = FREENECT_DEVICE_CAMERA; ctx->zero_plane_res = 334; @@ -231,7 +233,8 @@ FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index) #ifdef BUILD_AUDIO //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 ){ + if ((requested_devices & FREENECT_DEVICE_MOTOR) && (requested_devices & FREENECT_DEVICE_AUDIO) == 0) + { ctx->enabled_subdevices = (freenect_device_flags)(ctx->enabled_subdevices | FREENECT_DEVICE_AUDIO); } #endif From a05075a1bda356a79c3eeddcc4eab1ac20008425 Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Sat, 8 Feb 2014 20:48:45 -0500 Subject: [PATCH 36/84] Read int from fgetc for EOF comparison - fixes #365 Signed-off-by: Benn Snyder --- fakenect/fakenect.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/fakenect/fakenect.c b/fakenect/fakenect.c index 3f704fa9..174eab69 100644 --- a/fakenect/fakenect.c +++ b/fakenect/fakenect.c @@ -98,10 +98,8 @@ static char *one_line(FILE *fp) { int pos = 0; char *out = NULL; - char c; - while ((c = fgetc(fp))) { - if (c == '\n' || c == EOF) - break; + for (int c = fgetc(fp); !(c == '\n' || c == EOF); c = fgetc(fp)) + { out = realloc(out, pos + 1); out[pos++] = c; } From 296c5c4537c6652e30fcd022580252d9c35e6fc3 Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Sun, 9 Feb 2014 01:19:25 -0500 Subject: [PATCH 37/84] Shiny new README.md Beautify ebuild and add audio USE flag Signed-off-by: Benn Snyder --- OpenNI2-FreenectDriver/README.md | 22 ++- README.asciidoc | 147 --------------- README.md | 170 ++++++++++++++++++ .../portage/dev-libs/libfreenect/Manifest | 2 +- .../libfreenect/libfreenect-9999.ebuild | 96 +++++----- 5 files changed, 235 insertions(+), 202 deletions(-) delete mode 100644 README.asciidoc create mode 100644 README.md diff --git a/OpenNI2-FreenectDriver/README.md b/OpenNI2-FreenectDriver/README.md index e8a69c4a..3582c925 100644 --- a/OpenNI2-FreenectDriver/README.md +++ b/OpenNI2-FreenectDriver/README.md @@ -16,7 +16,7 @@ Install cmake .. -DBUILD_OPENNI2_DRIVER=ON make -3. Copy the driver to your OpenNI2 driver repository. +3. Copy the driver to your OpenNI2 driver repository. You must change `Repository` to match your project layout. Repository="/example/path/to/Samples/Bin/OpenNI2/Drivers/" cp -L lib/OpenNI2-FreenectDriver/libFreenectDriver.{so,dylib} ${Repository} @@ -28,15 +28,25 @@ __________________________________________________ Structure --------- -This driver is modeled on TestDevice.cpp and Drivers/Kinect/. In the FreenectDriver namespace, it ties together the C++ interfaces of OpenNI2 and libfreenect using multiple inheritance. +This driver is modeled on TestDevice.cpp and Drivers/Kinect/. +In the FreenectDriver namespace, it ties together the C++ interfaces of OpenNI2 and libfreenect using multiple inheritance. -Driver inherits publically from oni::driver::DriverBase and privately from Freenect::Freenect. A custom libfreenect.hpp allows protected access to the Freenect context, so that FreenectDriver can call the Freenect's C API. As a DriverBase, FreenectDriver manages devices and sets up device state callbacks. +Driver inherits publically from oni::driver::DriverBase and privately from Freenect::Freenect. +libfreenect.hpp allows protected access to the Freenect context, so that FreenectDriver can call the Freenect's C API. +As a DriverBase, FreenectDriver manages devices and sets up device state callbacks. -Device inherits publically from oni::driver::DeviceBase and Freenect::FreenectDevice. Because of this, it can be built by Freenect::Freenect::createDevice() and it can define Device's depth and video callbacks. Those callbacks trigger acquireFrame() in FreenectStream. +Device inherits publically from oni::driver::DeviceBase and Freenect::FreenectDevice. +Because of this, it can be built by Freenect::Freenect::createDevice() and it can define Device's depth and video callbacks. +Those callbacks trigger acquireFrame() in FreenectStream. -VideoStream is a virtual base class inheriting from oni::driver::StreamBase. It does generic frame setup in buildFrame() and then calls pure virtual populateFrame() to let derived classes finish the frame. It also provides the base skeleton for setting and getting properties, which cascades down the inheritance tree. +VideoStream is a virtual base class inheriting from oni::driver::StreamBase. +It does generic frame setup in buildFrame() and then calls pure virtual populateFrame() to let derived classes finish the frame. +It also provides the base skeleton for setting and getting properties, which cascades down the inheritance tree. -DepthStream and ColorStream are nearly identical in definition and implementation, both inheriting from VideoStream. They differ mostly in the formats they use to process data and the video modes they support. These two classes offer a system to store and report supported video modes. To implement a new mode, simply add it to getSupportedVideoModes() and modify populateFrame() if necessary. +DepthStream and ColorStream are nearly identical in definition and implementation, both inheriting from VideoStream. +They differ mostly in the formats they use to process data and the video modes they support. +These two classes offer a system to store and report supported video modes. +To implement a new mode, simply add it to getSupportedVideoModes() and modify populateFrame() as necessary. __________________________________________________ diff --git a/README.asciidoc b/README.asciidoc deleted file mode 100644 index 18e0b34b..00000000 --- a/README.asciidoc +++ /dev/null @@ -1,147 +0,0 @@ -== libfreenect - -Ongoing Development and Maintenance by the OpenKinect Community - -http://www.openkinect.org - -- Original Code and Engineering: Hector Martin (marcan) -- Community Lead: Josh Blake (JoshB) -- Integration: Kyle Machulis (qDot) - -=== Description - -libfreenect is the core library for accessing the Microsoft Kinect USB -camera. Currently, the library supports access to: - -- RGB and Depth Images -- Motors -- Accelerometer -- LED - -Audio is currently being worked on. - -=== Information Resources - -Information about the OpenKinect project can be found at - -http://www.openkinect.org - -For questions, support, and discussion, check out the google groups -mailing list at - -http://groups.google.com/group/openkinect - -Or the IRC channel at - -#openkinect on Freenode - -We are also on twitter at - -http://twitter.com/openkinect - -=== Requirements - -For the driver, you'll need - -- libusb-1.0 >= 1.0.9 (*nix and OS X) -- libusb-win32 (Windows) -- Cmake >= 2.6 (All platforms) - -For the glview sample, you'll need - -- OpenGL -- glut -- pthreads (Either platform provided or pthread-win32 for windows) - -For links to the software listed, see http://openkinect.org/wiki/Getting_Started#Dependencies - -See the platform specifics section for other information specific to -the platform you may be working on. - -=== Basic Compiling Instructions - -To use CMake: - -- Make a directory somewhere. Like, say, 'build' in your repo directory. -- Go into that directory -- Type cmake .. -- Watch the magic happen -- After this, just run make and you'll be fine. -- If you want to use an IDE or whatever, well, you'll figure it out. - -=== Platform Specifics - -==== OS X - -libusb is available through various package managers -including homebrew and Macports. -OpenGL and GLUT come as prebuilt frameworks. - -==== Linux - -Should "just work" if you have the following packages installed: - -- libusb-1.0-dev - -If you want to see the glview example: - -- freeglut3-dev (or whatever freeglut dev package your distro has) -- libxmu-dev -- libxi-dev - -udev rules are available in the platform/linux directory so that you -are not required to run as root. - -==== Windows - -Windows support is now available in libfreenect. The inf files in the -platform/windows directory can be used for installing the device, and -the library will need libusb-win32 to compile. - -==== Wrappers - -libfreenect has interface to several languages. Look in the wrappers/ -directory for them: - -- C (using a synchronous API) -- C++ -- C# -- python -- actionscript -- Java (JNA) - -=== Licensing - -The libfreenect project is covered under a dual Apache v2/GPL v2 -license. The licensing criteria are listed below, as well as at the -top of each source file in the repo. - ----------- - -This file is part of the OpenKinect Project. http://www.openkinect.org - -Copyright (c) 2010 individual OpenKinect contributors. See the CONTRIB -file for details. - -This code is licensed to you under the terms of the Apache License, -version 2.0, or, at your option, the terms of the GNU General Public -License, version 2.0. See the APACHE20 and GPL2 files for the text of -the licenses, or the following URLs: -http://www.apache.org/licenses/LICENSE-2.0 -http://www.gnu.org/licenses/gpl-2.0.txt - -If you redistribute this file in source form, modified or unmodified, -you may: - -- Leave this header intact and distribute it under the same terms, - accompanying it with the APACHE20 and GPL2 files, or -- Delete the Apache 2.0 clause and accompany it with the GPL2 file, or -- 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. - ----------- diff --git a/README.md b/README.md new file mode 100644 index 00000000..2e5c4706 --- /dev/null +++ b/README.md @@ -0,0 +1,170 @@ +libfreenect +=========== + +libfreenect is a userspace driver for the Microsoft Kinect. +It runs on \*nix, OSX, and Windows and supports + +- RGB and Depth Images +- Motors +- Accelerometer +- LED + +Audio is a work in progress. + + +# Build Guide + +To build libfreenect, you'll need + +- [libusb](http://libusb.info/) >= 1.0.13 +- [CMake](http://www.cmake.org/) >= 2.6 + +For the examples, you'll need + +- OpenGL (included with OSX) +- glut (included with OSX) +- [pthreads-win32](http://sourceforge.net/projects/pthreads4w/) (Windows) + +## Fetch & Build + + git clone https://github.com/OpenKinect/libfreenect + cd libfreenect + mkdir build + cd build + cmake .. + cmake --build . + +## OSX + +If you don't have a package manager, install [Homebrew](http://brew.sh/). +For a manual build, see [the wiki](http://openkinect.org/wiki/Getting_Started#Manual_Build_under_OSX). + +### Homebrew + + brew install libfreenect + # or get the very latest: + # brew install --HEAD libfreenect + +### MacPorts + + sudo port install git-core cmake libusb libtool + # GOTO: Fetch & Build + +## Linux + +For a manual build, see [the wiki](http://openkinect.org/wiki/Getting_Started#Manual_Build_on_Linux). + +### Ubuntu/Debian/Mint + +The version packaged in Ubuntu may be very old. +To install newer packaged builds, see [the wiki](http://openkinect.org/wiki/Getting_Started#Ubuntu.2FDebian). +Continue with this section for a manual build. + + sudo apt-get install git-core cmake pkg-config build-essential libusb-1.0-0-dev + sudo adduser $USER video + sudo adduser $USER plugdev # necessary? + + # only if you are building the examples: + sudo apt-get install libglut3-dev libxmu-dev libxi-dev + + # GOTO: Fetch & Build + +There is also a [debian branch](https://github.com/OpenKinect/libfreenect/tree/debian) for packaging purposes. + +### 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). + +### Arch Linux + +There is a [libfreenect-git](https://aur.archlinux.org/packages/libfreenect-git/) PKGBUILD in the AUR. + + +## Windows + +The inf files in [platform/windows/](https://github.com/OpenKinect/libfreenect/tree/master/platform/windows) may be used for installing the device. +Follow **Fetch & Build** or use Github and CMake GUI tools. +You may need to supply paths to CMake so it can find dependencies. +For example: + + cmake .. -DLIBUSB_1_INCLUDE_DIR="C:\path\to\libusb\include" -DLIBUSB_1_LIBRARY="C:\path\to\libusb\libusb.lib" + + +# Wrappers + +Interfaces to various languages are provided in [wrappers/](https://github.com/OpenKinect/libfreenect/tree/master/wrappers). +Wrappers are not guaranteed to be API stable or up to date. + +- C (using a synchronous API) +- C++ +- C# +- python +- ruby +- actionscript +- Java (JNA) + + +# Maintainers + +Ongoing Development and Maintenance by the OpenKinect Community + +http://www.openkinect.org + +- Original Code and Engineering: Hector Martin (marcan) +- Community Lead: Josh Blake (JoshB) +- Integration: Kyle Machulis (qDot) + + +# License + +The libfreenect project is covered under a dual Apache v2/GPL v2 +license. The licensing criteria are listed below, as well as at the +top of each source file in the repo. + +``` +This file is part of the OpenKinect Project. http://www.openkinect.org + +Copyright (c) 2010 individual OpenKinect contributors. See the CONTRIB +file for details. + +This code is licensed to you under the terms of the Apache License, +version 2.0, or, at your option, the terms of the GNU General Public +License, version 2.0. See the APACHE20 and GPL2 files for the text of +the licenses, or the following URLs: +http://www.apache.org/licenses/LICENSE-2.0 +http://www.gnu.org/licenses/gpl-2.0.txt + +If you redistribute this file in source form, modified or unmodified, +you may: + +- Leave this header intact and distribute it under the same terms, + accompanying it with the APACHE20 and GPL2 files, or +- Delete the Apache 2.0 clause and accompany it with the GPL2 file, or +- 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. +``` + + +# More Information + +Information about the OpenKinect project can be found at + +http://www.openkinect.org + +For questions, support, and discussion, check out the google groups +mailing list at + +http://groups.google.com/group/openkinect + +Or the IRC channel at + +\#openkinect on Freenode + +We are also on twitter at + +http://twitter.com/openkinect diff --git a/platform/linux/portage/dev-libs/libfreenect/Manifest b/platform/linux/portage/dev-libs/libfreenect/Manifest index 25f7a100..75992256 100644 --- a/platform/linux/portage/dev-libs/libfreenect/Manifest +++ b/platform/linux/portage/dev-libs/libfreenect/Manifest @@ -1 +1 @@ -EBUILD libfreenect-9999.ebuild 1926 SHA256 ce96381a0574be42ab0c50e06c647ef0db7a9fe8ed8a9ebf55c9013fb20f8e5f SHA512 ef692429fe0a746a42e3fb4ef39ead0da258ddf418cbb839d9bb4617aa6607490cc2578505a88d1cc5bc01ac90fabcb9d9a27a000f7ab6533a1fb2f75610c2a6 WHIRLPOOL 50bc5c4de88c28df3d94cc2b9bc9f90120ed029f2af43c585c54e0c9ce7b9f96893c74fe6a06f7145a081bbb4ad7893fec940218aa1ddd7dd34d895bd41ef5f5 +EBUILD libfreenect-9999.ebuild 2246 SHA256 9c108418122975f5c9f6587e9c7e35625ce4cc47932b2c0b03b22ccb802d39da SHA512 05310b350b6598fd826c6ca6e12edc1f809157924a6fac93cb01ee8652b1d544144a22f32fe6ecf8ebd476e73c2a3c334aed02342d2e060ab6cdf88ef4ec965f WHIRLPOOL e9676dbe32df58e78c66343a0f665217b5b89b08f2caf777090536757024e57478694abe04a6cb290a6aef9e5ed46964b83d64ab55c7187f77fbf54150b83fed diff --git a/platform/linux/portage/dev-libs/libfreenect/libfreenect-9999.ebuild b/platform/linux/portage/dev-libs/libfreenect/libfreenect-9999.ebuild index 9f014b65..1520e72e 100644 --- a/platform/linux/portage/dev-libs/libfreenect/libfreenect-9999.ebuild +++ b/platform/linux/portage/dev-libs/libfreenect/libfreenect-9999.ebuild @@ -1,4 +1,4 @@ -# Copyright 1999-2013 Gentoo Foundation +# Copyright 1999-2014 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ @@ -14,64 +14,64 @@ 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" +IUSE="audio bindist +c_sync +cpp doc examples fakenect opencv openni2 python" -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 )" +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 )" +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 + local mycmakeargs=( + $(cmake-utils_use_build audio AUDIO) + $(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 - # Rename record example so it does not collide with xawtv - if use examples; then - mv "${D}"/usr/bin/record "${D}"/usr/bin/frecord || die - fi - - # udev rules - insinto /lib/udev/rules.d/ - doins "${S}"/platform/linux/udev/51-kinect.rules + cmake-utils_src_install + # Rename record example so it does not collide with xawtv + if use examples; then + mv "${D}"/usr/bin/record "${D}"/usr/bin/frecord || die + fi + + # udev rules + insinto /lib/udev/rules.d/ + doins "${S}"/platform/linux/udev/51-kinect.rules - # documentation - dodoc HACKING README.asciidoc - if use doc; then - cd doc - doxygen || ewarn "doxygen failed" - dodoc -r html || ewarn "dodoc failed" - cd - - fi + # documentation + dodoc HACKING README.asciidoc + 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 "You have enabled audio via the bindist USE flag. 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." + if use bindist; then + ewarn "You have enabled the bindist USE flag. 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." } From 306ee84c9b2f96ec63c6c61272f487add30841a3 Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Tue, 11 Feb 2014 20:15:41 -0500 Subject: [PATCH 38/84] Remove C99 syntax - fixes #369 Signed-off-by: Benn Snyder --- fakenect/fakenect.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fakenect/fakenect.c b/fakenect/fakenect.c index 174eab69..21da75d3 100644 --- a/fakenect/fakenect.c +++ b/fakenect/fakenect.c @@ -96,9 +96,10 @@ static double get_time() static char *one_line(FILE *fp) { + int c; int pos = 0; char *out = NULL; - for (int c = fgetc(fp); !(c == '\n' || c == EOF); c = fgetc(fp)) + for (c = fgetc(fp); !(c == '\n' || c == EOF); c = fgetc(fp)) { out = realloc(out, pos + 1); out[pos++] = c; From ee8db7e252108156a285d245b9c726f5b1c6d9c9 Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Tue, 11 Feb 2014 23:14:53 -0500 Subject: [PATCH 39/84] Invoke fwfetcher.py with python2 - fixes #370 Refine README.md Signed-off-by: Benn Snyder --- CMakeLists.txt | 3 +-- OpenNI2-FreenectDriver/README.md | 7 ++++-- README.md | 38 +++++++++++++++----------------- src/fwfetcher.py | 2 +- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 064574b1..501bcb6e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,9 +30,8 @@ # CMake directives ###################################################################################### -#Require 2.6 or higher. - cmake_minimum_required(VERSION 2.6) +set(PYTHON_EXECUTABLE "python2") ###################################################################################### # Project declaration and options diff --git a/OpenNI2-FreenectDriver/README.md b/OpenNI2-FreenectDriver/README.md index 3582c925..55fd3791 100644 --- a/OpenNI2-FreenectDriver/README.md +++ b/OpenNI2-FreenectDriver/README.md @@ -4,7 +4,7 @@ OpenNI2-FreenectDriver OpenNI2-FreenectDriver is a bridge to libfreenect implemented as an OpenNI2 driver. It allows OpenNI2 to use Kinect hardware on Linux and OSX. It was originally a [separate project](https://github.com/piedar/OpenNI2-FreenectDriver) but is now distributed with libfreenect. -OpenNI2-FreenectDriver is distributed under the Apache 2 license. +OpenNI2-FreenectDriver is distributed under the [Apache 2](https://github.com/OpenKinect/libfreenect/blob/master/APACHE20) license. Install ------- @@ -16,10 +16,13 @@ Install cmake .. -DBUILD_OPENNI2_DRIVER=ON make -3. Copy the driver to your OpenNI2 driver repository. You must change `Repository` to match your project layout. +3. Copy the driver to your OpenNI2 driver repository. You must first change `Repository` to match your project layout. Repository="/example/path/to/Samples/Bin/OpenNI2/Drivers/" cp -L lib/OpenNI2-FreenectDriver/libFreenectDriver.{so,dylib} ${Repository} + + # you could instead make a symlink to avoid copying after every build + # ln -s lib/OpenNI2-FreenectDriver/libFreenectDriver.{so,dylib} ${Repository} OpenNI2-FreenectDriver is built with a static libfreenect, so you do not need to include libfreenect when deploying. However, you will need to make sure target systems have libusb and all other dependencies listed in `ldd libFreenectDriver.so`. diff --git a/README.md b/README.md index 2e5c4706..a3a2ec57 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ libfreenect =========== libfreenect is a userspace driver for the Microsoft Kinect. -It runs on \*nix, OSX, and Windows and supports +It runs on Linux, OSX, and Windows and supports - RGB and Depth Images - Motors @@ -12,7 +12,7 @@ It runs on \*nix, OSX, and Windows and supports Audio is a work in progress. -# Build Guide +# Build Instructions To build libfreenect, you'll need @@ -25,14 +25,19 @@ For the examples, you'll need - glut (included with OSX) - [pthreads-win32](http://sourceforge.net/projects/pthreads4w/) (Windows) -## Fetch & Build + +## Fetch & Build git clone https://github.com/OpenKinect/libfreenect cd libfreenect mkdir build cd build cmake .. - cmake --build . + make + + # if you don't have `make` or don't want color output + # cmake --build . + ## OSX @@ -48,7 +53,9 @@ For a manual build, see [the wiki](http://openkinect.org/wiki/Getting_Started#Ma ### MacPorts sudo port install git-core cmake libusb libtool - # GOTO: Fetch & Build + +Continue with [Fetch & Build](#fetch-build). + ## Linux @@ -67,7 +74,7 @@ Continue with this section for a manual build. # only if you are building the examples: sudo apt-get install libglut3-dev libxmu-dev libxi-dev - # GOTO: Fetch & Build +Continue with [Fetch & Build](#fetch-build). There is also a [debian branch](https://github.com/OpenKinect/libfreenect/tree/debian) for packaging purposes. @@ -83,7 +90,7 @@ There is a [libfreenect-git](https://aur.archlinux.org/packages/libfreenect-git/ ## Windows The inf files in [platform/windows/](https://github.com/OpenKinect/libfreenect/tree/master/platform/windows) may be used for installing the device. -Follow **Fetch & Build** or use Github and CMake GUI tools. +Follow [Fetch & Build](#fetch-build) or use Github and CMake GUI tools. You may need to supply paths to CMake so it can find dependencies. For example: @@ -152,19 +159,10 @@ of either License. # More Information -Information about the OpenKinect project can be found at - -http://www.openkinect.org - -For questions, support, and discussion, check out the google groups -mailing list at - -http://groups.google.com/group/openkinect - -Or the IRC channel at +Information about the OpenKinect project can be found at http://www.openkinect.org -\#openkinect on Freenode +For questions, support, and discussion, check out the google groups mailing list at http://groups.google.com/group/openkinect -We are also on twitter at +Or the IRC channel at \#openkinect on [Freenode](http://freenode.net/) -http://twitter.com/openkinect +We are also on twitter at http://twitter.com/openkinect diff --git a/src/fwfetcher.py b/src/fwfetcher.py index a83e5122..51dde4a5 100644 --- a/src/fwfetcher.py +++ b/src/fwfetcher.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 from urllib2 import Request, urlopen, URLError import hashlib From 8d8558fcae9bda58ce59dc8ea22be3f040ea9342 Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Wed, 12 Feb 2014 21:57:30 -0500 Subject: [PATCH 40/84] OpenNI2-FreenectDriver: Convert all printf and cout statements to log messages Signed-off-by: Benn Snyder --- OpenNI2-FreenectDriver/src/ColorStream.cpp | 31 ++++-- OpenNI2-FreenectDriver/src/ColorStream.hpp | 27 +++-- OpenNI2-FreenectDriver/src/DepthStream.cpp | 41 +++++--- OpenNI2-FreenectDriver/src/DepthStream.hpp | 81 +++++++++------ OpenNI2-FreenectDriver/src/DeviceDriver.cpp | 108 ++++++++++++-------- OpenNI2-FreenectDriver/src/VideoStream.hpp | 76 +++++++++----- 6 files changed, 232 insertions(+), 132 deletions(-) diff --git a/OpenNI2-FreenectDriver/src/ColorStream.cpp b/OpenNI2-FreenectDriver/src/ColorStream.cpp index a0b4c1bb..888996cb 100644 --- a/OpenNI2-FreenectDriver/src/ColorStream.cpp +++ b/OpenNI2-FreenectDriver/src/ColorStream.cpp @@ -1,15 +1,18 @@ +#include #include "ColorStream.hpp" using namespace FreenectDriver; -ColorStream::ColorStream(Freenect::FreenectDevice* pDevice) : VideoStream(pDevice) { +ColorStream::ColorStream(Freenect::FreenectDevice* pDevice) : VideoStream(pDevice) +{ video_mode = makeOniVideoMode(ONI_PIXEL_FORMAT_RGB888, 640, 480, 30); setVideoMode(video_mode); } // Add video modes here as you implement them -ColorStream::FreenectVideoModeMap ColorStream::getSupportedVideoModes() { +ColorStream::FreenectVideoModeMap ColorStream::getSupportedVideoModes() +{ FreenectVideoModeMap modes; // pixelFormat, resolutionX, resolutionY, fps freenect_video_format, freenect_resolution modes[makeOniVideoMode(ONI_PIXEL_FORMAT_RGB888, 640, 480, 30)] = std::pair(FREENECT_VIDEO_RGB, FREENECT_RESOLUTION_MEDIUM); @@ -24,7 +27,8 @@ ColorStream::FreenectVideoModeMap ColorStream::getSupportedVideoModes() { */ } -OniStatus ColorStream::setVideoMode(OniVideoMode requested_mode) { +OniStatus ColorStream::setVideoMode(OniVideoMode requested_mode) +{ FreenectVideoModeMap supported_video_modes = getSupportedVideoModes(); FreenectVideoModeMap::const_iterator matched_mode_iter = supported_video_modes.find(requested_mode); if (matched_mode_iter == supported_video_modes.end()) @@ -34,31 +38,36 @@ OniStatus ColorStream::setVideoMode(OniVideoMode requested_mode) { freenect_resolution resolution = matched_mode_iter->second.second; try { device->setVideoFormat(format, resolution); } - catch (std::runtime_error e) { - printf("format-resolution combination not supported by libfreenect: %d-%d\n", format, resolution); + catch (std::runtime_error e) + { + LogError("Format " + format + std::string(" and resolution " + resolution) + " combination not supported by libfreenect"); return ONI_STATUS_NOT_SUPPORTED; } video_mode = requested_mode; return ONI_STATUS_OK; } -void ColorStream::populateFrame(void* data, OniFrame* frame) const { +void ColorStream::populateFrame(void* data, OniFrame* frame) const +{ frame->sensorType = sensor_type; frame->stride = video_mode.resolutionX*3; frame->cropOriginX = frame->cropOriginY = 0; frame->croppingEnabled = FALSE; // copy stream buffer from freenect - switch (video_mode.pixelFormat) { + switch (video_mode.pixelFormat) + { default: - printf("pixelFormat %d not supported by populateFrame\n", video_mode.pixelFormat); + LogError(std::string("Pixel format " + video_mode.pixelFormat) + " not supported by populateFrame()"); return; case ONI_PIXEL_FORMAT_RGB888: unsigned char* data_ptr = static_cast(data); unsigned char* frame_data = static_cast(frame->data); - if (mirroring) { - for (int i = 0; i < frame->dataSize; i += 3) { + if (mirroring) + { + for (int i = 0; i < frame->dataSize; i += 3) + { // find corresponding mirrored pixel unsigned int pixel = i / 3; unsigned int row = pixel / video_mode.resolutionX; @@ -71,7 +80,9 @@ void ColorStream::populateFrame(void* data, OniFrame* frame) const { } } else + { std::copy(data_ptr, data_ptr+frame->dataSize, frame_data); + } return; } diff --git a/OpenNI2-FreenectDriver/src/ColorStream.hpp b/OpenNI2-FreenectDriver/src/ColorStream.hpp index 7039c063..1c657197 100644 --- a/OpenNI2-FreenectDriver/src/ColorStream.hpp +++ b/OpenNI2-FreenectDriver/src/ColorStream.hpp @@ -7,8 +7,10 @@ #include "VideoStream.hpp" -namespace FreenectDriver { - class ColorStream : public VideoStream { +namespace FreenectDriver +{ + class ColorStream : public VideoStream + { public: // from NUI library & converted to radians static const float DIAGONAL_FOV = 73.9 * (M_PI / 180); @@ -30,7 +32,8 @@ namespace FreenectDriver { ColorStream(Freenect::FreenectDevice* pDevice); //~ColorStream() { } - static OniSensorInfo getSensorInfo() { + static OniSensorInfo getSensorInfo() + { FreenectVideoModeMap supported_modes = getSupportedVideoModes(); OniVideoMode* modes = new OniVideoMode[supported_modes.size()]; std::transform(supported_modes.begin(), supported_modes.end(), modes, RetrieveKey()); @@ -39,8 +42,10 @@ namespace FreenectDriver { } // from StreamBase - OniBool isPropertySupported(int propertyId) { - switch(propertyId) { + OniBool isPropertySupported(int propertyId) + { + switch(propertyId) + { default: return VideoStream::isPropertySupported(propertyId); @@ -63,7 +68,7 @@ namespace FreenectDriver { { if (*pDataSize != sizeof(float)) { - printf("Unexpected size: %d != %lu\n", *pDataSize, sizeof(float)); + LogError("Unexpected size for ONI_STREAM_PROPERTY_HORIZONTAL_FOV"); return ONI_STATUS_ERROR; } *(static_cast(data)) = HORIZONTAL_FOV; @@ -73,7 +78,7 @@ namespace FreenectDriver { { if (*pDataSize != sizeof(float)) { - printf("Unexpected size: %d != %lu\n", *pDataSize, sizeof(float)); + LogError("Unexpected size for ONI_STREAM_PROPERTY_VERTICAL_FOV"); return ONI_STATUS_ERROR; } *(static_cast(data)) = VERTICAL_FOV; @@ -85,7 +90,7 @@ namespace FreenectDriver { { if (*pDataSize != sizeof(OniBool)) { - printf("Unexpected size: %d != %lu\n", *pDataSize, sizeof(OniBool)); + LogError("Unexpected size for ONI_STREAM_PROPERTY_AUTO_WHITE_BALANCE"); return ONI_STATUS_ERROR; } *(static_cast(data)) = auto_white_balance; @@ -95,7 +100,7 @@ namespace FreenectDriver { { if (*pDataSize != sizeof(OniBool)) { - printf("Unexpected size: %d != %lu\n", *pDataSize, sizeof(OniBool)); + LogError("Unexpected size for ONI_STREAM_PROPERTY_AUTO_EXPOSURE"); return ONI_STATUS_ERROR; } *(static_cast(data)) = auto_exposure; @@ -116,7 +121,7 @@ namespace FreenectDriver { { if (dataSize != sizeof(OniBool)) { - printf("Unexpected size: %d != %lu\n", dataSize, sizeof(OniBool)); + LogError("Unexpected size for ONI_STREAM_PROPERTY_AUTO_WHITE_BALANCE"); return ONI_STATUS_ERROR; } auto_white_balance = *(static_cast(data)); @@ -127,7 +132,7 @@ namespace FreenectDriver { { if (dataSize != sizeof(OniBool)) { - printf("Unexpected size: %d != %lu\n", dataSize, sizeof(OniBool)); + LogError("Unexpected size for ONI_STREAM_PROPERTY_AUTO_EXPOSURE"); return ONI_STATUS_ERROR; } auto_exposure = *(static_cast(data)); diff --git a/OpenNI2-FreenectDriver/src/DepthStream.cpp b/OpenNI2-FreenectDriver/src/DepthStream.cpp index dbab61da..ba10af2b 100644 --- a/OpenNI2-FreenectDriver/src/DepthStream.cpp +++ b/OpenNI2-FreenectDriver/src/DepthStream.cpp @@ -1,9 +1,11 @@ +#include #include "DepthStream.hpp" using namespace FreenectDriver; -DepthStream::DepthStream(Freenect::FreenectDevice* pDevice) : VideoStream(pDevice) { +DepthStream::DepthStream(Freenect::FreenectDevice* pDevice) : VideoStream(pDevice) +{ video_mode = makeOniVideoMode(ONI_PIXEL_FORMAT_DEPTH_1_MM, 640, 480, 30); image_registration_mode = ONI_IMAGE_REGISTRATION_OFF; setVideoMode(video_mode); @@ -12,7 +14,8 @@ DepthStream::DepthStream(Freenect::FreenectDevice* pDevice) : VideoStream(pDevic // Add video modes here as you implement them // Note: if image_registration_mode == ONI_IMAGE_REGISTRATION_DEPTH_TO_COLOR, // setVideoFormat() will try FREENECT_DEPTH_REGISTERED first then fall back on what is set here. -DepthStream::FreenectDepthModeMap DepthStream::getSupportedVideoModes() { +DepthStream::FreenectDepthModeMap DepthStream::getSupportedVideoModes() +{ FreenectDepthModeMap modes; // pixelFormat, resolutionX, resolutionY, fps modes[makeOniVideoMode(ONI_PIXEL_FORMAT_DEPTH_1_MM, 640, 480, 30)] = std::pair(FREENECT_DEPTH_MM, FREENECT_RESOLUTION_MEDIUM); @@ -21,7 +24,8 @@ DepthStream::FreenectDepthModeMap DepthStream::getSupportedVideoModes() { return modes; } -OniStatus DepthStream::setVideoMode(OniVideoMode requested_mode) { +OniStatus DepthStream::setVideoMode(OniVideoMode requested_mode) +{ FreenectDepthModeMap supported_video_modes = getSupportedVideoModes(); FreenectDepthModeMap::const_iterator matched_mode_iter = supported_video_modes.find(requested_mode); if (matched_mode_iter == supported_video_modes.end()) @@ -33,10 +37,12 @@ OniStatus DepthStream::setVideoMode(OniVideoMode requested_mode) { format = FREENECT_DEPTH_REGISTERED; try { device->setDepthFormat(format, resolution); } - catch (std::runtime_error e) { - printf("format-resolution combination not supported by libfreenect: %d-%d\n", format, resolution); - if (image_registration_mode == ONI_IMAGE_REGISTRATION_DEPTH_TO_COLOR) { - printf("could not use image registration format; disabling registration and falling back to format defined in getSupportedVideoModes()\n"); + catch (std::runtime_error e) + { + LogError("Format " + format + std::string(" and resolution " + resolution) + " combination not supported by libfreenect"); + if (image_registration_mode == ONI_IMAGE_REGISTRATION_DEPTH_TO_COLOR) + { + LogError("Could not enable image registration format; falling back to format defined in getSupportedVideoModes()"); image_registration_mode = ONI_IMAGE_REGISTRATION_OFF; return setVideoMode(requested_mode); } @@ -46,7 +52,8 @@ OniStatus DepthStream::setVideoMode(OniVideoMode requested_mode) { return ONI_STATUS_OK; } -void DepthStream::populateFrame(void* data, OniFrame* frame) const { +void DepthStream::populateFrame(void* data, OniFrame* frame) const +{ frame->sensorType = sensor_type; frame->stride = video_mode.resolutionX * sizeof(uint16_t); @@ -69,11 +76,14 @@ void DepthStream::populateFrame(void* data, OniFrame* frame) const { unsigned short* target = static_cast(frame->data); const unsigned int skipWidth = video_mode.resolutionX - frame->width; - if (mirroring) { + if (mirroring) + { target += frame->width; - for (int y = 0; y < frame->height; y++) { - for (int x = 0; x < frame->width; x++) { + for (int y = 0; y < frame->height; y++) + { + for (int x = 0; x < frame->width; x++) + { unsigned short value = *(source++); *(target--) = value < DepthStream::MAX_VALUE ? value : 0; } @@ -82,9 +92,12 @@ void DepthStream::populateFrame(void* data, OniFrame* frame) const { target += 2 * frame->width; } } - else { - for (int y = 0; y < frame->height; y++) { - for (int x = 0; x < frame->width; x++) { + else + { + for (int y = 0; y < frame->height; y++) + { + for (int x = 0; x < frame->width; x++) + { unsigned short value = *(source++); *(target++) = value < DepthStream::MAX_VALUE ? value : 0; } diff --git a/OpenNI2-FreenectDriver/src/DepthStream.hpp b/OpenNI2-FreenectDriver/src/DepthStream.hpp index 49973f41..be60a195 100644 --- a/OpenNI2-FreenectDriver/src/DepthStream.hpp +++ b/OpenNI2-FreenectDriver/src/DepthStream.hpp @@ -2,7 +2,7 @@ #include // for transform() #include // for M_PI -#include // fror memcpy +#include // for memcpy #include "libfreenect.hpp" #include "Driver/OniDriverAPI.h" #include "PS1080.h" @@ -11,8 +11,10 @@ #include "D2S.h" -namespace FreenectDriver { - class DepthStream : public VideoStream { +namespace FreenectDriver +{ + class DepthStream : public VideoStream + { public: // from NUI library and converted to radians static const float DIAGONAL_FOV = 70 * (M_PI / 180); @@ -42,7 +44,8 @@ namespace FreenectDriver { DepthStream(Freenect::FreenectDevice* pDevice); //~DepthStream() { } - static OniSensorInfo getSensorInfo() { + static OniSensorInfo getSensorInfo() + { FreenectDepthModeMap supported_modes = getSupportedVideoModes(); OniVideoMode* modes = new OniVideoMode[supported_modes.size()]; std::transform(supported_modes.begin(), supported_modes.end(), modes, RetrieveKey()); @@ -51,7 +54,8 @@ namespace FreenectDriver { } OniImageRegistrationMode getImageRegistrationMode() const { return image_registration_mode; } - OniStatus setImageRegistrationMode(OniImageRegistrationMode mode) { + OniStatus setImageRegistrationMode(OniImageRegistrationMode mode) + { if (!isImageRegistrationModeSupported(mode)) return ONI_STATUS_NOT_SUPPORTED; image_registration_mode = mode; @@ -61,8 +65,10 @@ namespace FreenectDriver { // from StreamBase OniBool isImageRegistrationModeSupported(OniImageRegistrationMode mode) { return (mode == ONI_IMAGE_REGISTRATION_OFF || mode == ONI_IMAGE_REGISTRATION_DEPTH_TO_COLOR); } - OniBool isPropertySupported(int propertyId) { - switch(propertyId) { + OniBool isPropertySupported(int propertyId) + { + switch(propertyId) + { default: return VideoStream::isPropertySupported(propertyId); case ONI_STREAM_PROPERTY_HORIZONTAL_FOV: @@ -82,28 +88,33 @@ namespace FreenectDriver { } } - OniStatus getProperty(int propertyId, void* data, int* pDataSize) { - switch (propertyId) { + OniStatus getProperty(int propertyId, void* data, int* pDataSize) + { + switch (propertyId) + { default: return VideoStream::getProperty(propertyId, data, pDataSize); case ONI_STREAM_PROPERTY_HORIZONTAL_FOV: // float (radians) - if (*pDataSize != sizeof(float)) { - printf("Unexpected size: %d != %lu\n", *pDataSize, sizeof(float)); + if (*pDataSize != sizeof(float)) + { + LogError("Unexpected size for ONI_STREAM_PROPERTY_HORIZONTAL_FOV"); return ONI_STATUS_ERROR; } *(static_cast(data)) = HORIZONTAL_FOV; return ONI_STATUS_OK; case ONI_STREAM_PROPERTY_VERTICAL_FOV: // float (radians) - if (*pDataSize != sizeof(float)) { - printf("Unexpected size: %d != %lu\n", *pDataSize, sizeof(float)); + if (*pDataSize != sizeof(float)) + { + LogError("Unexpected size for ONI_STREAM_PROPERTY_VERTICAL_FOV"); return ONI_STATUS_ERROR; } *(static_cast(data)) = VERTICAL_FOV; return ONI_STATUS_OK; case ONI_STREAM_PROPERTY_MAX_VALUE: // int - if (*pDataSize != sizeof(int)) { - printf("Unexpected size: %d != %lu\n", *pDataSize, sizeof(int)); + if (*pDataSize != sizeof(int)) + { + LogError("Unexpected size for ONI_STREAM_PROPERTY_MAX_VALUE"); return ONI_STATUS_ERROR; } *(static_cast(data)) = MAX_VALUE; @@ -120,57 +131,65 @@ namespace FreenectDriver { return ONI_STATUS_NOT_SUPPORTED; case XN_STREAM_PROPERTY_GAIN: // unsigned long long - if (*pDataSize != sizeof(unsigned long long)) { - printf("Unexpected size: %d != %lu\n", *pDataSize, sizeof(unsigned long long)); + if (*pDataSize != sizeof(unsigned long long)) + { + LogError("Unexpected size for XN_STREAM_PROPERTY_GAIN"); return ONI_STATUS_ERROR; } *(static_cast(data)) = GAIN_VAL; return ONI_STATUS_OK; case XN_STREAM_PROPERTY_CONST_SHIFT: // unsigned long long - if (*pDataSize != sizeof(unsigned long long)) { - printf("Unexpected size: %d != %lu\n", *pDataSize, sizeof(unsigned long long)); + if (*pDataSize != sizeof(unsigned long long)) + { + LogError("Unexpected size for XN_STREAM_PROPERTY_CONST_SHIFT"); return ONI_STATUS_ERROR; } *(static_cast(data)) = CONST_SHIFT_VAL; return ONI_STATUS_OK; case XN_STREAM_PROPERTY_MAX_SHIFT: // unsigned long long - if (*pDataSize != sizeof(unsigned long long)) { - printf("Unexpected size: %d != %lu\n", *pDataSize, sizeof(unsigned long long)); + if (*pDataSize != sizeof(unsigned long long)) + { + LogError("Unexpected size for XN_STREAM_PROPERTY_MAX_SHIFT"); return ONI_STATUS_ERROR; } *(static_cast(data)) = MAX_SHIFT_VAL; return ONI_STATUS_OK; case XN_STREAM_PROPERTY_PARAM_COEFF: // unsigned long long - if (*pDataSize != sizeof(unsigned long long)) { - printf("Unexpected size: %d != %lu\n", *pDataSize, sizeof(unsigned long long)); + if (*pDataSize != sizeof(unsigned long long)) + { + LogError("Unexpected size for XN_STREAM_PROPERTY_PARAM_COEFF"); return ONI_STATUS_ERROR; } *(static_cast(data)) = PARAM_COEFF_VAL; return ONI_STATUS_OK; case XN_STREAM_PROPERTY_SHIFT_SCALE: // unsigned long long - if (*pDataSize != sizeof(unsigned long long)) { - printf("Unexpected size: %d != %lu\n", *pDataSize, sizeof(unsigned long long)); + if (*pDataSize != sizeof(unsigned long long)) + { + LogError("Unexpected size for XN_STREAM_PROPERTY_SHIFT_SCALE"); return ONI_STATUS_ERROR; } *(static_cast(data)) = SHIFT_SCALE_VAL; return ONI_STATUS_OK; case XN_STREAM_PROPERTY_ZERO_PLANE_DISTANCE: // unsigned long long - if (*pDataSize != sizeof(unsigned long long)) { - printf("Unexpected size: %d != %lu\n", *pDataSize, sizeof(unsigned long long)); + if (*pDataSize != sizeof(unsigned long long)) + { + LogError("Unexpected size for XN_STREAM_PROPERTY_ZERO_PLANE_DISTANCE"); return ONI_STATUS_ERROR; } *(static_cast(data)) = ZERO_PLANE_DISTANCE_VAL; return ONI_STATUS_OK; case XN_STREAM_PROPERTY_ZERO_PLANE_PIXEL_SIZE: // double - if (*pDataSize != sizeof(double)) { - printf("Unexpected size: %d != %lu\n", *pDataSize, sizeof(double)); + if (*pDataSize != sizeof(double)) + { + LogError("Unexpected size for XN_STREAM_PROPERTY_ZERO_PLANE_PIXEL_SIZE"); return ONI_STATUS_ERROR; } *(static_cast(data)) = ZERO_PLANE_PIXEL_SIZE_VAL; return ONI_STATUS_OK; case XN_STREAM_PROPERTY_EMITTER_DCMOS_DISTANCE: // double - if (*pDataSize != sizeof(double)) { - printf("Unexpected size: %d != %lu\n", *pDataSize, sizeof(double)); + if (*pDataSize != sizeof(double)) + { + LogError("Unexpected size for XN_STREAM_PROPERTY_EMITTER_DCMOS_DISTANCE"); return ONI_STATUS_ERROR; } *(static_cast(data)) = EMITTER_DCMOS_DISTANCE_VAL; diff --git a/OpenNI2-FreenectDriver/src/DeviceDriver.cpp b/OpenNI2-FreenectDriver/src/DeviceDriver.cpp index 5e34f793..881f8df3 100644 --- a/OpenNI2-FreenectDriver/src/DeviceDriver.cpp +++ b/OpenNI2-FreenectDriver/src/DeviceDriver.cpp @@ -15,7 +15,7 @@ * limitations under the License. */ #include -#include +#include #include "Driver/OniDriverAPI.h" #include "libfreenect.hpp" #include "DepthStream.hpp" @@ -24,8 +24,10 @@ static bool operator<(const OniDeviceInfo& left, const OniDeviceInfo& right) { return (strcmp(left.uri, right.uri) < 0); } // for std::map -namespace FreenectDriver { - class Device : public oni::driver::DeviceBase, public Freenect::FreenectDevice { +namespace FreenectDriver +{ + class Device : public oni::driver::DeviceBase, public Freenect::FreenectDevice + { private: ColorStream* color; DepthStream* depth; @@ -42,7 +44,8 @@ namespace FreenectDriver { Device(freenect_context* fn_ctx, int index) : Freenect::FreenectDevice(fn_ctx, index), color(NULL), depth(NULL) { } - ~Device() { + ~Device() + { destroyStream(color); destroyStream(depth); } @@ -51,7 +54,8 @@ namespace FreenectDriver { OniBool isImageRegistrationModeSupported(OniImageRegistrationMode mode) { return depth->isImageRegistrationModeSupported(mode); } - OniStatus getSensorInfoList(OniSensorInfo** pSensors, int* numSensors) { + OniStatus getSensorInfoList(OniSensorInfo** pSensors, int* numSensors) + { *numSensors = 2; OniSensorInfo * sensors = new OniSensorInfo[*numSensors]; sensors[0] = depth->getSensorInfo(); @@ -60,10 +64,12 @@ namespace FreenectDriver { return ONI_STATUS_OK; } - oni::driver::StreamBase* createStream(OniSensorType sensorType) { - switch (sensorType) { + oni::driver::StreamBase* createStream(OniSensorType sensorType) + { + switch (sensorType) + { default: - //m_driverServices.errorLoggerAppend("FreenectDeviceNI: Can't create a stream of type %d", sensorType); + LogError("Cannot create a stream of type " + sensorType); return NULL; case ONI_SENSOR_COLOR: Freenect::FreenectDevice::startVideo(); @@ -79,16 +85,19 @@ namespace FreenectDriver { } } - void destroyStream(oni::driver::StreamBase* pStream) { - if (! pStream) + void destroyStream(oni::driver::StreamBase* pStream) + { + if (pStream == NULL) return; - if (pStream == color) { + if (pStream == color) + { Freenect::FreenectDevice::stopVideo(); delete color; color = NULL; } - if (pStream == depth) { + if (pStream == depth) + { Freenect::FreenectDevice::stopDepth(); delete depth; depth = NULL; @@ -98,14 +107,15 @@ namespace FreenectDriver { // todo: fill out properties OniBool isPropertySupported(int propertyId) { - if(propertyId == ONI_DEVICE_PROPERTY_IMAGE_REGISTRATION) + if (propertyId == ONI_DEVICE_PROPERTY_IMAGE_REGISTRATION) return true; return false; } OniStatus getProperty(int propertyId, void* data, int* pDataSize) { - switch (propertyId) { + switch (propertyId) + { default: case ONI_DEVICE_PROPERTY_FIRMWARE_VERSION: // string case ONI_DEVICE_PROPERTY_DRIVER_VERSION: // OniVersion @@ -125,17 +135,20 @@ namespace FreenectDriver { return ONI_STATUS_NOT_SUPPORTED; case ONI_DEVICE_PROPERTY_IMAGE_REGISTRATION: // OniImageRegistrationMode - if (*pDataSize != sizeof(OniImageRegistrationMode)) { - printf("Unexpected size: %d != %lu\n", *pDataSize, sizeof(OniImageRegistrationMode)); + if (*pDataSize != sizeof(OniImageRegistrationMode)) + { + LogError("Unexpected size for ONI_DEVICE_PROPERTY_IMAGE_REGISTRATION"); return ONI_STATUS_ERROR; } *(static_cast(data)) = depth->getImageRegistrationMode(); return ONI_STATUS_OK; } } + OniStatus setProperty(int propertyId, const void* data, int dataSize) { - switch (propertyId) { + switch (propertyId) + { default: case ONI_DEVICE_PROPERTY_FIRMWARE_VERSION: // By implementation case ONI_DEVICE_PROPERTY_DRIVER_VERSION: // OniVersion @@ -162,15 +175,16 @@ namespace FreenectDriver { return ONI_STATUS_NOT_SUPPORTED; case ONI_DEVICE_PROPERTY_IMAGE_REGISTRATION: // OniImageRegistrationMode - if (dataSize != sizeof(OniImageRegistrationMode)) { - printf("Unexpected size: %d != %lu\n", dataSize, sizeof(OniImageRegistrationMode)); + if (dataSize != sizeof(OniImageRegistrationMode)) + { + LogError("Unexpected size for ONI_DEVICE_PROPERTY_IMAGE_REGISTRATION"); return ONI_STATUS_ERROR; } return depth->setImageRegistrationMode(*(static_cast(data))); } } - OniBool isCommandSupported(int commandId) //{ return (invoke(propertyId, NULL, sizeof(NULL)) != ONI_STATUS_NOT_SUPPORTED); } + OniBool isCommandSupported(int commandId) { switch (commandId) { @@ -197,26 +211,30 @@ namespace FreenectDriver { }; - class Driver : public oni::driver::DriverBase, private Freenect::Freenect { + class Driver : public oni::driver::DriverBase, private Freenect::Freenect + { private: std::map devices; public: - Driver(OniDriverServices* pDriverServices) : DriverBase(pDriverServices) { - //freenect_set_log_level(m_ctx, FREENECT_LOG_NOTICE); - freenect_select_subdevices(m_ctx, FREENECT_DEVICE_CAMERA); // OpenNI2 doesn't use MOTOR + Driver(OniDriverServices* pDriverServices) : DriverBase(pDriverServices) + { + freenect_set_log_level(m_ctx, FREENECT_LOG_DEBUG); + freenect_select_subdevices(m_ctx, FREENECT_DEVICE_CAMERA); // OpenNI2 doesn't use MOTOR or AUDIO + DriverServices = &getServices(); } ~Driver() { shutdown(); } // for DriverBase - OniStatus initialize(oni::driver::DeviceConnectedCallback connectedCallback, oni::driver::DeviceDisconnectedCallback disconnectedCallback, oni::driver::DeviceStateChangedCallback deviceStateChangedCallback, void* pCookie) { + OniStatus initialize(oni::driver::DeviceConnectedCallback connectedCallback, oni::driver::DeviceDisconnectedCallback disconnectedCallback, oni::driver::DeviceStateChangedCallback deviceStateChangedCallback, void* pCookie) + { DriverBase::initialize(connectedCallback, disconnectedCallback, deviceStateChangedCallback, pCookie); - for (int i = 0; i < Freenect::deviceCount(); ++i) { - std::ostringstream uri; - uri << "freenect://" << i; + for (int i = 0; i < Freenect::deviceCount(); i++) + { + std::string uri = "freenect://" + i; OniDeviceInfo info; - strncpy(info.uri, uri.str().c_str(), ONI_MAX_STR); + 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; @@ -226,12 +244,18 @@ namespace FreenectDriver { return ONI_STATUS_OK; } - oni::driver::DeviceBase* deviceOpen(const char* uri, const char* mode = NULL) { - for (std::map::iterator iter = devices.begin(); iter != devices.end(); ++iter) { - if (strcmp(iter->first.uri, uri) == 0) { // found + oni::driver::DeviceBase* deviceOpen(const char* uri, const char* mode = NULL) + { + for (std::map::iterator iter = devices.begin(); iter != devices.end(); iter++) + { + if (strcmp(iter->first.uri, uri) == 0) // found + { if (iter->second) // already open + { return iter->second; - else { + } + else + { unsigned int id; std::istringstream is(iter->first.uri); is.seekg(strlen("freenect://")); @@ -243,12 +267,14 @@ namespace FreenectDriver { } } - getServices().errorLoggerAppend("Could not find device '%s'", uri); + LogError("Could not find device " + *uri); return NULL; } - void deviceClose(oni::driver::DeviceBase* pDevice) { - for (std::map::iterator iter = devices.begin(); iter != devices.end(); ++iter) { + void deviceClose(oni::driver::DeviceBase* pDevice) + { + for (std::map::iterator iter = devices.begin(); iter != devices.end(); iter++) + { if (iter->second == pDevice) { iter->second = NULL; unsigned int id; @@ -260,10 +286,11 @@ namespace FreenectDriver { } } - getServices().errorLoggerAppend("Could not close unrecognized device"); + LogError("Could not close unrecognized device"); } - OniStatus tryDevice(const char* uri) { + OniStatus tryDevice(const char* uri) + { oni::driver::DeviceBase* device = deviceOpen(uri); if (! device) return ONI_STATUS_ERROR; @@ -271,8 +298,9 @@ namespace FreenectDriver { return ONI_STATUS_OK; } - void shutdown() { - for (std::map::iterator iter = devices.begin(); iter != devices.end(); ++iter) + void shutdown() + { + for (std::map::iterator iter = devices.begin(); iter != devices.end(); iter++) deviceClose(iter->second); } diff --git a/OpenNI2-FreenectDriver/src/VideoStream.hpp b/OpenNI2-FreenectDriver/src/VideoStream.hpp index 40a0d911..d951de26 100644 --- a/OpenNI2-FreenectDriver/src/VideoStream.hpp +++ b/OpenNI2-FreenectDriver/src/VideoStream.hpp @@ -1,12 +1,12 @@ #pragma once -#include #include "libfreenect.hpp" #include "Driver/OniDriverAPI.h" #include "PS1080.h" -struct RetrieveKey { +struct RetrieveKey +{ template typename T::first_type operator()(T pair) const { return pair.first; @@ -14,7 +14,8 @@ struct RetrieveKey { }; // "extension constructor" for OniVideoMode struct -static OniVideoMode makeOniVideoMode(OniPixelFormat pixel_format, int resolution_x, int resolution_y, int frames_per_second) { +static OniVideoMode makeOniVideoMode(OniPixelFormat pixel_format, int resolution_x, int resolution_y, int frames_per_second) +{ OniVideoMode mode; mode.pixelFormat = pixel_format; mode.resolutionX = resolution_x; @@ -23,14 +24,25 @@ static OniVideoMode makeOniVideoMode(OniPixelFormat pixel_format, int resolution return mode; } -static bool operator==(const OniVideoMode& left, const OniVideoMode& right) { +static bool operator==(const OniVideoMode& left, const OniVideoMode& right) +{ return (left.pixelFormat == right.pixelFormat && left.resolutionX == right.resolutionX && left.resolutionY == right.resolutionY && left.fps == right.fps); } static bool operator<(const OniVideoMode& left, const OniVideoMode& right) { return (left.resolutionX*left.resolutionY < right.resolutionX*right.resolutionY); } -namespace FreenectDriver { - class VideoStream : public oni::driver::StreamBase { +namespace FreenectDriver +{ + // DriverServices is set in DeviceDriver.cpp so all files can call LogError() + static oni::driver::DriverServices* DriverServices; + static void LogError(std::string error) + { + if (DriverServices) + DriverServices->errorLoggerAppend(std::string("OpenNI2-FreenectDriver: " + error).c_str()); + } + + class VideoStream : public oni::driver::StreamBase + { private: unsigned int frame_id; // number each frame @@ -52,7 +64,8 @@ namespace FreenectDriver { mirroring(false) { } //~VideoStream() { stop(); } - void buildFrame(void* data, uint32_t timestamp) { + void buildFrame(void* data, uint32_t timestamp) + { if (!running) return; @@ -70,7 +83,8 @@ namespace FreenectDriver { // from StreamBase - OniStatus start() { + OniStatus start() + { running = true; return ONI_STATUS_OK; } @@ -78,8 +92,10 @@ namespace FreenectDriver { // only add to property handlers if the property is generic to all children // otherwise, implement in child and call these in default case - OniBool isPropertySupported(int propertyId) { - switch(propertyId) { + OniBool isPropertySupported(int propertyId) + { + switch(propertyId) + { case ONI_STREAM_PROPERTY_VIDEO_MODE: case ONI_STREAM_PROPERTY_CROPPING: case ONI_STREAM_PROPERTY_MIRRORING: @@ -89,8 +105,10 @@ namespace FreenectDriver { } } - virtual OniStatus getProperty(int propertyId, void* data, int* pDataSize) { - switch (propertyId) { + virtual OniStatus getProperty(int propertyId, void* data, int* pDataSize) + { + switch (propertyId) + { default: case ONI_STREAM_PROPERTY_HORIZONTAL_FOV: // float: radians case ONI_STREAM_PROPERTY_VERTICAL_FOV: // float: radians @@ -107,16 +125,18 @@ namespace FreenectDriver { return ONI_STATUS_NOT_SUPPORTED; case ONI_STREAM_PROPERTY_VIDEO_MODE: // OniVideoMode* - if (*pDataSize != sizeof(OniVideoMode)) { - printf("Unexpected size: %d != %lu\n", *pDataSize, sizeof(OniVideoMode)); + if (*pDataSize != sizeof(OniVideoMode)) + { + LogError("Unexpected size for ONI_STREAM_PROPERTY_VIDEO_MODE"); return ONI_STATUS_ERROR; } *(static_cast(data)) = video_mode; return ONI_STATUS_OK; case ONI_STREAM_PROPERTY_CROPPING: // OniCropping* - if (*pDataSize != sizeof(OniCropping)) { - printf("Unexptected size: %d != %lu\n", *pDataSize, sizeof(OniVideoMode)); + if (*pDataSize != sizeof(OniCropping)) + { + LogError("Unexpected size for ONI_STREAM_PROPERTY_CROPPING"); return ONI_STATUS_ERROR; } *(static_cast(data)) = cropping; @@ -125,15 +145,17 @@ namespace FreenectDriver { case ONI_STREAM_PROPERTY_MIRRORING: // OniBool if (*pDataSize != sizeof(OniBool)) { - printf("Unexpected size: %d != %lu\n", *pDataSize, sizeof(OniBool)); + LogError("Unexpected size for ONI_STREAM_PROPERTY_MIRRORING"); return ONI_STATUS_ERROR; } *(static_cast(data)) = mirroring; return ONI_STATUS_OK; } } - virtual OniStatus setProperty(int propertyId, const void* data, int dataSize) { - switch (propertyId) { + virtual OniStatus setProperty(int propertyId, const void* data, int dataSize) + { + switch (propertyId) + { default: case ONI_STREAM_PROPERTY_HORIZONTAL_FOV: // float: radians case ONI_STREAM_PROPERTY_VERTICAL_FOV: // float: radians @@ -150,8 +172,9 @@ namespace FreenectDriver { return ONI_STATUS_NOT_SUPPORTED; case ONI_STREAM_PROPERTY_VIDEO_MODE: // OniVideoMode* - if (dataSize != sizeof(OniVideoMode)) { - printf("Unexpected size: %d != %lu\n", dataSize, sizeof(OniVideoMode)); + if (dataSize != sizeof(OniVideoMode)) + { + LogError("Unexpected size for ONI_STREAM_PROPERTY_VIDEO_MODE"); return ONI_STATUS_ERROR; } if (ONI_STATUS_OK != setVideoMode(*(static_cast(data)))) @@ -160,9 +183,9 @@ namespace FreenectDriver { return ONI_STATUS_OK; case ONI_STREAM_PROPERTY_CROPPING: // OniCropping* - std::cout << "set cropping" << std::endl; - if (dataSize != sizeof(OniCropping)) { - printf("Unexpected size: %d != %lu\n", dataSize, sizeof(OniCropping)); + if (dataSize != sizeof(OniCropping)) + { + LogError("Unexpected size for ONI_STREAM_PROPERTY_CROPPING"); return ONI_STATUS_ERROR; } cropping = *(static_cast(data)); @@ -171,8 +194,9 @@ namespace FreenectDriver { return ONI_STATUS_OK; case ONI_STREAM_PROPERTY_MIRRORING: // OniBool - if (dataSize != sizeof(OniBool)) { - printf("Unexpected size: %d != %lu\n", dataSize, sizeof(OniBool)); + if (dataSize != sizeof(OniBool)) + { + LogError("Unexpected size for ONI_STREAM_PROPERTY_MIRRORING"); return ONI_STATUS_ERROR; } mirroring = *(static_cast(data)); From 5b3f3a7ab14e811a22f16fd5652cfcda768d477d Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Thu, 13 Feb 2014 21:39:13 -0500 Subject: [PATCH 41/84] OpenNI2-FreenectDriver: Fix silly silly string bugs; improve logging Fix ebuild for filename change Signed-off-by: Benn Snyder --- OpenNI2-FreenectDriver/src/ColorStream.cpp | 4 +-- OpenNI2-FreenectDriver/src/DepthStream.cpp | 2 +- OpenNI2-FreenectDriver/src/DeviceDriver.cpp | 26 ++++++++++++++----- OpenNI2-FreenectDriver/src/VideoStream.hpp | 23 +++++++++++++--- .../portage/dev-libs/libfreenect/Manifest | 2 +- .../libfreenect/libfreenect-9999.ebuild | 2 +- 6 files changed, 43 insertions(+), 16 deletions(-) diff --git a/OpenNI2-FreenectDriver/src/ColorStream.cpp b/OpenNI2-FreenectDriver/src/ColorStream.cpp index 888996cb..dfbe0627 100644 --- a/OpenNI2-FreenectDriver/src/ColorStream.cpp +++ b/OpenNI2-FreenectDriver/src/ColorStream.cpp @@ -40,7 +40,7 @@ OniStatus ColorStream::setVideoMode(OniVideoMode requested_mode) try { device->setVideoFormat(format, resolution); } catch (std::runtime_error e) { - LogError("Format " + format + std::string(" and resolution " + resolution) + " combination not supported by libfreenect"); + LogError("Format " + to_string(format) + " and resolution " + to_string(resolution) + " combination not supported by libfreenect"); return ONI_STATUS_NOT_SUPPORTED; } video_mode = requested_mode; @@ -58,7 +58,7 @@ void ColorStream::populateFrame(void* data, OniFrame* frame) const switch (video_mode.pixelFormat) { default: - LogError(std::string("Pixel format " + video_mode.pixelFormat) + " not supported by populateFrame()"); + LogError("Pixel format " + to_string(video_mode.pixelFormat) + " not supported by populateFrame()"); return; case ONI_PIXEL_FORMAT_RGB888: diff --git a/OpenNI2-FreenectDriver/src/DepthStream.cpp b/OpenNI2-FreenectDriver/src/DepthStream.cpp index ba10af2b..a2cca0e3 100644 --- a/OpenNI2-FreenectDriver/src/DepthStream.cpp +++ b/OpenNI2-FreenectDriver/src/DepthStream.cpp @@ -39,7 +39,7 @@ OniStatus DepthStream::setVideoMode(OniVideoMode requested_mode) try { device->setDepthFormat(format, resolution); } catch (std::runtime_error e) { - LogError("Format " + format + std::string(" and resolution " + resolution) + " combination not supported by libfreenect"); + LogError("Format " + to_string(format) + " and resolution " + to_string(resolution) + " combination not supported by libfreenect"); if (image_registration_mode == ONI_IMAGE_REGISTRATION_DEPTH_TO_COLOR) { LogError("Could not enable image registration format; falling back to format defined in getSupportedVideoModes()"); diff --git a/OpenNI2-FreenectDriver/src/DeviceDriver.cpp b/OpenNI2-FreenectDriver/src/DeviceDriver.cpp index 881f8df3..1a3fac19 100644 --- a/OpenNI2-FreenectDriver/src/DeviceDriver.cpp +++ b/OpenNI2-FreenectDriver/src/DeviceDriver.cpp @@ -69,7 +69,7 @@ namespace FreenectDriver switch (sensorType) { default: - LogError("Cannot create a stream of type " + sensorType); + LogError("Cannot create a stream of type " + to_string(sensorType)); return NULL; case ONI_SENSOR_COLOR: Freenect::FreenectDevice::startVideo(); @@ -232,7 +232,10 @@ namespace FreenectDriver DriverBase::initialize(connectedCallback, disconnectedCallback, deviceStateChangedCallback, pCookie); for (int i = 0; i < Freenect::deviceCount(); i++) { - std::string uri = "freenect://" + i; + std::string uri = "freenect://" + to_string(i); + + WriteMessage("Found device " + uri); + OniDeviceInfo info; strncpy(info.uri, uri.c_str(), ONI_MAX_STR); strncpy(info.vendor, "Microsoft", ONI_MAX_STR); @@ -256,6 +259,8 @@ namespace FreenectDriver } else { + WriteMessage("Opening device " + std::string(uri)); + unsigned int id; std::istringstream is(iter->first.uri); is.seekg(strlen("freenect://")); @@ -267,23 +272,30 @@ namespace FreenectDriver } } - LogError("Could not find device " + *uri); + LogError("Could not find device " + std::string(uri)); return NULL; } void deviceClose(oni::driver::DeviceBase* pDevice) { - for (std::map::iterator iter = devices.begin(); iter != devices.end(); iter++) + for (std::map::iterator iter = devices.begin(); iter != devices.end();) { - if (iter->second == pDevice) { - iter->second = NULL; + if (iter->second == pDevice) + { + WriteMessage("Closing device " + std::string(iter->first.uri)); + unsigned int id; - std::istringstream is(iter->first.uri); + std::istringstream is(std::string(iter->first.uri)); is.seekg(strlen("freenect://")); is >> id; + devices.erase(iter++); deleteDevice(id); return; } + else + { + iter++; + } } LogError("Could not close unrecognized device"); diff --git a/OpenNI2-FreenectDriver/src/VideoStream.hpp b/OpenNI2-FreenectDriver/src/VideoStream.hpp index d951de26..980f6173 100644 --- a/OpenNI2-FreenectDriver/src/VideoStream.hpp +++ b/OpenNI2-FreenectDriver/src/VideoStream.hpp @@ -1,5 +1,6 @@ #pragma once +#include #include "libfreenect.hpp" #include "Driver/OniDriverAPI.h" #include "PS1080.h" @@ -33,11 +34,26 @@ static bool operator<(const OniVideoMode& left, const OniVideoMode& right) { ret namespace FreenectDriver { - // DriverServices is set in DeviceDriver.cpp so all files can call LogError() + template < typename T > std::string to_string(const T& n) + { + std::ostringstream oss; + oss << n; + return oss.str(); + } + + static void WriteMessage(std::string info) + { + std::cout << "OpenNI2-FreenectDriver: " << info << std::endl; + } + + // DriverServices is set in DeviceDriver.cpp so all files can call errorLoggerAppend() static oni::driver::DriverServices* DriverServices; static void LogError(std::string error) { - if (DriverServices) + // errorLoggerAppend() doesn't seem to go anywhere, so call WriteMessage also + WriteMessage("(ERROR) " + error); + + if (DriverServices != NULL) DriverServices->errorLoggerAppend(std::string("OpenNI2-FreenectDriver: " + error).c_str()); } @@ -52,7 +68,7 @@ namespace FreenectDriver protected: static const OniSensorType sensor_type; Freenect::FreenectDevice* device; - bool running; // acquireFrame() does something iff true + bool running; // buildFrame() does something iff true OniVideoMode video_mode; OniCropping cropping; bool mirroring; @@ -189,7 +205,6 @@ namespace FreenectDriver return ONI_STATUS_ERROR; } cropping = *(static_cast(data)); - raisePropertyChanged(propertyId, data, dataSize); return ONI_STATUS_OK; diff --git a/platform/linux/portage/dev-libs/libfreenect/Manifest b/platform/linux/portage/dev-libs/libfreenect/Manifest index 75992256..240aa7f5 100644 --- a/platform/linux/portage/dev-libs/libfreenect/Manifest +++ b/platform/linux/portage/dev-libs/libfreenect/Manifest @@ -1 +1 @@ -EBUILD libfreenect-9999.ebuild 2246 SHA256 9c108418122975f5c9f6587e9c7e35625ce4cc47932b2c0b03b22ccb802d39da SHA512 05310b350b6598fd826c6ca6e12edc1f809157924a6fac93cb01ee8652b1d544144a22f32fe6ecf8ebd476e73c2a3c334aed02342d2e060ab6cdf88ef4ec965f WHIRLPOOL e9676dbe32df58e78c66343a0f665217b5b89b08f2caf777090536757024e57478694abe04a6cb290a6aef9e5ed46964b83d64ab55c7187f77fbf54150b83fed +EBUILD libfreenect-9999.ebuild 2240 SHA256 a08047d60a53061516df2a185361ff3d6f7b126f305786cdc95977038c981255 SHA512 4bcb2bcab1e6c396d33a767d13200c5e2a15f4387d2898ec28c36edd15baf15a02b1ed3c9f356c86a0b69ccd68f238b7b9aa9aaf4b19a6b6673ac6e3823b8d89 WHIRLPOOL 11274f350181cd8d550dc4161d6de751a401665e36449bc93701183c0636f0932b3dcc84ff55a2ebf52e5b7c1713c475649713a5416e7563058f7da0c0b42d64 diff --git a/platform/linux/portage/dev-libs/libfreenect/libfreenect-9999.ebuild b/platform/linux/portage/dev-libs/libfreenect/libfreenect-9999.ebuild index 1520e72e..5bc3dd8b 100644 --- a/platform/linux/portage/dev-libs/libfreenect/libfreenect-9999.ebuild +++ b/platform/linux/portage/dev-libs/libfreenect/libfreenect-9999.ebuild @@ -59,7 +59,7 @@ src_install() { doins "${S}"/platform/linux/udev/51-kinect.rules # documentation - dodoc HACKING README.asciidoc + dodoc HACKING README.md if use doc; then cd doc doxygen || ewarn "doxygen failed" From cfe9c49cc3bc39594a0c20ef885d4df8c0ad910f Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Fri, 14 Feb 2014 21:00:06 -0500 Subject: [PATCH 42/84] wrappers/cpp: Call freenect_process_events_timeout in loop to prevent freezes - fixes #223 Signed-off-by: Benn Snyder --- wrappers/cpp/libfreenect.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wrappers/cpp/libfreenect.hpp b/wrappers/cpp/libfreenect.hpp index 59450f8b..5703e30b 100644 --- a/wrappers/cpp/libfreenect.hpp +++ b/wrappers/cpp/libfreenect.hpp @@ -218,7 +218,8 @@ namespace Freenect { // Do not call directly, thread runs here void operator()() { while (!m_stop) { - int res = freenect_process_events(m_ctx); + static timeval timeout = { 1, 0 }; + int res = freenect_process_events_timeout(m_ctx, &timeout); if (res < 0) { // libusb signals an error has occurred From 7b9a5defe4ba6204cee1ae185bdfd181477dd931 Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Fri, 14 Feb 2014 21:24:02 -0500 Subject: [PATCH 43/84] All headers (including libfreenect.hpp) are installed to `$PREFIX/include/libfreenect/`. All libfreenect files have `#include "libfreenect.h"` rather than `#include `. This works during build and after installation all include files are in the same directory. Rename libfreenect-audio.h -> libfreenect_audio.h and libfreenect-registration.h -> libfreenect_registration.h. This makes them consistent with other libraries. THIS IS A BREAKING CHANGE; UPDATE YOUR INCLUDES Signed-off-by: Benn Snyder --- CMakeLists.txt | 6 +++--- examples/micview.c | 2 +- examples/wavrecord.c | 2 +- fakenect/fakenect.c | 2 +- fakenect/record.c | 2 +- include/{libfreenect-audio.h => libfreenect_audio.h} | 3 +-- ...reenect-registration.h => libfreenect_registration.h} | 3 +-- src/CMakeLists.txt | 4 ++-- src/audio.c | 2 +- src/freenect_internal.h | 9 ++++----- src/registration.c | 4 ++-- wrappers/c_sync/libfreenect_sync.h | 3 +-- wrappers/cpp/CMakeLists.txt | 2 +- wrappers/cpp/libfreenect.hpp | 3 +-- 14 files changed, 21 insertions(+), 26 deletions(-) rename include/{libfreenect-audio.h => libfreenect_audio.h} (99%) rename include/{libfreenect-registration.h => libfreenect_registration.h} (99%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 501bcb6e..da9741cd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -193,13 +193,13 @@ IF ( BUILD_CPACK ) INSTALL(FILES "${CMAKE_BINARY_DIR}/lib/libfreenect.a" DESTINATION ${PROJECT_LIBRARY_INSTALL_DIR}) if (BUILD_AUDIO) - INSTALL(FILES "include/libfreenect-audio.h" DESTINATION ${PROJECT_INCLUDE_INSTALL_DIR}) + INSTALL(FILES "include/libfreenect_audio.h" DESTINATION ${PROJECT_INCLUDE_INSTALL_DIR}) endif() INSTALL(FILES "include/libfreenect.h" DESTINATION ${PROJECT_INCLUDE_INSTALL_DIR}) - INSTALL(FILES "include/libfreenect-registration.h" DESTINATION ${PROJECT_INCLUDE_INSTALL_DIR}) + INSTALL(FILES "include/libfreenect_registration.h" DESTINATION ${PROJECT_INCLUDE_INSTALL_DIR}) INSTALL(FILES "APACHE20" DESTINATION "share/doc/${CPACK_PACKAGE_NAME}") INSTALL(FILES "GPL2" DESTINATION "share/doc/${CPACK_PACKAGE_NAME}") - INSTALL(FILES "README.asciidoc" DESTINATION "share/doc/${CPACK_PACKAGE_NAME}") + INSTALL(FILES "README.md" DESTINATION "share/doc/${CPACK_PACKAGE_NAME}") ENDIF ( BUILD_CPACK ) diff --git a/examples/micview.c b/examples/micview.c index 280c6d81..8d698329 100644 --- a/examples/micview.c +++ b/examples/micview.c @@ -25,7 +25,7 @@ */ #include "libfreenect.h" -#include "libfreenect-audio.h" +#include "libfreenect_audio.h" #include #include #include diff --git a/examples/wavrecord.c b/examples/wavrecord.c index 655b39ef..3ed08a48 100644 --- a/examples/wavrecord.c +++ b/examples/wavrecord.c @@ -25,7 +25,7 @@ */ #include "libfreenect.h" -#include "libfreenect-audio.h" +#include "libfreenect_audio.h" #include #include diff --git a/fakenect/fakenect.c b/fakenect/fakenect.c index 21da75d3..32a03307 100644 --- a/fakenect/fakenect.c +++ b/fakenect/fakenect.c @@ -23,7 +23,7 @@ * either License. */ -#include +#include "libfreenect.h" #include #include #include diff --git a/fakenect/record.c b/fakenect/record.c index 73603361..b3d2de6b 100644 --- a/fakenect/record.c +++ b/fakenect/record.c @@ -23,9 +23,9 @@ * either License. */ +#include "libfreenect.h" #include #include -#include #include #include #include diff --git a/include/libfreenect-audio.h b/include/libfreenect_audio.h similarity index 99% rename from include/libfreenect-audio.h rename to include/libfreenect_audio.h index 108cf381..2e1f66d6 100644 --- a/include/libfreenect-audio.h +++ b/include/libfreenect_audio.h @@ -23,10 +23,9 @@ * Binary distributions must follow the binary distribution requirements of * either License. */ - #pragma once -#include +#include "libfreenect.h" #include #ifdef __cplusplus diff --git a/include/libfreenect-registration.h b/include/libfreenect_registration.h similarity index 99% rename from include/libfreenect-registration.h rename to include/libfreenect_registration.h index 7ad2b5bb..43aeb973 100644 --- a/include/libfreenect-registration.h +++ b/include/libfreenect_registration.h @@ -23,10 +23,9 @@ * Binary distributions must follow the binary distribution requirements of * either License. */ - #pragma once -#include +#include "libfreenect.h" #include #ifdef __cplusplus diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b365076d..4faa6775 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -48,10 +48,10 @@ target_link_libraries (freenect ${LIBUSB_1_LIBRARIES}) target_link_libraries (freenectstatic ${LIBUSB_1_LIBRARIES}) # Install the header files -install (FILES "../include/libfreenect.h" "../include/libfreenect-registration.h" +install (FILES "../include/libfreenect.h" "../include/libfreenect_registration.h" DESTINATION ${PROJECT_INCLUDE_INSTALL_DIR}) if(BUILD_AUDIO) - install (FILES "../include/libfreenect-audio.h" + install (FILES "../include/libfreenect_audio.h" DESTINATION ${PROJECT_INCLUDE_INSTALL_DIR}) endif() diff --git a/src/audio.c b/src/audio.c index ac83d7df..e38340cc 100644 --- a/src/audio.c +++ b/src/audio.c @@ -24,7 +24,7 @@ * either License. */ #include "libfreenect.h" -#include "libfreenect-audio.h" +#include "libfreenect_audio.h" #include "freenect_internal.h" #include diff --git a/src/freenect_internal.h b/src/freenect_internal.h index 5bf98aa1..44d2f055 100644 --- a/src/freenect_internal.h +++ b/src/freenect_internal.h @@ -23,22 +23,21 @@ * Binary distributions must follow the binary distribution requirements of * either License. */ - #pragma once #include #include "libfreenect.h" -#include "libfreenect-registration.h" +#include "libfreenect_registration.h" #ifdef BUILD_AUDIO -#include "libfreenect-audio.h" + #include "libfreenect_audio.h" #endif #ifdef __ELF__ -#define FN_INTERNAL __attribute__ ((visibility ("hidden"))) + #define FN_INTERNAL __attribute__ ((visibility ("hidden"))) #else -#define FN_INTERNAL + #define FN_INTERNAL #endif diff --git a/src/registration.c b/src/registration.c index 072b7043..7111ae1f 100644 --- a/src/registration.c +++ b/src/registration.c @@ -24,8 +24,8 @@ * either License. */ -#include -#include +#include "libfreenect.h" +#include "freenect_internal.h" #include "registration.h" #include #include diff --git a/wrappers/c_sync/libfreenect_sync.h b/wrappers/c_sync/libfreenect_sync.h index 923074b5..568e59cf 100644 --- a/wrappers/c_sync/libfreenect_sync.h +++ b/wrappers/c_sync/libfreenect_sync.h @@ -23,10 +23,9 @@ * Binary distributions must follow the binary distribution requirements of * either License. */ - #pragma once -#include +#include "libfreenect.h" #include #ifdef __cplusplus diff --git a/wrappers/cpp/CMakeLists.txt b/wrappers/cpp/CMakeLists.txt index ff8469f7..863e8b7c 100644 --- a/wrappers/cpp/CMakeLists.txt +++ b/wrappers/cpp/CMakeLists.txt @@ -1,5 +1,5 @@ INSTALL(FILES libfreenect.hpp - DESTINATION include) + DESTINATION ${PROJECT_INCLUDE_INSTALL_DIR}) IF(BUILD_EXAMPLES) diff --git a/wrappers/cpp/libfreenect.hpp b/wrappers/cpp/libfreenect.hpp index 5703e30b..1cc1568e 100644 --- a/wrappers/cpp/libfreenect.hpp +++ b/wrappers/cpp/libfreenect.hpp @@ -23,10 +23,9 @@ * Binary distributions must follow the binary distribution requirements of * either License. */ - #pragma once -#include +#include "libfreenect.h" #include #include #include From 4b41f291e3b38e875aa4227eede06157b3d3f008 Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Sat, 15 Feb 2014 10:48:13 -0500 Subject: [PATCH 44/84] Update for v0.4.0 Signed-off-by: Benn Snyder --- CMakeLists.txt | 2 +- README.md | 9 +++++---- platform/linux/portage/dev-libs/libfreenect/Manifest | 2 +- .../portage/dev-libs/libfreenect/libfreenect-9999.ebuild | 5 +---- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index da9741cd..034d5bc6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,7 +40,7 @@ set(PYTHON_EXECUTABLE "python2") PROJECT(libfreenect) set (PROJECT_VER_MAJOR 0) -set (PROJECT_VER_MINOR 3) +set (PROJECT_VER_MINOR 4) set (PROJECT_VER_PATCH 0) set (PROJECT_VER "${PROJECT_VER_MAJOR}.${PROJECT_VER_MINOR}.${PROJECT_VER_PATCH}") diff --git a/README.md b/README.md index a3a2ec57..d2d2e149 100644 --- a/README.md +++ b/README.md @@ -16,8 +16,9 @@ Audio is a work in progress. To build libfreenect, you'll need -- [libusb](http://libusb.info/) >= 1.0.13 -- [CMake](http://www.cmake.org/) >= 2.6 +- [libusb](http://libusb.info) >= 1.0.13 +- [CMake](http://cmake.org) >= 2.6 +- [python](http://python.org) == 2.* (only if BUILD_AUDIO or BUILD_PYTHON) For the examples, you'll need @@ -26,13 +27,13 @@ For the examples, you'll need - [pthreads-win32](http://sourceforge.net/projects/pthreads4w/) (Windows) -## Fetch & Build +## Fetch & Build git clone https://github.com/OpenKinect/libfreenect cd libfreenect mkdir build cd build - cmake .. + cmake -L .. make # if you don't have `make` or don't want color output diff --git a/platform/linux/portage/dev-libs/libfreenect/Manifest b/platform/linux/portage/dev-libs/libfreenect/Manifest index 240aa7f5..291af3ed 100644 --- a/platform/linux/portage/dev-libs/libfreenect/Manifest +++ b/platform/linux/portage/dev-libs/libfreenect/Manifest @@ -1 +1 @@ -EBUILD libfreenect-9999.ebuild 2240 SHA256 a08047d60a53061516df2a185361ff3d6f7b126f305786cdc95977038c981255 SHA512 4bcb2bcab1e6c396d33a767d13200c5e2a15f4387d2898ec28c36edd15baf15a02b1ed3c9f356c86a0b69ccd68f238b7b9aa9aaf4b19a6b6673ac6e3823b8d89 WHIRLPOOL 11274f350181cd8d550dc4161d6de751a401665e36449bc93701183c0636f0932b3dcc84ff55a2ebf52e5b7c1713c475649713a5416e7563058f7da0c0b42d64 +EBUILD libfreenect-9999.ebuild 2121 SHA256 223618ff82ec043e8f65d977bc0297a1ba71d25658125b2f3aabbaaf51b361ac SHA512 2e6f0e484389b338b32a8ea8cdec652c3d03bcda106cd98484cdbf084ebd60497c5cb63dd1cbe0fb4566a2fc2efe2e9bc4053532dd5f7655249cc0803b84a090 WHIRLPOOL b0ea6afdf4c270113dda55684565a341c61c4568baff8457a66d74ccfa9e343cb73713247cbf12bb92f1f828524053ab89343bfc96feeddb629a279d2e1e41bf diff --git a/platform/linux/portage/dev-libs/libfreenect/libfreenect-9999.ebuild b/platform/linux/portage/dev-libs/libfreenect/libfreenect-9999.ebuild index 5bc3dd8b..7b5b9529 100644 --- a/platform/linux/portage/dev-libs/libfreenect/libfreenect-9999.ebuild +++ b/platform/linux/portage/dev-libs/libfreenect/libfreenect-9999.ebuild @@ -28,6 +28,7 @@ RDEPEND="${COMMON_DEP}" DEPEND= "${COMMON_DEP} dev-util/cmake virtual/pkgconfig + audio? ( dev-lang/python-2* ) doc? ( app-doc/doxygen ) python? ( dev-python/cython )" @@ -49,10 +50,6 @@ src_configure() { src_install() { cmake-utils_src_install - # Rename record example so it does not collide with xawtv - if use examples; then - mv "${D}"/usr/bin/record "${D}"/usr/bin/frecord || die - fi # udev rules insinto /lib/udev/rules.d/ From 7c0fcdf8dc6d6cfc36a79f5f70efe7046d673348 Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Sun, 16 Feb 2014 16:05:59 -0500 Subject: [PATCH 45/84] Return UINT16_MAX on error from read_register() and read_cmos_register() - fixes #367 Check actual ctx pointer for NULL in freenect_init() Signed-off-by: Benn Snyder --- README.md | 3 ++- src/core.c | 2 +- src/flags.c | 63 +++++++++++++++++++++++++++++++++-------------------- src/flags.h | 2 ++ 4 files changed, 44 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index d2d2e149..badf2eec 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,8 @@ There is a live ebuild for your convenience in [platform/linux/portage/dev-libs/ ### Arch Linux -There is a [libfreenect-git](https://aur.archlinux.org/packages/libfreenect-git/) PKGBUILD in the AUR. +There is a [libfreenect](https://aur.archlinux.org/packages/libfreenect) PKGBUILD in the AUR. +Alternately, the [libfreenect-git](https://aur.archlinux.org/packages/libfreenect-git) PKGBUILD builds the very latest. ## Windows diff --git a/src/core.c b/src/core.c index 4ad62255..476d0cbc 100644 --- a/src/core.c +++ b/src/core.c @@ -43,7 +43,7 @@ FREENECTAPI int freenect_init(freenect_context **ctx, freenect_usb_context *usb_ int res; *ctx = (freenect_context*)malloc(sizeof(freenect_context)); - if (!ctx) + if (*ctx == NULL) return -1; memset(*ctx, 0, sizeof(freenect_context)); diff --git a/src/flags.c b/src/flags.c index 169c771a..16bd94df 100644 --- a/src/flags.c +++ b/src/flags.c @@ -32,20 +32,23 @@ // freenect_set_flag is the only function exposed in libfreenect.h // The rest are available internally via #include flags.h -FN_INTERNAL static int register_for_flag(int flag) { - switch(flag) { - case FREENECT_MIRROR_DEPTH: - return 0x17; - case FREENECT_MIRROR_VIDEO: - return 0x47; - default: - return -1; +FN_INTERNAL int register_for_flag(int flag) +{ + switch(flag) + { + case FREENECT_MIRROR_DEPTH: + return 0x17; + case FREENECT_MIRROR_VIDEO: + return 0x47; + default: + return -1; } } int freenect_set_flag(freenect_device *dev, freenect_flag flag, freenect_flag_value value) { - if (flag >= (1 << 16)) { + if (flag >= (1 << 16)) + { int reg = register_for_flag(flag); if (reg < 0) return reg; @@ -53,8 +56,8 @@ int freenect_set_flag(freenect_device *dev, freenect_flag flag, freenect_flag_va } uint16_t reg = read_cmos_register(dev, 0x0106); - if (reg < 0) - return reg; + if (reg == UINT16_MAX) + return -1; if (value == FREENECT_ON) reg |= flag; else @@ -138,19 +141,21 @@ FN_INTERNAL int send_cmd(freenect_device *dev, uint16_t cmd, void *cmdbuf, unsig return actual_len; } +// returns UINT16_MAX on error FN_INTERNAL uint16_t read_register(freenect_device *dev, uint16_t reg) { freenect_context *ctx = dev->parent; + uint16_t reply[2]; - uint16_t cmd; - int res; - - cmd = fn_le16(reg); - + uint16_t cmd = fn_le16(reg); + FN_DEBUG("read_register: 0x%04x =>\n", reg); - res = send_cmd(dev, 0x02, &cmd, 2, reply, 4); + int res = send_cmd(dev, 0x02, &cmd, 2, reply, 4); if (res < 0) + { FN_ERROR("read_register: send_cmd() failed: %d\n", res); + return UINT16_MAX; + } if (res != 4) FN_WARNING("read_register: send_cmd() returned %d [%04x %04x], 0000 expected\n", res, reply[0], reply[1]); @@ -162,33 +167,40 @@ FN_INTERNAL int write_register(freenect_device *dev, uint16_t reg, uint16_t data freenect_context *ctx = dev->parent; uint16_t reply[2]; uint16_t cmd[2]; - int res; cmd[0] = fn_le16(reg); cmd[1] = fn_le16(data); FN_DEBUG("write_register: 0x%04x <= 0x%02x\n", reg, data); - res = send_cmd(dev, 0x03, cmd, 4, reply, 4); + int res = send_cmd(dev, 0x03, cmd, 4, reply, 4); if (res < 0) + { + FN_ERROR("write_register: send_cmd() returned %d\n", res); return res; - if (res != 2) { - FN_WARNING("send_cmd() returned %d [%04x %04x], 0000 expected\n", res, reply[0], reply[1]); } + if (res != 2) + FN_WARNING("write_register: send_cmd() returned %d [%04x %04x], 0000 expected\n", res, reply[0], reply[1]); + return 0; } +// returns UINT16_MAX on error FN_INTERNAL uint16_t read_cmos_register(freenect_device *dev, uint16_t reg) { freenect_context *ctx = dev->parent; uint16_t replybuf[0x200]; uint16_t cmdbuf[3]; + cmdbuf[0] = 1; cmdbuf[1] = reg & 0x7fff; cmdbuf[2] = 0; + + FN_DEBUG("read_cmos_register: 0x%04x =>\n", reg); int res = send_cmd(dev, 0x95, cmdbuf, 6, replybuf, 6); - if (res < 0) { + if (res < 0) + { FN_ERROR("read_cmos_register: send_cmd() returned %d\n", res); - return res; + return UINT16_MAX; } return replybuf[2]; } @@ -198,11 +210,14 @@ FN_INTERNAL int write_cmos_register(freenect_device *dev, uint16_t reg, uint16_t freenect_context *ctx = dev->parent; uint16_t replybuf[0x200]; uint16_t cmdbuf[3]; + cmdbuf[0] = 1; cmdbuf[1] = reg | 0x8000; cmdbuf[2] = value; + + FN_DEBUG("write_cmos_register: 0x%04x <= 0x%02x\n", reg, value); int res = send_cmd(dev, 0x95, cmdbuf, 6, replybuf, 6); if (res < 0) - FN_ERROR("read_cmos_register: send_cmd() returned %d\n", res); + FN_ERROR("write_cmos_register: send_cmd() returned %d\n", res); return res; } diff --git a/src/flags.h b/src/flags.h index 87e401df..a56ea887 100644 --- a/src/flags.h +++ b/src/flags.h @@ -31,8 +31,10 @@ int send_cmd(freenect_device *dev, uint16_t cmd, void *cmdbuf, unsigned int cmd_len, void *replybuf, int reply_len); +// returns UINT16_MAX on error uint16_t read_register(freenect_device *dev, uint16_t reg); int write_register(freenect_device *dev, uint16_t reg, uint16_t data); +// returns UINT16_MAX on error uint16_t read_cmos_register(freenect_device *dev, uint16_t reg); int write_cmos_register(freenect_device *dev, uint16_t reg, uint16_t value); From cc9ecfb78646168b0d99bd5e5635a7f0fd4ac5b7 Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Mon, 24 Feb 2014 21:42:09 -0500 Subject: [PATCH 46/84] ebuild: Print warning when bindist USE flag disabled. Signed-off-by: Benn Snyder --- platform/linux/portage/dev-libs/libfreenect/Manifest | 2 +- .../portage/dev-libs/libfreenect/libfreenect-9999.ebuild | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/platform/linux/portage/dev-libs/libfreenect/Manifest b/platform/linux/portage/dev-libs/libfreenect/Manifest index 291af3ed..5292a414 100644 --- a/platform/linux/portage/dev-libs/libfreenect/Manifest +++ b/platform/linux/portage/dev-libs/libfreenect/Manifest @@ -1 +1 @@ -EBUILD libfreenect-9999.ebuild 2121 SHA256 223618ff82ec043e8f65d977bc0297a1ba71d25658125b2f3aabbaaf51b361ac SHA512 2e6f0e484389b338b32a8ea8cdec652c3d03bcda106cd98484cdbf084ebd60497c5cb63dd1cbe0fb4566a2fc2efe2e9bc4053532dd5f7655249cc0803b84a090 WHIRLPOOL b0ea6afdf4c270113dda55684565a341c61c4568baff8457a66d74ccfa9e343cb73713247cbf12bb92f1f828524053ab89343bfc96feeddb629a279d2e1e41bf +EBUILD libfreenect-9999.ebuild 2118 SHA256 5606781a469e74de79fcbe620d81bdc2f221a52e85a5c3bd16eb2218d3789200 SHA512 f85d2658901d804202eb81d226f285dc753c1f8870d8d7ec553a0cef2d78fa30a9a789127cf278e03a35101fa7aa55967340f9907662e34c75a7420c3285fe9a WHIRLPOOL f3a5dd3a4c5cbe70a5b1ca98472bee71c9202b626c947275a7e7b449b1a17d91c18f1ff5b5075baa13fba797ac140a832a873662bd6e0d9adba8fa20f3852eff diff --git a/platform/linux/portage/dev-libs/libfreenect/libfreenect-9999.ebuild b/platform/linux/portage/dev-libs/libfreenect/libfreenect-9999.ebuild index 7b5b9529..d18c8ed7 100644 --- a/platform/linux/portage/dev-libs/libfreenect/libfreenect-9999.ebuild +++ b/platform/linux/portage/dev-libs/libfreenect/libfreenect-9999.ebuild @@ -66,8 +66,8 @@ src_install() { } pkg_postinst() { - if use bindist; then - ewarn "You have enabled the bindist USE flag. Resulting binaries may not be legal to re-distribute." + 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." From 4f4daa40cd4ef5d2b6ec4fd5ebad21b2f648736b Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Tue, 25 Feb 2014 01:07:58 -0500 Subject: [PATCH 47/84] Stop depth stream before destroying registration - fixes #373 Signed-off-by: Benn Snyder --- src/cameras.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cameras.c b/src/cameras.c index 99d387d9..722f8770 100644 --- a/src/cameras.c +++ b/src/cameras.c @@ -1048,7 +1048,6 @@ int freenect_stop_depth(freenect_device *dev) return -1; dev->depth.running = 0; - freenect_destroy_registration(&(dev->registration)); write_register(dev, 0x06, 0x00); // stop depth stream res = fnusb_stop_iso(&dev->usb_cam, &dev->depth_isoc); @@ -1057,6 +1056,7 @@ int freenect_stop_depth(freenect_device *dev) return res; } + freenect_destroy_registration(&(dev->registration)); stream_freebufs(ctx, &dev->depth); return 0; } From 867ca06763b184ccbaf23258cad98d0d9e2cfa63 Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Tue, 25 Feb 2014 01:25:28 -0500 Subject: [PATCH 48/84] OpenNI2-FreenectDriver: Mirror ColorStream in hardware Signed-off-by: Benn Snyder --- OpenNI2-FreenectDriver/src/ColorStream.cpp | 26 ++++------------------ OpenNI2-FreenectDriver/src/ColorStream.hpp | 11 +++++++++ 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/OpenNI2-FreenectDriver/src/ColorStream.cpp b/OpenNI2-FreenectDriver/src/ColorStream.cpp index dfbe0627..a30866c8 100644 --- a/OpenNI2-FreenectDriver/src/ColorStream.cpp +++ b/OpenNI2-FreenectDriver/src/ColorStream.cpp @@ -50,8 +50,9 @@ OniStatus ColorStream::setVideoMode(OniVideoMode requested_mode) void ColorStream::populateFrame(void* data, OniFrame* frame) const { frame->sensorType = sensor_type; - frame->stride = video_mode.resolutionX*3; - frame->cropOriginX = frame->cropOriginY = 0; + frame->stride = video_mode.resolutionX * 3; + frame->cropOriginX = 0; + frame->cropOriginY = 0; frame->croppingEnabled = FALSE; // copy stream buffer from freenect @@ -64,26 +65,7 @@ void ColorStream::populateFrame(void* data, OniFrame* frame) const case ONI_PIXEL_FORMAT_RGB888: unsigned char* data_ptr = static_cast(data); unsigned char* frame_data = static_cast(frame->data); - if (mirroring) - { - for (int i = 0; i < frame->dataSize; i += 3) - { - // find corresponding mirrored pixel - unsigned int pixel = i / 3; - unsigned int row = pixel / video_mode.resolutionX; - unsigned int col = video_mode.resolutionX - (pixel % video_mode.resolutionX); - unsigned int target = 3 * (row * video_mode.resolutionX + col); - // copy it to this pixel - frame_data[i] = data_ptr[target]; - frame_data[i+1] = data_ptr[target+1]; - frame_data[i+2] = data_ptr[target+2]; - } - } - else - { - std::copy(data_ptr, data_ptr+frame->dataSize, frame_data); - } - + std::copy(data_ptr, data_ptr + frame->dataSize, frame_data); return; } } diff --git a/OpenNI2-FreenectDriver/src/ColorStream.hpp b/OpenNI2-FreenectDriver/src/ColorStream.hpp index 1c657197..ee535f2b 100644 --- a/OpenNI2-FreenectDriver/src/ColorStream.hpp +++ b/OpenNI2-FreenectDriver/src/ColorStream.hpp @@ -139,6 +139,17 @@ namespace FreenectDriver int ret = device->setFlag(FREENECT_AUTO_WHITE_BALANCE, auto_exposure); return (ret == 0) ? ONI_STATUS_OK : ONI_STATUS_ERROR; } + case ONI_STREAM_PROPERTY_MIRRORING: // OniBool + { + if (dataSize != sizeof(OniBool)) + { + LogError("Unexpected size for ONI_STREAM_PROPERTY_MIRRORING"); + return ONI_STATUS_ERROR; + } + mirroring = *(static_cast(data)); + int ret = device->setFlag(FREENECT_MIRROR_VIDEO, mirroring); + return (ret == 0) ? ONI_STATUS_OK : ONI_STATUS_ERROR; + } } } }; From 62f0a0d580b222224118fa6cc63079ef5d8407e9 Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Wed, 26 Feb 2014 18:02:17 -0500 Subject: [PATCH 49/84] OpenNI2-FreenectDriver: Don't start streams before setting their formats Signed-off-by: Benn Snyder --- OpenNI2-FreenectDriver/src/DeviceDriver.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/OpenNI2-FreenectDriver/src/DeviceDriver.cpp b/OpenNI2-FreenectDriver/src/DeviceDriver.cpp index 1a3fac19..ebcb8397 100644 --- a/OpenNI2-FreenectDriver/src/DeviceDriver.cpp +++ b/OpenNI2-FreenectDriver/src/DeviceDriver.cpp @@ -72,12 +72,10 @@ namespace FreenectDriver LogError("Cannot create a stream of type " + to_string(sensorType)); return NULL; case ONI_SENSOR_COLOR: - Freenect::FreenectDevice::startVideo(); if (! color) color = new ColorStream(this); return color; case ONI_SENSOR_DEPTH: - Freenect::FreenectDevice::startDepth(); if (! depth) depth = new DepthStream(this); return depth; From 8cca12757824ee2277f7e8f238bbe96bb8e4b7cd Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Wed, 26 Feb 2014 19:02:08 -0500 Subject: [PATCH 50/84] OpenNI2-FreenectDriver: Move static and global symbols into Utility.hpp OpenNI2-FreenectDriver: Print libfreenect version when driver is loaded OpenNI2-FreenectDriver: Use explicitly-sized integers for buffers OpenNI2-FreenectDriver: 0-initialize structs Signed-off-by: Benn Snyder --- OpenNI2-FreenectDriver/CMakeLists.txt | 7 +- OpenNI2-FreenectDriver/src/ColorStream.cpp | 8 +-- OpenNI2-FreenectDriver/src/ColorStream.hpp | 2 +- OpenNI2-FreenectDriver/src/DepthStream.cpp | 19 +++--- OpenNI2-FreenectDriver/src/DepthStream.hpp | 2 +- OpenNI2-FreenectDriver/src/DeviceDriver.cpp | 4 +- OpenNI2-FreenectDriver/src/Utility.hpp | 74 +++++++++++++++++++++ OpenNI2-FreenectDriver/src/VideoStream.hpp | 59 ++-------------- 8 files changed, 104 insertions(+), 71 deletions(-) create mode 100644 OpenNI2-FreenectDriver/src/Utility.hpp diff --git a/OpenNI2-FreenectDriver/CMakeLists.txt b/OpenNI2-FreenectDriver/CMakeLists.txt index c0f5532e..9eeca908 100644 --- a/OpenNI2-FreenectDriver/CMakeLists.txt +++ b/OpenNI2-FreenectDriver/CMakeLists.txt @@ -2,17 +2,20 @@ # OpenNI2-FreenectDriver ###################################################################################### +file(GLOB HEADERS src/*.hpp src/*.h) file(GLOB SOURCES src/*.cpp) -add_library(FreenectDriver SHARED ${SOURCES}) +add_library(FreenectDriver SHARED ${HEADERS} ${SOURCES}) set(CMAKE_CXX_FLAGS "-Wno-gnu-static-float-init -Wno-unused-function") set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib/OpenNI2-FreenectDriver) -set_target_properties( FreenectDriver PROPERTIES +set_target_properties(FreenectDriver PROPERTIES VERSION ${PROJECT_VER} SOVERSION ${PROJECT_APIVER} OUTPUT_NAME FreenectDriver) +add_definitions(-DPROJECT_VER="${PROJECT_VER}") + include_directories(extern/OpenNI-Linux-x64-2.2.0.33/Include) include_directories(${PROJECT_SOURCE_DIR}/wrappers/cpp) diff --git a/OpenNI2-FreenectDriver/src/ColorStream.cpp b/OpenNI2-FreenectDriver/src/ColorStream.cpp index a30866c8..fc9bf12a 100644 --- a/OpenNI2-FreenectDriver/src/ColorStream.cpp +++ b/OpenNI2-FreenectDriver/src/ColorStream.cpp @@ -53,7 +53,7 @@ void ColorStream::populateFrame(void* data, OniFrame* frame) const frame->stride = video_mode.resolutionX * 3; frame->cropOriginX = 0; frame->cropOriginY = 0; - frame->croppingEnabled = FALSE; + frame->croppingEnabled = false; // copy stream buffer from freenect switch (video_mode.pixelFormat) @@ -63,9 +63,9 @@ void ColorStream::populateFrame(void* data, OniFrame* frame) const return; case ONI_PIXEL_FORMAT_RGB888: - unsigned char* data_ptr = static_cast(data); - unsigned char* frame_data = static_cast(frame->data); - std::copy(data_ptr, data_ptr + frame->dataSize, frame_data); + uint8_t* source = static_cast(data); + uint8_t* target = static_cast(frame->data); + std::copy(source, source + frame->dataSize, target); return; } } diff --git a/OpenNI2-FreenectDriver/src/ColorStream.hpp b/OpenNI2-FreenectDriver/src/ColorStream.hpp index ee535f2b..daf38bec 100644 --- a/OpenNI2-FreenectDriver/src/ColorStream.hpp +++ b/OpenNI2-FreenectDriver/src/ColorStream.hpp @@ -36,7 +36,7 @@ namespace FreenectDriver { FreenectVideoModeMap supported_modes = getSupportedVideoModes(); OniVideoMode* modes = new OniVideoMode[supported_modes.size()]; - std::transform(supported_modes.begin(), supported_modes.end(), modes, RetrieveKey()); + std::transform(supported_modes.begin(), supported_modes.end(), modes, ExtractKey()); OniSensorInfo sensors = { sensor_type, static_cast(supported_modes.size()), modes }; return sensors; } diff --git a/OpenNI2-FreenectDriver/src/DepthStream.cpp b/OpenNI2-FreenectDriver/src/DepthStream.cpp index a2cca0e3..cc4f7141 100644 --- a/OpenNI2-FreenectDriver/src/DepthStream.cpp +++ b/OpenNI2-FreenectDriver/src/DepthStream.cpp @@ -57,23 +57,26 @@ void DepthStream::populateFrame(void* data, OniFrame* frame) const frame->sensorType = sensor_type; frame->stride = video_mode.resolutionX * sizeof(uint16_t); - if (cropping.enabled) { + if (cropping.enabled) + { frame->height = cropping.height; frame->width = cropping.width; frame->cropOriginX = cropping.originX; frame->cropOriginY = cropping.originY; frame->croppingEnabled = true; } - else { - frame->cropOriginX = frame->cropOriginY = 0; + else + { + frame->cropOriginX = 0; + frame->cropOriginY = 0; frame->croppingEnabled = false; } // copy stream buffer from freenect - unsigned short* source = static_cast(data) + frame->cropOriginX + frame->cropOriginY * video_mode.resolutionX; - unsigned short* target = static_cast(frame->data); + uint16_t* source = static_cast(data) + frame->cropOriginX + frame->cropOriginY * video_mode.resolutionX; + uint16_t* target = static_cast(frame->data); const unsigned int skipWidth = video_mode.resolutionX - frame->width; if (mirroring) @@ -84,8 +87,7 @@ void DepthStream::populateFrame(void* data, OniFrame* frame) const { for (int x = 0; x < frame->width; x++) { - unsigned short value = *(source++); - *(target--) = value < DepthStream::MAX_VALUE ? value : 0; + *target-- = *source++; } source += skipWidth; @@ -98,8 +100,7 @@ void DepthStream::populateFrame(void* data, OniFrame* frame) const { for (int x = 0; x < frame->width; x++) { - unsigned short value = *(source++); - *(target++) = value < DepthStream::MAX_VALUE ? value : 0; + *target++ = *source++; } source += skipWidth; diff --git a/OpenNI2-FreenectDriver/src/DepthStream.hpp b/OpenNI2-FreenectDriver/src/DepthStream.hpp index be60a195..303449ec 100644 --- a/OpenNI2-FreenectDriver/src/DepthStream.hpp +++ b/OpenNI2-FreenectDriver/src/DepthStream.hpp @@ -48,7 +48,7 @@ namespace FreenectDriver { FreenectDepthModeMap supported_modes = getSupportedVideoModes(); OniVideoMode* modes = new OniVideoMode[supported_modes.size()]; - std::transform(supported_modes.begin(), supported_modes.end(), modes, RetrieveKey()); + std::transform(supported_modes.begin(), supported_modes.end(), modes, ExtractKey()); OniSensorInfo sensors = { sensor_type, static_cast(supported_modes.size()), modes }; return sensors; } diff --git a/OpenNI2-FreenectDriver/src/DeviceDriver.cpp b/OpenNI2-FreenectDriver/src/DeviceDriver.cpp index ebcb8397..c308b463 100644 --- a/OpenNI2-FreenectDriver/src/DeviceDriver.cpp +++ b/OpenNI2-FreenectDriver/src/DeviceDriver.cpp @@ -22,8 +22,6 @@ #include "ColorStream.hpp" -static bool operator<(const OniDeviceInfo& left, const OniDeviceInfo& right) { return (strcmp(left.uri, right.uri) < 0); } // for std::map - namespace FreenectDriver { class Device : public oni::driver::DeviceBase, public Freenect::FreenectDevice @@ -217,6 +215,8 @@ namespace FreenectDriver public: Driver(OniDriverServices* pDriverServices) : DriverBase(pDriverServices) { + WriteMessage("Using libfreenect v" + to_string(PROJECT_VER)); + freenect_set_log_level(m_ctx, FREENECT_LOG_DEBUG); freenect_select_subdevices(m_ctx, FREENECT_DEVICE_CAMERA); // OpenNI2 doesn't use MOTOR or AUDIO DriverServices = &getServices(); diff --git a/OpenNI2-FreenectDriver/src/Utility.hpp b/OpenNI2-FreenectDriver/src/Utility.hpp new file mode 100644 index 00000000..531be112 --- /dev/null +++ b/OpenNI2-FreenectDriver/src/Utility.hpp @@ -0,0 +1,74 @@ +// This file contains symbols that may be used by any class or don't really go anywhere else. +#pragma once + +#include +#include "Driver/OniDriverAPI.h" + + +// Oni helpers + +static OniVideoMode makeOniVideoMode(OniPixelFormat pixel_format, int resolution_x, int resolution_y, int frames_per_second) +{ + OniVideoMode mode; + mode.pixelFormat = pixel_format; + mode.resolutionX = resolution_x; + mode.resolutionY = resolution_y; + mode.fps = frames_per_second; + return mode; +} +static bool operator==(const OniVideoMode& left, const OniVideoMode& right) +{ + return (left.pixelFormat == right.pixelFormat && left.resolutionX == right.resolutionX + && left.resolutionY == right.resolutionY && left.fps == right.fps); +} +static bool operator<(const OniVideoMode& left, const OniVideoMode& right) +{ + return (left.resolutionX * left.resolutionY < right.resolutionX * right.resolutionY); +} + +static bool operator<(const OniDeviceInfo& left, const OniDeviceInfo& right) +{ + return (strcmp(left.uri, right.uri) < 0); +} + + +/// Extracts `first` from `pair`, for transforming a map into its keys. +struct ExtractKey +{ + template typename T::first_type + operator()(T pair) const + { + return pair.first; + } +}; + + +// holding out on C++11 +template +static std::string to_string(const T& n) +{ + std::ostringstream oss; + oss << n; + return oss.str(); +} + + +// global logging +namespace FreenectDriver +{ + static void WriteMessage(std::string info) + { + std::cout << "OpenNI2-FreenectDriver: " << info << std::endl; + } + + // DriverServices is set in DeviceDriver.cpp so all files can call errorLoggerAppend() + static oni::driver::DriverServices* DriverServices; + static void LogError(std::string error) + { + // errorLoggerAppend() doesn't seem to go anywhere, so WriteMessage also + WriteMessage("(ERROR) " + error); + + if (DriverServices != NULL) + DriverServices->errorLoggerAppend(std::string("OpenNI2-FreenectDriver: " + error).c_str()); + } +} diff --git a/OpenNI2-FreenectDriver/src/VideoStream.hpp b/OpenNI2-FreenectDriver/src/VideoStream.hpp index 980f6173..0823e7e7 100644 --- a/OpenNI2-FreenectDriver/src/VideoStream.hpp +++ b/OpenNI2-FreenectDriver/src/VideoStream.hpp @@ -1,62 +1,12 @@ #pragma once -#include #include "libfreenect.hpp" -#include "Driver/OniDriverAPI.h" #include "PS1080.h" +#include "Utility.hpp" -struct RetrieveKey -{ - template typename T::first_type - operator()(T pair) const { - return pair.first; - } -}; - -// "extension constructor" for OniVideoMode struct -static OniVideoMode makeOniVideoMode(OniPixelFormat pixel_format, int resolution_x, int resolution_y, int frames_per_second) -{ - OniVideoMode mode; - mode.pixelFormat = pixel_format; - mode.resolutionX = resolution_x; - mode.resolutionY = resolution_y; - mode.fps = frames_per_second; - return mode; -} - -static bool operator==(const OniVideoMode& left, const OniVideoMode& right) -{ - return (left.pixelFormat == right.pixelFormat && left.resolutionX == right.resolutionX - && left.resolutionY == right.resolutionY && left.fps == right.fps); -} -static bool operator<(const OniVideoMode& left, const OniVideoMode& right) { return (left.resolutionX*left.resolutionY < right.resolutionX*right.resolutionY); } - namespace FreenectDriver { - template < typename T > std::string to_string(const T& n) - { - std::ostringstream oss; - oss << n; - return oss.str(); - } - - static void WriteMessage(std::string info) - { - std::cout << "OpenNI2-FreenectDriver: " << info << std::endl; - } - - // DriverServices is set in DeviceDriver.cpp so all files can call errorLoggerAppend() - static oni::driver::DriverServices* DriverServices; - static void LogError(std::string error) - { - // errorLoggerAppend() doesn't seem to go anywhere, so call WriteMessage also - WriteMessage("(ERROR) " + error); - - if (DriverServices != NULL) - DriverServices->errorLoggerAppend(std::string("OpenNI2-FreenectDriver: " + error).c_str()); - } - class VideoStream : public oni::driver::StreamBase { private: @@ -77,7 +27,12 @@ namespace FreenectDriver VideoStream(Freenect::FreenectDevice* device) : frame_id(1), device(device), - mirroring(false) { } + mirroring(false) + { + // joy of structs + memset(&cropping, 0, sizeof(cropping)); + memset(&video_mode, 0, sizeof(video_mode)); + } //~VideoStream() { stop(); } void buildFrame(void* data, uint32_t timestamp) From 0cbb86ec982d3e79ad5efa9d1b2b16724ae89bc5 Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Sat, 22 Mar 2014 16:06:09 -0400 Subject: [PATCH 51/84] Stop clobbering CFLAGS FN_DEBUG: lost packets per frame (lppf) Signed-off-by: Benn Snyder --- CMakeLists.txt | 21 ++++++++++++--------- examples/CMakeLists.txt | 2 -- src/CMakeLists.txt | 2 -- src/cameras.c | 6 ++++++ src/freenect_internal.h | 1 + wrappers/cpp/CMakeLists.txt | 2 -- 6 files changed, 19 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 034d5bc6..7b8edaf1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -100,15 +100,18 @@ SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin) SET(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib) SET(DOC_OUTPUT_PATH ${CMAKE_BINARY_DIR}/doc) -# let CFLAGS env override this -if(CMAKE_C_FLAGS STREQUAL "") - set(CMAKE_C_FLAGS "-O2") -endif() -SET(CMAKE_C_FLAGS_DEBUG "-g -DDEBUG=1") -SET(CMAKE_C_FLAGS_RELEASE "-O2") -SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g") - -add_definitions(-Wall) +if (MSVC) + set(C_FLAGS_WARNING "-W4") +else () + set(C_FLAGS_WARNING "-Wall") +endif (MSVC) + +# These defaults can be overriden by environment CFLAGS +set(CMAKE_C_FLAGS "-O2 ${C_FLAGS_WARNING} ${CMAKE_C_FLAGS}") +# Configurations +SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -g -DDEBUG=1") +SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS}") +SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELEASE} -g") # Pretty much everyone is going to need the main includes include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 130afe63..26adbdec 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -2,8 +2,6 @@ # Packages needed for examples ###################################################################################### -set(CMAKE_C_FLAGS "-Wall") - if (WIN32) set_source_files_properties(glview.c PROPERTIES LANGUAGE CXX) set_source_files_properties(regview.c PROPERTIES LANGUAGE CXX) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4faa6775..1150666f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -4,8 +4,6 @@ include_directories (${CMAKE_CURRENT_SOURCE_DIR}) -set(CMAKE_C_FLAGS "-Wall") - include_directories(${LIBUSB_1_INCLUDE_DIRS}) LIST(APPEND SRC core.c tilt.c cameras.c flags.c usb_libusb10.c registration.c keep_alive.c) IF(WIN32) diff --git a/src/cameras.c b/src/cameras.c index 722f8770..428dc12f 100644 --- a/src/cameras.c +++ b/src/cameras.c @@ -129,7 +129,12 @@ static int stream_process(freenect_context *ctx, packet_stream *strm, uint8_t *p // handle lost packets if (strm->seq != hdr->seq) { uint8_t lost = hdr->seq - strm->seq; + strm->lost_pkts += lost; FN_LOG(l_info, "[Stream %02x] Lost %d packets\n", strm->flag, lost); + + FN_DEBUG("[Stream %02x] Lost %d total packets in %d frames (%f lppf)\n", + strm->flag, strm->lost_pkts, strm->valid_frames, (float)strm->lost_pkts / strm->valid_frames); + if (lost > 5 || strm->variable_length) { FN_LOG(l_notice, "[Stream %02x] Lost too many packets, resyncing...\n", strm->flag); strm->synced = 0; @@ -219,6 +224,7 @@ static int stream_process(freenect_context *ctx, packet_stream *strm, uint8_t *p strm->timestamp = strm->last_timestamp; strm->valid_frames++; } + return got_frame_size; } diff --git a/src/freenect_internal.h b/src/freenect_internal.h index 44d2f055..4b26c419 100644 --- a/src/freenect_internal.h +++ b/src/freenect_internal.h @@ -159,6 +159,7 @@ typedef struct { int frame_size; int last_pkt_size; int valid_pkts; + uint lost_pkts; int valid_frames; int variable_length; uint32_t last_timestamp; diff --git a/wrappers/cpp/CMakeLists.txt b/wrappers/cpp/CMakeLists.txt index 09a91400..92110d57 100644 --- a/wrappers/cpp/CMakeLists.txt +++ b/wrappers/cpp/CMakeLists.txt @@ -3,8 +3,6 @@ INSTALL(FILES libfreenect.hpp IF(BUILD_EXAMPLES) -set(CMAKE_C_FLAGS "-Wall") - if (WIN32) set(THREADS_USE_PTHREADS_WIN32 true) find_package(Threads REQUIRED) From 2ad7a57b0c2fc168a6470ef791c66ffc835f466f Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Sat, 22 Mar 2014 18:53:25 -0400 Subject: [PATCH 52/84] examples: Add build dependencies - fixes #237 Signed-off-by: Benn Snyder --- examples/CMakeLists.txt | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 26adbdec..c07f4a7d 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -2,24 +2,25 @@ # Packages needed for examples ###################################################################################### -if (WIN32) - set_source_files_properties(glview.c PROPERTIES LANGUAGE CXX) - set_source_files_properties(regview.c PROPERTIES LANGUAGE CXX) - set_source_files_properties(glpclview.c PROPERTIES LANGUAGE CXX) - set_source_files_properties(hiview.c PROPERTIES LANGUAGE CXX) - set_source_files_properties(tiltdemo.c PROPERTIES LANGUAGE CXX) - set_source_files_properties(chunkview.c PROPERTIES LANGUAGE CXX) +# todo: use these throughout +file(GLOB SRC_STANDARD chunkview.c glview.c hiview.c regview.c) +file(GLOB SRC_AUDIO micview.c wavrecord.c) +file(GLOB SRC_SYNC glpclview.c regtest.c tiltdemo.c) +set (SRC_ALL ${SRC_STANDARD} ${SRC_AUDIO} ${SRC_SYNC}) +if (WIN32) set(THREADS_USE_PTHREADS_WIN32 true) find_package(Threads REQUIRED) - include_directories(${THREADS_PTHREADS_INCLUDE_DIR}) + + set_source_file_properties(${SRC_ALL} PROPERTIES LANGUAGE CXX) endif() add_executable(freenect-glview glview.c) add_executable(freenect-regview regview.c) add_executable(freenect-hiview hiview.c) add_executable(freenect-chunkview chunkview.c) + if(BUILD_AUDIO) add_executable(freenect-wavrecord wavrecord.c) add_executable(freenect-micview micview.c) @@ -29,6 +30,9 @@ if (BUILD_C_SYNC) add_executable(freenect-glpclview glpclview.c) add_executable(freenect-tiltdemo tiltdemo.c) add_executable(freenect-regtest regtest.c) + + add_dependencies(freenect-glpclview freenect-tiltdemo freenect-regtest + freenect_sync) endif() # We need to include libfreenect_sync.h for glpclview From 3b74e9c30c962eb3f340d65742c50e791f0e4ee7 Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Sat, 22 Mar 2014 19:00:11 -0400 Subject: [PATCH 53/84] wrappers/cpp: Call setVideoFormat() in constructor so getVideoFormat() return valid format - fixes #308 Signed-off-by: Benn Snyder --- wrappers/cpp/libfreenect.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wrappers/cpp/libfreenect.hpp b/wrappers/cpp/libfreenect.hpp index 1cc1568e..fd267ce1 100644 --- a/wrappers/cpp/libfreenect.hpp +++ b/wrappers/cpp/libfreenect.hpp @@ -67,8 +67,8 @@ namespace Freenect { { if(freenect_open_device(_ctx, &m_dev, _index) < 0) throw std::runtime_error("Cannot open Kinect"); freenect_set_user(m_dev, this); - freenect_set_video_mode(m_dev, freenect_find_video_mode(FREENECT_RESOLUTION_MEDIUM, FREENECT_VIDEO_RGB)); - freenect_set_depth_mode(m_dev, freenect_find_depth_mode(FREENECT_RESOLUTION_MEDIUM, FREENECT_DEPTH_11BIT)); + setVideoFormat(FREENECT_VIDEO_RGB, FREENECT_RESOLUTION_MEDIUM); + setDepthFormat(FREENECT_DEPTH_11BIT, FREENECT_RESOLUTION_MEDIUM); freenect_set_depth_callback(m_dev, freenect_depth_callback); freenect_set_video_callback(m_dev, freenect_video_callback); } From 8c59ba29b0f90cc69788e2f71afd132ef3bd8047 Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Sat, 22 Mar 2014 19:14:40 -0400 Subject: [PATCH 54/84] wrappers/c_sync: Add dllexport to sync API - fixes #315 Signed-off-by: Benn Snyder --- wrappers/c_sync/libfreenect_sync.h | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/wrappers/c_sync/libfreenect_sync.h b/wrappers/c_sync/libfreenect_sync.h index 568e59cf..516c421d 100644 --- a/wrappers/c_sync/libfreenect_sync.h +++ b/wrappers/c_sync/libfreenect_sync.h @@ -28,11 +28,26 @@ #include "libfreenect.h" #include + +/// If Win32, export all functions for DLL usage +#ifndef _WIN32 + #define FREENECTAPI_SYNC /**< DLLExport information for windows, set to nothing on other platforms */ +#else + /**< DLLExport information for windows, set to nothing on other platforms */ + #ifdef __cplusplus + #define FREENECTAPI_SYNC extern "C" __declspec(dllexport) + #else + // this is required when building from a Win32 port of gcc without being + // forced to compile all of the library files (.c) with g++... + #define FREENECTAPI_SYNC __declspec(dllexport) + #endif +#endif + #ifdef __cplusplus extern "C" { #endif -int freenect_sync_get_video(void **video, uint32_t *timestamp, int index, freenect_video_format fmt); +FREENECTAPI_SYNC int freenect_sync_get_video(void **video, uint32_t *timestamp, int index, freenect_video_format fmt); /* Synchronous video function, starts the runloop if it isn't running The returned buffer is valid until this function is called again, after which the buffer must not @@ -49,7 +64,7 @@ int freenect_sync_get_video(void **video, uint32_t *timestamp, int index, freene */ -int freenect_sync_get_depth(void **depth, uint32_t *timestamp, int index, freenect_depth_format fmt); +FREENECTAPI_SYNC int freenect_sync_get_depth(void **depth, uint32_t *timestamp, int index, freenect_depth_format fmt); /* Synchronous depth function, starts the runloop if it isn't running The returned buffer is valid until this function is called again, after which the buffer must not @@ -65,7 +80,7 @@ int freenect_sync_get_depth(void **depth, uint32_t *timestamp, int index, freene Nonzero on error. */ -int freenect_sync_set_tilt_degs(int angle, int index); +FREENECTAPI_SYNC int freenect_sync_set_tilt_degs(int angle, int index); /* Tilt function, starts the runloop if it isn't running Args: @@ -76,7 +91,7 @@ int freenect_sync_set_tilt_degs(int angle, int index); Nonzero on error. */ -int freenect_sync_get_tilt_state(freenect_raw_tilt_state **state, int index); +FREENECTAPI_SYNC int freenect_sync_get_tilt_state(freenect_raw_tilt_state **state, int index); /* Tilt state function, starts the runloop if it isn't running Args: @@ -87,7 +102,7 @@ int freenect_sync_get_tilt_state(freenect_raw_tilt_state **state, int index); Nonzero on error. */ -int freenect_sync_set_led(freenect_led_options led, int index); +FREENECTAPI_SYNC int freenect_sync_set_led(freenect_led_options led, int index); /* Led function, starts the runloop if it isn't running Args: @@ -99,7 +114,7 @@ int freenect_sync_set_led(freenect_led_options led, int index); */ -void freenect_sync_stop(void); +FREENECTAPI_SYNC void freenect_sync_stop(void); #ifdef __cplusplus } #endif From 26c2358f115fe379c71c363bca6b94cdd062ecbf Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Sat, 22 Mar 2014 19:45:44 -0400 Subject: [PATCH 55/84] Update CMakeLists.txt for v0.4.1 Signed-off-by: Benn Snyder --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7b8edaf1..8747291a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,7 +41,7 @@ PROJECT(libfreenect) set (PROJECT_VER_MAJOR 0) set (PROJECT_VER_MINOR 4) -set (PROJECT_VER_PATCH 0) +set (PROJECT_VER_PATCH 1) set (PROJECT_VER "${PROJECT_VER_MAJOR}.${PROJECT_VER_MINOR}.${PROJECT_VER_PATCH}") set (PROJECT_APIVER From de79349de52e0458da38f3eaa721f2ca4b45ff29 Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Sat, 22 Mar 2014 20:33:43 -0400 Subject: [PATCH 56/84] wrappers/cpp: Do not start stopped streams when setting formats Signed-off-by: Benn Snyder --- OpenNI2-FreenectDriver/src/ColorStream.cpp | 1 + OpenNI2-FreenectDriver/src/DepthStream.cpp | 1 + wrappers/cpp/libfreenect.hpp | 10 ++++++---- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/OpenNI2-FreenectDriver/src/ColorStream.cpp b/OpenNI2-FreenectDriver/src/ColorStream.cpp index fc9bf12a..6ac7444d 100644 --- a/OpenNI2-FreenectDriver/src/ColorStream.cpp +++ b/OpenNI2-FreenectDriver/src/ColorStream.cpp @@ -8,6 +8,7 @@ ColorStream::ColorStream(Freenect::FreenectDevice* pDevice) : VideoStream(pDevic { video_mode = makeOniVideoMode(ONI_PIXEL_FORMAT_RGB888, 640, 480, 30); setVideoMode(video_mode); + pDevice->startVideo(); } // Add video modes here as you implement them diff --git a/OpenNI2-FreenectDriver/src/DepthStream.cpp b/OpenNI2-FreenectDriver/src/DepthStream.cpp index cc4f7141..7159003d 100644 --- a/OpenNI2-FreenectDriver/src/DepthStream.cpp +++ b/OpenNI2-FreenectDriver/src/DepthStream.cpp @@ -9,6 +9,7 @@ DepthStream::DepthStream(Freenect::FreenectDevice* pDevice) : VideoStream(pDevic video_mode = makeOniVideoMode(ONI_PIXEL_FORMAT_DEPTH_1_MM, 640, 480, 30); image_registration_mode = ONI_IMAGE_REGISTRATION_OFF; setVideoMode(video_mode); + pDevice->startDepth(); } // Add video modes here as you implement them diff --git a/wrappers/cpp/libfreenect.hpp b/wrappers/cpp/libfreenect.hpp index fd267ce1..21498228 100644 --- a/wrappers/cpp/libfreenect.hpp +++ b/wrappers/cpp/libfreenect.hpp @@ -101,11 +101,12 @@ 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) { - freenect_stop_video(m_dev); + bool wasRunning = (freenect_stop_video(m_dev) >= 0); 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"); - freenect_start_video(m_dev); + if (wasRunning) + freenect_start_video(m_dev); m_video_format = requested_format; m_video_resolution = requested_resolution; } @@ -118,11 +119,12 @@ namespace Freenect { } void setDepthFormat(freenect_depth_format requested_format, freenect_resolution requested_resolution = FREENECT_RESOLUTION_MEDIUM) { if (requested_format != m_depth_format || requested_resolution != m_depth_resolution) { - freenect_stop_depth(m_dev); + bool wasRunning = (freenect_stop_depth(m_dev) >= 0); freenect_frame_mode mode = freenect_find_depth_mode(requested_resolution, requested_format); if (!mode.is_valid) throw std::runtime_error("Cannot set depth format: invalid mode"); if (freenect_set_depth_mode(m_dev, mode) < 0) throw std::runtime_error("Cannot set depth format"); - freenect_start_depth(m_dev); + if (wasRunning) + freenect_start_depth(m_dev); m_depth_format = requested_format; m_depth_resolution = requested_resolution; } From bd9e41bffd4e9e25c220d06745724fd060ff9fa0 Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Sun, 23 Mar 2014 10:28:33 -0400 Subject: [PATCH 57/84] Remove directory prefix from #include - fixes #379 Signed-off-by: Benn Snyder --- src/keep_alive.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/keep_alive.c b/src/keep_alive.c index ca85f8f0..3e372775 100644 --- a/src/keep_alive.c +++ b/src/keep_alive.c @@ -58,14 +58,10 @@ * those of the authors and should not be interpreted as representing official * policies, either expressed or implied, of Drew Fisher. */ - - - - #include "keep_alive.h" #include "freenect_internal.h" -#include +#include #include #include #include From cb0254a10dbeae8bdb8095d390b4ff69a2becc6e Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Sun, 23 Mar 2014 16:04:19 -0400 Subject: [PATCH 58/84] Add default CMAKE_CXX_FLAGS OpenNI2-FreenectDriver: Stop clobbering CXXFLAGS Signed-off-by: Benn Snyder --- CMakeLists.txt | 18 +++++++++++++----- OpenNI2-FreenectDriver/CMakeLists.txt | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8747291a..f39c1203 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,7 +62,7 @@ IF(PROJECT_OS_LINUX) ENDIF(PROJECT_OS_LINUX) ###################################################################################### -# CMake Modules +# Dependencies and Definitions ###################################################################################### set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/") @@ -106,13 +106,22 @@ else () set(C_FLAGS_WARNING "-Wall") endif (MSVC) -# These defaults can be overriden by environment CFLAGS -set(CMAKE_C_FLAGS "-O2 ${C_FLAGS_WARNING} ${CMAKE_C_FLAGS}") -# Configurations +set(C_CXX_FLAGS_DEFAULT "${C_FLAGS_WARNING} -O2") + +# These defaults can be overriden by -DCMAKE_C_FLAGS="" +set(CMAKE_C_FLAGS "${C_CXX_FLAGS_DEFAULT} ${CMAKE_C_FLAGS}") +# C Configurations SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -g -DDEBUG=1") SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS}") SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELEASE} -g") +# These defaults can be overriden by -DCMAKE_CXX_FLAGS="" +set(CMAKE_CXX_FLAGS "${C_CXX_FLAGS_DEFAULT} ${CMAKE_CXX_FLAGS}") +# C++ Configurations +SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -g -DDEBUG=1") +SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS}") +SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELEASE} -g") + # Pretty much everyone is going to need the main includes include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include) @@ -127,7 +136,6 @@ endif() # Add library project add_subdirectory (src) -# Add examples IF(BUILD_EXAMPLES) add_subdirectory (examples) ENDIF() diff --git a/OpenNI2-FreenectDriver/CMakeLists.txt b/OpenNI2-FreenectDriver/CMakeLists.txt index 9eeca908..a1be114a 100644 --- a/OpenNI2-FreenectDriver/CMakeLists.txt +++ b/OpenNI2-FreenectDriver/CMakeLists.txt @@ -6,7 +6,7 @@ file(GLOB HEADERS src/*.hpp src/*.h) file(GLOB SOURCES src/*.cpp) add_library(FreenectDriver SHARED ${HEADERS} ${SOURCES}) -set(CMAKE_CXX_FLAGS "-Wno-gnu-static-float-init -Wno-unused-function") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-function") set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib/OpenNI2-FreenectDriver) set_target_properties(FreenectDriver PROPERTIES From 935a998f13ce377cd8f4c2c13e2d1cbf0bde8e1a Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Mon, 14 Apr 2014 20:47:37 -0400 Subject: [PATCH 59/84] Install libraries to lib and let platform symlinks determine actual location - fixes #382 Signed-off-by: Benn Snyder --- cmake_modules/SetupDirectories.cmake | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/cmake_modules/SetupDirectories.cmake b/cmake_modules/SetupDirectories.cmake index 0ae7de5a..9c8c5094 100644 --- a/cmake_modules/SetupDirectories.cmake +++ b/cmake_modules/SetupDirectories.cmake @@ -5,21 +5,11 @@ ELSE (PROJECT_OS_WIN) SET (CMAKE_INSTALL_PREFIX "/usr/local" CACHE PATH "Installation directory") ENDIF (PROJECT_OS_WIN) -MESSAGE (STATUS "${PROJECT_NAME} will be installed to ${CMAKE_INSTALL_PREFIX}") - -# Installation prefix for include files STRING (TOLOWER ${PROJECT_NAME} projectNameLower) SET (PROJECT_INCLUDE_INSTALL_DIR "include/${projectNameLower}") SET (PROJECT_MANPAGE_INSTALL_DIR "share/man") +SET (PROJECT_LIBRARY_INSTALL_DIR "lib") -IF (PROJECT_PROC_64BIT) - SET (LIB_SUFFIX "64" CACHE STRING "Suffix for library installation directory") -ELSE (PROJECT_PROC_64BIT) - SET (LIB_SUFFIX "" CACHE STRING "Suffix for library installation directory") -ENDIF (PROJECT_PROC_64BIT) - -SET (PROJECT_LIBRARY_INSTALL_DIR "lib${LIB_SUFFIX}") - +MESSAGE (STATUS "${PROJECT_NAME} will be installed to ${CMAKE_INSTALL_PREFIX}") MESSAGE (STATUS "Headers will be installed to ${CMAKE_INSTALL_PREFIX}/${PROJECT_INCLUDE_INSTALL_DIR}") MESSAGE (STATUS "Libraries will be installed to ${CMAKE_INSTALL_PREFIX}/${PROJECT_LIBRARY_INSTALL_DIR}") - From dafe01e81fc4642cc41e5731d5f0c4696b738b38 Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Mon, 14 Apr 2014 21:51:30 -0400 Subject: [PATCH 60/84] win32: Core project compiles with VS 2012 and gcc-4.7.3 Signed-off-by: Benn Snyder --- CMakeLists.txt | 3 +- fakenect/CMakeLists.txt | 2 +- fakenect/fakenect.c | 46 ++---------------------- fakenect/platform.h | 75 +++++++++++++++++++++++++++++++++++++++ fakenect/record.c | 22 +++++------- platform/windows/unistd.h | 8 ++--- src/CMakeLists.txt | 1 - src/usb_libusb10.c | 2 +- 8 files changed, 92 insertions(+), 67 deletions(-) create mode 100644 fakenect/platform.h diff --git a/CMakeLists.txt b/CMakeLists.txt index f39c1203..28a480d7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -87,7 +87,7 @@ if(BUILD_AUDIO) endif() if (WIN32) - set(MATH_LIB "") + set(MATH_LIB "") else(WIN32) set(MATH_LIB "m") endif() @@ -130,7 +130,6 @@ include_directories(${LIBUSB_1_INCLUDE_DIRS}) if(WIN32) include_directories("${CMAKE_CURRENT_SOURCE_DIR}/platform/windows") - include_directories("${CMAKE_CURRENT_SOURCE_DIR}/platform/windows/libusb10emu/libusb-1.0") endif() # Add library project diff --git a/fakenect/CMakeLists.txt b/fakenect/CMakeLists.txt index bc156309..f1e36e39 100644 --- a/fakenect/CMakeLists.txt +++ b/fakenect/CMakeLists.txt @@ -14,7 +14,7 @@ install (TARGETS fakenect DESTINATION "${PROJECT_LIBRARY_INSTALL_DIR}/fakenect") add_executable(fakenect-record record.c) -target_link_libraries(fakenect-record freenect m) +target_link_libraries(fakenect-record freenect ${MATH_LIB}) install (TARGETS fakenect-record DESTINATION bin) diff --git a/fakenect/fakenect.c b/fakenect/fakenect.c index 32a03307..65eceac0 100644 --- a/fakenect/fakenect.c +++ b/fakenect/fakenect.c @@ -24,16 +24,13 @@ */ #include "libfreenect.h" +#include "platform.h" #include #include #include #include #include -#include #include -#ifdef _WIN32 -#include -#endif #define GRAVITY 9.80665 @@ -45,7 +42,7 @@ static freenect_depth_cb cur_depth_cb = NULL; static freenect_video_cb cur_rgb_cb = NULL; static char *input_path = NULL; static FILE *index_fp = NULL; -static freenect_raw_tilt_state state = {}; +static freenect_raw_tilt_state state = { 0 }; static int already_warned = 0; static double playback_prev_time = 0.; static double record_prev_time = 0.; @@ -55,45 +52,6 @@ static int depth_running = 0; static int rgb_running = 0; static void *user_ptr = NULL; -static void sleep_highres(double tm) -{ -#ifdef _WIN32 - int msec = floor(tm * 1000); - if (msec > 0) { - Sleep(msec); - } -#else - int sec = floor(tm); - int usec = (tm - sec) * 1000000; - if (tm > 0) { - sleep(sec); - usleep(usec); - } -#endif -} - -static double get_time() -{ -#ifdef _WIN32 - SYSTEMTIME st; - GetSystemTime(&st); - FILETIME ft; - SystemTimeToFileTime(&st, &ft); - ULARGE_INTEGER li; - li.LowPart = ft.dwLowDateTime; - li.HighPart = ft.dwHighDateTime; - // FILETIME is given as a 64-bit value for the number of 100-nanosecond - // intervals that have passed since Jan 1, 1601 (UTC). The difference between that - // epoch and the POSIX epoch (Jan 1, 1970) is 116444736000000000 such ticks. - uint64_t total_usecs = (li.QuadPart - 116444736000000000L) / 10L; - return (total_usecs / 1000000.); -#else - struct timeval cur; - gettimeofday(&cur, NULL); - return cur.tv_sec + cur.tv_usec / 1000000.; -#endif -} - static char *one_line(FILE *fp) { int c; diff --git a/fakenect/platform.h b/fakenect/platform.h new file mode 100644 index 00000000..35e08e7f --- /dev/null +++ b/fakenect/platform.h @@ -0,0 +1,75 @@ +/* + * This file is part of the OpenKinect Project. http://www.openkinect.org + * + * Copyright (c) 2010 Brandyn White (bwhite@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. + */ +#pragma once + +#include +#ifdef _WIN32 + #include + #define snprintf _snprintf + #define popen _popen +#else + #include + #include +#endif + + +double get_time() +{ +#ifdef _WIN32 + SYSTEMTIME st; + GetSystemTime(&st); + FILETIME ft; + SystemTimeToFileTime(&st, &ft); + ULARGE_INTEGER li; + li.LowPart = ft.dwLowDateTime; + li.HighPart = ft.dwHighDateTime; + // FILETIME is given as a 64-bit value for the number of 100-nanosecond + // intervals that have passed since Jan 1, 1601 (UTC). The difference between that + // epoch and the POSIX epoch (Jan 1, 1970) is 116444736000000000 such ticks. + uint64_t total_usecs = (li.QuadPart - 116444736000000000L) / 10L; + return (total_usecs / 1000000.); +#else + struct timeval cur; + gettimeofday(&cur, NULL); + return cur.tv_sec + cur.tv_usec / 1000000.; +#endif +} + +void sleep_highres(double tm) +{ +#ifdef _WIN32 + int msec = floor(tm * 1000); + if (msec > 0) { + Sleep(msec); + } +#else + int sec = floor(tm); + int usec = (tm - sec) * 1000000; + if (tm > 0) { + sleep(sec); + usleep(usec); + } +#endif +} diff --git a/fakenect/record.c b/fakenect/record.c index b3d2de6b..abd8d4b2 100644 --- a/fakenect/record.c +++ b/fakenect/record.c @@ -24,13 +24,13 @@ */ #include "libfreenect.h" +#include "platform.h" #include #include #include #include #include #include -#include char *out_dir=0; volatile sig_atomic_t running = 1; @@ -48,13 +48,6 @@ char *rgb_name = 0; FILE *depth_stream=0; FILE *rgb_stream=0; -double get_time() -{ - struct timeval cur; - gettimeofday(&cur, NULL); - return cur.tv_sec + cur.tv_usec / 1000000.; -} - void dump_depth(FILE *fp, void *data, int data_size) { fprintf(fp, "P5 %d %d 65535\n", FREENECT_FRAME_W, FREENECT_FRAME_H); @@ -140,20 +133,21 @@ void dump_ffmpeg_24(FILE *stream, uint32_t timestamp, void *data, void dump_ffmpeg_pad16(FILE *stream, uint32_t timestamp, void *data, int data_size) { - unsigned int z=0; - void *end = data + data_size; - while (data < end) { - z = *(unsigned short*)data; + unsigned int z = 0; + uint16_t* data_ptr = (uint16_t*)data; + uint16_t* end = data_ptr + data_size; + while (data_ptr < end) { + z = *data_ptr; fwrite(((char*)(&z)), 3, 1, stream); - data += 2; + data_ptr += 2; } } void snapshot_accel(freenect_device *dev) { + freenect_raw_tilt_state* state; if (!last_timestamp) return; - freenect_raw_tilt_state* state; freenect_update_tilt_state(dev); state = freenect_get_tilt_state(dev); dump('a', last_timestamp, state, sizeof *state); diff --git a/platform/windows/unistd.h b/platform/windows/unistd.h index 25965356..2652b31a 100644 --- a/platform/windows/unistd.h +++ b/platform/windows/unistd.h @@ -28,10 +28,10 @@ #include -// MinGW defines _SSIZE_T_ in sys/types.h when it defines ssize_t to be a long. +// MinGW defines _SSIZE_T_DEFINED in sys/types.h when it defines ssize_t to be a long. // Redefining it causes an error. // MSVC does not define this. -#ifndef _SSIZE_T_ -#define _SSIZE_T_ +#ifndef _SSIZE_T_DEFINED +#define _SSIZE_T_DEFINED typedef long ssize_t; -#endif // _SSIZE_T_ +#endif // _SSIZE_T_DEFINED diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1150666f..068f803d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -7,7 +7,6 @@ include_directories (${CMAKE_CURRENT_SOURCE_DIR}) include_directories(${LIBUSB_1_INCLUDE_DIRS}) LIST(APPEND SRC core.c tilt.c cameras.c flags.c usb_libusb10.c registration.c keep_alive.c) IF(WIN32) - LIST(APPEND SRC ../platform/windows/libusb10emu/libusb-1.0/libusbemu.cpp ../platform/windows/libusb10emu/libusb-1.0/failguard.cpp) set_source_files_properties(${SRC} PROPERTIES LANGUAGE CXX) ENDIF(WIN32) diff --git a/src/usb_libusb10.c b/src/usb_libusb10.c index 9fa56087..4652e19e 100644 --- a/src/usb_libusb10.c +++ b/src/usb_libusb10.c @@ -517,7 +517,7 @@ FN_INTERNAL int fnusb_close_subdevices(freenect_device *dev) return 0; } -static void iso_callback(struct libusb_transfer *xfer) +static void LIBUSB_CALL iso_callback(struct libusb_transfer *xfer) { int i; fnusb_isoc_stream *strm = (fnusb_isoc_stream*)xfer->user_data; From 3f214411ea096c778ee5ef0d69dd2aa14f1a2046 Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Tue, 15 Apr 2014 20:51:46 -0400 Subject: [PATCH 61/84] win32: Fix 1 error and 2 warnings Signed-off-by: Benn Snyder --- fakenect/platform.h | 1 + src/cameras.c | 2 +- src/freenect_internal.h | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/fakenect/platform.h b/fakenect/platform.h index 35e08e7f..73c1d5e9 100644 --- a/fakenect/platform.h +++ b/fakenect/platform.h @@ -26,6 +26,7 @@ #include #ifdef _WIN32 + #include #include #define snprintf _snprintf #define popen _popen diff --git a/src/cameras.c b/src/cameras.c index 428dc12f..12eaba22 100644 --- a/src/cameras.c +++ b/src/cameras.c @@ -833,7 +833,7 @@ static int freenect_fetch_zero_plane_info(freenect_device *dev) FN_SPEW("reference_pixel_size: %f\n", dev->registration.zero_plane_info.reference_pixel_size); // FIXME: OpenNI seems to use a hardcoded value of 2.4 instead of 2.3 as reported by Kinect - dev->registration.zero_plane_info.dcmos_rcmos_dist = 2.4; + dev->registration.zero_plane_info.dcmos_rcmos_dist = 2.4f; return 0; } diff --git a/src/freenect_internal.h b/src/freenect_internal.h index 4b26c419..a3c98ef9 100644 --- a/src/freenect_internal.h +++ b/src/freenect_internal.h @@ -159,7 +159,7 @@ typedef struct { int frame_size; int last_pkt_size; int valid_pkts; - uint lost_pkts; + unsigned int lost_pkts; int valid_frames; int variable_length; uint32_t last_timestamp; From a05b6c77cbca45e9da590038c53405476a7fc471 Mon Sep 17 00:00:00 2001 From: ofTheo Date: Wed, 23 Apr 2014 16:23:08 -0400 Subject: [PATCH 62/84] Bugfix for multiple K4W or 1473 devices needing keep_alive. Opening by PID fails when multiple identical devices are on the system. This PR uses libusb_get_parent and lib_usb_get_bus_number to get the correct audio device for a camera. PR is backwards compatible with older versions of libusb. Signed-off-by: Theodore Watson (ofTheo) --- src/freenect_internal.h | 3 ++ src/tilt.c | 19 ++++++---- src/usb_libusb10.c | 78 ++++++++++++++++++++++++++++++++++++++--- 3 files changed, 88 insertions(+), 12 deletions(-) diff --git a/src/freenect_internal.h b/src/freenect_internal.h index 4b26c419..c929a0e9 100644 --- a/src/freenect_internal.h +++ b/src/freenect_internal.h @@ -45,6 +45,9 @@ typedef void (*fnusb_iso_cb)(freenect_device *dev, uint8_t *buf, int len); #include "usb_libusb10.h" +//needed to set the led state for non 1414 devices - replaces keep_alive.c +FN_INTERNAL int fnusb_set_led_alt(libusb_device_handle * dev, freenect_context * ctx, freenect_led_options state); + struct _freenect_context { freenect_loglevel log_level; freenect_log_cb log_cb; diff --git a/src/tilt.c b/src/tilt.c index c9cb5c5f..4e7453b2 100644 --- a/src/tilt.c +++ b/src/tilt.c @@ -243,11 +243,9 @@ int freenect_set_tilt_degs(freenect_device *dev, double angle) return ret; } -#ifdef BUILD_AUDIO -int freenect_set_led_alt(freenect_device *dev, freenect_led_options state) -{ - freenect_context *ctx = dev->parent; +FN_INTERNAL int fnusb_set_led_alt(libusb_device_handle * dev, freenect_context * ctx, freenect_led_options state) +{ typedef enum { LED_ALT_OFF = 1, LED_ALT_BLINK_GREEN = 2, @@ -283,12 +281,19 @@ int freenect_set_led_alt(freenect_device *dev, freenect_led_options state) unsigned char buffer[20]; memcpy(buffer, &cmd, 20); - res = libusb_bulk_transfer(dev->usb_audio.dev, 0x01, buffer, 20, &transferred, 0); + res = libusb_bulk_transfer(dev, 0x01, buffer, 20, &transferred, 0); if (res != 0) { - FN_WARNING("freenect_set_led_alt(): libusb_bulk_transfer failed: %d (transferred = %d)\n", res, transferred); + FN_WARNING("fnusb_set_led_alt(): libusb_bulk_transfer failed: %d (transferred = %d)\n", res, transferred); return res; } - return get_reply(dev->usb_audio.dev, ctx); + return get_reply(dev, ctx); +} + +#ifdef BUILD_AUDIO +int freenect_set_led_alt(freenect_device *dev, freenect_led_options state) +{ + freenect_context *ctx = dev->parent; + return fnusb_set_led_alt(dev->usb_audio.dev, ctx, state); } #endif diff --git a/src/usb_libusb10.c b/src/usb_libusb10.c index 9fa56087..9cebd737 100644 --- a/src/usb_libusb10.c +++ b/src/usb_libusb10.c @@ -168,6 +168,43 @@ FN_INTERNAL int fnusb_is_pid_k4w_audio(int pid) return (pid == PID_K4W_AUDIO || pid == PID_K4W_AUDIO_ALT_1 || pid == PID_K4W_AUDIO_ALT_2); } +// fnusb_find_connected_audio_device uses new libusb features. we use guards to make sure its backwards compatible with older versions of libusb +#if defined(LIBUSB_API_VERSION) && (LIBUSB_API_VERSION >= 0x01000102) +FN_INTERNAL libusb_device * fnusb_find_connected_audio_device(libusb_device * camera, libusb_device ** deviceList, int cnt){ + + int cameraBusNo = libusb_get_bus_number(camera); + libusb_device * cameraParent = libusb_get_parent(camera); + + if( cameraBusNo < 0 ) return NULL; + if( cnt <= 0 ) return NULL; + + int i = 0; + struct libusb_device_descriptor desc; + + for (i = 0; i < cnt; i++) { + int r = libusb_get_device_descriptor (deviceList[i], &desc); + if (r < 0) continue; + if (desc.idVendor != VID_MICROSOFT) continue; + + //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! + //lets double check + libusb_device * audioParent = libusb_get_parent(deviceList[i]); + if( cameraParent == audioParent ){ + return deviceList[i]; + } + } + } + } + + return NULL; +} +#endif + FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index) { freenect_context *ctx = dev->parent; @@ -214,14 +251,44 @@ FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index) dev->usb_cam.dev = NULL; break; } - if (desc.idProduct == PID_K4W_CAMERA || desc.bcdDevice != fn_le32(267)) { + 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); - // Not the old kinect so we only set up the camera - ctx->enabled_subdevices = FREENECT_DEVICE_CAMERA; ctx->zero_plane_res = 334; dev->device_does_motor_control_with_audio = 1; + //lets also set the LED for non 1414 devices. + //this keeps the camera alive for some systems which get freezes. + //this code replaces keep_alive.c. As keep_alive.c didn't know which hub the connected audio device was on. + //fnusb_find_connected_audio_device needs libusb 1.0.18 or later though. + +#if defined(LIBUSB_API_VERSION) && (LIBUSB_API_VERSION >= 0x01000102) + 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); + + if( res != 0 ){ + FN_ERROR("Failed to set the LED of K4W or 1473 device: %d\n", res); + }else{ + 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); + } + } +#else + //Legacy: For older versions of libusb we use this approach which doesn't do well when multiple K4W or 1473 devices are attached to the system. //lets also set the LED ON //this keeps the camera alive for some systems which get freezes if( desc.idProduct == PID_K4W_CAMERA ){ @@ -229,12 +296,13 @@ FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index) }else{ freenect_extra_keep_alive(PID_NUI_AUDIO); } +#endif + #ifdef BUILD_AUDIO //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) - { + if( (requested_devices & FREENECT_DEVICE_MOTOR) && (requested_devices & FREENECT_DEVICE_AUDIO) == 0 ){ ctx->enabled_subdevices = (freenect_device_flags)(ctx->enabled_subdevices | FREENECT_DEVICE_AUDIO); } #endif From ee162e26da5cdc5ac98b4f7f6be1db8cc11e46a3 Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Thu, 24 Apr 2014 22:07:11 -0400 Subject: [PATCH 63/84] Move useful info from HACKING to README.md and delete the former Signed-off-by: Benn Snyder --- HACKING | 102 ------------------ README.md | 5 + .../portage/dev-libs/libfreenect/Manifest | 2 +- .../libfreenect/libfreenect-9999.ebuild | 2 +- 4 files changed, 7 insertions(+), 104 deletions(-) delete mode 100644 HACKING diff --git a/HACKING b/HACKING deleted file mode 100644 index b5b29be4..00000000 --- a/HACKING +++ /dev/null @@ -1,102 +0,0 @@ - "Coding styles are like assholes, everyone has one and no one likes anyone else's." - --Eric Warmenhoven - -We're not terribly particular about coding style at this early stage. However, -you should try to follow the following basic guidelines: - -=== INDENTATION === - -libfreenect is coded using tabs for indentation. The nominal width is 4 spaces. -However, you are encouraged to use spaces for alignment, as in the following -example: - - if (foo(this, that, there) - && bar == baz) { - dostuff(); - } - -Notice the spaces before the second line of the if() condition, after a single -tab. This lets people use their preferred tab width setting while maintaining -alignment. - -Do not, however, use spaces for indentation. Always use tabs. - -=== WIDTH === - -We're not particular about code width, but 80 characters is a good mark where -you should begin to consider breaking into multiple lines. A few 100 or 120-char -lines are fine, but don't go longer than that. Documentation, if linewrapped, -should be linewrapped to 80 character lines. - -=== IF / FOR / WHILE / etc. === - -Put the opening brace on the same line, like this: - - if (foo) { - ... - } else if (bar) { - ... - } else { - ... - } - -Or don't use braces for single-line bodies, like this: - - if (foo) - ... - else if (bar) - ... - else - ... - -Exceptions are allowed when the if() condition spans multiple lines and putting -the brace on its own line looks better by visually separating the condition from -the body. - -=== FUNCTIONS === - -Functions should have the opening brace on the next line, like this: - - void foo(int a_thing, int something_else) - { - ... - } - -No-args functions should be (void), and function arguments should be separated -with a space after the comma, like this: - - void baz(void) - { - foo(bluh, blah); - } - -Try to avoid having excessively long function names (abbreviating is fine) and -don't make multiple functions that do essentially the same thing (and certainly -don't copy and paste the code). - -In general, for data obtained with the Kinect, we'll provide a raw and a -"cooked" variant, where it makes sense, but we don't need to support every -"cooked" value convention under the sun. - -=== WHITESPACE === - -Avoid trailing whitespace. No lines should end in a tab or a space. Keep a -newline (blank line) at the end of each file. - -=== DEBUG BUILD === - -In order to build the binaries with debug symbols the following commands -can be used: - - $ mkdir build - $ cd build - $ cmake ../ -DCMAKE_BUILD_TYPE=debug - $ make - -If you want to build in release mode (with optimizations) but still have debug -symbols, try RelWithDebInfo: - - $ mkdir build - $ cd build - $ cmake ../ -DCMAKE_BUILD_TYPE=RelWithDebInfo - $ make diff --git a/README.md b/README.md index badf2eec..85912e0c 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,11 @@ For the examples, you'll need # if you don't have `make` or don't want color output # cmake --build . +You can also specify a build with debug symbols: + + cmake -L .. -DCMAKE_BUILD_TYPE=debug + # or with optimizations + # cmake -L .. -DCMAKE_BUILD_TYPE=RelWithDebInfo ## OSX diff --git a/platform/linux/portage/dev-libs/libfreenect/Manifest b/platform/linux/portage/dev-libs/libfreenect/Manifest index 5292a414..6c1da4bb 100644 --- a/platform/linux/portage/dev-libs/libfreenect/Manifest +++ b/platform/linux/portage/dev-libs/libfreenect/Manifest @@ -1 +1 @@ -EBUILD libfreenect-9999.ebuild 2118 SHA256 5606781a469e74de79fcbe620d81bdc2f221a52e85a5c3bd16eb2218d3789200 SHA512 f85d2658901d804202eb81d226f285dc753c1f8870d8d7ec553a0cef2d78fa30a9a789127cf278e03a35101fa7aa55967340f9907662e34c75a7420c3285fe9a WHIRLPOOL f3a5dd3a4c5cbe70a5b1ca98472bee71c9202b626c947275a7e7b449b1a17d91c18f1ff5b5075baa13fba797ac140a832a873662bd6e0d9adba8fa20f3852eff +EBUILD libfreenect-9999.ebuild 2110 SHA256 56a16645d035372f181c5e79005a2806adaeec7f816fbd11f6004c3af7f2e3b7 SHA512 1f634aae56466cd32c3abf7c1989c285612a454b0eb55b6a67fd82c951981d44f7d53f78de79968f59c454da6c8a60c08f4b3833777f91328345a865b7958179 WHIRLPOOL 9bdc6ec18fdaa58b7cee7b5a1346c1a02df3bd6dd0367fbe5218285c800de7c8651877054c21bf66587ec449e9fe3bfac7a0eddc5db65f36bb63b2e2c5851b2d diff --git a/platform/linux/portage/dev-libs/libfreenect/libfreenect-9999.ebuild b/platform/linux/portage/dev-libs/libfreenect/libfreenect-9999.ebuild index d18c8ed7..48e69ecb 100644 --- a/platform/linux/portage/dev-libs/libfreenect/libfreenect-9999.ebuild +++ b/platform/linux/portage/dev-libs/libfreenect/libfreenect-9999.ebuild @@ -56,7 +56,7 @@ src_install() { doins "${S}"/platform/linux/udev/51-kinect.rules # documentation - dodoc HACKING README.md + dodoc README.md if use doc; then cd doc doxygen || ewarn "doxygen failed" From 9a722e3572b344850b61283dd3868526ff049dd9 Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Mon, 28 Apr 2014 23:20:53 -0400 Subject: [PATCH 64/84] win32: Fix 2 errors under MinGW - fixes #359 Signed-off-by: Benn Snyder --- examples/glview.c | 8 ++++---- examples/regview.c | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/glview.c b/examples/glview.c index 18f478fc..4ec6d489 100644 --- a/examples/glview.c +++ b/examples/glview.c @@ -217,23 +217,23 @@ 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); - auto_exposure = !auto_exposure; + auto_exposure = auto_exposure ? FREENECT_OFF : FREENECT_ON; } if (key == 'b') { static freenect_flag_value white_balance = FREENECT_ON; freenect_set_flag(f_dev, FREENECT_AUTO_WHITE_BALANCE, white_balance); - white_balance = !white_balance; + white_balance = white_balance ? FREENECT_OFF : FREENECT_ON; } if (key == 'r') { static freenect_flag_value raw_color = FREENECT_ON; freenect_set_flag(f_dev, FREENECT_RAW_COLOR, raw_color); - raw_color = !raw_color; + raw_color = raw_color ? FREENECT_OFF : FREENECT_ON; } if (key == 'm') { static freenect_flag_value mirror = FREENECT_ON; freenect_set_flag(f_dev, FREENECT_MIRROR_DEPTH, mirror); freenect_set_flag(f_dev, FREENECT_MIRROR_VIDEO, mirror); - mirror = !mirror; + mirror = mirror ? FREENECT_OFF : FREENECT_ON; } if (key == '1') { freenect_set_led(f_dev,LED_GREEN); diff --git a/examples/regview.c b/examples/regview.c index 1bd2281c..7bbfd758 100644 --- a/examples/regview.c +++ b/examples/regview.c @@ -74,7 +74,7 @@ int got_rgb = 0; int got_depth = 0; int frame = 0; -int ftime = 0; +int my_ftime = 0; double fps = 0; void idle() @@ -140,8 +140,8 @@ void DrawGLScene() { frame++; if (frame % 30 == 0) { int ms = glutGet(GLUT_ELAPSED_TIME); - fps = 30.0/((ms-ftime)/1000.0); - ftime = ms; + fps = 30.0/((ms - my_ftime)/1000.0); + my_ftime = ms; } } From d9cc2b219a11fbd6ecf44a4ddce886d34534ddca Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Mon, 28 Apr 2014 23:39:59 -0400 Subject: [PATCH 65/84] wrappers/python: update freenect.c - fixes #326 Signed-off-by: Benn Snyder --- README.md | 9 + wrappers/python/freenect.c | 8383 ++++++++++++++++++++++-------------- 2 files changed, 5154 insertions(+), 3238 deletions(-) diff --git a/README.md b/README.md index 85912e0c..f599e4f6 100644 --- a/README.md +++ b/README.md @@ -117,6 +117,15 @@ Wrappers are not guaranteed to be API stable or up to date. - actionscript - Java (JNA) +## Python + + cd wrappers/python + # if you have cython and want to rebuild the binding + # cython freenect.pyx + python2 setup.py build_ext --inplace + +For example, start with [demo_cv_async.py](https://gihub.com/OpenKinect/libfreenect/tree/master/wrappers/python/devmo_cv_async.py). + # Maintainers diff --git a/wrappers/python/freenect.c b/wrappers/python/freenect.c index dce306be..0ec633f9 100644 --- a/wrappers/python/freenect.c +++ b/wrappers/python/freenect.c @@ -1,16 +1,28 @@ -/* Generated by Cython 0.14.1 on Thu Nov 10 13:32:00 2011 */ +/* Generated by Cython 0.19.1 on Mon Apr 28 23:37:38 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 - #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 @@ -22,36 +34,47 @@ #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 - -#if PY_VERSION_HEX < 0x02040000 - #define METH_COEXIST 0 - #define PyDict_CheckExact(op) (Py_TYPE(op) == &PyDict_Type) - #define PyDict_Contains(d,o) PySequence_Contains(d,o) +#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 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) PyInt_AsLong(o) - #define PyNumber_Index(o) PyNumber_Int(o) - #define PyIndex_Check(o) PyNumber_Check(o) + #define PyInt_AsSsize_t(o) __Pyx_PyInt_AsInt(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) @@ -59,7 +82,6 @@ #define PyVarObject_HEAD_INIT(type, size) \ PyObject_HEAD_INIT(type) size, #define PyType_Modified(t) - typedef struct { void *buf; PyObject *obj; @@ -73,7 +95,6 @@ Py_ssize_t *suboffsets; void *internal; } Py_buffer; - #define PyBUF_SIMPLE 0 #define PyBUF_WRITABLE 0x0001 #define PyBUF_FORMAT 0x0004 @@ -83,24 +104,47 @@ #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, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) #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) +#endif +#if PY_MAJOR_VERSION < 3 && PY_MINOR_VERSION < 6 + #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 > 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_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_READ(k, d, i) ((k=k), (Py_UCS4)(((Py_UNICODE*)d)[i])) +#endif #if PY_MAJOR_VERSION >= 3 #define PyBaseString_Type PyUnicode_Type #define PyStringObject PyUnicodeObject @@ -108,7 +152,6 @@ #define PyString_Check PyUnicode_Check #define PyString_CheckExact PyUnicode_CheckExact #endif - #if PY_VERSION_HEX < 0x02060000 #define PyBytesObject PyStringObject #define PyBytes_Type PyString_Type @@ -127,7 +170,14 @@ #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) (Py_TYPE(obj) == &PyBaseString_Type) +#endif #if PY_VERSION_HEX < 0x02060000 #define PySet_Check(obj) PyObject_TypeCheck(obj, &PySet_Type) #define PyFrozenSet_Check(obj) PyObject_TypeCheck(obj, &PyFrozenSet_Type) @@ -135,9 +185,7 @@ #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 @@ -154,20 +202,17 @@ #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask #endif - #if PY_MAJOR_VERSION >= 3 #define PyBoolObject PyLongObject #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) +#if PY_VERSION_HEX < 0x03020000 + typedef long Py_hash_t; + #define __Pyx_PyInt_FromHash_t PyInt_FromLong + #define __Pyx_PyInt_AsHash_t PyInt_AsLong #else - #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) - #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) + #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) @@ -186,11 +231,9 @@ (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)) @@ -200,7 +243,6 @@ #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)) @@ -208,45 +250,80 @@ #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) + #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 -#define __PYX_EXTERN_C extern "C" + +#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_EXTERN_C extern + #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 - -/* inline attribute */ -#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 - -/* unused attribute */ #ifndef CYTHON_UNUSED # if defined(__GNUC__) # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) @@ -254,47 +331,153 @@ # else # define CYTHON_UNUSED # endif -# elif defined(__ICC) || defined(__INTEL_COMPILER) +# 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 long n; const char* encoding; const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; /*proto*/ - - -/* Type Conversion Predeclarations */ - -#define __Pyx_PyBytes_FromUString(s) PyBytes_FromString((char*)s) -#define __Pyx_PyBytes_AsUString(s) ((unsigned char*) PyBytes_AsString(s)) - +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 +static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*); +static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); +#define __Pyx_PyBytes_FromString PyBytes_FromString +#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize +static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(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_AsUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_FromUString(s) __Pyx_PyObject_FromString((char*)s) +#define __Pyx_PyBytes_FromUString(s) __Pyx_PyBytes_FromString((char*)s) +#define __Pyx_PyStr_FromUString(s) __Pyx_PyStr_FromString((char*)s) +#define __Pyx_PyUnicode_FromUString(s) __Pyx_PyUnicode_FromString((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 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); static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*); - +#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() { + PyObject* sys = NULL; + PyObject* default_encoding = NULL; + PyObject* ascii_chars_u = NULL; + PyObject* ascii_chars_b = NULL; + sys = PyImport_ImportModule("sys"); + if (sys == NULL) goto bad; + default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); + if (default_encoding == NULL) goto bad; + if (strcmp(PyBytes_AsString(default_encoding), "ascii") == 0) { + __Pyx_sys_getdefaultencoding_not_ascii = 0; + } else { + const char* default_encoding_c = PyBytes_AS_STRING(default_encoding); + 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 == NULL) goto bad; + ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL); + if (ascii_chars_b == NULL || strncmp(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 '%s' is not a superset of ascii.", + default_encoding_c); + goto bad; + } + } + Py_XDECREF(sys); + Py_XDECREF(default_encoding); + Py_XDECREF(ascii_chars_u); + Py_XDECREF(ascii_chars_b); + return 0; +bad: + Py_XDECREF(sys); + 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() { + PyObject* sys = NULL; + PyObject* default_encoding = NULL; + char* default_encoding_c; + sys = PyImport_ImportModule("sys"); + if (sys == NULL) goto bad; + default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); + if (default_encoding == NULL) goto bad; + default_encoding_c = PyBytes_AS_STRING(default_encoding); + __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c)); + strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c); + Py_DECREF(sys); + Py_DECREF(default_encoding); + return 0; +bad: + Py_XDECREF(sys); + Py_XDECREF(default_encoding); + return -1; +} +#endif +#endif #ifdef __GNUC__ -/* Test for GCC > 2.95 */ -#if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)) -#define likely(x) __builtin_expect(!!(x), 1) -#define unlikely(x) __builtin_expect(!!(x), 0) -#else /* __GNUC__ > 2 ... */ -#define likely(x) (x) -#define unlikely(x) (x) -#endif /* __GNUC__ > 2 ... */ + /* Test for GCC > 2.95 */ + #if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)) + #define likely(x) __builtin_expect(!!(x), 1) + #define unlikely(x) __builtin_expect(!!(x), 0) + #else /* __GNUC__ > 2 ... */ + #define likely(x) (x) + #define unlikely(x) (x) + #endif /* __GNUC__ > 2 ... */ #else /* __GNUC__ */ -#define likely(x) (x) -#define unlikely(x) (x) + #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; @@ -303,7 +486,6 @@ 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 @@ -313,7 +495,6 @@ static const char *__pyx_filename; #define CYTHON_CCOMPLEX 0 #endif #endif - #if CYTHON_CCOMPLEX #ifdef __cplusplus #include @@ -321,55 +502,206 @@ static const char *__pyx_filename; #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", "numpy.pxd", + "type.pxd", }; +/* "numpy.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; +/* "numpy.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; +/* "numpy.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; +/* "numpy.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; +/* "numpy.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; +/* "numpy.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; +/* "numpy.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; +/* "numpy.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; +/* "numpy.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; +/* "numpy.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; +/* "numpy.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; +/* "numpy.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; -typedef npy_intp __pyx_t_5numpy_intp_t; - -typedef npy_uintp __pyx_t_5numpy_uintp_t; +/* "numpy.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; +/* "numpy.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; +/* "numpy.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; +/* "numpy.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; + +/* "numpy.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; + +/* "numpy.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; + +/* "numpy.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; +/* "numpy.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; +/* "numpy.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; @@ -390,50 +722,81 @@ typedef npy_longdouble __pyx_t_5numpy_longdouble_t; typedef struct { double real, imag; } __pyx_t_double_complex; #endif -/* Type declarations */ +/*--- Type declarations ---*/ +struct __pyx_obj_8freenect_CtxPtr; +struct __pyx_obj_8freenect_StatePtr; +struct __pyx_obj_8freenect_DevPtr; + +/* "numpy.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; +/* "numpy.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; +/* "numpy.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; +/* "numpy.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":165 +/* "freenect.pyx":169 * * * cdef class CtxPtr: # <<<<<<<<<<<<<< * cdef freenect_context* _ptr * def __repr__(self): */ - struct __pyx_obj_8freenect_CtxPtr { PyObject_HEAD freenect_context *_ptr; }; -/* "freenect.pyx":176 + +/* "freenect.pyx":180 * return "" * * cdef class StatePtr: # <<<<<<<<<<<<<< * cdef freenect_raw_tilt_state* _ptr * def __repr__(self): */ - struct __pyx_obj_8freenect_StatePtr { PyObject_HEAD freenect_raw_tilt_state *_ptr; }; -/* "freenect.pyx":170 + +/* "freenect.pyx":174 * return "" * * cdef class DevPtr: # <<<<<<<<<<<<<< * cdef freenect_device* _ptr * cdef CtxPtr ctx */ - struct __pyx_obj_8freenect_DevPtr { PyObject_HEAD freenect_device *_ptr; @@ -443,7 +806,6 @@ struct __pyx_obj_8freenect_DevPtr { #ifndef CYTHON_REFNANNY #define CYTHON_REFNANNY 0 #endif - #if CYTHON_REFNANNY typedef struct { void (*INCREF)(void*, PyObject*, int); @@ -454,82 +816,120 @@ struct __pyx_obj_8freenect_DevPtr { void (*FinishContext)(void**); } __Pyx_RefNannyAPIStruct; static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; - 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; - } - #define __Pyx_RefNannySetupContext(name) void *__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__) - #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__) + 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_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r);} } while(0) + #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_RefNannySetupContext(name) + #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_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);} } while(0) -#define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r);} } 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_GetName(PyObject *dict, PyObject *name); /*proto*/ +static PyObject *__Pyx_GetBuiltinName(PyObject *name); /*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 void __Pyx_RaiseDoubleKeywordsError( - const char* func_name, PyObject* kw_name); /*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 int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[], \ + PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, \ + const char* function_name); /*proto*/ static 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 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); /*proto*/ +static void __Pyx_WriteUnraisable(const char *name, int clineno, + int lineno, const char *filename); /*proto*/ -static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void); +static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/ -static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index); +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); /*proto*/ static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected); -static void __Pyx_UnpackTupleError(PyObject *, Py_ssize_t index); /*proto*/ +static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index); + +static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void); + +static CYTHON_INLINE int __Pyx_IterFinish(void); /*proto*/ + +static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected); /*proto*/ + +static PyObject *__Pyx_GetNameInClass(PyObject *nmspace, PyObject *name); /*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 PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/ +static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); /*proto*/ static PyObject *__Pyx_FindPy2Metaclass(PyObject *bases); /*proto*/ static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name, - PyObject *modname); /*proto*/ + PyObject *qualname, PyObject *modname); /*proto*/ static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_int16_t(int16_t); static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_int8_t(int8_t); static int __Pyx_Print(PyObject*, PyObject *, int); /*proto*/ -#if PY_MAJOR_VERSION >= 3 +#if CYTHON_COMPILING_IN_PYPY || PY_MAJOR_VERSION >= 3 static PyObject* __pyx_print = 0; static PyObject* __pyx_print_kwargs = 0; #endif @@ -538,14 +938,6 @@ static int __Pyx_PrintOne(PyObject* stream, PyObject *o); /*proto*/ static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_uint32_t(uint32_t); -#ifndef __PYX_FORCE_INIT_THREADS - #if PY_VERSION_HEX < 0x02040200 - #define __PYX_FORCE_INIT_THREADS 1 - #else - #define __PYX_FORCE_INIT_THREADS 0 - #endif -#endif - #if CYTHON_CCOMPLEX #ifdef __cplusplus #define __Pyx_CREAL(z) ((z).real()) @@ -558,7 +950,6 @@ static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_uint32_t(uint32_t); #define __Pyx_CREAL(z) ((z).real) #define __Pyx_CIMAG(z) ((z).imag) #endif - #if defined(_WIN32) && defined(__cplusplus) && CYTHON_CCOMPLEX #define __Pyx_SET_CREAL(z,x) ((z).real(x)) #define __Pyx_SET_CIMAG(z,y) ((z).imag(y)) @@ -677,63 +1068,129 @@ static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *); static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *); -static void __Pyx_WriteUnraisable(const char *name); /*proto*/ +static int __Pyx_check_binary_version(void); -static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, long size, int strict); /*proto*/ +#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 void __Pyx_AddTraceback(const char *funcname); /*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.stdint' */ -/* Module declarations from libc.stdio */ +/* Module declarations from 'cpython.buffer' */ -/* Module declarations from cpython.object */ +/* Module declarations from 'cpython.ref' */ -/* Module declarations from libc.stdlib */ +/* Module declarations from 'libc.string' */ -/* Module declarations from numpy */ +/* Module declarations from 'libc.stdio' */ -/* Module declarations from numpy */ +/* 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 PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *); /*proto*/ -static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *, PyObject *); /*proto*/ -static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *, PyObject *, PyObject *); /*proto*/ -static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *, PyObject *, PyObject *, PyObject *); /*proto*/ -static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *, PyObject *, PyObject *, PyObject *, PyObject *); /*proto*/ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *, char *, char *, int *); /*proto*/ -static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *, PyObject *); /*proto*/ -static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *); /*proto*/ -/* Module declarations from freenect */ +/* 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 PyTypeObject *__pyx_ptype_8freenect_DevPtr = 0; 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*/ #define __Pyx_MODULE_NAME "freenect" -static int __pyx_module_is_main_freenect = 0; +int __pyx_module_is_main_freenect = 0; -/* Implementation of freenect */ +/* 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 PyObject *__pyx_pf_8freenect_6CtxPtr___repr__(CYTHON_UNUSED struct __pyx_obj_8freenect_CtxPtr *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_8freenect_6DevPtr___repr__(CYTHON_UNUSED struct __pyx_obj_8freenect_DevPtr *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_8freenect_8StatePtr___repr__(CYTHON_UNUSED struct __pyx_obj_8freenect_StatePtr *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_8freenect_8StatePtr_2_get_accelx(struct __pyx_obj_8freenect_StatePtr *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_8freenect_8StatePtr_4_get_accely(struct __pyx_obj_8freenect_StatePtr *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_8freenect_8StatePtr_6_get_accelz(struct __pyx_obj_8freenect_StatePtr *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_8freenect_8StatePtr_8_get_tilt_angle(struct __pyx_obj_8freenect_StatePtr *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_8freenect_8StatePtr_10_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_4start_depth(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_DevPtr *__pyx_v_dev); /* proto */ +static PyObject *__pyx_pf_8freenect_6start_video(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_DevPtr *__pyx_v_dev); /* proto */ +static PyObject *__pyx_pf_8freenect_8stop_depth(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_DevPtr *__pyx_v_dev); /* proto */ +static PyObject *__pyx_pf_8freenect_10stop_video(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_DevPtr *__pyx_v_dev); /* proto */ +static PyObject *__pyx_pf_8freenect_12shutdown(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_CtxPtr *__pyx_v_ctx); /* proto */ +static PyObject *__pyx_pf_8freenect_14process_events(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_CtxPtr *__pyx_v_ctx); /* proto */ +static PyObject *__pyx_pf_8freenect_16num_devices(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_CtxPtr *__pyx_v_ctx); /* proto */ +static PyObject *__pyx_pf_8freenect_18close_device(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_DevPtr *__pyx_v_dev); /* proto */ +static PyObject *__pyx_pf_8freenect_20set_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_22set_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_24update_tilt_state(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_DevPtr *__pyx_v_dev); /* proto */ +static PyObject *__pyx_pf_8freenect_26get_tilt_state(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_DevPtr *__pyx_v_dev); /* proto */ +static PyObject *__pyx_pf_8freenect_28get_mks_accel(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_StatePtr *__pyx_v_state); /* proto */ +static PyObject *__pyx_pf_8freenect_30get_accel(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_DevPtr *__pyx_v_dev); /* proto */ +static PyObject *__pyx_pf_8freenect_32get_tilt_degs(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_StatePtr *__pyx_v_state); /* proto */ +static PyObject *__pyx_pf_8freenect_34error_open_device(CYTHON_UNUSED PyObject *__pyx_self); /* proto */ +static PyObject *__pyx_pf_8freenect_36init(CYTHON_UNUSED PyObject *__pyx_self); /* proto */ +static PyObject *__pyx_pf_8freenect_38open_device(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_CtxPtr *__pyx_v_ctx, int __pyx_v_index); /* proto */ +static PyObject *__pyx_pf_8freenect_40set_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_42set_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_44runloop(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_46base_runloop(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_CtxPtr *__pyx_v_ctx, PyObject *__pyx_v_body); /* proto */ +static PyObject *__pyx_pf_8freenect_48_depth_cb_np(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_dev, PyObject *__pyx_v_string, PyObject *__pyx_v_timestamp); /* proto */ +static PyObject *__pyx_pf_8freenect_50_video_cb_np(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_dev, PyObject *__pyx_v_string, PyObject *__pyx_v_timestamp); /* 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_StatePtr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_8freenect_DevPtr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static char __pyx_k_1[] = ""; static char __pyx_k_2[] = ""; static char __pyx_k_3[] = ""; @@ -747,7 +1204,8 @@ static char __pyx_k_19[] = "Format string allocated too short, see comment in nu static char __pyx_k_22[] = "Format string allocated too short."; static char __pyx_k_24[] = "VIDEO_IR_10BIT_PACKED"; static char __pyx_k_25[] = "LED_BLINK_RED_YELLOW"; -static char __pyx_k_26[] = "This kills the runloop, raise from the body only"; +static char __pyx_k_28[] = "/home/benn/code/libfreenect-upstream/wrappers/python/freenect.pyx"; +static char __pyx_k_66[] = "This kills the runloop, raise from the body only"; static char __pyx_k__B[] = "B"; static char __pyx_k__H[] = "H"; static char __pyx_k__I[] = "I"; @@ -762,34 +1220,39 @@ 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__buf[] = "buf"; static char __pyx_k__ctx[] = "ctx"; static char __pyx_k__dev[] = "dev"; -static char __pyx_k__obj[] = "obj"; +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___ptr[] = "_ptr"; -static char __pyx_k__base[] = "base"; 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__mdev[] = "mdev"; static char __pyx_k__mode[] = "mode"; -static char __pyx_k__ndim[] = "ndim"; static char __pyx_k__angle[] = "angle"; static char __pyx_k__depth[] = "depth"; -static char __pyx_k__descr[] = "descr"; static char __pyx_k__dtype[] = "dtype"; static char __pyx_k__index[] = "index"; -static char __pyx_k__names[] = "names"; static char __pyx_k__numpy[] = "numpy"; +static char __pyx_k__print[] = "print"; static char __pyx_k__range[] = "range"; -static char __pyx_k__shape[] = "shape"; +static char __pyx_k__state[] = "state"; static char __pyx_k__uint8[] = "uint8"; static char __pyx_k__video[] = "video"; -static char __pyx_k__fields[] = "fields"; +static char __pyx_k___index[] = "_index"; static char __pyx_k__format[] = "format"; static char __pyx_k__option[] = "option"; static char __pyx_k__resize[] = "resize"; @@ -797,33 +1260,33 @@ static char __pyx_k__string[] = "string"; static char __pyx_k__uint16[] = "uint16"; static char __pyx_k__LED_OFF[] = "LED_OFF"; static char __pyx_k__LED_RED[] = "LED_RED"; +static char __pyx_k___format[] = "_format"; static char __pyx_k__runloop[] = "runloop"; static char __pyx_k__set_led[] = "set_led"; -static char __pyx_k__strides[] = "strides"; +static char __pyx_k__DEPTH_MM[] = "DEPTH_MM"; static char __pyx_k____main__[] = "__main__"; static char __pyx_k____test__[] = "__test__"; static char __pyx_k__freenect[] = "freenect"; -static char __pyx_k__itemsize[] = "itemsize"; static char __pyx_k__property[] = "property"; -static char __pyx_k__readonly[] = "readonly"; static char __pyx_k__shutdown[] = "shutdown"; -static char __pyx_k__type_num[] = "type_num"; 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____class__[] = "__class__"; static char __pyx_k___depth_cb[] = "_depth_cb"; static char __pyx_k___video_cb[] = "_video_cb"; -static char __pyx_k__byteorder[] = "byteorder"; static char __pyx_k__get_accel[] = "get_accel"; +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____import__[] = "__import__"; +static char __pyx_k____module__[] = "__module__"; static char __pyx_k__fromstring[] = "fromstring"; static char __pyx_k__stop_depth[] = "stop_depth"; static char __pyx_k__stop_video[] = "stop_video"; -static char __pyx_k__suboffsets[] = "suboffsets"; static char __pyx_k__tilt_angle[] = "tilt_angle"; static char __pyx_k__DEPTH_10BIT[] = "DEPTH_10BIT"; static char __pyx_k__DEPTH_11BIT[] = "DEPTH_11BIT"; @@ -838,6 +1301,7 @@ 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____qualname__[] = "__qualname__"; static char __pyx_k___depth_cb_np[] = "_depth_cb_np"; static char __pyx_k___video_cb_np[] = "_video_cb_np"; static char __pyx_k__base_runloop[] = "base_runloop"; @@ -846,6 +1310,7 @@ static char __pyx_k__DEVICE_CAMERA[] = "DEVICE_CAMERA"; 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____metaclass__[] = "__metaclass__"; 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"; @@ -863,6 +1328,7 @@ static char __pyx_k___get_tilt_angle[] = "_get_tilt_angle"; 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__DEPTH_REGISTERED[] = "DEPTH_REGISTERED"; static char __pyx_k___get_tilt_status[] = "_get_tilt_status"; static char __pyx_k__RESOLUTION_MEDIUM[] = "RESOLUTION_MEDIUM"; static char __pyx_k__error_open_device[] = "error_open_device"; @@ -882,13 +1348,16 @@ static PyObject *__pyx_kp_s_2; static PyObject *__pyx_kp_u_22; static PyObject *__pyx_n_s_24; static PyObject *__pyx_n_s_25; -static PyObject *__pyx_kp_s_26; +static PyObject *__pyx_kp_s_28; static PyObject *__pyx_kp_s_3; static PyObject *__pyx_kp_s_4; +static PyObject *__pyx_kp_s_66; 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; @@ -911,36 +1380,43 @@ 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_n_s____class__; +static PyObject *__pyx_n_s____import__; static PyObject *__pyx_n_s____main__; +static PyObject *__pyx_n_s____metaclass__; +static PyObject *__pyx_n_s____module__; +static PyObject *__pyx_n_s____qualname__; static PyObject *__pyx_n_s____test__; static PyObject *__pyx_n_s___depth_cb; static PyObject *__pyx_n_s___depth_cb_np; +static PyObject *__pyx_n_s___format; 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_tilt_angle; static PyObject *__pyx_n_s___get_tilt_status; -static PyObject *__pyx_n_s___ptr; +static PyObject *__pyx_n_s___index; static PyObject *__pyx_n_s___video_cb; static PyObject *__pyx_n_s___video_cb_np; 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; static PyObject *__pyx_n_s__base_runloop; static PyObject *__pyx_n_s__body; -static PyObject *__pyx_n_s__buf; -static PyObject *__pyx_n_s__byteorder; 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__descr; static PyObject *__pyx_n_s__dev; +static PyObject *__pyx_n_s__devp; +static PyObject *__pyx_n_s__dims; static PyObject *__pyx_n_s__dtype; +static PyObject *__pyx_n_s__end; static PyObject *__pyx_n_s__error_open_device; -static PyObject *__pyx_n_s__fields; +static PyObject *__pyx_n_s__file; static PyObject *__pyx_n_s__format; static PyObject *__pyx_n_s__freenect; static PyObject *__pyx_n_s__fromstring; @@ -949,19 +1425,17 @@ static PyObject *__pyx_n_s__get_mks_accel; static PyObject *__pyx_n_s__get_tilt_degs; static PyObject *__pyx_n_s__get_tilt_state; static PyObject *__pyx_n_s__index; -static PyObject *__pyx_n_s__itemsize; +static PyObject *__pyx_n_s__mdev; static PyObject *__pyx_n_s__mode; -static PyObject *__pyx_n_s__names; -static PyObject *__pyx_n_s__ndim; static PyObject *__pyx_n_s__np; static PyObject *__pyx_n_s__num_devices; static PyObject *__pyx_n_s__numpy; -static PyObject *__pyx_n_s__obj; static PyObject *__pyx_n_s__option; +static PyObject *__pyx_n_s__out; +static PyObject *__pyx_n_s__print; static PyObject *__pyx_n_s__process_events; static PyObject *__pyx_n_s__property; static PyObject *__pyx_n_s__range; -static PyObject *__pyx_n_s__readonly; static PyObject *__pyx_n_s__res; static PyObject *__pyx_n_s__resize; static PyObject *__pyx_n_s__runloop; @@ -971,26 +1445,27 @@ 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__shape; 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__strides; static PyObject *__pyx_n_s__string; -static PyObject *__pyx_n_s__suboffsets; 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__tilt_angle; static PyObject *__pyx_n_s__tilt_status; static PyObject *__pyx_n_s__timestamp; -static PyObject *__pyx_n_s__type_num; static PyObject *__pyx_n_s__uint16; static PyObject *__pyx_n_s__uint8; static PyObject *__pyx_n_s__update_tilt_state; static PyObject *__pyx_n_s__video; +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_int_3; static PyObject *__pyx_int_15; @@ -1008,21 +1483,84 @@ static PyObject *__pyx_k_tuple_17; static PyObject *__pyx_k_tuple_20; static PyObject *__pyx_k_tuple_21; static PyObject *__pyx_k_tuple_23; - -/* "freenect.pyx":167 - * cdef class CtxPtr: +static PyObject *__pyx_k_tuple_26; +static PyObject *__pyx_k_tuple_29; +static PyObject *__pyx_k_tuple_31; +static PyObject *__pyx_k_tuple_33; +static PyObject *__pyx_k_tuple_35; +static PyObject *__pyx_k_tuple_37; +static PyObject *__pyx_k_tuple_39; +static PyObject *__pyx_k_tuple_41; +static PyObject *__pyx_k_tuple_43; +static PyObject *__pyx_k_tuple_45; +static PyObject *__pyx_k_tuple_47; +static PyObject *__pyx_k_tuple_49; +static PyObject *__pyx_k_tuple_51; +static PyObject *__pyx_k_tuple_53; +static PyObject *__pyx_k_tuple_55; +static PyObject *__pyx_k_tuple_57; +static PyObject *__pyx_k_tuple_59; +static PyObject *__pyx_k_tuple_62; +static PyObject *__pyx_k_tuple_64; +static PyObject *__pyx_k_tuple_67; +static PyObject *__pyx_k_tuple_69; +static PyObject *__pyx_k_tuple_71; +static PyObject *__pyx_k_tuple_73; +static PyObject *__pyx_k_tuple_75; +static PyObject *__pyx_k_tuple_77; +static PyObject *__pyx_k_codeobj_27; +static PyObject *__pyx_k_codeobj_30; +static PyObject *__pyx_k_codeobj_32; +static PyObject *__pyx_k_codeobj_34; +static PyObject *__pyx_k_codeobj_36; +static PyObject *__pyx_k_codeobj_38; +static PyObject *__pyx_k_codeobj_40; +static PyObject *__pyx_k_codeobj_42; +static PyObject *__pyx_k_codeobj_44; +static PyObject *__pyx_k_codeobj_46; +static PyObject *__pyx_k_codeobj_48; +static PyObject *__pyx_k_codeobj_50; +static PyObject *__pyx_k_codeobj_52; +static PyObject *__pyx_k_codeobj_54; +static PyObject *__pyx_k_codeobj_56; +static PyObject *__pyx_k_codeobj_58; +static PyObject *__pyx_k_codeobj_60; +static PyObject *__pyx_k_codeobj_61; +static PyObject *__pyx_k_codeobj_63; +static PyObject *__pyx_k_codeobj_65; +static PyObject *__pyx_k_codeobj_68; +static PyObject *__pyx_k_codeobj_70; +static PyObject *__pyx_k_codeobj_72; +static PyObject *__pyx_k_codeobj_74; +static PyObject *__pyx_k_codeobj_76; +static PyObject *__pyx_k_codeobj_78; +static PyObject *__pyx_k_codeobj_79; + +/* Python wrapper */ +static PyObject *__pyx_pw_8freenect_6CtxPtr_1__repr__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_8freenect_6CtxPtr_1__repr__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0); + __pyx_r = __pyx_pf_8freenect_6CtxPtr___repr__(((struct __pyx_obj_8freenect_CtxPtr *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "freenect.pyx":171 + * cdef class CtxPtr: * cdef freenect_context* _ptr * def __repr__(self): # <<<<<<<<<<<<<< * return "" * */ -static PyObject *__pyx_pf_8freenect_6CtxPtr___repr__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pf_8freenect_6CtxPtr___repr__(PyObject *__pyx_v_self) { +static PyObject *__pyx_pf_8freenect_6CtxPtr___repr__(CYTHON_UNUSED struct __pyx_obj_8freenect_CtxPtr *__pyx_v_self) { PyObject *__pyx_r = NULL; - __Pyx_RefNannySetupContext("__repr__"); + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__repr__", 0); - /* "freenect.pyx":168 + /* "freenect.pyx":172 * cdef freenect_context* _ptr * def __repr__(self): * return "" # <<<<<<<<<<<<<< @@ -1041,7 +1579,18 @@ static PyObject *__pyx_pf_8freenect_6CtxPtr___repr__(PyObject *__pyx_v_self) { return __pyx_r; } -/* "freenect.pyx":173 +/* Python wrapper */ +static PyObject *__pyx_pw_8freenect_6DevPtr_1__repr__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_8freenect_6DevPtr_1__repr__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0); + __pyx_r = __pyx_pf_8freenect_6DevPtr___repr__(((struct __pyx_obj_8freenect_DevPtr *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "freenect.pyx":177 * cdef freenect_device* _ptr * cdef CtxPtr ctx * def __repr__(self): # <<<<<<<<<<<<<< @@ -1049,12 +1598,12 @@ static PyObject *__pyx_pf_8freenect_6CtxPtr___repr__(PyObject *__pyx_v_self) { * */ -static PyObject *__pyx_pf_8freenect_6DevPtr___repr__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pf_8freenect_6DevPtr___repr__(PyObject *__pyx_v_self) { +static PyObject *__pyx_pf_8freenect_6DevPtr___repr__(CYTHON_UNUSED struct __pyx_obj_8freenect_DevPtr *__pyx_v_self) { PyObject *__pyx_r = NULL; - __Pyx_RefNannySetupContext("__repr__"); + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__repr__", 0); - /* "freenect.pyx":174 + /* "freenect.pyx":178 * cdef CtxPtr ctx * def __repr__(self): * return "" # <<<<<<<<<<<<<< @@ -1073,7 +1622,18 @@ static PyObject *__pyx_pf_8freenect_6DevPtr___repr__(PyObject *__pyx_v_self) { return __pyx_r; } -/* "freenect.pyx":178 +/* Python wrapper */ +static PyObject *__pyx_pw_8freenect_8StatePtr_1__repr__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_8freenect_8StatePtr_1__repr__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0); + __pyx_r = __pyx_pf_8freenect_8StatePtr___repr__(((struct __pyx_obj_8freenect_StatePtr *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "freenect.pyx":182 * cdef class StatePtr: * cdef freenect_raw_tilt_state* _ptr * def __repr__(self): # <<<<<<<<<<<<<< @@ -1081,12 +1641,12 @@ static PyObject *__pyx_pf_8freenect_6DevPtr___repr__(PyObject *__pyx_v_self) { * */ -static PyObject *__pyx_pf_8freenect_8StatePtr___repr__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pf_8freenect_8StatePtr___repr__(PyObject *__pyx_v_self) { +static PyObject *__pyx_pf_8freenect_8StatePtr___repr__(CYTHON_UNUSED struct __pyx_obj_8freenect_StatePtr *__pyx_v_self) { PyObject *__pyx_r = NULL; - __Pyx_RefNannySetupContext("__repr__"); + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__repr__", 0); - /* "freenect.pyx":179 + /* "freenect.pyx":183 * cdef freenect_raw_tilt_state* _ptr * def __repr__(self): * return "" # <<<<<<<<<<<<<< @@ -1105,7 +1665,18 @@ static PyObject *__pyx_pf_8freenect_8StatePtr___repr__(PyObject *__pyx_v_self) { return __pyx_r; } -/* "freenect.pyx":181 +/* Python wrapper */ +static PyObject *__pyx_pw_8freenect_8StatePtr_3_get_accelx(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_8freenect_8StatePtr_3_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_2_get_accelx(((struct __pyx_obj_8freenect_StatePtr *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "freenect.pyx":185 * return "" * * def _get_accelx(self): # <<<<<<<<<<<<<< @@ -1113,14 +1684,17 @@ static PyObject *__pyx_pf_8freenect_8StatePtr___repr__(PyObject *__pyx_v_self) { * */ -static PyObject *__pyx_pf_8freenect_8StatePtr_1_get_accelx(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pf_8freenect_8StatePtr_1_get_accelx(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { +static PyObject *__pyx_pf_8freenect_8StatePtr_2_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; - __Pyx_RefNannySetupContext("_get_accelx"); + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("_get_accelx", 0); - /* "freenect.pyx":182 + /* "freenect.pyx":186 * * def _get_accelx(self): * return int(self._ptr.accelerometer_x) # <<<<<<<<<<<<<< @@ -1128,14 +1702,14 @@ static PyObject *__pyx_pf_8freenect_8StatePtr_1_get_accelx(PyObject *__pyx_v_sel * def _get_accely(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_to_py_int16_t(((struct __pyx_obj_8freenect_StatePtr *)__pyx_v_self)->_ptr->accelerometer_x); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyInt_to_py_int16_t(__pyx_v_self->_ptr->accelerometer_x); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __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 = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_2)); + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __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 = PyObject_Call(((PyObject *)((PyObject*)(&PyInt_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyInt_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; @@ -1147,7 +1721,7 @@ static PyObject *__pyx_pf_8freenect_8StatePtr_1_get_accelx(PyObject *__pyx_v_sel __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("freenect.StatePtr._get_accelx"); + __Pyx_AddTraceback("freenect.StatePtr._get_accelx", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -1155,7 +1729,18 @@ static PyObject *__pyx_pf_8freenect_8StatePtr_1_get_accelx(PyObject *__pyx_v_sel return __pyx_r; } -/* "freenect.pyx":184 +/* Python wrapper */ +static PyObject *__pyx_pw_8freenect_8StatePtr_5_get_accely(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_8freenect_8StatePtr_5_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_4_get_accely(((struct __pyx_obj_8freenect_StatePtr *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "freenect.pyx":188 * return int(self._ptr.accelerometer_x) * * def _get_accely(self): # <<<<<<<<<<<<<< @@ -1163,14 +1748,17 @@ static PyObject *__pyx_pf_8freenect_8StatePtr_1_get_accelx(PyObject *__pyx_v_sel * */ -static PyObject *__pyx_pf_8freenect_8StatePtr_2_get_accely(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pf_8freenect_8StatePtr_2_get_accely(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { +static PyObject *__pyx_pf_8freenect_8StatePtr_4_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; - __Pyx_RefNannySetupContext("_get_accely"); + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("_get_accely", 0); - /* "freenect.pyx":185 + /* "freenect.pyx":189 * * def _get_accely(self): * return int(self._ptr.accelerometer_y) # <<<<<<<<<<<<<< @@ -1178,14 +1766,14 @@ static PyObject *__pyx_pf_8freenect_8StatePtr_2_get_accely(PyObject *__pyx_v_sel * def _get_accelz(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_to_py_int16_t(((struct __pyx_obj_8freenect_StatePtr *)__pyx_v_self)->_ptr->accelerometer_y); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyInt_to_py_int16_t(__pyx_v_self->_ptr->accelerometer_y); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; __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 = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_2)); + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; __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 = PyObject_Call(((PyObject *)((PyObject*)(&PyInt_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyInt_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; @@ -1197,7 +1785,7 @@ static PyObject *__pyx_pf_8freenect_8StatePtr_2_get_accely(PyObject *__pyx_v_sel __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("freenect.StatePtr._get_accely"); + __Pyx_AddTraceback("freenect.StatePtr._get_accely", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -1205,7 +1793,18 @@ static PyObject *__pyx_pf_8freenect_8StatePtr_2_get_accely(PyObject *__pyx_v_sel return __pyx_r; } -/* "freenect.pyx":187 +/* Python wrapper */ +static PyObject *__pyx_pw_8freenect_8StatePtr_7_get_accelz(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_8freenect_8StatePtr_7_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_6_get_accelz(((struct __pyx_obj_8freenect_StatePtr *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "freenect.pyx":191 * return int(self._ptr.accelerometer_y) * * def _get_accelz(self): # <<<<<<<<<<<<<< @@ -1213,14 +1812,17 @@ static PyObject *__pyx_pf_8freenect_8StatePtr_2_get_accely(PyObject *__pyx_v_sel * */ -static PyObject *__pyx_pf_8freenect_8StatePtr_3_get_accelz(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pf_8freenect_8StatePtr_3_get_accelz(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { +static PyObject *__pyx_pf_8freenect_8StatePtr_6_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; - __Pyx_RefNannySetupContext("_get_accelz"); + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("_get_accelz", 0); - /* "freenect.pyx":188 + /* "freenect.pyx":192 * * def _get_accelz(self): * return int(self._ptr.accelerometer_z) # <<<<<<<<<<<<<< @@ -1228,14 +1830,14 @@ static PyObject *__pyx_pf_8freenect_8StatePtr_3_get_accelz(PyObject *__pyx_v_sel * def _get_tilt_angle(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_to_py_int16_t(((struct __pyx_obj_8freenect_StatePtr *)__pyx_v_self)->_ptr->accelerometer_z); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyInt_to_py_int16_t(__pyx_v_self->_ptr->accelerometer_z); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __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 = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_2)); + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __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 = PyObject_Call(((PyObject *)((PyObject*)(&PyInt_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyInt_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; @@ -1247,7 +1849,7 @@ static PyObject *__pyx_pf_8freenect_8StatePtr_3_get_accelz(PyObject *__pyx_v_sel __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("freenect.StatePtr._get_accelz"); + __Pyx_AddTraceback("freenect.StatePtr._get_accelz", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -1255,7 +1857,18 @@ static PyObject *__pyx_pf_8freenect_8StatePtr_3_get_accelz(PyObject *__pyx_v_sel return __pyx_r; } -/* "freenect.pyx":190 +/* Python wrapper */ +static PyObject *__pyx_pw_8freenect_8StatePtr_9_get_tilt_angle(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_8freenect_8StatePtr_9_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_8_get_tilt_angle(((struct __pyx_obj_8freenect_StatePtr *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "freenect.pyx":194 * return int(self._ptr.accelerometer_z) * * def _get_tilt_angle(self): # <<<<<<<<<<<<<< @@ -1263,14 +1876,17 @@ static PyObject *__pyx_pf_8freenect_8StatePtr_3_get_accelz(PyObject *__pyx_v_sel * */ -static PyObject *__pyx_pf_8freenect_8StatePtr_4_get_tilt_angle(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pf_8freenect_8StatePtr_4_get_tilt_angle(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { +static PyObject *__pyx_pf_8freenect_8StatePtr_8_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; - __Pyx_RefNannySetupContext("_get_tilt_angle"); + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("_get_tilt_angle", 0); - /* "freenect.pyx":191 + /* "freenect.pyx":195 * * def _get_tilt_angle(self): * return int(self._ptr.tilt_angle) # <<<<<<<<<<<<<< @@ -1278,14 +1894,14 @@ static PyObject *__pyx_pf_8freenect_8StatePtr_4_get_tilt_angle(PyObject *__pyx_v * def _get_tilt_status(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_to_py_int8_t(((struct __pyx_obj_8freenect_StatePtr *)__pyx_v_self)->_ptr->tilt_angle); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyInt_to_py_int8_t(__pyx_v_self->_ptr->tilt_angle); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __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 = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_2)); + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __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 = PyObject_Call(((PyObject *)((PyObject*)(&PyInt_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyInt_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; @@ -1297,7 +1913,7 @@ static PyObject *__pyx_pf_8freenect_8StatePtr_4_get_tilt_angle(PyObject *__pyx_v __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("freenect.StatePtr._get_tilt_angle"); + __Pyx_AddTraceback("freenect.StatePtr._get_tilt_angle", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -1305,7 +1921,18 @@ static PyObject *__pyx_pf_8freenect_8StatePtr_4_get_tilt_angle(PyObject *__pyx_v return __pyx_r; } -/* "freenect.pyx":193 +/* Python wrapper */ +static PyObject *__pyx_pw_8freenect_8StatePtr_11_get_tilt_status(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_8freenect_8StatePtr_11_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_10_get_tilt_status(((struct __pyx_obj_8freenect_StatePtr *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "freenect.pyx":197 * return int(self._ptr.tilt_angle) * * def _get_tilt_status(self): # <<<<<<<<<<<<<< @@ -1313,14 +1940,17 @@ static PyObject *__pyx_pf_8freenect_8StatePtr_4_get_tilt_angle(PyObject *__pyx_v * */ -static PyObject *__pyx_pf_8freenect_8StatePtr_5_get_tilt_status(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pf_8freenect_8StatePtr_5_get_tilt_status(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { +static PyObject *__pyx_pf_8freenect_8StatePtr_10_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; - __Pyx_RefNannySetupContext("_get_tilt_status"); + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("_get_tilt_status", 0); - /* "freenect.pyx":194 + /* "freenect.pyx":198 * * def _get_tilt_status(self): * return int(self._ptr.tilt_status) # <<<<<<<<<<<<<< @@ -1328,14 +1958,14 @@ static PyObject *__pyx_pf_8freenect_8StatePtr_5_get_tilt_status(PyObject *__pyx_ * accelerometer_x = property(_get_accelx) */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_8freenect_StatePtr *)__pyx_v_self)->_ptr->tilt_status); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromLong(__pyx_v_self->_ptr->tilt_status); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; __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 = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_2)); + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; __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 = PyObject_Call(((PyObject *)((PyObject*)(&PyInt_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyInt_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; @@ -1347,7 +1977,7 @@ static PyObject *__pyx_pf_8freenect_8StatePtr_5_get_tilt_status(PyObject *__pyx_ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("freenect.StatePtr._get_tilt_status"); + __Pyx_AddTraceback("freenect.StatePtr._get_tilt_status", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -1355,77 +1985,98 @@ static PyObject *__pyx_pf_8freenect_8StatePtr_5_get_tilt_status(PyObject *__pyx_ return __pyx_r; } -/* "freenect.pyx":202 - * 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)) - * - */ - -static PyObject *__pyx_pf_8freenect_set_depth_mode(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyMethodDef __pyx_mdef_8freenect_set_depth_mode = {__Pyx_NAMESTR("set_depth_mode"), (PyCFunction)__pyx_pf_8freenect_set_depth_mode, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}; -static PyObject *__pyx_pf_8freenect_set_depth_mode(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +/* 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; - PyObject *__pyx_r = NULL; - PyObject *__pyx_t_1 = NULL; - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__dev,&__pyx_n_s__res,&__pyx_n_s__mode,0}; - __Pyx_RefNannySetupContext("set_depth_mode"); - __pyx_self = __pyx_self; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args = PyDict_Size(__pyx_kwds); + 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}; - switch (PyTuple_GET_SIZE(__pyx_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; - } - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 0: - values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__dev); - if (likely(values[0])) kw_args--; - else goto __pyx_L5_argtuple_error; - case 1: - values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__res); - if (likely(values[1])) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("set_depth_mode", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + 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 = 206; __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 = 206; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } } - case 2: - values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__mode); - if (likely(values[2])) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("set_depth_mode", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __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 = 206; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "set_depth_mode") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __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_AsInt(values[1]); if (unlikely((__pyx_v_res == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_v_mode = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_mode == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { - goto __pyx_L5_argtuple_error; - } else { - __pyx_v_dev = ((struct __pyx_obj_8freenect_DevPtr *)PyTuple_GET_ITEM(__pyx_args, 0)); - __pyx_v_res = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_res == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_v_mode = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 2)); if (unlikely((__pyx_v_mode == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_res = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_res == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_mode = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_mode == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __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 = 202; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("set_depth_mode", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; - __Pyx_AddTraceback("freenect.set_depth_mode"); + __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 = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dev), __pyx_ptype_8freenect_DevPtr, 1, "dev", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __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); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "freenect.pyx":203 +/* "freenect.pyx":206 + * 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)) + * + */ + +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":207 * * def set_depth_mode(DevPtr dev, int res, int mode): * return freenect_set_depth_mode(dev._ptr, freenect_find_depth_mode(res, mode)) # <<<<<<<<<<<<<< @@ -1433,7 +2084,7 @@ static PyObject *__pyx_pf_8freenect_set_depth_mode(PyObject *__pyx_self, PyObjec * def set_video_mode(DevPtr dev, int res, int mode): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyInt_FromLong(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 = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromLong(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 = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -1443,7 +2094,7 @@ static PyObject *__pyx_pf_8freenect_set_depth_mode(PyObject *__pyx_self, PyObjec goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("freenect.set_depth_mode"); + __Pyx_AddTraceback("freenect.set_depth_mode", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -1451,77 +2102,98 @@ static PyObject *__pyx_pf_8freenect_set_depth_mode(PyObject *__pyx_self, PyObjec return __pyx_r; } -/* "freenect.pyx":205 - * 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)) - * - */ - -static PyObject *__pyx_pf_8freenect_1set_video_mode(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyMethodDef __pyx_mdef_8freenect_1set_video_mode = {__Pyx_NAMESTR("set_video_mode"), (PyCFunction)__pyx_pf_8freenect_1set_video_mode, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}; -static PyObject *__pyx_pf_8freenect_1set_video_mode(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +/* 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; - PyObject *__pyx_r = NULL; - PyObject *__pyx_t_1 = NULL; - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__dev,&__pyx_n_s__res,&__pyx_n_s__mode,0}; - __Pyx_RefNannySetupContext("set_video_mode"); - __pyx_self = __pyx_self; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args = PyDict_Size(__pyx_kwds); + 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}; - switch (PyTuple_GET_SIZE(__pyx_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; - } - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 0: - values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__dev); - if (likely(values[0])) kw_args--; - else goto __pyx_L5_argtuple_error; - case 1: - values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__res); - if (likely(values[1])) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("set_video_mode", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + 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; } - case 2: - values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__mode); - if (likely(values[2])) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("set_video_mode", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L3_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 = 209; __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 = 209; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "set_video_mode") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __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 = 209; __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_AsInt(values[1]); if (unlikely((__pyx_v_res == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_v_mode = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_mode == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { - goto __pyx_L5_argtuple_error; - } else { - __pyx_v_dev = ((struct __pyx_obj_8freenect_DevPtr *)PyTuple_GET_ITEM(__pyx_args, 0)); - __pyx_v_res = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_res == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_v_mode = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 2)); if (unlikely((__pyx_v_mode == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_res = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_res == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_mode = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_mode == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __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 = 205; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("set_video_mode", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; - __Pyx_AddTraceback("freenect.set_video_mode"); + __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 = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dev), __pyx_ptype_8freenect_DevPtr, 1, "dev", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __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); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "freenect.pyx":206 +/* "freenect.pyx":209 + * 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)) + * + */ + +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":210 * * def set_video_mode(DevPtr dev, int res, int mode): * return freenect_set_video_mode(dev._ptr, freenect_find_video_mode(res, mode)) # <<<<<<<<<<<<<< @@ -1529,7 +2201,7 @@ static PyObject *__pyx_pf_8freenect_1set_video_mode(PyObject *__pyx_self, PyObje * def start_depth(DevPtr dev): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyInt_FromLong(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 = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromLong(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 = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -1539,7 +2211,7 @@ static PyObject *__pyx_pf_8freenect_1set_video_mode(PyObject *__pyx_self, PyObje goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("freenect.set_video_mode"); + __Pyx_AddTraceback("freenect.set_video_mode", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -1547,7 +2219,27 @@ static PyObject *__pyx_pf_8freenect_1set_video_mode(PyObject *__pyx_self, PyObje return __pyx_r; } -/* "freenect.pyx":208 +/* Python wrapper */ +static PyObject *__pyx_pw_8freenect_5start_depth(PyObject *__pyx_self, PyObject *__pyx_v_dev); /*proto*/ +static PyMethodDef __pyx_mdef_8freenect_5start_depth = {__Pyx_NAMESTR("start_depth"), (PyCFunction)__pyx_pw_8freenect_5start_depth, METH_O, __Pyx_DOCSTR(0)}; +static PyObject *__pyx_pw_8freenect_5start_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 = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_8freenect_4start_depth(__pyx_self, ((struct __pyx_obj_8freenect_DevPtr *)__pyx_v_dev)); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "freenect.pyx":212 * return freenect_set_video_mode(dev._ptr, freenect_find_video_mode(res, mode)) * * def start_depth(DevPtr dev): # <<<<<<<<<<<<<< @@ -1555,16 +2247,16 @@ static PyObject *__pyx_pf_8freenect_1set_video_mode(PyObject *__pyx_self, PyObje * */ -static PyObject *__pyx_pf_8freenect_2start_depth(PyObject *__pyx_self, PyObject *__pyx_v_dev); /*proto*/ -static PyMethodDef __pyx_mdef_8freenect_2start_depth = {__Pyx_NAMESTR("start_depth"), (PyCFunction)__pyx_pf_8freenect_2start_depth, METH_O, __Pyx_DOCSTR(0)}; -static PyObject *__pyx_pf_8freenect_2start_depth(PyObject *__pyx_self, PyObject *__pyx_v_dev) { +static PyObject *__pyx_pf_8freenect_4start_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; - __Pyx_RefNannySetupContext("start_depth"); - __pyx_self = __pyx_self; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dev), __pyx_ptype_8freenect_DevPtr, 1, "dev", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("start_depth", 0); - /* "freenect.pyx":209 + /* "freenect.pyx":213 * * def start_depth(DevPtr dev): * return freenect_start_depth(dev._ptr) # <<<<<<<<<<<<<< @@ -1572,7 +2264,7 @@ static PyObject *__pyx_pf_8freenect_2start_depth(PyObject *__pyx_self, PyObject * def start_video(DevPtr dev): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyInt_FromLong(freenect_start_depth(((struct __pyx_obj_8freenect_DevPtr *)__pyx_v_dev)->_ptr)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromLong(freenect_start_depth(__pyx_v_dev->_ptr)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -1582,7 +2274,7 @@ static PyObject *__pyx_pf_8freenect_2start_depth(PyObject *__pyx_self, PyObject goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("freenect.start_depth"); + __Pyx_AddTraceback("freenect.start_depth", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -1590,7 +2282,27 @@ static PyObject *__pyx_pf_8freenect_2start_depth(PyObject *__pyx_self, PyObject return __pyx_r; } -/* "freenect.pyx":211 +/* Python wrapper */ +static PyObject *__pyx_pw_8freenect_7start_video(PyObject *__pyx_self, PyObject *__pyx_v_dev); /*proto*/ +static PyMethodDef __pyx_mdef_8freenect_7start_video = {__Pyx_NAMESTR("start_video"), (PyCFunction)__pyx_pw_8freenect_7start_video, METH_O, __Pyx_DOCSTR(0)}; +static PyObject *__pyx_pw_8freenect_7start_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 = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_8freenect_6start_video(__pyx_self, ((struct __pyx_obj_8freenect_DevPtr *)__pyx_v_dev)); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "freenect.pyx":215 * return freenect_start_depth(dev._ptr) * * def start_video(DevPtr dev): # <<<<<<<<<<<<<< @@ -1598,16 +2310,16 @@ static PyObject *__pyx_pf_8freenect_2start_depth(PyObject *__pyx_self, PyObject * */ -static PyObject *__pyx_pf_8freenect_3start_video(PyObject *__pyx_self, PyObject *__pyx_v_dev); /*proto*/ -static PyMethodDef __pyx_mdef_8freenect_3start_video = {__Pyx_NAMESTR("start_video"), (PyCFunction)__pyx_pf_8freenect_3start_video, METH_O, __Pyx_DOCSTR(0)}; -static PyObject *__pyx_pf_8freenect_3start_video(PyObject *__pyx_self, PyObject *__pyx_v_dev) { +static PyObject *__pyx_pf_8freenect_6start_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; - __Pyx_RefNannySetupContext("start_video"); - __pyx_self = __pyx_self; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dev), __pyx_ptype_8freenect_DevPtr, 1, "dev", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("start_video", 0); - /* "freenect.pyx":212 + /* "freenect.pyx":216 * * def start_video(DevPtr dev): * return freenect_start_video(dev._ptr) # <<<<<<<<<<<<<< @@ -1615,7 +2327,7 @@ static PyObject *__pyx_pf_8freenect_3start_video(PyObject *__pyx_self, PyObject * def stop_depth(DevPtr dev): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyInt_FromLong(freenect_start_video(((struct __pyx_obj_8freenect_DevPtr *)__pyx_v_dev)->_ptr)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromLong(freenect_start_video(__pyx_v_dev->_ptr)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -1625,7 +2337,7 @@ static PyObject *__pyx_pf_8freenect_3start_video(PyObject *__pyx_self, PyObject goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("freenect.start_video"); + __Pyx_AddTraceback("freenect.start_video", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -1633,7 +2345,27 @@ static PyObject *__pyx_pf_8freenect_3start_video(PyObject *__pyx_self, PyObject return __pyx_r; } -/* "freenect.pyx":214 +/* Python wrapper */ +static PyObject *__pyx_pw_8freenect_9stop_depth(PyObject *__pyx_self, PyObject *__pyx_v_dev); /*proto*/ +static PyMethodDef __pyx_mdef_8freenect_9stop_depth = {__Pyx_NAMESTR("stop_depth"), (PyCFunction)__pyx_pw_8freenect_9stop_depth, METH_O, __Pyx_DOCSTR(0)}; +static PyObject *__pyx_pw_8freenect_9stop_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 = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_8freenect_8stop_depth(__pyx_self, ((struct __pyx_obj_8freenect_DevPtr *)__pyx_v_dev)); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "freenect.pyx":218 * return freenect_start_video(dev._ptr) * * def stop_depth(DevPtr dev): # <<<<<<<<<<<<<< @@ -1641,16 +2373,16 @@ static PyObject *__pyx_pf_8freenect_3start_video(PyObject *__pyx_self, PyObject * */ -static PyObject *__pyx_pf_8freenect_4stop_depth(PyObject *__pyx_self, PyObject *__pyx_v_dev); /*proto*/ -static PyMethodDef __pyx_mdef_8freenect_4stop_depth = {__Pyx_NAMESTR("stop_depth"), (PyCFunction)__pyx_pf_8freenect_4stop_depth, METH_O, __Pyx_DOCSTR(0)}; -static PyObject *__pyx_pf_8freenect_4stop_depth(PyObject *__pyx_self, PyObject *__pyx_v_dev) { +static PyObject *__pyx_pf_8freenect_8stop_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; - __Pyx_RefNannySetupContext("stop_depth"); - __pyx_self = __pyx_self; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dev), __pyx_ptype_8freenect_DevPtr, 1, "dev", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("stop_depth", 0); - /* "freenect.pyx":215 + /* "freenect.pyx":219 * * def stop_depth(DevPtr dev): * return freenect_stop_depth(dev._ptr) # <<<<<<<<<<<<<< @@ -1658,7 +2390,7 @@ static PyObject *__pyx_pf_8freenect_4stop_depth(PyObject *__pyx_self, PyObject * * def stop_video(DevPtr dev): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyInt_FromLong(freenect_stop_depth(((struct __pyx_obj_8freenect_DevPtr *)__pyx_v_dev)->_ptr)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromLong(freenect_stop_depth(__pyx_v_dev->_ptr)); 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_r = __pyx_t_1; __pyx_t_1 = 0; @@ -1668,7 +2400,7 @@ static PyObject *__pyx_pf_8freenect_4stop_depth(PyObject *__pyx_self, PyObject * goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("freenect.stop_depth"); + __Pyx_AddTraceback("freenect.stop_depth", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -1676,7 +2408,27 @@ static PyObject *__pyx_pf_8freenect_4stop_depth(PyObject *__pyx_self, PyObject * return __pyx_r; } -/* "freenect.pyx":217 +/* Python wrapper */ +static PyObject *__pyx_pw_8freenect_11stop_video(PyObject *__pyx_self, PyObject *__pyx_v_dev); /*proto*/ +static PyMethodDef __pyx_mdef_8freenect_11stop_video = {__Pyx_NAMESTR("stop_video"), (PyCFunction)__pyx_pw_8freenect_11stop_video, METH_O, __Pyx_DOCSTR(0)}; +static PyObject *__pyx_pw_8freenect_11stop_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 = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_8freenect_10stop_video(__pyx_self, ((struct __pyx_obj_8freenect_DevPtr *)__pyx_v_dev)); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "freenect.pyx":221 * return freenect_stop_depth(dev._ptr) * * def stop_video(DevPtr dev): # <<<<<<<<<<<<<< @@ -1684,16 +2436,16 @@ static PyObject *__pyx_pf_8freenect_4stop_depth(PyObject *__pyx_self, PyObject * * */ -static PyObject *__pyx_pf_8freenect_5stop_video(PyObject *__pyx_self, PyObject *__pyx_v_dev); /*proto*/ -static PyMethodDef __pyx_mdef_8freenect_5stop_video = {__Pyx_NAMESTR("stop_video"), (PyCFunction)__pyx_pf_8freenect_5stop_video, METH_O, __Pyx_DOCSTR(0)}; -static PyObject *__pyx_pf_8freenect_5stop_video(PyObject *__pyx_self, PyObject *__pyx_v_dev) { +static PyObject *__pyx_pf_8freenect_10stop_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; - __Pyx_RefNannySetupContext("stop_video"); - __pyx_self = __pyx_self; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dev), __pyx_ptype_8freenect_DevPtr, 1, "dev", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("stop_video", 0); - /* "freenect.pyx":218 + /* "freenect.pyx":222 * * def stop_video(DevPtr dev): * return freenect_stop_video(dev._ptr) # <<<<<<<<<<<<<< @@ -1701,7 +2453,7 @@ static PyObject *__pyx_pf_8freenect_5stop_video(PyObject *__pyx_self, PyObject * * def shutdown(CtxPtr ctx): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyInt_FromLong(freenect_stop_video(((struct __pyx_obj_8freenect_DevPtr *)__pyx_v_dev)->_ptr)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromLong(freenect_stop_video(__pyx_v_dev->_ptr)); 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_r = __pyx_t_1; __pyx_t_1 = 0; @@ -1711,7 +2463,7 @@ static PyObject *__pyx_pf_8freenect_5stop_video(PyObject *__pyx_self, PyObject * goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("freenect.stop_video"); + __Pyx_AddTraceback("freenect.stop_video", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -1719,7 +2471,27 @@ static PyObject *__pyx_pf_8freenect_5stop_video(PyObject *__pyx_self, PyObject * return __pyx_r; } -/* "freenect.pyx":220 +/* Python wrapper */ +static PyObject *__pyx_pw_8freenect_13shutdown(PyObject *__pyx_self, PyObject *__pyx_v_ctx); /*proto*/ +static PyMethodDef __pyx_mdef_8freenect_13shutdown = {__Pyx_NAMESTR("shutdown"), (PyCFunction)__pyx_pw_8freenect_13shutdown, METH_O, __Pyx_DOCSTR(0)}; +static PyObject *__pyx_pw_8freenect_13shutdown(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 = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_8freenect_12shutdown(__pyx_self, ((struct __pyx_obj_8freenect_CtxPtr *)__pyx_v_ctx)); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "freenect.pyx":224 * return freenect_stop_video(dev._ptr) * * def shutdown(CtxPtr ctx): # <<<<<<<<<<<<<< @@ -1727,16 +2499,16 @@ static PyObject *__pyx_pf_8freenect_5stop_video(PyObject *__pyx_self, PyObject * * */ -static PyObject *__pyx_pf_8freenect_6shutdown(PyObject *__pyx_self, PyObject *__pyx_v_ctx); /*proto*/ -static PyMethodDef __pyx_mdef_8freenect_6shutdown = {__Pyx_NAMESTR("shutdown"), (PyCFunction)__pyx_pf_8freenect_6shutdown, METH_O, __Pyx_DOCSTR(0)}; -static PyObject *__pyx_pf_8freenect_6shutdown(PyObject *__pyx_self, PyObject *__pyx_v_ctx) { +static PyObject *__pyx_pf_8freenect_12shutdown(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8freenect_CtxPtr *__pyx_v_ctx) { PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("shutdown"); - __pyx_self = __pyx_self; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_ctx), __pyx_ptype_8freenect_CtxPtr, 1, "ctx", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 220; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("shutdown", 0); - /* "freenect.pyx":221 + /* "freenect.pyx":225 * * def shutdown(CtxPtr ctx): * return freenect_shutdown(ctx._ptr) # <<<<<<<<<<<<<< @@ -1744,7 +2516,7 @@ static PyObject *__pyx_pf_8freenect_6shutdown(PyObject *__pyx_self, PyObject *__ * def process_events(CtxPtr ctx): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyInt_FromLong(freenect_shutdown(((struct __pyx_obj_8freenect_CtxPtr *)__pyx_v_ctx)->_ptr)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromLong(freenect_shutdown(__pyx_v_ctx->_ptr)); 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); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -1754,7 +2526,7 @@ static PyObject *__pyx_pf_8freenect_6shutdown(PyObject *__pyx_self, PyObject *__ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("freenect.shutdown"); + __Pyx_AddTraceback("freenect.shutdown", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -1762,7 +2534,27 @@ static PyObject *__pyx_pf_8freenect_6shutdown(PyObject *__pyx_self, PyObject *__ return __pyx_r; } -/* "freenect.pyx":223 +/* Python wrapper */ +static PyObject *__pyx_pw_8freenect_15process_events(PyObject *__pyx_self, PyObject *__pyx_v_ctx); /*proto*/ +static PyMethodDef __pyx_mdef_8freenect_15process_events = {__Pyx_NAMESTR("process_events"), (PyCFunction)__pyx_pw_8freenect_15process_events, METH_O, __Pyx_DOCSTR(0)}; +static PyObject *__pyx_pw_8freenect_15process_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 = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_8freenect_14process_events(__pyx_self, ((struct __pyx_obj_8freenect_CtxPtr *)__pyx_v_ctx)); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "freenect.pyx":227 * return freenect_shutdown(ctx._ptr) * * def process_events(CtxPtr ctx): # <<<<<<<<<<<<<< @@ -1770,16 +2562,16 @@ static PyObject *__pyx_pf_8freenect_6shutdown(PyObject *__pyx_self, PyObject *__ * */ -static PyObject *__pyx_pf_8freenect_7process_events(PyObject *__pyx_self, PyObject *__pyx_v_ctx); /*proto*/ -static PyMethodDef __pyx_mdef_8freenect_7process_events = {__Pyx_NAMESTR("process_events"), (PyCFunction)__pyx_pf_8freenect_7process_events, METH_O, __Pyx_DOCSTR(0)}; -static PyObject *__pyx_pf_8freenect_7process_events(PyObject *__pyx_self, PyObject *__pyx_v_ctx) { +static PyObject *__pyx_pf_8freenect_14process_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; - __Pyx_RefNannySetupContext("process_events"); - __pyx_self = __pyx_self; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_ctx), __pyx_ptype_8freenect_CtxPtr, 1, "ctx", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("process_events", 0); - /* "freenect.pyx":224 + /* "freenect.pyx":228 * * def process_events(CtxPtr ctx): * return freenect_process_events(ctx._ptr) # <<<<<<<<<<<<<< @@ -1787,7 +2579,7 @@ static PyObject *__pyx_pf_8freenect_7process_events(PyObject *__pyx_self, PyObje * def num_devices(CtxPtr ctx): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyInt_FromLong(freenect_process_events(((struct __pyx_obj_8freenect_CtxPtr *)__pyx_v_ctx)->_ptr)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromLong(freenect_process_events(__pyx_v_ctx->_ptr)); 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); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -1797,7 +2589,7 @@ static PyObject *__pyx_pf_8freenect_7process_events(PyObject *__pyx_self, PyObje goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("freenect.process_events"); + __Pyx_AddTraceback("freenect.process_events", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -1805,7 +2597,27 @@ static PyObject *__pyx_pf_8freenect_7process_events(PyObject *__pyx_self, PyObje return __pyx_r; } -/* "freenect.pyx":226 +/* Python wrapper */ +static PyObject *__pyx_pw_8freenect_17num_devices(PyObject *__pyx_self, PyObject *__pyx_v_ctx); /*proto*/ +static PyMethodDef __pyx_mdef_8freenect_17num_devices = {__Pyx_NAMESTR("num_devices"), (PyCFunction)__pyx_pw_8freenect_17num_devices, METH_O, __Pyx_DOCSTR(0)}; +static PyObject *__pyx_pw_8freenect_17num_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 = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_8freenect_16num_devices(__pyx_self, ((struct __pyx_obj_8freenect_CtxPtr *)__pyx_v_ctx)); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "freenect.pyx":230 * return freenect_process_events(ctx._ptr) * * def num_devices(CtxPtr ctx): # <<<<<<<<<<<<<< @@ -1813,16 +2625,16 @@ static PyObject *__pyx_pf_8freenect_7process_events(PyObject *__pyx_self, PyObje * */ -static PyObject *__pyx_pf_8freenect_8num_devices(PyObject *__pyx_self, PyObject *__pyx_v_ctx); /*proto*/ -static PyMethodDef __pyx_mdef_8freenect_8num_devices = {__Pyx_NAMESTR("num_devices"), (PyCFunction)__pyx_pf_8freenect_8num_devices, METH_O, __Pyx_DOCSTR(0)}; -static PyObject *__pyx_pf_8freenect_8num_devices(PyObject *__pyx_self, PyObject *__pyx_v_ctx) { +static PyObject *__pyx_pf_8freenect_16num_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; - __Pyx_RefNannySetupContext("num_devices"); - __pyx_self = __pyx_self; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_ctx), __pyx_ptype_8freenect_CtxPtr, 1, "ctx", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("num_devices", 0); - /* "freenect.pyx":227 + /* "freenect.pyx":231 * * def num_devices(CtxPtr ctx): * return freenect_num_devices(ctx._ptr) # <<<<<<<<<<<<<< @@ -1830,7 +2642,7 @@ static PyObject *__pyx_pf_8freenect_8num_devices(PyObject *__pyx_self, PyObject * def close_device(DevPtr dev): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyInt_FromLong(freenect_num_devices(((struct __pyx_obj_8freenect_CtxPtr *)__pyx_v_ctx)->_ptr)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromLong(freenect_num_devices(__pyx_v_ctx->_ptr)); 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); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -1840,7 +2652,7 @@ static PyObject *__pyx_pf_8freenect_8num_devices(PyObject *__pyx_self, PyObject goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("freenect.num_devices"); + __Pyx_AddTraceback("freenect.num_devices", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -1848,7 +2660,27 @@ static PyObject *__pyx_pf_8freenect_8num_devices(PyObject *__pyx_self, PyObject return __pyx_r; } -/* "freenect.pyx":229 +/* Python wrapper */ +static PyObject *__pyx_pw_8freenect_19close_device(PyObject *__pyx_self, PyObject *__pyx_v_dev); /*proto*/ +static PyMethodDef __pyx_mdef_8freenect_19close_device = {__Pyx_NAMESTR("close_device"), (PyCFunction)__pyx_pw_8freenect_19close_device, METH_O, __Pyx_DOCSTR(0)}; +static PyObject *__pyx_pw_8freenect_19close_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 = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_8freenect_18close_device(__pyx_self, ((struct __pyx_obj_8freenect_DevPtr *)__pyx_v_dev)); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "freenect.pyx":233 * return freenect_num_devices(ctx._ptr) * * def close_device(DevPtr dev): # <<<<<<<<<<<<<< @@ -1856,16 +2688,16 @@ static PyObject *__pyx_pf_8freenect_8num_devices(PyObject *__pyx_self, PyObject * */ -static PyObject *__pyx_pf_8freenect_9close_device(PyObject *__pyx_self, PyObject *__pyx_v_dev); /*proto*/ -static PyMethodDef __pyx_mdef_8freenect_9close_device = {__Pyx_NAMESTR("close_device"), (PyCFunction)__pyx_pf_8freenect_9close_device, METH_O, __Pyx_DOCSTR(0)}; -static PyObject *__pyx_pf_8freenect_9close_device(PyObject *__pyx_self, PyObject *__pyx_v_dev) { +static PyObject *__pyx_pf_8freenect_18close_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; - __Pyx_RefNannySetupContext("close_device"); - __pyx_self = __pyx_self; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dev), __pyx_ptype_8freenect_DevPtr, 1, "dev", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("close_device", 0); - /* "freenect.pyx":230 + /* "freenect.pyx":234 * * def close_device(DevPtr dev): * return freenect_close_device(dev._ptr) # <<<<<<<<<<<<<< @@ -1873,7 +2705,7 @@ static PyObject *__pyx_pf_8freenect_9close_device(PyObject *__pyx_self, PyObject * def set_tilt_degs(DevPtr dev, float angle): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyInt_FromLong(freenect_close_device(((struct __pyx_obj_8freenect_DevPtr *)__pyx_v_dev)->_ptr)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromLong(freenect_close_device(__pyx_v_dev->_ptr)); 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); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -1883,7 +2715,7 @@ static PyObject *__pyx_pf_8freenect_9close_device(PyObject *__pyx_self, PyObject goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("freenect.close_device"); + __Pyx_AddTraceback("freenect.close_device", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -1891,66 +2723,85 @@ static PyObject *__pyx_pf_8freenect_9close_device(PyObject *__pyx_self, PyObject return __pyx_r; } -/* "freenect.pyx":232 - * return freenect_close_device(dev._ptr) - * - * def set_tilt_degs(DevPtr dev, float angle): # <<<<<<<<<<<<<< - * freenect_set_tilt_degs(dev._ptr, angle) - * - */ - -static PyObject *__pyx_pf_8freenect_10set_tilt_degs(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyMethodDef __pyx_mdef_8freenect_10set_tilt_degs = {__Pyx_NAMESTR("set_tilt_degs"), (PyCFunction)__pyx_pf_8freenect_10set_tilt_degs, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}; -static PyObject *__pyx_pf_8freenect_10set_tilt_degs(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +/* Python wrapper */ +static PyObject *__pyx_pw_8freenect_21set_tilt_degs(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyMethodDef __pyx_mdef_8freenect_21set_tilt_degs = {__Pyx_NAMESTR("set_tilt_degs"), (PyCFunction)__pyx_pw_8freenect_21set_tilt_degs, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}; +static PyObject *__pyx_pw_8freenect_21set_tilt_degs(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { struct __pyx_obj_8freenect_DevPtr *__pyx_v_dev = 0; float __pyx_v_angle; - PyObject *__pyx_r = NULL; - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__dev,&__pyx_n_s__angle,0}; - __Pyx_RefNannySetupContext("set_tilt_degs"); - __pyx_self = __pyx_self; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args = PyDict_Size(__pyx_kwds); + 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}; - 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; - } - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 0: - values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__dev); - if (likely(values[0])) kw_args--; - else goto __pyx_L5_argtuple_error; - case 1: - values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__angle); - if (likely(values[1])) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("set_tilt_degs", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + 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; } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "set_tilt_degs") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L3_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 = 236; __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 = 236; __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_AsDouble(values[1]); if (unlikely((__pyx_v_angle == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { - goto __pyx_L5_argtuple_error; - } else { - __pyx_v_dev = ((struct __pyx_obj_8freenect_DevPtr *)PyTuple_GET_ITEM(__pyx_args, 0)); - __pyx_v_angle = __pyx_PyFloat_AsDouble(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_angle == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_angle = __pyx_PyFloat_AsFloat(values[1]); if (unlikely((__pyx_v_angle == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __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 = 232; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("set_tilt_degs", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; - __Pyx_AddTraceback("freenect.set_tilt_degs"); + __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 = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dev), __pyx_ptype_8freenect_DevPtr, 1, "dev", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_8freenect_20set_tilt_degs(__pyx_self, __pyx_v_dev, __pyx_v_angle); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "freenect.pyx":233 +/* "freenect.pyx":236 + * return freenect_close_device(dev._ptr) + * + * def set_tilt_degs(DevPtr dev, float angle): # <<<<<<<<<<<<<< + * freenect_set_tilt_degs(dev._ptr, angle) + * + */ + +static PyObject *__pyx_pf_8freenect_20set_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":237 * * def set_tilt_degs(DevPtr dev, float angle): * freenect_set_tilt_degs(dev._ptr, angle) # <<<<<<<<<<<<<< @@ -1960,77 +2811,94 @@ static PyObject *__pyx_pf_8freenect_10set_tilt_degs(PyObject *__pyx_self, PyObje freenect_set_tilt_degs(__pyx_v_dev->_ptr, __pyx_v_angle); __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_AddTraceback("freenect.set_tilt_degs"); - __pyx_r = NULL; - __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "freenect.pyx":235 - * freenect_set_tilt_degs(dev._ptr, angle) - * - * def set_led(DevPtr dev, freenect_led_options option): # <<<<<<<<<<<<<< - * return freenect_set_led(dev._ptr, option) - * - */ - -static PyObject *__pyx_pf_8freenect_11set_led(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyMethodDef __pyx_mdef_8freenect_11set_led = {__Pyx_NAMESTR("set_led"), (PyCFunction)__pyx_pf_8freenect_11set_led, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}; -static PyObject *__pyx_pf_8freenect_11set_led(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +/* Python wrapper */ +static PyObject *__pyx_pw_8freenect_23set_led(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyMethodDef __pyx_mdef_8freenect_23set_led = {__Pyx_NAMESTR("set_led"), (PyCFunction)__pyx_pw_8freenect_23set_led, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}; +static PyObject *__pyx_pw_8freenect_23set_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; - PyObject *__pyx_r = NULL; - PyObject *__pyx_t_1 = NULL; - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__dev,&__pyx_n_s__option,0}; - __Pyx_RefNannySetupContext("set_led"); - __pyx_self = __pyx_self; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args = PyDict_Size(__pyx_kwds); + 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}; - 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; - } - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 0: - values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__dev); - if (likely(values[0])) kw_args--; - else goto __pyx_L5_argtuple_error; - case 1: - values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__option); - if (likely(values[1])) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("set_led", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + 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; } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "set_led") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L3_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 = 239; __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 = 239; __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 = PyInt_AsLong(values[1]); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { - goto __pyx_L5_argtuple_error; - } else { - __pyx_v_dev = ((struct __pyx_obj_8freenect_DevPtr *)PyTuple_GET_ITEM(__pyx_args, 0)); - __pyx_v_option = PyInt_AsLong(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_option = ((freenect_led_options)PyInt_AsLong(values[1])); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __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 = 235; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("set_led", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; - __Pyx_AddTraceback("freenect.set_led"); + __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 = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dev), __pyx_ptype_8freenect_DevPtr, 1, "dev", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_8freenect_22set_led(__pyx_self, __pyx_v_dev, __pyx_v_option); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "freenect.pyx":236 +/* "freenect.pyx":239 + * freenect_set_tilt_degs(dev._ptr, angle) + * + * def set_led(DevPtr dev, freenect_led_options option): # <<<<<<<<<<<<<< + * return freenect_set_led(dev._ptr, option) + * + */ + +static PyObject *__pyx_pf_8freenect_22set_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":240 * * def set_led(DevPtr dev, freenect_led_options option): * return freenect_set_led(dev._ptr, option) # <<<<<<<<<<<<<< @@ -2038,7 +2906,7 @@ static PyObject *__pyx_pf_8freenect_11set_led(PyObject *__pyx_self, PyObject *__ * def update_tilt_state(DevPtr dev): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyInt_FromLong(freenect_set_led(__pyx_v_dev->_ptr, __pyx_v_option)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromLong(freenect_set_led(__pyx_v_dev->_ptr, __pyx_v_option)); 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); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -2048,7 +2916,7 @@ static PyObject *__pyx_pf_8freenect_11set_led(PyObject *__pyx_self, PyObject *__ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("freenect.set_led"); + __Pyx_AddTraceback("freenect.set_led", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -2056,24 +2924,44 @@ static PyObject *__pyx_pf_8freenect_11set_led(PyObject *__pyx_self, PyObject *__ return __pyx_r; } -/* "freenect.pyx":238 - * return freenect_set_led(dev._ptr, option) +/* Python wrapper */ +static PyObject *__pyx_pw_8freenect_25update_tilt_state(PyObject *__pyx_self, PyObject *__pyx_v_dev); /*proto*/ +static PyMethodDef __pyx_mdef_8freenect_25update_tilt_state = {__Pyx_NAMESTR("update_tilt_state"), (PyCFunction)__pyx_pw_8freenect_25update_tilt_state, METH_O, __Pyx_DOCSTR(0)}; +static PyObject *__pyx_pw_8freenect_25update_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 = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_8freenect_24update_tilt_state(__pyx_self, ((struct __pyx_obj_8freenect_DevPtr *)__pyx_v_dev)); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "freenect.pyx":242 + * return freenect_set_led(dev._ptr, option) * * def update_tilt_state(DevPtr dev): # <<<<<<<<<<<<<< * return freenect_update_tilt_state(dev._ptr) * */ -static PyObject *__pyx_pf_8freenect_12update_tilt_state(PyObject *__pyx_self, PyObject *__pyx_v_dev); /*proto*/ -static PyMethodDef __pyx_mdef_8freenect_12update_tilt_state = {__Pyx_NAMESTR("update_tilt_state"), (PyCFunction)__pyx_pf_8freenect_12update_tilt_state, METH_O, __Pyx_DOCSTR(0)}; -static PyObject *__pyx_pf_8freenect_12update_tilt_state(PyObject *__pyx_self, PyObject *__pyx_v_dev) { +static PyObject *__pyx_pf_8freenect_24update_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; - __Pyx_RefNannySetupContext("update_tilt_state"); - __pyx_self = __pyx_self; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dev), __pyx_ptype_8freenect_DevPtr, 1, "dev", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("update_tilt_state", 0); - /* "freenect.pyx":239 + /* "freenect.pyx":243 * * def update_tilt_state(DevPtr dev): * return freenect_update_tilt_state(dev._ptr) # <<<<<<<<<<<<<< @@ -2081,7 +2969,7 @@ static PyObject *__pyx_pf_8freenect_12update_tilt_state(PyObject *__pyx_self, Py * def get_tilt_state(DevPtr dev): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyInt_FromLong(freenect_update_tilt_state(((struct __pyx_obj_8freenect_DevPtr *)__pyx_v_dev)->_ptr)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromLong(freenect_update_tilt_state(__pyx_v_dev->_ptr)); 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); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -2091,7 +2979,7 @@ static PyObject *__pyx_pf_8freenect_12update_tilt_state(PyObject *__pyx_self, Py goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("freenect.update_tilt_state"); + __Pyx_AddTraceback("freenect.update_tilt_state", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -2099,7 +2987,27 @@ static PyObject *__pyx_pf_8freenect_12update_tilt_state(PyObject *__pyx_self, Py return __pyx_r; } -/* "freenect.pyx":241 +/* Python wrapper */ +static PyObject *__pyx_pw_8freenect_27get_tilt_state(PyObject *__pyx_self, PyObject *__pyx_v_dev); /*proto*/ +static PyMethodDef __pyx_mdef_8freenect_27get_tilt_state = {__Pyx_NAMESTR("get_tilt_state"), (PyCFunction)__pyx_pw_8freenect_27get_tilt_state, METH_O, __Pyx_DOCSTR(0)}; +static PyObject *__pyx_pw_8freenect_27get_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 = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_8freenect_26get_tilt_state(__pyx_self, ((struct __pyx_obj_8freenect_DevPtr *)__pyx_v_dev)); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "freenect.pyx":245 * return freenect_update_tilt_state(dev._ptr) * * def get_tilt_state(DevPtr dev): # <<<<<<<<<<<<<< @@ -2107,41 +3015,39 @@ static PyObject *__pyx_pf_8freenect_12update_tilt_state(PyObject *__pyx_self, Py * cdef StatePtr state_out */ -static PyObject *__pyx_pf_8freenect_13get_tilt_state(PyObject *__pyx_self, PyObject *__pyx_v_dev); /*proto*/ -static PyMethodDef __pyx_mdef_8freenect_13get_tilt_state = {__Pyx_NAMESTR("get_tilt_state"), (PyCFunction)__pyx_pf_8freenect_13get_tilt_state, METH_O, __Pyx_DOCSTR(0)}; -static PyObject *__pyx_pf_8freenect_13get_tilt_state(PyObject *__pyx_self, PyObject *__pyx_v_dev) { +static PyObject *__pyx_pf_8freenect_26get_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; + struct __pyx_obj_8freenect_StatePtr *__pyx_v_state_out = 0; PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("get_tilt_state"); - __pyx_self = __pyx_self; - __pyx_v_state_out = ((struct __pyx_obj_8freenect_StatePtr *)Py_None); __Pyx_INCREF(Py_None); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dev), __pyx_ptype_8freenect_DevPtr, 1, "dev", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("get_tilt_state", 0); - /* "freenect.pyx":242 + /* "freenect.pyx":246 * * def get_tilt_state(DevPtr dev): * cdef freenect_raw_tilt_state* state = freenect_get_tilt_state(dev._ptr) # <<<<<<<<<<<<<< * cdef StatePtr state_out * state_out = StatePtr() */ - __pyx_v_state = freenect_get_tilt_state(((struct __pyx_obj_8freenect_DevPtr *)__pyx_v_dev)->_ptr); + __pyx_v_state = freenect_get_tilt_state(__pyx_v_dev->_ptr); - /* "freenect.pyx":244 + /* "freenect.pyx":248 * cdef freenect_raw_tilt_state* state = freenect_get_tilt_state(dev._ptr) * cdef StatePtr state_out * state_out = StatePtr() # <<<<<<<<<<<<<< * state_out._ptr = state * return state_out */ - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_8freenect_StatePtr)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_8freenect_StatePtr)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(((PyObject *)__pyx_v_state_out)); __pyx_v_state_out = ((struct __pyx_obj_8freenect_StatePtr *)__pyx_t_1); __pyx_t_1 = 0; - /* "freenect.pyx":245 + /* "freenect.pyx":249 * cdef StatePtr state_out * state_out = StatePtr() * state_out._ptr = state # <<<<<<<<<<<<<< @@ -2150,7 +3056,7 @@ static PyObject *__pyx_pf_8freenect_13get_tilt_state(PyObject *__pyx_self, PyObj */ __pyx_v_state_out->_ptr = __pyx_v_state; - /* "freenect.pyx":246 + /* "freenect.pyx":250 * state_out = StatePtr() * state_out._ptr = state * return state_out # <<<<<<<<<<<<<< @@ -2166,16 +3072,36 @@ static PyObject *__pyx_pf_8freenect_13get_tilt_state(PyObject *__pyx_self, PyObj goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("freenect.get_tilt_state"); + __Pyx_AddTraceback("freenect.get_tilt_state", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; - __Pyx_DECREF((PyObject *)__pyx_v_state_out); + __Pyx_XDECREF((PyObject *)__pyx_v_state_out); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "freenect.pyx":248 +/* Python wrapper */ +static PyObject *__pyx_pw_8freenect_29get_mks_accel(PyObject *__pyx_self, PyObject *__pyx_v_state); /*proto*/ +static PyMethodDef __pyx_mdef_8freenect_29get_mks_accel = {__Pyx_NAMESTR("get_mks_accel"), (PyCFunction)__pyx_pw_8freenect_29get_mks_accel, METH_O, __Pyx_DOCSTR(0)}; +static PyObject *__pyx_pw_8freenect_29get_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 = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_8freenect_28get_mks_accel(__pyx_self, ((struct __pyx_obj_8freenect_StatePtr *)__pyx_v_state)); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "freenect.pyx":252 * return state_out * * def get_mks_accel(StatePtr state): # <<<<<<<<<<<<<< @@ -2183,31 +3109,31 @@ static PyObject *__pyx_pf_8freenect_13get_tilt_state(PyObject *__pyx_self, PyObj * freenect_get_mks_accel(state._ptr, &x, &y, &z) */ -static PyObject *__pyx_pf_8freenect_14get_mks_accel(PyObject *__pyx_self, PyObject *__pyx_v_state); /*proto*/ -static PyMethodDef __pyx_mdef_8freenect_14get_mks_accel = {__Pyx_NAMESTR("get_mks_accel"), (PyCFunction)__pyx_pf_8freenect_14get_mks_accel, METH_O, __Pyx_DOCSTR(0)}; -static PyObject *__pyx_pf_8freenect_14get_mks_accel(PyObject *__pyx_self, PyObject *__pyx_v_state) { +static PyObject *__pyx_pf_8freenect_28get_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; - __Pyx_RefNannySetupContext("get_mks_accel"); - __pyx_self = __pyx_self; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_state), __pyx_ptype_8freenect_StatePtr, 1, "state", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("get_mks_accel", 0); - /* "freenect.pyx":250 + /* "freenect.pyx":254 * 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(((struct __pyx_obj_8freenect_StatePtr *)__pyx_v_state)->_ptr, (&__pyx_v_x), (&__pyx_v_y), (&__pyx_v_z)); + freenect_get_mks_accel(__pyx_v_state->_ptr, (&__pyx_v_x), (&__pyx_v_y), (&__pyx_v_z)); - /* "freenect.pyx":251 + /* "freenect.pyx":255 * cdef double x, y, z * freenect_get_mks_accel(state._ptr, &x, &y, &z) * return x, y, z # <<<<<<<<<<<<<< @@ -2215,14 +3141,14 @@ static PyObject *__pyx_pf_8freenect_14get_mks_accel(PyObject *__pyx_self, PyObje * 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 = 251; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyFloat_FromDouble(__pyx_v_x); 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); - __pyx_t_2 = PyFloat_FromDouble(__pyx_v_y); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyFloat_FromDouble(__pyx_v_y); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; __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 = 251; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyFloat_FromDouble(__pyx_v_z); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; __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 = 251; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_4)); + __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; __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); @@ -2243,7 +3169,7 @@ static PyObject *__pyx_pf_8freenect_14get_mks_accel(PyObject *__pyx_self, PyObje __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); - __Pyx_AddTraceback("freenect.get_mks_accel"); + __Pyx_AddTraceback("freenect.get_mks_accel", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -2251,7 +3177,28 @@ static PyObject *__pyx_pf_8freenect_14get_mks_accel(PyObject *__pyx_self, PyObje return __pyx_r; } -/* "freenect.pyx":253 +/* Python wrapper */ +static PyObject *__pyx_pw_8freenect_31get_accel(PyObject *__pyx_self, PyObject *__pyx_v_dev); /*proto*/ +static char __pyx_doc_8freenect_30get_accel[] = "MKS Accelerometer helper\n\n Args:\n dev:\n\n Returns:\n (x, y, z) accelerometer values\n "; +static PyMethodDef __pyx_mdef_8freenect_31get_accel = {__Pyx_NAMESTR("get_accel"), (PyCFunction)__pyx_pw_8freenect_31get_accel, METH_O, __Pyx_DOCSTR(__pyx_doc_8freenect_30get_accel)}; +static PyObject *__pyx_pw_8freenect_31get_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 = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_8freenect_30get_accel(__pyx_self, ((struct __pyx_obj_8freenect_DevPtr *)__pyx_v_dev)); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "freenect.pyx":257 * return x, y, z * * def get_accel(DevPtr dev): # <<<<<<<<<<<<<< @@ -2259,40 +3206,39 @@ static PyObject *__pyx_pf_8freenect_14get_mks_accel(PyObject *__pyx_self, PyObje * */ -static PyObject *__pyx_pf_8freenect_15get_accel(PyObject *__pyx_self, PyObject *__pyx_v_dev); /*proto*/ -static char __pyx_doc_8freenect_15get_accel[] = "MKS Accelerometer helper\n\n Args:\n dev:\n\n Returns:\n (x, y, z) accelerometer values\n "; -static PyMethodDef __pyx_mdef_8freenect_15get_accel = {__Pyx_NAMESTR("get_accel"), (PyCFunction)__pyx_pf_8freenect_15get_accel, METH_O, __Pyx_DOCSTR(__pyx_doc_8freenect_15get_accel)}; -static PyObject *__pyx_pf_8freenect_15get_accel(PyObject *__pyx_self, PyObject *__pyx_v_dev) { +static PyObject *__pyx_pf_8freenect_30get_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; - __Pyx_RefNannySetupContext("get_accel"); - __pyx_self = __pyx_self; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dev), __pyx_ptype_8freenect_DevPtr, 1, "dev", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("get_accel", 0); - /* "freenect.pyx":262 + /* "freenect.pyx":266 * (x, y, z) accelerometer values * """ * update_tilt_state(dev) # <<<<<<<<<<<<<< * return get_mks_accel(get_tilt_state(dev)) * */ - __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__update_tilt_state); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__update_tilt_state); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; __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 = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_2)); - __Pyx_INCREF(__pyx_v_dev); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_dev); - __Pyx_GIVEREF(__pyx_v_dev); - __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; __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 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - /* "freenect.pyx":263 + /* "freenect.pyx":267 * """ * update_tilt_state(dev) * return get_mks_accel(get_tilt_state(dev)) # <<<<<<<<<<<<<< @@ -2300,25 +3246,25 @@ static PyObject *__pyx_pf_8freenect_15get_accel(PyObject *__pyx_self, PyObject * * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__get_mks_accel); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__get_mks_accel); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__get_tilt_state); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__get_tilt_state); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __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 = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __Pyx_INCREF(__pyx_v_dev); - PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_dev); - __Pyx_GIVEREF(__pyx_v_dev); - __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_New(1); 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); + __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 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(((PyObject *)__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 = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_1)); + __pyx_t_1 = PyTuple_New(1); 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); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; @@ -2333,7 +3279,7 @@ static PyObject *__pyx_pf_8freenect_15get_accel(PyObject *__pyx_self, PyObject * __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); - __Pyx_AddTraceback("freenect.get_accel"); + __Pyx_AddTraceback("freenect.get_accel", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -2341,7 +3287,27 @@ static PyObject *__pyx_pf_8freenect_15get_accel(PyObject *__pyx_self, PyObject * return __pyx_r; } -/* "freenect.pyx":266 +/* Python wrapper */ +static PyObject *__pyx_pw_8freenect_33get_tilt_degs(PyObject *__pyx_self, PyObject *__pyx_v_state); /*proto*/ +static PyMethodDef __pyx_mdef_8freenect_33get_tilt_degs = {__Pyx_NAMESTR("get_tilt_degs"), (PyCFunction)__pyx_pw_8freenect_33get_tilt_degs, METH_O, __Pyx_DOCSTR(0)}; +static PyObject *__pyx_pw_8freenect_33get_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 = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_8freenect_32get_tilt_degs(__pyx_self, ((struct __pyx_obj_8freenect_StatePtr *)__pyx_v_state)); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "freenect.pyx":270 * * * def get_tilt_degs(StatePtr state): # <<<<<<<<<<<<<< @@ -2349,16 +3315,16 @@ static PyObject *__pyx_pf_8freenect_15get_accel(PyObject *__pyx_self, PyObject * * */ -static PyObject *__pyx_pf_8freenect_16get_tilt_degs(PyObject *__pyx_self, PyObject *__pyx_v_state); /*proto*/ -static PyMethodDef __pyx_mdef_8freenect_16get_tilt_degs = {__Pyx_NAMESTR("get_tilt_degs"), (PyCFunction)__pyx_pf_8freenect_16get_tilt_degs, METH_O, __Pyx_DOCSTR(0)}; -static PyObject *__pyx_pf_8freenect_16get_tilt_degs(PyObject *__pyx_self, PyObject *__pyx_v_state) { +static PyObject *__pyx_pf_8freenect_32get_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; - __Pyx_RefNannySetupContext("get_tilt_degs"); - __pyx_self = __pyx_self; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_state), __pyx_ptype_8freenect_StatePtr, 1, "state", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("get_tilt_degs", 0); - /* "freenect.pyx":267 + /* "freenect.pyx":271 * * def get_tilt_degs(StatePtr state): * return freenect_get_tilt_degs(state._ptr) # <<<<<<<<<<<<<< @@ -2366,7 +3332,7 @@ static PyObject *__pyx_pf_8freenect_16get_tilt_degs(PyObject *__pyx_self, PyObje * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyFloat_FromDouble(freenect_get_tilt_degs(((struct __pyx_obj_8freenect_StatePtr *)__pyx_v_state)->_ptr)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __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 = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -2376,7 +3342,7 @@ static PyObject *__pyx_pf_8freenect_16get_tilt_degs(PyObject *__pyx_self, PyObje goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("freenect.get_tilt_degs"); + __Pyx_AddTraceback("freenect.get_tilt_degs", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -2384,7 +3350,19 @@ static PyObject *__pyx_pf_8freenect_16get_tilt_degs(PyObject *__pyx_self, PyObje return __pyx_r; } -/* "freenect.pyx":270 +/* Python wrapper */ +static PyObject *__pyx_pw_8freenect_35error_open_device(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyMethodDef __pyx_mdef_8freenect_35error_open_device = {__Pyx_NAMESTR("error_open_device"), (PyCFunction)__pyx_pw_8freenect_35error_open_device, METH_NOARGS, __Pyx_DOCSTR(0)}; +static PyObject *__pyx_pw_8freenect_35error_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_34error_open_device(__pyx_self); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "freenect.pyx":274 * * * def error_open_device(): # <<<<<<<<<<<<<< @@ -2392,26 +3370,27 @@ static PyObject *__pyx_pf_8freenect_16get_tilt_degs(PyObject *__pyx_self, PyObje * */ -static PyObject *__pyx_pf_8freenect_17error_open_device(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyMethodDef __pyx_mdef_8freenect_17error_open_device = {__Pyx_NAMESTR("error_open_device"), (PyCFunction)__pyx_pf_8freenect_17error_open_device, METH_NOARGS, __Pyx_DOCSTR(0)}; -static PyObject *__pyx_pf_8freenect_17error_open_device(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { +static PyObject *__pyx_pf_8freenect_34error_open_device(CYTHON_UNUSED PyObject *__pyx_self) { PyObject *__pyx_r = NULL; - __Pyx_RefNannySetupContext("error_open_device"); - __pyx_self = __pyx_self; + __Pyx_RefNannyDeclarations + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("error_open_device", 0); - /* "freenect.pyx":271 + /* "freenect.pyx":275 * * 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, ((PyObject *)__pyx_kp_s_4)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_PrintOne(0, ((PyObject *)__pyx_kp_s_4)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; - __Pyx_AddTraceback("freenect.error_open_device"); + __Pyx_AddTraceback("freenect.error_open_device", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -2419,7 +3398,7 @@ static PyObject *__pyx_pf_8freenect_17error_open_device(PyObject *__pyx_self, CY return __pyx_r; } -/* "freenect.pyx":273 +/* "freenect.pyx":277 * print("Error: Can't open device. 1.) is it plugged in? 2.) Read the README") * * cpdef init(): # <<<<<<<<<<<<<< @@ -2427,27 +3406,30 @@ static PyObject *__pyx_pf_8freenect_17error_open_device(PyObject *__pyx_self, CY * if freenect_init(&ctx, NULL) < 0: */ -static PyObject *__pyx_pf_8freenect_18init(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_f_8freenect_init(int __pyx_skip_dispatch) { +static PyObject *__pyx_pw_8freenect_37init(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; + 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; - __Pyx_RefNannySetupContext("init"); - __pyx_v_ctx_out = ((struct __pyx_obj_8freenect_CtxPtr *)Py_None); __Pyx_INCREF(Py_None); + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("init", 0); - /* "freenect.pyx":275 + /* "freenect.pyx":279 * 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); + __pyx_t_1 = ((freenect_init((&__pyx_v_ctx), NULL) < 0) != 0); if (__pyx_t_1) { - /* "freenect.pyx":276 + /* "freenect.pyx":280 * cdef freenect_context* ctx * if freenect_init(&ctx, NULL) < 0: * return # <<<<<<<<<<<<<< @@ -2461,29 +3443,28 @@ static PyObject *__pyx_f_8freenect_init(int __pyx_skip_dispatch) { } __pyx_L3:; - /* "freenect.pyx":281 + /* "freenect.pyx":285 * # 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) # <<<<<<<<<<<<<< + * freenect_select_subdevices(ctx, (FREENECT_DEVICE_MOTOR | FREENECT_DEVICE_CAMERA)) # <<<<<<<<<<<<<< * cdef CtxPtr ctx_out * ctx_out = CtxPtr() */ - freenect_select_subdevices(__pyx_v_ctx, (FREENECT_DEVICE_MOTOR | FREENECT_DEVICE_CAMERA)); + freenect_select_subdevices(__pyx_v_ctx, ((freenect_device_flags)(FREENECT_DEVICE_MOTOR | FREENECT_DEVICE_CAMERA))); - /* "freenect.pyx":283 - * freenect_select_subdevices(ctx, FREENECT_DEVICE_MOTOR | FREENECT_DEVICE_CAMERA) + /* "freenect.pyx":287 + * freenect_select_subdevices(ctx, (FREENECT_DEVICE_MOTOR | FREENECT_DEVICE_CAMERA)) * cdef CtxPtr ctx_out * ctx_out = CtxPtr() # <<<<<<<<<<<<<< * ctx_out._ptr = ctx * return ctx_out */ - __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_8freenect_CtxPtr)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_8freenect_CtxPtr)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(((PyObject *)__pyx_v_ctx_out)); __pyx_v_ctx_out = ((struct __pyx_obj_8freenect_CtxPtr *)__pyx_t_2); __pyx_t_2 = 0; - /* "freenect.pyx":284 + /* "freenect.pyx":288 * cdef CtxPtr ctx_out * ctx_out = CtxPtr() * ctx_out._ptr = ctx # <<<<<<<<<<<<<< @@ -2492,7 +3473,7 @@ static PyObject *__pyx_f_8freenect_init(int __pyx_skip_dispatch) { */ __pyx_v_ctx_out->_ptr = __pyx_v_ctx; - /* "freenect.pyx":285 + /* "freenect.pyx":289 * ctx_out = CtxPtr() * ctx_out._ptr = ctx * return ctx_out # <<<<<<<<<<<<<< @@ -2508,16 +3489,27 @@ static PyObject *__pyx_f_8freenect_init(int __pyx_skip_dispatch) { goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("freenect.init"); + __Pyx_AddTraceback("freenect.init", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; - __Pyx_DECREF((PyObject *)__pyx_v_ctx_out); + __Pyx_XDECREF((PyObject *)__pyx_v_ctx_out); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "freenect.pyx":273 +/* Python wrapper */ +static PyObject *__pyx_pw_8freenect_37init(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_8freenect_37init(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("init (wrapper)", 0); + __pyx_r = __pyx_pf_8freenect_36init(__pyx_self); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "freenect.pyx":277 * print("Error: Can't open device. 1.) is it plugged in? 2.) Read the README") * * cpdef init(): # <<<<<<<<<<<<<< @@ -2525,14 +3517,16 @@ static PyObject *__pyx_f_8freenect_init(int __pyx_skip_dispatch) { * if freenect_init(&ctx, NULL) < 0: */ -static PyObject *__pyx_pf_8freenect_18init(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pf_8freenect_18init(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { +static PyObject *__pyx_pf_8freenect_36init(CYTHON_UNUSED PyObject *__pyx_self) { PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("init"); - __pyx_self = __pyx_self; + 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 = 273; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __pyx_f_8freenect_init(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -2542,7 +3536,7 @@ static PyObject *__pyx_pf_8freenect_18init(PyObject *__pyx_self, CYTHON_UNUSED P goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("freenect.init"); + __Pyx_AddTraceback("freenect.init", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -2550,7 +3544,7 @@ static PyObject *__pyx_pf_8freenect_18init(PyObject *__pyx_self, CYTHON_UNUSED P return __pyx_r; } -/* "freenect.pyx":287 +/* "freenect.pyx":291 * return ctx_out * * cpdef open_device(CtxPtr ctx, int index): # <<<<<<<<<<<<<< @@ -2558,27 +3552,30 @@ static PyObject *__pyx_pf_8freenect_18init(PyObject *__pyx_self, CYTHON_UNUSED P * if freenect_open_device(ctx._ptr, &dev, index) < 0: */ -static PyObject *__pyx_pf_8freenect_19open_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, int __pyx_skip_dispatch) { +static PyObject *__pyx_pw_8freenect_39open_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; + 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; - __Pyx_RefNannySetupContext("open_device"); - __pyx_v_dev_out = ((struct __pyx_obj_8freenect_DevPtr *)Py_None); __Pyx_INCREF(Py_None); + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("open_device", 0); - /* "freenect.pyx":289 + /* "freenect.pyx":293 * 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 */ - __pyx_t_1 = (freenect_open_device(__pyx_v_ctx->_ptr, (&__pyx_v_dev), __pyx_v_index) < 0); + __pyx_t_1 = ((freenect_open_device(__pyx_v_ctx->_ptr, (&__pyx_v_dev), __pyx_v_index) < 0) != 0); if (__pyx_t_1) { - /* "freenect.pyx":290 + /* "freenect.pyx":294 * cdef freenect_device* dev * if freenect_open_device(ctx._ptr, &dev, index) < 0: * return # <<<<<<<<<<<<<< @@ -2592,20 +3589,19 @@ static PyObject *__pyx_f_8freenect_open_device(struct __pyx_obj_8freenect_CtxPt } __pyx_L3:; - /* "freenect.pyx":292 + /* "freenect.pyx":296 * return * cdef DevPtr dev_out * dev_out = DevPtr() # <<<<<<<<<<<<<< * dev_out._ptr = dev * dev_out.ctx = ctx */ - __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_8freenect_DevPtr)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_8freenect_DevPtr)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(((PyObject *)__pyx_v_dev_out)); __pyx_v_dev_out = ((struct __pyx_obj_8freenect_DevPtr *)__pyx_t_2); __pyx_t_2 = 0; - /* "freenect.pyx":293 + /* "freenect.pyx":297 * cdef DevPtr dev_out * dev_out = DevPtr() * dev_out._ptr = dev # <<<<<<<<<<<<<< @@ -2614,7 +3610,7 @@ static PyObject *__pyx_f_8freenect_open_device(struct __pyx_obj_8freenect_CtxPt */ __pyx_v_dev_out->_ptr = __pyx_v_dev; - /* "freenect.pyx":294 + /* "freenect.pyx":298 * dev_out = DevPtr() * dev_out._ptr = dev * dev_out.ctx = ctx # <<<<<<<<<<<<<< @@ -2627,7 +3623,7 @@ static PyObject *__pyx_f_8freenect_open_device(struct __pyx_obj_8freenect_CtxPt __Pyx_DECREF(((PyObject *)__pyx_v_dev_out->ctx)); __pyx_v_dev_out->ctx = __pyx_v_ctx; - /* "freenect.pyx":295 + /* "freenect.pyx":299 * dev_out._ptr = dev * dev_out.ctx = ctx * return dev_out # <<<<<<<<<<<<<< @@ -2643,75 +3639,97 @@ static PyObject *__pyx_f_8freenect_open_device(struct __pyx_obj_8freenect_CtxPt goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("freenect.open_device"); + __Pyx_AddTraceback("freenect.open_device", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; - __Pyx_DECREF((PyObject *)__pyx_v_dev_out); + __Pyx_XDECREF((PyObject *)__pyx_v_dev_out); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "freenect.pyx":287 - * 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_pf_8freenect_19open_device(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_pf_8freenect_19open_device(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +/* Python wrapper */ +static PyObject *__pyx_pw_8freenect_39open_device(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_8freenect_39open_device(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { struct __pyx_obj_8freenect_CtxPtr *__pyx_v_ctx = 0; int __pyx_v_index; - PyObject *__pyx_r = NULL; - PyObject *__pyx_t_1 = NULL; - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__ctx,&__pyx_n_s__index,0}; - __Pyx_RefNannySetupContext("open_device"); - __pyx_self = __pyx_self; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args = PyDict_Size(__pyx_kwds); + 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}; - 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; - } - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 0: - values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__ctx); - if (likely(values[0])) kw_args--; - else goto __pyx_L5_argtuple_error; - case 1: - values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__index); - if (likely(values[1])) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("open_device", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + 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; } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "open_device") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L3_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 = 291; __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 = 291; __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_AsInt(values[1]); if (unlikely((__pyx_v_index == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { - goto __pyx_L5_argtuple_error; - } else { - __pyx_v_ctx = ((struct __pyx_obj_8freenect_CtxPtr *)PyTuple_GET_ITEM(__pyx_args, 0)); - __pyx_v_index = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_index == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_index = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_index == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __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 = 287; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("open_device", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; - __Pyx_AddTraceback("freenect.open_device"); + __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 = 287; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_ctx), __pyx_ptype_8freenect_CtxPtr, 1, "ctx", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_8freenect_38open_device(__pyx_self, __pyx_v_ctx, __pyx_v_index); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "freenect.pyx":291 + * 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_pf_8freenect_38open_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 = 287; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __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 = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -2721,7 +3739,7 @@ static PyObject *__pyx_pf_8freenect_19open_device(PyObject *__pyx_self, PyObject goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("freenect.open_device"); + __Pyx_AddTraceback("freenect.open_device", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -2729,7 +3747,7 @@ static PyObject *__pyx_pf_8freenect_19open_device(PyObject *__pyx_self, PyObject return __pyx_r; } -/* "freenect.pyx":299 +/* "freenect.pyx":303 * _depth_cb, _video_cb = None, None * * cdef void depth_cb(freenect_device *dev, void *data, uint32_t timestamp) with gil: # <<<<<<<<<<<<<< @@ -2737,22 +3755,25 @@ static PyObject *__pyx_pf_8freenect_19open_device(PyObject *__pyx_self, PyObject * cdef DevPtr dev_out */ -static void __pyx_f_8freenect_depth_cb(freenect_device *__pyx_v_dev, void *__pyx_v_data, uint32_t __pyx_v_timestamp) { +static void __pyx_f_8freenect_depth_cb(freenect_device *__pyx_v_dev, void *__pyx_v_data, uint32_t __pyx_v_timestamp) { long __pyx_v_nbytes; - struct __pyx_obj_8freenect_DevPtr *__pyx_v_dev_out; + struct __pyx_obj_8freenect_DevPtr *__pyx_v_dev_out = 0; + __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; #ifdef WITH_THREAD - PyGILState_STATE _save = PyGILState_Ensure(); + PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); #endif - __Pyx_RefNannySetupContext("depth_cb"); - __pyx_v_dev_out = ((struct __pyx_obj_8freenect_DevPtr *)Py_None); __Pyx_INCREF(Py_None); + __Pyx_RefNannySetupContext("depth_cb", 0); - /* "freenect.pyx":300 + /* "freenect.pyx":304 * * cdef void depth_cb(freenect_device *dev, void *data, uint32_t timestamp) with gil: * nbytes = 614400 # 480 * 640 * 2 # <<<<<<<<<<<<<< @@ -2761,20 +3782,19 @@ static void __pyx_f_8freenect_depth_cb(freenect_device *__pyx_v_dev, void *__py */ __pyx_v_nbytes = 614400; - /* "freenect.pyx":302 + /* "freenect.pyx":306 * nbytes = 614400 # 480 * 640 * 2 * cdef DevPtr dev_out * dev_out = DevPtr() # <<<<<<<<<<<<<< * dev_out._ptr = dev * if _depth_cb: */ - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_8freenect_DevPtr)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 302; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_8freenect_DevPtr)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(((PyObject *)__pyx_v_dev_out)); __pyx_v_dev_out = ((struct __pyx_obj_8freenect_DevPtr *)__pyx_t_1); __pyx_t_1 = 0; - /* "freenect.pyx":303 + /* "freenect.pyx":307 * cdef DevPtr dev_out * dev_out = DevPtr() * dev_out._ptr = dev # <<<<<<<<<<<<<< @@ -2783,36 +3803,36 @@ static void __pyx_f_8freenect_depth_cb(freenect_device *__pyx_v_dev, void *__py */ __pyx_v_dev_out->_ptr = __pyx_v_dev; - /* "freenect.pyx":304 + /* "freenect.pyx":308 * dev_out = DevPtr() * dev_out._ptr = dev * if _depth_cb: # <<<<<<<<<<<<<< * _depth_cb(*_depth_cb_np(dev_out, (data)[:nbytes], timestamp)) * */ - __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s___depth_cb); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s___depth_cb); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { - /* "freenect.pyx":305 + /* "freenect.pyx":309 * dev_out._ptr = dev * if _depth_cb: * _depth_cb(*_depth_cb_np(dev_out, (data)[:nbytes], timestamp)) # <<<<<<<<<<<<<< * * cdef void video_cb(freenect_device *dev, void *data, uint32_t timestamp) with gil: */ - __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s___depth_cb); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s___depth_cb); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s___depth_cb_np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s___depth_cb_np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyBytes_FromStringAndSize(((char *)__pyx_v_data) + 0, __pyx_v_nbytes - 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_PyBytes_FromStringAndSize(((char *)__pyx_v_data) + 0, __pyx_v_nbytes - 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_4)); - __pyx_t_5 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_timestamp); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_timestamp); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_6)); + __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(((PyObject *)__pyx_v_dev_out)); PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_v_dev_out)); __Pyx_GIVEREF(((PyObject *)__pyx_v_dev_out)); @@ -2822,14 +3842,14 @@ static void __pyx_f_8freenect_depth_cb(freenect_device *__pyx_v_dev, void *__py __Pyx_GIVEREF(__pyx_t_5); __pyx_t_4 = 0; __pyx_t_5 = 0; - __pyx_t_5 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; - __pyx_t_6 = PySequence_Tuple(__pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PySequence_Tuple(__pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_6)); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; @@ -2845,16 +3865,16 @@ static void __pyx_f_8freenect_depth_cb(freenect_device *__pyx_v_dev, void *__py __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); - __Pyx_WriteUnraisable("freenect.depth_cb"); + __Pyx_WriteUnraisable("freenect.depth_cb", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_L0:; - __Pyx_DECREF((PyObject *)__pyx_v_dev_out); + __Pyx_XDECREF((PyObject *)__pyx_v_dev_out); __Pyx_RefNannyFinishContext(); #ifdef WITH_THREAD - PyGILState_Release(_save); + PyGILState_Release(__pyx_gilstate_save); #endif } -/* "freenect.pyx":307 +/* "freenect.pyx":311 * _depth_cb(*_depth_cb_np(dev_out, (data)[:nbytes], timestamp)) * * cdef void video_cb(freenect_device *dev, void *data, uint32_t timestamp) with gil: # <<<<<<<<<<<<<< @@ -2862,22 +3882,25 @@ static void __pyx_f_8freenect_depth_cb(freenect_device *__pyx_v_dev, void *__py * cdef DevPtr dev_out */ -static void __pyx_f_8freenect_video_cb(freenect_device *__pyx_v_dev, void *__pyx_v_data, uint32_t __pyx_v_timestamp) { +static void __pyx_f_8freenect_video_cb(freenect_device *__pyx_v_dev, void *__pyx_v_data, uint32_t __pyx_v_timestamp) { long __pyx_v_nbytes; - struct __pyx_obj_8freenect_DevPtr *__pyx_v_dev_out; + struct __pyx_obj_8freenect_DevPtr *__pyx_v_dev_out = 0; + __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; #ifdef WITH_THREAD - PyGILState_STATE _save = PyGILState_Ensure(); + PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); #endif - __Pyx_RefNannySetupContext("video_cb"); - __pyx_v_dev_out = ((struct __pyx_obj_8freenect_DevPtr *)Py_None); __Pyx_INCREF(Py_None); + __Pyx_RefNannySetupContext("video_cb", 0); - /* "freenect.pyx":308 + /* "freenect.pyx":312 * * cdef void video_cb(freenect_device *dev, void *data, uint32_t timestamp) with gil: * nbytes = 921600 # 480 * 640 * 3 # <<<<<<<<<<<<<< @@ -2886,20 +3909,19 @@ static void __pyx_f_8freenect_video_cb(freenect_device *__pyx_v_dev, void *__py */ __pyx_v_nbytes = 921600; - /* "freenect.pyx":310 + /* "freenect.pyx":314 * nbytes = 921600 # 480 * 640 * 3 * cdef DevPtr dev_out * dev_out = DevPtr() # <<<<<<<<<<<<<< * dev_out._ptr = dev * if _video_cb: */ - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_8freenect_DevPtr)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_8freenect_DevPtr)), ((PyObject *)__pyx_empty_tuple), NULL); 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_DECREF(((PyObject *)__pyx_v_dev_out)); __pyx_v_dev_out = ((struct __pyx_obj_8freenect_DevPtr *)__pyx_t_1); __pyx_t_1 = 0; - /* "freenect.pyx":311 + /* "freenect.pyx":315 * cdef DevPtr dev_out * dev_out = DevPtr() * dev_out._ptr = dev # <<<<<<<<<<<<<< @@ -2908,36 +3930,36 @@ static void __pyx_f_8freenect_video_cb(freenect_device *__pyx_v_dev, void *__py */ __pyx_v_dev_out->_ptr = __pyx_v_dev; - /* "freenect.pyx":312 + /* "freenect.pyx":316 * dev_out = DevPtr() * dev_out._ptr = dev * if _video_cb: # <<<<<<<<<<<<<< * _video_cb(*_video_cb_np(dev_out, (data)[:nbytes], timestamp)) * */ - __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s___video_cb); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s___video_cb); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { - /* "freenect.pyx":313 + /* "freenect.pyx":317 * dev_out._ptr = dev * if _video_cb: * _video_cb(*_video_cb_np(dev_out, (data)[:nbytes], timestamp)) # <<<<<<<<<<<<<< * * def set_depth_callback(DevPtr dev, cb): */ - __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s___video_cb); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s___video_cb); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s___video_cb_np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s___video_cb_np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyBytes_FromStringAndSize(((char *)__pyx_v_data) + 0, __pyx_v_nbytes - 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_PyBytes_FromStringAndSize(((char *)__pyx_v_data) + 0, __pyx_v_nbytes - 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_4)); - __pyx_t_5 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_timestamp); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_timestamp); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_6)); + __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(((PyObject *)__pyx_v_dev_out)); PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_v_dev_out)); __Pyx_GIVEREF(((PyObject *)__pyx_v_dev_out)); @@ -2947,14 +3969,14 @@ static void __pyx_f_8freenect_video_cb(freenect_device *__pyx_v_dev, void *__py __Pyx_GIVEREF(__pyx_t_5); __pyx_t_4 = 0; __pyx_t_5 = 0; - __pyx_t_5 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; - __pyx_t_6 = PySequence_Tuple(__pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PySequence_Tuple(__pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_6)); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; @@ -2970,76 +3992,99 @@ static void __pyx_f_8freenect_video_cb(freenect_device *__pyx_v_dev, void *__py __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); - __Pyx_WriteUnraisable("freenect.video_cb"); + __Pyx_WriteUnraisable("freenect.video_cb", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_L0:; - __Pyx_DECREF((PyObject *)__pyx_v_dev_out); + __Pyx_XDECREF((PyObject *)__pyx_v_dev_out); __Pyx_RefNannyFinishContext(); #ifdef WITH_THREAD - PyGILState_Release(_save); + PyGILState_Release(__pyx_gilstate_save); #endif } -/* "freenect.pyx":315 - * _video_cb(*_video_cb_np(dev_out, (data)[:nbytes], timestamp)) - * - * def set_depth_callback(DevPtr dev, cb): # <<<<<<<<<<<<<< - * global _depth_cb - * if cb is not None: - */ - -static PyObject *__pyx_pf_8freenect_20set_depth_callback(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyMethodDef __pyx_mdef_8freenect_20set_depth_callback = {__Pyx_NAMESTR("set_depth_callback"), (PyCFunction)__pyx_pf_8freenect_20set_depth_callback, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}; -static PyObject *__pyx_pf_8freenect_20set_depth_callback(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +/* Python wrapper */ +static PyObject *__pyx_pw_8freenect_41set_depth_callback(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyMethodDef __pyx_mdef_8freenect_41set_depth_callback = {__Pyx_NAMESTR("set_depth_callback"), (PyCFunction)__pyx_pw_8freenect_41set_depth_callback, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}; +static PyObject *__pyx_pw_8freenect_41set_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; - PyObject *__pyx_r = NULL; - int __pyx_t_1; - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__dev,&__pyx_n_s__cb,0}; - __Pyx_RefNannySetupContext("set_depth_callback"); - __pyx_self = __pyx_self; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args = PyDict_Size(__pyx_kwds); + 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}; - 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; - } - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 0: - values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__dev); - if (likely(values[0])) kw_args--; - else goto __pyx_L5_argtuple_error; - case 1: - values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__cb); - if (likely(values[1])) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("set_depth_callback", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + 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; } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "set_depth_callback") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L3_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 = 319; __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 = 319; __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]; - } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { - goto __pyx_L5_argtuple_error; - } else { - __pyx_v_dev = ((struct __pyx_obj_8freenect_DevPtr *)PyTuple_GET_ITEM(__pyx_args, 0)); - __pyx_v_cb = PyTuple_GET_ITEM(__pyx_args, 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 = 315; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("set_depth_callback", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; - __Pyx_AddTraceback("freenect.set_depth_callback"); + __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 = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dev), __pyx_ptype_8freenect_DevPtr, 1, "dev", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_8freenect_40set_depth_callback(__pyx_self, __pyx_v_dev, __pyx_v_cb); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "freenect.pyx":319 + * _video_cb(*_video_cb_np(dev_out, (data)[:nbytes], timestamp)) + * + * def set_depth_callback(DevPtr dev, cb): # <<<<<<<<<<<<<< + * global _depth_cb + * if cb is not None: + */ + +static PyObject *__pyx_pf_8freenect_40set_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":317 + /* "freenect.pyx":321 * def set_depth_callback(DevPtr dev, cb): * global _depth_cb * if cb is not None: # <<<<<<<<<<<<<< @@ -3047,18 +4092,19 @@ static PyObject *__pyx_pf_8freenect_20set_depth_callback(PyObject *__pyx_self, P * freenect_set_depth_callback(dev._ptr, depth_cb) */ __pyx_t_1 = (__pyx_v_cb != Py_None); - if (__pyx_t_1) { + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { - /* "freenect.pyx":318 + /* "freenect.pyx":322 * global _depth_cb * if cb is not None: * _depth_cb = cb # <<<<<<<<<<<<<< * freenect_set_depth_callback(dev._ptr, depth_cb) * else: */ - if (PyObject_SetAttr(__pyx_m, __pyx_n_s___depth_cb, __pyx_v_cb) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s___depth_cb, __pyx_v_cb) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "freenect.pyx":319 + /* "freenect.pyx":323 * if cb is not None: * _depth_cb = cb * freenect_set_depth_callback(dev._ptr, depth_cb) # <<<<<<<<<<<<<< @@ -3066,20 +4112,20 @@ static PyObject *__pyx_pf_8freenect_20set_depth_callback(PyObject *__pyx_self, P * _depth_cb = None */ freenect_set_depth_callback(__pyx_v_dev->_ptr, __pyx_f_8freenect_depth_cb); - goto __pyx_L6; + goto __pyx_L3; } /*else*/ { - /* "freenect.pyx":321 + /* "freenect.pyx":325 * freenect_set_depth_callback(dev._ptr, depth_cb) * else: * _depth_cb = None # <<<<<<<<<<<<<< * freenect_set_depth_callback(dev._ptr, NULL) * */ - if (PyObject_SetAttr(__pyx_m, __pyx_n_s___depth_cb, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s___depth_cb, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "freenect.pyx":322 + /* "freenect.pyx":326 * else: * _depth_cb = None * freenect_set_depth_callback(dev._ptr, NULL) # <<<<<<<<<<<<<< @@ -3088,12 +4134,12 @@ static PyObject *__pyx_pf_8freenect_20set_depth_callback(PyObject *__pyx_self, P */ freenect_set_depth_callback(__pyx_v_dev->_ptr, NULL); } - __pyx_L6:; + __pyx_L3:; __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; - __Pyx_AddTraceback("freenect.set_depth_callback"); + __Pyx_AddTraceback("freenect.set_depth_callback", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -3101,67 +4147,90 @@ static PyObject *__pyx_pf_8freenect_20set_depth_callback(PyObject *__pyx_self, P return __pyx_r; } -/* "freenect.pyx":324 - * freenect_set_depth_callback(dev._ptr, NULL) - * - * def set_video_callback(DevPtr dev, cb): # <<<<<<<<<<<<<< - * global _video_cb - * if cb is not None: - */ - -static PyObject *__pyx_pf_8freenect_21set_video_callback(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyMethodDef __pyx_mdef_8freenect_21set_video_callback = {__Pyx_NAMESTR("set_video_callback"), (PyCFunction)__pyx_pf_8freenect_21set_video_callback, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}; -static PyObject *__pyx_pf_8freenect_21set_video_callback(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +/* Python wrapper */ +static PyObject *__pyx_pw_8freenect_43set_video_callback(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyMethodDef __pyx_mdef_8freenect_43set_video_callback = {__Pyx_NAMESTR("set_video_callback"), (PyCFunction)__pyx_pw_8freenect_43set_video_callback, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}; +static PyObject *__pyx_pw_8freenect_43set_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; - PyObject *__pyx_r = NULL; - int __pyx_t_1; - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__dev,&__pyx_n_s__cb,0}; - __Pyx_RefNannySetupContext("set_video_callback"); - __pyx_self = __pyx_self; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args = PyDict_Size(__pyx_kwds); + 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}; - 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; - } - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 0: - values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__dev); - if (likely(values[0])) kw_args--; - else goto __pyx_L5_argtuple_error; - case 1: - values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__cb); - if (likely(values[1])) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("set_video_callback", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + 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; } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "set_video_callback") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L3_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 = 328; __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 = 328; __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]; - } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { - goto __pyx_L5_argtuple_error; - } else { - __pyx_v_dev = ((struct __pyx_obj_8freenect_DevPtr *)PyTuple_GET_ITEM(__pyx_args, 0)); - __pyx_v_cb = PyTuple_GET_ITEM(__pyx_args, 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 = 324; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("set_video_callback", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; - __Pyx_AddTraceback("freenect.set_video_callback"); + __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 = 324; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dev), __pyx_ptype_8freenect_DevPtr, 1, "dev", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_8freenect_42set_video_callback(__pyx_self, __pyx_v_dev, __pyx_v_cb); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "freenect.pyx":328 + * freenect_set_depth_callback(dev._ptr, NULL) + * + * def set_video_callback(DevPtr dev, cb): # <<<<<<<<<<<<<< + * global _video_cb + * if cb is not None: + */ + +static PyObject *__pyx_pf_8freenect_42set_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":326 + /* "freenect.pyx":330 * def set_video_callback(DevPtr dev, cb): * global _video_cb * if cb is not None: # <<<<<<<<<<<<<< @@ -3169,18 +4238,19 @@ static PyObject *__pyx_pf_8freenect_21set_video_callback(PyObject *__pyx_self, P * freenect_set_video_callback(dev._ptr, video_cb) */ __pyx_t_1 = (__pyx_v_cb != Py_None); - if (__pyx_t_1) { + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { - /* "freenect.pyx":327 + /* "freenect.pyx":331 * global _video_cb * if cb is not None: * _video_cb = cb # <<<<<<<<<<<<<< * freenect_set_video_callback(dev._ptr, video_cb) * else: */ - if (PyObject_SetAttr(__pyx_m, __pyx_n_s___video_cb, __pyx_v_cb) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s___video_cb, __pyx_v_cb) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "freenect.pyx":328 + /* "freenect.pyx":332 * if cb is not None: * _video_cb = cb * freenect_set_video_callback(dev._ptr, video_cb) # <<<<<<<<<<<<<< @@ -3188,20 +4258,20 @@ static PyObject *__pyx_pf_8freenect_21set_video_callback(PyObject *__pyx_self, P * _video_cb = None */ freenect_set_video_callback(__pyx_v_dev->_ptr, __pyx_f_8freenect_video_cb); - goto __pyx_L6; + goto __pyx_L3; } /*else*/ { - /* "freenect.pyx":330 + /* "freenect.pyx":334 * freenect_set_video_callback(dev._ptr, video_cb) * else: * _video_cb = None # <<<<<<<<<<<<<< * freenect_set_video_callback(dev._ptr, NULL) * */ - if (PyObject_SetAttr(__pyx_m, __pyx_n_s___video_cb, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s___video_cb, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "freenect.pyx":331 + /* "freenect.pyx":335 * else: * _video_cb = None * freenect_set_video_callback(dev._ptr, NULL) # <<<<<<<<<<<<<< @@ -3210,12 +4280,12 @@ static PyObject *__pyx_pf_8freenect_21set_video_callback(PyObject *__pyx_self, P */ freenect_set_video_callback(__pyx_v_dev->_ptr, NULL); } - __pyx_L6:; + __pyx_L3:; __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; - __Pyx_AddTraceback("freenect.set_video_callback"); + __Pyx_AddTraceback("freenect.set_video_callback", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -3223,149 +4293,168 @@ static PyObject *__pyx_pf_8freenect_21set_video_callback(PyObject *__pyx_self, P return __pyx_r; } -/* "freenect.pyx":338 +/* Python wrapper */ +static PyObject *__pyx_pw_8freenect_45runloop(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_8freenect_44runloop[] = "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_45runloop = {__Pyx_NAMESTR("runloop"), (PyCFunction)__pyx_pw_8freenect_45runloop, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_8freenect_44runloop)}; +static PyObject *__pyx_pw_8freenect_45runloop(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}; + + /* "freenect.pyx":342 * * * def runloop(depth=None, video=None, body=None, dev=None): # <<<<<<<<<<<<<< * """Sets up the kinect and maintains a runloop * */ - -static PyObject *__pyx_pf_8freenect_22runloop(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_8freenect_22runloop[] = "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_22runloop = {__Pyx_NAMESTR("runloop"), (PyCFunction)__pyx_pf_8freenect_22runloop, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_8freenect_22runloop)}; -static PyObject *__pyx_pf_8freenect_22runloop(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; - struct __pyx_obj_8freenect_DevPtr *__pyx_v_mdev; - struct __pyx_obj_8freenect_CtxPtr *__pyx_v_ctx; - freenect_device *__pyx_v_devp; - freenect_context *__pyx_v_ctxp; - PyObject *__pyx_r = NULL; - int __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - int __pyx_t_3; - PyObject *__pyx_t_4 = NULL; - int __pyx_t_5; - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__depth,&__pyx_n_s__video,&__pyx_n_s__body,&__pyx_n_s__dev,0}; - __Pyx_RefNannySetupContext("runloop"); - __pyx_self = __pyx_self; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args = PyDict_Size(__pyx_kwds); - 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); - 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; - } - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 0: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__depth); - if (value) { values[0] = value; kw_args--; } + 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; } - case 1: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__video); - if (value) { values[1] = value; kw_args--; } + 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--; } + } } - case 2: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__body); - if (value) { values[2] = 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 = 342; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } - case 3: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__dev); - if (value) { values[3] = value; kw_args--; } + } 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; } } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "runloop") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } __pyx_v_depth = values[0]; __pyx_v_video = values[1]; __pyx_v_body = values[2]; __pyx_v_dev = values[3]; - } else { - __pyx_v_depth = ((PyObject *)Py_None); - __pyx_v_video = ((PyObject *)Py_None); - __pyx_v_body = ((PyObject *)Py_None); - __pyx_v_dev = ((PyObject *)Py_None); - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 4: __pyx_v_dev = PyTuple_GET_ITEM(__pyx_args, 3); - case 3: __pyx_v_body = PyTuple_GET_ITEM(__pyx_args, 2); - case 2: __pyx_v_video = PyTuple_GET_ITEM(__pyx_args, 1); - case 1: __pyx_v_depth = PyTuple_GET_ITEM(__pyx_args, 0); - case 0: break; - default: goto __pyx_L5_argtuple_error; - } } 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 = 338; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("runloop", 0, 0, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; - __Pyx_AddTraceback("freenect.runloop"); + __Pyx_AddTraceback("freenect.runloop", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - __pyx_v_mdev = ((struct __pyx_obj_8freenect_DevPtr *)Py_None); __Pyx_INCREF(Py_None); - __pyx_v_ctx = ((struct __pyx_obj_8freenect_CtxPtr *)Py_None); __Pyx_INCREF(Py_None); + __pyx_r = __pyx_pf_8freenect_44runloop(__pyx_self, __pyx_v_depth, __pyx_v_video, __pyx_v_body, __pyx_v_dev); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "freenect.pyx":355 +static PyObject *__pyx_pf_8freenect_44runloop(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":359 * """ * 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 = 355; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_depth); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_t_1) { - /* "freenect.pyx":356 + /* "freenect.pyx":360 * global _depth_cb, _video_cb * if depth: * _depth_cb = depth # <<<<<<<<<<<<<< * if video: * _video_cb = video */ - if (PyObject_SetAttr(__pyx_m, __pyx_n_s___depth_cb, __pyx_v_depth) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L6; + if (PyDict_SetItem(__pyx_d, __pyx_n_s___depth_cb, __pyx_v_depth) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L3; } - __pyx_L6:; + __pyx_L3:; - /* "freenect.pyx":357 + /* "freenect.pyx":361 * 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 = 357; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_video); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_t_1) { - /* "freenect.pyx":358 + /* "freenect.pyx":362 * _depth_cb = depth * if video: * _video_cb = video # <<<<<<<<<<<<<< * cdef DevPtr mdev * cdef CtxPtr ctx */ - if (PyObject_SetAttr(__pyx_m, __pyx_n_s___video_cb, __pyx_v_video) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L7; + if (PyDict_SetItem(__pyx_d, __pyx_n_s___video_cb, __pyx_v_video) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L4; } - __pyx_L7:; + __pyx_L4:; - /* "freenect.pyx":363 + /* "freenect.pyx":367 * cdef freenect_device* devp * cdef freenect_context* ctxp * if dev is None: # <<<<<<<<<<<<<< @@ -3373,48 +4462,48 @@ static PyObject *__pyx_pf_8freenect_22runloop(PyObject *__pyx_self, PyObject *__ * if not ctx: */ __pyx_t_1 = (__pyx_v_dev == Py_None); - if (__pyx_t_1) { + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { - /* "freenect.pyx":364 + /* "freenect.pyx":368 * cdef freenect_context* ctxp * if dev is None: * ctx = init() # <<<<<<<<<<<<<< * if not ctx: * error_open_device() */ - __pyx_t_2 = __pyx_f_8freenect_init(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_8freenect_CtxPtr))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(((PyObject *)__pyx_v_ctx)); - __pyx_v_ctx = ((struct __pyx_obj_8freenect_CtxPtr *)__pyx_t_2); - __pyx_t_2 = 0; + __pyx_t_3 = __pyx_f_8freenect_init(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; __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 = 368; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_ctx = ((struct __pyx_obj_8freenect_CtxPtr *)__pyx_t_3); + __pyx_t_3 = 0; - /* "freenect.pyx":365 + /* "freenect.pyx":369 * if dev is None: * ctx = init() * if not ctx: # <<<<<<<<<<<<<< * error_open_device() * return */ - __pyx_t_1 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_ctx)); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_3 = (!__pyx_t_1); - if (__pyx_t_3) { + __pyx_t_2 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_ctx)); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((!__pyx_t_2) != 0); + if (__pyx_t_1) { - /* "freenect.pyx":366 + /* "freenect.pyx":370 * ctx = init() * if not ctx: * error_open_device() # <<<<<<<<<<<<<< * return * mdev = open_device(ctx, 0) */ - __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__error_open_device); 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_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__error_open_device); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __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_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - /* "freenect.pyx":367 + /* "freenect.pyx":371 * if not ctx: * error_open_device() * return # <<<<<<<<<<<<<< @@ -3424,179 +4513,209 @@ static PyObject *__pyx_pf_8freenect_22runloop(PyObject *__pyx_self, PyObject *__ __Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; - goto __pyx_L9; + goto __pyx_L6; } - __pyx_L9:; + __pyx_L6:; - /* "freenect.pyx":368 + /* "freenect.pyx":372 * 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 = 368; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __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 = 372; __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 = 368; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(((PyObject *)__pyx_v_mdev)); + if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_8freenect_DevPtr))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_mdev = ((struct __pyx_obj_8freenect_DevPtr *)__pyx_t_4); __pyx_t_4 = 0; - /* "freenect.pyx":369 + /* "freenect.pyx":373 * return * mdev = open_device(ctx, 0) * if not mdev: # <<<<<<<<<<<<<< * error_open_device() * return */ - __pyx_t_3 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_mdev)); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_1 = (!__pyx_t_3); - if (__pyx_t_1) { + __pyx_t_1 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_mdev)); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = ((!__pyx_t_1) != 0); + if (__pyx_t_2) { - /* "freenect.pyx":370 + /* "freenect.pyx":374 * mdev = open_device(ctx, 0) * if not mdev: * error_open_device() # <<<<<<<<<<<<<< * return - * else: + * if depth is not None: */ - __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__error_open_device); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s__error_open_device); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_2 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); 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); + __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 374; __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_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - /* "freenect.pyx":371 + /* "freenect.pyx":375 * if not mdev: * error_open_device() * return # <<<<<<<<<<<<<< - * else: - * mdev = dev + * 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; - goto __pyx_L10; + goto __pyx_L7; + } + __pyx_L7:; + + /* "freenect.pyx":376 + * 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":377 + * 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":378 + * 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":379 + * 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_L10:; - goto __pyx_L8; + __pyx_L9:; + goto __pyx_L5; } /*else*/ { - /* "freenect.pyx":373 - * return + /* "freenect.pyx":382 + * * 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 = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_v_dev) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_dev, __pyx_ptype_8freenect_DevPtr))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_INCREF(__pyx_v_dev); - __Pyx_DECREF(((PyObject *)__pyx_v_mdev)); __pyx_v_mdev = ((struct __pyx_obj_8freenect_DevPtr *)__pyx_v_dev); } - __pyx_L8:; + __pyx_L5:; - /* "freenect.pyx":374 + /* "freenect.pyx":383 * else: * mdev = dev * devp = mdev._ptr # <<<<<<<<<<<<<< * ctxp = mdev.ctx._ptr * if depth is not None: */ - __pyx_v_devp = __pyx_v_mdev->_ptr; + __pyx_t_5 = __pyx_v_mdev->_ptr; + __pyx_v_devp = __pyx_t_5; - /* "freenect.pyx":375 + /* "freenect.pyx":384 * mdev = dev * devp = mdev._ptr * ctxp = mdev.ctx._ptr # <<<<<<<<<<<<<< * if depth is not None: - * freenect_set_depth_mode(devp, freenect_find_depth_mode(FREENECT_RESOLUTION_MEDIUM, FREENECT_DEPTH_11BIT)) + * freenect_start_depth(devp) */ - __pyx_v_ctxp = __pyx_v_mdev->ctx->_ptr; + __pyx_t_6 = __pyx_v_mdev->ctx->_ptr; + __pyx_v_ctxp = __pyx_t_6; - /* "freenect.pyx":376 + /* "freenect.pyx":385 * devp = mdev._ptr * ctxp = mdev.ctx._ptr * if depth is not None: # <<<<<<<<<<<<<< - * freenect_set_depth_mode(devp, freenect_find_depth_mode(FREENECT_RESOLUTION_MEDIUM, FREENECT_DEPTH_11BIT)) * freenect_start_depth(devp) + * freenect_set_depth_callback(devp, depth_cb) */ - __pyx_t_1 = (__pyx_v_depth != Py_None); + __pyx_t_2 = (__pyx_v_depth != Py_None); + __pyx_t_1 = (__pyx_t_2 != 0); if (__pyx_t_1) { - /* "freenect.pyx":377 + /* "freenect.pyx":386 * ctxp = mdev.ctx._ptr * if depth is not None: - * freenect_set_depth_mode(devp, freenect_find_depth_mode(FREENECT_RESOLUTION_MEDIUM, FREENECT_DEPTH_11BIT)) # <<<<<<<<<<<<<< - * freenect_start_depth(devp) - * freenect_set_depth_callback(devp, depth_cb) - */ - freenect_set_depth_mode(__pyx_v_devp, freenect_find_depth_mode(FREENECT_RESOLUTION_MEDIUM, FREENECT_DEPTH_11BIT)); - - /* "freenect.pyx":378 - * if depth is not None: - * freenect_set_depth_mode(devp, freenect_find_depth_mode(FREENECT_RESOLUTION_MEDIUM, FREENECT_DEPTH_11BIT)) * freenect_start_depth(devp) # <<<<<<<<<<<<<< * freenect_set_depth_callback(devp, depth_cb) * if video is not None: */ freenect_start_depth(__pyx_v_devp); - /* "freenect.pyx":379 - * freenect_set_depth_mode(devp, freenect_find_depth_mode(FREENECT_RESOLUTION_MEDIUM, FREENECT_DEPTH_11BIT)) + /* "freenect.pyx":387 + * if depth is not None: * freenect_start_depth(devp) * freenect_set_depth_callback(devp, depth_cb) # <<<<<<<<<<<<<< * if video is not None: - * freenect_set_video_mode(devp, freenect_find_video_mode(FREENECT_RESOLUTION_MEDIUM, FREENECT_VIDEO_RGB)) + * freenect_start_video(devp) */ freenect_set_depth_callback(__pyx_v_devp, __pyx_f_8freenect_depth_cb); - goto __pyx_L11; + goto __pyx_L10; } - __pyx_L11:; + __pyx_L10:; - /* "freenect.pyx":380 + /* "freenect.pyx":388 * freenect_start_depth(devp) * freenect_set_depth_callback(devp, depth_cb) * if video is not None: # <<<<<<<<<<<<<< - * freenect_set_video_mode(devp, freenect_find_video_mode(FREENECT_RESOLUTION_MEDIUM, FREENECT_VIDEO_RGB)) * freenect_start_video(devp) + * freenect_set_video_callback(devp, video_cb) */ __pyx_t_1 = (__pyx_v_video != Py_None); - if (__pyx_t_1) { + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { - /* "freenect.pyx":381 + /* "freenect.pyx":389 * freenect_set_depth_callback(devp, depth_cb) * if video is not None: - * freenect_set_video_mode(devp, freenect_find_video_mode(FREENECT_RESOLUTION_MEDIUM, FREENECT_VIDEO_RGB)) # <<<<<<<<<<<<<< - * freenect_start_video(devp) - * freenect_set_video_callback(devp, video_cb) - */ - freenect_set_video_mode(__pyx_v_devp, freenect_find_video_mode(FREENECT_RESOLUTION_MEDIUM, FREENECT_VIDEO_RGB)); - - /* "freenect.pyx":382 - * if video is not None: - * freenect_set_video_mode(devp, freenect_find_video_mode(FREENECT_RESOLUTION_MEDIUM, FREENECT_VIDEO_RGB)) * freenect_start_video(devp) # <<<<<<<<<<<<<< * freenect_set_video_callback(devp, video_cb) * try: */ freenect_start_video(__pyx_v_devp); - /* "freenect.pyx":383 - * freenect_set_video_mode(devp, freenect_find_video_mode(FREENECT_RESOLUTION_MEDIUM, FREENECT_VIDEO_RGB)) + /* "freenect.pyx":390 + * 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_L12; + goto __pyx_L11; } - __pyx_L12:; + __pyx_L11:; - /* "freenect.pyx":384 + /* "freenect.pyx":391 * freenect_start_video(devp) * freenect_set_video_callback(devp, video_cb) * try: # <<<<<<<<<<<<<< @@ -3604,14 +4723,13 @@ static PyObject *__pyx_pf_8freenect_22runloop(PyObject *__pyx_self, PyObject *__ * with nogil: */ { - PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb; - __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb); - __Pyx_XGOTREF(__pyx_save_exc_type); - __Pyx_XGOTREF(__pyx_save_exc_value); - __Pyx_XGOTREF(__pyx_save_exc_tb); + __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":385 + /* "freenect.pyx":392 * freenect_set_video_callback(devp, video_cb) * try: * while True: # <<<<<<<<<<<<<< @@ -3621,7 +4739,7 @@ static PyObject *__pyx_pf_8freenect_22runloop(PyObject *__pyx_self, PyObject *__ while (1) { if (!1) break; - /* "freenect.pyx":386 + /* "freenect.pyx":393 * try: * while True: * with nogil: # <<<<<<<<<<<<<< @@ -3629,127 +4747,129 @@ static PyObject *__pyx_pf_8freenect_22runloop(PyObject *__pyx_self, PyObject *__ * break */ { - #ifdef WITH_THREAD - PyThreadState *_save; - #endif - Py_UNBLOCK_THREADS - /*try:*/ { + #ifdef WITH_THREAD + PyThreadState *_save; + Py_UNBLOCK_THREADS + #endif + /*try:*/ { - /* "freenect.pyx":387 + /* "freenect.pyx":394 * while True: * with nogil: * if freenect_process_events(ctxp) < 0: # <<<<<<<<<<<<<< * break * if body: */ - __pyx_t_1 = (freenect_process_events(__pyx_v_ctxp) < 0); - if (__pyx_t_1) { + __pyx_t_2 = ((freenect_process_events(__pyx_v_ctxp) < 0) != 0); + if (__pyx_t_2) { - /* "freenect.pyx":388 + /* "freenect.pyx":395 * with nogil: * if freenect_process_events(ctxp) < 0: * break # <<<<<<<<<<<<<< * if body: * body(mdev, mdev.ctx) */ - goto __pyx_L24; - goto __pyx_L28; + goto __pyx_L23; + goto __pyx_L27; + } + __pyx_L27:; } - __pyx_L28:; - } - /* "freenect.pyx":386 + /* "freenect.pyx":393 * try: * while True: * with nogil: # <<<<<<<<<<<<<< * if freenect_process_events(ctxp) < 0: * break */ - /*finally:*/ { - int __pyx_why; - __pyx_why = 0; goto __pyx_L27; - __pyx_L24: __pyx_why = 2; goto __pyx_L27; - __pyx_L27:; - Py_BLOCK_THREADS - switch (__pyx_why) { - case 2: goto __pyx_L22_break; + /*finally:*/ { + int __pyx_why; + __pyx_why = 0; goto __pyx_L26; + __pyx_L23: __pyx_why = 2; goto __pyx_L26; + __pyx_L26:; + #ifdef WITH_THREAD + Py_BLOCK_THREADS + #endif + switch (__pyx_why) { + case 2: goto __pyx_L21_break; + } } - } } - /* "freenect.pyx":389 + /* "freenect.pyx":396 * if freenect_process_events(ctxp) < 0: * break * if body: # <<<<<<<<<<<<<< * body(mdev, mdev.ctx) * except Kill: */ - __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_body); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; __pyx_clineno = __LINE__; goto __pyx_L13_error;} - if (__pyx_t_1) { + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_body); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __pyx_L12_error;} + if (__pyx_t_2) { - /* "freenect.pyx":390 + /* "freenect.pyx":397 * break * if body: * body(mdev, mdev.ctx) # <<<<<<<<<<<<<< * except Kill: * pass */ - __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L13_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_2)); + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L12_error;} + __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(((PyObject *)__pyx_v_mdev)); - PyTuple_SET_ITEM(__pyx_t_2, 0, ((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_2, 1, ((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 = PyObject_Call(__pyx_v_body, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L13_error;} + __pyx_t_4 = PyObject_Call(__pyx_v_body, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L12_error;} __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - goto __pyx_L29; + goto __pyx_L28; } - __pyx_L29:; + __pyx_L28:; } - __pyx_L22_break:; + __pyx_L21_break:; } - __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0; - __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0; - __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0; - goto __pyx_L20_try_end; - __pyx_L13_error:; - __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __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":391 + /* "freenect.pyx":398 * if body: * body(mdev, mdev.ctx) * except Kill: # <<<<<<<<<<<<<< * pass * freenect_stop_depth(devp) */ - __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__Kill); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L15_except_error;} + __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s__Kill); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; __pyx_clineno = __LINE__; goto __pyx_L14_except_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyErr_ExceptionMatches(__pyx_t_4); + __pyx_t_10 = PyErr_ExceptionMatches(__pyx_t_4); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (__pyx_t_5) { + if (__pyx_t_10) { PyErr_Restore(0,0,0); - goto __pyx_L14_exception_handled; + goto __pyx_L13_exception_handled; } - __pyx_L15_except_error:; - __Pyx_XGIVEREF(__pyx_save_exc_type); - __Pyx_XGIVEREF(__pyx_save_exc_value); - __Pyx_XGIVEREF(__pyx_save_exc_tb); - __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb); + __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_L14_exception_handled:; - __Pyx_XGIVEREF(__pyx_save_exc_type); - __Pyx_XGIVEREF(__pyx_save_exc_value); - __Pyx_XGIVEREF(__pyx_save_exc_tb); - __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb); - __pyx_L20_try_end:; + __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":393 + /* "freenect.pyx":400 * except Kill: * pass * freenect_stop_depth(devp) # <<<<<<<<<<<<<< @@ -3758,7 +4878,7 @@ static PyObject *__pyx_pf_8freenect_22runloop(PyObject *__pyx_self, PyObject *__ */ freenect_stop_depth(__pyx_v_devp); - /* "freenect.pyx":394 + /* "freenect.pyx":401 * pass * freenect_stop_depth(devp) * freenect_stop_video(devp) # <<<<<<<<<<<<<< @@ -3767,17 +4887,18 @@ static PyObject *__pyx_pf_8freenect_22runloop(PyObject *__pyx_self, PyObject *__ */ freenect_stop_video(__pyx_v_devp); - /* "freenect.pyx":395 + /* "freenect.pyx":402 * freenect_stop_depth(devp) * freenect_stop_video(devp) * if dev is None: # <<<<<<<<<<<<<< * freenect_close_device(devp) * freenect_shutdown(ctxp) */ - __pyx_t_1 = (__pyx_v_dev == Py_None); + __pyx_t_2 = (__pyx_v_dev == Py_None); + __pyx_t_1 = (__pyx_t_2 != 0); if (__pyx_t_1) { - /* "freenect.pyx":396 + /* "freenect.pyx":403 * freenect_stop_video(devp) * if dev is None: * freenect_close_device(devp) # <<<<<<<<<<<<<< @@ -3786,7 +4907,7 @@ static PyObject *__pyx_pf_8freenect_22runloop(PyObject *__pyx_self, PyObject *__ */ freenect_close_device(__pyx_v_devp); - /* "freenect.pyx":397 + /* "freenect.pyx":404 * if dev is None: * freenect_close_device(devp) * freenect_shutdown(ctxp) # <<<<<<<<<<<<<< @@ -3794,103 +4915,130 @@ static PyObject *__pyx_pf_8freenect_22runloop(PyObject *__pyx_self, PyObject *__ * def base_runloop(CtxPtr ctx, body=None): */ freenect_shutdown(__pyx_v_ctxp); - goto __pyx_L30; + goto __pyx_L29; } - __pyx_L30:; + __pyx_L29:; __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); - __Pyx_AddTraceback("freenect.runloop"); + __Pyx_AddTraceback("freenect.runloop", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; - __Pyx_DECREF((PyObject *)__pyx_v_mdev); - __Pyx_DECREF((PyObject *)__pyx_v_ctx); + __Pyx_XDECREF((PyObject *)__pyx_v_mdev); + __Pyx_XDECREF((PyObject *)__pyx_v_ctx); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "freenect.pyx":399 +/* Python wrapper */ +static PyObject *__pyx_pw_8freenect_47base_runloop(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_8freenect_46base_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_47base_runloop = {__Pyx_NAMESTR("base_runloop"), (PyCFunction)__pyx_pw_8freenect_47base_runloop, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_8freenect_46base_runloop)}; +static PyObject *__pyx_pw_8freenect_47base_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}; + + /* "freenect.pyx":406 * freenect_shutdown(ctxp) * * def base_runloop(CtxPtr ctx, body=None): # <<<<<<<<<<<<<< * """Starts a runloop * */ - -static PyObject *__pyx_pf_8freenect_23base_runloop(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_8freenect_23base_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_23base_runloop = {__Pyx_NAMESTR("base_runloop"), (PyCFunction)__pyx_pf_8freenect_23base_runloop, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_8freenect_23base_runloop)}; -static PyObject *__pyx_pf_8freenect_23base_runloop(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - struct __pyx_obj_8freenect_CtxPtr *__pyx_v_ctx = 0; - PyObject *__pyx_v_body = 0; - freenect_context *__pyx_v_ctxp; - PyObject *__pyx_r = NULL; - int __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - int __pyx_t_4; - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__ctx,&__pyx_n_s__body,0}; - __Pyx_RefNannySetupContext("base_runloop"); - __pyx_self = __pyx_self; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args = PyDict_Size(__pyx_kwds); - PyObject* values[2] = {0,0}; values[1] = ((PyObject *)Py_None); - 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; - } - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 0: - values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__ctx); - if (likely(values[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(__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 = 406; __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; } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "base_runloop") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } __pyx_v_ctx = ((struct __pyx_obj_8freenect_CtxPtr *)values[0]); __pyx_v_body = values[1]; - } else { - __pyx_v_body = ((PyObject *)Py_None); - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 2: __pyx_v_body = PyTuple_GET_ITEM(__pyx_args, 1); - case 1: __pyx_v_ctx = ((struct __pyx_obj_8freenect_CtxPtr *)PyTuple_GET_ITEM(__pyx_args, 0)); - break; - default: goto __pyx_L5_argtuple_error; - } } 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 = 399; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("base_runloop", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; - __Pyx_AddTraceback("freenect.base_runloop"); + __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 = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_ctx), __pyx_ptype_8freenect_CtxPtr, 1, "ctx", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_8freenect_46base_runloop(__pyx_self, __pyx_v_ctx, __pyx_v_body); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_8freenect_46base_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":412 + /* "freenect.pyx":419 * """ * cdef freenect_context* ctxp * ctxp = ctx._ptr # <<<<<<<<<<<<<< * try: * while True: */ - __pyx_v_ctxp = __pyx_v_ctx->_ptr; + __pyx_t_1 = __pyx_v_ctx->_ptr; + __pyx_v_ctxp = __pyx_t_1; - /* "freenect.pyx":413 + /* "freenect.pyx":420 * cdef freenect_context* ctxp * ctxp = ctx._ptr * try: # <<<<<<<<<<<<<< @@ -3898,14 +5046,13 @@ static PyObject *__pyx_pf_8freenect_23base_runloop(PyObject *__pyx_self, PyObjec * with nogil: */ { - PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb; - __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb); - __Pyx_XGOTREF(__pyx_save_exc_type); - __Pyx_XGOTREF(__pyx_save_exc_value); - __Pyx_XGOTREF(__pyx_save_exc_tb); + __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":414 + /* "freenect.pyx":421 * ctxp = ctx._ptr * try: * while True: # <<<<<<<<<<<<<< @@ -3915,7 +5062,7 @@ static PyObject *__pyx_pf_8freenect_23base_runloop(PyObject *__pyx_self, PyObjec while (1) { if (!1) break; - /* "freenect.pyx":415 + /* "freenect.pyx":422 * try: * while True: * with nogil: # <<<<<<<<<<<<<< @@ -3923,129 +5070,131 @@ static PyObject *__pyx_pf_8freenect_23base_runloop(PyObject *__pyx_self, PyObjec * break */ { - #ifdef WITH_THREAD - PyThreadState *_save; - #endif - Py_UNBLOCK_THREADS - /*try:*/ { + #ifdef WITH_THREAD + PyThreadState *_save; + Py_UNBLOCK_THREADS + #endif + /*try:*/ { - /* "freenect.pyx":416 + /* "freenect.pyx":423 * while True: * with nogil: * if freenect_process_events(ctxp) < 0: # <<<<<<<<<<<<<< * break * if body: */ - __pyx_t_1 = (freenect_process_events(__pyx_v_ctxp) < 0); - if (__pyx_t_1) { + __pyx_t_5 = ((freenect_process_events(__pyx_v_ctxp) < 0) != 0); + if (__pyx_t_5) { - /* "freenect.pyx":417 + /* "freenect.pyx":424 * with nogil: * if freenect_process_events(ctxp) < 0: * break # <<<<<<<<<<<<<< * if body: * body(ctx) */ - goto __pyx_L17; - goto __pyx_L21; + goto __pyx_L14; + goto __pyx_L18; + } + __pyx_L18:; } - __pyx_L21:; - } - /* "freenect.pyx":415 + /* "freenect.pyx":422 * try: * while True: * with nogil: # <<<<<<<<<<<<<< * if freenect_process_events(ctxp) < 0: * break */ - /*finally:*/ { - int __pyx_why; - __pyx_why = 0; goto __pyx_L20; - __pyx_L17: __pyx_why = 2; goto __pyx_L20; - __pyx_L20:; - Py_BLOCK_THREADS - switch (__pyx_why) { - case 2: goto __pyx_L15_break; + /*finally:*/ { + int __pyx_why; + __pyx_why = 0; goto __pyx_L17; + __pyx_L14: __pyx_why = 2; goto __pyx_L17; + __pyx_L17:; + #ifdef WITH_THREAD + Py_BLOCK_THREADS + #endif + switch (__pyx_why) { + case 2: goto __pyx_L12_break; + } } - } } - /* "freenect.pyx":418 + /* "freenect.pyx":425 * if freenect_process_events(ctxp) < 0: * break * if body: # <<<<<<<<<<<<<< * body(ctx) * except Kill: */ - __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_body); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L6_error;} - if (__pyx_t_1) { + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_body); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (__pyx_t_5) { - /* "freenect.pyx":419 + /* "freenect.pyx":426 * break * if body: * body(ctx) # <<<<<<<<<<<<<< * except Kill: * pass */ - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 419; __pyx_clineno = __LINE__; goto __pyx_L6_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_2)); + __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(((PyObject *)__pyx_v_ctx)); - PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_ctx)); + PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_v_ctx)); __Pyx_GIVEREF(((PyObject *)__pyx_v_ctx)); - __pyx_t_3 = PyObject_Call(__pyx_v_body, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 419; __pyx_clineno = __LINE__; goto __pyx_L6_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - goto __pyx_L22; + __pyx_t_7 = PyObject_Call(__pyx_v_body, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + goto __pyx_L19; } - __pyx_L22:; + __pyx_L19:; } - __pyx_L15_break:; + __pyx_L12_break:; } - __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0; - __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0; - __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0; - goto __pyx_L13_try_end; - __pyx_L6_error:; __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":420 + /* "freenect.pyx":427 * if body: * body(ctx) * except Kill: # <<<<<<<<<<<<<< * pass * */ - __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__Kill); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyErr_ExceptionMatches(__pyx_t_3); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_4) { + __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s__Kill); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 427; __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_L7_exception_handled; + goto __pyx_L4_exception_handled; } - __pyx_L8_except_error:; - __Pyx_XGIVEREF(__pyx_save_exc_type); - __Pyx_XGIVEREF(__pyx_save_exc_value); - __Pyx_XGIVEREF(__pyx_save_exc_tb); - __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb); + __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_L7_exception_handled:; - __Pyx_XGIVEREF(__pyx_save_exc_type); - __Pyx_XGIVEREF(__pyx_save_exc_value); - __Pyx_XGIVEREF(__pyx_save_exc_tb); - __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb); - __pyx_L13_try_end:; + __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:; } __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_AddTraceback("freenect.base_runloop"); + __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); @@ -4053,132 +5202,147 @@ static PyObject *__pyx_pf_8freenect_23base_runloop(PyObject *__pyx_self, PyObjec return __pyx_r; } -/* "freenect.pyx":423 - * pass - * - * def _depth_cb_np(dev, string, timestamp): # <<<<<<<<<<<<<< - * """Converts the raw depth data into a numpy array for your function - * - */ - -static PyObject *__pyx_pf_8freenect_24_depth_cb_np(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_8freenect_24_depth_cb_np[] = "Converts the raw depth data into a numpy array for your function\n\n Args:\n dev: DevPtr object\n string: A python string with the depth data\n timestamp: An int representing the time\n\n Returns:\n (dev, data, timestamp) where data is a 2D numpy array\n "; -static PyMethodDef __pyx_mdef_8freenect_24_depth_cb_np = {__Pyx_NAMESTR("_depth_cb_np"), (PyCFunction)__pyx_pf_8freenect_24_depth_cb_np, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_8freenect_24_depth_cb_np)}; -static PyObject *__pyx_pf_8freenect_24_depth_cb_np(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +/* Python wrapper */ +static PyObject *__pyx_pw_8freenect_49_depth_cb_np(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_8freenect_48_depth_cb_np[] = "Converts the raw depth data into a numpy array for your function\n\n Args:\n dev: DevPtr object\n string: A python string with the depth data\n timestamp: An int representing the time\n\n Returns:\n (dev, data, timestamp) where data is a 2D numpy array\n "; +static PyMethodDef __pyx_mdef_8freenect_49_depth_cb_np = {__Pyx_NAMESTR("_depth_cb_np"), (PyCFunction)__pyx_pw_8freenect_49_depth_cb_np, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_8freenect_48_depth_cb_np)}; +static PyObject *__pyx_pw_8freenect_49_depth_cb_np(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_dev = 0; PyObject *__pyx_v_string = 0; PyObject *__pyx_v_timestamp = 0; - PyObject *__pyx_v_data; - PyObject *__pyx_r = NULL; - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__dev,&__pyx_n_s__string,&__pyx_n_s__timestamp,0}; - __Pyx_RefNannySetupContext("_depth_cb_np"); - __pyx_self = __pyx_self; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args = PyDict_Size(__pyx_kwds); + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_depth_cb_np (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__dev,&__pyx_n_s__string,&__pyx_n_s__timestamp,0}; PyObject* values[3] = {0,0,0}; - switch (PyTuple_GET_SIZE(__pyx_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; - } - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 0: - values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__dev); - if (likely(values[0])) kw_args--; - else goto __pyx_L5_argtuple_error; - case 1: - values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__string); - if (likely(values[1])) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("_depth_cb_np", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + 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__string)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("_depth_cb_np", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__timestamp)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("_depth_cb_np", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } } - case 2: - values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__timestamp); - if (likely(values[2])) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("_depth_cb_np", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_depth_cb_np") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "_depth_cb_np") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; __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 = values[0]; __pyx_v_string = values[1]; __pyx_v_timestamp = values[2]; - } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { - goto __pyx_L5_argtuple_error; - } else { - __pyx_v_dev = PyTuple_GET_ITEM(__pyx_args, 0); - __pyx_v_string = PyTuple_GET_ITEM(__pyx_args, 1); - __pyx_v_timestamp = PyTuple_GET_ITEM(__pyx_args, 2); } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("_depth_cb_np", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_depth_cb_np", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; - __Pyx_AddTraceback("freenect._depth_cb_np"); + __Pyx_AddTraceback("freenect._depth_cb_np", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - __pyx_v_data = Py_None; __Pyx_INCREF(Py_None); + __pyx_r = __pyx_pf_8freenect_48_depth_cb_np(__pyx_self, __pyx_v_dev, __pyx_v_string, __pyx_v_timestamp); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "freenect.pyx":430 + * pass + * + * def _depth_cb_np(dev, string, timestamp): # <<<<<<<<<<<<<< + * """Converts the raw depth data into a numpy array for your function + * + */ + +static PyObject *__pyx_pf_8freenect_48_depth_cb_np(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_dev, PyObject *__pyx_v_string, PyObject *__pyx_v_timestamp) { + PyObject *__pyx_v_data = NULL; + 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; + PyObject *__pyx_t_5 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("_depth_cb_np", 0); - /* "freenect.pyx":434 + /* "freenect.pyx":441 * (dev, data, timestamp) where data is a 2D numpy array * """ * data = np.fromstring(string, dtype=np.uint16) # <<<<<<<<<<<<<< * data.resize((480, 640)) * return dev, data, timestamp */ - __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__fromstring); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__fromstring); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __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 = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_1)); + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_string); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_string); __Pyx_GIVEREF(__pyx_v_string); - __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_3)); - __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__uint16); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s__uint16); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__dtype), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__dtype), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = PyEval_CallObjectWithKeywords(__pyx_t_2, ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_v_data); __pyx_v_data = __pyx_t_5; __pyx_t_5 = 0; - /* "freenect.pyx":435 + /* "freenect.pyx":442 * """ * data = np.fromstring(string, dtype=np.uint16) * data.resize((480, 640)) # <<<<<<<<<<<<<< * return dev, data, timestamp * */ - __pyx_t_5 = PyObject_GetAttr(__pyx_v_data, __pyx_n_s__resize); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s__resize); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - __pyx_t_3 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_k_tuple_6), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_k_tuple_6), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - /* "freenect.pyx":436 + /* "freenect.pyx":443 * data = np.fromstring(string, dtype=np.uint16) * data.resize((480, 640)) * return dev, data, timestamp # <<<<<<<<<<<<<< @@ -4186,8 +5350,8 @@ static PyObject *__pyx_pf_8freenect_24_depth_cb_np(PyObject *__pyx_self, PyObjec * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_3)); + __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 443; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_dev); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_dev); __Pyx_GIVEREF(__pyx_v_dev); @@ -4209,141 +5373,156 @@ static PyObject *__pyx_pf_8freenect_24_depth_cb_np(PyObject *__pyx_self, PyObjec __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); - __Pyx_AddTraceback("freenect._depth_cb_np"); + __Pyx_AddTraceback("freenect._depth_cb_np", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; - __Pyx_DECREF(__pyx_v_data); + __Pyx_XDECREF(__pyx_v_data); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "freenect.pyx":439 - * - * - * def _video_cb_np(dev, string, timestamp): # <<<<<<<<<<<<<< - * """Converts the raw depth data into a numpy array for your function - * - */ - -static PyObject *__pyx_pf_8freenect_25_video_cb_np(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_8freenect_25_video_cb_np[] = "Converts the raw depth data into a numpy array for your function\n\n Args:\n dev: DevPtr object\n string: A python string with the video data\n timestamp: An int representing the time\n\n Returns:\n (dev, data, timestamp) where data is a 2D numpy array\n "; -static PyMethodDef __pyx_mdef_8freenect_25_video_cb_np = {__Pyx_NAMESTR("_video_cb_np"), (PyCFunction)__pyx_pf_8freenect_25_video_cb_np, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_8freenect_25_video_cb_np)}; -static PyObject *__pyx_pf_8freenect_25_video_cb_np(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +/* Python wrapper */ +static PyObject *__pyx_pw_8freenect_51_video_cb_np(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_8freenect_50_video_cb_np[] = "Converts the raw depth data into a numpy array for your function\n\n Args:\n dev: DevPtr object\n string: A python string with the video data\n timestamp: An int representing the time\n\n Returns:\n (dev, data, timestamp) where data is a 2D numpy array\n "; +static PyMethodDef __pyx_mdef_8freenect_51_video_cb_np = {__Pyx_NAMESTR("_video_cb_np"), (PyCFunction)__pyx_pw_8freenect_51_video_cb_np, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_8freenect_50_video_cb_np)}; +static PyObject *__pyx_pw_8freenect_51_video_cb_np(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_dev = 0; PyObject *__pyx_v_string = 0; PyObject *__pyx_v_timestamp = 0; - PyObject *__pyx_v_data; - PyObject *__pyx_r = NULL; - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__dev,&__pyx_n_s__string,&__pyx_n_s__timestamp,0}; - __Pyx_RefNannySetupContext("_video_cb_np"); - __pyx_self = __pyx_self; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args = PyDict_Size(__pyx_kwds); + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_video_cb_np (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__dev,&__pyx_n_s__string,&__pyx_n_s__timestamp,0}; PyObject* values[3] = {0,0,0}; - switch (PyTuple_GET_SIZE(__pyx_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; - } - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 0: - values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__dev); - if (likely(values[0])) kw_args--; - else goto __pyx_L5_argtuple_error; - case 1: - values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__string); - if (likely(values[1])) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("_video_cb_np", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + 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__string)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("_video_cb_np", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__timestamp)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("_video_cb_np", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } } - case 2: - values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__timestamp); - if (likely(values[2])) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("_video_cb_np", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_video_cb_np") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "_video_cb_np") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __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 = values[0]; __pyx_v_string = values[1]; __pyx_v_timestamp = values[2]; - } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { - goto __pyx_L5_argtuple_error; - } else { - __pyx_v_dev = PyTuple_GET_ITEM(__pyx_args, 0); - __pyx_v_string = PyTuple_GET_ITEM(__pyx_args, 1); - __pyx_v_timestamp = PyTuple_GET_ITEM(__pyx_args, 2); } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("_video_cb_np", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_video_cb_np", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; - __Pyx_AddTraceback("freenect._video_cb_np"); + __Pyx_AddTraceback("freenect._video_cb_np", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - __pyx_v_data = Py_None; __Pyx_INCREF(Py_None); + __pyx_r = __pyx_pf_8freenect_50_video_cb_np(__pyx_self, __pyx_v_dev, __pyx_v_string, __pyx_v_timestamp); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "freenect.pyx":446 + * + * + * def _video_cb_np(dev, string, timestamp): # <<<<<<<<<<<<<< + * """Converts the raw depth data into a numpy array for your function + * + */ + +static PyObject *__pyx_pf_8freenect_50_video_cb_np(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_dev, PyObject *__pyx_v_string, PyObject *__pyx_v_timestamp) { + PyObject *__pyx_v_data = NULL; + 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; + PyObject *__pyx_t_5 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("_video_cb_np", 0); - /* "freenect.pyx":450 + /* "freenect.pyx":457 * (dev, data, timestamp) where data is a 2D numpy array * """ * data = np.fromstring(string, dtype=np.uint8) # <<<<<<<<<<<<<< * data.resize((480, 640, 3)) * return dev, data, timestamp */ - __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__fromstring); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__fromstring); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __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 = 450; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_1)); + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_string); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_string); __Pyx_GIVEREF(__pyx_v_string); - __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_3)); - __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__uint8); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s__uint8); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__dtype), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__dtype), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = PyEval_CallObjectWithKeywords(__pyx_t_2, ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_v_data); __pyx_v_data = __pyx_t_5; __pyx_t_5 = 0; - /* "freenect.pyx":451 + /* "freenect.pyx":458 * """ * data = np.fromstring(string, dtype=np.uint8) * data.resize((480, 640, 3)) # <<<<<<<<<<<<<< * return dev, data, timestamp * */ - __pyx_t_5 = PyObject_GetAttr(__pyx_v_data, __pyx_n_s__resize); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s__resize); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - __pyx_t_3 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_k_tuple_8), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_k_tuple_8), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - /* "freenect.pyx":452 + /* "freenect.pyx":459 * data = np.fromstring(string, dtype=np.uint8) * data.resize((480, 640, 3)) * return dev, data, timestamp # <<<<<<<<<<<<<< @@ -4351,8 +5530,8 @@ static PyObject *__pyx_pf_8freenect_25_video_cb_np(PyObject *__pyx_self, PyObjec * import_array() */ __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_3)); + __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 459; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_dev); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_dev); __Pyx_GIVEREF(__pyx_v_dev); @@ -4374,115 +5553,135 @@ static PyObject *__pyx_pf_8freenect_25_video_cb_np(PyObject *__pyx_self, PyObjec __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); - __Pyx_AddTraceback("freenect._video_cb_np"); + __Pyx_AddTraceback("freenect._video_cb_np", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; - __Pyx_DECREF(__pyx_v_data); + __Pyx_XDECREF(__pyx_v_data); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "freenect.pyx":456 - * import_array() - * - * def sync_get_depth(index=0, format=DEPTH_11BIT): # <<<<<<<<<<<<<< - * """Get the next available depth frame from the kinect, as a numpy array. - * - */ - -static PyObject *__pyx_pf_8freenect_26sync_get_depth(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_8freenect_26sync_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_26sync_get_depth = {__Pyx_NAMESTR("sync_get_depth"), (PyCFunction)__pyx_pf_8freenect_26sync_get_depth, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_8freenect_26sync_get_depth)}; -static PyObject *__pyx_pf_8freenect_26sync_get_depth(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +/* 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; - 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; - int __pyx_t_1; - freenect_depth_format __pyx_t_2; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - int __pyx_t_5; - npy_intp __pyx_t_6; - npy_intp __pyx_t_7; - PyObject *__pyx_t_8 = NULL; - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__index,&__pyx_n_s__format,0}; - __Pyx_RefNannySetupContext("sync_get_depth"); - __pyx_self = __pyx_self; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args = PyDict_Size(__pyx_kwds); + 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_9; - 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; - } - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 0: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__index); - if (value) { values[0] = value; kw_args--; } + 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; } - case 1: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__format); - if (value) { values[1] = value; kw_args--; } + 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 = 463; __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; } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "sync_get_depth") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } __pyx_v_index = values[0]; __pyx_v_format = values[1]; - } else { - __pyx_v_index = ((PyObject *)__pyx_int_0); - __pyx_v_format = __pyx_k_9; - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 2: __pyx_v_format = PyTuple_GET_ITEM(__pyx_args, 1); - case 1: __pyx_v_index = PyTuple_GET_ITEM(__pyx_args, 0); - case 0: break; - default: goto __pyx_L5_argtuple_error; - } } 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 = 456; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("sync_get_depth", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; - __Pyx_AddTraceback("freenect.sync_get_depth"); + __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); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "freenect.pyx":472 - * cdef npc.npy_intp dims[2] +/* "freenect.pyx":463 + * import_array() + * + * def sync_get_depth(index=0, format=DEPTH_11BIT): # <<<<<<<<<<<<<< + * """Get the next available depth frame from the kinect, as a numpy array. + * + */ + +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":479 + * 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_AsInt(__pyx_v_index); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_index); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 479; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v__index = __pyx_t_1; - /* "freenect.pyx":473 + /* "freenect.pyx":480 * 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 = 473; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = ((freenect_depth_format)PyInt_AsLong(__pyx_v_format)); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 480; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v__format = __pyx_t_2; - /* "freenect.pyx":474 + /* "freenect.pyx":481 * cdef int _index = index * cdef freenect_depth_format _format = format * with nogil: # <<<<<<<<<<<<<< @@ -4490,156 +5689,195 @@ static PyObject *__pyx_pf_8freenect_26sync_get_depth(PyObject *__pyx_self, PyObj * if out: */ { - #ifdef WITH_THREAD - PyThreadState *_save; - #endif - Py_UNBLOCK_THREADS - /*try:*/ { + #ifdef WITH_THREAD + PyThreadState *_save; + Py_UNBLOCK_THREADS + #endif + /*try:*/ { - /* "freenect.pyx":475 + /* "freenect.pyx":482 * 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); - } + __pyx_v_out = freenect_sync_get_depth((&__pyx_v_data), (&__pyx_v_timestamp), __pyx_v__index, __pyx_v__format); + } - /* "freenect.pyx":474 + /* "freenect.pyx":481 * cdef int _index = index * cdef freenect_depth_format _format = format * with nogil: # <<<<<<<<<<<<<< * out = freenect_sync_get_depth(&data, ×tamp, _index, _format) * if out: */ - /*finally:*/ { - Py_BLOCK_THREADS - } + /*finally:*/ { + #ifdef WITH_THREAD + Py_BLOCK_THREADS + #endif + } } - /* "freenect.pyx":476 + /* "freenect.pyx":483 * with nogil: * out = freenect_sync_get_depth(&data, ×tamp, _index, _format) * if out: # <<<<<<<<<<<<<< * error_open_device() * return */ - if (__pyx_v_out) { + __pyx_t_3 = (__pyx_v_out != 0); + if (__pyx_t_3) { - /* "freenect.pyx":477 + /* "freenect.pyx":484 * out = freenect_sync_get_depth(&data, ×tamp, _index, _format) * if out: * error_open_device() # <<<<<<<<<<<<<< * return - * if format == DEPTH_11BIT: + * if format in [DEPTH_11BIT, DEPTH_10BIT, DEPTH_MM, DEPTH_REGISTERED]: */ - __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__error_open_device); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 477; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 477; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s__error_open_device); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_5 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __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":478 + /* "freenect.pyx":485 * if out: * error_open_device() * return # <<<<<<<<<<<<<< - * if format == DEPTH_11BIT: + * 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; - goto __pyx_L9; + goto __pyx_L6; } - __pyx_L9:; + __pyx_L6:; - /* "freenect.pyx":479 + /* "freenect.pyx":486 * error_open_device() * return - * if format == DEPTH_11BIT: # <<<<<<<<<<<<<< + * 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_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__DEPTH_11BIT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 479; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __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 = 486; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_format, __pyx_t_4, Py_EQ); 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_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 = 486; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); 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_3); __pyx_t_3 = 0; - if (__pyx_t_5) { + __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + if (!((int)__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 = 486; __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 = 486; __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 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_8 = ((int)__pyx_t_7); + } else { + __pyx_t_8 = ((int)__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 = 486; __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 = 486; __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 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_7 = ((int)__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 = 486; __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 = 486; __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 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_3 = ((int)__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":480 + /* "freenect.pyx":487 * return - * if format == DEPTH_11BIT: + * 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_6 = 480; - __pyx_t_7 = 640; - (__pyx_v_dims[0]) = __pyx_t_6; - (__pyx_v_dims[1]) = __pyx_t_7; + __pyx_t_9 = 480; + __pyx_t_10 = 640; + (__pyx_v_dims[0]) = __pyx_t_9; + (__pyx_v_dims[1]) = __pyx_t_10; - /* "freenect.pyx":481 - * if format == DEPTH_11BIT: + /* "freenect.pyx":488 + * 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_3 = PyArray_SimpleNewFromData(2, __pyx_v_dims, NPY_UINT16, __pyx_v_data); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 481; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_timestamp); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 481; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __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 = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_4 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_timestamp); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 481; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_8)); - PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3); - __Pyx_GIVEREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_4); + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __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_3 = 0; + __pyx_t_5 = 0; __pyx_t_4 = 0; - __pyx_r = ((PyObject *)__pyx_t_8); - __pyx_t_8 = 0; + __pyx_r = ((PyObject *)__pyx_t_6); + __pyx_t_6 = 0; goto __pyx_L0; - goto __pyx_L10; + goto __pyx_L7; } /*else*/ { - /* "freenect.pyx":483 + /* "freenect.pyx":490 * return PyArray_SimpleNewFromData(2, dims, npc.NPY_UINT16, data), timestamp * else: * raise TypeError('Conversion not implemented for type [%d]' % (format)) # <<<<<<<<<<<<<< * * */ - __pyx_t_8 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_10), __pyx_v_format); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_8)); - __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_4)); - PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_8)); - __Pyx_GIVEREF(((PyObject *)__pyx_t_8)); - __pyx_t_8 = 0; - __pyx_t_8 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_8); + __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_10), __pyx_v_format); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 490; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_6)); + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 490; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_6)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_6)); + __pyx_t_6 = 0; + __pyx_t_6 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 490; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; - __Pyx_Raise(__pyx_t_8, 0, 0); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_Raise(__pyx_t_6, 0, 0, 0); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 490; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_L10:; + __pyx_L7:; __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_XDECREF(__pyx_t_8); - __Pyx_AddTraceback("freenect.sync_get_depth"); + __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); @@ -4647,7 +5885,74 @@ static PyObject *__pyx_pf_8freenect_26sync_get_depth(PyObject *__pyx_self, PyObj return __pyx_r; } -/* "freenect.pyx":486 +/* 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_11; + 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 = 493; __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 = 493; __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); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "freenect.pyx":493 * * * def sync_get_video(index=0, format=VIDEO_RGB): # <<<<<<<<<<<<<< @@ -4655,12 +5960,7 @@ static PyObject *__pyx_pf_8freenect_26sync_get_depth(PyObject *__pyx_self, PyObj * */ -static PyObject *__pyx_pf_8freenect_27sync_get_video(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_8freenect_27sync_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_27sync_get_video = {__Pyx_NAMESTR("sync_get_video"), (PyCFunction)__pyx_pf_8freenect_27sync_get_video, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_8freenect_27sync_get_video)}; -static PyObject *__pyx_pf_8freenect_27sync_get_video(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_index = 0; - PyObject *__pyx_v_format = 0; +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]; @@ -4668,86 +5968,42 @@ static PyObject *__pyx_pf_8freenect_27sync_get_video(PyObject *__pyx_self, PyObj 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; - PyObject *__pyx_t_3 = NULL; + int __pyx_t_3; PyObject *__pyx_t_4 = NULL; - int __pyx_t_5; + 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; - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__index,&__pyx_n_s__format,0}; - __Pyx_RefNannySetupContext("sync_get_video"); - __pyx_self = __pyx_self; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args = PyDict_Size(__pyx_kwds); - PyObject* values[2] = {0,0}; - values[0] = ((PyObject *)__pyx_int_0); - values[1] = __pyx_k_11; - 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; - } - switch (PyTuple_GET_SIZE(__pyx_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, PyTuple_GET_SIZE(__pyx_args), "sync_get_video") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - __pyx_v_index = values[0]; - __pyx_v_format = values[1]; - } else { - __pyx_v_index = ((PyObject *)__pyx_int_0); - __pyx_v_format = __pyx_k_11; - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 2: __pyx_v_format = PyTuple_GET_ITEM(__pyx_args, 1); - case 1: __pyx_v_index = PyTuple_GET_ITEM(__pyx_args, 0); - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - } - 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 = 486; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_L3_error:; - __Pyx_AddTraceback("freenect.sync_get_video"); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("sync_get_video", 0); - /* "freenect.pyx":502 + /* "freenect.pyx":509 * 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_AsInt(__pyx_v_index); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_index); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v__index = __pyx_t_1; - /* "freenect.pyx":503 + /* "freenect.pyx":510 * 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 = 503; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = ((freenect_video_format)PyInt_AsLong(__pyx_v_format)); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v__format = __pyx_t_2; - /* "freenect.pyx":504 + /* "freenect.pyx":511 * cdef int _index = index * cdef freenect_video_format _format = format * with nogil: # <<<<<<<<<<<<<< @@ -4755,58 +6011,61 @@ static PyObject *__pyx_pf_8freenect_27sync_get_video(PyObject *__pyx_self, PyObj * if out: */ { - #ifdef WITH_THREAD - PyThreadState *_save; - #endif - Py_UNBLOCK_THREADS - /*try:*/ { + #ifdef WITH_THREAD + PyThreadState *_save; + Py_UNBLOCK_THREADS + #endif + /*try:*/ { - /* "freenect.pyx":505 + /* "freenect.pyx":512 * 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); - } + __pyx_v_out = freenect_sync_get_video((&__pyx_v_data), (&__pyx_v_timestamp), __pyx_v__index, __pyx_v__format); + } - /* "freenect.pyx":504 + /* "freenect.pyx":511 * cdef int _index = index * cdef freenect_video_format _format = format * with nogil: # <<<<<<<<<<<<<< * out = freenect_sync_get_video(&data, ×tamp, _index, _format) * if out: */ - /*finally:*/ { - Py_BLOCK_THREADS - } + /*finally:*/ { + #ifdef WITH_THREAD + Py_BLOCK_THREADS + #endif + } } - /* "freenect.pyx":506 + /* "freenect.pyx":513 * with nogil: * out = freenect_sync_get_video(&data, ×tamp, _index, _format) * if out: # <<<<<<<<<<<<<< * error_open_device() * return */ - if (__pyx_v_out) { + __pyx_t_3 = (__pyx_v_out != 0); + if (__pyx_t_3) { - /* "freenect.pyx":507 + /* "freenect.pyx":514 * out = freenect_sync_get_video(&data, ×tamp, _index, _format) * if out: * error_open_device() # <<<<<<<<<<<<<< * return * if format == VIDEO_RGB: */ - __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__error_open_device); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 507; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 507; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s__error_open_device); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_5 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; __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":508 + /* "freenect.pyx":515 * if out: * error_open_device() * return # <<<<<<<<<<<<<< @@ -4816,27 +6075,26 @@ static PyObject *__pyx_pf_8freenect_27sync_get_video(PyObject *__pyx_self, PyObj __Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; - goto __pyx_L9; + goto __pyx_L6; } - __pyx_L9:; + __pyx_L6:; - /* "freenect.pyx":509 + /* "freenect.pyx":516 * 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_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__VIDEO_RGB); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_format, __pyx_t_4, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s__VIDEO_RGB); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 516; __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 = 516; __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 = 516; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_5) { + if (__pyx_t_3) { - /* "freenect.pyx":510 + /* "freenect.pyx":517 * return * if format == VIDEO_RGB: * dims[0], dims[1], dims[2] = 480, 640, 3 # <<<<<<<<<<<<<< @@ -4850,7 +6108,7 @@ static PyObject *__pyx_pf_8freenect_27sync_get_video(PyObject *__pyx_self, PyObj (__pyx_v_dims[1]) = __pyx_t_7; (__pyx_v_dims[2]) = __pyx_t_8; - /* "freenect.pyx":511 + /* "freenect.pyx":518 * if format == VIDEO_RGB: * dims[0], dims[1], dims[2] = 480, 640, 3 * return PyArray_SimpleNewFromData(3, dims, npc.NPY_UINT8, data), timestamp # <<<<<<<<<<<<<< @@ -4858,41 +6116,40 @@ static PyObject *__pyx_pf_8freenect_27sync_get_video(PyObject *__pyx_self, PyObj * dims[0], dims[1] = 480, 640 */ __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = PyArray_SimpleNewFromData(3, __pyx_v_dims, NPY_UINT8, __pyx_v_data); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_timestamp); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __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 = 518; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_9)); - PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_3); - __Pyx_GIVEREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_4); + __pyx_t_5 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_timestamp); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 518; __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 = 518; __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); - __pyx_t_3 = 0; + 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 = ((PyObject *)__pyx_t_9); __pyx_t_9 = 0; goto __pyx_L0; - goto __pyx_L10; + goto __pyx_L7; } - /* "freenect.pyx":512 + /* "freenect.pyx":519 * 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_GetName(__pyx_m, __pyx_n_s__VIDEO_IR_8BIT); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s__VIDEO_IR_8BIT); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_9); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_format, __pyx_t_9, Py_EQ); 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); + __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 = 519; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (__pyx_t_5) { + __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_3) { - /* "freenect.pyx":513 + /* "freenect.pyx":520 * return PyArray_SimpleNewFromData(3, dims, npc.NPY_UINT8, data), timestamp * elif format == VIDEO_IR_8BIT: * dims[0], dims[1] = 480, 640 # <<<<<<<<<<<<<< @@ -4904,7 +6161,7 @@ static PyObject *__pyx_pf_8freenect_27sync_get_video(PyObject *__pyx_self, PyObj (__pyx_v_dims[0]) = __pyx_t_8; (__pyx_v_dims[1]) = __pyx_t_7; - /* "freenect.pyx":514 + /* "freenect.pyx":521 * elif format == VIDEO_IR_8BIT: * dims[0], dims[1] = 480, 640 * return PyArray_SimpleNewFromData(2, dims, npc.NPY_UINT8, data), timestamp # <<<<<<<<<<<<<< @@ -4912,55 +6169,55 @@ static PyObject *__pyx_pf_8freenect_27sync_get_video(PyObject *__pyx_self, PyObj * raise TypeError('Conversion not implemented for type [%d]' % (format)) */ __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 = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_9 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_timestamp); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __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 = 521; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_9 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_timestamp); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 521; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_9); - __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_3)); - PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_9); + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 521; __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_4 = 0; + __pyx_t_5 = 0; __pyx_t_9 = 0; - __pyx_r = ((PyObject *)__pyx_t_3); - __pyx_t_3 = 0; + __pyx_r = ((PyObject *)__pyx_t_4); + __pyx_t_4 = 0; goto __pyx_L0; - goto __pyx_L10; + goto __pyx_L7; } /*else*/ { - /* "freenect.pyx":516 + /* "freenect.pyx":523 * return PyArray_SimpleNewFromData(2, dims, npc.NPY_UINT8, data), timestamp * else: * raise TypeError('Conversion not implemented for type [%d]' % (format)) # <<<<<<<<<<<<<< * * */ - __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_10), __pyx_v_format); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 516; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_3)); - __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 516; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_9)); - PyTuple_SET_ITEM(__pyx_t_9, 0, ((PyObject *)__pyx_t_3)); - __Pyx_GIVEREF(((PyObject *)__pyx_t_3)); - __pyx_t_3 = 0; - __pyx_t_3 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 516; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_10), __pyx_v_format); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_4)); + __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + PyTuple_SET_ITEM(__pyx_t_9, 0, ((PyObject *)__pyx_t_4)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_4)); + __pyx_t_4 = 0; + __pyx_t_4 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0; - __Pyx_Raise(__pyx_t_3, 0, 0); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 516; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_Raise(__pyx_t_4, 0, 0, 0); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_L10:; + __pyx_L7:; __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_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_9); - __Pyx_AddTraceback("freenect.sync_get_video"); + __Pyx_AddTraceback("freenect.sync_get_video", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -4968,7 +6225,20 @@ static PyObject *__pyx_pf_8freenect_27sync_get_video(PyObject *__pyx_self, PyObj return __pyx_r; } -/* "freenect.pyx":519 +/* 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); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "freenect.pyx":526 * * * def sync_stop(): # <<<<<<<<<<<<<< @@ -4976,15 +6246,12 @@ static PyObject *__pyx_pf_8freenect_27sync_get_video(PyObject *__pyx_self, PyObj * """ */ -static PyObject *__pyx_pf_8freenect_28sync_stop(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static char __pyx_doc_8freenect_28sync_stop[] = "Terminate the synchronous runloop if running, else this is a NOP\n "; -static PyMethodDef __pyx_mdef_8freenect_28sync_stop = {__Pyx_NAMESTR("sync_stop"), (PyCFunction)__pyx_pf_8freenect_28sync_stop, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_8freenect_28sync_stop)}; -static PyObject *__pyx_pf_8freenect_28sync_stop(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { +static PyObject *__pyx_pf_8freenect_56sync_stop(CYTHON_UNUSED PyObject *__pyx_self) { PyObject *__pyx_r = NULL; - __Pyx_RefNannySetupContext("sync_stop"); - __pyx_self = __pyx_self; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("sync_stop", 0); - /* "freenect.pyx":522 + /* "freenect.pyx":529 * """Terminate the synchronous runloop if running, else this is a NOP * """ * freenect_sync_stop() # <<<<<<<<<<<<<< @@ -4997,7 +6264,18 @@ static PyObject *__pyx_pf_8freenect_28sync_stop(PyObject *__pyx_self, CYTHON_UNU return __pyx_r; } -/* "numpy.pxd":188 +/* 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)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "numpy.pxd":194 * # experimental exception made for __getbuffer__ and __releasebuffer__ * # -- the details of this may change. * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<< @@ -5005,8 +6283,7 @@ static PyObject *__pyx_pf_8freenect_28sync_stop(PyObject *__pyx_self, CYTHON_UNU * # requirements, and does not yet fullfill the PEP. */ -static CYTHON_UNUSED int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/ -static CYTHON_UNUSED int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { +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; @@ -5018,6 +6295,7 @@ static CYTHON_UNUSED int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_ 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; @@ -5027,13 +6305,32 @@ static CYTHON_UNUSED int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_ int __pyx_t_7; PyObject *__pyx_t_8 = NULL; char *__pyx_t_9; - __Pyx_RefNannySetupContext("__getbuffer__"); - if (__pyx_v_info == NULL) return 0; - __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None); - __Pyx_GIVEREF(__pyx_v_info->obj); + 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); + } - /* "numpy.pxd":194 + /* "numpy.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; + goto __pyx_L3; + } + __pyx_L3:; + + /* "numpy.pxd":203 + * * cdef int copy_shape, i, ndim * cdef int endian_detector = 1 # <<<<<<<<<<<<<< * cdef bint little_endian = ((&endian_detector)[0] != 0) @@ -5041,7 +6338,7 @@ static CYTHON_UNUSED int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_ */ __pyx_v_endian_detector = 1; - /* "numpy.pxd":195 + /* "numpy.pxd":204 * cdef int copy_shape, i, ndim * cdef int endian_detector = 1 * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< @@ -5050,26 +6347,26 @@ static CYTHON_UNUSED int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_ */ __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); - /* "numpy.pxd":197 + /* "numpy.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(((PyArrayObject *)__pyx_v_self)); + __pyx_v_ndim = PyArray_NDIM(__pyx_v_self); - /* "numpy.pxd":199 + /* "numpy.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))); + __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); if (__pyx_t_1) { - /* "numpy.pxd":200 + /* "numpy.pxd":209 * * if sizeof(npy_intp) != sizeof(Py_ssize_t): * copy_shape = 1 # <<<<<<<<<<<<<< @@ -5077,11 +6374,11 @@ static CYTHON_UNUSED int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_ * copy_shape = 0 */ __pyx_v_copy_shape = 1; - goto __pyx_L5; + goto __pyx_L4; } /*else*/ { - /* "numpy.pxd":202 + /* "numpy.pxd":211 * copy_shape = 1 * else: * copy_shape = 0 # <<<<<<<<<<<<<< @@ -5090,135 +6387,136 @@ static CYTHON_UNUSED int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_ */ __pyx_v_copy_shape = 0; } - __pyx_L5:; + __pyx_L4:; - /* "numpy.pxd":204 + /* "numpy.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); + __pyx_t_1 = (((__pyx_v_flags & PyBUF_C_CONTIGUOUS) == PyBUF_C_CONTIGUOUS) != 0); if (__pyx_t_1) { - /* "numpy.pxd":205 + /* "numpy.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(((PyArrayObject *)__pyx_v_self), NPY_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) { - /* "numpy.pxd":206 + /* "numpy.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 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_13), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_13), 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); + __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - {__pyx_filename = __pyx_f[1]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L6; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L5; } - __pyx_L6:; + __pyx_L5:; - /* "numpy.pxd":208 + /* "numpy.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); + __pyx_t_3 = (((__pyx_v_flags & PyBUF_F_CONTIGUOUS) == PyBUF_F_CONTIGUOUS) != 0); if (__pyx_t_3) { - /* "numpy.pxd":209 + /* "numpy.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(((PyArrayObject *)__pyx_v_self), NPY_F_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) { - /* "numpy.pxd":210 + /* "numpy.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 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_15), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_15), 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); + __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - {__pyx_filename = __pyx_f[1]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L7; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L6; } - __pyx_L7:; + __pyx_L6:; - /* "numpy.pxd":212 + /* "numpy.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(((PyArrayObject *)__pyx_v_self)); + __pyx_v_info->buf = PyArray_DATA(__pyx_v_self); - /* "numpy.pxd":213 + /* "numpy.pxd":222 * * info.buf = PyArray_DATA(self) * info.ndim = ndim # <<<<<<<<<<<<<< * if copy_shape: - * # Allocate new buffer for strides and shape info. This is allocated + * # Allocate new buffer for strides and shape info. */ __pyx_v_info->ndim = __pyx_v_ndim; - /* "numpy.pxd":214 + /* "numpy.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. + * # Allocate new buffer for strides and shape info. + * # This is allocated as one block, strides first. */ - if (__pyx_v_copy_shape) { + __pyx_t_2 = (__pyx_v_copy_shape != 0); + if (__pyx_t_2) { - /* "numpy.pxd":217 - * # 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) # <<<<<<<<<<<<<< + /* "numpy.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)) * __pyx_v_ndim) * 2))); + __pyx_v_info->strides = ((Py_ssize_t *)malloc((((sizeof(Py_ssize_t)) * ((size_t)__pyx_v_ndim)) * 2))); - /* "numpy.pxd":218 - * # as one block, strides first. - * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) + /* "numpy.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); - /* "numpy.pxd":219 - * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) + /* "numpy.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] @@ -5228,49 +6526,49 @@ static CYTHON_UNUSED int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_ for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { __pyx_v_i = __pyx_t_6; - /* "numpy.pxd":220 + /* "numpy.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(((PyArrayObject *)__pyx_v_self))[__pyx_v_i]); + (__pyx_v_info->strides[__pyx_v_i]) = (PyArray_STRIDES(__pyx_v_self)[__pyx_v_i]); - /* "numpy.pxd":221 + /* "numpy.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(((PyArrayObject *)__pyx_v_self))[__pyx_v_i]); + (__pyx_v_info->shape[__pyx_v_i]) = (PyArray_DIMS(__pyx_v_self)[__pyx_v_i]); } - goto __pyx_L8; + goto __pyx_L7; } /*else*/ { - /* "numpy.pxd":223 + /* "numpy.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(((PyArrayObject *)__pyx_v_self))); + __pyx_v_info->strides = ((Py_ssize_t *)PyArray_STRIDES(__pyx_v_self)); - /* "numpy.pxd":224 + /* "numpy.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(((PyArrayObject *)__pyx_v_self))); + __pyx_v_info->shape = ((Py_ssize_t *)PyArray_DIMS(__pyx_v_self)); } - __pyx_L8:; + __pyx_L7:; - /* "numpy.pxd":225 + /* "numpy.pxd":234 * info.strides = PyArray_STRIDES(self) * info.shape = PyArray_DIMS(self) * info.suboffsets = NULL # <<<<<<<<<<<<<< @@ -5279,25 +6577,25 @@ static CYTHON_UNUSED int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_ */ __pyx_v_info->suboffsets = NULL; - /* "numpy.pxd":226 + /* "numpy.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(((PyArrayObject *)__pyx_v_self)); + __pyx_v_info->itemsize = PyArray_ITEMSIZE(__pyx_v_self); - /* "numpy.pxd":227 + /* "numpy.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(((PyArrayObject *)__pyx_v_self))); + __pyx_v_info->readonly = (!(PyArray_ISWRITEABLE(__pyx_v_self) != 0)); - /* "numpy.pxd":230 + /* "numpy.pxd":239 * * cdef int t * cdef char* f = NULL # <<<<<<<<<<<<<< @@ -5306,17 +6604,19 @@ static CYTHON_UNUSED int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_ */ __pyx_v_f = NULL; - /* "numpy.pxd":231 + /* "numpy.pxd":240 * cdef int t * cdef char* f = NULL * cdef dtype descr = self.descr # <<<<<<<<<<<<<< * cdef list stack * cdef int offset */ - __Pyx_INCREF(((PyObject *)((PyArrayObject *)__pyx_v_self)->descr)); - __pyx_v_descr = ((PyArrayObject *)__pyx_v_self)->descr; + __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; - /* "numpy.pxd":235 + /* "numpy.pxd":244 * cdef int offset * * cdef bint hasfields = PyDataType_HASFIELDS(descr) # <<<<<<<<<<<<<< @@ -5325,23 +6625,23 @@ static CYTHON_UNUSED int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_ */ __pyx_v_hasfields = PyDataType_HASFIELDS(__pyx_v_descr); - /* "numpy.pxd":237 + /* "numpy.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); + __pyx_t_2 = ((!(__pyx_v_hasfields != 0)) != 0); if (__pyx_t_2) { - __pyx_t_3 = (!__pyx_v_copy_shape); + __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) { - /* "numpy.pxd":239 + /* "numpy.pxd":248 * if not hasfields and not copy_shape: * # do not call releasebuffer * info.obj = None # <<<<<<<<<<<<<< @@ -5353,69 +6653,70 @@ static CYTHON_UNUSED int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_ __Pyx_GOTREF(__pyx_v_info->obj); __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = Py_None; - goto __pyx_L11; + goto __pyx_L10; } /*else*/ { - /* "numpy.pxd":242 + /* "numpy.pxd":251 * else: * # need to call releasebuffer * info.obj = self # <<<<<<<<<<<<<< * * if not hasfields: */ - __Pyx_INCREF(__pyx_v_self); - __Pyx_GIVEREF(__pyx_v_self); + __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 = __pyx_v_self; + __pyx_v_info->obj = ((PyObject *)__pyx_v_self); } - __pyx_L11:; + __pyx_L10:; - /* "numpy.pxd":244 + /* "numpy.pxd":253 * info.obj = self * * if not hasfields: # <<<<<<<<<<<<<< * t = descr.type_num - * if ((descr.byteorder == '>' and little_endian) or + * if ((descr.byteorder == c'>' and little_endian) or */ - __pyx_t_1 = (!__pyx_v_hasfields); + __pyx_t_1 = ((!(__pyx_v_hasfields != 0)) != 0); if (__pyx_t_1) { - /* "numpy.pxd":245 + /* "numpy.pxd":254 * * if not hasfields: * t = descr.type_num # <<<<<<<<<<<<<< - * if ((descr.byteorder == '>' and little_endian) or - * (descr.byteorder == '<' and not little_endian)): + * if ((descr.byteorder == c'>' and little_endian) or + * (descr.byteorder == c'<' and not little_endian)): */ - __pyx_v_t = __pyx_v_descr->type_num; + __pyx_t_5 = __pyx_v_descr->type_num; + __pyx_v_t = __pyx_t_5; - /* "numpy.pxd":246 + /* "numpy.pxd":255 * if not hasfields: * t = descr.type_num - * if ((descr.byteorder == '>' and little_endian) or # <<<<<<<<<<<<<< - * (descr.byteorder == '<' and not little_endian)): + * 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 == '>'); + __pyx_t_1 = ((__pyx_v_descr->byteorder == '>') != 0); if (__pyx_t_1) { - __pyx_t_2 = __pyx_v_little_endian; + __pyx_t_2 = (__pyx_v_little_endian != 0); } else { __pyx_t_2 = __pyx_t_1; } if (!__pyx_t_2) { - /* "numpy.pxd":247 + /* "numpy.pxd":256 * t = descr.type_num - * if ((descr.byteorder == '>' and little_endian) or - * (descr.byteorder == '<' and not little_endian)): # <<<<<<<<<<<<<< + * 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 == '<'); + __pyx_t_1 = ((__pyx_v_descr->byteorder == '<') != 0); if (__pyx_t_1) { - __pyx_t_3 = (!__pyx_v_little_endian); + __pyx_t_3 = ((!(__pyx_v_little_endian != 0)) != 0); __pyx_t_7 = __pyx_t_3; } else { __pyx_t_7 = __pyx_t_1; @@ -5426,271 +6727,246 @@ static CYTHON_UNUSED int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_ } if (__pyx_t_1) { - /* "numpy.pxd":248 - * if ((descr.byteorder == '>' and little_endian) or - * (descr.byteorder == '<' and not little_endian)): + /* "numpy.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 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_17), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_17), 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); + __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - {__pyx_filename = __pyx_f[1]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L13; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L12; } - __pyx_L13:; + __pyx_L12:; + + /* "numpy.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) { - /* "numpy.pxd":249 - * (descr.byteorder == '<' and not little_endian)): + /* "numpy.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" */ - __pyx_t_1 = (__pyx_v_t == NPY_BYTE); - if (__pyx_t_1) { + case NPY_BYTE: __pyx_v_f = __pyx_k__b; - goto __pyx_L14; - } + break; - /* "numpy.pxd":250 + /* "numpy.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" */ - __pyx_t_1 = (__pyx_v_t == NPY_UBYTE); - if (__pyx_t_1) { + case NPY_UBYTE: __pyx_v_f = __pyx_k__B; - goto __pyx_L14; - } + break; - /* "numpy.pxd":251 + /* "numpy.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" */ - __pyx_t_1 = (__pyx_v_t == NPY_SHORT); - if (__pyx_t_1) { + case NPY_SHORT: __pyx_v_f = __pyx_k__h; - goto __pyx_L14; - } + break; - /* "numpy.pxd":252 + /* "numpy.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" */ - __pyx_t_1 = (__pyx_v_t == NPY_USHORT); - if (__pyx_t_1) { + case NPY_USHORT: __pyx_v_f = __pyx_k__H; - goto __pyx_L14; - } + break; - /* "numpy.pxd":253 + /* "numpy.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" */ - __pyx_t_1 = (__pyx_v_t == NPY_INT); - if (__pyx_t_1) { + case NPY_INT: __pyx_v_f = __pyx_k__i; - goto __pyx_L14; - } + break; - /* "numpy.pxd":254 + /* "numpy.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" */ - __pyx_t_1 = (__pyx_v_t == NPY_UINT); - if (__pyx_t_1) { + case NPY_UINT: __pyx_v_f = __pyx_k__I; - goto __pyx_L14; - } + break; - /* "numpy.pxd":255 + /* "numpy.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" */ - __pyx_t_1 = (__pyx_v_t == NPY_LONG); - if (__pyx_t_1) { + case NPY_LONG: __pyx_v_f = __pyx_k__l; - goto __pyx_L14; - } + break; - /* "numpy.pxd":256 + /* "numpy.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" */ - __pyx_t_1 = (__pyx_v_t == NPY_ULONG); - if (__pyx_t_1) { + case NPY_ULONG: __pyx_v_f = __pyx_k__L; - goto __pyx_L14; - } + break; - /* "numpy.pxd":257 + /* "numpy.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" */ - __pyx_t_1 = (__pyx_v_t == NPY_LONGLONG); - if (__pyx_t_1) { + case NPY_LONGLONG: __pyx_v_f = __pyx_k__q; - goto __pyx_L14; - } + break; - /* "numpy.pxd":258 + /* "numpy.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" */ - __pyx_t_1 = (__pyx_v_t == NPY_ULONGLONG); - if (__pyx_t_1) { + case NPY_ULONGLONG: __pyx_v_f = __pyx_k__Q; - goto __pyx_L14; - } + break; - /* "numpy.pxd":259 + /* "numpy.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" */ - __pyx_t_1 = (__pyx_v_t == NPY_FLOAT); - if (__pyx_t_1) { + case NPY_FLOAT: __pyx_v_f = __pyx_k__f; - goto __pyx_L14; - } + break; - /* "numpy.pxd":260 + /* "numpy.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" */ - __pyx_t_1 = (__pyx_v_t == NPY_DOUBLE); - if (__pyx_t_1) { + case NPY_DOUBLE: __pyx_v_f = __pyx_k__d; - goto __pyx_L14; - } + break; - /* "numpy.pxd":261 + /* "numpy.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" */ - __pyx_t_1 = (__pyx_v_t == NPY_LONGDOUBLE); - if (__pyx_t_1) { + case NPY_LONGDOUBLE: __pyx_v_f = __pyx_k__g; - goto __pyx_L14; - } + break; - /* "numpy.pxd":262 + /* "numpy.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" */ - __pyx_t_1 = (__pyx_v_t == NPY_CFLOAT); - if (__pyx_t_1) { + case NPY_CFLOAT: __pyx_v_f = __pyx_k__Zf; - goto __pyx_L14; - } + break; - /* "numpy.pxd":263 + /* "numpy.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" */ - __pyx_t_1 = (__pyx_v_t == NPY_CDOUBLE); - if (__pyx_t_1) { + case NPY_CDOUBLE: __pyx_v_f = __pyx_k__Zd; - goto __pyx_L14; - } + break; - /* "numpy.pxd":264 + /* "numpy.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: */ - __pyx_t_1 = (__pyx_v_t == NPY_CLONGDOUBLE); - if (__pyx_t_1) { + case NPY_CLONGDOUBLE: __pyx_v_f = __pyx_k__Zg; - goto __pyx_L14; - } + break; - /* "numpy.pxd":265 + /* "numpy.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) */ - __pyx_t_1 = (__pyx_v_t == NPY_OBJECT); - if (__pyx_t_1) { + case NPY_OBJECT: __pyx_v_f = __pyx_k__O; - goto __pyx_L14; - } - /*else*/ { + break; + default: - /* "numpy.pxd":267 + /* "numpy.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 = PyInt_FromLong(__pyx_v_t); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyInt_FromLong(__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 = PyNumber_Remainder(((PyObject *)__pyx_kp_u_18), __pyx_t_4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyNumber_Remainder(((PyObject *)__pyx_kp_u_18), __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(((PyObject *)__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 = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_4)); + __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, ((PyObject *)__pyx_t_8)); __Pyx_GIVEREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0; - __pyx_t_8 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__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(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; - __Pyx_Raise(__pyx_t_8, 0, 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 = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + break; } - __pyx_L14:; - /* "numpy.pxd":268 + /* "numpy.pxd":277 * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) * info.format = f # <<<<<<<<<<<<<< @@ -5699,7 +6975,7 @@ static CYTHON_UNUSED int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_ */ __pyx_v_info->format = __pyx_v_f; - /* "numpy.pxd":269 + /* "numpy.pxd":278 * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) * info.format = f * return # <<<<<<<<<<<<<< @@ -5708,70 +6984,72 @@ static CYTHON_UNUSED int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_ */ __pyx_r = 0; goto __pyx_L0; - goto __pyx_L12; + goto __pyx_L11; } /*else*/ { - /* "numpy.pxd":271 + /* "numpy.pxd":280 * return * else: * info.format = stdlib.malloc(_buffer_format_string_len) # <<<<<<<<<<<<<< - * info.format[0] = '^' # Native data types, manual alignment + * info.format[0] = c'^' # Native data types, manual alignment * offset = 0 */ __pyx_v_info->format = ((char *)malloc(255)); - /* "numpy.pxd":272 + /* "numpy.pxd":281 * else: * info.format = stdlib.malloc(_buffer_format_string_len) - * info.format[0] = '^' # Native data types, manual alignment # <<<<<<<<<<<<<< + * info.format[0] = c'^' # Native data types, manual alignment # <<<<<<<<<<<<<< * offset = 0 * f = _util_dtypestring(descr, info.format + 1, */ (__pyx_v_info->format[0]) = '^'; - /* "numpy.pxd":273 + /* "numpy.pxd":282 * info.format = stdlib.malloc(_buffer_format_string_len) - * info.format[0] = '^' # Native data types, manual alignment + * 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; - /* "numpy.pxd":276 + /* "numpy.pxd":285 * f = _util_dtypestring(descr, info.format + 1, * info.format + _buffer_format_string_len, * &offset) # <<<<<<<<<<<<<< - * f[0] = 0 # Terminate format string + * f[0] = c'\0' # Terminate format string * */ - __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 = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __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; - /* "numpy.pxd":277 + /* "numpy.pxd":286 * info.format + _buffer_format_string_len, * &offset) - * f[0] = 0 # Terminate format string # <<<<<<<<<<<<<< + * f[0] = c'\0' # Terminate format string # <<<<<<<<<<<<<< * * def __releasebuffer__(ndarray self, Py_buffer* info): */ - (__pyx_v_f[0]) = 0; + (__pyx_v_f[0]) = '\x00'; } - __pyx_L12:; + __pyx_L11:; __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_AddTraceback("numpy.ndarray.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; - __Pyx_GOTREF(__pyx_v_info->obj); - __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = NULL; + 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->obj == Py_None) { + if (__pyx_v_info != NULL && __pyx_v_info->obj == Py_None) { __Pyx_GOTREF(Py_None); __Pyx_DECREF(Py_None); __pyx_v_info->obj = NULL; } @@ -5781,30 +7059,39 @@ static CYTHON_UNUSED int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_ return __pyx_r; } -/* "numpy.pxd":279 - * f[0] = 0 # Terminate format string +/* 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)); + __Pyx_RefNannyFinishContext(); +} + +/* "numpy.pxd":288 + * f[0] = c'\0' # Terminate format string * * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<< * if PyArray_HASFIELDS(self): * stdlib.free(info.format) */ -static CYTHON_UNUSED void __pyx_pf_5numpy_7ndarray_1__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info); /*proto*/ -static CYTHON_UNUSED void __pyx_pf_5numpy_7ndarray_1__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info) { +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__"); + __Pyx_RefNannySetupContext("__releasebuffer__", 0); - /* "numpy.pxd":280 + /* "numpy.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(((PyArrayObject *)__pyx_v_self)); + __pyx_t_1 = (PyArray_HASFIELDS(__pyx_v_self) != 0); if (__pyx_t_1) { - /* "numpy.pxd":281 + /* "numpy.pxd":290 * def __releasebuffer__(ndarray self, Py_buffer* info): * if PyArray_HASFIELDS(self): * stdlib.free(info.format) # <<<<<<<<<<<<<< @@ -5812,21 +7099,21 @@ static CYTHON_UNUSED void __pyx_pf_5numpy_7ndarray_1__releasebuffer__(PyObject * * stdlib.free(info.strides) */ free(__pyx_v_info->format); - goto __pyx_L5; + goto __pyx_L3; } - __pyx_L5:; + __pyx_L3:; - /* "numpy.pxd":282 + /* "numpy.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))); + __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); if (__pyx_t_1) { - /* "numpy.pxd":283 + /* "numpy.pxd":292 * stdlib.free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): * stdlib.free(info.strides) # <<<<<<<<<<<<<< @@ -5834,14 +7121,14 @@ static CYTHON_UNUSED void __pyx_pf_5numpy_7ndarray_1__releasebuffer__(PyObject * * */ free(__pyx_v_info->strides); - goto __pyx_L6; + goto __pyx_L4; } - __pyx_L6:; + __pyx_L4:; __Pyx_RefNannyFinishContext(); } -/* "numpy.pxd":756 +/* "numpy.pxd":768 * ctypedef npy_cdouble complex_t * * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< @@ -5851,10 +7138,14 @@ static CYTHON_UNUSED void __pyx_pf_5numpy_7ndarray_1__releasebuffer__(PyObject * static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__pyx_v_a) { PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("PyArray_MultiIterNew1"); + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0); - /* "numpy.pxd":757 + /* "numpy.pxd":769 * * cdef inline object PyArray_MultiIterNew1(a): * return PyArray_MultiIterNew(1, a) # <<<<<<<<<<<<<< @@ -5862,7 +7153,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__ * 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 = 757; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __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; @@ -5872,7 +7163,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("numpy.PyArray_MultiIterNew1"); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew1", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -5880,7 +7171,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__ return __pyx_r; } -/* "numpy.pxd":759 +/* "numpy.pxd":771 * return PyArray_MultiIterNew(1, a) * * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< @@ -5890,10 +7181,14 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__ 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; - __Pyx_RefNannySetupContext("PyArray_MultiIterNew2"); + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0); - /* "numpy.pxd":760 + /* "numpy.pxd":772 * * cdef inline object PyArray_MultiIterNew2(a, b): * return PyArray_MultiIterNew(2, a, b) # <<<<<<<<<<<<<< @@ -5901,7 +7196,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__ * 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 = 760; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __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; @@ -5911,7 +7206,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("numpy.PyArray_MultiIterNew2"); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew2", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -5919,7 +7214,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__ return __pyx_r; } -/* "numpy.pxd":762 +/* "numpy.pxd":774 * return PyArray_MultiIterNew(2, a, b) * * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< @@ -5929,10 +7224,14 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__ 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; - __Pyx_RefNannySetupContext("PyArray_MultiIterNew3"); + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0); - /* "numpy.pxd":763 + /* "numpy.pxd":775 * * cdef inline object PyArray_MultiIterNew3(a, b, c): * return PyArray_MultiIterNew(3, a, b, c) # <<<<<<<<<<<<<< @@ -5940,7 +7239,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__ * 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 = 763; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __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; @@ -5950,7 +7249,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("numpy.PyArray_MultiIterNew3"); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew3", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -5958,7 +7257,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__ return __pyx_r; } -/* "numpy.pxd":765 +/* "numpy.pxd":777 * return PyArray_MultiIterNew(3, a, b, c) * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< @@ -5968,10 +7267,14 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__ 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; - __Pyx_RefNannySetupContext("PyArray_MultiIterNew4"); + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0); - /* "numpy.pxd":766 + /* "numpy.pxd":778 * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): * return PyArray_MultiIterNew(4, a, b, c, d) # <<<<<<<<<<<<<< @@ -5979,7 +7282,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__ * 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 = 766; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __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; @@ -5989,7 +7292,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("numpy.PyArray_MultiIterNew4"); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew4", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -5997,7 +7300,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__ return __pyx_r; } -/* "numpy.pxd":768 +/* "numpy.pxd":780 * return PyArray_MultiIterNew(4, a, b, c, d) * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< @@ -6007,10 +7310,14 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__ 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; - __Pyx_RefNannySetupContext("PyArray_MultiIterNew5"); + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0); - /* "numpy.pxd":769 + /* "numpy.pxd":781 * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): * return PyArray_MultiIterNew(5, a, b, c, d, e) # <<<<<<<<<<<<<< @@ -6018,7 +7325,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__ * 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 = 769; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __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; @@ -6028,7 +7335,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("numpy.PyArray_MultiIterNew5"); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew5", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -6036,7 +7343,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__ return __pyx_r; } -/* "numpy.pxd":771 +/* "numpy.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: # <<<<<<<<<<<<<< @@ -6045,33 +7352,33 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__ */ 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; + PyArray_Descr *__pyx_v_child = 0; int __pyx_v_endian_detector; int __pyx_v_little_endian; - PyObject *__pyx_v_fields; - PyObject *__pyx_v_childname; - PyObject *__pyx_v_new_offset; - PyObject *__pyx_v_t; + PyObject *__pyx_v_fields = 0; + PyObject *__pyx_v_childname = NULL; + PyObject *__pyx_v_new_offset = NULL; + PyObject *__pyx_v_t = NULL; char *__pyx_r; - Py_ssize_t __pyx_t_1; - PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + Py_ssize_t __pyx_t_2; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; - int __pyx_t_6; + PyObject *(*__pyx_t_6)(PyObject *); int __pyx_t_7; int __pyx_t_8; int __pyx_t_9; - long __pyx_t_10; - char *__pyx_t_11; - __Pyx_RefNannySetupContext("_util_dtypestring"); - __pyx_v_child = ((PyArray_Descr *)Py_None); __Pyx_INCREF(Py_None); - __pyx_v_fields = ((PyObject*)Py_None); __Pyx_INCREF(Py_None); - __pyx_v_childname = Py_None; __Pyx_INCREF(Py_None); - __pyx_v_new_offset = Py_None; __Pyx_INCREF(Py_None); - __pyx_v_t = Py_None; __Pyx_INCREF(Py_None); - - /* "numpy.pxd":778 + int __pyx_t_10; + long __pyx_t_11; + char *__pyx_t_12; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("_util_dtypestring", 0); + + /* "numpy.pxd":790 * cdef int delta_offset * cdef tuple i * cdef int endian_detector = 1 # <<<<<<<<<<<<<< @@ -6080,7 +7387,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ __pyx_v_endian_detector = 1; - /* "numpy.pxd":779 + /* "numpy.pxd":791 * cdef tuple i * cdef int endian_detector = 1 * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< @@ -6089,154 +7396,196 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); - /* "numpy.pxd":782 + /* "numpy.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 = 782; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(((PyObject *)__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 = 0; __pyx_t_2 = ((PyObject *)__pyx_v_descr->names); __Pyx_INCREF(__pyx_t_2); + __pyx_t_1 = ((PyObject *)__pyx_v_descr->names); __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; for (;;) { - if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_2)) break; - __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_1); __Pyx_INCREF(__pyx_t_3); __pyx_t_1++; - __Pyx_DECREF(__pyx_v_childname); + 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(__pyx_v_childname); __pyx_v_childname = __pyx_t_3; __pyx_t_3 = 0; - /* "numpy.pxd":783 + /* "numpy.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 (!__pyx_t_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 783; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_GetItem(__pyx_v_descr->fields, __pyx_v_childname); if (!__pyx_t_3) {__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 tuple, got %.200s", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 783; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(((PyObject *)__pyx_v_fields)); + if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected tuple, got %.200s", 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(((PyObject *)__pyx_v_fields)); __pyx_v_fields = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; - /* "numpy.pxd":784 + /* "numpy.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(((PyObject *)__pyx_v_fields) != Py_None) && likely(PyTuple_GET_SIZE(((PyObject *)__pyx_v_fields)) == 2)) { - PyObject* tuple = ((PyObject *)__pyx_v_fields); - __pyx_t_3 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_3); - if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_dtype))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 784; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_4 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_4); - __Pyx_DECREF(((PyObject *)__pyx_v_child)); - __pyx_v_child = ((PyArray_Descr *)__pyx_t_3); - __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_v_new_offset); - __pyx_v_new_offset = __pyx_t_4; - __pyx_t_4 = 0; - } else { - __Pyx_UnpackTupleError(((PyObject *)__pyx_v_fields), 2); - {__pyx_filename = __pyx_f[1]; __pyx_lineno = 784; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } + if (likely(PyTuple_CheckExact(((PyObject *)__pyx_v_fields)))) { + PyObject* sequence = ((PyObject *)__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 if (1) { + __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else + { + Py_ssize_t index = -1; + __pyx_t_5 = PyObject_GetIter(((PyObject *)__pyx_v_fields)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_6 = Py_TYPE(__pyx_t_5)->tp_iternext; + index = 0; __pyx_t_3 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L5_unpacking_failed; + __Pyx_GOTREF(__pyx_t_3); + index = 1; __pyx_t_4 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_4)) goto __pyx_L5_unpacking_failed; + __Pyx_GOTREF(__pyx_t_4); + if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 2) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = NULL; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + goto __pyx_L6_unpacking_done; + __pyx_L5_unpacking_failed:; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_6 = NULL; + if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_L6_unpacking_done:; + } + 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(((PyObject *)__pyx_v_child)); + __pyx_v_child = ((PyArray_Descr *)__pyx_t_3); + __pyx_t_3 = 0; + __Pyx_XDECREF(__pyx_v_new_offset); + __pyx_v_new_offset = __pyx_t_4; + __pyx_t_4 = 0; - /* "numpy.pxd":786 + /* "numpy.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 = PyInt_FromLong((__pyx_v_end - __pyx_v_f)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 786; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyInt_FromLong((__pyx_v_end - __pyx_v_f)); 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 = PyInt_FromLong((__pyx_v_offset[0])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 786; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyInt_FromLong((__pyx_v_offset[0])); 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_t_5 = PyNumber_Subtract(__pyx_v_new_offset, __pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 786; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyNumber_Subtract(__pyx_v_new_offset, __pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyNumber_Subtract(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 786; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyNumber_Subtract(__pyx_t_4, __pyx_t_5); 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_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = PyObject_RichCompare(__pyx_t_3, __pyx_int_15, Py_LT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 786; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); + __pyx_t_5 = PyObject_RichCompare(__pyx_t_3, __pyx_int_15, Py_LT); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__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_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 786; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (__pyx_t_6) { + if (__pyx_t_7) { - /* "numpy.pxd":787 + /* "numpy.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 == '>' and little_endian) or + * if ((child.byteorder == c'>' and little_endian) or */ - __pyx_t_5 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_20), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 787; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_20), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - __Pyx_Raise(__pyx_t_5, 0, 0); + __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - {__pyx_filename = __pyx_f[1]; __pyx_lineno = 787; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L5; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L7; } - __pyx_L5:; + __pyx_L7:; - /* "numpy.pxd":789 + /* "numpy.pxd":801 * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * - * if ((child.byteorder == '>' and little_endian) or # <<<<<<<<<<<<<< - * (child.byteorder == '<' and not little_endian)): + * 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 == '>'); - if (__pyx_t_6) { - __pyx_t_7 = __pyx_v_little_endian; + __pyx_t_7 = ((__pyx_v_child->byteorder == '>') != 0); + if (__pyx_t_7) { + __pyx_t_8 = (__pyx_v_little_endian != 0); } else { - __pyx_t_7 = __pyx_t_6; + __pyx_t_8 = __pyx_t_7; } - if (!__pyx_t_7) { + if (!__pyx_t_8) { - /* "numpy.pxd":790 + /* "numpy.pxd":802 * - * if ((child.byteorder == '>' and little_endian) or - * (child.byteorder == '<' and not little_endian)): # <<<<<<<<<<<<<< + * 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 == '<'); - if (__pyx_t_6) { - __pyx_t_8 = (!__pyx_v_little_endian); - __pyx_t_9 = __pyx_t_8; + __pyx_t_7 = ((__pyx_v_child->byteorder == '<') != 0); + if (__pyx_t_7) { + __pyx_t_9 = ((!(__pyx_v_little_endian != 0)) != 0); + __pyx_t_10 = __pyx_t_9; } else { - __pyx_t_9 = __pyx_t_6; + __pyx_t_10 = __pyx_t_7; } - __pyx_t_6 = __pyx_t_9; + __pyx_t_7 = __pyx_t_10; } else { - __pyx_t_6 = __pyx_t_7; + __pyx_t_7 = __pyx_t_8; } - if (__pyx_t_6) { + if (__pyx_t_7) { - /* "numpy.pxd":791 - * if ((child.byteorder == '>' and little_endian) or - * (child.byteorder == '<' and not little_endian)): + /* "numpy.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_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_21), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 791; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_21), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - __Pyx_Raise(__pyx_t_5, 0, 0); + __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - {__pyx_filename = __pyx_f[1]; __pyx_lineno = 791; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L6; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L8; } - __pyx_L6:; + __pyx_L8:; - /* "numpy.pxd":801 + /* "numpy.pxd":813 * * # Output padding bytes * while offset[0] < new_offset: # <<<<<<<<<<<<<< @@ -6244,16 +7593,15 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx * f += 1 */ while (1) { - __pyx_t_5 = PyInt_FromLong((__pyx_v_offset[0])); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 801; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyInt_FromLong((__pyx_v_offset[0])); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - __pyx_t_3 = PyObject_RichCompare(__pyx_t_5, __pyx_v_new_offset, Py_LT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 801; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); + __pyx_t_3 = PyObject_RichCompare(__pyx_t_5, __pyx_v_new_offset, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 801; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (!__pyx_t_6) break; + if (!__pyx_t_7) break; - /* "numpy.pxd":802 + /* "numpy.pxd":814 * # Output padding bytes * while offset[0] < new_offset: * f[0] = 120 # "x"; pad byte # <<<<<<<<<<<<<< @@ -6262,7 +7610,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ (__pyx_v_f[0]) = 120; - /* "numpy.pxd":803 + /* "numpy.pxd":815 * while offset[0] < new_offset: * f[0] = 120 # "x"; pad byte * f += 1 # <<<<<<<<<<<<<< @@ -6271,430 +7619,413 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ __pyx_v_f = (__pyx_v_f + 1); - /* "numpy.pxd":804 + /* "numpy.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); + __pyx_t_11 = 0; + (__pyx_v_offset[__pyx_t_11]) = ((__pyx_v_offset[__pyx_t_11]) + 1); } - /* "numpy.pxd":806 + /* "numpy.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); + __pyx_t_11 = 0; + (__pyx_v_offset[__pyx_t_11]) = ((__pyx_v_offset[__pyx_t_11]) + __pyx_v_child->elsize); - /* "numpy.pxd":808 + /* "numpy.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)); - if (__pyx_t_6) { + __pyx_t_7 = ((!(PyDataType_HASFIELDS(__pyx_v_child) != 0)) != 0); + if (__pyx_t_7) { - /* "numpy.pxd":809 + /* "numpy.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_3 = PyInt_FromLong(__pyx_v_child->type_num); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 809; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyInt_FromLong(__pyx_v_child->type_num); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_v_t); + __Pyx_XDECREF(__pyx_v_t); __pyx_v_t = __pyx_t_3; __pyx_t_3 = 0; - /* "numpy.pxd":810 + /* "numpy.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); - if (__pyx_t_6) { + __pyx_t_7 = (((__pyx_v_end - __pyx_v_f) < 5) != 0); + if (__pyx_t_7) { - /* "numpy.pxd":811 + /* "numpy.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_3 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_23), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 811; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_23), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __Pyx_Raise(__pyx_t_3, 0, 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 = 811; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L10; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L12; } - __pyx_L10:; + __pyx_L12:; - /* "numpy.pxd":814 + /* "numpy.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_3 = PyInt_FromLong(NPY_BYTE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 814; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyInt_FromLong(NPY_BYTE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 814; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 814; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (__pyx_t_6) { + if (__pyx_t_7) { (__pyx_v_f[0]) = 98; - goto __pyx_L11; + goto __pyx_L13; } - /* "numpy.pxd":815 + /* "numpy.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_5 = PyInt_FromLong(NPY_UBYTE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 815; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyInt_FromLong(NPY_UBYTE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 815; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 815; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_6) { + if (__pyx_t_7) { (__pyx_v_f[0]) = 66; - goto __pyx_L11; + goto __pyx_L13; } - /* "numpy.pxd":816 + /* "numpy.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_3 = PyInt_FromLong(NPY_SHORT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyInt_FromLong(NPY_SHORT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (__pyx_t_6) { + if (__pyx_t_7) { (__pyx_v_f[0]) = 104; - goto __pyx_L11; + goto __pyx_L13; } - /* "numpy.pxd":817 + /* "numpy.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_5 = PyInt_FromLong(NPY_USHORT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 817; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyInt_FromLong(NPY_USHORT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 817; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 817; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_6) { + if (__pyx_t_7) { (__pyx_v_f[0]) = 72; - goto __pyx_L11; + goto __pyx_L13; } - /* "numpy.pxd":818 + /* "numpy.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_3 = PyInt_FromLong(NPY_INT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyInt_FromLong(NPY_INT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (__pyx_t_6) { + if (__pyx_t_7) { (__pyx_v_f[0]) = 105; - goto __pyx_L11; + goto __pyx_L13; } - /* "numpy.pxd":819 + /* "numpy.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_5 = PyInt_FromLong(NPY_UINT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyInt_FromLong(NPY_UINT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_6) { + if (__pyx_t_7) { (__pyx_v_f[0]) = 73; - goto __pyx_L11; + goto __pyx_L13; } - /* "numpy.pxd":820 + /* "numpy.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_3 = PyInt_FromLong(NPY_LONG); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 820; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyInt_FromLong(NPY_LONG); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 820; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 820; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (__pyx_t_6) { + if (__pyx_t_7) { (__pyx_v_f[0]) = 108; - goto __pyx_L11; + goto __pyx_L13; } - /* "numpy.pxd":821 + /* "numpy.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_5 = PyInt_FromLong(NPY_ULONG); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyInt_FromLong(NPY_ULONG); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_6) { + if (__pyx_t_7) { (__pyx_v_f[0]) = 76; - goto __pyx_L11; + goto __pyx_L13; } - /* "numpy.pxd":822 + /* "numpy.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_3 = PyInt_FromLong(NPY_LONGLONG); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyInt_FromLong(NPY_LONGLONG); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (__pyx_t_6) { + if (__pyx_t_7) { (__pyx_v_f[0]) = 113; - goto __pyx_L11; + goto __pyx_L13; } - /* "numpy.pxd":823 + /* "numpy.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_5 = PyInt_FromLong(NPY_ULONGLONG); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyInt_FromLong(NPY_ULONGLONG); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_6) { + if (__pyx_t_7) { (__pyx_v_f[0]) = 81; - goto __pyx_L11; + goto __pyx_L13; } - /* "numpy.pxd":824 + /* "numpy.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_3 = PyInt_FromLong(NPY_FLOAT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyInt_FromLong(NPY_FLOAT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (__pyx_t_6) { + if (__pyx_t_7) { (__pyx_v_f[0]) = 102; - goto __pyx_L11; + goto __pyx_L13; } - /* "numpy.pxd":825 + /* "numpy.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_5 = PyInt_FromLong(NPY_DOUBLE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyInt_FromLong(NPY_DOUBLE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_6) { + if (__pyx_t_7) { (__pyx_v_f[0]) = 100; - goto __pyx_L11; + goto __pyx_L13; } - /* "numpy.pxd":826 + /* "numpy.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_3 = PyInt_FromLong(NPY_LONGDOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyInt_FromLong(NPY_LONGDOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (__pyx_t_6) { + if (__pyx_t_7) { (__pyx_v_f[0]) = 103; - goto __pyx_L11; + goto __pyx_L13; } - /* "numpy.pxd":827 + /* "numpy.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_5 = PyInt_FromLong(NPY_CFLOAT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyInt_FromLong(NPY_CFLOAT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); 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_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_6) { + if (__pyx_t_7) { (__pyx_v_f[0]) = 90; (__pyx_v_f[1]) = 102; __pyx_v_f = (__pyx_v_f + 1); - goto __pyx_L11; + goto __pyx_L13; } - /* "numpy.pxd":828 + /* "numpy.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_3 = PyInt_FromLong(NPY_CDOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyInt_FromLong(NPY_CDOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (__pyx_t_6) { + if (__pyx_t_7) { (__pyx_v_f[0]) = 90; (__pyx_v_f[1]) = 100; __pyx_v_f = (__pyx_v_f + 1); - goto __pyx_L11; + goto __pyx_L13; } - /* "numpy.pxd":829 + /* "numpy.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_5 = PyInt_FromLong(NPY_CLONGDOUBLE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyInt_FromLong(NPY_CLONGDOUBLE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); 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_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_6) { + if (__pyx_t_7) { (__pyx_v_f[0]) = 90; (__pyx_v_f[1]) = 103; __pyx_v_f = (__pyx_v_f + 1); - goto __pyx_L11; + goto __pyx_L13; } - /* "numpy.pxd":830 + /* "numpy.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_3 = PyInt_FromLong(NPY_OBJECT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyInt_FromLong(NPY_OBJECT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (__pyx_t_6) { + if (__pyx_t_7) { (__pyx_v_f[0]) = 79; - goto __pyx_L11; + goto __pyx_L13; } /*else*/ { - /* "numpy.pxd":832 + /* "numpy.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_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_u_18), __pyx_v_t); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_u_18), __pyx_v_t); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_5)); - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_3)); + __pyx_t_3 = PyTuple_New(1); 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); PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_5)); __Pyx_GIVEREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; - __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; - __Pyx_Raise(__pyx_t_5, 0, 0); + __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_L11:; + __pyx_L13:; - /* "numpy.pxd":833 + /* "numpy.pxd":845 * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) * f += 1 # <<<<<<<<<<<<<< @@ -6702,25 +8033,25 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx * # Cython ignores struct boundary information ("T{...}"), */ __pyx_v_f = (__pyx_v_f + 1); - goto __pyx_L9; + goto __pyx_L11; } /*else*/ { - /* "numpy.pxd":837 + /* "numpy.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 = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_f = __pyx_t_11; + __pyx_t_12 = __pyx_f_5numpy__util_dtypestring(__pyx_v_child, __pyx_v_f, __pyx_v_end, __pyx_v_offset); if (unlikely(__pyx_t_12 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_f = __pyx_t_12; } - __pyx_L9:; + __pyx_L11:; } - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "numpy.pxd":838 + /* "numpy.pxd":850 * # so don't output it * f = _util_dtypestring(child, f, end, offset) * return f # <<<<<<<<<<<<<< @@ -6733,23 +8064,23 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); - __Pyx_AddTraceback("numpy._util_dtypestring"); + __Pyx_AddTraceback("numpy._util_dtypestring", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; - __Pyx_DECREF((PyObject *)__pyx_v_child); - __Pyx_DECREF(__pyx_v_fields); - __Pyx_DECREF(__pyx_v_childname); - __Pyx_DECREF(__pyx_v_new_offset); - __Pyx_DECREF(__pyx_v_t); + __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; } -/* "numpy.pxd":953 +/* "numpy.pxd":965 * * * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< @@ -6759,10 +8090,12 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx 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; - __Pyx_RefNannySetupContext("set_array_base"); + int __pyx_t_2; + __Pyx_RefNannySetupContext("set_array_base", 0); - /* "numpy.pxd":955 + /* "numpy.pxd":967 * cdef inline void set_array_base(ndarray arr, object base): * cdef PyObject* baseptr * if base is None: # <<<<<<<<<<<<<< @@ -6770,9 +8103,10 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a * else: */ __pyx_t_1 = (__pyx_v_base == Py_None); - if (__pyx_t_1) { + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { - /* "numpy.pxd":956 + /* "numpy.pxd":968 * cdef PyObject* baseptr * if base is None: * baseptr = NULL # <<<<<<<<<<<<<< @@ -6784,7 +8118,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a } /*else*/ { - /* "numpy.pxd":958 + /* "numpy.pxd":970 * baseptr = NULL * else: * Py_INCREF(base) # important to do this before decref below! # <<<<<<<<<<<<<< @@ -6793,7 +8127,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a */ Py_INCREF(__pyx_v_base); - /* "numpy.pxd":959 + /* "numpy.pxd":971 * else: * Py_INCREF(base) # important to do this before decref below! * baseptr = base # <<<<<<<<<<<<<< @@ -6804,7 +8138,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a } __pyx_L3:; - /* "numpy.pxd":960 + /* "numpy.pxd":972 * Py_INCREF(base) # important to do this before decref below! * baseptr = base * Py_XDECREF(arr.base) # <<<<<<<<<<<<<< @@ -6813,7 +8147,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a */ Py_XDECREF(__pyx_v_arr->base); - /* "numpy.pxd":961 + /* "numpy.pxd":973 * baseptr = base * Py_XDECREF(arr.base) * arr.base = baseptr # <<<<<<<<<<<<<< @@ -6825,7 +8159,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a __Pyx_RefNannyFinishContext(); } -/* "numpy.pxd":963 +/* "numpy.pxd":975 * arr.base = baseptr * * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< @@ -6835,20 +8169,21 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a 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"); + __Pyx_RefNannySetupContext("get_array_base", 0); - /* "numpy.pxd":964 + /* "numpy.pxd":976 * * cdef inline object get_array_base(ndarray arr): * if arr.base is NULL: # <<<<<<<<<<<<<< * return None * else: */ - __pyx_t_1 = (__pyx_v_arr->base == NULL); + __pyx_t_1 = ((__pyx_v_arr->base == NULL) != 0); if (__pyx_t_1) { - /* "numpy.pxd":965 + /* "numpy.pxd":977 * cdef inline object get_array_base(ndarray arr): * if arr.base is NULL: * return None # <<<<<<<<<<<<<< @@ -6863,7 +8198,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py } /*else*/ { - /* "numpy.pxd":967 + /* "numpy.pxd":979 * return None * else: * return arr.base # <<<<<<<<<<<<<< @@ -6882,9 +8217,10 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py return __pyx_r; } -static PyObject *__pyx_tp_new_8freenect_CtxPtr(PyTypeObject *t, PyObject *a, PyObject *k) { - PyObject *o = (*t->tp_alloc)(t, 0); - if (!o) return 0; +static PyObject *__pyx_tp_new_8freenect_CtxPtr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + PyObject *o; + o = (*t->tp_alloc)(t, 0); + if (unlikely(!o)) return 0; return o; } @@ -6896,110 +8232,88 @@ static PyMethodDef __pyx_methods_8freenect_CtxPtr[] = { {0, 0, 0, 0} }; -static PyNumberMethods __pyx_tp_as_number_CtxPtr = { - 0, /*nb_add*/ - 0, /*nb_subtract*/ - 0, /*nb_multiply*/ - #if PY_MAJOR_VERSION < 3 - 0, /*nb_divide*/ - #endif - 0, /*nb_remainder*/ - 0, /*nb_divmod*/ - 0, /*nb_power*/ - 0, /*nb_negative*/ - 0, /*nb_positive*/ - 0, /*nb_absolute*/ - 0, /*nb_nonzero*/ - 0, /*nb_invert*/ - 0, /*nb_lshift*/ - 0, /*nb_rshift*/ - 0, /*nb_and*/ - 0, /*nb_xor*/ - 0, /*nb_or*/ - #if PY_MAJOR_VERSION < 3 - 0, /*nb_coerce*/ - #endif - 0, /*nb_int*/ +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, /*nb_long*/ + 0, /*tp_compare*/ #else 0, /*reserved*/ #endif - 0, /*nb_float*/ - #if PY_MAJOR_VERSION < 3 - 0, /*nb_oct*/ - #endif - #if PY_MAJOR_VERSION < 3 - 0, /*nb_hex*/ - #endif - 0, /*nb_inplace_add*/ - 0, /*nb_inplace_subtract*/ - 0, /*nb_inplace_multiply*/ - #if PY_MAJOR_VERSION < 3 - 0, /*nb_inplace_divide*/ - #endif - 0, /*nb_inplace_remainder*/ - 0, /*nb_inplace_power*/ - 0, /*nb_inplace_lshift*/ - 0, /*nb_inplace_rshift*/ - 0, /*nb_inplace_and*/ - 0, /*nb_inplace_xor*/ - 0, /*nb_inplace_or*/ - 0, /*nb_floor_divide*/ - 0, /*nb_true_divide*/ - 0, /*nb_inplace_floor_divide*/ - 0, /*nb_inplace_true_divide*/ - #if PY_VERSION_HEX >= 0x02050000 - 0, /*nb_index*/ + __pyx_pw_8freenect_6CtxPtr_1__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*/ + 0, /*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 }; -static PySequenceMethods __pyx_tp_as_sequence_CtxPtr = { - 0, /*sq_length*/ - 0, /*sq_concat*/ - 0, /*sq_repeat*/ - 0, /*sq_item*/ - 0, /*sq_slice*/ - 0, /*sq_ass_item*/ - 0, /*sq_ass_slice*/ - 0, /*sq_contains*/ - 0, /*sq_inplace_concat*/ - 0, /*sq_inplace_repeat*/ -}; +static PyObject *__pyx_tp_new_8freenect_StatePtr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + PyObject *o; + o = (*t->tp_alloc)(t, 0); + if (unlikely(!o)) return 0; + return o; +} -static PyMappingMethods __pyx_tp_as_mapping_CtxPtr = { - 0, /*mp_length*/ - 0, /*mp_subscript*/ - 0, /*mp_ass_subscript*/ -}; +static void __pyx_tp_dealloc_8freenect_StatePtr(PyObject *o) { + (*Py_TYPE(o)->tp_free)(o); +} -static PyBufferProcs __pyx_tp_as_buffer_CtxPtr = { - #if PY_MAJOR_VERSION < 3 - 0, /*bf_getreadbuffer*/ - #endif - #if PY_MAJOR_VERSION < 3 - 0, /*bf_getwritebuffer*/ - #endif - #if PY_MAJOR_VERSION < 3 - 0, /*bf_getsegcount*/ - #endif - #if PY_MAJOR_VERSION < 3 - 0, /*bf_getcharbuffer*/ - #endif - #if PY_VERSION_HEX >= 0x02060000 - 0, /*bf_getbuffer*/ - #endif - #if PY_VERSION_HEX >= 0x02060000 - 0, /*bf_releasebuffer*/ - #endif +static PyMethodDef __pyx_methods_8freenect_StatePtr[] = { + {__Pyx_NAMESTR("_get_accelx"), (PyCFunction)__pyx_pw_8freenect_8StatePtr_3_get_accelx, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("_get_accely"), (PyCFunction)__pyx_pw_8freenect_8StatePtr_5_get_accely, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("_get_accelz"), (PyCFunction)__pyx_pw_8freenect_8StatePtr_7_get_accelz, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("_get_tilt_angle"), (PyCFunction)__pyx_pw_8freenect_8StatePtr_9_get_tilt_angle, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("_get_tilt_status"), (PyCFunction)__pyx_pw_8freenect_8StatePtr_11_get_tilt_status, METH_NOARGS, __Pyx_DOCSTR(0)}, + {0, 0, 0, 0} }; -static PyTypeObject __pyx_type_8freenect_CtxPtr = { +static PyTypeObject __pyx_type_8freenect_StatePtr = { PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("freenect.CtxPtr"), /*tp_name*/ - sizeof(struct __pyx_obj_8freenect_CtxPtr), /*tp_basicsize*/ + __Pyx_NAMESTR("freenect.StatePtr"), /*tp_name*/ + sizeof(struct __pyx_obj_8freenect_StatePtr), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_8freenect_CtxPtr, /*tp_dealloc*/ + __pyx_tp_dealloc_8freenect_StatePtr, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -7008,17 +8322,17 @@ static PyTypeObject __pyx_type_8freenect_CtxPtr = { #else 0, /*reserved*/ #endif - __pyx_pf_8freenect_6CtxPtr___repr__, /*tp_repr*/ - &__pyx_tp_as_number_CtxPtr, /*tp_as_number*/ - &__pyx_tp_as_sequence_CtxPtr, /*tp_as_sequence*/ - &__pyx_tp_as_mapping_CtxPtr, /*tp_as_mapping*/ + __pyx_pw_8freenect_8StatePtr_1__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*/ - &__pyx_tp_as_buffer_CtxPtr, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ + 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*/ @@ -7026,7 +8340,7 @@ static PyTypeObject __pyx_type_8freenect_CtxPtr = { 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ - __pyx_methods_8freenect_CtxPtr, /*tp_methods*/ + __pyx_methods_8freenect_StatePtr, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ @@ -7036,7 +8350,7 @@ static PyTypeObject __pyx_type_8freenect_CtxPtr = { 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_8freenect_CtxPtr, /*tp_new*/ + __pyx_tp_new_8freenect_StatePtr, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -7050,10 +8364,11 @@ static PyTypeObject __pyx_type_8freenect_CtxPtr = { #endif }; -static PyObject *__pyx_tp_new_8freenect_DevPtr(PyTypeObject *t, PyObject *a, PyObject *k) { +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 = (*t->tp_alloc)(t, 0); - if (!o) return 0; + PyObject *o; + o = (*t->tp_alloc)(t, 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; @@ -7061,7 +8376,8 @@ static PyObject *__pyx_tp_new_8freenect_DevPtr(PyTypeObject *t, PyObject *a, PyO static void __pyx_tp_dealloc_8freenect_DevPtr(PyObject *o) { struct __pyx_obj_8freenect_DevPtr *p = (struct __pyx_obj_8freenect_DevPtr *)o; - Py_XDECREF(((PyObject *)p->ctx)); + PyObject_GC_UnTrack(o); + Py_CLEAR(p->ctx); (*Py_TYPE(o)->tp_free)(o); } @@ -7087,104 +8403,6 @@ static PyMethodDef __pyx_methods_8freenect_DevPtr[] = { {0, 0, 0, 0} }; -static PyNumberMethods __pyx_tp_as_number_DevPtr = { - 0, /*nb_add*/ - 0, /*nb_subtract*/ - 0, /*nb_multiply*/ - #if PY_MAJOR_VERSION < 3 - 0, /*nb_divide*/ - #endif - 0, /*nb_remainder*/ - 0, /*nb_divmod*/ - 0, /*nb_power*/ - 0, /*nb_negative*/ - 0, /*nb_positive*/ - 0, /*nb_absolute*/ - 0, /*nb_nonzero*/ - 0, /*nb_invert*/ - 0, /*nb_lshift*/ - 0, /*nb_rshift*/ - 0, /*nb_and*/ - 0, /*nb_xor*/ - 0, /*nb_or*/ - #if PY_MAJOR_VERSION < 3 - 0, /*nb_coerce*/ - #endif - 0, /*nb_int*/ - #if PY_MAJOR_VERSION < 3 - 0, /*nb_long*/ - #else - 0, /*reserved*/ - #endif - 0, /*nb_float*/ - #if PY_MAJOR_VERSION < 3 - 0, /*nb_oct*/ - #endif - #if PY_MAJOR_VERSION < 3 - 0, /*nb_hex*/ - #endif - 0, /*nb_inplace_add*/ - 0, /*nb_inplace_subtract*/ - 0, /*nb_inplace_multiply*/ - #if PY_MAJOR_VERSION < 3 - 0, /*nb_inplace_divide*/ - #endif - 0, /*nb_inplace_remainder*/ - 0, /*nb_inplace_power*/ - 0, /*nb_inplace_lshift*/ - 0, /*nb_inplace_rshift*/ - 0, /*nb_inplace_and*/ - 0, /*nb_inplace_xor*/ - 0, /*nb_inplace_or*/ - 0, /*nb_floor_divide*/ - 0, /*nb_true_divide*/ - 0, /*nb_inplace_floor_divide*/ - 0, /*nb_inplace_true_divide*/ - #if PY_VERSION_HEX >= 0x02050000 - 0, /*nb_index*/ - #endif -}; - -static PySequenceMethods __pyx_tp_as_sequence_DevPtr = { - 0, /*sq_length*/ - 0, /*sq_concat*/ - 0, /*sq_repeat*/ - 0, /*sq_item*/ - 0, /*sq_slice*/ - 0, /*sq_ass_item*/ - 0, /*sq_ass_slice*/ - 0, /*sq_contains*/ - 0, /*sq_inplace_concat*/ - 0, /*sq_inplace_repeat*/ -}; - -static PyMappingMethods __pyx_tp_as_mapping_DevPtr = { - 0, /*mp_length*/ - 0, /*mp_subscript*/ - 0, /*mp_ass_subscript*/ -}; - -static PyBufferProcs __pyx_tp_as_buffer_DevPtr = { - #if PY_MAJOR_VERSION < 3 - 0, /*bf_getreadbuffer*/ - #endif - #if PY_MAJOR_VERSION < 3 - 0, /*bf_getwritebuffer*/ - #endif - #if PY_MAJOR_VERSION < 3 - 0, /*bf_getsegcount*/ - #endif - #if PY_MAJOR_VERSION < 3 - 0, /*bf_getcharbuffer*/ - #endif - #if PY_VERSION_HEX >= 0x02060000 - 0, /*bf_getbuffer*/ - #endif - #if PY_VERSION_HEX >= 0x02060000 - 0, /*bf_releasebuffer*/ - #endif -}; - static PyTypeObject __pyx_type_8freenect_DevPtr = { PyVarObject_HEAD_INIT(0, 0) __Pyx_NAMESTR("freenect.DevPtr"), /*tp_name*/ @@ -7199,17 +8417,17 @@ static PyTypeObject __pyx_type_8freenect_DevPtr = { #else 0, /*reserved*/ #endif - __pyx_pf_8freenect_6DevPtr___repr__, /*tp_repr*/ - &__pyx_tp_as_number_DevPtr, /*tp_as_number*/ - &__pyx_tp_as_sequence_DevPtr, /*tp_as_sequence*/ - &__pyx_tp_as_mapping_DevPtr, /*tp_as_mapping*/ + __pyx_pw_8freenect_6DevPtr_1__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*/ - &__pyx_tp_as_buffer_DevPtr, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 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*/ @@ -7241,188 +8459,19 @@ static PyTypeObject __pyx_type_8freenect_DevPtr = { #endif }; -static PyObject *__pyx_tp_new_8freenect_StatePtr(PyTypeObject *t, PyObject *a, PyObject *k) { - PyObject *o = (*t->tp_alloc)(t, 0); - if (!o) return 0; - return o; -} - -static void __pyx_tp_dealloc_8freenect_StatePtr(PyObject *o) { - (*Py_TYPE(o)->tp_free)(o); -} - -static PyMethodDef __pyx_methods_8freenect_StatePtr[] = { - {__Pyx_NAMESTR("_get_accelx"), (PyCFunction)__pyx_pf_8freenect_8StatePtr_1_get_accelx, METH_NOARGS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("_get_accely"), (PyCFunction)__pyx_pf_8freenect_8StatePtr_2_get_accely, METH_NOARGS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("_get_accelz"), (PyCFunction)__pyx_pf_8freenect_8StatePtr_3_get_accelz, METH_NOARGS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("_get_tilt_angle"), (PyCFunction)__pyx_pf_8freenect_8StatePtr_4_get_tilt_angle, METH_NOARGS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("_get_tilt_status"), (PyCFunction)__pyx_pf_8freenect_8StatePtr_5_get_tilt_status, METH_NOARGS, __Pyx_DOCSTR(0)}, - {0, 0, 0, 0} -}; - -static PyNumberMethods __pyx_tp_as_number_StatePtr = { - 0, /*nb_add*/ - 0, /*nb_subtract*/ - 0, /*nb_multiply*/ - #if PY_MAJOR_VERSION < 3 - 0, /*nb_divide*/ - #endif - 0, /*nb_remainder*/ - 0, /*nb_divmod*/ - 0, /*nb_power*/ - 0, /*nb_negative*/ - 0, /*nb_positive*/ - 0, /*nb_absolute*/ - 0, /*nb_nonzero*/ - 0, /*nb_invert*/ - 0, /*nb_lshift*/ - 0, /*nb_rshift*/ - 0, /*nb_and*/ - 0, /*nb_xor*/ - 0, /*nb_or*/ - #if PY_MAJOR_VERSION < 3 - 0, /*nb_coerce*/ - #endif - 0, /*nb_int*/ - #if PY_MAJOR_VERSION < 3 - 0, /*nb_long*/ - #else - 0, /*reserved*/ - #endif - 0, /*nb_float*/ - #if PY_MAJOR_VERSION < 3 - 0, /*nb_oct*/ - #endif - #if PY_MAJOR_VERSION < 3 - 0, /*nb_hex*/ - #endif - 0, /*nb_inplace_add*/ - 0, /*nb_inplace_subtract*/ - 0, /*nb_inplace_multiply*/ - #if PY_MAJOR_VERSION < 3 - 0, /*nb_inplace_divide*/ - #endif - 0, /*nb_inplace_remainder*/ - 0, /*nb_inplace_power*/ - 0, /*nb_inplace_lshift*/ - 0, /*nb_inplace_rshift*/ - 0, /*nb_inplace_and*/ - 0, /*nb_inplace_xor*/ - 0, /*nb_inplace_or*/ - 0, /*nb_floor_divide*/ - 0, /*nb_true_divide*/ - 0, /*nb_inplace_floor_divide*/ - 0, /*nb_inplace_true_divide*/ - #if PY_VERSION_HEX >= 0x02050000 - 0, /*nb_index*/ - #endif -}; - -static PySequenceMethods __pyx_tp_as_sequence_StatePtr = { - 0, /*sq_length*/ - 0, /*sq_concat*/ - 0, /*sq_repeat*/ - 0, /*sq_item*/ - 0, /*sq_slice*/ - 0, /*sq_ass_item*/ - 0, /*sq_ass_slice*/ - 0, /*sq_contains*/ - 0, /*sq_inplace_concat*/ - 0, /*sq_inplace_repeat*/ -}; - -static PyMappingMethods __pyx_tp_as_mapping_StatePtr = { - 0, /*mp_length*/ - 0, /*mp_subscript*/ - 0, /*mp_ass_subscript*/ -}; - -static PyBufferProcs __pyx_tp_as_buffer_StatePtr = { - #if PY_MAJOR_VERSION < 3 - 0, /*bf_getreadbuffer*/ - #endif - #if PY_MAJOR_VERSION < 3 - 0, /*bf_getwritebuffer*/ - #endif - #if PY_MAJOR_VERSION < 3 - 0, /*bf_getsegcount*/ - #endif - #if PY_MAJOR_VERSION < 3 - 0, /*bf_getcharbuffer*/ - #endif - #if PY_VERSION_HEX >= 0x02060000 - 0, /*bf_getbuffer*/ - #endif - #if PY_VERSION_HEX >= 0x02060000 - 0, /*bf_releasebuffer*/ - #endif -}; - -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_pf_8freenect_8StatePtr___repr__, /*tp_repr*/ - &__pyx_tp_as_number_StatePtr, /*tp_as_number*/ - &__pyx_tp_as_sequence_StatePtr, /*tp_as_sequence*/ - &__pyx_tp_as_mapping_StatePtr, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - &__pyx_tp_as_buffer_StatePtr, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|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*/ - 0, /*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 -}; - static PyMethodDef __pyx_methods[] = { - {__Pyx_NAMESTR("init"), (PyCFunction)__pyx_pf_8freenect_18init, METH_NOARGS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("open_device"), (PyCFunction)__pyx_pf_8freenect_19open_device, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("init"), (PyCFunction)__pyx_pw_8freenect_37init, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("open_device"), (PyCFunction)__pyx_pw_8freenect_39open_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 */ @@ -7446,13 +8495,16 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_kp_u_22, __pyx_k_22, sizeof(__pyx_k_22), 0, 1, 0, 0}, {&__pyx_n_s_24, __pyx_k_24, sizeof(__pyx_k_24), 0, 0, 1, 1}, {&__pyx_n_s_25, __pyx_k_25, sizeof(__pyx_k_25), 0, 0, 1, 1}, - {&__pyx_kp_s_26, __pyx_k_26, sizeof(__pyx_k_26), 0, 0, 1, 0}, + {&__pyx_kp_s_28, __pyx_k_28, sizeof(__pyx_k_28), 0, 0, 1, 0}, {&__pyx_kp_s_3, __pyx_k_3, sizeof(__pyx_k_3), 0, 0, 1, 0}, {&__pyx_kp_s_4, __pyx_k_4, sizeof(__pyx_k_4), 0, 0, 1, 0}, + {&__pyx_kp_s_66, __pyx_k_66, sizeof(__pyx_k_66), 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}, @@ -7475,36 +8527,43 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__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_n_s____class__, __pyx_k____class__, sizeof(__pyx_k____class__), 0, 0, 1, 1}, + {&__pyx_n_s____import__, __pyx_k____import__, sizeof(__pyx_k____import__), 0, 0, 1, 1}, {&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1}, + {&__pyx_n_s____metaclass__, __pyx_k____metaclass__, sizeof(__pyx_k____metaclass__), 0, 0, 1, 1}, + {&__pyx_n_s____module__, __pyx_k____module__, sizeof(__pyx_k____module__), 0, 0, 1, 1}, + {&__pyx_n_s____qualname__, __pyx_k____qualname__, sizeof(__pyx_k____qualname__), 0, 0, 1, 1}, {&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 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___depth_cb_np, __pyx_k___depth_cb_np, sizeof(__pyx_k___depth_cb_np), 0, 0, 1, 1}, + {&__pyx_n_s___format, __pyx_k___format, sizeof(__pyx_k___format), 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_tilt_angle, __pyx_k___get_tilt_angle, sizeof(__pyx_k___get_tilt_angle), 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___ptr, __pyx_k___ptr, sizeof(__pyx_k___ptr), 0, 0, 1, 1}, + {&__pyx_n_s___index, __pyx_k___index, sizeof(__pyx_k___index), 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___video_cb_np, __pyx_k___video_cb_np, sizeof(__pyx_k___video_cb_np), 0, 0, 1, 1}, {&__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, __pyx_k__base, sizeof(__pyx_k__base), 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__buf, __pyx_k__buf, sizeof(__pyx_k__buf), 0, 0, 1, 1}, - {&__pyx_n_s__byteorder, __pyx_k__byteorder, sizeof(__pyx_k__byteorder), 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__descr, __pyx_k__descr, sizeof(__pyx_k__descr), 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__dtype, __pyx_k__dtype, sizeof(__pyx_k__dtype), 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__fields, __pyx_k__fields, sizeof(__pyx_k__fields), 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__freenect, __pyx_k__freenect, sizeof(__pyx_k__freenect), 0, 0, 1, 1}, {&__pyx_n_s__fromstring, __pyx_k__fromstring, sizeof(__pyx_k__fromstring), 0, 0, 1, 1}, @@ -7513,19 +8572,17 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__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__index, __pyx_k__index, sizeof(__pyx_k__index), 0, 0, 1, 1}, - {&__pyx_n_s__itemsize, __pyx_k__itemsize, sizeof(__pyx_k__itemsize), 0, 0, 1, 1}, + {&__pyx_n_s__mdev, __pyx_k__mdev, sizeof(__pyx_k__mdev), 0, 0, 1, 1}, {&__pyx_n_s__mode, __pyx_k__mode, sizeof(__pyx_k__mode), 0, 0, 1, 1}, - {&__pyx_n_s__names, __pyx_k__names, sizeof(__pyx_k__names), 0, 0, 1, 1}, - {&__pyx_n_s__ndim, __pyx_k__ndim, sizeof(__pyx_k__ndim), 0, 0, 1, 1}, {&__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__obj, __pyx_k__obj, sizeof(__pyx_k__obj), 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__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__range, __pyx_k__range, sizeof(__pyx_k__range), 0, 0, 1, 1}, - {&__pyx_n_s__readonly, __pyx_k__readonly, sizeof(__pyx_k__readonly), 0, 0, 1, 1}, {&__pyx_n_s__res, __pyx_k__res, sizeof(__pyx_k__res), 0, 0, 1, 1}, {&__pyx_n_s__resize, __pyx_k__resize, sizeof(__pyx_k__resize), 0, 0, 1, 1}, {&__pyx_n_s__runloop, __pyx_k__runloop, sizeof(__pyx_k__runloop), 0, 0, 1, 1}, @@ -7535,175 +8592,456 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__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__shape, __pyx_k__shape, sizeof(__pyx_k__shape), 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__strides, __pyx_k__strides, sizeof(__pyx_k__strides), 0, 0, 1, 1}, {&__pyx_n_s__string, __pyx_k__string, sizeof(__pyx_k__string), 0, 0, 1, 1}, - {&__pyx_n_s__suboffsets, __pyx_k__suboffsets, sizeof(__pyx_k__suboffsets), 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__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_n_s__type_num, __pyx_k__type_num, sizeof(__pyx_k__type_num), 0, 0, 1, 1}, {&__pyx_n_s__uint16, __pyx_k__uint16, sizeof(__pyx_k__uint16), 0, 0, 1, 1}, {&__pyx_n_s__uint8, __pyx_k__uint8, sizeof(__pyx_k__uint8), 0, 0, 1, 1}, {&__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__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_GetName(__pyx_b, __pyx_n_s__property); if (!__pyx_builtin_property) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_Exception = __Pyx_GetName(__pyx_b, __pyx_n_s__Exception); if (!__pyx_builtin_Exception) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_TypeError = __Pyx_GetName(__pyx_b, __pyx_n_s__TypeError); if (!__pyx_builtin_TypeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_ValueError = __Pyx_GetName(__pyx_b, __pyx_n_s__ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_range = __Pyx_GetName(__pyx_b, __pyx_n_s__range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_RuntimeError = __Pyx_GetName(__pyx_b, __pyx_n_s__RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 787; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_property = __Pyx_GetBuiltinName(__pyx_n_s__property); if (!__pyx_builtin_property) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 200; __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 = 338; __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 = 490; __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_RefNannySetupContext("__Pyx_InitCachedConstants"); + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); - /* "freenect.pyx":435 + /* "freenect.pyx":442 * """ * data = np.fromstring(string, dtype=np.uint16) * data.resize((480, 640)) # <<<<<<<<<<<<<< * return dev, data, timestamp * */ - __pyx_k_tuple_5 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_5)); - __Pyx_INCREF(__pyx_int_480); - PyTuple_SET_ITEM(__pyx_k_tuple_5, 0, __pyx_int_480); - __Pyx_GIVEREF(__pyx_int_480); - __Pyx_INCREF(__pyx_int_640); - PyTuple_SET_ITEM(__pyx_k_tuple_5, 1, __pyx_int_640); - __Pyx_GIVEREF(__pyx_int_640); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_5)); - __pyx_k_tuple_6 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_6)); - __Pyx_INCREF(((PyObject *)__pyx_k_tuple_5)); - PyTuple_SET_ITEM(__pyx_k_tuple_6, 0, ((PyObject *)__pyx_k_tuple_5)); + __pyx_k_tuple_5 = PyTuple_Pack(2, __pyx_int_480, __pyx_int_640); if (unlikely(!__pyx_k_tuple_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_5); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_5)); + __pyx_k_tuple_6 = PyTuple_Pack(1, ((PyObject *)__pyx_k_tuple_5)); if (unlikely(!__pyx_k_tuple_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_6); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_6)); - /* "freenect.pyx":451 + /* "freenect.pyx":458 * """ * data = np.fromstring(string, dtype=np.uint8) * data.resize((480, 640, 3)) # <<<<<<<<<<<<<< * return dev, data, timestamp * */ - __pyx_k_tuple_7 = PyTuple_New(3); if (unlikely(!__pyx_k_tuple_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_7)); - __Pyx_INCREF(__pyx_int_480); - PyTuple_SET_ITEM(__pyx_k_tuple_7, 0, __pyx_int_480); - __Pyx_GIVEREF(__pyx_int_480); - __Pyx_INCREF(__pyx_int_640); - PyTuple_SET_ITEM(__pyx_k_tuple_7, 1, __pyx_int_640); - __Pyx_GIVEREF(__pyx_int_640); - __Pyx_INCREF(__pyx_int_3); - PyTuple_SET_ITEM(__pyx_k_tuple_7, 2, __pyx_int_3); - __Pyx_GIVEREF(__pyx_int_3); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_7)); - __pyx_k_tuple_8 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_8)); - __Pyx_INCREF(((PyObject *)__pyx_k_tuple_7)); - PyTuple_SET_ITEM(__pyx_k_tuple_8, 0, ((PyObject *)__pyx_k_tuple_7)); + __pyx_k_tuple_7 = PyTuple_Pack(3, __pyx_int_480, __pyx_int_640, __pyx_int_3); if (unlikely(!__pyx_k_tuple_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_7); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_7)); + __pyx_k_tuple_8 = PyTuple_Pack(1, ((PyObject *)__pyx_k_tuple_7)); if (unlikely(!__pyx_k_tuple_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_8); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_8)); - /* "numpy.pxd":206 + /* "numpy.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_k_tuple_13 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_13)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_13)); - __Pyx_INCREF(((PyObject *)__pyx_kp_u_12)); - PyTuple_SET_ITEM(__pyx_k_tuple_13, 0, ((PyObject *)__pyx_kp_u_12)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_12)); + __pyx_k_tuple_13 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_u_12)); if (unlikely(!__pyx_k_tuple_13)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_13); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_13)); - /* "numpy.pxd":210 + /* "numpy.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_k_tuple_15 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_15)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_15)); - __Pyx_INCREF(((PyObject *)__pyx_kp_u_14)); - PyTuple_SET_ITEM(__pyx_k_tuple_15, 0, ((PyObject *)__pyx_kp_u_14)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_14)); + __pyx_k_tuple_15 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_u_14)); if (unlikely(!__pyx_k_tuple_15)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_15); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_15)); - /* "numpy.pxd":248 - * if ((descr.byteorder == '>' and little_endian) or - * (descr.byteorder == '<' and not little_endian)): + /* "numpy.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_k_tuple_17 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_17)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_17)); - __Pyx_INCREF(((PyObject *)__pyx_kp_u_16)); - PyTuple_SET_ITEM(__pyx_k_tuple_17, 0, ((PyObject *)__pyx_kp_u_16)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_16)); + __pyx_k_tuple_17 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_u_16)); if (unlikely(!__pyx_k_tuple_17)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_17); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_17)); - /* "numpy.pxd":787 + /* "numpy.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 == '>' and little_endian) or + * if ((child.byteorder == c'>' and little_endian) or */ - __pyx_k_tuple_20 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_20)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 787; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_20)); - __Pyx_INCREF(((PyObject *)__pyx_kp_u_19)); - PyTuple_SET_ITEM(__pyx_k_tuple_20, 0, ((PyObject *)__pyx_kp_u_19)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_19)); + __pyx_k_tuple_20 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_u_19)); if (unlikely(!__pyx_k_tuple_20)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_20); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_20)); - /* "numpy.pxd":791 - * if ((child.byteorder == '>' and little_endian) or - * (child.byteorder == '<' and not little_endian)): + /* "numpy.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_k_tuple_21 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_21)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 791; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_21)); - __Pyx_INCREF(((PyObject *)__pyx_kp_u_16)); - PyTuple_SET_ITEM(__pyx_k_tuple_21, 0, ((PyObject *)__pyx_kp_u_16)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_16)); + __pyx_k_tuple_21 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_u_16)); if (unlikely(!__pyx_k_tuple_21)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_21); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_21)); - /* "numpy.pxd":811 + /* "numpy.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_k_tuple_23 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_23)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 811; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_23)); - __Pyx_INCREF(((PyObject *)__pyx_kp_u_22)); - PyTuple_SET_ITEM(__pyx_k_tuple_23, 0, ((PyObject *)__pyx_kp_u_22)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_22)); + __pyx_k_tuple_23 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_u_22)); if (unlikely(!__pyx_k_tuple_23)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_23); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_23)); + + /* "freenect.pyx":206 + * 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_k_tuple_26 = PyTuple_Pack(3, ((PyObject *)__pyx_n_s__dev), ((PyObject *)__pyx_n_s__res), ((PyObject *)__pyx_n_s__mode)); if (unlikely(!__pyx_k_tuple_26)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_26); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_26)); + __pyx_k_codeobj_27 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_26, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_28, __pyx_n_s__set_depth_mode, 206, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_27)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "freenect.pyx":209 + * 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_k_tuple_29 = PyTuple_Pack(3, ((PyObject *)__pyx_n_s__dev), ((PyObject *)__pyx_n_s__res), ((PyObject *)__pyx_n_s__mode)); if (unlikely(!__pyx_k_tuple_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_29); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_29)); + __pyx_k_codeobj_30 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_29, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_28, __pyx_n_s__set_video_mode, 209, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_30)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "freenect.pyx":212 + * return freenect_set_video_mode(dev._ptr, freenect_find_video_mode(res, mode)) + * + * def start_depth(DevPtr dev): # <<<<<<<<<<<<<< + * return freenect_start_depth(dev._ptr) + * + */ + __pyx_k_tuple_31 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__dev)); if (unlikely(!__pyx_k_tuple_31)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_31); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_31)); + __pyx_k_codeobj_32 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_31, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_28, __pyx_n_s__start_depth, 212, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_32)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "freenect.pyx":215 + * return freenect_start_depth(dev._ptr) + * + * def start_video(DevPtr dev): # <<<<<<<<<<<<<< + * return freenect_start_video(dev._ptr) + * + */ + __pyx_k_tuple_33 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__dev)); if (unlikely(!__pyx_k_tuple_33)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_33); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_33)); + __pyx_k_codeobj_34 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_33, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_28, __pyx_n_s__start_video, 215, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_34)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "freenect.pyx":218 + * return freenect_start_video(dev._ptr) + * + * def stop_depth(DevPtr dev): # <<<<<<<<<<<<<< + * return freenect_stop_depth(dev._ptr) + * + */ + __pyx_k_tuple_35 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__dev)); if (unlikely(!__pyx_k_tuple_35)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_35); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_35)); + __pyx_k_codeobj_36 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_35, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_28, __pyx_n_s__stop_depth, 218, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_36)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "freenect.pyx":221 + * return freenect_stop_depth(dev._ptr) + * + * def stop_video(DevPtr dev): # <<<<<<<<<<<<<< + * return freenect_stop_video(dev._ptr) + * + */ + __pyx_k_tuple_37 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__dev)); if (unlikely(!__pyx_k_tuple_37)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_37); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_37)); + __pyx_k_codeobj_38 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_37, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_28, __pyx_n_s__stop_video, 221, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_38)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "freenect.pyx":224 + * return freenect_stop_video(dev._ptr) + * + * def shutdown(CtxPtr ctx): # <<<<<<<<<<<<<< + * return freenect_shutdown(ctx._ptr) + * + */ + __pyx_k_tuple_39 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__ctx)); if (unlikely(!__pyx_k_tuple_39)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_39); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_39)); + __pyx_k_codeobj_40 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_39, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_28, __pyx_n_s__shutdown, 224, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_40)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "freenect.pyx":227 + * return freenect_shutdown(ctx._ptr) + * + * def process_events(CtxPtr ctx): # <<<<<<<<<<<<<< + * return freenect_process_events(ctx._ptr) + * + */ + __pyx_k_tuple_41 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__ctx)); if (unlikely(!__pyx_k_tuple_41)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_41); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_41)); + __pyx_k_codeobj_42 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_41, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_28, __pyx_n_s__process_events, 227, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_42)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "freenect.pyx":230 + * return freenect_process_events(ctx._ptr) + * + * def num_devices(CtxPtr ctx): # <<<<<<<<<<<<<< + * return freenect_num_devices(ctx._ptr) + * + */ + __pyx_k_tuple_43 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__ctx)); if (unlikely(!__pyx_k_tuple_43)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_43); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_43)); + __pyx_k_codeobj_44 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_43, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_28, __pyx_n_s__num_devices, 230, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_44)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "freenect.pyx":233 + * return freenect_num_devices(ctx._ptr) + * + * def close_device(DevPtr dev): # <<<<<<<<<<<<<< + * return freenect_close_device(dev._ptr) + * + */ + __pyx_k_tuple_45 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__dev)); if (unlikely(!__pyx_k_tuple_45)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_45); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_45)); + __pyx_k_codeobj_46 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_45, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_28, __pyx_n_s__close_device, 233, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_46)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "freenect.pyx":236 + * return freenect_close_device(dev._ptr) + * + * def set_tilt_degs(DevPtr dev, float angle): # <<<<<<<<<<<<<< + * freenect_set_tilt_degs(dev._ptr, angle) + * + */ + __pyx_k_tuple_47 = PyTuple_Pack(2, ((PyObject *)__pyx_n_s__dev), ((PyObject *)__pyx_n_s__angle)); if (unlikely(!__pyx_k_tuple_47)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_47); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_47)); + __pyx_k_codeobj_48 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_47, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_28, __pyx_n_s__set_tilt_degs, 236, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_48)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "freenect.pyx":239 + * freenect_set_tilt_degs(dev._ptr, angle) + * + * def set_led(DevPtr dev, freenect_led_options option): # <<<<<<<<<<<<<< + * return freenect_set_led(dev._ptr, option) + * + */ + __pyx_k_tuple_49 = PyTuple_Pack(2, ((PyObject *)__pyx_n_s__dev), ((PyObject *)__pyx_n_s__option)); if (unlikely(!__pyx_k_tuple_49)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_49); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_49)); + __pyx_k_codeobj_50 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_49, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_28, __pyx_n_s__set_led, 239, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_50)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "freenect.pyx":242 + * return freenect_set_led(dev._ptr, option) + * + * def update_tilt_state(DevPtr dev): # <<<<<<<<<<<<<< + * return freenect_update_tilt_state(dev._ptr) + * + */ + __pyx_k_tuple_51 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__dev)); if (unlikely(!__pyx_k_tuple_51)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_51); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_51)); + __pyx_k_codeobj_52 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_51, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_28, __pyx_n_s__update_tilt_state, 242, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_52)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "freenect.pyx":245 + * 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 + */ + __pyx_k_tuple_53 = PyTuple_Pack(3, ((PyObject *)__pyx_n_s__dev), ((PyObject *)__pyx_n_s__state), ((PyObject *)__pyx_n_s__state_out)); if (unlikely(!__pyx_k_tuple_53)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_53); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_53)); + __pyx_k_codeobj_54 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_53, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_28, __pyx_n_s__get_tilt_state, 245, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_54)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "freenect.pyx":252 + * return state_out + * + * def get_mks_accel(StatePtr state): # <<<<<<<<<<<<<< + * cdef double x, y, z + * freenect_get_mks_accel(state._ptr, &x, &y, &z) + */ + __pyx_k_tuple_55 = PyTuple_Pack(4, ((PyObject *)__pyx_n_s__state), ((PyObject *)__pyx_n_s__x), ((PyObject *)__pyx_n_s__y), ((PyObject *)__pyx_n_s__z)); if (unlikely(!__pyx_k_tuple_55)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_55); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_55)); + __pyx_k_codeobj_56 = (PyObject*)__Pyx_PyCode_New(1, 0, 4, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_55, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_28, __pyx_n_s__get_mks_accel, 252, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_56)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "freenect.pyx":257 + * return x, y, z + * + * def get_accel(DevPtr dev): # <<<<<<<<<<<<<< + * """MKS Accelerometer helper + * + */ + __pyx_k_tuple_57 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__dev)); if (unlikely(!__pyx_k_tuple_57)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_57); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_57)); + __pyx_k_codeobj_58 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_57, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_28, __pyx_n_s__get_accel, 257, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_58)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "freenect.pyx":270 + * + * + * def get_tilt_degs(StatePtr state): # <<<<<<<<<<<<<< + * return freenect_get_tilt_degs(state._ptr) + * + */ + __pyx_k_tuple_59 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__state)); if (unlikely(!__pyx_k_tuple_59)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_59); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_59)); + __pyx_k_codeobj_60 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_59, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_28, __pyx_n_s__get_tilt_degs, 270, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_60)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "freenect.pyx":274 + * + * + * def error_open_device(): # <<<<<<<<<<<<<< + * print("Error: Can't open device. 1.) is it plugged in? 2.) Read the README") + * + */ + __pyx_k_codeobj_61 = (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_28, __pyx_n_s__error_open_device, 274, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_61)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "freenect.pyx":319 + * _video_cb(*_video_cb_np(dev_out, (data)[:nbytes], timestamp)) + * + * def set_depth_callback(DevPtr dev, cb): # <<<<<<<<<<<<<< + * global _depth_cb + * if cb is not None: + */ + __pyx_k_tuple_62 = PyTuple_Pack(2, ((PyObject *)__pyx_n_s__dev), ((PyObject *)__pyx_n_s__cb)); if (unlikely(!__pyx_k_tuple_62)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_62); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_62)); + __pyx_k_codeobj_63 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_62, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_28, __pyx_n_s__set_depth_callback, 319, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_63)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "freenect.pyx":328 + * freenect_set_depth_callback(dev._ptr, NULL) + * + * def set_video_callback(DevPtr dev, cb): # <<<<<<<<<<<<<< + * global _video_cb + * if cb is not None: + */ + __pyx_k_tuple_64 = PyTuple_Pack(2, ((PyObject *)__pyx_n_s__dev), ((PyObject *)__pyx_n_s__cb)); if (unlikely(!__pyx_k_tuple_64)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_64); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_64)); + __pyx_k_codeobj_65 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_64, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_28, __pyx_n_s__set_video_callback, 328, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_65)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "freenect.pyx":342 + * + * + * def runloop(depth=None, video=None, body=None, dev=None): # <<<<<<<<<<<<<< + * """Sets up the kinect and maintains a runloop + * + */ + __pyx_k_tuple_67 = PyTuple_Pack(8, ((PyObject *)__pyx_n_s__depth), ((PyObject *)__pyx_n_s__video), ((PyObject *)__pyx_n_s__body), ((PyObject *)__pyx_n_s__dev), ((PyObject *)__pyx_n_s__mdev), ((PyObject *)__pyx_n_s__ctx), ((PyObject *)__pyx_n_s__devp), ((PyObject *)__pyx_n_s__ctxp)); if (unlikely(!__pyx_k_tuple_67)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_67); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_67)); + __pyx_k_codeobj_68 = (PyObject*)__Pyx_PyCode_New(4, 0, 8, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_67, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_28, __pyx_n_s__runloop, 342, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_68)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "freenect.pyx":406 + * freenect_shutdown(ctxp) + * + * def base_runloop(CtxPtr ctx, body=None): # <<<<<<<<<<<<<< + * """Starts a runloop + * + */ + __pyx_k_tuple_69 = PyTuple_Pack(3, ((PyObject *)__pyx_n_s__ctx), ((PyObject *)__pyx_n_s__body), ((PyObject *)__pyx_n_s__ctxp)); if (unlikely(!__pyx_k_tuple_69)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_69); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_69)); + __pyx_k_codeobj_70 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_69, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_28, __pyx_n_s__base_runloop, 406, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_70)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "freenect.pyx":430 + * pass + * + * def _depth_cb_np(dev, string, timestamp): # <<<<<<<<<<<<<< + * """Converts the raw depth data into a numpy array for your function + * + */ + __pyx_k_tuple_71 = PyTuple_Pack(4, ((PyObject *)__pyx_n_s__dev), ((PyObject *)__pyx_n_s__string), ((PyObject *)__pyx_n_s__timestamp), ((PyObject *)__pyx_n_s__data)); if (unlikely(!__pyx_k_tuple_71)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_71); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_71)); + __pyx_k_codeobj_72 = (PyObject*)__Pyx_PyCode_New(3, 0, 4, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_71, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_28, __pyx_n_s___depth_cb_np, 430, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_72)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "freenect.pyx":446 + * + * + * def _video_cb_np(dev, string, timestamp): # <<<<<<<<<<<<<< + * """Converts the raw depth data into a numpy array for your function + * + */ + __pyx_k_tuple_73 = PyTuple_Pack(4, ((PyObject *)__pyx_n_s__dev), ((PyObject *)__pyx_n_s__string), ((PyObject *)__pyx_n_s__timestamp), ((PyObject *)__pyx_n_s__data)); if (unlikely(!__pyx_k_tuple_73)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_73); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_73)); + __pyx_k_codeobj_74 = (PyObject*)__Pyx_PyCode_New(3, 0, 4, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_73, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_28, __pyx_n_s___video_cb_np, 446, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_74)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "freenect.pyx":463 + * import_array() + * + * def sync_get_depth(index=0, format=DEPTH_11BIT): # <<<<<<<<<<<<<< + * """Get the next available depth frame from the kinect, as a numpy array. + * + */ + __pyx_k_tuple_75 = PyTuple_Pack(8, ((PyObject *)__pyx_n_s__index), ((PyObject *)__pyx_n_s__format), ((PyObject *)__pyx_n_s__data), ((PyObject *)__pyx_n_s__timestamp), ((PyObject *)__pyx_n_s__dims), ((PyObject *)__pyx_n_s__out), ((PyObject *)__pyx_n_s___index), ((PyObject *)__pyx_n_s___format)); if (unlikely(!__pyx_k_tuple_75)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_75); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_75)); + __pyx_k_codeobj_76 = (PyObject*)__Pyx_PyCode_New(2, 0, 8, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_75, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_28, __pyx_n_s__sync_get_depth, 463, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_76)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "freenect.pyx":493 + * + * + * def sync_get_video(index=0, format=VIDEO_RGB): # <<<<<<<<<<<<<< + * """Get the next available rgb frame from the kinect, as a numpy array. + * + */ + __pyx_k_tuple_77 = PyTuple_Pack(8, ((PyObject *)__pyx_n_s__index), ((PyObject *)__pyx_n_s__format), ((PyObject *)__pyx_n_s__data), ((PyObject *)__pyx_n_s__timestamp), ((PyObject *)__pyx_n_s__dims), ((PyObject *)__pyx_n_s__out), ((PyObject *)__pyx_n_s___index), ((PyObject *)__pyx_n_s___format)); if (unlikely(!__pyx_k_tuple_77)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 493; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_77); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_77)); + __pyx_k_codeobj_78 = (PyObject*)__Pyx_PyCode_New(2, 0, 8, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_77, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_28, __pyx_n_s__sync_get_video, 493, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_78)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 493; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "freenect.pyx":526 + * + * + * def sync_stop(): # <<<<<<<<<<<<<< + * """Terminate the synchronous runloop if running, else this is a NOP + * """ + */ + __pyx_k_codeobj_79 = (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_28, __pyx_n_s__sync_stop, 526, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_79)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 526; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; @@ -7734,8 +9072,11 @@ PyMODINIT_FUNC PyInit_freenect(void) PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannyDeclarations #if CYTHON_REFNANNY - void* __pyx_refnanny = NULL; __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); if (!__Pyx_RefNanny) { PyErr_Clear(); @@ -7743,12 +9084,19 @@ PyMODINIT_FUNC PyInit_freenect(void) if (!__Pyx_RefNanny) Py_FatalError("failed to import 'refnanny' module"); } - __pyx_refnanny = __Pyx_RefNanny->SetupContext("PyMODINIT_FUNC PyInit_freenect(void)", __LINE__, __FILE__); #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_binding_PyCFunctionType_USED - if (__pyx_binding_PyCFunctionType_init() < 0) {__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 ---*/ @@ -7759,19 +9107,31 @@ PyMODINIT_FUNC PyInit_freenect(void) #endif /*--- Module creation code ---*/ #if PY_MAJOR_VERSION < 3 - __pyx_m = Py_InitModule4(__Pyx_NAMESTR("freenect"), __pyx_methods, 0, 0, PYTHON_API_VERSION); + __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 (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - #if PY_MAJOR_VERSION < 3 - Py_INCREF(__pyx_m); + 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); + #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 + __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 - __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME)); - if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; 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;}; } @@ -7780,23 +9140,32 @@ PyMODINIT_FUNC PyInit_freenect(void) /*--- 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 = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "CtxPtr", (PyObject *)&__pyx_type_8freenect_CtxPtr) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_8freenect_CtxPtr) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "CtxPtr", (PyObject *)&__pyx_type_8freenect_CtxPtr) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __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 = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "DevPtr", (PyObject *)&__pyx_type_8freenect_DevPtr) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __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 = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "StatePtr", (PyObject *)&__pyx_type_8freenect_StatePtr) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_8freenect_StatePtr) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "StatePtr", (PyObject *)&__pyx_type_8freenect_StatePtr) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_8freenect_StatePtr = &__pyx_type_8freenect_StatePtr; + if (PyType_Ready(&__pyx_type_8freenect_DevPtr) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "DevPtr", (PyObject *)&__pyx_type_8freenect_DevPtr) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_8freenect_DevPtr = &__pyx_type_8freenect_DevPtr; /*--- Type import code ---*/ - __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 = 149; __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 = 159; __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 = 163; __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 = 172; __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 = 849; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __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 ---*/ @@ -7807,609 +9176,633 @@ PyMODINIT_FUNC PyInit_freenect(void) * cimport numpy as npc * */ - __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__numpy), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_Import(((PyObject *)__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 (PyObject_SetAttr(__pyx_m, __pyx_n_s__np, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + 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":140 + /* "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 = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __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 (PyObject_SetAttr(__pyx_m, __pyx_n_s__VIDEO_RGB, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + 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":141 + /* "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 = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __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 (PyObject_SetAttr(__pyx_m, __pyx_n_s__VIDEO_BAYER, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + 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":142 + /* "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 = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __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 (PyObject_SetAttr(__pyx_m, __pyx_n_s__VIDEO_IR_8BIT, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + 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":143 + /* "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 = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __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 (PyObject_SetAttr(__pyx_m, __pyx_n_s__VIDEO_IR_10BIT, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + 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":144 + /* "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 = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __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 (PyObject_SetAttr(__pyx_m, __pyx_n_s_24, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s_24, __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":145 + /* "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 = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __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 (PyObject_SetAttr(__pyx_m, __pyx_n_s__VIDEO_YUV_RGB, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + 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":146 + /* "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 = 146; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __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 (PyObject_SetAttr(__pyx_m, __pyx_n_s__VIDEO_YUV_RAW, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 146; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + 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":147 + /* "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 = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __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 (PyObject_SetAttr(__pyx_m, __pyx_n_s__DEPTH_11BIT, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + 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":148 + /* "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 = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __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 (PyObject_SetAttr(__pyx_m, __pyx_n_s__DEPTH_10BIT, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + 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":149 + /* "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 - * LED_OFF = FREENECT_LED_OFF + * 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 = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __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 (PyObject_SetAttr(__pyx_m, __pyx_n_s__DEPTH_11BIT_PACKED, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + 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":150 + /* "freenect.pyx":152 * DEPTH_10BIT = FREENECT_DEPTH_10BIT * DEPTH_11BIT_PACKED = FREENECT_DEPTH_11BIT_PACKED * DEPTH_10BIT_PACKED = FREENECT_DEPTH_10BIT_PACKED # <<<<<<<<<<<<<< - * LED_OFF = FREENECT_LED_OFF - * LED_GREEN = FREENECT_LED_GREEN + * 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 = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __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 (PyObject_SetAttr(__pyx_m, __pyx_n_s__DEPTH_10BIT_PACKED, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + 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":151 + /* "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 = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __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 (PyObject_SetAttr(__pyx_m, __pyx_n_s__LED_OFF, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + 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":152 - * DEPTH_10BIT_PACKED = FREENECT_DEPTH_10BIT_PACKED + /* "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 = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __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 (PyObject_SetAttr(__pyx_m, __pyx_n_s__LED_GREEN, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + 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":153 + /* "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 = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __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 (PyObject_SetAttr(__pyx_m, __pyx_n_s__LED_RED, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + 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":154 + /* "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 = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __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 (PyObject_SetAttr(__pyx_m, __pyx_n_s__LED_YELLOW, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + 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":155 + /* "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 = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __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 (PyObject_SetAttr(__pyx_m, __pyx_n_s__LED_BLINK_GREEN, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + 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":156 + /* "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 = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __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 (PyObject_SetAttr(__pyx_m, __pyx_n_s_25, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s_25, __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":157 + /* "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 = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __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 (PyObject_SetAttr(__pyx_m, __pyx_n_s__RESOLUTION_LOW, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + 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":158 + /* "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 = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __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 (PyObject_SetAttr(__pyx_m, __pyx_n_s__RESOLUTION_MEDIUM, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + 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":159 + /* "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 = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __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 (PyObject_SetAttr(__pyx_m, __pyx_n_s__RESOLUTION_HIGH, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + 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":160 + /* "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 = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __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 (PyObject_SetAttr(__pyx_m, __pyx_n_s__DEVICE_MOTOR, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + 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":161 + /* "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 = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __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 (PyObject_SetAttr(__pyx_m, __pyx_n_s__DEVICE_CAMERA, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + 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":162 + /* "freenect.pyx":166 * DEVICE_MOTOR = FREENECT_DEVICE_MOTOR * DEVICE_CAMERA = FREENECT_DEVICE_CAMERA * DEVICE_AUDIO = FREENECT_DEVICE_AUDIO # <<<<<<<<<<<<<< * * */ - __pyx_t_1 = PyInt_FromLong(FREENECT_DEVICE_AUDIO); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __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 (PyObject_SetAttr(__pyx_m, __pyx_n_s__DEVICE_AUDIO, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + 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":196 + /* "freenect.pyx":200 * 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_GetName((PyObject *)__pyx_ptype_8freenect_StatePtr, __pyx_n_s___get_accelx); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __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 = 200; __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 = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_2)); + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 200; __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 = PyObject_Call(__pyx_builtin_property, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(__pyx_builtin_property, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__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 = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + 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 = 200; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; PyType_Modified(__pyx_ptype_8freenect_StatePtr); - /* "freenect.pyx":197 + /* "freenect.pyx":201 * * 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_GetName((PyObject *)__pyx_ptype_8freenect_StatePtr, __pyx_n_s___get_accely); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __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 = 201; __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 = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_2)); + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __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 = PyObject_Call(__pyx_builtin_property, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(__pyx_builtin_property, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__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 = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + 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 = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; PyType_Modified(__pyx_ptype_8freenect_StatePtr); - /* "freenect.pyx":198 + /* "freenect.pyx":202 * 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_GetName((PyObject *)__pyx_ptype_8freenect_StatePtr, __pyx_n_s___get_accelz); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __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 = 202; __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 = 198; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_2)); + __pyx_t_2 = PyTuple_New(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); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(__pyx_builtin_property, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(__pyx_builtin_property, ((PyObject *)__pyx_t_2), NULL); 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_DECREF(((PyObject *)__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 = 198; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + 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 = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; PyType_Modified(__pyx_ptype_8freenect_StatePtr); - /* "freenect.pyx":199 + /* "freenect.pyx":203 * 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_GetName((PyObject *)__pyx_ptype_8freenect_StatePtr, __pyx_n_s___get_tilt_angle); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __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 = 203; __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 = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_2)); + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __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 = PyObject_Call(__pyx_builtin_property, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(__pyx_builtin_property, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__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 = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + 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 = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; PyType_Modified(__pyx_ptype_8freenect_StatePtr); - /* "freenect.pyx":200 + /* "freenect.pyx":204 * 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_GetName((PyObject *)__pyx_ptype_8freenect_StatePtr, __pyx_n_s___get_tilt_status); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __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 = 204; __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 = 200; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_2)); + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; __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 = PyObject_Call(__pyx_builtin_property, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(__pyx_builtin_property, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__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 = 200; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + 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 = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; PyType_Modified(__pyx_ptype_8freenect_StatePtr); - /* "freenect.pyx":202 + /* "freenect.pyx":206 * 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_set_depth_mode, NULL, __pyx_n_s__freenect); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __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 = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s__set_depth_mode, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s__set_depth_mode, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "freenect.pyx":205 + /* "freenect.pyx":209 * 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_1set_video_mode, NULL, __pyx_n_s__freenect); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __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 = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s__set_video_mode, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s__set_video_mode, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "freenect.pyx":208 + /* "freenect.pyx":212 * return freenect_set_video_mode(dev._ptr, freenect_find_video_mode(res, mode)) * * def start_depth(DevPtr dev): # <<<<<<<<<<<<<< * return freenect_start_depth(dev._ptr) * */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_8freenect_2start_depth, NULL, __pyx_n_s__freenect); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_8freenect_5start_depth, NULL, __pyx_n_s__freenect); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s__start_depth, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s__start_depth, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "freenect.pyx":211 + /* "freenect.pyx":215 * 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_3start_video, NULL, __pyx_n_s__freenect); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_8freenect_7start_video, NULL, __pyx_n_s__freenect); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s__start_video, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s__start_video, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "freenect.pyx":214 + /* "freenect.pyx":218 * 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_4stop_depth, NULL, __pyx_n_s__freenect); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_8freenect_9stop_depth, NULL, __pyx_n_s__freenect); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s__stop_depth, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s__stop_depth, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "freenect.pyx":217 + /* "freenect.pyx":221 * 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_5stop_video, NULL, __pyx_n_s__freenect); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_8freenect_11stop_video, NULL, __pyx_n_s__freenect); 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); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s__stop_video, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s__stop_video, __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; - /* "freenect.pyx":220 + /* "freenect.pyx":224 * return freenect_stop_video(dev._ptr) * * def shutdown(CtxPtr ctx): # <<<<<<<<<<<<<< * return freenect_shutdown(ctx._ptr) * */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_8freenect_6shutdown, NULL, __pyx_n_s__freenect); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 220; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_8freenect_13shutdown, NULL, __pyx_n_s__freenect); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s__shutdown, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 220; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s__shutdown, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "freenect.pyx":223 + /* "freenect.pyx":227 * return freenect_shutdown(ctx._ptr) * * def process_events(CtxPtr ctx): # <<<<<<<<<<<<<< * return freenect_process_events(ctx._ptr) * */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_8freenect_7process_events, NULL, __pyx_n_s__freenect); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_8freenect_15process_events, NULL, __pyx_n_s__freenect); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s__process_events, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s__process_events, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "freenect.pyx":226 + /* "freenect.pyx":230 * 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_8num_devices, NULL, __pyx_n_s__freenect); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_8freenect_17num_devices, NULL, __pyx_n_s__freenect); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s__num_devices, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s__num_devices, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "freenect.pyx":229 + /* "freenect.pyx":233 * 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_9close_device, NULL, __pyx_n_s__freenect); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_8freenect_19close_device, NULL, __pyx_n_s__freenect); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s__close_device, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s__close_device, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "freenect.pyx":232 + /* "freenect.pyx":236 * 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_10set_tilt_degs, NULL, __pyx_n_s__freenect); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_8freenect_21set_tilt_degs, NULL, __pyx_n_s__freenect); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s__set_tilt_degs, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s__set_tilt_degs, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "freenect.pyx":235 + /* "freenect.pyx":239 * 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_11set_led, NULL, __pyx_n_s__freenect); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_8freenect_23set_led, NULL, __pyx_n_s__freenect); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s__set_led, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s__set_led, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "freenect.pyx":238 + /* "freenect.pyx":242 * 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_12update_tilt_state, NULL, __pyx_n_s__freenect); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_8freenect_25update_tilt_state, NULL, __pyx_n_s__freenect); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s__update_tilt_state, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s__update_tilt_state, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "freenect.pyx":241 + /* "freenect.pyx":245 * 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 */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_8freenect_13get_tilt_state, NULL, __pyx_n_s__freenect); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_8freenect_27get_tilt_state, NULL, __pyx_n_s__freenect); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s__get_tilt_state, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s__get_tilt_state, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "freenect.pyx":248 + /* "freenect.pyx":252 * 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_14get_mks_accel, NULL, __pyx_n_s__freenect); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_8freenect_29get_mks_accel, 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 (PyObject_SetAttr(__pyx_m, __pyx_n_s__get_mks_accel, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s__get_mks_accel, __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":253 + /* "freenect.pyx":257 * return x, y, z * * def get_accel(DevPtr dev): # <<<<<<<<<<<<<< * """MKS Accelerometer helper * */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_8freenect_15get_accel, NULL, __pyx_n_s__freenect); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_8freenect_31get_accel, NULL, __pyx_n_s__freenect); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s__get_accel, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s__get_accel, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "freenect.pyx":266 + /* "freenect.pyx":270 * * * def get_tilt_degs(StatePtr state): # <<<<<<<<<<<<<< * return freenect_get_tilt_degs(state._ptr) * */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_8freenect_16get_tilt_degs, NULL, __pyx_n_s__freenect); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_8freenect_33get_tilt_degs, 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 (PyObject_SetAttr(__pyx_m, __pyx_n_s__get_tilt_degs, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s__get_tilt_degs, __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":270 + /* "freenect.pyx":274 * * * 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_17error_open_device, 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_t_1 = PyCFunction_NewEx(&__pyx_mdef_8freenect_35error_open_device, NULL, __pyx_n_s__freenect); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s__error_open_device, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s__error_open_device, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "freenect.pyx":297 + /* "freenect.pyx":301 * return dev_out * * _depth_cb, _video_cb = None, None # <<<<<<<<<<<<<< @@ -8420,106 +9813,106 @@ PyMODINIT_FUNC PyInit_freenect(void) __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = Py_None; __Pyx_INCREF(__pyx_t_2); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s___depth_cb, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s___depth_cb, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (PyObject_SetAttr(__pyx_m, __pyx_n_s___video_cb, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s___video_cb, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "freenect.pyx":315 + /* "freenect.pyx":319 * _video_cb(*_video_cb_np(dev_out, (data)[:nbytes], timestamp)) * * def set_depth_callback(DevPtr dev, cb): # <<<<<<<<<<<<<< * global _depth_cb * if cb is not None: */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_8freenect_20set_depth_callback, NULL, __pyx_n_s__freenect); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_8freenect_41set_depth_callback, NULL, __pyx_n_s__freenect); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s__set_depth_callback, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s__set_depth_callback, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "freenect.pyx":324 + /* "freenect.pyx":328 * 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_21set_video_callback, NULL, __pyx_n_s__freenect); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_8freenect_43set_video_callback, NULL, __pyx_n_s__freenect); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s__set_video_callback, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s__set_video_callback, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "freenect.pyx":334 + /* "freenect.pyx":338 * * * class Kill(Exception): # <<<<<<<<<<<<<< * """This kills the runloop, raise from the body only""" * */ - __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_2)); - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_1)); + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_builtin_Exception); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_builtin_Exception); __Pyx_GIVEREF(__pyx_builtin_Exception); - if (PyDict_SetItemString(((PyObject *)__pyx_t_2), "__doc__", ((PyObject *)__pyx_kp_s_26)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_3 = __Pyx_CreateClass(((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_2), __pyx_n_s__Kill, __pyx_n_s__freenect); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItemString(((PyObject *)__pyx_t_2), "__doc__", ((PyObject *)__pyx_kp_s_66)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_CreateClass(((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_2), __pyx_n_s__Kill, __pyx_n_s__Kill, __pyx_n_s__freenect); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - if (PyObject_SetAttr(__pyx_m, __pyx_n_s__Kill, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s__Kill, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - /* "freenect.pyx":338 + /* "freenect.pyx":342 * * * 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_22runloop, NULL, __pyx_n_s__freenect); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_8freenect_45runloop, NULL, __pyx_n_s__freenect); 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 (PyObject_SetAttr(__pyx_m, __pyx_n_s__runloop, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s__runloop, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "freenect.pyx":399 + /* "freenect.pyx":406 * freenect_shutdown(ctxp) * * def base_runloop(CtxPtr ctx, body=None): # <<<<<<<<<<<<<< * """Starts a runloop * */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_8freenect_23base_runloop, NULL, __pyx_n_s__freenect); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_8freenect_47base_runloop, NULL, __pyx_n_s__freenect); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s__base_runloop, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s__base_runloop, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "freenect.pyx":423 + /* "freenect.pyx":430 * pass * * def _depth_cb_np(dev, string, timestamp): # <<<<<<<<<<<<<< * """Converts the raw depth data into a numpy array for your function * */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_8freenect_24_depth_cb_np, NULL, __pyx_n_s__freenect); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_8freenect_49_depth_cb_np, NULL, __pyx_n_s__freenect); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s___depth_cb_np, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s___depth_cb_np, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "freenect.pyx":439 + /* "freenect.pyx":446 * * * def _video_cb_np(dev, string, timestamp): # <<<<<<<<<<<<<< * """Converts the raw depth data into a numpy array for your function * */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_8freenect_25_video_cb_np, NULL, __pyx_n_s__freenect); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_8freenect_51_video_cb_np, NULL, __pyx_n_s__freenect); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s___video_cb_np, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s___video_cb_np, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "freenect.pyx":454 + /* "freenect.pyx":461 * return dev, data, timestamp * * import_array() # <<<<<<<<<<<<<< @@ -8528,50 +9921,50 @@ PyMODINIT_FUNC PyInit_freenect(void) */ import_array(); - /* "freenect.pyx":456 + /* "freenect.pyx":463 * import_array() * * 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_GetName(__pyx_m, __pyx_n_s__DEPTH_11BIT); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__DEPTH_11BIT); 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_k_9 = __pyx_t_2; __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_8freenect_26sync_get_depth, NULL, __pyx_n_s__freenect); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __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 = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s__sync_get_depth, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s__sync_get_depth, __pyx_t_2) < 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; - /* "freenect.pyx":486 + /* "freenect.pyx":493 * * * 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_GetName(__pyx_m, __pyx_n_s__VIDEO_RGB); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__VIDEO_RGB); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 493; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_k_11 = __pyx_t_2; __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_8freenect_27sync_get_video, NULL, __pyx_n_s__freenect); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __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 = 493; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s__sync_get_video, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s__sync_get_video, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 493; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "freenect.pyx":519 + /* "freenect.pyx":526 * * * def sync_stop(): # <<<<<<<<<<<<<< * """Terminate the synchronous runloop if running, else this is a NOP * """ */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_8freenect_28sync_stop, NULL, __pyx_n_s__freenect); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __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 = 526; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s__sync_stop, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s__sync_stop, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 526; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "freenect.pyx":1 @@ -8581,10 +9974,10 @@ PyMODINIT_FUNC PyInit_freenect(void) */ __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(((PyObject *)__pyx_t_2)); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_2)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s____test__, ((PyObject *)__pyx_t_2)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - /* "numpy.pxd":963 + /* "numpy.pxd":975 * arr.base = baseptr * * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< @@ -8597,7 +9990,7 @@ PyMODINIT_FUNC PyInit_freenect(void) __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); if (__pyx_m) { - __Pyx_AddTraceback("init freenect"); + __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"); @@ -8612,12 +10005,32 @@ PyMODINIT_FUNC PyInit_freenect(void) } /* 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_GetName(PyObject *dict, PyObject *name) { - PyObject *result; - result = PyObject_GetAttr(dict, name); - if (!result) - PyErr_SetObject(PyExc_NameError, name); +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 '%s' is not defined", PyString_AS_STRING(name)); +#endif + } return result; } @@ -8629,8 +10042,7 @@ static void __Pyx_RaiseArgtupleInvalid( Py_ssize_t num_found) { Py_ssize_t num_expected; - const char *number, *more_or_less; - + const char *more_or_less; if (num_found < num_min) { num_expected = num_min; more_or_less = "at least"; @@ -8641,14 +10053,10 @@ static void __Pyx_RaiseArgtupleInvalid( if (exact) { more_or_less = "exactly"; } - number = (num_expected == 1) ? "" : "s"; PyErr_Format(PyExc_TypeError, - #if PY_VERSION_HEX < 0x02050000 - "%s() takes %s %d positional argument%s (%d given)", - #else - "%s() takes %s %zd positional argument%s (%zd given)", - #endif - func_name, more_or_less, num_expected, number, num_found); + "%s() takes %s %" CYTHON_FORMAT_SSIZE_T "d positional argument%s (%" CYTHON_FORMAT_SSIZE_T "d given)", + func_name, more_or_less, num_expected, + (num_expected == 1) ? "" : "s", num_found); } static void __Pyx_RaiseDoubleKeywordsError( @@ -8660,7 +10068,7 @@ static void __Pyx_RaiseDoubleKeywordsError( "%s() got multiple values for keyword argument '%U'", func_name, kw_name); #else "%s() got multiple values for keyword argument '%s'", func_name, - PyString_AS_STRING(kw_name)); + PyString_AsString(kw_name)); #endif } @@ -8676,55 +10084,77 @@ static int __Pyx_ParseOptionalKeywords( 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; - } else { - #if PY_MAJOR_VERSION < 3 - if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key))) { - #else - if (unlikely(!PyUnicode_CheckExact(key)) && unlikely(!PyUnicode_Check(key))) { - #endif - goto invalid_keyword_type; - } else { - for (name = first_kw_arg; *name; name++) { - #if PY_MAJOR_VERSION >= 3 - if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) && - PyUnicode_Compare(**name, key) == 0) break; - #else - if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) && - _PyString_Eq(**name, key)) break; - #endif - } - if (*name) { + 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; - } else { - /* unexpected keyword found */ - for (name=argnames; name != first_kw_arg; name++) { - if (**name == key) goto arg_passed_twice; - #if PY_MAJOR_VERSION >= 3 - if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) && - PyUnicode_Compare(**name, key) == 0) goto arg_passed_twice; - #else - if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) && - _PyString_Eq(**name, key)) goto arg_passed_twice; - #endif - } - if (kwds2) { - if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; - } else { - goto invalid_keyword; + 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, **name); + __Pyx_RaiseDoubleKeywordsError(function_name, key); goto bad; invalid_keyword_type: PyErr_Format(PyExc_TypeError, @@ -8763,22 +10193,27 @@ static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed return 0; } -static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { - if (unlikely(!type)) { - PyErr_Format(PyExc_SystemError, "Missing type object"); - 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); } - 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; + return result; } 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; @@ -8788,77 +10223,112 @@ static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyOb 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 +} + +static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno, + CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename) { + PyObject *old_exc, *old_val, *old_tb; + PyObject *ctx; + __Pyx_ErrFetch(&old_exc, &old_val, &old_tb); + #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 int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { + if (unlikely(!type)) { + PyErr_Format(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; +} #if PY_MAJOR_VERSION < 3 -static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) { +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, + CYTHON_UNUSED PyObject *cause) { Py_XINCREF(type); - Py_XINCREF(value); - Py_XINCREF(tb); - /* First, check the traceback argument, replacing None with NULL. */ - if (tb == Py_None) { - Py_DECREF(tb); - tb = 0; - } - else if (tb != NULL && !PyTraceBack_Check(tb)) { - PyErr_SetString(PyExc_TypeError, - "raise: arg 3 must be a traceback or None"); - goto raise_error; - } - /* Next, replace a missing value with None */ - if (value == NULL) { - value = Py_None; + 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)) + if (PyClass_Check(type)) { #else - if (!PyType_Check(type)) + if (PyType_Check(type)) { #endif - { - /* Raising an instance. The value should be a dummy. */ - if (value != Py_None) { +#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; } - /* Normalize to raise , */ - Py_DECREF(value); 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); + if (PyInstance_Check(type)) { + type = (PyObject*) ((PyInstanceObject*)type)->in_class; 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; - } + } 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: @@ -8867,10 +10337,9 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) { Py_XDECREF(tb); return; } - #else /* Python 3+ */ - -static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) { +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)) { @@ -8880,7 +10349,6 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) { } if (value == Py_None) value = 0; - if (PyExceptionInstance_Check(type)) { if (value) { PyErr_SetString(PyExc_TypeError, @@ -8889,14 +10357,58 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) { } value = type; type = (PyObject*) Py_TYPE(value); - } else if (!PyExceptionClass_Check(type)) { + } else if (PyExceptionClass_Check(type)) { + 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 = PyEval_CallObject(type, args); + 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; @@ -8906,46 +10418,82 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) { Py_XDECREF(tmp_tb); } } - bad: + Py_XDECREF(owned_instance); return; } #endif -static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) { - PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); +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, - #if PY_VERSION_HEX < 0x02050000 - "need more than %d value%s to unpack", (int)index, - #else - "need more than %zd value%s to unpack", index, - #endif - (index == 1) ? "" : "s"); + "need more than %" CYTHON_FORMAT_SSIZE_T "d value%s to unpack", + index, (index == 1) ? "" : "s"); } -static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { - PyErr_Format(PyExc_ValueError, - #if PY_VERSION_HEX < 0x02050000 - "too many values to unpack (expected %d)", (int)expected); - #else - "too many values to unpack (expected %zd)", expected); - #endif +static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); +} + +static CYTHON_INLINE int __Pyx_IterFinish(void) { +#if CYTHON_COMPILING_IN_CPYTHON + PyThreadState *tstate = PyThreadState_GET(); + PyObject* exc_type = tstate->curexc_type; + if (unlikely(exc_type)) { + if (likely(exc_type == PyExc_StopIteration) || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)) { + PyObject *exc_value, *exc_tb; + exc_value = tstate->curexc_value; + exc_tb = tstate->curexc_traceback; + tstate->curexc_type = 0; + tstate->curexc_value = 0; + tstate->curexc_traceback = 0; + Py_DECREF(exc_type); + Py_XDECREF(exc_value); + Py_XDECREF(exc_tb); + return 0; + } else { + return -1; + } + } + return 0; +#else + if (unlikely(PyErr_Occurred())) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) { + PyErr_Clear(); + return 0; + } else { + return -1; + } + } + return 0; +#endif } -static void __Pyx_UnpackTupleError(PyObject *t, Py_ssize_t index) { - if (t == Py_None) { - __Pyx_RaiseNoneNotIterableError(); - } else if (PyTuple_GET_SIZE(t) < index) { - __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(t)); +static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) { + if (unlikely(retval)) { + Py_DECREF(retval); + __Pyx_RaiseTooManyValuesError(expected); + return -1; } else { - __Pyx_RaiseTooManyValuesError(index); + return __Pyx_IterFinish(); } + return 0; +} + +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 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; @@ -8953,9 +10501,12 @@ static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, 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; @@ -8967,18 +10518,23 @@ static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb) Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); +#else + PyErr_SetExcInfo(type, value, tb); +#endif } -static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list) { - PyObject *py_import = 0; +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; - py_import = __Pyx_GetAttrString(__pyx_b, "__import__"); + #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 { @@ -8993,22 +10549,68 @@ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list) { 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: - Py_XDECREF(empty_list); + #if PY_VERSION_HEX < 0x03030000 Py_XDECREF(py_import); + #endif + Py_XDECREF(empty_list); Py_XDECREF(empty_dict); return module; } static PyObject *__Pyx_FindPy2Metaclass(PyObject *bases) { PyObject *metaclass; - /* Default metaclass */ #if PY_MAJOR_VERSION < 3 if (PyTuple_Check(bases) && PyTuple_GET_SIZE(bases) > 0) { PyObject *base = PyTuple_GET_ITEM(bases, 0); - metaclass = PyObject_GetAttrString(base, "__class__"); + metaclass = __Pyx_PyObject_GetAttrStr(base, __pyx_n_s____class__); if (!metaclass) { PyErr_Clear(); metaclass = (PyObject*) Py_TYPE(base); @@ -9029,15 +10631,14 @@ static PyObject *__Pyx_FindPy2Metaclass(PyObject *bases) { } static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name, - PyObject *modname) { + PyObject *qualname, PyObject *modname) { PyObject *result; PyObject *metaclass; - - if (PyDict_SetItemString(dict, "__module__", modname) < 0) + if (PyDict_SetItem(dict, __pyx_n_s____module__, modname) < 0) return NULL; - - /* Python2 __metaclass__ */ - metaclass = PyDict_GetItemString(dict, "__metaclass__"); + if (PyDict_SetItem(dict, __pyx_n_s____qualname__, qualname) < 0) + return NULL; + metaclass = PyDict_GetItem(dict, __pyx_n_s____metaclass__); if (metaclass) { Py_INCREF(metaclass); } else { @@ -9068,7 +10669,7 @@ static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_int16_t(int16_t val) { } else { int one = 1; int little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; - return _PyLong_FromByteArray(bytes, sizeof(int16_t), + return _PyLong_FromByteArray(bytes, sizeof(int16_t), little, !is_unsigned); } } @@ -9093,12 +10694,12 @@ static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_int8_t(int8_t val) { } else { int one = 1; int little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; - return _PyLong_FromByteArray(bytes, sizeof(int8_t), + return _PyLong_FromByteArray(bytes, sizeof(int8_t), little, !is_unsigned); } } -#if PY_MAJOR_VERSION < 3 +#if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION < 3 static PyObject *__Pyx_GetStdout(void) { PyObject *f = PySys_GetObject((char *)"stdout"); if (!f) { @@ -9106,23 +10707,22 @@ static PyObject *__Pyx_GetStdout(void) { } return f; } - static int __Pyx_Print(PyObject* f, PyObject *arg_tuple, int newline) { - PyObject* v; 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) - return -1; + goto error; } v = PyTuple_GET_ITEM(arg_tuple, i); if (PyFile_WriteObject(v, f, Py_PRINT_RAW) < 0) - return -1; + goto error; if (PyString_Check(v)) { char *s = PyString_AsString(v); Py_ssize_t len = PyString_Size(v); @@ -9134,20 +10734,22 @@ static int __Pyx_Print(PyObject* f, PyObject *arg_tuple, int newline) { } if (newline) { if (PyFile_WriteString("\n", f) < 0) - return -1; + 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 = __Pyx_GetAttrString(__pyx_b, "print"); + __pyx_print = PyObject_GetAttr(__pyx_b, __pyx_n_s__print); if (!__pyx_print) return -1; } @@ -9155,13 +10757,13 @@ static int __Pyx_Print(PyObject* stream, PyObject *arg_tuple, int newline) { kwargs = PyDict_New(); if (unlikely(!kwargs)) return -1; - if (unlikely(PyDict_SetItemString(kwargs, "file", stream) < 0)) + 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_SetItemString(kwargs, "end", end_string) < 0) { + if (PyDict_SetItem(kwargs, __pyx_n_s__end, end_string) < 0) { Py_DECREF(end_string); goto bad; } @@ -9175,7 +10777,7 @@ static int __Pyx_Print(PyObject* stream, PyObject *arg_tuple, int newline) { end_string = PyUnicode_FromStringAndSize(" ", 1); if (unlikely(!end_string)) return -1; - if (PyDict_SetItemString(__pyx_print_kwargs, "end", end_string) < 0) { + if (PyDict_SetItem(__pyx_print_kwargs, __pyx_n_s__end, end_string) < 0) { Py_DECREF(end_string); return -1; } @@ -9195,44 +10797,42 @@ static int __Pyx_Print(PyObject* stream, PyObject *arg_tuple, int newline) { Py_XDECREF(kwargs); return -1; } - #endif -#if PY_MAJOR_VERSION < 3 - +#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) - return -1; + goto error; } if (PyFile_WriteObject(o, f, Py_PRINT_RAW) < 0) - return -1; + goto error; if (PyFile_WriteString("\n", f) < 0) - return -1; + goto error; + Py_DECREF(f); return 0; - /* the line below is just to avoid compiler - * compiler warnings about unused functions */ +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_New(1); + PyObject* arg_tuple = PyTuple_Pack(1, o); if (unlikely(!arg_tuple)) return -1; - Py_INCREF(o); - PyTuple_SET_ITEM(arg_tuple, 0, o); res = __Pyx_Print(stream, arg_tuple, 1); Py_DECREF(arg_tuple); return res; } - #endif static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_uint32_t(uint32_t val) { @@ -9255,7 +10855,7 @@ static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_uint32_t(uint32_t val) { } else { int one = 1; int little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; - return _PyLong_FromByteArray(bytes, sizeof(uint32_t), + return _PyLong_FromByteArray(bytes, sizeof(uint32_t), little, !is_unsigned); } } @@ -9690,10 +11290,15 @@ static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject* x) { return (int)__Pyx_PyInt_AsLong(x); } +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS +#include "longintrepr.h" +#endif +#endif static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject* x) { const unsigned long neg_one = (unsigned long)-1, const_zero = 0; const int is_unsigned = neg_one > const_zero; -#if PY_VERSION_HEX < 0x03000000 +#if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { @@ -9706,14 +11311,35 @@ static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject* x) { #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(unsigned long)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return (unsigned long) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif if (unlikely(Py_SIZE(x) < 0)) { PyErr_SetString(PyExc_OverflowError, "can't convert negative value to unsigned long"); return (unsigned long)-1; } - return PyLong_AsUnsignedLong(x); + return (unsigned long)PyLong_AsUnsignedLong(x); } else { - return PyLong_AsLong(x); +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(unsigned long)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return +(unsigned long) ((PyLongObject*)x)->ob_digit[0]; + case -1: return -(unsigned long) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + return (unsigned long)PyLong_AsLong(x); } } else { unsigned long val; @@ -9725,10 +11351,15 @@ static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject* x) { } } +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS +#include "longintrepr.h" +#endif +#endif static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject* x) { const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG)-1, const_zero = 0; const int is_unsigned = neg_one > const_zero; -#if PY_VERSION_HEX < 0x03000000 +#if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { @@ -9741,14 +11372,35 @@ static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObje #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(unsigned PY_LONG_LONG)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return (unsigned PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif if (unlikely(Py_SIZE(x) < 0)) { PyErr_SetString(PyExc_OverflowError, "can't convert negative value to unsigned PY_LONG_LONG"); return (unsigned PY_LONG_LONG)-1; } - return PyLong_AsUnsignedLongLong(x); + return (unsigned PY_LONG_LONG)PyLong_AsUnsignedLongLong(x); } else { - return PyLong_AsLongLong(x); +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(unsigned PY_LONG_LONG)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return +(unsigned PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + case -1: return -(unsigned PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + return (unsigned PY_LONG_LONG)PyLong_AsLongLong(x); } } else { unsigned PY_LONG_LONG val; @@ -9760,10 +11412,15 @@ static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObje } } +#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_AsLong(PyObject* x) { const long neg_one = (long)-1, const_zero = 0; const int is_unsigned = neg_one > const_zero; -#if PY_VERSION_HEX < 0x03000000 +#if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { @@ -9776,14 +11433,35 @@ static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject* x) { #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; } - return PyLong_AsUnsignedLong(x); + return (long)PyLong_AsUnsignedLong(x); } else { - return PyLong_AsLong(x); +#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 + return (long)PyLong_AsLong(x); } } else { long val; @@ -9795,10 +11473,15 @@ static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject* x) { } } +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS +#include "longintrepr.h" +#endif +#endif static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject* x) { const PY_LONG_LONG neg_one = (PY_LONG_LONG)-1, const_zero = 0; const int is_unsigned = neg_one > const_zero; -#if PY_VERSION_HEX < 0x03000000 +#if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { @@ -9811,14 +11494,35 @@ static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject* x) { #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(PY_LONG_LONG)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return (PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif if (unlikely(Py_SIZE(x) < 0)) { PyErr_SetString(PyExc_OverflowError, "can't convert negative value to PY_LONG_LONG"); return (PY_LONG_LONG)-1; } - return PyLong_AsUnsignedLongLong(x); + return (PY_LONG_LONG)PyLong_AsUnsignedLongLong(x); } else { - return PyLong_AsLongLong(x); +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(PY_LONG_LONG)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return +(PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + case -1: return -(PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + return (PY_LONG_LONG)PyLong_AsLongLong(x); } } else { PY_LONG_LONG val; @@ -9830,10 +11534,15 @@ static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject* x) { } } +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS +#include "longintrepr.h" +#endif +#endif static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject* x) { const signed long neg_one = (signed long)-1, const_zero = 0; const int is_unsigned = neg_one > const_zero; -#if PY_VERSION_HEX < 0x03000000 +#if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { @@ -9846,14 +11555,35 @@ static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject* x) { #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(signed long)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return (signed long) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif if (unlikely(Py_SIZE(x) < 0)) { PyErr_SetString(PyExc_OverflowError, "can't convert negative value to signed long"); return (signed long)-1; } - return PyLong_AsUnsignedLong(x); + return (signed long)PyLong_AsUnsignedLong(x); } else { - return PyLong_AsLong(x); +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(signed long)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return +(signed long) ((PyLongObject*)x)->ob_digit[0]; + case -1: return -(signed long) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + return (signed long)PyLong_AsLong(x); } } else { signed long val; @@ -9865,10 +11595,15 @@ static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject* x) { } } +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS +#include "longintrepr.h" +#endif +#endif static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject* x) { const signed PY_LONG_LONG neg_one = (signed PY_LONG_LONG)-1, const_zero = 0; const int is_unsigned = neg_one > const_zero; -#if PY_VERSION_HEX < 0x03000000 +#if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { @@ -9881,14 +11616,35 @@ static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject* #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(signed PY_LONG_LONG)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return (signed PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif if (unlikely(Py_SIZE(x) < 0)) { PyErr_SetString(PyExc_OverflowError, "can't convert negative value to signed PY_LONG_LONG"); return (signed PY_LONG_LONG)-1; } - return PyLong_AsUnsignedLongLong(x); + return (signed PY_LONG_LONG)PyLong_AsUnsignedLongLong(x); } else { - return PyLong_AsLongLong(x); +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(signed PY_LONG_LONG)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return +(signed PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + case -1: return -(signed PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + return (signed PY_LONG_LONG)PyLong_AsLongLong(x); } } else { signed PY_LONG_LONG val; @@ -9900,42 +11656,59 @@ static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject* } } -static void __Pyx_WriteUnraisable(const char *name) { - PyObject *old_exc, *old_val, *old_tb; - PyObject *ctx; - __Pyx_ErrFetch(&old_exc, &old_val, &old_tb); - #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 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, - long size, int strict) + 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; - #if PY_MAJOR_VERSION < 3 - py_name = PyString_FromString(class_name); - #else - py_name = PyUnicode_FromString(class_name); - #endif + py_name = __Pyx_PyIdentifier_FromString(class_name); if (!py_name) goto bad; result = PyObject_GetAttr(py_module, py_name); @@ -9951,17 +11724,29 @@ static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class module_name, class_name); goto bad; } - if (!strict && ((PyTypeObject *)result)->tp_basicsize > size) { +#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 - PyErr_Warn(NULL, warning); + if (PyErr_Warn(NULL, warning) < 0) goto bad; #else - PyErr_WarnEx(NULL, warning, 0); + if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad; #endif } - else if (((PyTypeObject *)result)->tp_basicsize != size) { + else if ((size_t)basicsize != size) { PyErr_Format(PyExc_ValueError, "%s.%s has the wrong size, try recompiling", module_name, class_name); @@ -9971,54 +11756,109 @@ static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class bad: Py_XDECREF(py_module); Py_XDECREF(result); - return 0; + return NULL; } #endif -#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; - - #if PY_MAJOR_VERSION < 3 - py_name = PyString_FromString(name); - #else - py_name = PyUnicode_FromString(name); - #endif - 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; +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, 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); } -#endif #include "compile.h" #include "frameobject.h" #include "traceback.h" - -static void __Pyx_AddTraceback(const char *funcname) { +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; - PyObject *py_globals = 0; - PyCodeObject *py_code = 0; - PyFrameObject *py_frame = 0; - #if PY_MAJOR_VERSION < 3 - py_srcfile = PyString_FromString(__pyx_filename); + py_srcfile = PyString_FromString(filename); #else - py_srcfile = PyUnicode_FromString(__pyx_filename); + py_srcfile = PyUnicode_FromString(filename); #endif if (!py_srcfile) goto bad; - if (__pyx_clineno) { + if (c_line) { #if PY_MAJOR_VERSION < 3 - py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno); + py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); #else - py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno); + py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); #endif } else { @@ -10029,28 +11869,45 @@ static void __Pyx_AddTraceback(const char *funcname) { #endif } if (!py_funcname) goto bad; - py_globals = PyModule_GetDict(__pyx_m); - if (!py_globals) goto bad; - py_code = PyCode_New( + py_code = __Pyx_PyCode_New( 0, /*int argcount,*/ - #if PY_MAJOR_VERSION >= 3 0, /*int kwonlyargcount,*/ - #endif 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,*/ + __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,*/ - __pyx_lineno, /*int firstlineno,*/ + py_line, /*int firstlineno,*/ __pyx_empty_bytes /*PyObject *lnotab*/ ); - if (!py_code) goto bad; + 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,*/ @@ -10058,11 +11915,9 @@ static void __Pyx_AddTraceback(const char *funcname) { 0 /*PyObject *locals*/ ); if (!py_frame) goto bad; - py_frame->f_lineno = __pyx_lineno; + py_frame->f_lineno = py_line; PyTraceBack_Here(py_frame); bad: - Py_XDECREF(py_srcfile); - Py_XDECREF(py_funcname); Py_XDECREF(py_code); Py_XDECREF(py_frame); } @@ -10097,26 +11952,82 @@ static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { return 0; } -/* Type Conversion Functions */ - +static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(char* c_str) { + return __Pyx_PyUnicode_FromStringAndSize(c_str, 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_DATA_SIZE(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 */ + { + char* result; + int r = PyBytes_AsStringAndSize(o, &result, length); + if (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_VERSION_HEX < 0x03000000 +#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_VERSION_HEX < 0x03000000 +#if PY_MAJOR_VERSION < 3 if (m && m->nb_int) { name = "int"; res = PyNumber_Int(x); @@ -10132,7 +12043,7 @@ static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) { } #endif if (res) { -#if PY_VERSION_HEX < 0x03000000 +#if PY_MAJOR_VERSION < 3 if (!PyInt_Check(res) && !PyLong_Check(res)) { #else if (!PyLong_Check(res)) { @@ -10150,7 +12061,6 @@ static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) { } return res; } - static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { Py_ssize_t ival; PyObject* x = PyNumber_Index(b); @@ -10159,7 +12069,6 @@ static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { 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) @@ -10173,14 +12082,12 @@ static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { return PyInt_FromSize_t(ival); #endif } - static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject* x) { unsigned PY_LONG_LONG val = __Pyx_PyInt_AsUnsignedLongLong(x); - if (unlikely(val == (unsigned PY_LONG_LONG)-1 && PyErr_Occurred())) { - return (size_t)-1; - } else if (unlikely(val != (unsigned PY_LONG_LONG)(size_t)val)) { - PyErr_SetString(PyExc_OverflowError, - "value too large to convert to size_t"); + if (unlikely(val != (unsigned PY_LONG_LONG)(size_t)val)) { + if ((val != (unsigned PY_LONG_LONG)-1) || !PyErr_Occurred()) + PyErr_SetString(PyExc_OverflowError, + "value too large to convert to size_t"); return (size_t)-1; } return (size_t)val; From e61d701e015d0eb8673c9b356bd62a403afeba9c Mon Sep 17 00:00:00 2001 From: Christian Emmerich Date: Tue, 7 Jan 2014 19:08:59 +0100 Subject: [PATCH 66/84] Fix cmake module include order Fix cpack user option on linux Separate cpack options for different generators and add tgz generator Add cmake config file Fixes #355 Signed-off-by: Benn Snyder --- CMakeLists.txt | 43 +++++++++++++++++++++++++------------- libfreenectConfig.cmake.in | 8 +++++++ 2 files changed, 37 insertions(+), 14 deletions(-) create mode 100644 libfreenectConfig.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 28a480d7..8d05157e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,12 +39,19 @@ set(PYTHON_EXECUTABLE "python2") PROJECT(libfreenect) +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/") + +# Find the host operating system and architecture +include (FindOS) +# Set up installation directories +include (SetupDirectories) + set (PROJECT_VER_MAJOR 0) set (PROJECT_VER_MINOR 4) set (PROJECT_VER_PATCH 1) -set (PROJECT_VER +set (PROJECT_VER "${PROJECT_VER_MAJOR}.${PROJECT_VER_MINOR}.${PROJECT_VER_PATCH}") -set (PROJECT_APIVER +set (PROJECT_APIVER "${PROJECT_VER_MAJOR}.${PROJECT_VER_MINOR}") OPTION(BUILD_AUDIO "Build audio support" OFF) @@ -58,20 +65,15 @@ OPTION(BUILD_AS3_SERVER "Build the Actionscript 3 Server Example" OFF) OPTION(BUILD_PYTHON "Build Python extension" OFF) OPTION(BUILD_OPENNI2_DRIVER "Build libfreenect driver for OpenNI2" OFF) IF(PROJECT_OS_LINUX) - OPTION(BUILD_CPACK "Build an RPM or DEB using CPack" OFF) + OPTION(BUILD_CPACK_DEB "Build an DEB using CPack" OFF) + OPTION(BUILD_CPACK_RPM "Build an RPM using CPack" OFF) + OPTION(BUILD_CPACK_TGZ "Build an TGZ using CPack" OFF) ENDIF(PROJECT_OS_LINUX) ###################################################################################### # Dependencies and Definitions ###################################################################################### -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/") - -# Find the host operating system and architecture -include (FindOS) -# Set up installation directories -include (SetupDirectories) - # Find packages needed to build library find_package(libusb-1.0 REQUIRED) @@ -93,7 +95,7 @@ else(WIN32) endif() ###################################################################################### -# CMake +# CMake ###################################################################################### SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin) @@ -177,13 +179,17 @@ configure_file( "${CMAKE_CURRENT_BINARY_DIR}/UninstallTarget.cmake" IMMEDIATE @ONLY) +# --- cmake config file --- +CONFIGURE_FILE(libfreenectConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/libfreenectConfig.cmake @ONLY) +INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libfreenectConfig.cmake DESTINATION share/${PROJECT_NAME}) + add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/UninstallTarget.cmake) # Create Debian/RPM Packages # after make, use "fakeroot cpack" in the build Dir to complete -IF ( BUILD_CPACK ) +IF ( BUILD_CPACK_TGZ OR BUILD_CPACK_DEB OR BUILD_CPACK_RPM ) set(CPACK_PACKAGE_DESCRIPTION "libfreenect for kinect") set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "libfreenect library for using kinect") set(CPACK_PACKAGE_NAME "libfreenect-dev") @@ -196,7 +202,16 @@ IF ( BUILD_CPACK ) set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VER_PATCH}) set(VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") - set(CPACK_GENERATOR "DEB;RPM;") + set(CPACK_GENERATOR "") + if (BUILD_CPACK_TGZ) + list(APPEND CPACK_GENERATOR "TGZ") + endif() + if (BUILD_CPACK_RPM) + list(APPEND CPACK_GENERATOR "RPM") + endif() + if (BUILD_CPACK_DEB) + list(APPEND CPACK_GENERATOR "DEB") + endif() set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}-${CMAKE_SYSTEM_PROCESSOR}") include(CPack) @@ -211,5 +226,5 @@ IF ( BUILD_CPACK ) INSTALL(FILES "GPL2" DESTINATION "share/doc/${CPACK_PACKAGE_NAME}") INSTALL(FILES "README.md" DESTINATION "share/doc/${CPACK_PACKAGE_NAME}") -ENDIF ( BUILD_CPACK ) +ENDIF ( ) diff --git a/libfreenectConfig.cmake.in b/libfreenectConfig.cmake.in new file mode 100644 index 00000000..d0d1aa12 --- /dev/null +++ b/libfreenectConfig.cmake.in @@ -0,0 +1,8 @@ +get_filename_component(CONFIG_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) + +set(FREENECT_INCLUDE_DIRS "${CONFIG_DIR}/../../@PROJECT_INCLUDE_INSTALL_DIR@") +set(FREENECT_RUNTIME_LIBRARY_DIRS "${CONFIG_DIR}/../../bin") +set(FREENECT_LIBRARY_DIRS "${CONFIG_DIR}/../../@PROJECT_LIBRARY_INSTALL_DIR@") +#/libfreenect.so.@PROJECT_VER@ +set(FREENECT_LIBRARIES "freenect") +set(FREENECT_VERSION "@PROJECT_VER@") From 43d44e9c0748454f6af47df1d90c8675a11884e6 Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Thu, 1 May 2014 23:07:21 -0400 Subject: [PATCH 67/84] FN_DEBUG: print read_register and read_cmos_register replies Signed-off-by: Benn Snyder --- src/flags.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/flags.c b/src/flags.c index 16bd94df..51cc9c82 100644 --- a/src/flags.c +++ b/src/flags.c @@ -55,14 +55,16 @@ int freenect_set_flag(freenect_device *dev, freenect_flag flag, freenect_flag_va return write_register(dev, reg, value); } - uint16_t reg = read_cmos_register(dev, 0x0106); - if (reg == UINT16_MAX) + uint16_t cmos_value = read_cmos_register(dev, 0x0106); + if (cmos_value == UINT16_MAX) + { return -1; + } if (value == FREENECT_ON) - reg |= flag; + cmos_value |= flag; else - reg &= ~flag; - return write_cmos_register(dev, 0x0106, reg); + cmos_value &= ~flag; + return write_cmos_register(dev, 0x0106, cmos_value); } typedef struct { @@ -145,11 +147,10 @@ FN_INTERNAL int send_cmd(freenect_device *dev, uint16_t cmd, void *cmdbuf, unsig FN_INTERNAL uint16_t read_register(freenect_device *dev, uint16_t reg) { freenect_context *ctx = dev->parent; - + uint16_t reply[2]; uint16_t cmd = fn_le16(reg); - - FN_DEBUG("read_register: 0x%04x =>\n", reg); + int res = send_cmd(dev, 0x02, &cmd, 2, reply, 4); if (res < 0) { @@ -159,6 +160,7 @@ FN_INTERNAL uint16_t read_register(freenect_device *dev, uint16_t reg) if (res != 4) FN_WARNING("read_register: send_cmd() returned %d [%04x %04x], 0000 expected\n", res, reply[0], reply[1]); + FN_DEBUG("read_register: 0x%04x => 0x%04x\n", reg, reply[1]); return reply[1]; } @@ -180,7 +182,7 @@ FN_INTERNAL int write_register(freenect_device *dev, uint16_t reg, uint16_t data } if (res != 2) FN_WARNING("write_register: send_cmd() returned %d [%04x %04x], 0000 expected\n", res, reply[0], reply[1]); - + return 0; } @@ -190,18 +192,19 @@ FN_INTERNAL uint16_t read_cmos_register(freenect_device *dev, uint16_t reg) freenect_context *ctx = dev->parent; uint16_t replybuf[0x200]; uint16_t cmdbuf[3]; - + cmdbuf[0] = 1; cmdbuf[1] = reg & 0x7fff; cmdbuf[2] = 0; - - FN_DEBUG("read_cmos_register: 0x%04x =>\n", reg); + int res = send_cmd(dev, 0x95, cmdbuf, 6, replybuf, 6); if (res < 0) { FN_ERROR("read_cmos_register: send_cmd() returned %d\n", res); return UINT16_MAX; } + + FN_DEBUG("read_cmos_register: 0x%04x => 0x%04x\n", reg, replybuf[2]); return replybuf[2]; } @@ -210,11 +213,11 @@ FN_INTERNAL int write_cmos_register(freenect_device *dev, uint16_t reg, uint16_t freenect_context *ctx = dev->parent; uint16_t replybuf[0x200]; uint16_t cmdbuf[3]; - + cmdbuf[0] = 1; cmdbuf[1] = reg | 0x8000; cmdbuf[2] = value; - + FN_DEBUG("write_cmos_register: 0x%04x <= 0x%02x\n", reg, value); int res = send_cmd(dev, 0x95, cmdbuf, 6, replybuf, 6); if (res < 0) From d09fcf96d4cc244b4401600dd3f0bfe3620d2097 Mon Sep 17 00:00:00 2001 From: Jonas Deitmerg Date: Fri, 2 May 2014 22:24:21 +0200 Subject: [PATCH 68/84] Fix fakenect not handling freenect_process_events_timeout There was no equivalent to freenect_process_events_timeout (core.c) in fakenect.c. The supplied fix might be crude, but it's better than fakenect not working at all. Signed-off-by: Jonas Deitmerg --- fakenect/fakenect.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fakenect/fakenect.c b/fakenect/fakenect.c index 65eceac0..a28af555 100644 --- a/fakenect/fakenect.c +++ b/fakenect/fakenect.c @@ -203,6 +203,11 @@ int freenect_process_events(freenect_context *ctx) return 0; } +int freenect_process_events_timeout(freenect_context *ctx, struct timeval *timeout) +{ + return freenect_process_events(ctx); +} + double freenect_get_tilt_degs(freenect_raw_tilt_state *state) { // NOTE: This is duped from tilt.c, this is the only function we need from there From a35642fefd533c6b21864cd3bab7fefb9f0e2f00 Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Sun, 4 May 2014 15:02:06 -0400 Subject: [PATCH 69/84] Update README.md and CMakeLists.txt for v0.4.2 Signed-off-by: Benn Snyder --- CMakeLists.txt | 2 +- README.md | 38 ++++++++++++++++++++++++++++---------- src/flags.c | 2 +- 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d05157e..091381e7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,7 +48,7 @@ include (SetupDirectories) set (PROJECT_VER_MAJOR 0) set (PROJECT_VER_MINOR 4) -set (PROJECT_VER_PATCH 1) +set (PROJECT_VER_PATCH 2) set (PROJECT_VER "${PROJECT_VER_MAJOR}.${PROJECT_VER_MINOR}.${PROJECT_VER_PATCH}") set (PROJECT_APIVER diff --git a/README.md b/README.md index f599e4f6..68f43421 100644 --- a/README.md +++ b/README.md @@ -35,16 +35,25 @@ For the examples, you'll need cd build cmake -L .. make - + # if you don't have `make` or don't want color output # cmake --build . -You can also specify a build with debug symbols: +For some newer Kinect models, audio must be enabled for tilt and LED control: + + cmake -L .. -DBUILD_AUDIO=ON + +You can specify a build with debug symbols: cmake -L .. -DCMAKE_BUILD_TYPE=debug # or with optimizations # cmake -L .. -DCMAKE_BUILD_TYPE=RelWithDebInfo +You can build .deb, .rpm, and/or .tgz packages with `cpack`: + + cmake .. -L -DBUILD_CPACK_DEB=ON -DBUILD_CPACK_RPM=ON -DBUILD_CPACK_TGZ=ON + cpack + ## OSX If you don't have a package manager, install [Homebrew](http://brew.sh/). @@ -55,11 +64,11 @@ For a manual build, see [the wiki](http://openkinect.org/wiki/Getting_Started#Ma brew install libfreenect # or get the very latest: # brew install --HEAD libfreenect - + ### MacPorts sudo port install git-core cmake libusb libtool - + Continue with [Fetch & Build](#fetch-build). @@ -76,12 +85,12 @@ Continue with this section for a manual build. sudo apt-get install git-core cmake pkg-config build-essential libusb-1.0-0-dev sudo adduser $USER video sudo adduser $USER plugdev # necessary? - + # only if you are building the examples: sudo apt-get install libglut3-dev libxmu-dev libxi-dev - + Continue with [Fetch & Build](#fetch-build). - + There is also a [debian branch](https://github.com/OpenKinect/libfreenect/tree/debian) for packaging purposes. ### Gentoo Linux @@ -127,6 +136,15 @@ Wrappers are not guaranteed to be API stable or up to date. For example, start with [demo_cv_async.py](https://gihub.com/OpenKinect/libfreenect/tree/master/wrappers/python/devmo_cv_async.py). +# Code Contributions + +In order of importance: + +- Make sure to sign commits: `git commit -s` +- Use a [feature branch](https://www.atlassian.com/git/workflows#!workflow-feature-branch) in your own fork and target master with pull requests +- Tab indentation, no trailing whitespace + + # Maintainers Ongoing Development and Maintenance by the OpenKinect Community @@ -158,16 +176,16 @@ 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: +you may: - Leave this header intact and distribute it under the same terms, accompanying it with the APACHE20 and GPL2 files, or - Delete the Apache 2.0 clause and accompany it with the GPL2 file, or -- Delete the GPL v2 clause and accompany it with the APACHE20 file +- 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. ``` diff --git a/src/flags.c b/src/flags.c index 51cc9c82..7036f487 100644 --- a/src/flags.c +++ b/src/flags.c @@ -218,7 +218,7 @@ FN_INTERNAL int write_cmos_register(freenect_device *dev, uint16_t reg, uint16_t cmdbuf[1] = reg | 0x8000; cmdbuf[2] = value; - FN_DEBUG("write_cmos_register: 0x%04x <= 0x%02x\n", reg, value); + FN_DEBUG("write_cmos_register: 0x%04x <= 0x%04x\n", reg, value); int res = send_cmd(dev, 0x95, cmdbuf, 6, replybuf, 6); if (res < 0) FN_ERROR("write_cmos_register: send_cmd() returned %d\n", res); From 3f705d5e81f811f2b8f43c55dc01935ea0685687 Mon Sep 17 00:00:00 2001 From: ofTheo Date: Fri, 9 May 2014 16:17:46 -0400 Subject: [PATCH 70/84] Use non-infinite timeouts for bulk tilt / led commands Reset the audio device before using it to ensure the commands can be sent correctly Fixes #390 Signed-off-by: Benn Snyder --- src/tilt.c | 10 +++++----- src/usb_libusb10.c | 9 +++++++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/tilt.c b/src/tilt.c index 4e7453b2..b0377888 100644 --- a/src/tilt.c +++ b/src/tilt.c @@ -62,7 +62,7 @@ int get_reply(libusb_device_handle* dev, freenect_context *ctx){ memset(buffer, 0, 512); int transferred = 0; int res = 0; - res = libusb_bulk_transfer(dev, 0x81, buffer, 512, &transferred, 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); } else if (transferred != 12) { @@ -112,12 +112,12 @@ int update_tilt_state_alt(freenect_device *dev){ unsigned char buffer[256]; memcpy(buffer, &cmd, 16); - res = libusb_bulk_transfer(dev->usb_audio.dev, 0x01, buffer, 16, &transferred, 0); + res = libusb_bulk_transfer(dev->usb_audio.dev, 0x01, buffer, 16, &transferred, 250); if (res != 0) { return res; } - res = libusb_bulk_transfer(dev->usb_audio.dev, 0x81, buffer, 256, &transferred, 0); // 104 bytes + res = libusb_bulk_transfer(dev->usb_audio.dev, 0x81, buffer, 256, &transferred, 250); // 104 bytes if (res != 0) { return res; } else { @@ -209,7 +209,7 @@ int freenect_set_tilt_degs_alt(freenect_device *dev, int tilt_degrees) unsigned char buffer[20]; memcpy(buffer, &cmd, 20); - res = libusb_bulk_transfer(dev->usb_audio.dev, 0x01, buffer, 20, &transferred, 0); + 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); return res; @@ -281,7 +281,7 @@ FN_INTERNAL int fnusb_set_led_alt(libusb_device_handle * dev, freenect_context * unsigned char buffer[20]; memcpy(buffer, &cmd, 20); - res = libusb_bulk_transfer(dev, 0x01, buffer, 20, &transferred, 0); + res = libusb_bulk_transfer(dev, 0x01, buffer, 20, &transferred, 100); if (res != 0) { FN_WARNING("fnusb_set_led_alt(): libusb_bulk_transfer failed: %d (transferred = %d)\n", res, transferred); return res; diff --git a/src/usb_libusb10.c b/src/usb_libusb10.c index 91850572..8afb6ca4 100644 --- a/src/usb_libusb10.c +++ b/src/usb_libusb10.c @@ -277,6 +277,14 @@ FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index) 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); + + 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); @@ -287,6 +295,7 @@ FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index) libusb_close(audioHandle); } } + } #else //Legacy: For older versions of libusb we use this approach which doesn't do well when multiple K4W or 1473 devices are attached to the system. //lets also set the LED ON From adf46c408e950901315bc0f98fd2631e712d8968 Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Sun, 11 May 2014 00:23:18 -0400 Subject: [PATCH 71/84] Standardize indentation in fnusb_open_subdevices Signed-off-by: Benn Snyder --- src/usb_libusb10.c | 326 ++++++++++++++++++++++++++------------------- 1 file changed, 189 insertions(+), 137 deletions(-) diff --git a/src/usb_libusb10.c b/src/usb_libusb10.c index 8afb6ca4..6ea6e5e1 100644 --- a/src/usb_libusb10.c +++ b/src/usb_libusb10.c @@ -221,7 +221,7 @@ FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index) dev->usb_audio.dev = NULL; #endif - libusb_device **devs; //pointer to pointer of device, used to retrieve a list of devices + 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) return -1; @@ -233,7 +233,8 @@ FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index) int res; struct libusb_device_descriptor desc; - for (i = 0; i < cnt; i++) { + for (i = 0; i < cnt; i++) + { int r = libusb_get_device_descriptor (devs[i], &desc); if (r < 0) continue; @@ -242,91 +243,96 @@ FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index) 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)) { + if ((ctx->enabled_subdevices & FREENECT_DEVICE_CAMERA) && !dev->usb_cam.dev && (desc.idProduct == PID_NUI_CAMERA || desc.idProduct == PID_K4W_CAMERA)) + { // If the index given by the user matches our camera index - if (nr_cam == index) { + if (nr_cam == index) + { res = libusb_open (devs[i], &dev->usb_cam.dev); - if (res < 0 || !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)){ - + 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 */ + // 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; - //lets also set the LED for non 1414 devices. - //this keeps the camera alive for some systems which get freezes. - //this code replaces keep_alive.c. As keep_alive.c didn't know which hub the connected audio device was on. - //fnusb_find_connected_audio_device needs libusb 1.0.18 or later though. - + // set the LED for non 1414 devices to keep the camera alive for some systems which get freezes + // this code replaces keep_alive.c, which didn't know which hub the connected audio device was on + // fnusb_find_connected_audio_device needs libusb 1.0.18 or later + #if defined(LIBUSB_API_VERSION) && (LIBUSB_API_VERSION >= 0x01000102) - 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); - - 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); - - 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); - } - } - } + 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); + + 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); + + 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); + } + } + } #else - //Legacy: For older versions of libusb we use this approach which doesn't do well when multiple K4W or 1473 devices are attached to the system. - //lets also set the LED ON - //this keeps the camera alive for some systems which get freezes - if( desc.idProduct == PID_K4W_CAMERA ){ - freenect_extra_keep_alive(PID_K4W_AUDIO); - }else{ - freenect_extra_keep_alive(PID_NUI_AUDIO); - } + // Legacy: for older versions of libusb we use this approach which doesn't do well when multiple K4W or 1473 devices are attached to the system. + // also set the LED ON to keep the camera alive for some systems which get freezes + freenect_extra_keep_alive((desc.idProduct == PID_K4W_CAMERA) ? PID_K4W_AUDIO : PID_NUI_AUDIO); #endif - #ifdef BUILD_AUDIO - //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); - } + // 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); + } #endif - - }else{ - /* The good old kinect that tilts and tweets */ + } + else + { + // The good old kinect that tilts and tweets ctx->zero_plane_res = 322; } - + #ifndef _WIN32 // Detach an existing kernel driver for the device res = libusb_kernel_driver_active(dev->usb_cam.dev, 0); - if (res == 1) { + if (res == 1) + { res = libusb_detach_kernel_driver(dev->usb_cam.dev, 0); - if (res < 0) { + if (res < 0) + { FN_ERROR("Could not detach kernel driver for camera: %d\n", res); libusb_close(dev->usb_cam.dev); dev->usb_cam.dev = NULL; @@ -335,99 +341,116 @@ FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index) } #endif res = libusb_claim_interface (dev->usb_cam.dev, 0); - if (res < 0) { + if (res < 0) + { FN_ERROR("Could not claim interface on camera: %d\n", res); libusb_close(dev->usb_cam.dev); dev->usb_cam.dev = NULL; break; } - if(desc.idProduct == PID_K4W_CAMERA){ + if (desc.idProduct == PID_K4W_CAMERA) + { res = libusb_set_interface_alt_setting(dev->usb_cam.dev, 0, 1); - if (res != 0) { - FN_ERROR("Failed to set alternate interface #1 for K4W: %d\n", res); - libusb_close(dev->usb_cam.dev); - dev->usb_cam.dev = NULL; - break; - } - + if (res != 0) + { + FN_ERROR("Failed to set alternate interface #1 for K4W: %d\n", res); + libusb_close(dev->usb_cam.dev); + dev->usb_cam.dev = NULL; + break; + } } - } else { + } + else + { nr_cam++; } } } - if(ctx->enabled_subdevices == FREENECT_DEVICE_CAMERA || res < 0) cnt = 0; - - // Search for the motor + if (ctx->enabled_subdevices == FREENECT_DEVICE_CAMERA || res < 0) + cnt = 0; - for (i = 0; i < cnt; i++) { + // Search for the motor + for (i = 0; i < cnt; i++) + { int r = libusb_get_device_descriptor (devs[i], &desc); if (r < 0) continue; if (desc.idVendor != VID_MICROSOFT) continue; - if ((ctx->enabled_subdevices & FREENECT_DEVICE_MOTOR) && !dev->usb_motor.dev && desc.idProduct == PID_NUI_MOTOR) { + if ((ctx->enabled_subdevices & FREENECT_DEVICE_MOTOR) && !dev->usb_motor.dev && desc.idProduct == PID_NUI_MOTOR) + { // If the index given by the user matches our camera index - if (nr_mot == index) { + if (nr_mot == index) + { res = libusb_open (devs[i], &dev->usb_motor.dev); - if (res < 0 || !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) { + 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; } - } else { + } + else + { nr_mot++; } } #ifdef BUILD_AUDIO - // TODO: check that the firmware has already been loaded; if not, upload firmware. // Search for the audio - if ((ctx->enabled_subdevices & FREENECT_DEVICE_AUDIO) && !dev->usb_audio.dev && (desc.idProduct == PID_NUI_AUDIO || fnusb_is_pid_k4w_audio(desc.idProduct))) { + if ((ctx->enabled_subdevices & FREENECT_DEVICE_AUDIO) && !dev->usb_audio.dev && (desc.idProduct == PID_NUI_AUDIO || fnusb_is_pid_k4w_audio(desc.idProduct))) + { // If the index given by the user matches our audio index - - if (nr_audio == index) { + if (nr_audio == index) + { res = libusb_open (devs[i], &dev->usb_audio.dev); - if (res < 0 || !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; } res = libusb_claim_interface (dev->usb_audio.dev, 0); - if (res < 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; } - + // 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 + // 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{ - + 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) { + if (res < 0) + { FN_ERROR("Failed to retrieve serial number for audio device in bootloader state\n"); break; } @@ -435,20 +458,24 @@ FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index) 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 (res < 0) { + // 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 (res < 0) + { FN_ERROR("upload_firmware failed: %d\n", res); break; } @@ -456,20 +483,23 @@ FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index) dev->usb_audio.dev = NULL; // Wait for the device to reappear. int loops = 0; - for (loops = 0; loops < 10; loops++) { // Loop for at most 10 tries. + for (loops = 0; loops < 10; loops++) + { 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) { + 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 (new_dev_desc.idVendor == VID_MICROSOFT && (new_dev_desc.idProduct == PID_NUI_AUDIO || fnusb_is_pid_k4w_audio(desc.idProduct))) { + if (new_dev_desc.idVendor == VID_MICROSOFT && (new_dev_desc.idProduct == PID_NUI_AUDIO || fnusb_is_pid_k4w_audio(desc.idProduct))) + { FN_SPEW("Matched VID/PID!\n"); libusb_device_handle* new_dev_handle; // Open device @@ -478,16 +508,19 @@ FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index) continue; // Read serial r = libusb_get_string_descriptor_ascii(new_dev_handle, new_dev_desc.iSerialNumber, string_desc, 256); - if (r < 0) { + 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) { + 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) { + 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); @@ -495,21 +528,27 @@ FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index) } // 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"); + + 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 { + } + else + { FN_SPEW("Got serial %s, expected serial %s\n", (char*)string_desc, audio_serial); } } @@ -524,44 +563,57 @@ FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index) } free(audio_serial); } - } else { + } + else + { nr_audio++; } } #endif - } libusb_free_device_list (devs, 1); // free the list, unref the devices in it // Check that each subdevice is either opened or not enabled. - if ( (dev->usb_cam.dev || !(ctx->enabled_subdevices & FREENECT_DEVICE_CAMERA)) + if ((dev->usb_cam.dev || !(ctx->enabled_subdevices & FREENECT_DEVICE_CAMERA)) && (dev->usb_motor.dev || !(ctx->enabled_subdevices & FREENECT_DEVICE_MOTOR)) #ifdef BUILD_AUDIO && (dev->usb_audio.dev || !(ctx->enabled_subdevices & FREENECT_DEVICE_AUDIO)) #endif - ) { + ) + { return 0; - } else { - if (dev->usb_cam.dev) { + } + else + { + if (dev->usb_cam.dev) + { libusb_release_interface(dev->usb_cam.dev, 0); libusb_close(dev->usb_cam.dev); - } else { + } + else + { FN_ERROR("Failed to open camera subdevice or it is not disabled."); } - if (dev->usb_motor.dev) { + if (dev->usb_motor.dev) + { libusb_release_interface(dev->usb_motor.dev, 0); libusb_close(dev->usb_motor.dev); - } else { + } + else + { FN_ERROR("Failed to open motor subddevice or it is not disabled."); } #ifdef BUILD_AUDIO - if (dev->usb_audio.dev) { + if (dev->usb_audio.dev) + { libusb_release_interface(dev->usb_audio.dev, 0); libusb_close(dev->usb_audio.dev); - } else { + } + else + { FN_ERROR("Failed to open audio subdevice or it is not disabled."); } #endif From 248795a35e45eb28678fc102f9e58c4cf7f78590 Mon Sep 17 00:00:00 2001 From: Denis Bakunovitch Date: Sat, 17 May 2014 19:59:38 +0300 Subject: [PATCH 72/84] ebuild: Improve python dependency - fixes #391 Signed-off-by: Benn Snyder --- platform/linux/portage/dev-libs/libfreenect/Manifest | 2 +- .../portage/dev-libs/libfreenect/libfreenect-9999.ebuild | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/platform/linux/portage/dev-libs/libfreenect/Manifest b/platform/linux/portage/dev-libs/libfreenect/Manifest index 6c1da4bb..29a11c30 100644 --- a/platform/linux/portage/dev-libs/libfreenect/Manifest +++ b/platform/linux/portage/dev-libs/libfreenect/Manifest @@ -1 +1 @@ -EBUILD libfreenect-9999.ebuild 2110 SHA256 56a16645d035372f181c5e79005a2806adaeec7f816fbd11f6004c3af7f2e3b7 SHA512 1f634aae56466cd32c3abf7c1989c285612a454b0eb55b6a67fd82c951981d44f7d53f78de79968f59c454da6c8a60c08f4b3833777f91328345a865b7958179 WHIRLPOOL 9bdc6ec18fdaa58b7cee7b5a1346c1a02df3bd6dd0367fbe5218285c800de7c8651877054c21bf66587ec449e9fe3bfac7a0eddc5db65f36bb63b2e2c5851b2d +EBUILD libfreenect-9999.ebuild 2103 SHA256 fe79a2a0fbabeb2c2a85e88569c005f74034539fb28243f5a2b6ed3ee71d8910 SHA512 ac6f45f6100f8174e825cae913597cd4c959f28ca60dc2c49b4ca345f6881666bf5dbb0da619d1258041307e618e5344b9fe7cb837847a7dee1b16311ad797ec WHIRLPOOL dc5266930ce5aa5f7918de230e0822dd93055e07f75e3bf210dddfef2e563b273518269ac17f5cc905e0428c59492c31e05ba5d8d2698d47a46f20804408b3cc diff --git a/platform/linux/portage/dev-libs/libfreenect/libfreenect-9999.ebuild b/platform/linux/portage/dev-libs/libfreenect/libfreenect-9999.ebuild index 48e69ecb..8849c708 100644 --- a/platform/linux/portage/dev-libs/libfreenect/libfreenect-9999.ebuild +++ b/platform/linux/portage/dev-libs/libfreenect/libfreenect-9999.ebuild @@ -4,7 +4,7 @@ EAPI="5" -inherit cmake-utils git-2 multilib +inherit cmake-utils git-2 multilib python DESCRIPTION="Core library for accessing the Microsoft Kinect." @@ -16,6 +16,8 @@ SLOT="0" KEYWORDS="" IUSE="audio bindist +c_sync +cpp doc examples fakenect opencv openni2 python" +PYTHON_DEPEND="audio? 2" + COMMON_DEP="virtual/libusb:1 examples? ( media-libs/freeglut virtual/opengl @@ -25,10 +27,9 @@ COMMON_DEP="virtual/libusb:1 python? ( dev-python/numpy )" RDEPEND="${COMMON_DEP}" -DEPEND= "${COMMON_DEP} +DEPEND="${COMMON_DEP} dev-util/cmake virtual/pkgconfig - audio? ( dev-lang/python-2* ) doc? ( app-doc/doxygen ) python? ( dev-python/cython )" From 52d5e20327ff8fdeaa0cdbb5ea310ddaede903c8 Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Sun, 18 May 2014 12:11:36 -0400 Subject: [PATCH 73/84] win32: Fix command in examples/CMakeLists.txt Signed-off-by: Benn Snyder --- examples/CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index c07f4a7d..fb915a17 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -12,8 +12,7 @@ if (WIN32) set(THREADS_USE_PTHREADS_WIN32 true) find_package(Threads REQUIRED) include_directories(${THREADS_PTHREADS_INCLUDE_DIR}) - - set_source_file_properties(${SRC_ALL} PROPERTIES LANGUAGE CXX) + set_source_files_properties(${SRC_ALL} PROPERTIES LANGUAGE CXX) endif() add_executable(freenect-glview glview.c) From 9b671cd7210d16d330a88c7f4e80ce48f42d013e Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Sun, 18 May 2014 12:38:10 -0400 Subject: [PATCH 74/84] Update CMakeLists.txt for v0.4.3 Signed-off-by: Benn Snyder --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 091381e7..441e66fc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,7 +48,7 @@ include (SetupDirectories) set (PROJECT_VER_MAJOR 0) set (PROJECT_VER_MINOR 4) -set (PROJECT_VER_PATCH 2) +set (PROJECT_VER_PATCH 3) set (PROJECT_VER "${PROJECT_VER_MAJOR}.${PROJECT_VER_MINOR}.${PROJECT_VER_PATCH}") set (PROJECT_APIVER From 213c39a6cbc35b6042a3da03125c11602d4a8c76 Mon Sep 17 00:00:00 2001 From: Jocelyn Turcotte Date: Mon, 23 Jun 2014 11:03:50 +0200 Subject: [PATCH 75/84] Allow freenect_set_tilt_degs to take a negative angle I can't set a negative angle using gcc 4.8.2 for ARM since negative double values get clamped to 0x0 when casted to uint16_t, as one would expect. Oddly it works on a x86_64 build. Fix the issue by casting the double to int16_t instead. Signed-off-by: Jocelyn Turcotte --- src/tilt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tilt.c b/src/tilt.c index b0377888..1d470e3c 100644 --- a/src/tilt.c +++ b/src/tilt.c @@ -239,7 +239,7 @@ int freenect_set_tilt_degs(freenect_device *dev, double angle) angle = (angleMAX_TILT_ANGLE) ? MAX_TILT_ANGLE : angle); angle = angle * 2; - ret = fnusb_control(&dev->usb_motor, 0x40, 0x31, (uint16_t)angle, 0x0, empty, 0x0); + ret = fnusb_control(&dev->usb_motor, 0x40, 0x31, (int16_t)angle, 0x0, empty, 0x0); return ret; } From 47301ac9803176ced29d7855a08f17011b4f9e95 Mon Sep 17 00:00:00 2001 From: Robert Xiao Date: Wed, 2 Jul 2014 20:17:37 -0400 Subject: [PATCH 76/84] Cleanup imports in examples; also fixes a micview compile error on OS X. Note that gl.h and glu.h are always included in glut.h, and thus do not need to be included again. Signed-off-by: Robert Xiao --- examples/chunkview.c | 4 ---- examples/glpclview.c | 7 +------ examples/glview.c | 4 ---- examples/hiview.c | 4 ---- examples/micview.c | 5 +++++ examples/regview.c | 6 +----- 6 files changed, 7 insertions(+), 23 deletions(-) diff --git a/examples/chunkview.c b/examples/chunkview.c index 92e89426..71c7dfa7 100644 --- a/examples/chunkview.c +++ b/examples/chunkview.c @@ -35,12 +35,8 @@ #if defined(__APPLE__) #include -#include -#include #else #include -#include -#include #endif #include diff --git a/examples/glpclview.c b/examples/glpclview.c index 40b59c42..3b89cb66 100644 --- a/examples/glpclview.c +++ b/examples/glpclview.c @@ -30,18 +30,13 @@ #include "libfreenect_sync.h" #include #include +#include #if defined(__APPLE__) #include -#include -#include #else #include -#include -#include #endif -#include -#include int window; GLuint gl_rgb_tex; diff --git a/examples/glview.c b/examples/glview.c index 4ec6d489..bfdbb561 100644 --- a/examples/glview.c +++ b/examples/glview.c @@ -35,12 +35,8 @@ #if defined(__APPLE__) #include -#include -#include #else #include -#include -#include #endif #include diff --git a/examples/hiview.c b/examples/hiview.c index 40080099..0143ce60 100644 --- a/examples/hiview.c +++ b/examples/hiview.c @@ -35,12 +35,8 @@ #if defined(__APPLE__) #include -#include -#include #else #include -#include -#include #endif #include diff --git a/examples/micview.c b/examples/micview.c index 8d698329..fde49cd5 100644 --- a/examples/micview.c +++ b/examples/micview.c @@ -30,7 +30,12 @@ #include #include #include + +#if defined(__APPLE__) +#include +#else #include +#endif pthread_t freenect_thread; volatile int die = 0; diff --git a/examples/regview.c b/examples/regview.c index 7bbfd758..79f2f126 100644 --- a/examples/regview.c +++ b/examples/regview.c @@ -32,18 +32,14 @@ #include "libfreenect.h" #include +#include #if defined(__APPLE__) #include -#include -#include #else #include -#include -#include #endif -#include pthread_t freenect_thread; volatile int die = 0; From 8dd518540075f32f58554d503945e862bad9d374 Mon Sep 17 00:00:00 2001 From: Robert Xiao Date: Wed, 2 Jul 2014 19:33:48 -0400 Subject: [PATCH 77/84] Fix a crash-on-exit in the OpenNI2 driver caused by using a deleted iterator. Signed-off-by: Robert Xiao --- OpenNI2-FreenectDriver/src/DeviceDriver.cpp | 51 ++++++++++++--------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/OpenNI2-FreenectDriver/src/DeviceDriver.cpp b/OpenNI2-FreenectDriver/src/DeviceDriver.cpp index c308b463..a6cfe025 100644 --- a/OpenNI2-FreenectDriver/src/DeviceDriver.cpp +++ b/OpenNI2-FreenectDriver/src/DeviceDriver.cpp @@ -210,7 +210,20 @@ namespace FreenectDriver class Driver : public oni::driver::DriverBase, private Freenect::Freenect { private: - std::map devices; + typedef std::map OniDeviceMap; + OniDeviceMap devices; + + static std::string devid_to_uri(int id) { + return "freenect://" + to_string(id); + } + + static int uri_to_devid(const std::string uri) { + int id; + std::istringstream is(uri); + is.seekg(strlen("freenect://")); + is >> id; + return id; + } public: Driver(OniDriverServices* pDriverServices) : DriverBase(pDriverServices) @@ -230,8 +243,8 @@ namespace FreenectDriver DriverBase::initialize(connectedCallback, disconnectedCallback, deviceStateChangedCallback, pCookie); for (int i = 0; i < Freenect::deviceCount(); i++) { - std::string uri = "freenect://" + to_string(i); - + std::string uri = devid_to_uri(i); + WriteMessage("Found device " + uri); OniDeviceInfo info; @@ -247,7 +260,7 @@ namespace FreenectDriver oni::driver::DeviceBase* deviceOpen(const char* uri, const char* mode = NULL) { - for (std::map::iterator iter = devices.begin(); iter != devices.end(); iter++) + for (OniDeviceMap::iterator iter = devices.begin(); iter != devices.end(); iter++) { if (strcmp(iter->first.uri, uri) == 0) // found { @@ -258,11 +271,7 @@ namespace FreenectDriver else { WriteMessage("Opening device " + std::string(uri)); - - unsigned int id; - std::istringstream is(iter->first.uri); - is.seekg(strlen("freenect://")); - is >> id; + int id = uri_to_devid(iter->first.uri); Device* device = &createDevice(id); iter->second = device; return device; @@ -276,24 +285,16 @@ namespace FreenectDriver void deviceClose(oni::driver::DeviceBase* pDevice) { - for (std::map::iterator iter = devices.begin(); iter != devices.end();) + for (OniDeviceMap::iterator iter = devices.begin(); iter != devices.end(); iter++) { if (iter->second == pDevice) { WriteMessage("Closing device " + std::string(iter->first.uri)); - - unsigned int id; - std::istringstream is(std::string(iter->first.uri)); - is.seekg(strlen("freenect://")); - is >> id; - devices.erase(iter++); + int id = uri_to_devid(iter->first.uri); + devices.erase(iter); deleteDevice(id); return; } - else - { - iter++; - } } LogError("Could not close unrecognized device"); @@ -310,8 +311,14 @@ namespace FreenectDriver void shutdown() { - for (std::map::iterator iter = devices.begin(); iter != devices.end(); iter++) - deviceClose(iter->second); + for (OniDeviceMap::iterator iter = devices.begin(); iter != devices.end(); iter++) + { + WriteMessage("Closing device " + std::string(iter->first.uri)); + int id = uri_to_devid(iter->first.uri); + deleteDevice(id); + } + + devices.clear(); } From d071095a3e671c47ffbab4580a620edb33fb9ee4 Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Mon, 14 Jul 2014 22:11:55 -0400 Subject: [PATCH 78/84] c_sync: Add freenect_sync_camera_to_world() (thanks @martyvona) - fixes #294 Signed-off-by: Benn Snyder --- wrappers/c_sync/libfreenect_sync.c | 8 ++++++++ wrappers/c_sync/libfreenect_sync.h | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/wrappers/c_sync/libfreenect_sync.c b/wrappers/c_sync/libfreenect_sync.c index 6fe55bd7..0268f660 100644 --- a/wrappers/c_sync/libfreenect_sync.c +++ b/wrappers/c_sync/libfreenect_sync.c @@ -28,6 +28,7 @@ #include #include #include +#include "libfreenect_registration.h" #include "libfreenect_sync.h" typedef struct buffer_ring { @@ -402,6 +403,13 @@ int freenect_sync_set_led(freenect_led_options led, int index) { return 0; } +int freenect_sync_camera_to_world(int cx, int cy, int wz, double* wx, double* wy, int index) { + if (runloop_enter(index)) return -1; + freenect_camera_to_world(kinects[index]->dev, cx, cy, wz, wx, wy); + runloop_exit(); + return 0; +} + void freenect_sync_stop(void) { if (thread_running) { diff --git a/wrappers/c_sync/libfreenect_sync.h b/wrappers/c_sync/libfreenect_sync.h index 516c421d..8a3b68dc 100644 --- a/wrappers/c_sync/libfreenect_sync.h +++ b/wrappers/c_sync/libfreenect_sync.h @@ -113,6 +113,11 @@ FREENECTAPI_SYNC int freenect_sync_set_led(freenect_led_options led, int index); Nonzero on error. */ +FREENECTAPI_SYNC int freenect_sync_camera_to_world(int cx, int cy, int wz, double* wx, double* wy, int index); +/* Camera to world mapping, starts the runloop if it isn't running + + Wraps libfreenect_registration.h function of same name. +*/ FREENECTAPI_SYNC void freenect_sync_stop(void); #ifdef __cplusplus From 88aba0a037d234635dda26d40a108e54f2284004 Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Mon, 14 Jul 2014 21:31:47 -0600 Subject: [PATCH 79/84] Remove legacy keep_alive.c; now require libusb >= 1.0.18 Signed-off-by: Benn Snyder --- README.md | 2 +- src/CMakeLists.txt | 2 +- src/freenect_internal.h | 4 +- src/keep_alive.c | 204 ---------------------------------------- src/keep_alive.h | 31 ------ src/usb_libusb10.c | 12 --- 6 files changed, 4 insertions(+), 251 deletions(-) delete mode 100644 src/keep_alive.c delete mode 100644 src/keep_alive.h diff --git a/README.md b/README.md index 68f43421..67547f18 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Audio is a work in progress. To build libfreenect, you'll need -- [libusb](http://libusb.info) >= 1.0.13 +- [libusb](http://libusb.info) >= 1.0.18 - [CMake](http://cmake.org) >= 2.6 - [python](http://python.org) == 2.* (only if BUILD_AUDIO or BUILD_PYTHON) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 068f803d..a4aec9c1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -5,7 +5,7 @@ include_directories (${CMAKE_CURRENT_SOURCE_DIR}) include_directories(${LIBUSB_1_INCLUDE_DIRS}) -LIST(APPEND SRC core.c tilt.c cameras.c flags.c usb_libusb10.c registration.c keep_alive.c) +LIST(APPEND SRC core.c tilt.c cameras.c flags.c usb_libusb10.c registration.c) IF(WIN32) set_source_files_properties(${SRC} PROPERTIES LANGUAGE CXX) ENDIF(WIN32) diff --git a/src/freenect_internal.h b/src/freenect_internal.h index 729aa9fe..60df715f 100644 --- a/src/freenect_internal.h +++ b/src/freenect_internal.h @@ -45,7 +45,7 @@ typedef void (*fnusb_iso_cb)(freenect_device *dev, uint8_t *buf, int len); #include "usb_libusb10.h" -//needed to set the led state for non 1414 devices - replaces keep_alive.c +// needed to set the led state for non 1414 devices FN_INTERNAL int fnusb_set_led_alt(libusb_device_handle * dev, freenect_context * ctx, freenect_led_options state); struct _freenect_context { @@ -56,7 +56,7 @@ struct _freenect_context { freenect_device *first; int zero_plane_res; - //if you want to load firmware from memory rather than disk + // if you want to load firmware from memory rather than disk unsigned char * fn_fw_nui_ptr; unsigned int fn_fw_nui_size; diff --git a/src/keep_alive.c b/src/keep_alive.c deleted file mode 100644 index 3e372775..00000000 --- a/src/keep_alive.c +++ /dev/null @@ -1,204 +0,0 @@ -// -// keep_alive.c -// Created by Theodore Watson on 1/23/14. - -//This file is part of the OpenKinect Project. http://www.openkinect.org -// -// Copyright (c) 2010 individual OpenKinect contributors. See the CONTRIB file -// for details. -// -// This code is licensed to you under the terms of the Apache License, version -// 2.0, or, at your option, the terms of the GNU General Public License, -// version 2.0. See the APACHE20 and GPL20 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 GPL20 file, or -// 3) Delete the GPL v2.0 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. - - -//Based on code provided by Drew Fisher - -/* - * Copyright 2011 Drew Fisher . All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ''AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL DREW FISHER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are - * those of the authors and should not be interpreted as representing official - * policies, either expressed or implied, of Drew Fisher. - */ -#include "keep_alive.h" -#include "freenect_internal.h" - -#include -#include -#include -#include -#include -#include // For usleep() - -#define le32(X) (X) -#define LOG(...) fprintf(stderr, __VA_ARGS__) - -static uint32_t tag_seq = 1; -static uint32_t tag_next_ack = 1; - -typedef struct { - uint32_t magic; - uint32_t tag; - uint32_t status; -} motor_reply; - -typedef struct { - uint32_t magic; - uint32_t tag; - uint32_t arg1; - uint32_t cmd; - uint32_t arg2; -} motor_command; - -static int get_reply(libusb_device_handle* dev){ - unsigned char buffer[512]; - memset(buffer, 0, 512); - int transferred = 0; - int res = 0; - res = libusb_bulk_transfer(dev, 0x81, buffer, 512, &transferred, 0); - if (res != 0) { - LOG("freenect_extra_keep_alive get_reply(): libusb_bulk_transfer failed: %d (transferred = %d)\n", res, transferred); - } else if (transferred != 12) { - LOG("freenect_extra_keep_alive get_reply(): weird - got %d bytes (expected 12)\n", transferred); - } else { - motor_reply reply; - memcpy(&reply, buffer, sizeof(reply)); - if (reply.magic != 0x0a6fe000) { - LOG("freenect_extra_keep_alive Bad magic: %08X (expected 0A6FE000\n", reply.magic); - res = -1; - } - if (reply.tag != tag_next_ack) { - LOG("freenect_extra_keep_alive Reply tag out of order: expected %d, got %d\n", tag_next_ack, reply.tag); - res = -1; - } - if (reply.status != 0) { - LOG("freenect_extra_keep_alive reply status != 0: failure?\n"); - res = -1; - } - tag_next_ack++; -// LOG("freenect_extra_keep_alive get_reply(): got %d bytes:", transferred); -// int i; -// for (i = 0; i < transferred; i++) { -// LOG(" %02X", buffer[i]); -// } -// LOG("\n"); - } - return res; -} - -static int set_led(libusb_device_handle* dev, int state) { - int transferred = 0; - int res = 0; - motor_command cmd; - cmd.magic = le32(0x06022009); - cmd.tag = le32(tag_seq++); - cmd.arg1 = le32(0); - cmd.cmd = le32(0x10); - cmd.arg2 = (uint32_t)(le32((int32_t)state)); - unsigned char buffer[20]; - memcpy(buffer, &cmd, 20); - // Send command to set LED to solid green -// LOG("About to send bulk transfer:"); -// int i; -// for(i = 0; i < 20 ; i++) { -// LOG(" %02X", buffer[i]); -// } -// LOG("\n"); - res = libusb_bulk_transfer(dev, 0x01, buffer, 20, &transferred, 0); - if (res != 0) { - LOG("freenect_extra_keep_alive set_led(): libusb_bulk_transfer failed: %d (transferred = %d)\n", res, transferred); - return res; - } - return get_reply(dev); -} - -//this is for K4W or 1473 devices - pass in the PID of the audio device that needs the LED set. -void freenect_extra_keep_alive(int pid){ - - int res; - int state_to_set = 3; - - libusb_context* ctx = NULL; - libusb_init(&ctx); - - libusb_device_handle* dev = NULL; - - //check the default audio device - dev = libusb_open_device_with_vid_pid(ctx, 0x045e, pid); - - //K4W only: - //if the firmware is uploaded the device could have a two different PIDs based on which firmware was uploaded. - //so we have to check for both - //note: it might be better if we pass in the PID of the camera and then find the audio device that is in the same usb tree/hub - might be more reliable when multiple devices are plugged in - if( dev == NULL && pid == PID_K4W_AUDIO ){ - pid = PID_K4W_AUDIO_ALT_1; - dev = libusb_open_device_with_vid_pid(ctx, 0x045e, pid); - } - if( dev == NULL && pid == PID_K4W_AUDIO_ALT_1 ){ - pid = PID_K4W_AUDIO_ALT_2; - dev = libusb_open_device_with_vid_pid(ctx, 0x045e, pid); - } - - if(dev == NULL) { - LOG("freenect extra keepAlive: Failed to open audio device\n"); - libusb_exit(ctx); - return; - } - - res = libusb_claim_interface(dev, 0); - if (res != 0) { - LOG("freenect extra keepAlive: Failed to claim interface 1: %d\n", res); - libusb_close(dev); - libusb_exit(ctx); - return; - } - - res = set_led(dev, state_to_set); - if (res != 0) { - LOG("freenect extra keepAlive: set_led failed\n"); - libusb_close(dev); - libusb_exit(ctx); - return; - } - - libusb_close(dev); - libusb_exit(ctx); -} diff --git a/src/keep_alive.h b/src/keep_alive.h deleted file mode 100644 index 61123129..00000000 --- a/src/keep_alive.h +++ /dev/null @@ -1,31 +0,0 @@ -// keep_alive.h -// -// Created by Theodore Watson on 1/23/14. - -//This file is part of the OpenKinect Project. http://www.openkinect.org -// -// Copyright (c) 2010 individual OpenKinect contributors. See the CONTRIB file -// for details. -// -// This code is licensed to you under the terms of the Apache License, version -// 2.0, or, at your option, the terms of the GNU General Public License, -// version 2.0. See the APACHE20 and GPL20 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 GPL20 file, or -// 3) Delete the GPL v2.0 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. - - -#pragma once -void freenect_extra_keep_alive(int pid); - diff --git a/src/usb_libusb10.c b/src/usb_libusb10.c index 6ea6e5e1..468c69bc 100644 --- a/src/usb_libusb10.c +++ b/src/usb_libusb10.c @@ -31,7 +31,6 @@ #include #include "freenect_internal.h" #include "loader.h" -#include "keep_alive.h" #ifdef _MSC_VER # define sleep(x) Sleep((x)*1000) @@ -168,8 +167,6 @@ FN_INTERNAL int fnusb_is_pid_k4w_audio(int pid) return (pid == PID_K4W_AUDIO || pid == PID_K4W_AUDIO_ALT_1 || pid == PID_K4W_AUDIO_ALT_2); } -// fnusb_find_connected_audio_device uses new libusb features. we use guards to make sure its backwards compatible with older versions of libusb -#if defined(LIBUSB_API_VERSION) && (LIBUSB_API_VERSION >= 0x01000102) FN_INTERNAL libusb_device * fnusb_find_connected_audio_device(libusb_device * camera, libusb_device ** deviceList, int cnt){ int cameraBusNo = libusb_get_bus_number(camera); @@ -203,7 +200,6 @@ FN_INTERNAL libusb_device * fnusb_find_connected_audio_device(libusb_device * ca return NULL; } -#endif FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index) { @@ -266,10 +262,7 @@ FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index) 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 - // this code replaces keep_alive.c, which didn't know which hub the connected audio device was on - // fnusb_find_connected_audio_device needs libusb 1.0.18 or later -#if defined(LIBUSB_API_VERSION) && (LIBUSB_API_VERSION >= 0x01000102) libusb_device * audioDevice = fnusb_find_connected_audio_device(devs[i], devs, cnt); if (audioDevice != NULL) { @@ -304,11 +297,6 @@ FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index) } } } -#else - // Legacy: for older versions of libusb we use this approach which doesn't do well when multiple K4W or 1473 devices are attached to the system. - // also set the LED ON to keep the camera alive for some systems which get freezes - freenect_extra_keep_alive((desc.idProduct == PID_K4W_CAMERA) ? PID_K4W_AUDIO : PID_NUI_AUDIO); -#endif #ifdef BUILD_AUDIO // for newer devices we need to enable the audio device for motor control From fb2b0562d461ee4ce5fbb60382b19821b1b6b724 Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Fri, 18 Jul 2014 19:37:46 -0600 Subject: [PATCH 80/84] Use audio serial as a fallback for K4W and 1473 models that do not provide a useful camera serial (thanks @olzhas). Fixes #360 and resolves #393. Signed-off-by: Benn Snyder --- include/libfreenect.h | 8 +- src/usb_libusb10.c | 185 +++++++++++++++++++++++++++--------------- 2 files changed, 122 insertions(+), 71 deletions(-) diff --git a/include/libfreenect.h b/include/libfreenect.h index cc8c6046..edc38985 100644 --- a/include/libfreenect.h +++ b/include/libfreenect.h @@ -64,10 +64,10 @@ typedef enum { /// A struct used in enumeration to give access to serial numbers, so you can /// open a particular device by serial rather than depending on index. This /// is most useful if you have more than one Kinect. -struct freenect_device_attributes; -struct freenect_device_attributes { - struct freenect_device_attributes *next; /**< Next device in the linked list */ - const char* camera_serial; /**< Serial number of this device's camera subdevice */ +struct freenect_device_attributes +{ + struct freenect_device_attributes *next; // Next device in the linked list + const char* camera_serial; // Serial number of camera or audio subdevice }; /// Enumeration of available resolutions. diff --git a/src/usb_libusb10.c b/src/usb_libusb10.c index 468c69bc..a85e5939 100644 --- a/src/usb_libusb10.c +++ b/src/usb_libusb10.c @@ -60,58 +60,149 @@ FN_INTERNAL int fnusb_num_devices(fnusb_ctx *ctx) return nr; } +// Returns 1 if `pid` identifies K4W audio, 0 otherwise +FN_INTERNAL int fnusb_is_pid_k4w_audio(int pid) +{ + return (pid == PID_K4W_AUDIO || pid == PID_K4W_AUDIO_ALT_1 || pid == PID_K4W_AUDIO_ALT_2); +} + +FN_INTERNAL libusb_device * fnusb_find_connected_audio_device(libusb_device * camera, libusb_device ** deviceList, int cnt) +{ + if (cnt <= 0) return NULL; + + int cameraBusNo = libusb_get_bus_number(camera); + if (cameraBusNo < 0) return NULL; + libusb_device * cameraParent = libusb_get_parent(camera); + + int i = 0; + for (i = 0; i < cnt; i++) + { + struct libusb_device_descriptor desc; + int res = libusb_get_device_descriptor (deviceList[i], &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]; + } + } + } + } + } + + return NULL; +} + FN_INTERNAL int fnusb_list_device_attributes(fnusb_ctx *ctx, struct freenect_device_attributes** attribute_list) { + // todo: figure out how to log without freenect_context + *attribute_list = NULL; // initialize some return value in case the user is careless. - libusb_device **devs; - //pointer to pointer of device, used to retrieve a list of devices + libusb_device **devs; // pointer to pointer of device, used to retrieve a list of devices ssize_t count = libusb_get_device_list (ctx->ctx, &devs); if (count < 0) + { return -1; + } - struct freenect_device_attributes** camera_prev_next = attribute_list; + struct freenect_device_attributes** next_attr = attribute_list; // Pass over the list. For each camera seen, if we already have a camera // for the newest_camera device, allocate a new one and append it to the list, - // incrementing num_devs. Likewise for each audio device. - struct libusb_device_descriptor desc; + // incrementing num_cams. int num_cams = 0; int i; - for (i = 0; i < count; i++) { - int r = libusb_get_device_descriptor (devs[i], &desc); - if (r < 0) + for (i = 0; i < count; i++) + { + libusb_device* camera_device = devs[i]; + + struct libusb_device_descriptor desc; + int res = libusb_get_device_descriptor (camera_device, &desc); + if (res < 0) + { continue; - if (desc.idVendor == VID_MICROSOFT && (desc.idProduct == PID_NUI_CAMERA || desc.idProduct == PID_K4W_CAMERA)) { + } + + if (desc.idVendor == VID_MICROSOFT && (desc.idProduct == PID_NUI_CAMERA || desc.idProduct == PID_K4W_CAMERA)) + { // Verify that a serial number exists to query. If not, don't touch the device. - if (desc.iSerialNumber == 0) { + if (desc.iSerialNumber == 0) + { continue; } - // Open device. - int res; - libusb_device_handle *this_device; - res = libusb_open(devs[i], &this_device); - unsigned char string_desc[256]; // String descriptors are at most 256 bytes. - if (res != 0) { + libusb_device_handle *camera_handle; + res = libusb_open(camera_device, &camera_handle); + if (res != 0) + { continue; } // Read string descriptor referring to serial number. - res = libusb_get_string_descriptor_ascii(this_device, desc.iSerialNumber, string_desc, 256); - libusb_close(this_device); - if (res < 0) { + unsigned char serial[256]; // String descriptors are at most 256 bytes. + res = libusb_get_string_descriptor_ascii(camera_handle, desc.iSerialNumber, serial, 256); + libusb_close(camera_handle); + if (res < 0) + { continue; } + // K4W and 1473 don't provide a camera serial; use audio serial instead. + 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); + + if (audio_device != NULL) + { + struct libusb_device_descriptor audio_desc; + res = libusb_get_device_descriptor(audio_device, &audio_desc); + if (res != 0) + { + //FN_ERROR("Failed to get audio serial descriptors of K4W or 1473 device: %d\n", res); + } + else + { + libusb_device_handle * audio_handle = NULL; + res = libusb_open(audio_device, &audio_handle); + if (res != 0) + { + //FN_ERROR("Failed to open audio device for serial of K4W or 1473 device: %d\n", res); + } + else + { + res = libusb_get_string_descriptor_ascii(audio_handle, audio_desc.iSerialNumber, serial, 256); + libusb_close(audio_handle); + if (res != 0) + { + //FN_ERROR("Failed to get audio serial of K4W or 1473 device: %d\n", res); + } + } + } + } + } + // Add item to linked list. - struct freenect_device_attributes* new_dev_attrs = (struct freenect_device_attributes*)malloc(sizeof(struct freenect_device_attributes)); - memset(new_dev_attrs, 0, sizeof(*new_dev_attrs)); - - *camera_prev_next = new_dev_attrs; - // Copy string with serial number - new_dev_attrs->camera_serial = strdup((char*)string_desc); - camera_prev_next = &(new_dev_attrs->next); - // Increment number of cameras found + struct freenect_device_attributes* current_attr = (struct freenect_device_attributes*)malloc(sizeof(struct freenect_device_attributes)); + memset(current_attr, 0, sizeof(*current_attr)); + + current_attr->camera_serial = strdup((char*)serial); + *next_attr = current_attr; + next_attr = &(current_attr->next); num_cams++; } } @@ -161,46 +252,6 @@ FN_INTERNAL int fnusb_process_events_timeout(fnusb_ctx *ctx, struct timeval* tim return libusb_handle_events_timeout(ctx->ctx, timeout); } -// Returns 1 if `pid` identifies K4W audio, 0 otherwise -FN_INTERNAL int fnusb_is_pid_k4w_audio(int pid) -{ - return (pid == PID_K4W_AUDIO || pid == PID_K4W_AUDIO_ALT_1 || pid == PID_K4W_AUDIO_ALT_2); -} - -FN_INTERNAL libusb_device * fnusb_find_connected_audio_device(libusb_device * camera, libusb_device ** deviceList, int cnt){ - - int cameraBusNo = libusb_get_bus_number(camera); - libusb_device * cameraParent = libusb_get_parent(camera); - - if( cameraBusNo < 0 ) return NULL; - if( cnt <= 0 ) return NULL; - - int i = 0; - struct libusb_device_descriptor desc; - - for (i = 0; i < cnt; i++) { - int r = libusb_get_device_descriptor (deviceList[i], &desc); - if (r < 0) continue; - if (desc.idVendor != VID_MICROSOFT) continue; - - //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! - //lets double check - libusb_device * audioParent = libusb_get_parent(deviceList[i]); - if( cameraParent == audioParent ){ - return deviceList[i]; - } - } - } - } - - return NULL; -} - FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index) { freenect_context *ctx = dev->parent; From 80f74239db4d450ecc0e45aa8b89cfcbc35defc2 Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Sun, 11 May 2014 01:03:56 -0400 Subject: [PATCH 81/84] Configure audio support at runtime - fixes #372 Signed-off-by: Benn Snyder --- CMakeLists.txt | 11 ++--------- README.md | 15 ++++++++------- examples/CMakeLists.txt | 26 +++++++------------------- src/CMakeLists.txt | 33 ++++++++++++++------------------- src/audio.c | 3 --- src/core.c | 30 +++++++++--------------------- src/freenect_internal.h | 11 ++--------- src/loader.c | 4 ---- src/tilt.c | 12 ------------ src/usb_libusb10.c | 21 ++------------------- src/usb_libusb10.h | 2 -- 11 files changed, 44 insertions(+), 124 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 441e66fc..59ff52d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,8 +54,7 @@ set (PROJECT_VER set (PROJECT_APIVER "${PROJECT_VER_MAJOR}.${PROJECT_VER_MINOR}") -OPTION(BUILD_AUDIO "Build audio support" OFF) -OPTION(BUILD_REDIST_PACKAGE "Build libfreenect in a legally-redistributable manner (only affects audio)" OFF) +OPTION(BUILD_REDIST_PACKAGE "Build libfreenect in a legally-redistributable manner (only affects audio)" ON) OPTION(BUILD_EXAMPLES "Build example programs" ON) OPTION(BUILD_FAKENECT "Build fakenect mock library" ON) OPTION(BUILD_C_SYNC "Build c synchronous library" ON) @@ -84,10 +83,6 @@ if(BIG_ENDIAN) add_definitions(-DFN_BIGENDIAN) endif() -if(BUILD_AUDIO) - add_definitions(-DBUILD_AUDIO) -endif() - if (WIN32) set(MATH_LIB "") else(WIN32) @@ -217,11 +212,9 @@ IF ( BUILD_CPACK_TGZ OR BUILD_CPACK_DEB OR BUILD_CPACK_RPM ) include(CPack) INSTALL(FILES "${CMAKE_BINARY_DIR}/lib/libfreenect.a" DESTINATION ${PROJECT_LIBRARY_INSTALL_DIR}) - if (BUILD_AUDIO) - INSTALL(FILES "include/libfreenect_audio.h" DESTINATION ${PROJECT_INCLUDE_INSTALL_DIR}) - endif() INSTALL(FILES "include/libfreenect.h" DESTINATION ${PROJECT_INCLUDE_INSTALL_DIR}) INSTALL(FILES "include/libfreenect_registration.h" DESTINATION ${PROJECT_INCLUDE_INSTALL_DIR}) + INSTALL(FILES "include/libfreenect_audio.h" DESTINATION ${PROJECT_INCLUDE_INSTALL_DIR}) INSTALL(FILES "APACHE20" DESTINATION "share/doc/${CPACK_PACKAGE_NAME}") INSTALL(FILES "GPL2" DESTINATION "share/doc/${CPACK_PACKAGE_NAME}") INSTALL(FILES "README.md" DESTINATION "share/doc/${CPACK_PACKAGE_NAME}") diff --git a/README.md b/README.md index 67547f18..654d0ad7 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,7 @@ It runs on Linux, OSX, and Windows and supports - Motors - Accelerometer - LED - -Audio is a work in progress. +- Audio # Build Instructions @@ -18,7 +17,7 @@ To build libfreenect, you'll need - [libusb](http://libusb.info) >= 1.0.18 - [CMake](http://cmake.org) >= 2.6 -- [python](http://python.org) == 2.* (only if BUILD_AUDIO or BUILD_PYTHON) +- [python](http://python.org) == 2.* (only if BUILD_PYTHON=ON or BUILD_REDIST_PACKAGE=OFF) For the examples, you'll need @@ -26,6 +25,12 @@ For the examples, you'll need - glut (included with OSX) - [pthreads-win32](http://sourceforge.net/projects/pthreads4w/) (Windows) +For audio support, you must have firmware to upload to the Kinect. +If you specify a non-redistributable package, firmware will be downloaded automatically: + + cmake -L .. -DBUILD_REDIST_PACKAGE=OFF + +Note that the downloaded firmware may not be legal to redistribute! ## Fetch & Build @@ -39,10 +44,6 @@ For the examples, you'll need # if you don't have `make` or don't want color output # cmake --build . -For some newer Kinect models, audio must be enabled for tilt and LED control: - - cmake -L .. -DBUILD_AUDIO=ON - You can specify a build with debug symbols: cmake -L .. -DCMAKE_BUILD_TYPE=debug diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index fb915a17..4e9cb3ed 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -19,11 +19,8 @@ add_executable(freenect-glview glview.c) add_executable(freenect-regview regview.c) add_executable(freenect-hiview hiview.c) add_executable(freenect-chunkview chunkview.c) - -if(BUILD_AUDIO) - add_executable(freenect-wavrecord wavrecord.c) - add_executable(freenect-micview micview.c) -endif() +add_executable(freenect-wavrecord wavrecord.c) +add_executable(freenect-micview micview.c) if (BUILD_C_SYNC) add_executable(freenect-glpclview glpclview.c) @@ -44,10 +41,8 @@ if(APPLE) target_link_libraries(freenect-regview freenect) target_link_libraries(freenect-hiview freenect) target_link_libraries(freenect-chunkview freenect) - if (BUILD_AUDIO) - target_link_libraries(freenect-wavrecord freenect) - target_link_libraries(freenect-micview freenect) - endif() + target_link_libraries(freenect-wavrecord freenect) + target_link_libraries(freenect-micview freenect) if (BUILD_C_SYNC) target_link_libraries(freenect-glpclview freenect_sync) target_link_libraries(freenect-tiltdemo freenect_sync) @@ -66,10 +61,8 @@ else() 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}) - if (BUILD_AUDIO) - target_link_libraries(freenect-wavrecord freenect ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB}) - target_link_libraries(freenect-micview freenect ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB}) - endif() + target_link_libraries(freenect-wavrecord freenect ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB}) + target_link_libraries(freenect-micview freenect ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB}) if (BUILD_C_SYNC) target_link_libraries(freenect-glpclview freenect_sync ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB}) @@ -78,15 +71,10 @@ else() endif() endif() -install (TARGETS freenect-glview freenect-regview freenect-hiview freenect-chunkview +install (TARGETS freenect-glview freenect-regview freenect-hiview freenect-chunkview freenect-wavrecord freenect-micview DESTINATION bin) if (BUILD_C_SYNC) install (TARGETS freenect-glpclview freenect-tiltdemo DESTINATION bin) endif() - -if (BUILD_AUDIO) - install (TARGETS freenect-wavrecord DESTINATION bin) - install (TARGETS freenect-micview DESTINATION bin) -endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a4aec9c1..9534ea55 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -10,20 +10,19 @@ IF(WIN32) set_source_files_properties(${SRC} PROPERTIES LANGUAGE CXX) ENDIF(WIN32) -IF(BUILD_AUDIO) - include(FindPythonInterp) - LIST(APPEND SRC audio.c loader.c) - 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 - add_custom_target(firmware ALL - 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() +# Audio +include(FindPythonInterp) +LIST(APPEND SRC audio.c loader.c) +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 + add_custom_target(firmware ALL + 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() add_library (freenect SHARED ${SRC}) @@ -45,12 +44,8 @@ target_link_libraries (freenect ${LIBUSB_1_LIBRARIES}) target_link_libraries (freenectstatic ${LIBUSB_1_LIBRARIES}) # Install the header files -install (FILES "../include/libfreenect.h" "../include/libfreenect_registration.h" +install (FILES "../include/libfreenect.h" "../include/libfreenect_registration.h" "../include/libfreenect_audio.h" DESTINATION ${PROJECT_INCLUDE_INSTALL_DIR}) -if(BUILD_AUDIO) - install (FILES "../include/libfreenect_audio.h" - DESTINATION ${PROJECT_INCLUDE_INSTALL_DIR}) -endif() IF(UNIX AND NOT APPLE) # Produce a pkg-config file for linking against the shared lib diff --git a/src/audio.c b/src/audio.c index e38340cc..e2758486 100644 --- a/src/audio.c +++ b/src/audio.c @@ -30,7 +30,6 @@ #include #include -#ifdef BUILD_AUDIO static void prepare_iso_out_data(freenect_device* dev, uint8_t* buffer) { audio_stream* stream = &dev->audio; @@ -239,5 +238,3 @@ int freenect_stop_audio(freenect_device* dev) { return ret; } - -#endif diff --git a/src/core.c b/src/core.c index 476d0cbc..a03f7247 100644 --- a/src/core.c +++ b/src/core.c @@ -34,9 +34,8 @@ #include "freenect_internal.h" #include "registration.h" #include "cameras.h" -#ifdef BUILD_AUDIO #include "loader.h" -#endif + FREENECTAPI int freenect_init(freenect_context **ctx, freenect_usb_context *usb_ctx) { @@ -49,11 +48,7 @@ FREENECTAPI int freenect_init(freenect_context **ctx, freenect_usb_context *usb_ memset(*ctx, 0, sizeof(freenect_context)); (*ctx)->log_level = LL_WARNING; - (*ctx)->enabled_subdevices = (freenect_device_flags)(FREENECT_DEVICE_MOTOR | FREENECT_DEVICE_CAMERA -#ifdef BUILD_AUDIO - | FREENECT_DEVICE_AUDIO -#endif - ); + (*ctx)->enabled_subdevices = (freenect_device_flags)(FREENECT_DEVICE_MOTOR | FREENECT_DEVICE_CAMERA | FREENECT_DEVICE_AUDIO); res = fnusb_init(&(*ctx)->usb, usb_ctx); if (res < 0) { free(*ctx); @@ -94,13 +89,11 @@ FREENECTAPI int freenect_process_events_timeout(freenect_context *ctx, struct ti freenect_stop_video(dev); freenect_stop_depth(dev); } -#ifdef BUILD_AUDIO if (dev->usb_audio.device_dead) { FN_ERROR("USB audio marked dead, stopping streams\n"); res = -1; // Or something else to tell the user that the device just vanished. freenect_stop_audio(dev); } -#endif dev = dev->next; } return res; @@ -132,23 +125,18 @@ FREENECTAPI void freenect_free_device_attributes(struct freenect_device_attribut return; } -FREENECTAPI int freenect_supported_subdevices(void) { -#ifdef BUILD_AUDIO +FREENECTAPI int freenect_supported_subdevices(void) +{ return FREENECT_DEVICE_MOTOR | FREENECT_DEVICE_CAMERA | FREENECT_DEVICE_AUDIO; -#else - return FREENECT_DEVICE_MOTOR | FREENECT_DEVICE_CAMERA; -#endif } -FREENECTAPI void freenect_select_subdevices(freenect_context *ctx, freenect_device_flags subdevs) { - ctx->enabled_subdevices = (freenect_device_flags)(subdevs & (FREENECT_DEVICE_MOTOR | FREENECT_DEVICE_CAMERA -#ifdef BUILD_AUDIO - | FREENECT_DEVICE_AUDIO -#endif - )); +FREENECTAPI void freenect_select_subdevices(freenect_context *ctx, freenect_device_flags subdevs) +{ + ctx->enabled_subdevices = (freenect_device_flags)(subdevs & (FREENECT_DEVICE_MOTOR | FREENECT_DEVICE_CAMERA | FREENECT_DEVICE_AUDIO)); } -FREENECTAPI freenect_device_flags freenect_enabled_subdevices(freenect_context *ctx) { +FREENECTAPI freenect_device_flags freenect_enabled_subdevices(freenect_context *ctx) +{ return ctx->enabled_subdevices; } diff --git a/src/freenect_internal.h b/src/freenect_internal.h index 60df715f..3cee98e8 100644 --- a/src/freenect_internal.h +++ b/src/freenect_internal.h @@ -29,10 +29,7 @@ #include "libfreenect.h" #include "libfreenect_registration.h" - -#ifdef BUILD_AUDIO - #include "libfreenect_audio.h" -#endif +#include "libfreenect_audio.h" #ifdef __ELF__ #define FN_INTERNAL __attribute__ ((visibility ("hidden"))) @@ -174,7 +171,6 @@ typedef struct { void *proc_buf; } packet_stream; -#ifdef BUILD_AUDIO typedef struct { int running; @@ -214,8 +210,6 @@ typedef struct { freenect_sample_51 samples[6]; // Audio samples - 6 samples per transfer } audio_out_block; -#endif - struct _freenect_device { freenect_context *parent; freenect_device *next; @@ -244,7 +238,6 @@ struct _freenect_device { // Registration freenect_registration registration; -#ifdef BUILD_AUDIO // Audio fnusb_dev usb_audio; fnusb_isoc_stream audio_out_isoc; @@ -255,7 +248,7 @@ struct _freenect_device { audio_stream audio; uint32_t audio_tag; -#endif + // Motor fnusb_dev usb_motor; freenect_raw_tilt_state raw_state; diff --git a/src/loader.c b/src/loader.c index dc2a8ea2..55fa0019 100644 --- a/src/loader.c +++ b/src/loader.c @@ -32,7 +32,6 @@ #include #include -#ifdef BUILD_AUDIO static void dump_bl_cmd(freenect_context* ctx, bootloader_command cmd) { int i; @@ -418,6 +417,3 @@ FN_INTERNAL int upload_cemd_data(fnusb_dev* dev) { FN_INFO("CEMD data uploaded successfully.\n"); return 0; } - -#endif - diff --git a/src/tilt.c b/src/tilt.c index 1d470e3c..c1a61b15 100644 --- a/src/tilt.c +++ b/src/tilt.c @@ -97,7 +97,6 @@ freenect_raw_tilt_state* freenect_get_tilt_state(freenect_device *dev) return &dev->raw_state; } -#ifdef BUILD_AUDIO int update_tilt_state_alt(freenect_device *dev){ freenect_context *ctx = dev->parent; @@ -150,18 +149,15 @@ int update_tilt_state_alt(freenect_device *dev){ // Units still to be worked out. return get_reply(dev->usb_audio.dev, ctx); } -#endif int freenect_update_tilt_state(freenect_device *dev) { freenect_context *ctx = dev->parent; - #ifdef BUILD_AUDIO //if we have motor control via audio and fw is uploaded - call the alt function if( dev->motor_control_with_audio_enabled ){ return update_tilt_state_alt(dev); } - #endif if(!(ctx->enabled_subdevices & FREENECT_DEVICE_MOTOR)) return 0; @@ -188,7 +184,6 @@ int freenect_update_tilt_state(freenect_device *dev) return ret; } -#ifdef BUILD_AUDIO int freenect_set_tilt_degs_alt(freenect_device *dev, int tilt_degrees) { freenect_context *ctx = dev->parent; @@ -217,18 +212,15 @@ int freenect_set_tilt_degs_alt(freenect_device *dev, int tilt_degrees) return get_reply(dev->usb_audio.dev, ctx); } -#endif int freenect_set_tilt_degs(freenect_device *dev, double angle) { freenect_context *ctx = dev->parent; - #ifdef BUILD_AUDIO //if we have motor control via audio and fw is uploaded - call the alt function if( dev->motor_control_with_audio_enabled ){ return freenect_set_tilt_degs_alt(dev, angle); } - #endif if(!(ctx->enabled_subdevices & FREENECT_DEVICE_MOTOR)) return 0; @@ -289,24 +281,20 @@ FN_INTERNAL int fnusb_set_led_alt(libusb_device_handle * dev, freenect_context * return get_reply(dev, ctx); } -#ifdef BUILD_AUDIO int freenect_set_led_alt(freenect_device *dev, freenect_led_options state) { freenect_context *ctx = dev->parent; return fnusb_set_led_alt(dev->usb_audio.dev, ctx, state); } -#endif int freenect_set_led(freenect_device *dev, freenect_led_options option) { freenect_context *ctx = dev->parent; //if we have motor control via audio and fw is uploaded - call the alt function - #ifdef BUILD_AUDIO if( dev->motor_control_with_audio_enabled ){ return freenect_set_led_alt(dev, option); } - #endif if(!(ctx->enabled_subdevices & FREENECT_DEVICE_MOTOR)) return 0; diff --git a/src/usb_libusb10.c b/src/usb_libusb10.c index a85e5939..0a624ac6 100644 --- a/src/usb_libusb10.c +++ b/src/usb_libusb10.c @@ -263,10 +263,8 @@ FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index) dev->usb_cam.dev = NULL; dev->usb_motor.parent = dev; dev->usb_motor.dev = NULL; -#ifdef BUILD_AUDIO dev->usb_audio.parent = dev; dev->usb_audio.dev = NULL; -#endif 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 @@ -274,9 +272,7 @@ FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index) return -1; int i = 0, nr_cam = 0, nr_mot = 0; -#ifdef BUILD_AUDIO int nr_audio = 0; -#endif int res; struct libusb_device_descriptor desc; @@ -348,15 +344,12 @@ FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index) } } } - -#ifdef BUILD_AUDIO // 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); } -#endif } else { @@ -445,7 +438,6 @@ FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index) } } -#ifdef BUILD_AUDIO // Search for the audio if ((ctx->enabled_subdevices & FREENECT_DEVICE_AUDIO) && !dev->usb_audio.dev && (desc.idProduct == PID_NUI_AUDIO || fnusb_is_pid_k4w_audio(desc.idProduct))) { @@ -608,7 +600,6 @@ FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index) nr_audio++; } } -#endif } libusb_free_device_list (devs, 1); // free the list, unref the devices in it @@ -616,10 +607,7 @@ FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index) // Check that each subdevice is either opened or not enabled. if ((dev->usb_cam.dev || !(ctx->enabled_subdevices & FREENECT_DEVICE_CAMERA)) && (dev->usb_motor.dev || !(ctx->enabled_subdevices & FREENECT_DEVICE_MOTOR)) -#ifdef BUILD_AUDIO - && (dev->usb_audio.dev || !(ctx->enabled_subdevices & FREENECT_DEVICE_AUDIO)) -#endif - ) + && (dev->usb_audio.dev || !(ctx->enabled_subdevices & FREENECT_DEVICE_AUDIO))) { return 0; } @@ -645,7 +633,6 @@ FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index) FN_ERROR("Failed to open motor subddevice or it is not disabled."); } -#ifdef BUILD_AUDIO if (dev->usb_audio.dev) { libusb_release_interface(dev->usb_audio.dev, 0); @@ -655,7 +642,7 @@ FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index) { FN_ERROR("Failed to open audio subdevice or it is not disabled."); } -#endif + return -1; } } @@ -675,13 +662,11 @@ FN_INTERNAL int fnusb_close_subdevices(freenect_device *dev) libusb_close(dev->usb_motor.dev); dev->usb_motor.dev = NULL; } -#ifdef BUILD_AUDIO if (dev->usb_audio.dev) { libusb_release_interface(dev->usb_audio.dev, 0); libusb_close(dev->usb_audio.dev); dev->usb_audio.dev = NULL; } -#endif return 0; } @@ -840,7 +825,6 @@ FN_INTERNAL int fnusb_control(fnusb_dev *dev, uint8_t bmRequestType, uint8_t bRe return libusb_control_transfer(dev->dev, bmRequestType, bRequest, wValue, wIndex, data, wLength, 0); } -#ifdef BUILD_AUDIO FN_INTERNAL int fnusb_bulk(fnusb_dev *dev, uint8_t endpoint, uint8_t *data, int len, int *transferred) { *transferred = 0; return libusb_bulk_transfer(dev->dev, endpoint, data, len, transferred, 0); @@ -858,4 +842,3 @@ FN_INTERNAL int fnusb_num_interfaces(fnusb_dev *dev) { libusb_free_config_descriptor(config); return retval; } -#endif diff --git a/src/usb_libusb10.h b/src/usb_libusb10.h index 9133a3c4..63d56d74 100644 --- a/src/usb_libusb10.h +++ b/src/usb_libusb10.h @@ -98,7 +98,5 @@ int fnusb_start_iso(fnusb_dev *dev, fnusb_isoc_stream *strm, fnusb_iso_cb cb, in int fnusb_stop_iso(fnusb_dev *dev, fnusb_isoc_stream *strm); int fnusb_control(fnusb_dev *dev, uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, uint8_t *data, uint16_t wLength); -#ifdef BUILD_AUDIO int fnusb_bulk(fnusb_dev *dev, uint8_t endpoint, uint8_t *data, int len, int *transferred); int fnusb_num_interfaces(fnusb_dev *dev); -#endif From c6eceda01f71f34e3f2d7bb7564b8cccac0c2ad5 Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Sat, 19 Jul 2014 17:26:11 -0600 Subject: [PATCH 82/84] c_sync: Collapse unused functions Signed-off-by: Benn Snyder --- wrappers/c_sync/libfreenect_sync.c | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/wrappers/c_sync/libfreenect_sync.c b/wrappers/c_sync/libfreenect_sync.c index 034d4bb3..45ffbf5a 100644 --- a/wrappers/c_sync/libfreenect_sync.c +++ b/wrappers/c_sync/libfreenect_sync.c @@ -222,7 +222,7 @@ static void init_thread(void) pthread_create(&thread, NULL, init, NULL); } -static int change_video_format_with_res(sync_kinect_t *kinect, freenect_resolution res, freenect_video_format fmt) +static int change_video_format(sync_kinect_t *kinect, freenect_resolution res, freenect_video_format fmt) { freenect_stop_video(kinect->dev); free_buffer_ring(&kinect->video); @@ -234,12 +234,7 @@ static int change_video_format_with_res(sync_kinect_t *kinect, freenect_resoluti return 0; } -static int change_video_format(sync_kinect_t *kinect, freenect_resolution res, freenect_video_format fmt) -{ - return change_video_format_with_res(kinect, FREENECT_RESOLUTION_MEDIUM, fmt); -} - -static int change_depth_format_with_res(sync_kinect_t *kinect, freenect_resolution res, freenect_depth_format fmt) +static int change_depth_format(sync_kinect_t *kinect, freenect_resolution res, freenect_depth_format fmt) { freenect_stop_depth(kinect->dev); free_buffer_ring(&kinect->depth); @@ -251,11 +246,6 @@ static int change_depth_format_with_res(sync_kinect_t *kinect, freenect_resoluti return 0; } -static int change_depth_format(sync_kinect_t *kinect, freenect_resolution res, freenect_depth_format fmt) -{ - return change_depth_format_with_res(kinect, FREENECT_RESOLUTION_MEDIUM, fmt); -} - static sync_kinect_t *alloc_kinect(int index) { sync_kinect_t *kinect = (sync_kinect_t*)malloc(sizeof(sync_kinect_t)); @@ -281,7 +271,7 @@ static sync_kinect_t *alloc_kinect(int index) return kinect; } -static int setup_kinect_with_res(int index, int res, int fmt, int is_depth) +static int setup_kinect(int index, int res, int fmt, int is_depth) { pending_runloop_tasks_inc(); pthread_mutex_lock(&runloop_lock); @@ -315,9 +305,9 @@ static int setup_kinect_with_res(int index, int res, int fmt, int is_depth) if ((buf->fmt != fmt) || (buf->res != res)) { if (is_depth) - change_depth_format_with_res(kinects[index], (freenect_resolution)res, (freenect_depth_format)fmt); + change_depth_format(kinects[index], (freenect_resolution)res, (freenect_depth_format)fmt); else - change_video_format_with_res(kinects[index], (freenect_resolution)res, (freenect_video_format)fmt); + change_video_format(kinects[index], (freenect_resolution)res, (freenect_video_format)fmt); } pthread_mutex_unlock(&buf->lock); pthread_mutex_unlock(&runloop_lock); @@ -325,10 +315,6 @@ static int setup_kinect_with_res(int index, int res, int fmt, int is_depth) return 0; } -static int setup_kinect(int index, int fmt, int is_depth) { - return setup_kinect_with_res(index, FREENECT_RESOLUTION_MEDIUM, fmt, is_depth); -} - static int sync_get(void **data, uint32_t *timestamp, buffer_ring_t *buf) { pthread_mutex_lock(&buf->lock); @@ -361,7 +347,7 @@ static int runloop_enter(int index) return -1; } if (!thread_running || !kinects[index]) - if (setup_kinect_with_res(index, FREENECT_RESOLUTION_MEDIUM, FREENECT_DEPTH_11BIT, 1)) + if (setup_kinect(index, FREENECT_RESOLUTION_MEDIUM, FREENECT_DEPTH_11BIT, 1)) return -1; pending_runloop_tasks_inc(); @@ -383,7 +369,7 @@ int freenect_sync_get_video_with_res(void **video, uint32_t *timestamp, int inde return -1; } if (!thread_running || !kinects[index] || kinects[index]->video.fmt != fmt || kinects[index]->video.res != res) - if (setup_kinect_with_res(index, res, fmt, 0)) + if (setup_kinect(index, res, fmt, 0)) return -1; sync_get(video, timestamp, &kinects[index]->video); return 0; @@ -403,7 +389,7 @@ int freenect_sync_get_depth_with_res(void **depth, uint32_t *timestamp, int inde } if (!thread_running || !kinects[index] || kinects[index]->depth.fmt != fmt || kinects[index]->depth.res != res) - if (setup_kinect_with_res(index, res, fmt, 1)) + if (setup_kinect(index, res, fmt, 1)) return -1; sync_get(depth, timestamp, &kinects[index]->depth); return 0; From 3bfc0a773a7339990bcea6bfce665a0753a6b316 Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Sun, 20 Jul 2014 12:04:00 -0600 Subject: [PATCH 83/84] Update CMakeList.txt and ebuild for v0.5.0 Signed-off-by: Benn Snyder --- CMakeLists.txt | 4 ++-- platform/linux/portage/dev-libs/libfreenect/Manifest | 2 +- .../portage/dev-libs/libfreenect/libfreenect-9999.ebuild | 5 ++--- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 59ff52d5..1a866d33 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,8 +47,8 @@ include (FindOS) include (SetupDirectories) set (PROJECT_VER_MAJOR 0) -set (PROJECT_VER_MINOR 4) -set (PROJECT_VER_PATCH 3) +set (PROJECT_VER_MINOR 5) +set (PROJECT_VER_PATCH 0) set (PROJECT_VER "${PROJECT_VER_MAJOR}.${PROJECT_VER_MINOR}.${PROJECT_VER_PATCH}") set (PROJECT_APIVER diff --git a/platform/linux/portage/dev-libs/libfreenect/Manifest b/platform/linux/portage/dev-libs/libfreenect/Manifest index 29a11c30..66181878 100644 --- a/platform/linux/portage/dev-libs/libfreenect/Manifest +++ b/platform/linux/portage/dev-libs/libfreenect/Manifest @@ -1 +1 @@ -EBUILD libfreenect-9999.ebuild 2103 SHA256 fe79a2a0fbabeb2c2a85e88569c005f74034539fb28243f5a2b6ed3ee71d8910 SHA512 ac6f45f6100f8174e825cae913597cd4c959f28ca60dc2c49b4ca345f6881666bf5dbb0da619d1258041307e618e5344b9fe7cb837847a7dee1b16311ad797ec WHIRLPOOL dc5266930ce5aa5f7918de230e0822dd93055e07f75e3bf210dddfef2e563b273518269ac17f5cc905e0428c59492c31e05ba5d8d2698d47a46f20804408b3cc +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 index 8849c708..eb308e23 100644 --- a/platform/linux/portage/dev-libs/libfreenect/libfreenect-9999.ebuild +++ b/platform/linux/portage/dev-libs/libfreenect/libfreenect-9999.ebuild @@ -14,9 +14,9 @@ EGIT_REPO_URI="git://github.com/OpenKinect/${PN}.git" LICENSE="Apache-2.0 GPL-2" SLOT="0" KEYWORDS="" -IUSE="audio bindist +c_sync +cpp doc examples fakenect opencv openni2 python" +IUSE="bindist +c_sync +cpp doc examples fakenect opencv openni2 python" -PYTHON_DEPEND="audio? 2" +PYTHON_DEPEND="!bindist? 2" COMMON_DEP="virtual/libusb:1 examples? ( media-libs/freeglut @@ -36,7 +36,6 @@ DEPEND="${COMMON_DEP} src_configure() { local mycmakeargs=( - $(cmake-utils_use_build audio AUDIO) $(cmake-utils_use_build bindist REDIST_PACKAGE) $(cmake-utils_use_build c_sync C_SYNC) $(cmake-utils_use_build cpp CPP) From 8d957924f8a82a235aaa44d8c455113f10c0373f Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Wed, 23 Jul 2014 16:09:37 -0600 Subject: [PATCH 84/84] Fix stupid comparison mistake in audio serial fallback Signed-off-by: Benn Snyder --- src/usb_libusb10.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/usb_libusb10.c b/src/usb_libusb10.c index 0a624ac6..b51de128 100644 --- a/src/usb_libusb10.c +++ b/src/usb_libusb10.c @@ -163,7 +163,7 @@ FN_INTERNAL int fnusb_list_device_attributes(fnusb_ctx *ctx, struct freenect_dev // K4W and 1473 don't provide a camera serial; use audio serial instead. const char* const K4W_1473_SERIAL = "0000000000000000"; - if (strncmp((const char*)serial, K4W_1473_SERIAL, 16) != 0) + if (strncmp((const char*)serial, K4W_1473_SERIAL, 16) == 0) { libusb_device* audio_device = fnusb_find_connected_audio_device(camera_device, devs, count);