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