Upgrade to Pro — share decks privately, control downloads, hide ads and more …

After I/O Istanbul Jetpack CameraX

After I/O Istanbul Jetpack CameraX

A6c0dcba5f373b33df2c2c55540faab1?s=128

Hadi Tok

June 29, 2019
Tweet

Transcript

  1. Jetpack CameraX GDG Istanbul After I/O 2019

  2. Jetpack CameraX Hadi Tok CitizenMe @hadi_tok

  3. Android versiyonlari End Android Kamera API Problemleri Cihaz ve Üretici

    Çeşitliliği Karmaşık API
  4. CameraX nedir? • Daha kolay kamera uygulamaları geliştirmeye yardımcı •

    Açık kaynak • Alpha
  5. Android 5+ End CameraX Tüm köşe senaryolar kapsanmış Arka planda

    Camera2 API kullanan basit API
  6. CameraX • Lifecycle ile uyumlu • Portrait, HDR, Night, ve

    Beauty • Eklenti alabiliyor
  7. CameraX Ön İzleme Görüntü Analizi Görüntü Yakalama

  8. Ön İzleme

  9. val viewFinderConfig = PreviewConfig.Builder().build()

  10. val viewFinderConfig = PreviewConfig.Builder().build() val preview = AutoFitPreviewBuilder.build(viewFinderConfig, viewFinder)

  11. val viewFinderConfig = PreviewConfig.Builder().build() val preview = AutoFitPreviewBuilder.build(viewFinderConfig, viewFinder) preview.setOnPreviewOutputUpdateListener

    { previewOutput -> //use previewOutput.surfaceTexture if needed }
  12. val viewFinderConfig = PreviewConfig.Builder().build() val preview = AutoFitPreviewBuilder.build(viewFinderConfig, viewFinder) preview.setOnPreviewOutputUpdateListener

    { previewOutput -> //use previewOutput.surfaceTexture if needed } CameraX.bindToLifecycle(this, preview)
  13. val viewFinderConfig = PreviewConfig.Builder().build() val preview = AutoFitPreviewBuilder.build(viewFinderConfig, viewFinder) preview.setOnPreviewOutputUpdateListener

    { previewOutput -> //use previewOutput.surfaceTexture if needed } CameraX.bindToLifecycle(this, preview)
  14. Görüntü Analizi

  15. val imageAnalysisConfig = ImageAnalysisConfig.Builder() .setTargetResolution(Size(1280, 730)) .build()

  16. val imageAnalysisConfig = ImageAnalysisConfig.Builder() .setTargetResolution(Size(1280, 730)) .build() val imageAnalysis =

    ImageAnalysis(imageAnalysisConfig)
  17. val imageAnalysisConfig = ImageAnalysisConfig.Builder() .setTargetResolution(Size(1280, 730)) .build() val imageAnalysis =

    ImageAnalysis(imageAnalysisConfig) imageAnalysis.setAnalyzer { imageProxy, rotationDegrees -> //do image analysis }
  18. val imageAnalysisConfig = ImageAnalysisConfig.Builder() .setTargetResolution(Size(1280, 730)) .build() val imageAnalysis =

    ImageAnalysis(imageAnalysisConfig) imageAnalysis.setAnalyzer { imageProxy, rotationDegrees -> //do image analysis } CameraX.bindToLifecycle(this, imageAnalysis, preview)
  19. val imageAnalysisConfig = ImageAnalysisConfig.Builder() .setTargetResolution(Size(1280, 730)) .build() val imageAnalysis =

    ImageAnalysis(imageAnalysisConfig) imageAnalysis.setAnalyzer { imageProxy, rotationDegrees -> //do image analysis } CameraX.bindToLifecycle(this, imageAnalysis, preview)
  20. Görüntü Yakalama

  21. val imageCaptureConfig = ImageCaptureConfig.Builder() .build()

  22. val imageCaptureConfig = ImageCaptureConfig.Builder() .build() val imageCapture = ImageCapture(imageCaptureConfig)

  23. val imageCaptureConfig = ImageCaptureConfig.Builder() .build() val imageCapture = ImageCapture(imageCaptureConfig) CameraX.bindToLifecycle(

    this, preview, imageCapture, imageAnalyzer)
  24. val imageCaptureConfig = ImageCaptureConfig.Builder() .build() val imageCapture = ImageCapture(imageCaptureConfig) CameraX.bindToLifecycle(

    this, preview, imageCapture, imageAnalyzer)
  25. val imageSaveListener = object : ImageCapture.OnImageSavedListener { override fun onImageSaved(file:

    File) { //use the image file } override fun onError(useCaseError: ImageCapture.UseCaseError, message: String, cause: Throwable?) { //handle error } }
  26. val imageSaveListener = object : ImageCapture.OnImageSavedListener { override fun onImageSaved(file:

    File) { //use the image file } override fun onError(useCaseError: ImageCapture.UseCaseError, message: String, cause: Throwable?) { //handle error } } val photoFile = createFile(outputDirectory, FILENAME, PHOTO_EXTENSION)
  27. val imageSaveListener = object : ImageCapture.OnImageSavedListener { override fun onImageSaved(file:

    File) { //use the image file } override fun onError(useCaseError: ImageCapture.UseCaseError, message: String, cause: Throwable?) { //handle error } } val photoFile = createFile(outputDirectory, FILENAME, PHOTO_EXTENSION) imageCapture.takePicture(photoFile, imageSaveListener)
  28. val imageSaveListener = object : ImageCapture.OnImageSavedListener { override fun onImageSaved(file:

    File) { //use the image file } override fun onError(useCaseError: ImageCapture.UseCaseError, message: String, cause: Throwable?) { //handle error } } val photoFile = createFile(outputDirectory, FILENAME, PHOTO_EXTENSION) imageCapture.takePicture(photoFile, imageSaveListener)
  29. Kaynaklar • https://developer.android.com/training/camerax • https://www.youtube.com/watch?v=kuv8uK-5CLY • https://github.com/android/camera/tree/master/CameraXBasic

  30. Hadi Tok, CitizenMe @hadi_tok Teşekkürler

  31. Soru-Cevap