I'm currently trying multiple AR plugins in unity and I'm stuck in how to place certain objects in specific landmark positions. I used the landmark positions to spawn certain objects but they are way off from the intended areas I wanted.

Here is the code sample I'm using the get the facial landmarks of the ears, mouth, nose and eyes :

MatOfPoint2f imagePoints;
imagePoints = new MatOfPoint2f ();
Mat rgbaMat = webCamTextureToMatHelper.GetMat();
Rect detectionResult = faceLandmarkDetector.Detect();
List<Vector2> points;
if(detectionResult != null && detectionsResult > 0)
    points = faceLandmarkDetector.DetectLandmark(detectionResult[0]);
if(points != null)
new Point((points[38].x + points[41].x) / 2, (points[38].y + points[41].y) / 2), //Left Eye Facial LandMark Position
new Point((points[43].x + points[46].x) / 2, (points[43].y + points[46].y) / 2),// Right Eye
new Point(points[30].x, points[30].y), //Nose
new Point(points[0].x, points[0].y),Left Ear
new Point(points[16].x, points[16].y) Right Ear

  • \$\begingroup\$ How are you detecting these locations at present? \$\endgroup\$ – DMGregory Dec 11 '19 at 11:54
  • \$\begingroup\$ I'm using facemask, found it on the unity asset store, I want to find a way to use their 68 facial landmark points to place objects on the face. \$\endgroup\$ – darksphere Dec 11 '19 at 12:01
  • \$\begingroup\$ Great. For users who aren't familiar with this asset, please show a minimal sample of your code where you're reading these landmark points. Including information on what coordinate space they're in would also be helpful. \$\endgroup\$ – DMGregory Dec 11 '19 at 12:06
  • \$\begingroup\$ @DMGregory I modified the question and added a code sample. \$\endgroup\$ – darksphere Dec 11 '19 at 12:26
  • \$\begingroup\$ So, presumably you tried instantiating your props and setting their positions to those screen points? Where did that go wrong? \$\endgroup\$ – DMGregory Dec 11 '19 at 12:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.