Class SimpleSearchManager

java.lang.Object
edu.tufts.hrilab.vision.stm.SearchManager
edu.tufts.hrilab.vision.stm.SimpleSearchManager

public final class SimpleSearchManager extends SearchManager
A SimpleSearchManager is capable of visually searching (detecting and tracking) for a certain object type (e.g., face, coke can, etc.) or visual region with certain properties (e.g., red, round, etc). A SimpleSearchManager can have multiple means of detection and/or tracking but is guaranteed to have at least one instantiated Detector. Using a Tracker is optional depending on if this is a standalone search manager or part of a CompositeSearchManager. ============ IMPORTANT ==================== (1) terminate() must be called when a SearchManager is no longer used. (2) Every non-private class method must be synchronized and call isValid() at the beginning of the method. ===========================================
  • Method Details

    • printStats

      public void printStats(String directory)
      Print the Detector and Tracker introspection statistics in directory/detector_<id>.txt and directory/tracker_<id>.txt
      Parameters:
      directory -
    • addConstraint

      public 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.
      Specified by:
      addConstraint in class SearchManager
      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 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!!
      Specified by:
      removeConstraint in class SearchManager
      Parameters:
      term - to remove
      Returns:
      True, if was successfully removed. If wasn't contained, returns false.
    • registerForNotification

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

      public void unregisterForNotification(VisionProcess processor)
      Description copied from class: SearchManager
      This allows notifications between SearchManagers to be canceled.
      Specified by:
      unregisterForNotification in class SearchManager
      Parameters:
      processor - VisionProcess to be notified
    • setDetectorIncrementalProcessing

      public void setDetectorIncrementalProcessing(boolean flag)
      Set the incremental processing flag for the Detector.
      Specified by:
      setDetectorIncrementalProcessing in class SearchManager
      Parameters:
      flag -
    • getDetectorIncrementalProcessing

      public boolean getDetectorIncrementalProcessing()
      Get incremental processing flag for selected Detector. Returns "incrementalDetectorFlag" if no detector exists (as default preference to use incremental processing).
      Specified by:
      getDetectorIncrementalProcessing in class SearchManager
      Returns:
    • setConstraintsIncrementalProcessing

      public void setConstraintsIncrementalProcessing(boolean flag)
      Set the incremental processing flag for all image processors.
      Specified by:
      setConstraintsIncrementalProcessing in class SearchManager
      Parameters:
      flag -
    • getConstraintsIncrementalProcessing

      public 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).
      Specified by:
      getConstraintsIncrementalProcessing in class SearchManager
      Returns:
    • setSingleIteration

      public void setSingleIteration(boolean flag)
      Specified by:
      setSingleIteration in class SearchManager
    • getSingleIteration

      public boolean getSingleIteration()
      Specified by:
      getSingleIteration in class SearchManager
    • setSerialProcessing

      public void setSerialProcessing(boolean flag)
      Specified by:
      setSerialProcessing in class SearchManager
    • getSerialProcessing

      public boolean getSerialProcessing()
      Specified by:
      getSerialProcessing in class SearchManager
    • getSaliencyOperators

      public ListModel getSaliencyOperators()
      Get saliency operators as a ListModel to allow the UI to listen when changes to the operators are made.
      Returns:
    • getValidatorConstraints

      public ListModel getValidatorConstraints()
      Get validator constraints as a ListModel to allow the UI to listen when changes to the constraints are made.
      Returns:
    • getDetectorOptions

      public Set<NativeDetector.DetectorType> getDetectorOptions()
      Get set of DetectorTypes available for this search.
    • getTrackerOptions

      public Set<NativeTracker.TrackerType> getTrackerOptions()
      Get set of TrackerTypes available for this search.
    • getDetector

      public Detector getDetector(NativeDetector.DetectorType detectorType)
      Get Detector option, if it exists.
      Parameters:
      detectorType -
      Returns:
      Detector, or null
    • getTracker

      public Tracker getTracker(NativeTracker.TrackerType trackerType)
      Get Tracker, if it exists.
      Parameters:
      trackerType -
      Returns:
      Tracker, or null
    • getSelectedDetector

      public Detector getSelectedDetector()
      Find which available Detector is currently selected for use.
      Returns:
      Detector
    • getSelectedTracker

      public Tracker getSelectedTracker()
      Find which available Tracker is currently selected for use.
      Returns:
    • getFirstVisionProcessor

      public VisionProcess getFirstVisionProcessor()
      Description copied from class: SearchManager
      Get the first VisionProcess in the processing chain for this search. This is usually a detector (but could conceivably be SaliencyOperators in the future).
      Specified by:
      getFirstVisionProcessor in class SearchManager
      Returns:
    • getLastVisionProcessor

      public VisionProcess getLastVisionProcessor()
      Description copied from class: SearchManager
      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).
      Specified by:
      getLastVisionProcessor in class SearchManager
      Returns:
    • getAllVisionProcessors

      public Set<VisionProcess> getAllVisionProcessors()
      Description copied from class: SearchManager
      Get all of the VisionProcessers in the processing chain for this search. Currently used for the Vision Pipeline GUI
      Specified by:
      getAllVisionProcessors in class SearchManager
    • setDetector

      public boolean setDetector(NativeDetector.DetectorType detectorType)
      Switch the Detector to be used. If successful, also switches to a suitable Tracker.
      Parameters:
      detectorType -
      Returns:
      bool - if switch was successful
    • setTracker

      public boolean setTracker(NativeTracker.TrackerType trackerType)
      Switch the Tracker to be used. If successful, also switches to a suitable Detector.
      Parameters:
      trackerType -
      Returns:
      bool - if switch was successful
    • meetsExpectations

      public Collection<TaskAnalysisPolicy.Result> meetsExpectations()
      Does the search meet the expectation of its set analysis policy. This is for vision introspection.
      Specified by:
      meetsExpectations in class SearchManager
      Returns:
    • getAlternativeDetectorTypes

      public Set<NativeDetector.DetectorType> getAlternativeDetectorTypes()
      Get all available detector types, leaving out the current detector type.
      Returns:
      set of DetectorTypes
    • getAlternativeTrackerTypes

      public Set<NativeTracker.TrackerType> getAlternativeTrackerTypes()
      Get all available tracker types, leaving out the current tracker type.
      Returns:
      set of TrackerTypes
    • isRunning

      public boolean isRunning()
      Is this search currently running.
      Specified by:
      isRunning in class SearchManager
      Returns:
    • start

      protected final void start()
      Start type's detection, tracker, and constraints threads.
      Specified by:
      start in class SearchManager
    • stop

      protected final void stop(boolean wait)
      Stop constraints, detector, and tracker if they are running, and return immediately without waiting for processors to stop.
      Specified by:
      stop in class SearchManager
      Parameters:
      wait -
    • hasIterationCompleted

      public boolean hasIterationCompleted()
      Description copied from class: SearchManager
      Checks if at least one full detection -> tracking iteration has completed. This is required in order to get detection results.
      Specified by:
      hasIterationCompleted in class SearchManager
      Returns:
    • setTimeOfLastClientUse

      public void setTimeOfLastClientUse(long time)
      Description copied from class: SearchManager
      Update introspection info: time of last client use.
      Specified by:
      setTimeOfLastClientUse in class SearchManager