Closed haripen closed 2 years ago
I'm having exactly the same issue with c3d files downloaded from Carneggie Mellon University
I was facing the same issue, but after a lot of tinkering, I got it to work. Let a point
be a ndarray with 3 columns for x,y,z and each row is a frame. First I appended the columns for conditionals and number of cameras observing the point (all zeros).
point = np.hstack((point, np.zeros((point.shape[0], 2), dtype=point.dtype)))
I then appended the point to a list of points
and converted the list to an array. There's probably a better way for this. The frames to add need to be a sequence of tuples. The points need to have 3 dimensions (point x frame x axis), the analogs 2.
points.append(point)
points = np.array(points)
writer = c3d.Writer()
for i in range(points.shape[1]): # for each frame
writer.add_frames([(points[:, i], np.array([[]]))]) # empty 2 dimensional ndarray for analogs
with open('test.c3d', 'wb') as h:
writer.write(h)
Actually I've made a mistake with my comment, I was having problems reading the Carneggie Mellon examples. But I will try with a modification of your example
I was facing the same issue, but after a lot of tinkering, I got it to work. Let a
point
be a ndarray with 3 columns for x,y,z and each row is a frame. First I appended the columns for conditionals and number of cameras observing the point (all zeros).point = np.hstack((point, np.zeros((point.shape[0], 2), dtype=point.dtype)))
I then appended the point to a list ofpoints
and converted the list to an array. There's probably a better way for this. The frames to add need to be a sequence of tuples. The points need to have 3 dimensions (point x frame x axis), the analogs 2.points.append(point) points = np.array(points) writer = c3d.Writer() for i in range(points.shape[1]): # for each frame writer.add_frames([(points[:, i], np.array([[]]))]) # empty 2 dimensional ndarray for analogs with open('test.c3d', 'wb') as h: writer.write(h)
Thank you!
Given that the workaraound seems to work, I will close the issue for now. Feel free to reopen, if you think there needs to be further discussions or work
Hi,
I'm trying to read, process, and write C3D files with py-c3d (0.3.0). The input C3D files are generated with the (old) Vicon Workstation software and I'm using Sypder (Python 3.6.3) on a Win 64-bit machine.
Your reading example works just fine. However, the writing examples of both the stable version as well as the read/process/write example of the latest version result in the following error
Do you have any idea why? Thanks in advance!