StmDetection
The SDK Detection object (StmDetection) is the SDK's central part.
It internally manages the whole detection logic based on the IBcmDetectionConfig.
You can consume this class by creating an instance via the related constructor parameters (StmDetection).
The SDK Detection object is configured using an instance of the IStmGlobalConfig and the IStmDetectionConfig.
Progress and results are reported to an object implementing the IStmFlowDelegate interface.
Please refer to the usage examples for a high-level overview of the StmDetection.
Interface
Kotlin:
open class StmDetection(
activity: Activity,
/**
* Global Config
*/
globalConfig: IStmGlobalConfig,
/**
* Detection Config
*/
private val detectionConfig: IStmDetectionConfig = IStmDetectionConfig(),
/**
* A delegate object for detection flow events
*/
flowDelegate: IStmFlowDelegate
) {
companion object {
/**
* Information about the required permissions.
*/
fun getRequiredPermissions(): Array<String>? {
return arrayOf()
}
}
public fun recognizeImage(
bitmap: Bitmap
) {
od.recognizeImage(bitmap)
}
}
Java:
public class StmDetection {
/**
* An object enables basic configuration of SDK behavior.
*/
public IStmGlobalConfig globalConfig = new IStmGlobalConfig();
/**
* An instance of IBcmScanConfig, which may be changed/replaced at will prior to presenting the scan fragment
*/
public IStmDetectionConfig detectionConfig = new IStmDetectionConfig();
/**
* A delegate object for scan flow events
*/
public IStmFlowDelegate flowDelegate = null;
}
Usage
Configuring the Detection object
To use the SDKs Detection class, it is required to create an instance of the StmDetection.
Your instance maintains the SDK's global configuration using the IStmGlobalConfig interface.
The IStmGlobalConfig object can be set via the constructor, using the globalConfig field.
Additionally, you may change the Detection behavior by providing your own instance of detectionConfig or changing values of the configuration object.
For a list of configurable options, please refer to the class documentation of IStmScanConfig.
Assign a flowDelegate object to receive information about detection progress and the final results (IStmFlowDelegate).
Kotlin:
class YourStmDetectionActivity : Activity(), IStmFlowDelegate {
class StmGlobalConfigOverride : IStmGlobalConfig() {
open fun licensing(): StmLicensing = Offline("license-key")
}
class StmDetectionConfigOverride : IStmScanConfig() {
open fun hitBasedOnly(): Boolean = false
...
}
var stmDetection: StmDetection? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
stmDetection = StmDetection(
activity = this,
globalConfig = StmGlobalConfigOverride(),
detectionConfig = StmDetectionConfigOverride(),
flowDelegate = this)
}
...
}
Java:
public class YourStmDetectionActivity extends Activity implements IStmFlowDelegate {
class StmGlobalConfigOverride extends IStmGlobalConfig {
@Nullable
@Override
public StmLicensing licensing() {
return ...;
}
}
StmDetection stmDetection = null;
class StmDetectionConfigOverride extends IStmScanConfig {
@Nullable
@Override
public ScanTerminationOptions scanTerminationOption() {
return ...;
}
}
@Override
void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
stmDetection = new StmDetection(
this,
new StmGlobalConfigOverride(),
new StmDetectionConfigOverride(),
this)
}
...
}
The settings are applied for all future detection sessions during your Detection object lifetime.