0
Help us understand the problem. What are the problem?

posted at

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

概要

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)
}

Register as a new user and use Qiita more conveniently

  1. You can follow users and tags
  2. you can stock useful information
  3. You can make editorial suggestions for articles
What you can do with signing up
0
Help us understand the problem. What are the problem?