SimpleLPR Java API Reference

Package com.warelogic.simplelpr — package overview

Package com.warelogic.simplelpr


package com.warelogic.simplelpr

Class Candidate

java.lang.Object
com.warelogic.simplelpr.Candidate

public final class Candidate extends Object
One license plate candidate found in an image. Immutable snapshot.

Counterpart of ICandidate in the .NET wrapper. Following the same policy as .NET, all candidate data is copied out of the native result as soon as an analyze* call returns, and the native handles are released immediately — so this class needs no close() and cannot dangle.

A candidate carries zero or more CountryMatch interpretations. The last entry in the list corresponds to the raw text before syntax validation — it carries an empty country/ISO code, and is the reason a plate usually appears twice in simple listings.

Class CountryMatch

java.lang.Object
com.warelogic.simplelpr.CountryMatch

public final class CountryMatch extends Object
The interpretation of a plate candidate according to one country's syntax rules. Immutable snapshot.

Counterpart of ICountryMatch in the .NET wrapper. All data is copied out of the native result at analysis time, so instances carry no native resources and never need disposing — they can be stored, logged or passed between threads freely.

Class Element

java.lang.Object
com.warelogic.simplelpr.Element

public final class Element extends Object
One recognized character within a license plate candidate. Immutable snapshot.

Counterpart of SIMPLELPR_Element / the .NET Element struct. Elements are listed by CountryMatch.getElements() in the same order as they appear in the plate text; to know the physical layout, use each element's bounding box.

Class EngineSetupParams

java.lang.Object
com.warelogic.simplelpr.EngineSetupParams

public final class EngineSetupParams extends Object
SimpleLPR engine initialization parameters.

Java counterpart of EngineSetupParms in the .NET wrapper. When a CUDA-compatible GPU is available it can be selected to off-load computation intensive tasks from the CPU; image processing and text candidate classification can be moved to the GPU independently. Since some of the image processing algorithms are memory consuming, the maximum number of concurrent image processing operations can also be capped. Defaults select CPU-only operation with the recommended concurrency.


 EngineSetupParams params = new EngineSetupParams(); // CPU, recommended settings
 try (SimpleLPR lpr = SimpleLPR.setup(params)) {
     ...
 }
 

Enum FrameFormat

java.lang.Object
java.lang.Enum<FrameFormat>
com.warelogic.simplelpr.FrameFormat
All Implemented Interfaces:
Serializable, Comparable<FrameFormat>

public enum FrameFormat extends Enum<FrameFormat>
Color format of frames delivered by a VideoSource. Counterpart of SIMPLELPR_FrameFormat.

Class PlateCandidateTracker

java.lang.Object
com.warelogic.simplelpr.PlateCandidateTracker
All Implemented Interfaces:
AutoCloseable

public final class PlateCandidateTracker extends Object implements AutoCloseable
Aggregates per-frame plate detections into temporal tracks: one physical plate seen across many frames becomes one TrackedPlateCandidate. The temporal correlation is resistant to OCR misreadings and partial detections — occasional bad frames are absorbed into the track instead of producing spurious reads.

Counterpart of IPlateCandidateTracker in the .NET wrapper. Create instances with SimpleLPR.createPlateCandidateTracker(com.warelogic.simplelpr.PlateCandidateTrackerSetupParams). Feed it every analyzed frame's result in presentation order via processFrameCandidates(PoolTrackingResult, VideoFrame), and call flush() at end of stream to close whatever is still being tracked. The tracker is single-stream and not thread-safe: feed it from one thread (typically the same loop that polls the pool).

Class PlateCandidateTrackerSetupParams

java.lang.Object
com.warelogic.simplelpr.PlateCandidateTrackerSetupParams

public final class PlateCandidateTrackerSetupParams extends Object
Configuration of a PlateCandidateTracker: temporal behavior and thumbnail sizing. Counterpart of PlateCandidateTrackerSetupParms in the .NET wrapper, with the same defaults.

Class Point

java.lang.Object
com.warelogic.simplelpr.Point

public final class Point extends Object
An (x, y) point in pixel coordinates. Immutable.

Counterpart of SIMPLELPR_Point. Defined here rather than reusing java.awt.Point to keep the wrapper free of the desktop (AWT) module, which matters for server deployments.

Class PoolResult

java.lang.Object
com.warelogic.simplelpr.PoolResult

public final class PoolResult extends Object
The outcome of one asynchronous request submitted to a ProcessorPool. Immutable snapshot: all data is copied out of the native result at poll time and the native handles are released before pollNextResult returns.

