Squeak Class Documentation category index | class index  
 
CRRecognizer
  category: Genie-Engine
  superclass: Object
  subclasses:

The class CRRecognizer is the heart of the genie recognition engine.
Instances of it control the whole process of capturing a new stroke, decomposing it into appropriate vectors and building the according feature (a subclass of CRFeature).
The recognizing process consists of two states:

1) In the first step, the points (in global display coordinates) are just added to the collection called points of the recognizer. The recognizer doesn't do much processing in this first step: It just checks wheter the new points is at least a given distance (in pixel) from the last one. If not, the point is ignored. If echo is enabled, the recognizer shows an cho feedback of the stroke on the screen (Using an array of LineMorphs).

2) In the second step, the recognizer builds the feature according to the stroke. It translates the points from global display coordinates into normalized feature coordinates (using the current display properties), it determines the siginificant points, etc. This step is more time consuming than the first, but compared to the dictionary lookup (the feature comparing algorithms) it's nothing.

NOTE: To optimize speeds on PDA, the recognizer doesn't use floating point operations. This
makes it sometimes a little bit more complicated.

Instance variables:

dictionary <CRDictionary>
The dictionary the recognizer is recognizing for. In fact, The recognizer needs not really
the dictionary but much more the associated parameters.

displayProperties <CRDisplayProperties>
The display properties the recognizer uses to translate from global screen coordinates (pixel)
into normalized feature coordinates.

points <SequenceableCollection>
The captured points in global screen coordinates.

coordinates <CRRecognizerCoordinates>
Informations about the location of the recognized stroke in global screen coordinates.


