IStmDetectionConfig
The SDK detection configuration interface (IStmDetectionConfig) is an optional interface. The interface is
used for configuring underlying SDK components, which are related to the detection. You can
consume this class by subclassing it, which enables lazy value computation.
Interface
Kotlin:
open class IStmDetectionConfig {
/**
* Detection types
*/
sealed class StmDetectionType
class General(
val detections: List<GeneralDetection>
) : StmDetectionType() {
data class GeneralDetection(
val classifier: Classifier,
val threshold: Float = 0.5f)
public enum class Classifier {
UNKNOWN,
TEXT,
FACE,
GUN,
FINGERPRINT,
ISIS_FLAG,
CANNON,
MILITARY_UNIFORM,
MEDIA_ALKHAYR,
ARMY_TANK,
MEDIA_JUND_ALLAH,
SKI_MASK,
SCREENSHOT,
PASSPORT,
MAP,
IDENTITY_CARD,
MEDIA_ALFURQAN,
LICENSEPLATE,
MEDIA_ALFALLUJAH,
DOCUMENT,
MEDIA_STUDIO_FETWA,
ROCKET,
TEARDROP_TATTOO,
POLICE_UNIFORM,
PORN,
SWASTIKA,
HELLS_ANGELS,
MEDICATION,
TIGER,
HOLSTER,
BULLETPROOF_VEST,
PAPER_MONEY,
RECEIPT,
MEDIA_ALMOURABITOUN,
TATTOO,
MASK;
}
companion object {
fun defaultDetections(): List<GeneralDetection> {
return Classifier.values().map {
GeneralDetection(it)
}
}
}
}
class CSA(
val detections: List<CsaDetection>
) : StmDetectionType() {
data class CsaDetection(
val classifier: Classifier,
val threshold: Float = 0.5f)
public enum class Classifier {
UNKNOWN,
U5_GENITALS,
U5_NAKED,
U5_UNDERWEAR,
U10_GENITALS,
U10_NAKED,
U10_UNDERWEAR,
U15_GENITALS,
U15_NAKED,
U15_UNDERWEAR,
FACE_CLOSEUP;
}
companion object {
fun defaultDetections(): List<CsaDetection> {
return Classifier.values().map {
CsaDetection(it)
}
}
}
}
/**
* Function to be override.
*/
open fun hitBasedOnly(): Boolean = false
// detection chain
// if there are multiple models configured; the general model should be always the first one
open fun detectionChain(): List<StmDetectionType> = listOf(
General(General.defaultDetections()),
CSA(CSA.defaultDetections())
)
}
Example
Kotlin:
class StmDetectionConfig() : IStmDetectionConfig() {
override fun hitBasedOnly(): Boolean = True
override fun detectionChain(): List<StmDetectionType> = ...
}
Java:
public class StmDetectionConfig extends IStmDetectionConfig {
public StmDetectionConfig() {
super();
}
@Nullable
@Override
public Boolean hitBasedOnly() {
return true;
}
@Override
public List<StmDetectionType> detectionChain() {
return ...
}
}
Usage
The detectionConfig needs to be configured via the StmDetection object.
Set the detectionConfig at the StmDetection object (StmDetection)
Kotlin:
val stmDetection = StmDetection(
activity = this,
globalConfig = stmGlobalConfig,
detectionConfig = stmDetectionConfig,
flowDelegate = this)
Java:
StmDetection stmDetection = new StmDetection(
this,
stmGlobalConfig,
stmDetectionConfig,
this)
Additive
The IStmFlowDelegate parameter in the StmDetection constructor receives messages about detection progress and results.
The SDK global configuration interface (IStmGlobalConfig) is used for configuring underlying SDK components, such as API keys, and global configurations.