Skip to content

Commit

Permalink
3d pose to maya
Browse files Browse the repository at this point in the history
  • Loading branch information
Arash Hosseini committed May 15, 2019
1 parent 96a500b commit 423771d
Showing 1 changed file with 27 additions and 8 deletions.
35 changes: 27 additions & 8 deletions src/openpose_3dpose_sandbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ def read_openpose_json(smooth=True, *args):
if not os.path.isfile(_file): raise Exception("No file found!!, {0}".format(_file))
data = json.load(open(_file))
#take first person
_data = data["people"][0]["pose_keypoints_2d"]

_data = data["people"][0]["pose_keypoints"]
xy = []
if len(_data)>=53:
#openpose incl. confidence score
Expand Down Expand Up @@ -304,13 +303,15 @@ def main(_):

device_count = {"GPU": 1}
png_lib = []
before_pose = None
with tf.Session(config=tf.ConfigProto(
device_count=device_count,
allow_soft_placement=True)) as sess:
#plt.figure(3)
batch_size = 128
model = create_model(sess, actions, batch_size)
iter_range = len(smoothed.keys())
export_units = {}
for n, (frame, xy) in enumerate(smoothed.items()):
logger.info("calc frame {0}/{1}".format(frame, iter_range))
# map list into np array
Expand Down Expand Up @@ -377,28 +378,46 @@ def main(_):
# Plot 3d predictions
ax = plt.subplot(gs1[subplot_idx - 1], projection='3d')
ax.view_init(18, -70)
logger.debug(np.min(poses3d))
if np.min(poses3d) < -1000:
poses3d = before_pose

if FLAGS.cache_on_fail:
if np.min(poses3d) < -1000:
poses3d = before_pose

p3d = poses3d
logger.debug(poses3d)
to_export = poses3d.tolist()[0]
x,y,z = [[] for _ in range(3)]
for o in range(0, len(to_export), 3):
x.append(to_export[o])
y.append(to_export[o+1])
z.append(to_export[o+2])
export_units[frame]={}
for jnt_index, (_x, _y, _z) in enumerate(zip(x,y,z)):
export_units[frame][jnt_index] = {"translate": [_x, _y, _z]}

This comment has been minimized.

Copy link
@tonoim

tonoim Jun 1, 2019

Hello @ArashHosseini , could you point to me where i can find the joint order ,the 32 joint order in 3D space . From the 3d.json file it looks like
"frame_number": {"joint[0]: {"translate": [x0,y0,z0] ,,........ joint[31]: {"translate": [x31,y31,z31]
Where can i find the joint order ?


viz.show3Dpose(p3d, ax, lcolor="#9b59b6", rcolor="#2ecc71")

pngName = 'png/pose_frame_{0}.png'.format(str(frame).zfill(12))
plt.savefig(pngName)
if FLAGS.write_gif:
png_lib.append(imageio.imread(pngName))
before_pose = poses3d

if FLAGS.cache_on_fail:

This comment has been minimized.

Copy link
@basicvisual

basicvisual May 23, 2019

Hi Arash , sorry for asking you again but i seem to get the raise AttributeError(name) AttributeError: cache_on_fail error, You mentioned it was probably due to the last frame. I didnt quite get it. I have the following 2d detections from posenet detector which is modified according to your dictionary. Could you please help me to debug the problem

https://drive.google.com/open?id=1DihubcorqWcQ5viLxIAlRVJPzu-BapI5

This comment has been minimized.

Copy link
@basicvisual

basicvisual May 29, 2019

Hi , Arash did you have some feedback on the problem . I am trying to think what can be the problem . I just had changed the keypoints and kept the same dictionary . So i am quite clueless

This comment has been minimized.

Copy link
@ArashHosseini

ArashHosseini May 29, 2019

@basicvisual yes, can you try it from frame 169?

This comment has been minimized.

Copy link
@ArashHosseini

ArashHosseini May 29, 2019

@basicvisual
animation
is the output from frame 169, make a fresh clone please

This comment has been minimized.

Copy link
@basicvisual

basicvisual Jun 1, 2019

@ArashHosseini works , if i change the flag condition and avoid it

before_pose = poses3d

if FLAGS.write_gif:
if FLAGS.interpolation:
#take every frame on gif_fps * multiplier_inv
png_lib = np.array([png_lib[png_image] for png_image in range(0,len(png_lib), int(multiplier_inv)) ])
logger.info("creating Gif gif_output/animation.gif, please Wait!")
imageio.mimsave('gif_output/animation.gif', png_lib, fps=FLAGS.gif_fps)
logger.info("Done!".format(pngName))

_out_file = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'maya/3d_data.json')
with open(_out_file, 'w') as outfile:
logger.info("exported maya json to {0}".format(_out_file))
json.dump(export_units, outfile)

logger.info("Done!".format(pngName))

if __name__ == "__main__":

Expand Down

0 comments on commit 423771d

Please sign in to comment.