cats-oss / android-gpuimage

Android filters based on OpenGL (idea from GPUImage for iOS)
8.98k stars 2.26k forks source link

Is it support camera 2 api ,? if then how to do in camera 2 #274

Open jibinjoseph opened 8 years ago

jibinjoseph commented 8 years ago

I want to use this library in camera 2 api .

wakedeer commented 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.

ferasodh commented 7 years ago

@wakedeer what do you mean doesn't work correctly?

stonyz commented 5 years ago

I implemented by ImagerReader , but has a very big delay in preview.

wasabeef commented 5 years ago

Our sample use the Camera2 so could you check it?

stonyz commented 5 years ago

Do you means https://github.com/cats-oss/android-gpuimage/blob/master/sample/src/main/java/jp/co/cyberagent/android/gpuimage/sample/utils/Camera2Loader.kt ?

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)
                }
stonyz commented 5 years ago

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()