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);
}
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);
}
Aggregations