Search in sources :

Example 31 with FrameFormat

use of android.filterfw.core.FrameFormat in project android_frameworks_base by ParanoidAndroid.

the class CrossProcessFilter method process.

@Override
public void process(FilterContext context) {
    // Get input frame
    Frame input = pullInput("image");
    FrameFormat inputFormat = input.getFormat();
    // Create program if not created already
    if (mProgram == null || inputFormat.getTarget() != mTarget) {
        initProgram(context, inputFormat.getTarget());
    }
    // Create output frame
    Frame output = context.getFrameManager().newFrame(inputFormat);
    // Process
    mProgram.process(input, output);
    // Push output
    pushOutput("image", output);
    // Release pushed frame
    output.release();
}
Also used : FrameFormat(android.filterfw.core.FrameFormat) Frame(android.filterfw.core.Frame) NativeFrame(android.filterfw.core.NativeFrame)

Example 32 with FrameFormat

use of android.filterfw.core.FrameFormat in project android_frameworks_base by ParanoidAndroid.

the class ObjectSource method process.

@Override
public void process(FilterContext context) {
    // If no frame has been created, create one now.
    if (mFrame == null) {
        if (mObject == null) {
            throw new NullPointerException("ObjectSource producing frame with no object set!");
        }
        FrameFormat outputFormat = ObjectFormat.fromObject(mObject, FrameFormat.TARGET_SIMPLE);
        mFrame = context.getFrameManager().newFrame(outputFormat);
        mFrame.setObjectValue(mObject);
        mFrame.setTimestamp(Frame.TIMESTAMP_UNKNOWN);
    }
    // Push output
    pushOutput("frame", mFrame);
    // Wait for free output
    if (!mRepeatFrame) {
        closeOutputPort("frame");
    }
}
Also used : FrameFormat(android.filterfw.core.FrameFormat) MutableFrameFormat(android.filterfw.core.MutableFrameFormat)

Example 33 with FrameFormat

use of android.filterfw.core.FrameFormat in project android_frameworks_base by ParanoidAndroid.

the class AutoFixFilter method prepare.

@Override
protected void prepare(FilterContext context) {
    int densityDim = 1024;
    int histDim = 255 * 3 + 1;
    long precision = (256l * 256l - 1l);
    int[] densityTable = new int[densityDim];
    for (int i = 0; i < densityDim; ++i) {
        long temp = normal_cdf[i] * precision / histDim;
        densityTable[i] = (int) temp;
    }
    FrameFormat densityFormat = ImageFormat.create(densityDim, 1, ImageFormat.COLORSPACE_RGBA, FrameFormat.TARGET_GPU);
    mDensityFrame = context.getFrameManager().newFrame(densityFormat);
    mDensityFrame.setInts(densityTable);
}
Also used : FrameFormat(android.filterfw.core.FrameFormat)

Example 34 with FrameFormat

use of android.filterfw.core.FrameFormat in project android_frameworks_base by ParanoidAndroid.

the class AutoFixFilter method process.

@Override
public void process(FilterContext context) {
    // Get input frame
    Frame input = pullInput("image");
    FrameFormat inputFormat = input.getFormat();
    // Create program if not created already
    if (mShaderProgram == null || inputFormat.getTarget() != mTarget) {
        initProgram(context, inputFormat.getTarget());
        initParameters();
    }
    // Check if the frame size has changed
    if (inputFormat.getWidth() != mWidth || inputFormat.getHeight() != mHeight) {
        mWidth = inputFormat.getWidth();
        mHeight = inputFormat.getHeight();
        createHistogramFrame(context, mWidth, mHeight, input.getInts());
    }
    // Create output frame
    Frame output = context.getFrameManager().newFrame(inputFormat);
    // Process
    Frame[] inputs = { input, mHistFrame, mDensityFrame };
    mShaderProgram.process(inputs, output);
    // Push output
    pushOutput("image", output);
    // Release pushed frame
    output.release();
}
Also used : FrameFormat(android.filterfw.core.FrameFormat) Frame(android.filterfw.core.Frame)

Example 35 with FrameFormat

use of android.filterfw.core.FrameFormat in project android_frameworks_base by ParanoidAndroid.

the class SepiaFilter method process.

@Override
public void process(FilterContext context) {
    // Get input frame
    Frame input = pullInput("image");
    FrameFormat inputFormat = input.getFormat();
    // Create output frame
    Frame output = context.getFrameManager().newFrame(inputFormat);
    // Create program if not created already
    if (mProgram == null || inputFormat.getTarget() != mTarget) {
        initProgram(context, inputFormat.getTarget());
        initParameters();
    }
    // Process
    mProgram.process(input, output);
    // Push output
    pushOutput("image", output);
    // Release pushed frame
    output.release();
}
Also used : FrameFormat(android.filterfw.core.FrameFormat) Frame(android.filterfw.core.Frame) NativeFrame(android.filterfw.core.NativeFrame)

Aggregations

FrameFormat (android.filterfw.core.FrameFormat)270 Frame (android.filterfw.core.Frame)198 MutableFrameFormat (android.filterfw.core.MutableFrameFormat)39 NativeFrame (android.filterfw.core.NativeFrame)25 GLFrame (android.filterfw.core.GLFrame)18 ShaderProgram (android.filterfw.core.ShaderProgram)12 Quad (android.filterfw.geometry.Quad)12 FrameManager (android.filterfw.core.FrameManager)6 Point (android.filterfw.geometry.Point)6 Bitmap (android.graphics.Bitmap)6 Paint (android.graphics.Paint)6 CachedFrameManager (android.filterfw.core.CachedFrameManager)1