Search in sources :

Example 26 with FrameValue

use of androidx.media.filterfw.FrameValue in project android_frameworks_base by ResurrectionRemix.

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 27 with FrameValue

use of androidx.media.filterfw.FrameValue in project android_frameworks_base by ResurrectionRemix.

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 28 with FrameValue

use of androidx.media.filterfw.FrameValue in project android_frameworks_base by ResurrectionRemix.

the class IfElseFilterTest method testIfElseFilterTrue.

public void testIfElseFilterTrue() throws Exception {
    FrameImage2D image = createFrame(FrameType.image2D(FrameType.ELEMENT_RGBA8888, FrameType.READ_CPU), new int[] { BIG_INPUT_WIDTH, BIG_INPUT_HEIGHT }).asFrameImage2D();
    FrameImage2D video = createFrame(FrameType.image2D(FrameType.ELEMENT_RGBA8888, FrameType.READ_CPU), new int[] { SMALL_INPUT_WIDTH, SMALL_INPUT_HEIGHT }).asFrameImage2D();
    // Image of legs
    Bitmap videoBitmap = BitmapFactory.decodeStream(assetMgr.open("0002_000390.jpg"));
    // Image of a face
    Bitmap imageBitmap = BitmapFactory.decodeStream(assetMgr.open("XZZ019.jpg"));
    image.setBitmap(imageBitmap);
    injectInputFrame("falseResult", image);
    video.setBitmap(videoBitmap);
    injectInputFrame("trueResult", video);
    FrameValue conditionFrame = createFrame(FrameType.single(boolean.class), new int[] { 1 }).asFrameValue();
    conditionFrame.setValue(true);
    injectInputFrame("condition", conditionFrame);
    process();
    // Ensure that for true, we use the video input
    FrameImage2D outputImage = getOutputFrame("output").asFrameImage2D();
    assertEquals(outputImage, video);
}
Also used : Bitmap(android.graphics.Bitmap) FrameImage2D(androidx.media.filterfw.FrameImage2D) FrameValue(androidx.media.filterfw.FrameValue)

Example 29 with FrameValue

use of androidx.media.filterfw.FrameValue in project android_frameworks_base by ResurrectionRemix.

the class IfElseFilterTest method testIfElseFilterFalse.

public void testIfElseFilterFalse() throws Exception {
    FrameImage2D image = createFrame(FrameType.image2D(FrameType.ELEMENT_RGBA8888, FrameType.READ_CPU), new int[] { BIG_INPUT_WIDTH, BIG_INPUT_HEIGHT }).asFrameImage2D();
    FrameImage2D video = createFrame(FrameType.image2D(FrameType.ELEMENT_RGBA8888, FrameType.READ_CPU), new int[] { SMALL_INPUT_WIDTH, SMALL_INPUT_HEIGHT }).asFrameImage2D();
    // Image of legs
    Bitmap videoBitmap = BitmapFactory.decodeStream(assetMgr.open("0002_000390.jpg"));
    // Image of a face
    Bitmap imageBitmap = BitmapFactory.decodeStream(assetMgr.open("XZZ019.jpg"));
    image.setBitmap(imageBitmap);
    injectInputFrame("falseResult", image);
    video.setBitmap(videoBitmap);
    injectInputFrame("trueResult", video);
    FrameValue conditionFrame = createFrame(FrameType.single(boolean.class), new int[] { 1 }).asFrameValue();
    conditionFrame.setValue(false);
    injectInputFrame("condition", conditionFrame);
    process();
    // Ensure that for true, we use the video input
    FrameImage2D outputImage = getOutputFrame("output").asFrameImage2D();
    assertEquals(outputImage, image);
}
Also used : Bitmap(android.graphics.Bitmap) FrameImage2D(androidx.media.filterfw.FrameImage2D) FrameValue(androidx.media.filterfw.FrameValue)

Example 30 with FrameValue

use of androidx.media.filterfw.FrameValue in project android_frameworks_base by ResurrectionRemix.

the class FloatArrayToSizeFilter method onProcess.

/**
     * @see androidx.media.filterfw.Filter#onProcess()
     */
@Override
protected void onProcess() {
    FrameValue arrayFrame = getConnectedInputPort("array").pullFrame().asFrameValues();
    Object array = arrayFrame.getValue();
    int size = Array.getLength(array);
    OutputPort outPort = getConnectedOutputPort("size");
    FrameValue sizeFrame = outPort.fetchAvailableFrame(null).asFrameValue();
    sizeFrame.setValue(size);
    outPort.pushFrame(sizeFrame);
}
Also used : OutputPort(androidx.media.filterfw.OutputPort) 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