Reputation: 35
In a part of a project, after displaying backgroundimage
, I should hide part of it by creating a mask (named mask1
in my code) and making first 3000 pixels of mask1
colorless. Then glare the result by utilizing blur()
method of OpenCV library. The problem is that it seems that OpenCv library is ignoring opacity(alpha channel) of pixels in mask1
. As a result, it is impossible to see the backgroundimage
behind the blured
image which has been created by OpenCV library. here is my code:
import gab.opencv.*;
OpenCV opencv;
int[] userMap;
PImage backgroundimage,mask1;
void setup() {
backgroundimage=loadImage("test.jpg");
mask1=createImage(640,480,ARGB);
opencv = new OpenCV(this,640,480);
size(640,480);
}
void draw() {
image(backgroundimage,0,0);
mask1.loadPixels();
for (int index=0; index<640*480; index++) {
if (index<30000) {
mask1.pixels[index]=color(0,0,0,0);
}
else{
mask1.pixels[index]=color(255,255,255);
}
}
mask1.updatePixels();
opencv.loadImage(mask1);
opencv.blur(8);
image(opencv.getSnapshot(), 0, 0);
}
Is there any other solution to glare mask1
??
Upvotes: 0
Views: 125