Reputation: 21
I have installed KinectV2 SDK on my Windows 10 system and test it successfully inside SDK browsers.
I tried to run some code from Pykinect2 library but there was an issues while importing:
from pykinect2 import PyKinectV2
Error:
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
Cell In[2], line 1
----> 1 from pykinect2 import PyKinectV2
2 from pykinect2.PyKinectV2 import *
File ~\Anaconda3\envs\kinect-env\lib\site-packages\pykinect2\PyKinectV2.py:2216
2131 ################################################################
2132 ## code template for ICoordinateMapper implementation
2133 ##class ICoordinateMapper_Impl(object):
(...)
2200 ## #return colorPoint
2201 ##
2203 tagSTATSTG._fields_ = [
2204 ('pwcsName', WSTRING),
2205 ('type', c_ulong),
(...)
2214 ('reserved', c_ulong),
2215 ]
-> 2216 assert sizeof(tagSTATSTG) == 72, sizeof(tagSTATSTG)
2217 assert alignment(tagSTATSTG) == 8, alignment(tagSTATSTG)
2218 IAudioBeamList._methods_ = [
2219 COMMETHOD(['propget'], HRESULT, 'BeamCount',
2220 ( ['retval', 'out'], POINTER(c_uint), 'count' )),
(...)
2223 ( ['out'], POINTER(POINTER(IAudioBeam)), 'AudioBeam' )),
2224 ]
AssertionError: 80
How to resolve it?
Upvotes: 2
Views: 315
Reputation: 60388
This seems to be a rather usual error (see here and here). Here is the remedy according to a thread in the PyKinect2 Github repo:
assuming this is the same import error I received caused by the
assert sizeof(tagSTATSTG) == 72
on line 2216 of PyKinectV2.py (sizeof
is now 80) then the quick fix is to edit the file toassert sizeof(tagSTATSTG) >= 72
.My assumption is that an extra field has been added to the structure in the Microsoft API... by convention Microsoft have usually/always append any new fields to the end of structures so as not to break backwards compatability... anyhow it allowed me to successfuly import PyKinectV2.
Notice that, according to your error trace, the error stems exactly from assert sizeof(tagSTATSTG) == 72
on line 2216 of PyKinectV2.py
, as argued in the Github thread.
According to a relevant Reddit thread, changing the line to assert sizeof(tagSTATSTG) == 80
should also work.
In any case, you should keep in mind that PyKinect2 seems abandoned since ~8 years ago.
Upvotes: 5