Search in sources :

Example 71 with FrameValue

use of androidx.media.filterfw.FrameValue in project android_frameworks_base by DirtyUnicorns.

the class ContrastRatioFilter method onProcess.

@Override
protected void onProcess() {
    FrameImage2D inputImage = getConnectedInputPort("image").pullFrame().asFrameImage2D();
    float contrastRatio;
    ByteBuffer inputBuffer = inputImage.lockBytes(Frame.MODE_READ);
    contrastRatio = contrastOperator(inputImage.getWidth(), inputImage.getHeight(), inputBuffer);
    inputImage.unlock();
    if (mLogVerbose)
        Log.v(TAG, "contrastRatio: " + contrastRatio);
    OutputPort contrastToGoodnessPort = getConnectedOutputPort("contrastRatingToGoodness");
    FrameValue contrastOutFrame2 = contrastToGoodnessPort.fetchAvailableFrame(null).asFrameValue();
    contrastOutFrame2.setValue(contrastRatio);
    contrastToGoodnessPort.pushFrame(contrastOutFrame2);
}
Also used : OutputPort(androidx.media.filterfw.OutputPort) FrameImage2D(androidx.media.filterfw.FrameImage2D) ByteBuffer(java.nio.ByteBuffer) FrameValue(androidx.media.filterfw.FrameValue)

Example 72 with FrameValue

use of androidx.media.filterfw.FrameValue in project android_frameworks_base by DirtyUnicorns.

the class ExposureFilter method onProcess.

@Override
protected void onProcess() {
    FrameImage2D inputImage = getConnectedInputPort("image").pullFrame().asFrameImage2D();
    float overExposedPixels, underExposedPixels;
    ByteBuffer inputBuffer = inputImage.lockBytes(Frame.MODE_READ);
    overExposedPixels = overExposureOperator(inputImage.getWidth(), inputImage.getHeight(), inputBuffer);
    underExposedPixels = underExposureOperator(inputImage.getWidth(), inputImage.getHeight(), inputBuffer);
    inputImage.unlock();
    if (mLogVerbose)
        Log.v(TAG, "underExposedPixelCount: " + underExposedPixels);
    OutputPort underPort = getConnectedOutputPort("underExposedNum");
    if (underPort != null) {
        FrameValue underOutFrame = underPort.fetchAvailableFrame(null).asFrameValue();
        underOutFrame.setValue(underExposedPixels * inputImage.getWidth() * inputImage.getHeight());
        underPort.pushFrame(underOutFrame);
    }
    OutputPort underPort2 = getConnectedOutputPort("underExposureRating");
    FrameValue underOutFrame2 = underPort2.fetchAvailableFrame(null).asFrameValue();
    underOutFrame2.setValue(underExposedPixels);
    underPort2.pushFrame(underOutFrame2);
    if (mLogVerbose)
        Log.v(TAG, "overExposedPixelCount: " + overExposedPixels);
    OutputPort overPort = getConnectedOutputPort("overExposedNum");
    if (overPort != null) {
        FrameValue overOutFrame = overPort.fetchAvailableFrame(null).asFrameValue();
        overOutFrame.setValue(overExposedPixels * inputImage.getWidth() * inputImage.getHeight());
        overPort.pushFrame(overOutFrame);
    }
    OutputPort overPort2 = getConnectedOutputPort("overExposureRating");
    FrameValue overOutFrame2 = overPort2.fetchAvailableFrame(null).asFrameValue();
    overOutFrame2.setValue(overExposedPixels);
    overPort2.pushFrame(overOutFrame2);
}
Also used : OutputPort(androidx.media.filterfw.OutputPort) FrameImage2D(androidx.media.filterfw.FrameImage2D) ByteBuffer(java.nio.ByteBuffer) FrameValue(androidx.media.filterfw.FrameValue)

Example 73 with FrameValue

use of androidx.media.filterfw.FrameValue in project android_frameworks_base by DirtyUnicorns.

the class StatsFilter method onProcess.

/**
     * @see androidx.media.filterfw.Filter#onProcess()
     */
@Override
protected void onProcess() {
    FrameBuffer2D inputFrame = getConnectedInputPort("buffer").pullFrame().asFrameImage2D();
    ByteBuffer pixelBuffer = inputFrame.lockBytes(Frame.MODE_READ);
    calcMeanAndStd(pixelBuffer, inputFrame.getWidth(), inputFrame.getHeight(), mCropRect);
    inputFrame.unlock();
    OutputPort outPort = getConnectedOutputPort("mean");
    FrameValue outFrame = outPort.fetchAvailableFrame(null).asFrameValue();
    outFrame.setValue(mStats[MEAN_INDEX]);
    outPort.pushFrame(outFrame);
    OutputPort outPortStdev = getConnectedOutputPort("stdev");
    FrameValue outFrameStdev = outPortStdev.fetchAvailableFrame(null).asFrameValue();
    outFrameStdev.setValue(mStats[STDEV_INDEX]);
    outPortStdev.pushFrame(outFrameStdev);
}
Also used : OutputPort(androidx.media.filterfw.OutputPort) FrameBuffer2D(androidx.media.filterfw.FrameBuffer2D) ByteBuffer(java.nio.ByteBuffer) FrameValue(androidx.media.filterfw.FrameValue)

Example 74 with FrameValue

use of androidx.media.filterfw.FrameValue in project android_frameworks_base by DirtyUnicorns.

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

Example 75 with FrameValue

use of androidx.media.filterfw.FrameValue in project android_frameworks_base by DirtyUnicorns.

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());
}
Also used : 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