FileDocCategorySizeDatePackage
DrawOverlayFilter.javaAPI DocAndroid 5.1 API2690Thu Mar 12 22:22:30 GMT 2015android.filterpacks.imageproc

DrawOverlayFilter

public class DrawOverlayFilter extends android.filterfw.core.Filter
hide

Fields Summary
private android.filterfw.core.ShaderProgram
mProgram
Constructors Summary
public DrawOverlayFilter(String name)

        super(name);
    
Methods Summary
public android.filterfw.core.FrameFormatgetOutputFormat(java.lang.String portName, android.filterfw.core.FrameFormat inputFormat)

        return inputFormat;
    
public voidprepare(android.filterfw.core.FilterContext context)

        mProgram = ShaderProgram.createIdentity(context);
    
public voidprocess(android.filterfw.core.FilterContext env)

        // Get input frame
        Frame sourceFrame = pullInput("source");
        Frame overlayFrame = pullInput("overlay");
        Frame boxFrame = pullInput("box");

        // Get the box
        Quad box = (Quad)boxFrame.getObjectValue();
        box = box.translated(1.0f, 1.0f).scaled(2.0f);

        mProgram.setTargetRegion(box);

        // Create output frame with copy of input
        Frame output = env.getFrameManager().newFrame(sourceFrame.getFormat());
        output.setDataFromFrame(sourceFrame);

        // Draw onto output
        mProgram.process(overlayFrame, output);

        // Push output
        pushOutput("image", output);

        // Release pushed frame
        output.release();
    
public voidsetupPorts()

        FrameFormat imageFormatMask = ImageFormat.create(ImageFormat.COLORSPACE_RGBA,
                                                         FrameFormat.TARGET_GPU);
        addMaskedInputPort("source", imageFormatMask);
        addMaskedInputPort("overlay", imageFormatMask);
        addMaskedInputPort("box", ObjectFormat.fromClass(Quad.class, FrameFormat.TARGET_SIMPLE));
        addOutputBasedOnInput("image", "source");