Class HumanFaceImpl

java.lang.Object
cz.fidentis.analyst.data.face.impl.HumanFaceImpl
All Implemented Interfaces:
HumanFace, HumanFaceEventBus, Serializable

public class HumanFaceImpl extends Object implements HumanFace
A human face implementation.
See Also:
  • Field Details

  • Constructor Details

    • HumanFaceImpl

      public HumanFaceImpl(File file, boolean loadLandmarks) throws IOException
      Reads a 3D human face from the given OBJ file.
      Parameters:
      file - OBJ file
      loadLandmarks - If true, then the constructor aims to load landmarks along with the mesh. Use getAllLandmarks() to check whether the landmarks (feature points) has been loaded.
      Throws:
      IOException - on I/O failure
    • HumanFaceImpl

      public HumanFaceImpl(File file) throws IOException
      Reads a 3D human face from the given OBJ file. Also loads landmarks (feature points) if appropriate file is found.
      Parameters:
      file - OBJ file
      Throws:
      IOException - on I/O failure
    • HumanFaceImpl

      public HumanFaceImpl(MeshModel model, String id)
      Creates a human face from existing mesh model. The mesh model is stored directly (not copied).
      Parameters:
      model - Mesh model
      id - Canonical path to the OBJ file
      Throws:
      IllegalArgumentException - if the model is null
  • Method Details

    • getMeshModel

      public MeshModel getMeshModel()
      Returns the triangular mesh model of the human face.
      Specified by:
      getMeshModel in interface HumanFace
      Returns:
      the triangular mesh model of the human face
    • setMeshModel

      public final void setMeshModel(MeshModel meshModel)
      Description copied from interface: HumanFace
      Sets the mesh model.
      Specified by:
      setMeshModel in interface HumanFace
      Parameters:
      meshModel - new mesh model, must not be null
    • setSymmetryPlane

      public void setSymmetryPlane(Plane plane)
      Description copied from interface: HumanFace
      Sets the symmetry plane. If the input argument is null, then removes the plane.
      Specified by:
      setSymmetryPlane in interface HumanFace
      Parameters:
      plane - The new symmetry plane
    • getSymmetryPlane

      public Plane getSymmetryPlane()
      Specified by:
      getSymmetryPlane in interface HumanFace
      Returns:
      The face's symmetry plane
    • hasSymmetryPlane

      public boolean hasSymmetryPlane()
      Description copied from interface: HumanFace
      Returns true if the face has the symmetry plane computed.
      Specified by:
      hasSymmetryPlane in interface HumanFace
      Returns:
      true if the face has the symmetry plane computed.
    • loadFeaturePoints

      public void loadFeaturePoints(String path, String fileName) throws IOException
      Description copied from interface: HumanFace
      Reads feature points from a file on the given path.
      Specified by:
      loadFeaturePoints in interface HumanFace
      Parameters:
      path - Directory where the file is located
      fileName - Name of the file
      Throws:
      IOException - on I/O failure
    • getAllLandmarks

      public List<Landmark> getAllLandmarks()
      Description copied from interface: HumanFace
      Returns all feature points or empty list.
      Specified by:
      getAllLandmarks in interface HumanFace
      Returns:
      The face's feature points.
    • getStandardFeaturePoints

      public List<Landmark> getStandardFeaturePoints()
      Specified by:
      getStandardFeaturePoints in interface HumanFace
      Returns:
      list of standard feature points
    • getCustomLandmarks

      public List<Landmark> getCustomLandmarks()
      Specified by:
      getCustomLandmarks in interface HumanFace
      Returns:
      list of custom feature points
    • addCustomLandmark

      public void addCustomLandmark(Landmark landmark)
      Description copied from interface: HumanFace
      Adds custom landmark to face
      Specified by:
      addCustomLandmark in interface HumanFace
    • removeCustomLandmark

      public boolean removeCustomLandmark(Landmark landmark)
      Description copied from interface: HumanFace
      Removes custom landmark from face
      Specified by:
      removeCustomLandmark in interface HumanFace
      Parameters:
      landmark - Landmark to remove
      Returns:
      true if the landmark was removed, false otherwise
    • hasLandmarks

      public boolean hasLandmarks()
      Description copied from interface: HumanFace
      Checks if HumanFace has feature points
      Specified by:
      hasLandmarks in interface HumanFace
      Returns:
      true if yes and false if not
    • getId

      public String getId()
      Description copied from interface: HumanFace
      Returns unique ID of the face.
      Specified by:
      getId in interface HumanFace
      Returns:
      unique ID of the face.
    • getPath

      public String getPath()
      Description copied from interface: HumanFace
      Returns canonical path to the face file
      Specified by:
      getPath in interface HumanFace
      Returns:
      canonical path to the face file
    • getShortName

      public String getShortName()
      Description copied from interface: HumanFace
      Returns short name of the face without its path in the name. May not be unique.
      Specified by:
      getShortName in interface HumanFace
      Returns:
      short name of the face without its path in the name
    • getDirectory

      public String getDirectory()
      Description copied from interface: HumanFace
      Returns canonical path to the folder in which the face file is located, i.e., HumanFace.getPath() with HumanFace.getShortName() suffix removed.
      Specified by:
      getDirectory in interface HumanFace
      Returns:
      Returns canonical path to the folder in which the face file is located
    • getOctree

      public Octree getOctree()
      Description copied from interface: HumanFace
      Returns already computed octree of the triangular mesh or null.
      Specified by:
      getOctree in interface HumanFace
      Returns:
      Already computed octree of the triangular mesh or null
    • hasOctree

      public boolean hasOctree()
      Description copied from interface: HumanFace
      Checks if HumanFace has octree calculated
      Specified by:
      hasOctree in interface HumanFace
      Returns:
      true if yes and false if not
    • setOctree

      public void setOctree(Octree octree)
      Description copied from interface: HumanFace
      Sets teh octree
      Specified by:
      setOctree in interface HumanFace
      Parameters:
      octree - New octree. Can be null
    • getKdTree

      public KdTree getKdTree()
      Description copied from interface: HumanFace
      Returns already computed k-d tree of the triangular mesh or null.
      Specified by:
      getKdTree in interface HumanFace
      Returns:
      Already computed k-d tree of the triangular mesh or null
    • setKdTree

      public void setKdTree(KdTree kdTree)
      Description copied from interface: HumanFace
      Sets teh octree
      Specified by:
      setKdTree in interface HumanFace
      Parameters:
      kdTree - New k-d tree. Can be null
    • hasKdTree

      public boolean hasKdTree()
      Description copied from interface: HumanFace
      Checks if HumanFace has KdTree calculated
      Specified by:
      hasKdTree in interface HumanFace
      Returns:
      true if yes and false if not
    • getSurfaceMask

      public SurfaceMask getSurfaceMask()
      Description copied from interface: HumanFace
      Returns Interactive mask. The mask can be empty;
      Specified by:
      getSurfaceMask in interface HumanFace
      Returns:
      the interactive mask
    • registerListener

      public void registerListener(HumanFaceListener listener)
      Description copied from interface: HumanFaceEventBus
      Registers listeners (objects concerned in the human face changes) to receive events. If listener is null, no exception is thrown and no action is taken.
      Specified by:
      registerListener in interface HumanFaceEventBus
      Parameters:
      listener - Listener concerned in the human face changes.
    • unregisterListener

      public void unregisterListener(HumanFaceListener listener)
      Description copied from interface: HumanFaceEventBus
      Unregisters listeners from receiving events.
      Specified by:
      unregisterListener in interface HumanFaceEventBus
      Parameters:
      listener - Registered listener
    • announceEvent

      public void announceEvent(HumanFaceEvent evt)
      Description copied from interface: HumanFaceEventBus
      Broadcast event to registered listeners.
      Specified by:
      announceEvent in interface HumanFaceEventBus
      Parameters:
      evt - Event to be triggered.
    • getState

      public HumanFaceState getState()
      Description copied from interface: HumanFace
      Returns a deep copy of current state.
      Specified by:
      getState in interface HumanFace
      Returns:
      a deep copy of current state.
    • setState

      public void setState(HumanFaceState state)
      Description copied from interface: HumanFace
      Falls back to given state. No event is triggered - it up to the caller.
      Specified by:
      setState in interface HumanFace
      Parameters:
      state - Old state. Must not be null
    • getGlyphs

      public List<Glyph> getGlyphs()
      Description copied from interface: HumanFace
      Gets the glyphs of the face or empty list
      Specified by:
      getGlyphs in interface HumanFace
      Returns:
      list of glyphs or empty list
    • setGlyphs

      public void setGlyphs(List<Glyph> glyphs)
      Description copied from interface: HumanFace
      Sets the glyphs.
      Specified by:
      setGlyphs in interface HumanFace
      Parameters:
      glyphs - Glyphs. Can be null
    • hasGlyphs

      public boolean hasGlyphs()
      Description copied from interface: HumanFace
      Checks if the human face has assigned glyphs
      Specified by:
      hasGlyphs in interface HumanFace
      Returns:
      true, if the glyphs exist
    • getBoundingBox

      public Box getBoundingBox()
      Description copied from interface: HumanFace
      Returns bounding box or null
      Specified by:
      getBoundingBox in interface HumanFace
      Returns:
      bounding box or null
    • setBoundingBox

      public void setBoundingBox(Box boundingBox)
      Description copied from interface: HumanFace
      Set a bounding box.
      Specified by:
      setBoundingBox in interface HumanFace
      Parameters:
      boundingBox - Bounding box or null
    • hasBoundingBox

      public boolean hasBoundingBox()
      Description copied from interface: HumanFace
      Checks if the human face has assigned a bounding box
      Specified by:
      hasBoundingBox in interface HumanFace
      Returns:
      true, if the bounding box exists
    • setSurfaceMask

      public void setSurfaceMask(SurfaceMask surfaceMask)
      Description copied from interface: HumanFace
      Set a surface mask.
      Specified by:
      setSurfaceMask in interface HumanFace
      Parameters:
      surfaceMask - surfaceMask or null
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • findLandmarks

      protected File findLandmarks()
      Tries to find a file with landmarks definition based on the name of the face's OBJ file.
      Returns:
      The file with landmarks or null