Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Drawing with normalized screen points

Discussion in 'Scripting' started by eyeofhorus, Feb 2, 2017.

  1. eyeofhorus

    eyeofhorus

    Joined:
    Oct 10, 2013
    Posts:
    10
    Hello,

    I have been integrating a facial detection SDK (http://www.visagetechnologies.com/) with Unity.

    At every Update() cycle I am able to obtain a set of normalized coordinates [x,y] of the face feature points. (0,0) = bottom left of the screen, (1,1) = top right.

    I would like to display sphere at each of these points on the screen for debugging. How can I convert this normalized coordinates to display the sphere objects correctly on the screen?
     
  2. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,773
    Easiest thing to do is use a Canvas, and create UI elements for each point. Set their .anchorMin and .anchorMax coordinates to your [x,y], and they should all be in the right spot.

    Second-easiest, if you're intent on using spheres, would be to set up an orthographic camera with a size of 1 at coordinates (0.5, 0.5, -100) facing forward. Then you can set your spheres' positions to [x,y,0] and they'll show up in the right spot. (Be advised that the standard sphere defaults to a size of 1, which would fill the screen; you'll want to scale it down to like (0.05,0.05,0.05) or something. )
     
  3. Dameon_

    Dameon_

    Joined:
    Apr 11, 2014
    Posts:
    542