我使用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
}