Skip to content

Instantly share code, notes, and snippets.


Oscar Wahltinez owahltinez

View GitHub Profile
View brazil_municipalities.csv
key country_code country_name subregion1_code subregion1_name subregion2_code subregion2_name locality_code locality_name match_string aggregate_report_offset
BR_AC_1200013 BR Brazil AC Acre 1200013 Acrelândia
BR_AC_1200054 BR Brazil AC Acre 1200054 Assis Brasil
BR_AC_1200104 BR Brazil AC Acre 1200104 Brasiléia
BR_AC_1200138 BR Brazil AC Acre 1200138 Bujari
BR_AC_1200179 BR Brazil AC Acre 1200179 Capixaba
BR_AC_1200203 BR Brazil AC Acre 1200203 Cruzeiro do Sul
BR_AC_1200252 BR Brazil AC Acre 1200252 Epitaciolândia
BR_AC_1200302 BR Brazil AC Acre 1200302 Feijó
BR_AC_1200328 BR Brazil AC Acre 1200328 Jordão
owahltinez / data_loading.ipynb
Created May 4, 2020
View data_loading.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View core-principles-2.kt
// RECOMMENDED: Bind use cases to a lifecycle in a single call:
this as LifecycleOwner, preview, imageCapture, imageAnalyzer)
// Do *NOT* bind your use cases like this
CameraX.bindToLifecycle(this as LifecycleOwner, preview)
CameraX.bindToLifecycle(this as LifecycleOwner, imageCapture)
CameraX.bindToLifecycle(this as LifecycleOwner, imageAnalyzer)
View core-principles-1.kt
// STEP 1: Define use case configuration
val imageCaptureConfig = ImageCaptureConfig.Builder()
.setTargetResolution(Size(1280, 720))
// STEP 2: Create the use case object
val imageCapture = ImageCapture(imageCaptureConfig)
// STEP 3: Bind the use case to our lifecycle
CameraX.bindToLifecycle(this as LifecycleOwner, imageCapture)
View studioFlags.xml
<component name="StudioFlags">
<option name="data">
<!-- This flag enables experimental automotive templates -->
<entry key="npw.templates.automotive" value="true" />
View multi-camera-api-6.kt
val cameraSession: CameraCaptureSession = ...
// Use still capture template to build our capture request
val captureRequest = cameraSession.device.createCaptureRequest(
// Determine if this device supports distortion correction
val characteristics: CameraCharacteristics = ...
val supportsDistortionCorrection = characteristics.get(
View multi-camera-api-5.kt
val cameraManager: CameraManager = ...
// Get the two output targets from the activity / fragment
val surface1 = ... // from SurfaceView
val surface2 = ... // from SurfaceView
val dualCamera = findShortLongCameraPair(manager)!!
val outputTargets = DualCameraOutputs(
null, mutableListOf(surface1), mutableListOf(surface2))
View multi-camera-api-4.kt
fun findShortLongCameraPair(manager: CameraManager, facing: Int? = null): DualCamera? {
return findDualCameras(manager, facing).map {
val characteristics1 = manager.getCameraCharacteristics(it.physicalId1)
val characteristics2 = manager.getCameraCharacteristics(it.physicalId2)
// Query the focal lengths advertised by each physical camera
val focalLengths1 = characteristics1.get(
CameraCharacteristics.LENS_INFO_AVAILABLE_FOCAL_LENGTHS) ?: floatArrayOf(0F)
val focalLengths2 = characteristics2.get(
View multi-camera-api-3.kt
* Helper type definition that encapsulates 3 sets of output targets:
* 1. Logical camera
* 2. First physical camera
* 3. Second physical camera
typealias DualCameraOutputs =
Triple<MutableList<Surface>?, MutableList<Surface>?, MutableList<Surface>?>
View multi-camera-api-2.kt
fun openDualCamera(cameraManager: CameraManager,
dualCamera: DualCamera,
executor: Executor = AsyncTask.SERIAL_EXECUTOR,
callback: (CameraDevice) -> Unit) {
dualCamera.logicalId, executor, object : CameraDevice.StateCallback() {
override fun onOpened(device: CameraDevice) = callback(device)
// Omitting for brevity...
override fun onError(device: CameraDevice, error: Int) = onDisconnected(device)
You can’t perform that action at this time.