lastPoint <Point>
The last captured points that was captured. (Needs to be stored seperately because captured
points are only added to points when the distance to the last point is big enough.

startTime <SmallInteger>
Time when the recognizer started.

endTime <SmallInteger>
Time when the recognizer stopped.

directionPoints <SequenceableCollection>
Collection of all the points the recognizer considers as significant (in normalized feature
coordinates)

escapePossible <Boolean>
Is it possible to escape the recognizer by leaving the pen at the startposition for a while?

isEchoEnabled <Boolean>
Shall the recognizer generate a graphical echo of the feature?

echo <Collection>
Collection holding all the LineMorphs representing the echo

instance methods
  accessing
  addAllPoints:
addPoint:
calculateNewFeature:
currentDisplayProperties
dictionary
dictionary:
displayProperties
displayProperties:
isEchoEnabled:
parameters
points
resetAndStart
stop
stopAndCalculateCoordinates
stopAndCalculateFeature

  initialize-release
  initializeDictionary:displayProperties:

  nothing
 

  private
  absDirectionDifference:and:
absMaxCoord:
absMaxCoordDistance:and:
addDirectionTowardsPoint:minSquaredLength:minAngle:last:dirPointsSize:directions:directionPoints:
addPointWithoutTest:
bottomRight
calcNormExtent
calcPointNormDivisor
calcPointNormFactor
calcPointNormShiftVector
clearPoints
coordinates
coordinates:
currentDisplayProperties:
directionFrom:to:
directionVectors:
echo
echo:
endTime
endTime:
ensureMaxDirectionLength:size:
escapePossible
escapePossible:
extent
lastAddedPoint
lastAddedPoint:
lastPoint
lastPoint:
normalizedDirection:
points:
setIdentityDisplayProperties
squaredDistanceFrom:to:
startTime
startTime:
time
topLeft

  testing
  isEchoEnabled
isRunning
shouldEscape

class methods
  computation
  degreesX:y:

  instance creation
  dictionary:
dictionary:displayProperties:

  version
  checkPluginVersion
majorNO
minorNO
versionNO
versionString

instance methods
  accessing top  
 

addAllPoints:

Add the given collection of points in global display coordinates (pixel) to the
collection of captured points


 

addPoint:

Add the given point in global screen coordinates (pixel) to the collection of captured
points. The points is only added if the distance to the last one is big enough


 

calculateNewFeature:

Treat the captured points of a previously calculated feature as source points to
calculate a new feature. This allows to recalculate an existing fature with different
properties.
NOTE: To do this recalculation, the captured points must be available in the feature


 

currentDisplayProperties


 

dictionary


 

dictionary:


 

displayProperties

The display properties the recognizer uses to translate between global scren coordinates
and normalized feature coordinates.
This instance variable can contain a CRDisplayPoperties or #activeInstance to
refer to the currently active display property instance.


 

displayProperties:

The display properties the recognizer uses to translate between global scren coordinates
and normalized feature coordinates.
This instance variable can contain a CRDisplayPoperties or #activeInstance to
refer to the currently active display property instance.


 

isEchoEnabled:

Is graphical echo wanted?


 

parameters


 

points

The captured points in global display coordinates


 

resetAndStart

Reset the recognizer and start capturing points.
This starts the clock measuring how long it takes to capture the points


 

stop

Stop capturing points.
This stops the clock measuring how long it took to capture the points.
It returns the informations about the coordinates of the stroke (in global screen
coordinates (pixel))


 

stopAndCalculateCoordinates


 

stopAndCalculateFeature

Stop the recognizer and calculate the feature according to the captured points


  initialize-release top  
 

initializeDictionary:displayProperties:


  nothing top  

  private top  
 

absDirectionDifference:and:

Absolute difference between this two angles.


 

absMaxCoord:


 

absMaxCoordDistance:and:


 

addDirectionTowardsPoint:minSquaredLength:minAngle:last:dirPointsSize:directions:directionPoints:

Add the direction (vector) towards newPoint to the sequence of direction vectors and also
add newPoint to the sequence of points.
The method ensures that all the direction vectors have at least a length of lenNumber
that the angle difference to the neighbour vectors is at least angleNumber.

NOTE: This method adds new vectors only if they point into another global segment.
(E.g., the segment size can be 45 degrees). This GLOBAL view is much better than a
relative view (only angle differences are considered) because it is much less sensitive
to different start angles or 'noise vectors' in the middle of a stroke!


 

addPointWithoutTest:

This method adds aPoint to the collection of all the captured points (in global display
coordinates). It doesn't test wheter the distance to the last one is big enough


 

bottomRight

Bottom right of stroke's bounding box


 

calcNormExtent

Calculates the normalized extent of the stroke


 

calcPointNormDivisor

Calculates the number display points have to be diveded by to get normalized points


 

calcPointNormFactor

Calcualtes the number display points have to be multiplied with to get normalized points


 

calcPointNormShiftVector

Calculates the vector that has to be added to translate display points into normalized
points


 

clearPoints

Clear all the points collections


 

coordinates

This instance variable stores the coordinates of the source stroke


 

coordinates:

This instance variable stores the coordinates of the source stroke


 

currentDisplayProperties:


 

directionFrom:to:


 

directionVectors:

Calculat the significant directions based on the siginificant points


 

echo

The StrokeMorph for the graphical echo


 

echo:

The graphical echo


 

endTime


 

endTime:


 

ensureMaxDirectionLength:size:

Ensures that all the siginificant directions are not longer than a certain length.
I didn't use this method dor a long time and the results were not much worse without
it. However, sometimes it's very useful to match a stroke containing one very long
direction vector and a very similar stroke containing two shorter vectors with a very
small intermdiate angle.
Note: This method partitions a vector that is too loong into smaller vectors all of which
having exactly the same length. An older version used captured points to introduce new
vectors, but it turned out to be worse than this.


 

escapePossible

Shall the recognizer esacpe when leaving the pen at the startposition for a certain
amount of time?


 

escapePossible:

Shall the recognizer esacpe when leaving the pen at the startposition for a certain
amount of time?


 

extent

Extent of the stroke's bounding box


 

lastAddedPoint


 

lastAddedPoint:


 

lastPoint

The last captured point.
Captured points are only added if the distance to the last point are at least a certain
amount of pixels. But, the last point of a stroke has to be added anyway and therefore
it has to be stored


 

lastPoint:

The last captured point.
Captured points are only added if the distance to the last point are at least a certain
amount of pixels. But, the last point of a stroke has to be added anyway and therefore
it has to be stored


 

normalizedDirection:

Given a direction in degrees.
Return the nearest direction that points to the start of a segment.
Example: If the segment size is 45 degrees, a value of 0, 45, 90, 135, 180, ..., 270, 315
degrees is returned. For 24 degres, 45 degrees is returned.


 

points:

The captured points in global display coordinates


 

setIdentityDisplayProperties

Set the display properties as if the source device would already be in normalized
feature coordinates. This is used to recalculate a fature after it's coordinates are
translated to normalized feature coordinates


 

squaredDistanceFrom:to:


 

startTime


 

startTime:


 

time

The time used to draw the stroke


 

topLeft

TopLft of the stroke's bounding box.


  testing top  
 

isEchoEnabled

Shall the recognizer generate a graphical echo?


 

isRunning

Is the recognize running?


 

shouldEscape


class methods
  computation top  
 

degreesX:y:

Answer the angle (in integer-degrees [0, 359]) of the vector x@y.
This is an approximation with accuracy +/-1 degree


  instance creation top  
 

dictionary:


 

dictionary:displayProperties:


  version top  
 

checkPluginVersion

Use this method to check whether the Genie version in the image is compatible
to the Genie VM plugin.
The method returns a Boolean and writes some more information on Transcript.
Note: Plugin and Image are compatible when they have the same major number


 

majorNO


 

minorNO


 

versionNO


 

versionString