LoginSignup
1
0

More than 1 year has passed since last update.

【Android】OpenCVでUnsupported format or combination of formatsとエラーが出た時の対処法

Posted at

概要

OpenCVのinpaintメソッドを使った際、下記のようなエラーが出た。

Unsupported format or combination of formats (8-bit, 16-bit unsigned or 32-bit float 1-channel and 8-bit 3-channel input/output images are supported)

対策

メソッド実行前に、cvtColorで色変換を行えば解決した。

val src:Bitmap = //(省略)
val mask:Bitmap = //(省略)

//元画像
val srcMat = Mat(src.width, src.height, CvType.CV_8UC3).also {
	Utils.bitmapToMat(src, it, false)
	Imgproc.cvtColor(it, it, Imgproc.COLOR_RGBA2RGB)
}

//マスク画像
val maskMat = Mat(mask.width, mask.height, CvType.CV_8U).also {
	Utils.bitmapToMat(mask, it, false)
	Imgproc.cvtColor(it, it, Imgproc.COLOR_RGB2GRAY)
}
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0