Package edu.tufts.hrilab.vision.stm
Class SearchManager
java.lang.Object
edu.tufts.hrilab.vision.stm.SearchManager
- Direct Known Subclasses:
CompositeSearchManager
,RelationSearchManager
,SimpleSearchManager
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected TaskAnalysisPolicy
protected Term
protected boolean
protected boolean
protected org.slf4j.Logger
protected Term
protected TaskPerformanceInformation
protected boolean
protected boolean
protected final long
protected boolean
-
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
addConstraint
(Term term) Add ImageProcessor or Detector constraint.abstract boolean
addConstraint
(Term term, boolean incrementalImgProcFlag, boolean incrementalDetectorFlag, boolean singleIterationFlag, boolean serialProcessingFlag) Add ImageProcessor or Detector constraint.void
addSearchManager
(List<Variable> variables, SearchManager searchManager) Add a sub-SearchManager to this SearchManager.abstract Set<VisionProcess>
Get all of the VisionProcessers in the processing chain for this search.abstract boolean
Get incremental processing flag for all image processors.Get predicates of search type.abstract boolean
Get incremental processing flag for selected Detectors.abstract VisionProcess
Get the first VisionProcess in the processing chain for this search.abstract VisionProcess
Get the last VisionProcess in the processing chain for this search.final Term
getName()
Get name of SearchManager.Get a list of SearchManager IDs This is especially important for searches that contain sub-searches like relationabstract boolean
abstract boolean
final long
Get unique SearchManager ID (search typeId).abstract boolean
Checks if at least one full detection -> tracking iteration has completed.final boolean
hasStarted
(Object caller) Check if this SearchManager has been started by the caller.abstract boolean
Is this search currently running.boolean
isStartCaller
(Object caller) Check if caller has called start on this VisionProcessor.protected void
isValid()
final boolean
matchesDescriptors
(List<? extends Term> descriptors) Returns true if predicates exactly* match SearchManager's description.abstract Collection<TaskAnalysisPolicy.Result>
Does the search meet the expectation of its set analysis policy.abstract void
registerForNotification
(VisionProcess processor) This allows notifications to be sent between SearchManagers.abstract boolean
removeConstraint
(Term term) Remove constraint from ImageProcessor or Detector.abstract void
setConstraintsIncrementalProcessing
(boolean flag) Set the incremental processing flag for all image processors.abstract void
setDetectorIncrementalProcessing
(boolean flag) Set the incremental processing flag for the Detectors.final void
Set name of SearchManager.abstract void
setSerialProcessing
(boolean flag) abstract void
setSingleIteration
(boolean flag) abstract void
setTimeOfLastClientUse
(long time) Update introspection info: time of last client use.final boolean
protected abstract void
start()
final void
Start detector(s), tracker(s), and constraint(s) threads of everything associated with this search.protected abstract void
stop
(boolean wait) final void
Stop detector(s), tracker(s), and constraint(s) of everything associated with this search if they are running.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.abstract void
unregisterForNotification
(VisionProcess processor) This allows notifications between SearchManagers to be canceled.
-
Field Details
-
typeId
protected final long typeId -
name
-
description
-
performanceInfo
-
analysisPolicy
-
validFlag
protected boolean validFlag -
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
Not synchronized because the GUI frequently calls this method for repainting so calling invokeAndWait (which needs to happen occasionally) will cause a deadlock. -
setName
Set name of SearchManager. a SearchManager is not required to have a name.- Parameters:
typeName
-
-
getName
Get name of SearchManager. This is null if not explicitly set by the setName method.- Returns:
-
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
Get a list of SearchManager IDs This is especially important for searches that contain sub-searches like relation- Returns:
-
matchesDescriptors
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
Add a sub-SearchManager to this SearchManager. This is only valid for SearchManagers that are composed of other SearchManagers.- Parameters:
variables
-searchManager
-
-
addConstraint
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 modeincrementalDetectorFlag
- - if constraint is detector, should run in incremental modesingleIterationFlag
- - if constraint should only run a single iterationserialProcessingFlag
- - if constraints should run in serial/parallel- Returns:
- boolean - if predicate mapped to a valid VisionProcessor
-
removeConstraint
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
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
This allows notifications between SearchManagers to be canceled.- Parameters:
processor
- VisionProcess to be notified
-
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
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
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
Check if caller has called start on this VisionProcessor.- Returns:
-
start
Start detector(s), tracker(s), and constraint(s) threads of everything associated with this search.- Parameters:
caller
-
-
stop
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
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
Does the search meet the expectation of its set analysis policy. This is for vision introspection.- Returns:
-
isValid
protected void isValid()
-