Search in sources :

Example 61 with FrameValue

use of androidx.media.filterfw.FrameValue in project platform_frameworks_base by android.

the class IfElseFilter method onProcess.

@Override
protected void onProcess() {
    OutputPort outPort = getConnectedOutputPort("output");
    FrameImage2D trueFrame = getConnectedInputPort("trueResult").pullFrame().asFrameImage2D();
    FrameImage2D falseFrame = getConnectedInputPort("falseResult").pullFrame().asFrameImage2D();
    FrameValue boolFrameValue = getConnectedInputPort("condition").pullFrame().asFrameValue();
    boolean condition = (Boolean) boolFrameValue.getValue();
    FrameBuffer2D outputFrame;
    // If the condition is true, then we want to use the camera, else use the gallery
    if (condition) {
        outputFrame = trueFrame;
    } else {
        outputFrame = falseFrame;
    }
    outPort.pushFrame(outputFrame);
}
Also used : OutputPort(androidx.media.filterfw.OutputPort) FrameBuffer2D(androidx.media.filterfw.FrameBuffer2D) FrameImage2D(androidx.media.filterfw.FrameImage2D) FrameValue(androidx.media.filterfw.FrameValue)

Example 62 with FrameValue

use of androidx.media.filterfw.FrameValue in project platform_frameworks_base by android.

the class FloatArrayToSizeFilterTest method testToSize.

public void testToSize() throws Exception {
    FrameValue floatArray = createFrame(FrameType.array(float.class), new int[] { 1 }).asFrameValue();
    float[] floatArr = { 10f, 15f, 25f };
    floatArray.setValue(floatArr);
    injectInputFrame("array", floatArray);
    process();
    assertEquals(3, ((Integer) getOutputFrame("size").asFrameValue().getValue()).intValue());
}
Also used : FrameValue(androidx.media.filterfw.FrameValue)

Example 63 with FrameValue

use of androidx.media.filterfw.FrameValue in project platform_frameworks_base by android.

the class FloatArrayToStrFilterTest method testToStr.

public void testToStr() throws Exception {
    FrameValue floatArray = createFrame(FrameType.array(float.class), new int[] { 1 }).asFrameValue();
    float[] floatArr = { 10f, 15f, 25f };
    floatArray.setValue(floatArr);
    injectInputFrame("array", floatArray);
    process();
    assertEquals("[10.0, 15.0, 25.0]", (String) getOutputFrame("string").asFrameValue().getValue());
}
Also used : FrameValue(androidx.media.filterfw.FrameValue)

Example 64 with FrameValue

use of androidx.media.filterfw.FrameValue in project platform_frameworks_base by android.

the class ImageGoodnessFilterTest method testBadPicture.

public void testBadPicture() throws Exception {
    FrameValue sharpnessFrame = createFrame(FrameType.single(), new int[] { 1 }).asFrameValue();
    sharpnessFrame.setValue(10f);
    FrameValue oEFrame = createFrame(FrameType.single(), new int[] { 1 }).asFrameValue();
    oEFrame.setValue(0.39f);
    FrameValue uEFrame = createFrame(FrameType.single(), new int[] { 1 }).asFrameValue();
    uEFrame.setValue(0.25f);
    FrameValue colorFrame = createFrame(FrameType.single(), new int[] { 1 }).asFrameValue();
    colorFrame.setValue(2.1f);
    FrameValue contrastFrame = createFrame(FrameType.single(), new int[] { 1 }).asFrameValue();
    contrastFrame.setValue(0.18f);
    FrameValue motionFrame = createFrame(FrameType.array(), new int[] { 1 }).asFrameValue();
    float[] motionFloatArray = { 0.0f, 0.0f, 0.0f };
    motionFrame.setValue(motionFloatArray);
    injectInputFrame("sharpness", sharpnessFrame);
    injectInputFrame("overExposure", oEFrame);
    injectInputFrame("underExposure", uEFrame);
    injectInputFrame("colorfulness", colorFrame);
    injectInputFrame("contrastRating", contrastFrame);
    injectInputFrame("motionValues", motionFrame);
    process();
    assertEquals("Bad Picture", (String) getOutputFrame("goodOrBadPic").asFrameValue().getValue());
}
Also used : FrameValue(androidx.media.filterfw.FrameValue)

Example 65 with FrameValue

use of androidx.media.filterfw.FrameValue in project platform_frameworks_base by android.

the class ImageGoodnessFilterTest method testAwfulPicture.

public void testAwfulPicture() throws Exception {
    FrameValue sharpnessFrame = createFrame(FrameType.single(), new int[] { 1 }).asFrameValue();
    sharpnessFrame.setValue(10f);
    FrameValue oEFrame = createFrame(FrameType.single(), new int[] { 1 }).asFrameValue();
    oEFrame.setValue(0.39f);
    FrameValue uEFrame = createFrame(FrameType.single(), new int[] { 1 }).asFrameValue();
    uEFrame.setValue(0.25f);
    FrameValue colorFrame = createFrame(FrameType.single(), new int[] { 1 }).asFrameValue();
    colorFrame.setValue(2.1f);
    FrameValue contrastFrame = createFrame(FrameType.single(), new int[] { 1 }).asFrameValue();
    contrastFrame.setValue(0.18f);
    FrameValue motionFrame = createFrame(FrameType.array(), new int[] { 1 }).asFrameValue();
    float[] motionFloatArray = { 9.0f, 3.0f, 2.0f };
    motionFrame.setValue(motionFloatArray);
    injectInputFrame("sharpness", sharpnessFrame);
    injectInputFrame("overExposure", oEFrame);
    injectInputFrame("underExposure", uEFrame);
    injectInputFrame("colorfulness", colorFrame);
    injectInputFrame("contrastRating", contrastFrame);
    injectInputFrame("motionValues", motionFrame);
    process();
    assertEquals("Awful Picture", (String) getOutputFrame("goodOrBadPic").asFrameValue().getValue());
}
Also used : FrameValue(androidx.media.filterfw.FrameValue)

Aggregations

FrameValue (androidx.media.filterfw.FrameValue)112 OutputPort (androidx.media.filterfw.OutputPort)60 FrameImage2D (androidx.media.filterfw.FrameImage2D)32 ByteBuffer (java.nio.ByteBuffer)20 Bitmap (android.graphics.Bitmap)12 FrameBuffer2D (androidx.media.filterfw.FrameBuffer2D)12 FrameValues (androidx.media.filterfw.FrameValues)4 BufferedWriter (java.io.BufferedWriter)4 FileWriter (java.io.FileWriter)4 IOException (java.io.IOException)4 FloatBuffer (java.nio.FloatBuffer)4