Hello everyone.

The Mixed Reality Forums here are no longer being used or maintained.

There are a few other places we would like to direct you to for support, both from Microsoft and from the community.

The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.

For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.

If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.

And always feel free to hit us up on Twitter @MxdRealityDev.
Options

How to show rectanlge boxes for each faces that is detected in Microsoft Hololens

FrebinFrebin
edited January 2017 in Questions And Answers

This is my current code that will show a rectangle for each faces. This code will work when the detected face stands exactly in center of Hololens, otherwise it fails to show the rectangle in correct position.
This also happens when it detect multiple faces from frame.

foreach (DetectedFace face in detectedFaces)
{
var cameraToWorldMatrix = Camera.main.cameraToWorldMatrix;
cameraPosition = cameraToWorldMatrix.MultiplyPoint3x4(new Vector3(0, 0, -1));
cameraRotation = Quaternion.LookRotation(-cameraToWorldMatrix.GetColumn(2), cameraToWorldMatrix.GetColumn(1));
Matrix4x4 projectionMatrix = Camera.main.projectionMatrix;
Matrix4x4 pixelToCameraMatrix = projectionMatrix.inverse;
float top = -((float)face.FaceBox.Y / (float)cameraResolution.height - .5f);
float left = (float)face.FaceBox.X / (float)cameraResolution.width - .5f;
float width = (float)face.FaceBox.Width / ((float)cameraResolution.width / 2f);
float height = (float)face.FaceBox.Height / ((float)cameraResolution.height / 2f);
GameObject faceBounds = (GameObject)Instantiate(framePrefab);
faceBounds.transform.position = cameraToWorldMatrix.MultiplyPoint3x4(pixelToCameraMatrix.MultiplyPoint3x4(new Vector3(left, top, 0)));
faceBounds.transform.rotation = cameraRotation;
Vector3 scale = pixelToCameraMatrix.MultiplyPoint3x4(new Vector3(width, height, 0));
scale.z = .1f;
faceBounds.transform.localScale = scale;
faceBounds.tag = "faceBounds";
}

Answers

Sign In or Register to comment.