"""Restore mirrored-right inference to left-hand geometry in the original world.""" from pathlib import Path import numpy as np from scipy.spatial.transform import Rotation ROOT=Path(__file__).resolve().parents[1];BASE=ROOT/'output/20260915_171525' src=BASE/'handflow_left_mirrored';out=BASE/'handflow_left';out.mkdir(exist_ok=True) M=np.diag([-1.,1.,1.]);M4=np.diag([-1.,1.,1.,1.]) h=dict(np.load(src/'handflow_results.npz'));j=dict(np.load(src/'human_joints.npz')) for k in ['verts_cam','verts_world','trans']:h[k]=h[k]@M h['c2w']=M4@h['c2w']@M4 h['pose']=h['pose'].copy();h['pose'][:,:3]=Rotation.from_matrix(M@Rotation.from_rotvec(h['pose'][:,:3]).as_matrix()@M).as_rotvec() h['intrinsics']=h['intrinsics'].copy();h['intrinsics'][2]=848-1-h['intrinsics'][2] h['side']='left';h['source']=str(ROOT/'docs/20260915_171525/color.mp4') h['convention_note']='Canonical right prediction from mirrored video, geometry reflected into actual left camera/world; body-pose fields remain canonical and are not native MANO-left parameters.' for k in ['joints','joints_raw','joints_world_raw','wrist_world','wrist_world_raw']: if k in j:j[k]=j[k]@M j['root_orient']=Rotation.from_matrix(M@Rotation.from_rotvec(j['root_orient']).as_matrix()@M).as_rotvec() j['source']=str(out/'handflow_results.npz');j['side']='left' np.savez_compressed(out/'handflow_results.npz',**h);np.savez_compressed(out/'human_joints.npz',**j) print('Unmirrored left geometry',len(j['joints']))