Search in sources :

Example 36 with FrameValue

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);
}
Also used : Bitmap(android.graphics.Bitmap) FrameImage2D(androidx.media.filterfw.FrameImage2D) FrameValue(androidx.media.filterfw.FrameValue)

Example 37 with FrameValue

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());
}
Also used : FrameValue(androidx.media.filterfw.FrameValue)

Example 38 with FrameValue

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());
}
Also used : FrameValue(androidx.media.filterfw.FrameValue)

Example 39 with FrameValue

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);
}
Also used : OutputPort(androidx.media.filterfw.OutputPort) FrameValue(androidx.media.filterfw.FrameValue)

Example 40 with FrameValue

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);
}
Also used : OutputPort(androidx.media.filterfw.OutputPort) FrameImage2D(androidx.media.filterfw.FrameImage2D) ByteBuffer(java.nio.ByteBuffer) FrameValue(androidx.media.filterfw.FrameValue)

Aggregations

FrameValue (androidx.media.filterfw.FrameValue)112 OutputPort (androidx.media.filterfw.OutputPort)60 FrameImage2D (androidx.media.filterfw.FrameImage2D)32 ByteBuffer (java.nio.ByteBuffer)20 Bitmap (android.graphics.Bitmap)12 FrameBuffer2D (androidx.media.filterfw.FrameBuffer2D)12 FrameValues (androidx.media.filterfw.FrameValues)4 BufferedWriter (java.io.BufferedWriter)4 FileWriter (java.io.FileWriter)4 IOException (java.io.IOException)4 FloatBuffer (java.nio.FloatBuffer)4