|
buildInput() { val bitmap = BitmapFactory.decodeFile(imagePath) // 缩放至224 val matrix = Matrix() matrix.postScale(224.0f / bitmap.width, 224.0f / bitmap.height) matrix.invert(matrix) // 4通道转为3通道 ARGB=> BGR val config = MNNImageProcess.Config() config.mean = floatArrayOf(103.94f, 116.78f, 123.68f) config.normal = floatArrayOf(0.017f, 0.017f, 0.017f) config.dest = MNNImageProcess.Format.BGR // inputTensor为输入缓冲区,下面这个方法意为将bitmap通过matrix转化,以及 通道配置转化,放入inputTensor MNNImageProcess.convertBitmap(bitmap, inputTensor, config, matrix)}
|
|