public void set(final Joints joint, final Joint3D element) { set(joint.getValue(), element); }
final Skeleton3D basePosture = postures.get(0); final Point3D[] points = new Point3D[Joints.values().length]; Arrays.fill(points, Point3D.ZERO); final double totalConf[] = new double[Joints.values().length]; Arrays.fill(totalConf, 0.0); final double maxConf[] = new double[Joints.values().length]; Arrays.fill(maxConf, 0.0); mirrorCount.getAndIncrement(); for (Joints joint : Joints.values()) { final int jointIndex = joint.getValue(); final Joint3D currentJoint = p.get(joint, mirrored); final double confidence = currentJoint.getConfidence() == 1.0 ? 1.0 : 0.25;
public static final double postureConfidence(final TrackedPosture3DFloat posture, final boolean right) { double confidence = posture.getConfidence(Joints.Head.getValue()); if (right) { confidence *= posture.getConfidence(Joints.ShoulderRight.getValue()); confidence *= posture.getConfidence(Joints.ElbowRight.getValue()); confidence *= posture.getConfidence(Joints.WristRight.getValue()); confidence *= posture.getConfidence(Joints.HandRight.getValue()); } else { confidence *= posture.getConfidence(Joints.ShoulderLeft.getValue()); confidence *= posture.getConfidence(Joints.ElbowLeft.getValue()); confidence *= posture.getConfidence(Joints.WristLeft.getValue()); confidence *= posture.getConfidence(Joints.HandLeft.getValue()); } return confidence; }
private void createMean() { assert this.size() == Joints.values().length; mean = stream() .map(Joint3D::getPosition) .reduce(Point3D.ZERO, Point3D::add) .multiply(1.0 / this.size()); }
public Joint3D get(final Joints joint) { return get(joint.getValue()); }
private void createWeightedMean() { assert this.size() == Joints.values().length; weightedMean = stream() .map(j -> j.getPosition().multiply(j.getConfidence())) .reduce(Point3D.ZERO, Point3D::add) .multiply(1.0 / getTotalConfidence()); }
public static final PointingRay3DFloat getPointingRayWithConfidence(final TrackedPosture3DFloat posture, final boolean right, final double pointingProbability, final PointingType type) { final JointPair jointPair = getJointPair(right, type); final float certainty = posture.getConfidence(jointPair.getJoint1().getValue()) * posture.getConfidence(jointPair.getJoint2().getValue()); return getPointingRay(posture, right, certainty * pointingProbability, type); }
public double jointDistance(final Skeleton3D other, final boolean mirrored) { // TODO: or sqrt of sum of squares like euclidean?! + weights stay... // TODO: other way with the distance between the means... if only calculated once would save a lot of calculations... double totalConf = 0.0; double totalDist = 0.0; for (final Joints joint : Joints.values()) { final Joint3D thisJoint = this.get(joint); final Joint3D otherJoint = other.get(joint, mirrored); final double conf = thisJoint.getConfidence() * otherJoint.getConfidence(); totalConf += conf; totalDist += thisJoint.getPosition().distance(otherJoint.getPosition()) * conf; } return totalDist / totalConf; } }
public static final Vec3DFloat getVec(final TrackedPosture3DFloat posture, final Joints joint) { return toVec3DFloat(posture.getPosture().getPosition(joint.getValue())); }
public static final Point3D getPoint3D(final TrackedPosture3DFloat posture, final Joints joint) { return toPoint3D(posture.getPosture().getPosition(joint.getValue())); }