Methods Summary |
---|
public void | fieldPortValueUpdated(java.lang.String name, android.filterfw.core.FilterContext context)
if (mBenProgram != null && mHerfProgram != null) {
updateParameters();
}
|
public android.filterfw.core.FrameFormat | getOutputFormat(java.lang.String portName, android.filterfw.core.FrameFormat inputFormat)
return inputFormat;
|
private void | initParameters()
float shift = 1.0f / 255.0f;
float weights[] = { 2f/8f, 5f/8f, 1f/8f};
mBenProgram.setHostValue("weights", weights);
mBenProgram.setHostValue("shift", shift);
mHerfProgram.setHostValue("weights", weights);
updateParameters();
|
public void | initProgram(android.filterfw.core.FilterContext context, int target)
switch (target) {
case FrameFormat.TARGET_GPU:
ShaderProgram shaderProgram = new ShaderProgram(context, mBenSaturateShader);
shaderProgram.setMaximumTileSize(mTileSize);
mBenProgram = shaderProgram;
shaderProgram = new ShaderProgram(context, mHerfSaturateShader);
shaderProgram.setMaximumTileSize(mTileSize);
mHerfProgram = shaderProgram;
break;
default:
throw new RuntimeException("Filter Sharpen does not support frames of " +
"target " + target + "!");
}
mTarget = target;
|
public void | process(android.filterfw.core.FilterContext context)
// Get input frame
Frame input = pullInput("image");
FrameFormat inputFormat = input.getFormat();
// Create program if not created already
if (mBenProgram == null || inputFormat.getTarget() != mTarget) {
initProgram(context, inputFormat.getTarget());
initParameters();
}
// Create output frame
Frame output = context.getFrameManager().newFrame(inputFormat);
// Process
if (mScale > 0.0f) {
mHerfProgram.process(input, output);
} else {
mBenProgram.process(input, output);
}
// Push output
pushOutput("image", output);
// Release pushed frame
output.release();
|
public void | setupPorts()
addMaskedInputPort("image", ImageFormat.create(ImageFormat.COLORSPACE_RGBA));
addOutputBasedOnInput("image", "image");
|
private void | updateParameters()
if (mScale > 0.0f) {
float exponents[] = new float[3];
exponents[0] = (0.9f * mScale) + 1.0f;
exponents[1] = (2.1f * mScale) + 1.0f;
exponents[2] = (2.7f * mScale) + 1.0f;
mHerfProgram.setHostValue("exponents", exponents);
} else {
mBenProgram.setHostValue("scale", 1.0f + mScale);
}
|