use of androidx.media.filterfw.OutputPort in project platform_frameworks_base by android.
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 platform_frameworks_base by android.
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.OutputPort in project platform_frameworks_base by android.
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);
}
use of androidx.media.filterfw.OutputPort in project platform_frameworks_base by android.
the class FaceSquareFilter method onProcess.
/**
* @see androidx.media.filterfw.Filter#onProcess()
*/
@Override
protected void onProcess() {
// Get inputs
FrameImage2D imageFrame = getConnectedInputPort("image").pullFrame().asFrameImage2D();
FrameValues facesFrame = getConnectedInputPort("faces").pullFrame().asFrameValues();
Face[] faces = (Face[]) facesFrame.getValues();
int[] dims = imageFrame.getDimensions();
ByteBuffer buffer = imageFrame.lockBytes(Frame.MODE_WRITE);
byte[] pixels = buffer.array();
// For every face in faces, draw a white rect around the
// face following the rect member of the Face
drawBoxes(pixels, faces, dims);
imageFrame.unlock();
OutputPort outPort = getConnectedOutputPort("image");
outPort.pushFrame(imageFrame);
}
use of androidx.media.filterfw.OutputPort in project platform_frameworks_base by android.
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);
}
Aggregations