Hi @George_Zheng
Is it necessary to do that using OpenCV? Do you have restrictions for using that?
Wouldn’t be simpler to load directly the Bitmap from assets folder, resize it and create the ByteBuffer?
Like:

fun loadBitmapFromResources(context: Context, path: String): Bitmap {
val inputStream = context.assets.open(path)
return BitmapFactory.decodeStream(inputStream)
}


var loadedBitmap = loadBitmapFromResources(context, “woman.png”)


val inputBitmap = Bitmap.createScaledBitmap(
loadedBitmap,
width,
height,
true
)


var tensorImage = TensorImage(DataType.FLOAT32)
tensorImage.load(inputBitmap)

…

TensorBuffer outputBuffer = TensorBuffer.createFixedSize(new int[]{1, 4}, DataType.FLOAT32);
tflite.run(tensorImage.getBuffer(), outputBuffer)
val data2 = outputBuffer. getFloatArray()

and log to see the values of data2.
OR if your model contains metadata you can follow the example here where the ML Model Binding does the preprocessing also:
  
      

      TensorFlow
  

  
    

Generate model interfaces using metadata  |  TensorFlow Lite



  

  
    
    
  

  


check the generated code for code sample.
Ping me if you need more help