use of androidx.media.filterfw.FrameValue in project android_frameworks_base by DirtyUnicorns.
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 DirtyUnicorns.
the class ImageGoodnessFilterTest method testGreatPicture.
public void testGreatPicture() throws Exception {
FrameValue sharpnessFrame = createFrame(FrameType.single(), new int[] { 1 }).asFrameValue();
sharpnessFrame.setValue(50f);
FrameValue oEFrame = createFrame(FrameType.single(), new int[] { 1 }).asFrameValue();
oEFrame.setValue(0.01f);
FrameValue uEFrame = createFrame(FrameType.single(), new int[] { 1 }).asFrameValue();
uEFrame.setValue(0.02f);
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.25f);
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("Great Picture!", (String) getOutputFrame("goodOrBadPic").asFrameValue().getValue());
}
use of androidx.media.filterfw.FrameValue in project android_frameworks_base by DirtyUnicorns.
the class ImageGoodnessFilterTest method testGoodPicture.
public void testGoodPicture() throws Exception {
FrameValue sharpnessFrame = createFrame(FrameType.single(), new int[] { 1 }).asFrameValue();
sharpnessFrame.setValue(50f);
FrameValue oEFrame = createFrame(FrameType.single(), new int[] { 1 }).asFrameValue();
oEFrame.setValue(0.01f);
FrameValue uEFrame = createFrame(FrameType.single(), new int[] { 1 }).asFrameValue();
uEFrame.setValue(0.01f);
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("Good Picture!", (String) getOutputFrame("goodOrBadPic").asFrameValue().getValue());
}
use of androidx.media.filterfw.FrameValue in project android_frameworks_base by DirtyUnicorns.
the class AverageFilter method onProcess.
@Override
protected void onProcess() {
FrameValue inFrameValue = getConnectedInputPort("sharpness").pullFrame().asFrameValue();
if (counter < NUM_FRAMES && counter >= 0) {
temp[counter] = ((Float) inFrameValue.getValue()).floatValue();
}
counter = (counter + 1) % NUM_FRAMES;
float output = (temp[0] + temp[1] + temp[2] + temp[3] + temp[4]) / NUM_FRAMES;
if (mLogVerbose)
Log.v(TAG, "Avg= " + output + "temp1= " + temp[0] + "temp2= " + temp[1] + "temp3= " + temp[2] + "temp4=" + temp[3] + "temp5=" + temp[4]);
OutputPort outPort = getConnectedOutputPort("avg");
FrameValue outFrame = outPort.fetchAvailableFrame(null).asFrameValue();
outFrame.setValue(output);
outPort.pushFrame(outFrame);
}
use of androidx.media.filterfw.FrameValue in project android_frameworks_base by DirtyUnicorns.
the class AvgBrightnessFilter method onProcess.
@Override
protected void onProcess() {
FrameImage2D inputImage = getConnectedInputPort("image").pullFrame().asFrameImage2D();
float brightness;
ByteBuffer inputBuffer = inputImage.lockBytes(Frame.MODE_READ);
brightness = brightnessOperator(inputImage.getWidth(), inputImage.getHeight(), inputBuffer);
inputImage.unlock();
if (mLogVerbose)
Log.v(TAG, "contrastRatio: " + brightness);
OutputPort brightnessPort = getConnectedOutputPort("brightnessRating");
FrameValue brightnessOutFrame = brightnessPort.fetchAvailableFrame(null).asFrameValue();
brightnessOutFrame.setValue(brightness);
brightnessPort.pushFrame(brightnessOutFrame);
}
Aggregations