public interface IAnprEngine
Using ANPR Engine from Activity
open(com.sdtoolkit.anpr.api.IAnprEngineListener, android.content.Intent)
from Activity.onCreate(android.os.Bundle)
methodclose()
from Activity.onDestroy()
methodIAnprEngineListener.onAnprOpened(int, com.sdtoolkit.anpr.api.DeviceParams, com.sdtoolkit.anpr.api.RecognitionParams)
method adding a call то setup(com.sdtoolkit.anpr.api.DeviceParams)
method:
`@Override`
public void onAnprOpened(int result, DeviceParams currentDeviceParams,
RecognitionParams currentRecognitionParams) {
if (!mAnprEngine.isRecognitionRunning()) {
mAnprEngine.setup(currentDeviceParams);
}
}
beginRecognition(com.sdtoolkit.anpr.api.RecognitionParams)
as a response to Start command from UI.endRecognition()
as a response to Stop command from UI.ANPR Service Lifecycle
The SD-TOOLKIT ANPR Service lifecycle is demonstrated on the diagram below.
The Service can be in one of following states:
IAnprEngine
instances and is ready to operate.
See open(com.sdtoolkit.anpr.api.IAnprEngineListener, android.content.Intent)
for more details. Service will stop itself (returns back to Killed state)
if all connected instances will call close()
IAnprEngine
instances
which calls setup(DeviceParams)
thus initializing camera device session. Subsequent calls
to open(com.sdtoolkit.anpr.api.IAnprEngineListener, android.content.Intent)
will not modify ANPR Service State. However, if all connected IAnprEngine
instances
will disconnect by calling close()
, ANPR Service will close camera session and terminates self
(returning back to KILLED state).IAnprEngine
instances calls beginRecognition(RecognitionParams)
thus initializing actual license plate recognition from camera device video stream. Subsequent calls to
open(com.sdtoolkit.anpr.api.IAnprEngineListener, android.content.Intent)
or close()
will not modify ANPR Service state. It will continue to run
recognition reading camera device stream. This secure no interruption of recognition session event
if screen is off. To stop recognition (and return back to PREVIEW state) one of connected
instances must call endRecognition()
For a complete example please refer to: ANPR Reader sources on github
Modifier and Type | Method and Description |
---|---|
int |
activateLicenseKey(java.lang.String runtimeLicense)
Method activates purchased runtime license of ANPR Service.
|
void |
addPreviewSurface(android.view.Surface surface,
int width,
int height,
int rotation)
Method adds preview surface to ANPR Engine
|
int |
beginRecognition(RecognitionParams recognitionParams)
Method starts actual recognition engine and video capturing.
|
boolean |
close()
Method unregisters listener previously registered by a call to
open(com.sdtoolkit.anpr.api.IAnprEngineListener, android.content.Intent) . |
int |
endRecognition()
Method stops the recognition capture.
|
IAnprDeviceDirectControl |
getDeviceDirectContorl()
Method returns direct device control interface if supported by the implementation
|
java.lang.String[] |
getExternalCameraNames()
Method returns string array filled in with external cameras names connected to the device
|
boolean |
isLicensed()
Method report licensing status of ANPR Service
|
boolean |
isRecognitionRunning()
Method is used to check if recognition capture session is already running.
|
boolean |
open(IAnprEngineListener listener,
android.content.Intent notifyIconIntent)
Method starts ANPR Serivice and registers listener to receive recognition notifications.
|
void |
removePreviewSurface(android.view.Surface surface)
Method removes preview surface
|
void |
setFocusPosOnSurface(android.view.Surface surface,
float posX,
float posY)
Sets focus position on the surface triggering camera auto focus command
|
boolean |
setup(DeviceParams deviceParams)
Method setup the recognition engine and camera device.
|
boolean |
setZoomFactor(float zoomFactor)
Sets zoom factor of camera.
|
void |
updatePreviewSurface(android.view.Surface surface,
int width,
int height,
int rotation)
Method updates preview surface dimensions and orientation
|
boolean open(IAnprEngineListener listener, android.content.Intent notifyIconIntent)
close()
to release binder connection.listener
- listener to receive ANPR engine status updatesnotifyIconIntent
- intent to be called when user clicks on notification bar iconboolean close()
open(com.sdtoolkit.anpr.api.IAnprEngineListener, android.content.Intent)
.
This method also release binder connection to the Service. The service and recognition
session will remain active.boolean isLicensed()
int activateLicenseKey(java.lang.String runtimeLicense)
isLicensed()
returns false.runtimeLicense
- a valid runtime license key obtained either by ordering it at
sd-toolkit.com
or as in-app purchase available over SD-TOOLKIT ANPR Service control panelAnprErrors
boolean setup(DeviceParams deviceParams)
IAnprEngineListener.onAnprSetupComplete(int, com.sdtoolkit.anpr.api.DeviceParams)
will be called to inform the caller
about resultsdeviceParams
- video capture session parametersint beginRecognition(RecognitionParams recognitionParams)
IAnprEngineListener.onAnprResult(int, com.sdtoolkit.anpr.api.AnprResult[], android.graphics.Bitmap)
will be calledrecognitionParams
- anpr engine parametersAnprErrors.SUCCESS
on success or one of error values defined in AnprErrors
int endRecognition()
IAnprEngineListener.onAnprStopped(int)
will be called.AnprErrors.SUCCESS
on success or one of error values defined in AnprErrors
boolean isRecognitionRunning()
void addPreviewSurface(android.view.Surface surface, int width, int height, int rotation)
surface
- a valid surface to which camera preview will be renderedwidth
- width of preview surface in pixelsheight
- height of preview surface in pixelsrotation
- rotation angle of the surface.void updatePreviewSurface(android.view.Surface surface, int width, int height, int rotation)
surface
- a valid surface previously added to ANPR Engine by a call to
addPreviewSurface(android.view.Surface, int, int, int)
width
- width of preview surface in pixelsheight
- height of preview surface in pixelsrotation
- rotation angle of the surface.void removePreviewSurface(android.view.Surface surface)
surface
- a valid surface previously added to ANPR Engine by a call to
addPreviewSurface(android.view.Surface, int, int, int)
void setFocusPosOnSurface(android.view.Surface surface, float posX, float posY)
surface
- a valid surface previously added to ANPR Engine by a call to
addPreviewSurface(android.view.Surface, int, int, int)
posX
- horizontal position in pixels on the surfaceposY
- vertical position in pixels on the surfaceboolean setZoomFactor(float zoomFactor)
DeviceParams.propZoomFactor()
zoomFactor
- a zoom factor of the camera in diapazon from 1.0f to 4.0fIAnprDeviceDirectControl getDeviceDirectContorl()
java.lang.String[] getExternalCameraNames()