PenProfile 2.x

Package com.livescribe.icr

Provides classes and interfaces for Intelligent Character Recognition (ICR).

See:
          Description

Class Summary
DetailedResult This class is not currently supported, but may be supported in a future release.
DetailedResult.CandidateEnumeration An Enumeration of recognition candidates.
ICRContext This class allows the application to use the Intelligent Character Recognition (ICR) engine.
Language Represents a language localized to a specific region or country.
LKDynamicResource A Linguistic Knowledge resource is used to enable the recognition of a set of words.
Resource This class is an abstraction of a generic ICR resource file.
SKDynamicResource This class is not currently supported, but may be supported in a future release.
WritingStyle This class defines the writing styles support by the Intelligent Character Recognition (ICR) feature.
 

Package com.livescribe.icr Description

Provides classes and interfaces for Intelligent Character Recognition (ICR).

In the future:

The main ICR features are as follows:

Here is an application sample that uses ICR to recognize one English word:

import com.livescribe.event.HWRListener;
import com.livescribe.event.PenTipListener;
import com.livescribe.event.StrokeListener;
import com.livescribe.icr.ICRContext;
import com.livescribe.penlet.PenletStateChangeException;

public class ICRApp extends Penlet
    implements HWRListener, StrokeListener, PenTipListener
{
    private ICRContext icrContext;

    public void initApp() throws PenletStateChangeException {
        // Acquire the ICR engine from the PenletContext

        try {
            icrContext = context.getICRContext(1000, this);
            icrContext.addResourceSet(icrContext.getSingleWordDefaultResourceSet());
        } catch (RuntimeException ex) {
            System.err.println("Error initializing HWR resources: " + ex);
            throw new PenletStateChangeException(ex.toString());
        }

        // Add the app as a listener for stroke and pen tip events

        context.addStrokeListener(this);
    }

    public void activateApp(int reason, Object[] params) {
        // Add listeners

        context.addStrokeListener(this);
        context.addPenTipListener(this);
    }

    public void deactivateApp(int reason) {
        // Remove listeners

        context.removePenTipListener(this);
        context.removeStrokeListener(this);

        // ICR

        icrContext.dispose();
        icrContext = null;
    }

    public void destroyApp() throws PenletStateChangeException {
    }

    // StrokeListener Methods

    public void strokeCreated(long time,
                              Region region,
                              PageInstance page) {
        icrEngine.addStroke(time);
    }

    // PenTipListener Methods

    public void penDown(long time,
                        Region region,
                        PageInstance pageInstance) {
        // Notify ICR to disable user-pause during stroke writing

        icrEngine.notifyPenDown(time);
    }

    public void doubleTap(long time, int x, int y) { }
    public void penUp(long time, Region region, PageInstance page) { }
    public void singleTap(long time, int x, int y) { }

    // HWRListener Methods

    public void hwrResult(long time, String result) {
        System.out.println("Intermediate recognition result = " + result);
    }

    public void hwrUserPause(long time, String result) {
        System.out.println("Final recognition result = " + result);
    }

    public void hwrError(long time, String error) {
        System.out.println("Error in HWR: " + error);
    }

    public void hwrCrossingOut(long time, String result) {
        System.out.println("Entry was crossed-out: result = " + result);
    }
}


PenProfile 2.x

Copyright © 2010 Livescribe Inc. All Rights Reserved.
Confidential and subject to NDA.