I want to overlay images using android opencv 4.5.1

I’m trying to overlay images using android opencv 4.5.1. But the blend does not produce the expected results.

[code]

val r: Resources = resources
val logo = BitmapFactory.decodeResource(r, R.drawable.logo)
var logoMat: Mat = Mat()
Utils.bitmapToMat(logo, logoMat)
Imgproc.cvtColor(logoMat, logoMat, Imgproc.COLOR_BGR2RGBA)

/* Abbreviation */

var mat = Imgproc.getAffineTransform(src, dst)
Imgproc.warpAffine(
logoMat, logoMat, mat, frame.size(),
Imgproc.INTER_NEAREST, Core.BORDER_TRANSPARENT)
val matList: List = ArrayList()
Core.split(logoMat, matList)
Core.merge(matList.subList(0, 3), logoMat)
mat.release()

Core.add(logoMat, frame, frame, matList[3])

[Result]

I would like to know a composition method that does not become translucent.

[This is what I want to do.]

I would like to know a composition method that does not become translucent.

nothing built-in.

here are a bunch of recipes. choose wisely. most of these people have no clue what they’re doing.

and here’s my own spin on it:

i think, this is the wrong operation.
adding will saturate, this makes your figure “all-white”.
(it’s not “translucent” (an alpha problem), but an rgb overflow, saturated to 255)

you should get much closer with a copy instead of the add operation:

logoMat.copyTo(frame, matList[3]); // copy with mask

Thank you. I got the result when I used copyTo.