diva.sketch.recognition
Class BasicScene

java.lang.Object
  extended by diva.sketch.recognition.BasicScene
All Implemented Interfaces:
Scene

public class BasicScene
extends Object
implements Scene

A scene database that keeps track of multiple interpretations of a set of strokes. Groups of strokes are stored hierarchically, and these also have multiple interpretations. There are also choice elements that represent a mutually exclusive choice between objects of the same type that use the same type. Using this data structure, a client can view all of the interpretations of the scene and perform efficient operations to filter interpretations.

BasicScene uses the Java collections classes to implement the scene infrastructure in an obvious and unoptimized way. Future implementations of the scene interface may

Version:
$Revision: 1.8 $
Author:
Michael Shilman (michaels@eecs.berkeley.edu)

Constructor Summary
BasicScene()
           
 
Method Summary
 void _markDescendents(SceneElement elt, short mark, boolean makeChoices)
          Mark the given element and all of its descendents with the given mark, so that a subsequent traversal will be able to distinguish between elements inside and outside of the marked set.
 boolean _sameID(BitSet id1, BitSet id2)
          Return true if the supports of the two elements (i.e.
 CompositeElement addComposite(TypedData data, double confidence, SceneElement[] children, String[] names)
          Add a new composite element to the database and return it.
 StrokeElement addStroke(TimedStroke stroke)
          Add a new stroke element to the database.
 List choices()
          Return a list of all of the choices contained in the scene.
 void confirm(CompositeElement elt, boolean makeChoices)
          Accept the given interpretation of the set of strokes that the given element covers as the correct interpretation of those strokes.
 List elementsOfType(Type type, CompositeElement elt)
          Find the elements in the scene with the given type that do not contradict the given element, and return them as a list.
 int getCompositeCount()
          Return a count of the total number of composite nodes in the database, for a crude measure of performance.
 int getStrokeCount()
          Return a count of the total number of stroke nodes in the database, for a crude measure of performance.
 boolean isConsistent(SceneElement e1, SceneElement e2)
          Return whether or not the two elements are consistent, that is, whether the leaf nodes that they cover (their support) are strictly disjoint.
 boolean isCoveringAll(SceneElement elt)
          Return whether or not this element covers all of the leaves.
 void removeElement(SceneElement elt)
          Remove an element from the database.
 List roots()
          Return a list of every root node in the database, i.e.
 boolean sameSupport(SceneElement e1, SceneElement e2)
          Return true if the supports of the two elements (i.e.
 List strokes()
          Return a list the stroke elements of the scene in the order that they were added to the database.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicScene

public BasicScene()
Method Detail

addComposite

public CompositeElement addComposite(TypedData data,
                                     double confidence,
                                     SceneElement[] children,
                                     String[] names)
Add a new composite element to the database and return it. This element will appear in the roots() iterator until it is added as a child of another composite node, or until it is removed from the database. This method will return null if a pre-existing choice node is used, in which case no node was actually added to the database.

Specified by:
addComposite in interface Scene
Parameters:
data - The typed data associated with the composite.
confidence - The confidence of recognition, between 0 and 1.
children - The children of this element in the tree.
names - The names of the children.

choices

public List choices()
Return a list of all of the choices contained in the scene. This list will only have choice elements that contain more than one choice.

Specified by:
choices in interface Scene

addStroke

public StrokeElement addStroke(TimedStroke stroke)
Add a new stroke element to the database. This element will appear in the strokes() iterator until it is removed from the database.

Specified by:
addStroke in interface Scene

confirm

public void confirm(CompositeElement elt,
                    boolean makeChoices)
Accept the given interpretation of the set of strokes that the given element covers as the correct interpretation of those strokes. This implies that all elements in the scene that contradict this interpretation are incorrect interpretations, so these interpretations are removed.

Specified by:
confirm in interface Scene
Parameters:
elt - The interpretation to confirm
makeChoices - Whether or not to confirm the existing choice nodes at or under elt.

elementsOfType

public List elementsOfType(Type type,
                           CompositeElement elt)
Find the elements in the scene with the given type that do not contradict the given element, and return them as a list. (FIXME- somehow ordered by relevance?)

Specified by:
elementsOfType in interface Scene
Parameters:
type - The type of elements that will be returned.
elt - The element that the returned set must be consistent with, or null if it doesn't matter.
Returns:
A list of scene elements that match the query.
See Also:
isConsistent(SceneElement, SceneElement)

getCompositeCount

public int getCompositeCount()
Return a count of the total number of composite nodes in the database, for a crude measure of performance.


getStrokeCount

public int getStrokeCount()
Return a count of the total number of stroke nodes in the database, for a crude measure of performance.


isCoveringAll

public boolean isCoveringAll(SceneElement elt)
Return whether or not this element covers all of the leaves. An element covers a leaf if the leaf is a descendent of the element.

Specified by:
isCoveringAll in interface Scene

isConsistent

public boolean isConsistent(SceneElement e1,
                            SceneElement e2)
Return whether or not the two elements are consistent, that is, whether the leaf nodes that they cover (their support) are strictly disjoint. Return true if either of the elements are null.

Specified by:
isConsistent in interface Scene

removeElement

public void removeElement(SceneElement elt)
Remove an element from the database. This will also trigger the removal of every element that depends on the given element.

Specified by:
removeElement in interface Scene

roots

public List roots()
Return a list of every root node in the database, i.e. all top-level scene interpretations, from high to low confidence. This iterator may contain composite elements or choice elements; it will not contain strokes.

Specified by:
roots in interface Scene

sameSupport

public boolean sameSupport(SceneElement e1,
                           SceneElement e2)
Return true if the supports of the two elements (i.e. the sets elements that they cover) are identical.


strokes

public List strokes()
Return a list the stroke elements of the scene in the order that they were added to the database.

Specified by:
strokes in interface Scene

_markDescendents

public void _markDescendents(SceneElement elt,
                             short mark,
                             boolean makeChoices)
Mark the given element and all of its descendents with the given mark, so that a subsequent traversal will be able to distinguish between elements inside and outside of the marked set.


_sameID

public boolean _sameID(BitSet id1,
                       BitSet id2)
Return true if the supports of the two elements (i.e. the sets elements that they cover) are identical.



Copyright © 2015 Central Laboratory of the Research Councils. All Rights Reserved.