use of androidx.media.filterfw.OutputPort in project android_frameworks_base by DirtyUnicorns.
the class FloatArrayToSizeFilter method onProcess.
/**
* @see androidx.media.filterfw.Filter#onProcess()
*/
@Override
protected void onProcess() {
FrameValue arrayFrame = getConnectedInputPort("array").pullFrame().asFrameValues();
Object array = arrayFrame.getValue();
int size = Array.getLength(array);
OutputPort outPort = getConnectedOutputPort("size");
FrameValue sizeFrame = outPort.fetchAvailableFrame(null).asFrameValue();
sizeFrame.setValue(size);
outPort.pushFrame(sizeFrame);
}
use of androidx.media.filterfw.OutputPort in project android_frameworks_base by DirtyUnicorns.
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);
}
}
use of androidx.media.filterfw.OutputPort in project android_frameworks_base by DirtyUnicorns.
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);
}
use of androidx.media.filterfw.OutputPort in project android_frameworks_base by DirtyUnicorns.
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 DirtyUnicorns.
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);
}
Aggregations