android / android/camera-samples
CameraX providing Distorted bitmap when saving ImageProxy to bitmap.
- Lingua principale
- Kotlin
- Stelle
- 5.5k
- Fork
- 2.4k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
When trying to save the bitmap from ImageProxy it save the bitmap as distorted but only in case of FrontCamera. we have tested on multiple devices the issues only appears in OnePlus6T on camera2 it was working properly. If we remove the imageCapture from bind to lifecycle then it start returning proper bitmap in OnepPlus6T devices as well.
Changes done instead of **setAspectRatio** **setTargetResolution** is used where size is calculated using
` val metrics = windowManager.getCurrentWindowMetrics().bounds`
ImageAnalzyer now looks like this.
` imageAnalyzer = ImageAnalysis.Builder()
.setTargetResolution(maxSize)
.setTargetRotation(rotation)
.setOutputImageFormat(ImageAnalysis.OUTPUT_IMAGE_FORMAT_RGBA_8888)
.setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST)
.build()
.also {
it.setAnalyzer(cameraExecutor, this)
}`
Bitmap is intialized
`bitmap = Bitmap.createBitmap(imageSize.width, imageSize.height, Bitmap.Config.ARGB_8888);`
Bitmap save is done in override analyze function
` bitmap!!.copyPixelsFromBuffer(image.image!!.planes[0].buffer);
val bos = ByteArrayOutputStream()
cameraBitmap!!.compress(Bitmap.CompressFormat.JPEG, 100, bos)
val bitmapdata = bos.toByteArray()`
Its happening on OnePlus 6T(A6010)
Android Version : 11
Oxygen OS Version : 11.1.2.2
Build Number : ONEPLUS A6010_41_21125
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia con il builder ImageAnalysis e la funzione analyze sovrascritta descritta nel report, concentrandoti sulla risoluzione target, sul formato dell'immagine di output e sul percorso buffer-to-bitmap di ImageProxy. Riproduci il caso della fotocamera anteriore sulla configurazione OnePlus 6T indicata con imageCapture associato, quindi confronta il bitmap salvato con il caso in cui imageCapture viene rimosso. Il lavoro è completato quando il bitmap della fotocamera anteriore viene salvato senza distorsioni mentre imageCapture rimane associato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- android, kotlin
- Ambito
- mobile
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 25/100