PoseFitPlugin
Pose plugin aligning node’s rig with keypoints
Universal plugin aligning node’s rig and pose estimated by @geenee/bodyprocessors!PoseProcessor. This is the best starting point for advanced virtual try-on of apparel. Basically, PoseFitPlugin evaluates positions and rotations of armature bones based on 3D pose keypoints, then applies these transforms to bones following the armature hierarchy. To improve accuracy of alignment, detected 3D points and skeleton sizes are mutually adjusted to fit each other. Plugin supports rigs compatible with Clo3D and Marvelous Designer avatars. This is the most common standard of rigs in cloth/apparel modeling software. Controlled scene node must contain an armature among its children nodes. Bones of armature must follow Clo3D naming convention and hierarchy. PoseFitPlugin can apply number of fine-tuning adjustments to basic alignment improving model fitting or making it look more natural. PoseTuneParams explains tuning options.
Extends
Section titled “Extends”Extended by
Section titled “Extended by”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new PoseFitPlugin(
tune
):PoseFitPlugin
Constructor
Parameters
Section titled “Parameters”PoseTuneParams
= ...
Fine-tuning parameters
Returns
Section titled “Returns”PoseFitPlugin
Overrides
Section titled “Overrides”Properties
Section titled “Properties”alignScore
Section titled “alignScore”
readonly
alignScore:0.9
=0.90
Pose score threshold
alignVisibility
Section titled “alignVisibility”
readonly
alignVisibility:0.9
=0.90
Keypoint visibility threshold
cameraAngle
Section titled “cameraAngle”
protected
cameraAngle:number
Camera vertical angle in radians
cameraRatio
Section titled “cameraRatio”
protected
cameraRatio:number
Camera aspect ratio
loaded
Section titled “loaded”loaded:
boolean
Loaded state
Inherited from
Section titled “Inherited from”
protected
optional
node:TransformNode
Attached scene node
nodeOrigin
Section titled “nodeOrigin”
protected
nodeOrigin:BoneTransform
Origin of node relative to the root bone
ordinal
Section titled “ordinal”ordinal:
number
Ordinal number
Inherited from
Section titled “Inherited from”renderer?
Section titled “renderer?”
protected
optional
renderer:Renderer
<PoseResult
>
Renderer loaded the plugin
Inherited from
Section titled “Inherited from”scene?
Section titled “scene?”
protected
optional
scene:Scene
Reference to a scene instance
Inherited from
Section titled “Inherited from”skeleton?
Section titled “skeleton?”
protected
optional
skeleton:Skeleton
Reference to model’s skeleton
skeletonNodes?
Section titled “skeletonNodes?”
protected
optional
skeletonNodes:SkeletonNodes
Bones of the model’s rig
skeletonSizes?
Section titled “skeletonSizes?”
protected
optional
skeletonSizes:SkeletonSizes
Reference sizes of skeleton
spineCurve?
Section titled “spineCurve?”
protected
optional
spineCurve:SpineCurve
Shape of spine
protected
tune:PoseTuneParams
Fine-tuning parameters
Methods
Section titled “Methods”dispose()
Section titled “dispose()”dispose():
void
Dispose video plugin
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”estimateBones()
Section titled “estimateBones()”
protected
estimateBones(pose
,spineCurve
,skeletonSizes
):object
Estimate bone positions and orientations
Using detected keypoints approximates bone transformations. Position of bone if defined by 3D point itself, bone length is the distance between keypoints connected by bone. Bone’s rotation is defined by its axes that are evaluated using kinematic rules and relative positions of adjacent keypoints. Method returns bone position and orientation in global world frame, final relative transformations are found traversing skeleton hierarchy and accumulating transforms of parents.
Parameters
Section titled “Parameters”Pose keypoints
spineCurve
Section titled “spineCurve”SpineCurve
Reference shape of spine
skeletonSizes
Section titled “skeletonSizes”SkeletonSizes
Reference sizes of skeleton
Returns
Section titled “Returns”object
Bone transformations
armL:
BoneTransform
=armL.arm
armMidL
Section titled “armMidL”armMidL:
BoneTransform
=armL.armMid
armMidR
Section titled “armMidR”armMidR:
BoneTransform
=armR.armMid
armR:
BoneTransform
=armR.arm
footL:
BoneTransform
=legL.foot
footR:
BoneTransform
=legR.foot
forearmL
Section titled “forearmL”forearmL:
BoneTransform
=armL.forearm
forearmMidL
Section titled “forearmMidL”forearmMidL:
BoneTransform
=armL.forearmMid
forearmMidR
Section titled “forearmMidR”forearmMidR:
BoneTransform
=armR.forearmMid
forearmR
Section titled “forearmR”forearmR:
BoneTransform
=armR.forearm
handL:
BoneTransform
=armL.hand
handR:
BoneTransform
=armR.hand
head:
BoneTransform
legL:
BoneTransform
=legL.leg
legR:
BoneTransform
=legR.leg
neck:
BoneTransform
neck1:
BoneTransform
pelvis
Section titled “pelvis”pelvis:
BoneTransform
root:
BoneTransform
shoulderL
Section titled “shoulderL”shoulderL:
BoneTransform
=armL.shoulder
shoulderR
Section titled “shoulderR”shoulderR:
BoneTransform
=armR.shoulder
spine:
BoneTransform
spine1
Section titled “spine1”spine1:
BoneTransform
spine2
Section titled “spine2”spine2:
BoneTransform
spine3
Section titled “spine3”spine3:
BoneTransform
uplegL
Section titled “uplegL”uplegL:
BoneTransform
=legL.upleg
uplegMidL
Section titled “uplegMidL”uplegMidL:
BoneTransform
=legL.uplegMid
uplegMidR
Section titled “uplegMidR”uplegMidR:
BoneTransform
=legR.uplegMid
uplegR
Section titled “uplegR”uplegR:
BoneTransform
=legR.upleg
load()
Section titled “load()”load(
renderer
):Promise
<void
>
Initialize plugin
Parses and caches the rig/armature of the attached scene node (one provided to plugin’s constructor). Precalculates geometrical parameters of skeleton.
Parameters
Section titled “Parameters”renderer
Section titled “renderer”Renderer this plugin is attached to
Returns
Section titled “Returns”Promise
<void
>
Promise resolving when initialization is finished
Overrides
Section titled “Overrides”setNode()
Section titled “setNode()”setNode(
node?
):void
Set/attach a scene node
Parses and caches the rig/armature of the node. Precalculates geometrical parameters of skeleton.
Parameters
Section titled “Parameters”TransformNode
Scene node to attach
Returns
Section titled “Returns”void
setupCamera()
Section titled “setupCamera()”setupCamera(
ratio
,angle
):void
Set camera parameters
Parameters
Section titled “Parameters”number
Aspect ration of input video
number
Vertical field of view in radians
Returns
Section titled “Returns”void
Overrides
Section titled “Overrides”setupVideo()
Section titled “setupVideo()”setupVideo(
size
):void
Set video size
Could be overridden to adjust plugin’s pipeline.
Parameters
Section titled “Parameters”Resolution of input video
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”unload()
Section titled “unload()”unload():
void
Reset plugin
Clears internal state and frees all resources allocated in load().
Returns
Section titled “Returns”void
Overrides
Section titled “Overrides”update()
Section titled “update()”update(
result
,stream
):Promise
<void
>
Update skeleton of the scene node
Evaluates positions, rotations and scales of node bones
based on estimation of 3D keypoints, then applies these
transformations to bones following hierarchy of armature.
To improve accuracy of alignment detected 3D points and
skeleton sizes are mutually adjusted to fit each other.
One can override this method to further tune model’s rig
using provided estimations of bones as a starting point.
Simply call await super.update(result, stream);
and use
PoseFitPlugin#skeletonNodes member storing refs
to all bones of the skeleton to access transformations.
Parameters
Section titled “Parameters”result
Section titled “result”Pose estimation results
stream
Section titled “stream”HTMLCanvasElement
Captured video frame
Returns
Section titled “Returns”Promise
<void
>
Promise resolving when update is finished
Overrides
Section titled “Overrides”updateArm()
Section titled “updateArm()”
protected
updateArm(bones
,points
):void
Update arm rig (see update)
Parameters
Section titled “Parameters”Arm bones and transforms
{ bone
: TransformNode
; transform
: BoneTransform
; }
arm.bone
Section titled “arm.bone”TransformNode
arm.transform
Section titled “arm.transform”armMid
Section titled “armMid”{ bone
: TransformNode
; transform
: BoneTransform
; }
armMid.bone
Section titled “armMid.bone”TransformNode
armMid.transform
Section titled “armMid.transform”forearm
Section titled “forearm”{ bone
: TransformNode
; transform
: BoneTransform
; }
forearm.bone
Section titled “forearm.bone”TransformNode
forearm.transform
Section titled “forearm.transform”forearmMid
Section titled “forearmMid”{ bone
: TransformNode
; transform
: BoneTransform
; }
forearmMid.bone
Section titled “forearmMid.bone”TransformNode
forearmMid.transform
Section titled “forearmMid.transform”{ bone
: TransformNode
; transform
: BoneTransform
; }
hand.bone
Section titled “hand.bone”TransformNode
hand.transform
Section titled “hand.transform”points
Section titled “points”Arm keypoints
shoulder
Section titled “shoulder”Returns
Section titled “Returns”void
updateLeg()
Section titled “updateLeg()”
protected
updateLeg(bones
,points
):void
Update leg rig (see update)
Parameters
Section titled “Parameters”Leg bones and transforms
{ bone
: TransformNode
; transform
: BoneTransform
; }
foot.bone
Section titled “foot.bone”TransformNode
foot.transform
Section titled “foot.transform”{ bone
: TransformNode
; transform
: BoneTransform
; }
leg.bone
Section titled “leg.bone”TransformNode
leg.transform
Section titled “leg.transform”{ bone
: TransformNode
; transform
: BoneTransform
; }
upleg.bone
Section titled “upleg.bone”TransformNode
upleg.transform
Section titled “upleg.transform”uplegMid
Section titled “uplegMid”{ bone
: TransformNode
; transform
: BoneTransform
; }
uplegMid.bone
Section titled “uplegMid.bone”TransformNode
uplegMid.transform
Section titled “uplegMid.transform”points
Section titled “points”Leg keypoints
Returns
Section titled “Returns”void
updateSpine()
Section titled “updateSpine()”
protected
updateSpine(transforms
,bones
):void
Update spine rig (see update)
Parameters
Section titled “Parameters”transforms
Section titled “transforms”Estimated transformations
BoneTransform
= armL.arm
armMidL
Section titled “armMidL”BoneTransform
= armL.armMid
armMidR
Section titled “armMidR”BoneTransform
= armR.armMid
BoneTransform
= armR.arm
BoneTransform
= legL.foot
BoneTransform
= legR.foot
forearmL
Section titled “forearmL”BoneTransform
= armL.forearm
forearmMidL
Section titled “forearmMidL”BoneTransform
= armL.forearmMid
forearmMidR
Section titled “forearmMidR”BoneTransform
= armR.forearmMid
forearmR
Section titled “forearmR”BoneTransform
= armR.forearm
BoneTransform
= armL.hand
BoneTransform
= armR.hand
BoneTransform
= ...
BoneTransform
= legL.leg
BoneTransform
= legR.leg
BoneTransform
= ...
BoneTransform
= ...
pelvis
Section titled “pelvis”BoneTransform
= ...
BoneTransform
= ...
shoulderL
Section titled “shoulderL”BoneTransform
= armL.shoulder
shoulderR
Section titled “shoulderR”BoneTransform
= armR.shoulder
BoneTransform
= ...
spine1
Section titled “spine1”BoneTransform
= ...
spine2
Section titled “spine2”BoneTransform
= ...
spine3
Section titled “spine3”BoneTransform
= ...
uplegL
Section titled “uplegL”BoneTransform
= legL.upleg
uplegMidL
Section titled “uplegMidL”BoneTransform
= legL.uplegMid
uplegMidR
Section titled “uplegMidR”BoneTransform
= legR.uplegMid
uplegR
Section titled “uplegR”BoneTransform
= legR.upleg
SkeletonNodes
Spine bones
Returns
Section titled “Returns”void