Counterpart of IProcessorPoolResult in the .NET wrapper. A result is either a success — getCandidates() holds the recognition outcome — or a failure — getError() describes what went wrong for that request (for example, an unreadable image file). Per-request failures are reported here rather than thrown, so one bad image does not abort a batch.

Class PoolTrackingResult

java.lang.Object
com.warelogic.simplelpr.PoolTrackingResult
All Implemented Interfaces:
AutoCloseable

public final class PoolTrackingResult extends Object implements AutoCloseable
A pool result polled through ProcessorPool.pollNextTrackingResult(int, int) — the tracking-oriented sibling of PoolResult.

Why two result types? The PlateCandidateTracker consumes recognition results natively, so this result must keep the native candidates handle alive until it has been fed to the tracker. That makes it the mirror of the .NET IProcessorPoolResult (which is IDisposable for the same reason), and it is why this class — unlike PoolResult — is AutoCloseable: close it after passing it to the tracker, ideally with try-with-resources. When no tracking is involved, use the plain pollNextResult and never think about disposal.

Class Processor

java.lang.Object
com.warelogic.simplelpr.Processor
All Implemented Interfaces:
AutoCloseable

public final class Processor extends Object implements AutoCloseable
A license plate recognition processor.

Counterpart of IProcessor in the .NET wrapper. Create instances with SimpleLPR.createProcessor(); each processor analyzes one image at a time, so use one processor per thread (or, in a later increment, a processor pool).

