use of androidx.media.filterfw.OutputPort in project android_frameworks_base by crdroidandroid.
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.OutputPort in project android_frameworks_base by crdroidandroid.
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);
}
use of androidx.media.filterfw.OutputPort in project android_frameworks_base by crdroidandroid.
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);
}
use of androidx.media.filterfw.OutputPort in project android_frameworks_base by crdroidandroid.
the class NormFilter method onProcess.
@Override
protected void onProcess() {
FrameValue xFrameValue = getConnectedInputPort("x").pullFrame().asFrameValue();
float xValue = ((Float) xFrameValue.getValue()).floatValue();
FrameValue yFrameValue = getConnectedInputPort("y").pullFrame().asFrameValue();
float yValue = ((Float) yFrameValue.getValue()).floatValue();
float norm = (float) Math.hypot(xValue, yValue);
if (mLogVerbose)
Log.v(TAG, "Norm = " + norm);
OutputPort outPort = getConnectedOutputPort("norm");
FrameValue outFrame = outPort.fetchAvailableFrame(null).asFrameValue();
outFrame.setValue(norm);
outPort.pushFrame(outFrame);
}
use of androidx.media.filterfw.OutputPort in project android_frameworks_base by crdroidandroid.
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);
}
Aggregations