ae28d55f81
Source: RGB-D -> Dyn-HaMR -> L20 retargeting -> FoundationPose -> reference repair -> SPIDER, documented in docs/PIPELINE_LATEST.md and docs/SETUP_AND_WEIGHTS.md. Adds FoundationPose and nvdiffrast upstream snapshots, requirements/pipeline_venv.txt and the FoundationPose weight manifest/downloader. Assets (Git LFS): weights/ (WiLoR detector, HandFlow denoiser, UniDepth-L), FoundationPose checkpoints, HaMeR checkpoint, Dyn-HaMR HMP model and BMC constraints, L20 URDF/meshes, the 20260915_171525 D405 recording and the two box CADs. MANO models are not redistributed (third_party/hamer/_DATA/data/mano/README.txt). Environments, caches and run outputs excluded. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
19 lines
905 B
Python
19 lines
905 B
Python
"""Unsigned closest distance with solid-angle winding sign for a closed mesh.
|
|
Avoid ray-parity misclassification at collinear CAD tessellation edges.
|
|
"""
|
|
import numpy as np
|
|
import open3d as o3d
|
|
|
|
def signed_distance(scene,mesh,points):
|
|
p=np.asarray(points,dtype=np.float64)
|
|
d=scene.compute_distance(o3d.core.Tensor(p.astype('float32'))).numpy()
|
|
ids=np.flatnonzero(((p>=mesh.bounds[0])&(p<=mesh.bounds[1])).all(1))
|
|
triangles=np.asarray(mesh.triangles,dtype=np.float64)
|
|
for start in range(0,len(ids),32):
|
|
ix=ids[start:start+32];v=triangles[None]-p[ix,None,None,:];a,b,c=v[:,:,0],v[:,:,1],v[:,:,2];length=np.linalg.norm(v,axis=-1)
|
|
numerator=np.einsum('bij,bij->bi',a,np.cross(b,c))
|
|
denominator=length.prod(-1)+(a*b).sum(-1)*length[:,:,2]+(b*c).sum(-1)*length[:,:,0]+(c*a).sum(-1)*length[:,:,1]
|
|
winding=np.arctan2(numerator,denominator).sum(-1)/(2*np.pi)
|
|
d[ix[np.abs(winding)>.5]]*=-1
|
|
return d
|