Class MemoryObject

java.lang.Object
edu.tufts.hrilab.vision.stm.MemoryObject
All Implemented Interfaces:
Serializable

public class MemoryObject extends Object implements Serializable
MemoryObject - A Java class-wrapper for the data to be passed between the vision system and the rest of the Java system.

Changes to this class MUST be appropriately reflected in native classes MemoryObjectInterface and MemoryObject, as well as TrackedObjects.addMemoryObjectToSend(...)

See Also:
  • Constructor Details

    • MemoryObject

      public MemoryObject()
      Default constructor.
    • MemoryObject

      public MemoryObject(MemoryObject rhs)
      Deep copy constructor.
      Parameters:
      rhs -
  • Method Details

    • addChild

      public void addChild(MemoryObject child)
      Add a child MemoryObject to the scene graph.
      Parameters:
      child -
    • addRelation

      public void addRelation(float confidence, Term descriptor, MemoryObject relatedObject, boolean reciprocate)
      Add new relation.
      Parameters:
      confidence - [0 1] value
      descriptor - Term description of relation
      relatedObject - other MemoryObject in relation
      reciprocate - if relation should be added to relatedObject too
    • addRelation

      public void addRelation(float confidence, String descriptor, MemoryObject relatedObject, boolean reciprocate)
      Convenience method to populate relations from native side.
      Parameters:
      confidence -
      descriptor -
      relatedObject -
      reciprocate -
    • getChildren

      public List<MemoryObject> getChildren()
      Get all immediate children of this MemoryObject.
      Returns:
      all immediate children in a List
    • getRelations

      public List<MemoryObjectRelation> getRelations()
      Get all relations this MemoryObject has.
      Returns:
      list of MemoryObjectRelations (potentially empty)
    • getRelations

      public List<MemoryObjectRelation> getRelations(Term relation)
      Get all relations this MemoryObject has that match the specified relation.
      Parameters:
      relation -
      Returns:
      list of MemoryObjectRelations (potentially empty)
    • getMemoryObject

      public MemoryObject getMemoryObject(Symbol identifier)
      Find the MemoryObject in the scene graph matching the identifier. Returns null if no match is found.
      Parameters:
      identifier -
      Returns:
    • isValid

      public boolean isValid()
      If MemoryObject is a valid STM MemoryObject (i.e., have the appropriate fields been set). Currently, this returns true if the ID has been set, and is no longer "-1".
      Returns:
    • getStringsForVisualization

      public ArrayList<String> getStringsForVisualization()
    • roundToXDigits

      public static double roundToXDigits(double num, int x)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getDisplayString

      public String getDisplayString()
    • printSceneGraph

      public void printSceneGraph()
    • setTypeId

      public void setTypeId(long typeId)
    • setTokenId

      public void setTokenId(long tokenId)
    • setFrameNum

      public void setFrameNum(long fNum)
    • setVariable

      public void setVariable(Variable variable)
    • setVariable

      public void setVariable(String variableName)
    • setConfidence

      @Deprecated public void setConfidence(double conf)
      Deprecated.
    • setDetectionConfidence

      public void setDetectionConfidence(double conf)
    • setTrackingConfidence

      public void setTrackingConfidence(double conf)
    • setLocation

      public void setLocation(double x, double y, double z)
    • setDirection

      public void setDirection(double x, double y, double z)
    • setBoundingBox

      public void setBoundingBox(int x, int y, int width, int height)
    • setDimensions

      public void setDimensions(double x, double y, double z)
    • setBaseTransform

      public void setBaseTransform(javax.vecmath.Matrix4d transform)
      Set the transform to go from vision to base coordinate system. Should only be set once, from native side.
      Parameters:
      transform -
    • setBaseTransform

      public void setBaseTransform(double[] transform)
      Set the transform to go from vision to base coordinate system. Should only be set once, from native side.
      Parameters:
      transform -
    • setNumPoints

      public void setNumPoints(int size)
      Set number of points in 3D point cloud.
      Parameters:
      size -
    • addPoint

      public void addPoint(int index, double x, double y, double z)
      Add point to point cloud. Assumes setNumPoints has been called to allocate space for points.
      Parameters:
      index -
      x -
      y -
      z -
    • setNumFaces

      public void setNumFaces(int size)
      Set number of faces in 3D mesh.
      Parameters:
      size -
    • addFace

      public void addFace(int index, int[] face)
      Add face to 3D mesh. Assumes setNumFaces has been called to allocate space for faces. Faces can contain three or more vertices.
      Parameters:
      face -
    • setNumOrientations

      public void setNumOrientations(int size)
      Set number of orientations.
      Parameters:
      size -
    • addOrientation

      public void addOrientation(int index, double x, double y, double z, double w)
      Add orientation. Assumes setNumOrientations has been called to allocate space for orientations.
      Parameters:
      index -
      x -
      y -
      z -
      w -
    • setNumMaskIndices

      public void setNumMaskIndices(int size)
      Set number of indices in mask.
      Parameters:
      size -
    • addMaskIndex

      public void addMaskIndex(int indexNumber, int index)
      Add index to mask. Assumes setNumMaskIndices has been called to allocate space for mask.
      Parameters:
      indexNumber - index into mask data structure
      index - image index value
    • setCoordinateFrame

      public void setCoordinateFrame(String frame)
    • setPrimitives

      public void setPrimitives(List<MemoryPrimitive> primitives)
    • addDescriptor

      @Deprecated public void addDescriptor(Term descriptor)
      Deprecated.
    • addDescriptor

      public void addDescriptor(Term descriptor, float confidence)
    • addDescriptor

      public void addDescriptor(String descriptor, float confidence)
      Convenience method for adding descriptors from native side.
      Parameters:
      descriptor - String that originated from Predicate
    • getTypeId

      public long getTypeId()
      Return search type ID.
      Returns:
    • getTokenId

      public long getTokenId()
      Get unique token ID.
      Returns:
    • getFrameNum

      public long getFrameNum()
    • getIdentifier

      public Symbol getIdentifier()
    • getVariable

      public Variable getVariable()
    • getConfidence

      @Deprecated public double getConfidence()
      Deprecated.
    • getDetectionConfidence

      public double getDetectionConfidence()
    • getTrackingConfidence

      public double getTrackingConfidence()
    • getBoundingBox

      public Rectangle getBoundingBox()
    • getDimensions

      public javax.vecmath.Point3d getDimensions()
    • getDist

      @Deprecated public double getDist()
      Deprecated.
    • getLocation

      public javax.vecmath.Point3d getLocation()
    • getDirection

      public javax.vecmath.Vector3d getDirection()
    • getPan

      @Deprecated public double getPan()
      Deprecated.
      Get pan angle (radians). This assumes camera coordinate frame (i.e., +pan is -x, +tilt is -y).
      Returns:
      angle in radians
    • getTilt

      @Deprecated public double getTilt()
      Deprecated.
      Get tilt angle (radians). This assumes camera coordinate frame (i.e., +pan is -x, +tilt is -y).
      Returns:
      angle in radians
    • getPointCloud

      public double[][] getPointCloud()
    • getFaceIndices

      public int[][] getFaceIndices()
    • getOrientations

      public double[][] getOrientations()
    • getMaskIndices

      public int[] getMaskIndices()
    • getBaseTransform

      public javax.vecmath.Matrix4d getBaseTransform()
    • getDescriptors

      public List<Term> getDescriptors()
    • containsDescriptors

      public boolean containsDescriptors(List<Term> descriptors)
    • containsDescriptor

      public boolean containsDescriptor(Term descriptor)
      Check if this MemoryObject contains the descriptor. If compared Terms both have a Variable as an argument, the Variable does not need to be equal. For example, on(X,Y) matches on(Y,Z).
      Parameters:
      descriptor -
      Returns:
    • getCoordinateFrame

      public String getCoordinateFrame()
    • getPrimitives

      public List<MemoryPrimitive> getPrimitives()
    • transformToBase

      public boolean transformToBase()
    • transformToVision

      public boolean transformToVision()
    • transform

      public boolean transform(javax.vecmath.Matrix4d transform, String dest)