Skip to content

Configuration

Create one CircadifySDK instance for the screen or flow that performs measurements. Only apiKey is required.

import com.circadify.sdk.CircadifySDK
val sdk = CircadifySDK(
context = context,
apiKey = "ck_live_your_key_here",
)

For full control, pass a CircadifyConfig:

import com.circadify.sdk.CircadifyCallbacks
import com.circadify.sdk.CircadifyConfig
import com.circadify.sdk.CircadifySDK
val sdk = CircadifySDK(
context = context,
config = CircadifyConfig(
apiKey = "ck_live_your_key_here",
baseUrl = "https://api.circadify.com",
measurementDurationSeconds = 30,
targetCaptureFps = 10,
minimumAcceptedFrames = 150,
maximumAcceptedFrames = 720,
debug = false,
onDeviceOnly = true,
callbacks = CircadifyCallbacks(
onProgress = { event -> updateProgress(event.percent, event.phase) },
onQualityState = { state -> updateQualityMeters(state) },
onQualityWarning = { warning -> showQualityHint(warning.message) },
onLandmarks = { landmarks -> renderFaceOverlay(landmarks) },
onCameraReady = { info -> showPreviewReady(info.hasPreviewSurface) },
),
),
)
PropertyTypeDefaultDescription
apiKeyString-Required. Your API key (ck_live_*).
baseUrlString"https://api.circadify.com"API base URL.
measurementDurationSecondsInt30Target measurement window and timeout basis. Upload can start earlier once enough quality frames are accepted.
targetCaptureFpsInt10Analysis frame-rate target. Lower values reduce CPU, heat, and bitmap allocation pressure on lower-end devices.
minimumAcceptedFramesInt150Minimum quality frames required before a measurement can finish.
maximumAcceptedFramesInt720Safety cap for accepted frames and in-memory tensor size.
debugBooleanfalseEnables Android logcat debug logging.
onDeviceOnlyBooleantrueRequests the standard on-device capture and measurement preparation path.
callbacksCircadifyCallbacksempty callbacksProgress, quality, landmark, and camera readiness callbacks.

Callbacks are optional. Use them to build the scan UI around the headless SDK.

data class CircadifyCallbacks(
val onProgress: ((ProgressEvent) -> Unit)? = null,
val onQualityWarning: ((QualityWarning) -> Unit)? = null,
val onQualityState: ((QualityState) -> Unit)? = null,
val onLandmarks: ((List<Landmark>) -> Unit)? = null,
val onCameraReady: ((CameraReadyInfo) -> Unit)? = null,
)

SDK callbacks are delivered on the Android main thread. Heavy capture, ROI extraction, tensor preparation, upload, and result polling are dispatched internally by the SDK.

callbacks = CircadifyCallbacks(
onProgress = { event ->
progressBar.progress = event.percent
statusText.text = event.phase.name.lowercase()
qualityFramesText.text = "${event.acceptedFrames ?: 0}/${event.targetFrames ?: 0}"
},
)
PhaseDescription
INITIALIZINGCreating a session and preparing capture
READINESSWaiting for a scan-ready face and acceptable quality
CAPTURINGCapturing the measurement
UPLOADINGUploading the measurement payload
PROCESSINGWaiting for results

During CAPTURING, ProgressEvent can include acceptedFrames, targetFrames, captureFps, and remainingSeconds. Use these fields for developer diagnostics or subtle scan copy, but avoid making users interpret raw frame counts.

onQualityState emits the current lighting, motion, pose, readiness flag, and messages. Use it for persistent UI such as quality meters.

callbacks = CircadifyCallbacks(
onQualityState = { state ->
if (!state.isReady && state.messages.isNotEmpty()) {
statusText.text = state.messages.first()
}
},
)

onQualityWarning emits short-lived guidance such as lighting, motion, face position, or occlusion warnings.

callbacks = CircadifyCallbacks(
onQualityWarning = { warning ->
showToast(warning.message)
},
)

onLandmarks emits normalized face landmarks. Use it only when you need a custom overlay.

callbacks = CircadifyCallbacks(
onLandmarks = { landmarks ->
overlayView.render(landmarks)
},
)

Pass MeasurementOptions each time you call measureVitals().

val cancellationSignal = CancellationSignal()
val result = sdk.measureVitals(
MeasurementOptions(
lifecycleOwner = lifecycleOwner,
previewView = previewView,
demographics = Demographics(age = 35, sex = Sex.M, fitzpatrick = 3),
cancellationSignal = cancellationSignal,
),
)
PropertyTypeRequiredDescription
lifecycleOwnerLifecycleOwnerYesLifecycle used by CameraX to bind and release camera use cases.
previewViewPreviewView?NoCaller-owned CameraX preview surface. Pass null for headless capture.
demographicsDemographics?NoOptional age, sex, and Fitzpatrick skin type.
cancellationSignalCancellationSignal?NoCancels the measurement without cancelling the whole coroutine scope.

Demographics is optional but can improve measurement accuracy when provided.

FieldTypeNotes
ageInt?User age in years. Constructor enforces 0..130.
sexSex?Sex.M or Sex.F. Each constant’s apiValue is what gets sent on the wire.
fitzpatrickInt?Fitzpatrick skin type. Constructor enforces 1..6.