Like the engine, a processor owns a native handle: release it with close(), ideally via try-with-resources (the Java analog of C#'s using block):


 try (Processor proc = lpr.createProcessor()) {
     List<Candidate> candidates = proc.analyzeFile(Paths.get("car.jpg"));
     for (Candidate c : candidates)
         for (CountryMatch m : c.getMatches())
             System.out.println(m.getText() + " [" + m.getCountryISO() + "]");
 }
 

Results are returned as immutable Candidate snapshots: every value is copied out of the native result and the native handles are released before the analyze* method returns (same eager-release policy as the .NET wrapper), so result objects never require disposal.

Disposal ordering note: the native layer is ordering-tolerant as of 3.6.4, so closing the engine before its processors is safe, though closing children first remains the tidy pattern the samples demonstrate.

Class ProcessorPool

java.lang.Object
com.warelogic.simplelpr.ProcessorPool
All Implemented Interfaces:
AutoCloseable

public final class ProcessorPool extends Object implements AutoCloseable
A pool of recognition processors fed through an asynchronous request queue — the high-throughput way of using SimpleLPR.

Counterpart of IProcessorPool in the .NET wrapper. Create instances with SimpleLPR.createProcessorPool(int). Requests are submitted with the launchAnalyze* methods and results collected with pollNextResult(int, int); results may arrive in any order, so callers correlate them through the request id they supplied at launch. The canonical batch pattern (identical to the .NET samples):


 try (ProcessorPool pool = lpr.createProcessorPool(poolSize)) {
     long requestId = 0;
     for (Path image : images) {
         pool.launchAnalyzeFile(0, requestId++, 0.0, ProcessorPool.TIMEOUT_INFINITE, image);
         // Drain whatever is already done, without blocking:
         for (PoolResult r; (r = pool.pollNextResult(0, ProcessorPool.TIMEOUT_IMMEDIATE)) != null; )
             handle(r);
     }
     // All submitted; wait for the stragglers:
     while (pool.getOngoingRequestCount(0) > 0)
         handle(pool.pollNextResult(0, ProcessorPool.TIMEOUT_INFINITE));
 }
 

Stream ids partition the pool's queues: requests and results with different stream ids never mix, which lets independent producers (e.g. two cameras) share one pool. Single-source applications simply use stream 0 throughout.

Class Rect

java.lang.Object
com.warelogic.simplelpr.Rect

public final class Rect extends Object
A rectangle in pixel coordinates. Immutable.

Counterpart of SIMPLELPR_Rect / the .NET wrapper's rectangle type.

Class SimpleLPR

java.lang.Object
com.warelogic.simplelpr.SimpleLPR
All Implemented Interfaces:
AutoCloseable

public final class SimpleLPR extends Object implements AutoCloseable
Entry point of the SimpleLPR Java wrapper: represents the recognition engine.

Java counterpart of ISimpleLPR / SimpleLPRImpl in the .NET wrapper. Instances are created through the static setup(EngineSetupParams) factory methods and own a native engine handle; release it deterministically with close(), ideally through try-with-resources:


 try (SimpleLPR lpr = SimpleLPR.setup(new EngineSetupParams())) {
     System.out.println("SimpleLPR version " + lpr.getVersionNumber());
 }
 

A Cleaner releases the native handle as a safety net if close() is never invoked, but — as with the .NET wrapper's finalizers — deterministic disposal is the supported pattern.

Class SimpleLPRException

java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
com.warelogic.simplelpr.SimpleLPRException
All Implemented Interfaces:
Serializable

public class SimpleLPRException extends RuntimeException
Thrown when a SimpleLPR native call reports an error.

Carries the native SIMPLELPR_HRESULT error code when one is available (see IErrorInfo in the C API); hasErrorCode() tells whether getErrorCode() is meaningful.

See Also:

Class TrackedPlateCandidate

java.lang.Object
com.warelogic.simplelpr.TrackedPlateCandidate
All Implemented Interfaces:
AutoCloseable

public final class TrackedPlateCandidate extends Object implements AutoCloseable
One tracked license plate: the aggregation of many per-frame detections of the same physical plate over time.

Counterpart of ITrackedPlateCandidate in the .NET wrapper. All scalar data and the representative Candidate are eager snapshots; the one live resource is getRepresentativeThumbnail() — a VideoFrame holding the cropped plate image — which is why this class is AutoCloseable (closing it closes the thumbnail). Save or copy the thumbnail before closing if you need it afterwards.

Class TrackerResult

java.lang.Object
com.warelogic.simplelpr.TrackerResult
All Implemented Interfaces:
AutoCloseable

public final class TrackerResult extends Object implements AutoCloseable
The outcome of feeding one frame's candidates to a PlateCandidateTracker (or of PlateCandidateTracker.flush()).

Counterpart of IPlateCandidateTrackerResult in the .NET wrapper. getNewTracks() lists plates whose trigger conditions were just met; getClosedTracks() lists tracks that just ended. Both are usually empty — results with content are the events an application reacts to.

AutoCloseable because each contained TrackedPlateCandidate owns a live thumbnail frame; closing the result closes them all (individually idempotent, so closing a track twice is harmless).

Class VersionNumber

java.lang.Object
com.warelogic.simplelpr.VersionNumber

public final class VersionNumber extends Object
SimpleLPR version number (A.B.C.D). Immutable.

Java counterpart of VersionNumber in the .NET wrapper. (A plain class rather than a record: the wrapper targets Java 11.)

Class VideoFrame

java.lang.Object
com.warelogic.simplelpr.VideoFrame
All Implemented Interfaces:
AutoCloseable

public final class VideoFrame extends Object implements AutoCloseable
One video frame delivered by a VideoSource.

Counterpart of IVideoFrame in the .NET wrapper — and, deliberately, the one object in this wrapper that is not an eager snapshot: a frame wraps the native pixel buffer directly, because copying every frame of a video stream would be prohibitively expensive.

Close frames promptly

Each open frame pins megabytes of native memory that the Java garbage collector cannot see: unlike .NET (whose wrapper calls GC.AddMemoryPressure), the JVM offers no way to report native allocations, so nothing nudges the GC to collect forgotten frames. Always close each frame as soon as it has been used — the standard shape is a try-with-resources around every frame, as the video samples demonstrate:


 for (VideoFrame frame; (frame = source.nextFrame()) != null; ) {
     try (VideoFrame f = frame) {          // guarantees close, even on exceptions
         process(proc.analyzeVideoFrame(f));
     }
 }
 

A Cleaner releases leaked frames eventually, but only when the GC happens to run — treat it strictly as a safety net.

Class VideoSource

java.lang.Object
com.warelogic.simplelpr.VideoSource
All Implemented Interfaces:
AutoCloseable

public final class VideoSource extends Object implements AutoCloseable
A source of video frames: a video file, an RTSP/HTTP stream URL, or any other URI the engine's FFmpeg-based backend understands.

Counterpart of IVideoSource in the .NET wrapper. Create instances with SimpleLPR.openVideoSource(java.lang.String, com.warelogic.simplelpr.FrameFormat, int, int); pull frames with nextFrame() until it returns null, then consult getState() to distinguish a normal end of stream (VideoSourceState.EOF) from an error. Live sources that hit an I/O error can be revived with reconnect().

Every frame returned by nextFrame() is owned by the caller and must be closed promptly — see the class comment of VideoFrame for why this matters more in Java than it did in .NET.

Enum VideoSourceState

java.lang.Object
java.lang.Enum<VideoSourceState>
com.warelogic.simplelpr.VideoSourceState
All Implemented Interfaces:
Serializable, Comparable<VideoSourceState>

public enum VideoSourceState extends Enum<VideoSourceState>
Lifecycle state of a VideoSource. Counterpart of SimpleLPR_VideoSourceState.