Skip to content

Instantly share code, notes, and snippets.

@muhwyndhamhp
Created July 13, 2022 08:01
Show Gist options
  • Save muhwyndhamhp/95635d1cd3f7fbc35f157fe845461b7d to your computer and use it in GitHub Desktop.
Save muhwyndhamhp/95635d1cd3f7fbc35f157fe845461b7d to your computer and use it in GitHub Desktop.
private val imgSize =
// Set this image size according to our choice of DNN Model (160 for FaceNet, 112 for MobileFaceNet)
private val imageTensorProcessor = ImageProcessor.Builder()
.add(ResizeOp(imgSize, imgSize, ResizeOp.ResizeMethod.BILINEAR))
.add(CastOp( DataType.FLOAT32 ))
.build()
private fun convertBitmapToBuffer(image: Bitmap): ByteBuffer {
return imageTensorProcessor.process(TensorImage.fromBitmap(image)).buffer
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment