use of androidx.media.filterfw.FrameValue in project android_frameworks_base by DirtyUnicorns.
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 DirtyUnicorns.
the class ImageGoodnessFilterTest method testOkPicture.
public void testOkPicture() throws Exception {
FrameValue sharpnessFrame = createFrame(FrameType.single(), new int[] { 1 }).asFrameValue();
sharpnessFrame.setValue(30f);
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("Ok Picture", (String) getOutputFrame("goodOrBadPic").asFrameValue().getValue());
}
use of androidx.media.filterfw.FrameValue in project android_frameworks_base by DirtyUnicorns.
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());
}
use of androidx.media.filterfw.FrameValue in project android_frameworks_base by DirtyUnicorns.
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());
}
use of androidx.media.filterfw.FrameValue in project android_frameworks_base by DirtyUnicorns.
the class FloatArrayToStrFilter method onProcess.
/**
* @see androidx.media.filterfw.Filter#onProcess()
*/
@Override
protected void onProcess() {
FrameValue arrayFrame = getConnectedInputPort("array").pullFrame().asFrameValues();
float[] array = (float[]) arrayFrame.getValue();
String outstr = Arrays.toString(array);
OutputPort outPort = getConnectedOutputPort("string");
FrameValue stringFrame = outPort.fetchAvailableFrame(null).asFrameValue();
stringFrame.setValue(outstr);
outPort.pushFrame(stringFrame);
}
Aggregations