use of androidx.media.filterfw.FrameValue in project android_frameworks_base by crdroidandroid.
the class IfElseFilterTest method testIfElseFilterFalse.
public void testIfElseFilterFalse() throws Exception {
FrameImage2D image = createFrame(FrameType.image2D(FrameType.ELEMENT_RGBA8888, FrameType.READ_CPU), new int[] { BIG_INPUT_WIDTH, BIG_INPUT_HEIGHT }).asFrameImage2D();
FrameImage2D video = createFrame(FrameType.image2D(FrameType.ELEMENT_RGBA8888, FrameType.READ_CPU), new int[] { SMALL_INPUT_WIDTH, SMALL_INPUT_HEIGHT }).asFrameImage2D();
// Image of legs
Bitmap videoBitmap = BitmapFactory.decodeStream(assetMgr.open("0002_000390.jpg"));
// Image of a face
Bitmap imageBitmap = BitmapFactory.decodeStream(assetMgr.open("XZZ019.jpg"));
image.setBitmap(imageBitmap);
injectInputFrame("falseResult", image);
video.setBitmap(videoBitmap);
injectInputFrame("trueResult", video);
FrameValue conditionFrame = createFrame(FrameType.single(boolean.class), new int[] { 1 }).asFrameValue();
conditionFrame.setValue(false);
injectInputFrame("condition", conditionFrame);
process();
// Ensure that for true, we use the video input
FrameImage2D outputImage = getOutputFrame("output").asFrameImage2D();
assertEquals(outputImage, image);
}
use of androidx.media.filterfw.FrameValue in project android_frameworks_base by crdroidandroid.
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.FrameValue 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.FrameValue 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.FrameValue in project android_frameworks_base by crdroidandroid.
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);
}
Aggregations