Search in sources :

Example 51 with OutputPort

use of androidx.media.filterfw.OutputPort in project platform_frameworks_base by android.

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 52 with OutputPort

use of androidx.media.filterfw.OutputPort in project platform_frameworks_base by android.

the class ToStringFilter method onProcess.

@Override
protected void onProcess() {
    FrameValue objectFrame = getConnectedInputPort("object").pullFrame().asFrameValue();
    String outStr = objectFrame.getValue().toString();
    OutputPort outPort = getConnectedOutputPort("string");
    FrameValue stringFrame = outPort.fetchAvailableFrame(null).asFrameValue();
    stringFrame.setValue(outStr);
    outPort.pushFrame(stringFrame);
}
Also used : OutputPort(androidx.media.filterfw.OutputPort) FrameValue(androidx.media.filterfw.FrameValue)

Example 53 with OutputPort

use of androidx.media.filterfw.OutputPort in project platform_frameworks_base by android.

the class NewChromaHistogramFilter method onProcess.

@Override
protected void onProcess() {
    FrameBuffer2D imageFrame = getConnectedInputPort("image").pullFrame().asFrameImage2D();
    OutputPort outPort = getConnectedOutputPort("histogram");
    mValueBins = mHueBins;
    int[] outDims = new int[] { mHueBins, mSaturationBins + 1 };
    FrameBuffer2D histogramFrame = outPort.fetchAvailableFrame(outDims).asFrameBuffer2D();
    ByteBuffer imageBuffer = imageFrame.lockBytes(Frame.MODE_READ);
    ByteBuffer histogramBuffer = histogramFrame.lockBytes(Frame.MODE_READ);
    histogramBuffer.order(ByteOrder.nativeOrder());
    FloatBuffer floatHistogram = histogramBuffer.asFloatBuffer();
    // Run native method
    extractChromaHistogram(imageBuffer, floatHistogram, mHueBins, mSaturationBins, mValueBins, mSaturationThreshold, mValueThreshold);
    imageFrame.unlock();
    histogramFrame.unlock();
    outPort.pushFrame(histogramFrame);
}
Also used : OutputPort(androidx.media.filterfw.OutputPort) FrameBuffer2D(androidx.media.filterfw.FrameBuffer2D) FloatBuffer(java.nio.FloatBuffer) ByteBuffer(java.nio.ByteBuffer)

Example 54 with OutputPort

use of androidx.media.filterfw.OutputPort in project platform_frameworks_base by android.

the class RotateFilter method onProcess.

@Override
protected void onProcess() {
    OutputPort outPort = getConnectedOutputPort("image");
    FrameImage2D inputImage = getConnectedInputPort("image").pullFrame().asFrameImage2D();
    int[] inDims = inputImage.getDimensions();
    FrameImage2D outputImage = outPort.fetchAvailableFrame(inDims).asFrameImage2D();
    mShader.setSourceQuad(mSourceRect);
    Quad targetQuad = mSourceRect.rotated((float) (mRotateAngle / 180 * Math.PI));
    mShader.setTargetQuad(targetQuad);
    mShader.process(inputImage, outputImage);
    outPort.pushFrame(outputImage);
}
Also used : OutputPort(androidx.media.filterfw.OutputPort) Quad(androidx.media.filterfw.geometry.Quad) FrameImage2D(androidx.media.filterfw.FrameImage2D)

Example 55 with OutputPort

use of androidx.media.filterfw.OutputPort in project platform_frameworks_base by android.

the class MotionSensor method onProcess.

@Override
protected void onProcess() {
    OutputPort outPort = getConnectedOutputPort("values");
    FrameValues outFrame = outPort.fetchAvailableFrame(null).asFrameValues();
    synchronized (mValues) {
        outFrame.setValues(mValues);
    }
    outFrame.setTimestamp(System.currentTimeMillis() * 1000000L);
    outPort.pushFrame(outFrame);
}
Also used : OutputPort(androidx.media.filterfw.OutputPort) FrameValues(androidx.media.filterfw.FrameValues)

Aggregations

OutputPort (androidx.media.filterfw.OutputPort)92 FrameValue (androidx.media.filterfw.FrameValue)60 FrameImage2D (androidx.media.filterfw.FrameImage2D)48 ByteBuffer (java.nio.ByteBuffer)36 FrameBuffer2D (androidx.media.filterfw.FrameBuffer2D)20 FrameValues (androidx.media.filterfw.FrameValues)12 Bitmap (android.graphics.Bitmap)8 Quad (androidx.media.filterfw.geometry.Quad)8 FloatBuffer (java.nio.FloatBuffer)8 Canvas (android.graphics.Canvas)4 Matrix (android.graphics.Matrix)4 Paint (android.graphics.Paint)4 Face (android.hardware.Camera.Face)4 RenderTarget (androidx.media.filterfw.RenderTarget)4