从标量值中减去一个垫子

时间:2017-07-07 02:25:57

标签: android opencv alphablending

我尝试按照learnopencv

进行Alpha混合
  //Load the bitmap
            foregroundBitmap = BitmapFactory.decodeResource(getApplicationContext().getResources(),
                    R.drawable.dominant);
            backgroundBitmap = BitmapFactory.decodeResource(getApplicationContext().getResources(),
                    R.drawable.call);
            alphaBitmap = BitmapFactory.decodeResource(getApplicationContext().getResources(),
                    R.drawable.trans);

        //initalize mat objects
        foreground = new Mat();
        background = new Mat();
        alpha = new Mat();

        //Convert bitmap to mat
        Utils.bitmapToMat(foregroundBitmap, foreground);
        Utils.bitmapToMat(backgroundBitmap, background);
        Utils.bitmapToMat(alphaBitmap, alpha);

        // Convert Mat to float data type
        foreground.convertTo(foreground, CV_32FC3);
        background.convertTo(background, CV_32FC3);

        // Normalize the alpha mask to keep intensity between 0 and 1
        alpha.convertTo(alpha, CV_32FC3, 1.0/255);

       // Storage for output image
        Mat ouImage = Mat.zeros(foreground.size(), foreground.type());


        // Multiply the foreground with the alpha matte
        multiply(alpha, foreground, foreground);

        multiply(1.0-alpha, background, background);


        add(foreground, background, ouImage);

但是它会抛出以下错误

  

错误:(62,21)错误:二元运算符的错误操作数类型' - '第一   类型:双秒类型:Mat

这指向multiply(1.0-alpha, background, background);

如何从标量值中减去垫?

0 个答案:

没有答案