use of androidx.media.filterfw.FrameValue in project android_frameworks_base by ResurrectionRemix.
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);
}
use of androidx.media.filterfw.FrameValue in project android_frameworks_base by ResurrectionRemix.
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.FrameValue in project android_frameworks_base by ResurrectionRemix.
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);
}
use of androidx.media.filterfw.FrameValue in project android_frameworks_base by ResurrectionRemix.
the class Camera2Source method onProcess.
@Override
protected void onProcess() {
Log.v(TAG, "on Process");
if (nextFrame()) {
OutputPort outPort = getConnectedOutputPort("video");
// Create a 2D frame that will hold the output
int[] dims = new int[] { mWidth, mHeight };
FrameImage2D outputFrame = Frame.create(mOutputType, dims).asFrameImage2D();
rgbConverter.forEach(mAllocationOut);
mAllocationOut.copyTo(mBitmap);
outputFrame.setBitmap(mBitmap);
outPort.pushFrame(outputFrame);
outputFrame.release();
OutputPort orientationPort = getConnectedOutputPort("orientation");
FrameValue orientationFrame = orientationPort.fetchAvailableFrame(null).asFrameValue();
// FIXME: Hardcoded value because ORIENTATION returns null, Qualcomm
// bug
Integer orientation = mProperties.get(CameraCharacteristics.SENSOR_ORIENTATION);
float temp;
if (orientation != null) {
temp = orientation.floatValue();
} else {
temp = 90.0f;
}
orientationFrame.setValue(temp);
orientationPort.pushFrame(orientationFrame);
}
}
use of androidx.media.filterfw.FrameValue in project android_frameworks_base by ResurrectionRemix.
the class FloatArrayToStrFilter method onProcess.
/**
* @see androidx.media.filterfw.Filter#onProcess()
*/
@Override
protected void onProcess() {
FrameValue arrayFrame = getConnectedInputPort("array").pullFrame().asFrameValues();
float[] array = (float[]) arrayFrame.getValue();
String outstr = Arrays.toString(array);
OutputPort outPort = getConnectedOutputPort("string");
FrameValue stringFrame = outPort.fetchAvailableFrame(null).asFrameValue();
stringFrame.setValue(outstr);
outPort.pushFrame(stringFrame);
}
Aggregations