Class SearchManager

java.lang.Object
edu.tufts.hrilab.vision.stm.SearchManager
Direct Known Subclasses:
CompositeSearchManager, RelationSearchManager, SimpleSearchManager

public abstract class SearchManager extends Object
  • Field Details

    • typeId

      protected final long typeId
    • name

      protected Term name
    • description

      protected List<Term> description
    • performanceInfo

      protected TaskPerformanceInformation performanceInfo
    • analysisPolicy

      protected TaskAnalysisPolicy analysisPolicy
    • validFlag

      protected boolean validFlag
    • defaultDetectorPredicate

      protected Term defaultDetectorPredicate
    • incrementalImgProc

      protected boolean incrementalImgProc
    • incrementalDetector

      protected boolean incrementalDetector
    • serialProcessing

      protected boolean serialProcessing
    • singleIteration

      protected boolean singleIteration
    • log

      protected org.slf4j.Logger log
  • Method Details

    • toString

      public final String toString()
      Not synchronized because the GUI frequently calls this method for repainting so calling invokeAndWait (which needs to happen occasionally) will cause a deadlock.
      Overrides:
      toString in class Object
      Returns:
    • setName

      public final void setName(Term typeName)
      Set name of SearchManager. a SearchManager is not required to have a name.
      Parameters:
      typeName -
    • getName

      public final Term getName()
      Get name of SearchManager. This is null if not explicitly set by the setName method.
      Returns:
    • getDescriptors

      public final List<Term> getDescriptors()
      Get predicates of search type. (e.g., color(X,white), type(X,box), color(Y,red), type(Y,cross), on(Y,X))
      Returns:
    • getTypeId

      public final long getTypeId()
      Get unique SearchManager ID (search typeId).
      Returns:
    • getRelatedTypeIds

      public List<Long> getRelatedTypeIds()
      Get a list of SearchManager IDs This is especially important for searches that contain sub-searches like relation
      Returns:
    • matchesDescriptors

      public final boolean matchesDescriptors(List<? extends Term> descriptors)
      Returns true if predicates exactly* match SearchManager's description. (*) Currently adds a default detector if a detector is not specified in the descriptors, and removes any descriptors that don't map to any detectors or image processors.
      Parameters:
      descriptors -
      Returns:
    • addSearchManager

      public void addSearchManager(List<Variable> variables, SearchManager searchManager)
      Add a sub-SearchManager to this SearchManager. This is only valid for SearchManagers that are composed of other SearchManagers.
      Parameters:
      variables -
      searchManager -
    • addConstraint

      public final boolean addConstraint(Term term)
      Add ImageProcessor or Detector constraint. Uses the flags set at runtime: startFlag, incrementalFlag, and singleIteration.
      Parameters:
      term -
      Returns:
      bool - if predicate mapped to an ImageProcessor or Detector
    • addConstraint

      public abstract boolean addConstraint(Term term, boolean incrementalImgProcFlag, boolean incrementalDetectorFlag, boolean singleIterationFlag, boolean serialProcessingFlag)
      Add ImageProcessor or Detector constraint. This overloaded method should only be called from the GUI in order to maintain consistency across all uses from the Vision API.
      Parameters:
      term -
      incrementalImgProcFlag - - if constraint is image processor, should run in incremental mode
      incrementalDetectorFlag - - if constraint is detector, should run in incremental mode
      singleIterationFlag - - if constraint should only run a single iteration
      serialProcessingFlag - - if constraints should run in serial/parallel
      Returns:
      boolean - if predicate mapped to a valid VisionProcessor
    • removeConstraint

      public abstract boolean removeConstraint(Term term)
      Remove constraint from ImageProcessor or Detector. First tries to remove from ImageProcessor constraints, and if nothing was found matching the constraint, then tries to remove Detector (and replace with default Detector). NOTE: doesn't remove Detector yet!!
      Parameters:
      term - to remove
      Returns:
      True, if was successfully removed. If wasn't contained, returns false.
    • registerForNotification

      public abstract void registerForNotification(VisionProcess processor)
      This allows notifications to be sent between SearchManagers. This SearchManager's Tracker will notify the passed in processor.
      Parameters:
      processor - VisionProcess to be notified
    • unregisterForNotification

      public abstract void unregisterForNotification(VisionProcess processor)
      This allows notifications between SearchManagers to be canceled.
      Parameters:
      processor - VisionProcess to be notified
    • getFirstVisionProcessor

      public abstract VisionProcess getFirstVisionProcessor()
      Get the first VisionProcess in the processing chain for this search. This is usually a detector (but could conceivably be SaliencyOperators in the future).
      Returns:
    • getLastVisionProcessor

      public abstract VisionProcess getLastVisionProcessor()
      Get the last VisionProcess in the processing chain for this search. This is usually the Tracker, but can be a Detector and Validator if there is no Tracker (as is the case with sub-SearchMangers in compositeSearchManagers).
      Returns:
    • getAllVisionProcessors

      public abstract Set<VisionProcess> getAllVisionProcessors()
      Get all of the VisionProcessers in the processing chain for this search. Currently used for the Vision Pipeline GUI
    • isRunning

      public abstract boolean isRunning()
      Is this search currently running.
      Returns:
    • isStartCaller

      public boolean isStartCaller(Object caller)
      Check if caller has called start on this VisionProcessor.
      Returns:
    • start

      public final void start(Object caller)
      Start detector(s), tracker(s), and constraint(s) threads of everything associated with this search.
      Parameters:
      caller -
    • stop

      public final void stop(Object caller, boolean wait)
      Stop detector(s), tracker(s), and constraint(s) of everything associated with this search if they are running.
      Parameters:
      caller -
      wait - if should wait for everything to stop before returning
    • hasStarted

      public final boolean hasStarted(Object caller)
      Check if this SearchManager has been started by the caller.
      Parameters:
      caller -
      Returns:
    • start

      protected abstract void start()
    • stop

      protected abstract void stop(boolean wait)
    • shouldBeRunning

      public final boolean shouldBeRunning()
    • hasIterationCompleted

      public abstract boolean hasIterationCompleted()
      Checks if at least one full detection -> tracking iteration has completed. This is required in order to get detection results.
      Returns:
    • setDetectorIncrementalProcessing

      public abstract void setDetectorIncrementalProcessing(boolean flag)
      Set the incremental processing flag for the Detectors.
      Parameters:
      flag -
    • getDetectorIncrementalProcessing

      public abstract boolean getDetectorIncrementalProcessing()
      Get incremental processing flag for selected Detectors. Returns "incrementalDetectorFlag" if no detector exists (as default preference to use incremental processing).
      Returns:
    • setConstraintsIncrementalProcessing

      public abstract void setConstraintsIncrementalProcessing(boolean flag)
      Set the incremental processing flag for all image processors.
      Parameters:
      flag -
    • getConstraintsIncrementalProcessing

      public abstract boolean getConstraintsIncrementalProcessing()
      Get incremental processing flag for all image processors. Will print error if they are not consistent. Returns true if no image processors exist (as default preference to use incremental processing).
      Returns:
    • setSingleIteration

      public abstract void setSingleIteration(boolean flag)
    • getSingleIteration

      public abstract boolean getSingleIteration()
    • setSerialProcessing

      public abstract void setSerialProcessing(boolean flag)
    • getSerialProcessing

      public abstract boolean getSerialProcessing()
    • setTimeOfLastClientUse

      public abstract void setTimeOfLastClientUse(long time)
      Update introspection info: time of last client use.
      Parameters:
      time -
    • meetsExpectations

      public abstract Collection<TaskAnalysisPolicy.Result> meetsExpectations()
      Does the search meet the expectation of its set analysis policy. This is for vision introspection.
      Returns:
    • isValid

      protected void isValid()