Open jibinjoseph opened 8 years ago
i think you can use camera2 api. You just need sent Bitmap to GPUImage like in example. But be careful, this lib doesn't work correctly.
@wakedeer what do you mean doesn't work correctly?
I implemented by ImagerReader , but has a very big delay in preview.
Our sample use the Camera2 so could you check it?
I checked. but Image doesn't have the method generateNV21Data()
imageReader =
ImageReader.newInstance(size.width, size.height, ImageFormat.YUV_420_888, 2).apply {
setOnImageAvailableListener({ reader ->
val image = reader?.acquireNextImage() ?: return@setOnImageAvailableListener
onPreviewFrame?.invoke(image.generateNV21Data(), image.width, image.height)
image.close()
}, null)
}
I understand. in the file, https://github.com/cats-oss/android-gpuimage/blob/master/sample/src/main/java/jp/co/cyberagent/android/gpuimage/sample/utils/ImageExt.kt ,
package jp.co.cyberagent.android.gpuimage.sample.utils
import android.graphics.ImageFormat
import android.media.Image
import android.os.Build
import androidx.annotation.RequiresApi
@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
fun Image.generateNV21Data(): ByteArray {
val crop = cropRect
val format = format
val width = crop.width()
val height = crop.height()
I want to use this library in camera 2 api .