Android OpenCV(4.1.0)错误:(-215:断言失败)img.depth()<= CV_8S && img.channels()== 1在函数'maskBoundingRect'中

时间:2019-12-12 14:19:13

标签: android opencv

我使用Android OpenCV合成位图,代码如下:但是控制台提示我:

Caused by: CvException [org.opencv.core.CvException: cv::Exception: OpenCV(4.1.0) /build/master_pack-android/opencv/modules/imgproc/src/shapedescr.cpp:913: error: (-215:Assertion failed) img.depth() <= CV_8S && img.channels() == 1 in function 'maskBoundingRect'

originBm,blurBm和maskBm大小相同。

fun compound(originBm: Bitmap, blurBm: Bitmap, maskBm: Bitmap): Bitmap? {
            var matSrc = Mat()
            Utils.bitmapToMat(originBm, matSrc)
            var matDst = Mat()
            Utils.bitmapToMat(blurBm, matDst)
            var matMask = Mat()
            Utils.bitmapToMat(maskBm, matMask)
            var point = Point(originBm.width / 2.0, originBm.height / 2.0)
            val matBlend = Mat.zeros(matDst.size(), matDst.type())
            seamlessClone(matSrc, matDst, matMask, point, matBlend, NORMAL_CLONE)
            var bitmap = createBitmap(originBm.width, originBm.height, Bitmap.Config.ARGB_8888)
            Utils.matToBitmap(matBlend, bitmap)
            return bitmap
        }

originBm: enter image description here blurBm: enter image description here maskBm: enter image description here 由于我没有opencv的经验,能否请您详细说明如何更正错误?谢谢。

0 个答案:

没有答案