Search in sources :

Example 71 with FrameImage2D

use of androidx.media.filterfw.FrameImage2D in project android_frameworks_base by crdroidandroid.

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 72 with FrameImage2D

use of androidx.media.filterfw.FrameImage2D in project android_frameworks_base by crdroidandroid.

the class AvgBrightnessFilterTest method testBrightnessFilter.

public void testBrightnessFilter() throws Exception {
    final int INPUT_WIDTH = 480;
    final int INPUT_HEIGHT = 640;
    FrameImage2D image = createFrame(FrameType.image2D(FrameType.ELEMENT_RGBA8888, FrameType.READ_CPU), new int[] { INPUT_WIDTH, INPUT_HEIGHT }).asFrameImage2D();
    Bitmap bitmap = BitmapFactory.decodeStream(assetMgr.open("0002_000390.jpg"));
    image.setBitmap(bitmap);
    injectInputFrame("image", image);
    process();
    final float EXPECTED_RESULT = 0.35f;
    assertEquals(EXPECTED_RESULT, ((Float) getOutputFrame("brightnessRating").asFrameValue().getValue()).floatValue(), 0.01f);
}
Also used : Bitmap(android.graphics.Bitmap) FrameImage2D(androidx.media.filterfw.FrameImage2D)

Aggregations

FrameImage2D (androidx.media.filterfw.FrameImage2D)72 OutputPort (androidx.media.filterfw.OutputPort)48 Bitmap (android.graphics.Bitmap)32 FrameValue (androidx.media.filterfw.FrameValue)32 ByteBuffer (java.nio.ByteBuffer)24 Face (android.hardware.Camera.Face)8 FrameBuffer2D (androidx.media.filterfw.FrameBuffer2D)8 FrameValues (androidx.media.filterfw.FrameValues)8 Quad (androidx.media.filterfw.geometry.Quad)8 Canvas (android.graphics.Canvas)4 Matrix (android.graphics.Matrix)4 Paint (android.graphics.Paint)4 Rect (android.graphics.Rect)4 Camera (android.hardware.Camera)4 RenderTarget (androidx.media.filterfw.RenderTarget)4