问题描述
我正在使用相机的imageAnalyzer并获得NV21框架,但我需要I420框架。有什么办法可以要求I420帧或将NV21转换为I420?在libyuv中,几乎看不到任何api,但这是在C ++中,我将只需要为一个api编写JNI并将libyub与应用程序一起打包,该解决方案对我不利。
这是我的分析仪:
private class LuminosityAnalyzer(private val listener: LumaListener) : ImageAnalysis.Analyzer {
private fun ByteBuffer.toByteArray(): ByteArray {
rewind() // Rewind the buffer to zero
val data = ByteArray(remaining())
get(data) // Copy the buffer into a byte array
return data // Return the byte array
}
override fun analyze(image: ImageProxy) {
val buffer = image.planes[0].buffer
Log.d(TAG,"analyze: y size = ${image.planes[0].buffer.remaining()} u size = ${image.planes[1].buffer.remaining()} v size = ${image.planes[2].buffer.remaining()}")
val data = buffer.toByteArray()
val pixels = data.map { it.toInt() and 0xFF }
val luma = pixels.average()
Log.d(TAG,"analyze: TarunD image format width = ${image.planes[0].pixelStride} ${image.planes[0].rowStride} height = ${image.height} u width = ${image.planes[2].rowStride} height = ${image.planes[2]}")
listener(luma)
image.close()
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)