-
Notifications
You must be signed in to change notification settings - Fork 408
Configuration Kotlin
Dionysis Lorentzos edited this page Jul 4, 2018
·
3 revisions
To configure Fotoapparat
in Kotlin:
You can initialise an instance of FotoApparat like below. That's an example of fully adjusted configuration. Some values are optional.
Fotoapparat(
context = this,
view = cameraView, // view which will draw the camera preview
scaleType = ScaleType.CenterCrop, // (optional) we want the preview to fill the view
lensPosition = back(), // (optional) we want back camera
cameraConfiguration = cameraConfiguration, // (optional) define an advanced configuration
logger = loggers( // (optional) we want to log camera events in 2 places at once
logcat(), // ... in logcat
fileLogger(this) // ... and to file
),
cameraErrorCallback = { error -> } // (optional) log fatal errors
)
An example of fully adjusted camera configuration is shown below. All values are optional by default
val cameraConfiguration = CameraConfiguration(
pictureResolution = highestResolution(), // (optional) we want to have the highest possible photo resolution
previewResolution = highestResolution(), // (optional) we want to have the highest possible preview resolution
previewFpsRange = highestFps(), // (optional) we want to have the best frame rate
focusMode = firstAvailable( // (optional) use the first focus mode which is supported by device
continuousFocusPicture(),
autoFocus(), // if continuous focus is not available on device, auto focus will be used
fixed() // if even auto focus is not available - fixed focus mode will be used
),
flashMode = firstAvailable( // (optional) similar to how it is done for focus mode, this time for flash
autoRedEye(),
autoFlash(),
torch(),
off()
),
antiBandingMode = firstAvailable( // (optional) similar to how it is done for focus mode & flash, now for anti banding
auto(),
hz50(),
hz60(),
none()
),
jpegQuality = manualJpegQuality(90), // (optional) select a jpeg quality of 90 (out of 0-100) values
sensorSensitivity = lowestSensorSensitivity(), // (optional) we want to have the lowest sensor sensitivity (ISO)
frameProcessor = { frame -> } // (optional) receives each frame from preview stream
)