Search in sources :

Example 76 with OutputPort

use of androidx.media.filterfw.OutputPort in project android_frameworks_base by ResurrectionRemix.

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)

Example 77 with OutputPort

use of androidx.media.filterfw.OutputPort in project android_frameworks_base by ResurrectionRemix.

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

use of androidx.media.filterfw.OutputPort in project android_frameworks_base by ResurrectionRemix.

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

use of androidx.media.filterfw.OutputPort in project android_frameworks_base by ResurrectionRemix.

the class MotionSensorWTime method onProcess.

@Override
protected void onProcess() {
    OutputPort outPort = getConnectedOutputPort("values");
    FrameValues outFrame = outPort.fetchAvailableFrame(null).asFrameValues();
    synchronized (mValues) {
        if (mCounter < 3 && mCounter >= 0) {
            mTemp[0][mCounter] = mValues[0];
            mTemp[1][mCounter] = mValues[1];
            mTemp[2][mCounter] = mValues[2];
        }
        mCounter = (mCounter + 1) % 3;
        mAvgValues[0] = (mTemp[0][0] + mTemp[0][1] + mTemp[0][2]) / 3;
        mAvgValues[1] = (mTemp[1][0] + mTemp[1][1] + mTemp[1][2]) / 3;
        mAvgValues[2] = (mTemp[2][0] + mTemp[2][1] + mTemp[2][2]) / 3;
        outFrame.setValues(mAvgValues);
    }
    outFrame.setTimestamp(System.currentTimeMillis() * 1000000L);
    outPort.pushFrame(outFrame);
    OutputPort timeOutPort = getConnectedOutputPort("timestamp");
    if (timeOutPort != null) {
        long timestamp = System.nanoTime();
        Log.v("MotionSensor", "Timestamp is: " + timestamp);
        FrameValue timeStampFrame = timeOutPort.fetchAvailableFrame(null).asFrameValue();
        timeStampFrame.setValue(timestamp);
        timeOutPort.pushFrame(timeStampFrame);
    }
}
Also used : OutputPort(androidx.media.filterfw.OutputPort) FrameValues(androidx.media.filterfw.FrameValues) FrameValue(androidx.media.filterfw.FrameValue)

Example 80 with OutputPort

use of androidx.media.filterfw.OutputPort in project android_frameworks_base by ResurrectionRemix.

the class WaveTriggerFilter method onProcess.

@Override
protected synchronized void onProcess() {
    // Check if we were triggered
    if (mTrigger) {
        mInWaveMode = true;
        mTrigger = false;
        mTime = 0.5f;
    }
    // Calculate output value
    float value = 0.5f;
    if (mInWaveMode) {
        value = -Math.abs(mTime - 1f) + 1f;
        mTime += 0.2f;
        if (mTime >= 2f) {
            mInWaveMode = false;
        }
    }
    // Push Value
    OutputPort outPort = getConnectedOutputPort("value");
    FrameValue frame = outPort.fetchAvailableFrame(null).asFrameValue();
    frame.setValue(value);
    outPort.pushFrame(frame);
}
Also used : OutputPort(androidx.media.filterfw.OutputPort) FrameValue(androidx.media.filterfw.FrameValue)

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