Reputation: 3
I'm trying to record kinectv2 data for Image classification problem I am trying to solve. Is there any way to record the kinectv2 data?
I have tried using pickle to save the depth data, however since there is no __reduce__ method in the libfreenect2
library for the Frame class I encountered an error.
frames = listener.waitForNewFrame()
depth = frames["depth"]
with open("captures/frame_" + str(i) + "_depth.obj", 'w') as file:
pickle.dump(depth, file)
with open("captures/frame_" + str(i) + "_depth.obj", 'r') as file:
depth = pickle.load(file)
I encountered the given error:
TypeError: no default __reduce__ due to non-trivial __cinit__
Upvotes: 0
Views: 250
Reputation: 30888
Your two options are:
Make the class pickleable. This involves editing the Cython code of libfreenect2. Probably the most viable way to do it is to add a __reduce__
method, returning the Frame
constructor and a tuple of arguments.
Just save the frame data instead - the Frame
has an asarray
function that can get a Numpy array, and there's loads of options for saving those. This is probably the simplest approach. When you want to load it then just load the Numpy array and call the frame constructor with that.
Upvotes: 0