Package edu.tufts.hrilab.vision
Class MockVisionComponent
java.lang.Object
edu.tufts.hrilab.diarc.DiarcComponent
edu.tufts.hrilab.vision.MockVisionComponent
- All Implemented Interfaces:
VisionInterface,MockVisionInterface,VisionInterface
-
Field Summary
Fields inherited from class edu.tufts.hrilab.diarc.DiarcComponent
executionLoopCycleTime, log, shouldRunExecutionLoop -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddDescriptor(long typeId, Symbol descriptor) Add new search constraint (i.e., ImageProcessor) to an existing SearchManager (specified by searchID).protected List<org.apache.commons.cli.Option>Provide additional information for usage...booleanconfirmToken(long tokenId) Confirms that the object is still in STM.booleanconfirmToken(MemoryObject token) Confirms that the object is still in STM.This instantiates a new MemoryObjecType (search manager) which can be incrementally configured viaaddDescriptor.voidendDescriptorChanges(long typeId) Signal the end of constraint addition.protected voidThis is where any code that needs to be called repeatedly in a dedicated thread should live.Get List of all SearchManager IDs in long term memory.byte[]Return the camera's last depth frame in a byte array.getDescriptors(Long typeId) Get the descriptors for a particular SearchManager.byte[]Return the camera's last disparity frame in a byte array.byte[]getFrame()Return the camera's last frame in a byte array.Returns the size of the image being used.getToken(long tokenId) Get the MemoryObject with the specified id.Get MemoryObject IDs in STM.getTokenIds(long typeId) Get MemoryObject IDs that have specified SearchManager ID.getTokenIds(List<? extends Symbol> descriptors) Get MemoryObject IDs for all tokens *exactly* matching descriptors in STM.Get MemoryObjects in STM.getTokens(long typeId) Get MemoryObjects of the specified SearchManager ID.Get MemoryObjects *exactly* matching descriptors in STM.Get the SearchManager ID (search ID) based on a Predicate description of the object.Get the SearchManager ID (search ID) based on a Predicate description of the object.Find all SearchManagers containing at least one token in STM.getUnsatisfiableConstraints(Symbol descriptor) Find what part(s) of the requested descriptor vision doesn't know how to process.getUnsatisfiableConstraints(List<? extends Symbol> descriptors) Find what part(s) of the requested descriptors vision doesn't know how to process.protected voidinit()Perform any component initialization.booleanUse the passed in term to learn a new descriptor.makeObservations(Term observation) Entry point in vision for making world observations.booleannameDescriptors(Long typeId, Symbol type) Name the collection of Predicate descriptors referred to by the SearchManager ID (search ID).booleannameDescriptors(List<? extends Symbol> descriptors, Symbol type) Name the collection of Predicate descriptors.protected voidparseArgs(org.apache.commons.cli.CommandLine cmdLine) Override this method to parse command line args in the sub-class.voidbooleanremoveDescriptor(long typeId, Symbol descriptor) Remove search constraint (i.e., processing descriptor and/or ImageProcessor) to an existing SearchManager (specified by searchID).voidvoidvoidsetObsevations(boolean makeObservations) booleansetSceneIndex(int index) voidAny component that needs particular shutdown logic needs to override this method andvoidstartType(long typeId) Start detecting/tracking specified SearchManager.voidvoidstopAndRemoveType(long typeId) Turns off search for typeId, and removes SearchManager.voidstopType(long typeId) Stop detecting/tracking specified SearchManager.voidtakeSnapshot(String filename) Save the current frame to file (e.g., for logging).booleanUn-learns things that have been learned by the learn method.Methods inherited from class edu.tufts.hrilab.diarc.DiarcComponent
createInstance, createInstance, createInstance, createInstance, getMyGroupConstraints, getMyGroups, getMyService, getMyServices, main, shutdownMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface edu.tufts.hrilab.vision.VisionInterface
getMyGroups
-
Constructor Details
-
MockVisionComponent
public MockVisionComponent()MockVisionComponent constructor.
-
-
Method Details
-
init
protected void init()Description copied from class:DiarcComponentPerform any component initialization. This should not be used for setting local fields to default values as was the case in DIARC. This method is called after the constructor, and after parseArgs. Setting default values should be done in field declaration or in the constructor.- Overrides:
initin classDiarcComponent
-
shutdownComponent
public void shutdownComponent()Description copied from class:DiarcComponentAny component that needs particular shutdown logic needs to override this method and- Overrides:
shutdownComponentin classDiarcComponent
-
executionLoop
protected void executionLoop()Description copied from class:DiarcComponentThis is where any code that needs to be called repeatedly in a dedicated thread should live. It is not called by default and you must set shouldRunExecutionLoop to true in your constructor.- Overrides:
executionLoopin classDiarcComponent
-
additionalUsageInfo
Provide additional information for usage...- Overrides:
additionalUsageInfoin classDiarcComponent- Returns:
-
parseArgs
protected void parseArgs(org.apache.commons.cli.CommandLine cmdLine) Description copied from class:DiarcComponentOverride this method to parse command line args in the sub-class. Called directly after construction to pass runtime values that will override default values. This should parse all the options that additionalUsageInfo provides.- Overrides:
parseArgsin classDiarcComponent
-
pauseCapture
public void pauseCapture()- Specified by:
pauseCapturein interfaceVisionInterface
-
resumeCapture
public void resumeCapture()- Specified by:
resumeCapturein interfaceVisionInterface
-
stopAllSearches
public void stopAllSearches()- Specified by:
stopAllSearchesin interfaceVisionInterface
-
restartAllStoppedSearches
public void restartAllStoppedSearches()- Specified by:
restartAllStoppedSearchesin interfaceVisionInterface
-
getAvailableTypeIds
Description copied from interface:VisionInterfaceGet List of all SearchManager IDs in long term memory.- Specified by:
getAvailableTypeIdsin interfaceVisionInterface- Returns:
- List of MemoryObjectType IDs
-
startType
public void startType(long typeId) Description copied from interface:VisionInterfaceStart detecting/tracking specified SearchManager.- Specified by:
startTypein interfaceVisionInterface
-
stopType
public void stopType(long typeId) Description copied from interface:VisionInterfaceStop detecting/tracking specified SearchManager.- Specified by:
stopTypein interfaceVisionInterface
-
stopAndRemoveType
public void stopAndRemoveType(long typeId) Description copied from interface:VisionInterfaceTurns off search for typeId, and removes SearchManager.- Specified by:
stopAndRemoveTypein interfaceVisionInterface
-
getTypeIds
Description copied from interface:VisionInterfaceFind all SearchManagers containing at least one token in STM. One each, regardless of how many tokens of a particular type are in STM.- Specified by:
getTypeIdsin interfaceVisionInterface- Returns:
- SearchManager IDs
-
getTypeId
Description copied from interface:VisionInterfaceGet the SearchManager ID (search ID) based on a Predicate description of the object. The Predicate description must match the SearchManager description exactly. If an existing SearchManager does not match the description, a new SearchManager will be attempted to be built. This assumes that all descriptors refer to the same object. Also starts the SearchManager if not running. NOTE: currently just ignores descriptors that vision doesn't know how to handle.- Specified by:
getTypeIdin interfaceVisionInterface- Parameters:
descriptors- Predicate description of object- Returns:
- SearchManager Id (-1 if there is no match)
-
getTypeId
Description copied from interface:VisionInterfaceGet the SearchManager ID (search ID) based on a Predicate description of the object. The Predicate description must match the SearchManager description exactly. If a current SearchManager does not match the description a new SearchManager will be attempted to be built. Also starts the SearchManager if not running. NOTE: This is only a convenience method so a List doesn't need to be passed when only a single Predicate is used.- Specified by:
getTypeIdin interfaceVisionInterface- Parameters:
objectRef- Predicate description of object- Returns:
- SearchManager Id (-1 if there is no match)
-
nameDescriptors
Description copied from interface:VisionInterfaceName the collection of Predicate descriptors. The descriptors must belong to a single SearchManager that already exists, or an attempt to create a new SearchManager matching the descriptors will be made. The description must match the SearchManager description exactly.- Specified by:
nameDescriptorsin interfaceVisionInterface- Parameters:
descriptors- Predicate description of objecttype- Predicate name of object (name will be bound to typeId in VisionComponent)- Returns:
- true if descriptors map to an existing typeId, false otherwise
-
nameDescriptors
Description copied from interface:VisionInterfaceName the collection of Predicate descriptors referred to by the SearchManager ID (search ID).- Specified by:
nameDescriptorsin interfaceVisionInterface- Parameters:
typeId- SearchManager ID (search ID)type- Predicate name of object (name will be bound to typeId in VisionComponent)- Returns:
- true if typeId exists, false otherwise
-
getDescriptors
Description copied from interface:VisionInterfaceGet the descriptors for a particular SearchManager.- Specified by:
getDescriptorsin interfaceVisionInterface- Returns:
-
getTokenIds
Description copied from interface:VisionInterfaceGet MemoryObject IDs in STM. Only considers results from SearchManager searches that are currently running.- Specified by:
getTokenIdsin interfaceVisionInterface- Returns:
- List of STM MemoryObject IDs
-
getTokenIds
Description copied from interface:VisionInterfaceGet MemoryObject IDs that have specified SearchManager ID. If the specified SearchManager exists but is not running, it will be started before returning results.- Specified by:
getTokenIdsin interfaceVisionInterface- Parameters:
typeId- SearchManager ID of tracked objects- Returns:
- List of STM MemoryObject IDs
-
getTokenIds
Description copied from interface:VisionInterfaceGet MemoryObject IDs for all tokens *exactly* matching descriptors in STM. If a matching type is found, it will be started (if not already running). If no match exists, a SearchManager will attempt to be built and started before returning. This is largely a convenience method andgetTypeIdshould be used whenever possible.- Specified by:
getTokenIdsin interfaceVisionInterface- Parameters:
descriptors- list of Symbol descriptors- Returns:
- List of STM MemoryObject IDs
-
getTokens
Description copied from interface:VisionInterfaceGet MemoryObjects in STM. Only considers results from SearchManager searches that are currently running.- Specified by:
getTokensin interfaceVisionInterface- Returns:
- List of MemoryObjects
-
getTokens
Description copied from interface:VisionInterfaceGet MemoryObjects of the specified SearchManager ID. If the specified SearchManager exists but is not running, it will be started before returning results.- Specified by:
getTokensin interfaceVisionInterface- Parameters:
typeId- SearchManager ID of tracked objects- Returns:
- List of MemoryObjects
-
getTokens
Description copied from interface:VisionInterfaceGet MemoryObjects *exactly* matching descriptors in STM. If a matching type is found, it will be started (if not already running). If no match exists, a SearchManager will attempt to be built and started before returning. This is largely a convenience method andgetTypeIdshould be used whenever possible.- Specified by:
getTokensin interfaceVisionInterface- Parameters:
descriptors- list of Symbol descriptors- Returns:
- List of STM MemoryObjects
-
getToken
Description copied from interface:VisionInterfaceGet the MemoryObject with the specified id.- Specified by:
getTokenin interfaceVisionInterface- Parameters:
tokenId- MemoryObject ID in STM- Returns:
- MemoryObject token (Null if doesn't exist)
-
createNewType
Description copied from interface:VisionInterfaceThis instantiates a new MemoryObjecType (search manager) which can be incrementally configured viaaddDescriptor.- Specified by:
createNewTypein interfaceVisionInterface- Returns:
- SearchManager ID (search id)
-
addDescriptor
Description copied from interface:VisionInterfaceAdd new search constraint (i.e., ImageProcessor) to an existing SearchManager (specified by searchID).- Specified by:
addDescriptorin interfaceVisionInterface- Parameters:
typeId- - unique ID returned bycreateNewTypedescriptor- - predicate describing visual search attribute (e.g., "red", "round")
-
removeDescriptor
Description copied from interface:VisionInterfaceRemove search constraint (i.e., processing descriptor and/or ImageProcessor) to an existing SearchManager (specified by searchID).- Specified by:
removeDescriptorin interfaceVisionInterfacedescriptor- - to remove- Returns:
- - if removal was successful
-
endDescriptorChanges
public void endDescriptorChanges(long typeId) Description copied from interface:VisionInterfaceSignal the end of constraint addition. Descriptors/constraints can no longer be added to the SearchManager after this has been called. This also starts the Detector and Tracker and will choose the "object" Detector if one hasn't already been selected.- Specified by:
endDescriptorChangesin interfaceVisionInterface
-
confirmToken
public boolean confirmToken(long tokenId) Description copied from interface:VisionInterfaceConfirms that the object is still in STM.- Specified by:
confirmTokenin interfaceVisionInterface- Parameters:
tokenId- MemoryObject ID of the object to be confirmed- Returns:
- true if the MemoryObject is present in STM
-
confirmToken
Description copied from interface:VisionInterfaceConfirms that the object is still in STM.- Specified by:
confirmTokenin interfaceVisionInterface- Parameters:
token- MemoryObject to be confirmed- Returns:
- true if the object is present in STM
-
getFrame
public byte[] getFrame()Description copied from interface:VisionInterfaceReturn the camera's last frame in a byte array.- Specified by:
getFramein interfaceVisionInterface- Returns:
- the image in a byte array
-
getDisparityFrame
public byte[] getDisparityFrame()Description copied from interface:VisionInterfaceReturn the camera's last disparity frame in a byte array.- Specified by:
getDisparityFramein interfaceVisionInterface- Returns:
-
getDepthFrame
public byte[] getDepthFrame()Description copied from interface:VisionInterfaceReturn the camera's last depth frame in a byte array.- Specified by:
getDepthFramein interfaceVisionInterface- Returns:
-
takeSnapshot
Description copied from interface:VisionInterfaceSave the current frame to file (e.g., for logging).- Specified by:
takeSnapshotin interfaceVisionInterface
-
getImageSize
Description copied from interface:VisionInterfaceReturns the size of the image being used.- Specified by:
getImageSizein interfaceVisionInterface- Returns:
- Dimension containing the size
-
getUnsatisfiableConstraints
Description copied from interface:VisionInterfaceFind what part(s) of the requested descriptors vision doesn't know how to process.- Specified by:
getUnsatisfiableConstraintsin interfaceVisionInterface- Returns:
- list of (possibly empty) unsatisfiable constraints
-
getUnsatisfiableConstraints
Description copied from interface:VisionInterfaceFind what part(s) of the requested descriptor vision doesn't know how to process.- Specified by:
getUnsatisfiableConstraintsin interfaceVisionInterface- Returns:
- list of (possibly empty) unsatisfiable constraints
-
learn
Description copied from interface:VisionInterfaceUse the passed in term to learn a new descriptor. The term must have two arguments, the first arg 'describing' the new thing-to-learn, and the second arg 'naming' the new thing-to-learn. The description must be composed entirely of things vision already knows about.- Specified by:
learnin interfaceVisionInterface- Parameters:
learnTerm- term specifying the kind of learning to do (e.g., instanceOf(X,Y), definitionOf(X,Y))bindings- variable bindings to any variables in query term- Returns:
- if thing-to-learn was successfully learned
-
unlearn
Description copied from interface:VisionInterfaceUn-learns things that have been learned by the learn method.- Specified by:
unlearnin interfaceVisionInterface- Returns:
-
makeObservations
Description copied from interface:VisionInterfaceEntry point in vision for making world observations.- Specified by:
makeObservationsin interfaceVisionInterface- Parameters:
observation- single term specifying observation to make- Returns:
- bindings for any free variables in observation term
-
setSceneIndex
public boolean setSceneIndex(int index) - Specified by:
setSceneIndexin interfaceMockVisionInterface
-
setObsevations
public void setObsevations(boolean makeObservations) - Specified by:
setObsevationsin interfaceMockVisionInterface
-