jmendeth/PyOpenNI — Issue #5: Access violation on Windows when using callbacks
Author: ellegi
Created: 2012-01-17 16:59:02+00:00
State: open

I am getting an access violation error on Windows 7 on callback execution.

In this example code:
```python
import openni as xn
import sys
import ctypes

XML_PATH = "OpenNIConfig.xml"

def new_user(user_generator, id):
print 'Detected user %d' % (id)
user_generator.skeleton_cap.request_calibration(id, True)

def lost_user():
pass

print "Initializing OpenNI..."

context = xn.Context()
context.init_from_xml_file(XML_PATH)
user_generator = context.find_existing_node(xn.NODE_TYPE_USER)
user_generator.skeleton_cap.set_profile(xn.SKEL_PROFILE_ALL)
user_generator.register_user_cb(new_user, lost_user)
context.start_generating_all()

print "Init done."

while True:
context.wait_any_update_all()
```

The Python interpreter crashes as soon as the first user is detected. When I move in front of the sensor, it prints "Detected user 1" and then immediately crashes. The crash occours in XnVFeatures_1_5_2.dll at 0x00095d7c .

I'm not familiar with either OpenNI or Windows development (but I HAVE to deploy my project on Windows XP) so maybe I am just using the module uncorrectly. I apologize in advance if that's the case.

I am using Windows 7 with Python 2.7 and Panda3D 1.7.2 (although in the example, none of the 3D engine functions is used). I'm using OpenNI 1.5.2.23 with NITE 1.5.2.21, all compiled for x86 (not x64).