use of androidx.media.filterfw.FrameValue in project android_frameworks_base by ResurrectionRemix.
the class ExposureFilter method onProcess.
@Override
protected void onProcess() {
FrameImage2D inputImage = getConnectedInputPort("image").pullFrame().asFrameImage2D();
float overExposedPixels, underExposedPixels;
ByteBuffer inputBuffer = inputImage.lockBytes(Frame.MODE_READ);
overExposedPixels = overExposureOperator(inputImage.getWidth(), inputImage.getHeight(), inputBuffer);
underExposedPixels = underExposureOperator(inputImage.getWidth(), inputImage.getHeight(), inputBuffer);
inputImage.unlock();
if (mLogVerbose)
Log.v(TAG, "underExposedPixelCount: " + underExposedPixels);
OutputPort underPort = getConnectedOutputPort("underExposedNum");
if (underPort != null) {
FrameValue underOutFrame = underPort.fetchAvailableFrame(null).asFrameValue();
underOutFrame.setValue(underExposedPixels * inputImage.getWidth() * inputImage.getHeight());
underPort.pushFrame(underOutFrame);
}
OutputPort underPort2 = getConnectedOutputPort("underExposureRating");
FrameValue underOutFrame2 = underPort2.fetchAvailableFrame(null).asFrameValue();
underOutFrame2.setValue(underExposedPixels);
underPort2.pushFrame(underOutFrame2);
if (mLogVerbose)
Log.v(TAG, "overExposedPixelCount: " + overExposedPixels);
OutputPort overPort = getConnectedOutputPort("overExposedNum");
if (overPort != null) {
FrameValue overOutFrame = overPort.fetchAvailableFrame(null).asFrameValue();
overOutFrame.setValue(overExposedPixels * inputImage.getWidth() * inputImage.getHeight());
overPort.pushFrame(overOutFrame);
}
OutputPort overPort2 = getConnectedOutputPort("overExposureRating");
FrameValue overOutFrame2 = overPort2.fetchAvailableFrame(null).asFrameValue();
overOutFrame2.setValue(overExposedPixels);
overPort2.pushFrame(overOutFrame2);
}
use of androidx.media.filterfw.FrameValue in project android_frameworks_base by ResurrectionRemix.
the class ImageGoodnessFilterTest method testBadPicture.
public void testBadPicture() throws Exception {
FrameValue sharpnessFrame = createFrame(FrameType.single(), new int[] { 1 }).asFrameValue();
sharpnessFrame.setValue(10f);
FrameValue oEFrame = createFrame(FrameType.single(), new int[] { 1 }).asFrameValue();
oEFrame.setValue(0.39f);
FrameValue uEFrame = createFrame(FrameType.single(), new int[] { 1 }).asFrameValue();
uEFrame.setValue(0.25f);
FrameValue colorFrame = createFrame(FrameType.single(), new int[] { 1 }).asFrameValue();
colorFrame.setValue(2.1f);
FrameValue contrastFrame = createFrame(FrameType.single(), new int[] { 1 }).asFrameValue();
contrastFrame.setValue(0.18f);
FrameValue motionFrame = createFrame(FrameType.array(), new int[] { 1 }).asFrameValue();
float[] motionFloatArray = { 0.0f, 0.0f, 0.0f };
motionFrame.setValue(motionFloatArray);
injectInputFrame("sharpness", sharpnessFrame);
injectInputFrame("overExposure", oEFrame);
injectInputFrame("underExposure", uEFrame);
injectInputFrame("colorfulness", colorFrame);
injectInputFrame("contrastRating", contrastFrame);
injectInputFrame("motionValues", motionFrame);
process();
assertEquals("Bad Picture", (String) getOutputFrame("goodOrBadPic").asFrameValue().getValue());
}
use of androidx.media.filterfw.FrameValue in project android_frameworks_base by ResurrectionRemix.
the class ImageGoodnessFilterTest method testOkPicture.
public void testOkPicture() throws Exception {
FrameValue sharpnessFrame = createFrame(FrameType.single(), new int[] { 1 }).asFrameValue();
sharpnessFrame.setValue(30f);
FrameValue oEFrame = createFrame(FrameType.single(), new int[] { 1 }).asFrameValue();
oEFrame.setValue(0.39f);
FrameValue uEFrame = createFrame(FrameType.single(), new int[] { 1 }).asFrameValue();
uEFrame.setValue(0.25f);
FrameValue colorFrame = createFrame(FrameType.single(), new int[] { 1 }).asFrameValue();
colorFrame.setValue(2.1f);
FrameValue contrastFrame = createFrame(FrameType.single(), new int[] { 1 }).asFrameValue();
contrastFrame.setValue(0.18f);
FrameValue motionFrame = createFrame(FrameType.array(), new int[] { 1 }).asFrameValue();
float[] motionFloatArray = { 0.0f, 0.0f, 0.0f };
motionFrame.setValue(motionFloatArray);
injectInputFrame("sharpness", sharpnessFrame);
injectInputFrame("overExposure", oEFrame);
injectInputFrame("underExposure", uEFrame);
injectInputFrame("colorfulness", colorFrame);
injectInputFrame("contrastRating", contrastFrame);
injectInputFrame("motionValues", motionFrame);
process();
assertEquals("Ok Picture", (String) getOutputFrame("goodOrBadPic").asFrameValue().getValue());
}
use of androidx.media.filterfw.FrameValue in project android_frameworks_base by crdroidandroid.
the class ImageGoodnessFilterTest method testOkPicture.
public void testOkPicture() throws Exception {
FrameValue sharpnessFrame = createFrame(FrameType.single(), new int[] { 1 }).asFrameValue();
sharpnessFrame.setValue(30f);
FrameValue oEFrame = createFrame(FrameType.single(), new int[] { 1 }).asFrameValue();
oEFrame.setValue(0.39f);
FrameValue uEFrame = createFrame(FrameType.single(), new int[] { 1 }).asFrameValue();
uEFrame.setValue(0.25f);
FrameValue colorFrame = createFrame(FrameType.single(), new int[] { 1 }).asFrameValue();
colorFrame.setValue(2.1f);
FrameValue contrastFrame = createFrame(FrameType.single(), new int[] { 1 }).asFrameValue();
contrastFrame.setValue(0.18f);
FrameValue motionFrame = createFrame(FrameType.array(), new int[] { 1 }).asFrameValue();
float[] motionFloatArray = { 0.0f, 0.0f, 0.0f };
motionFrame.setValue(motionFloatArray);
injectInputFrame("sharpness", sharpnessFrame);
injectInputFrame("overExposure", oEFrame);
injectInputFrame("underExposure", uEFrame);
injectInputFrame("colorfulness", colorFrame);
injectInputFrame("contrastRating", contrastFrame);
injectInputFrame("motionValues", motionFrame);
process();
assertEquals("Ok Picture", (String) getOutputFrame("goodOrBadPic").asFrameValue().getValue());
}
use of androidx.media.filterfw.FrameValue in project android_frameworks_base by crdroidandroid.
the class ImageGoodnessFilterTest method testBadPicture.
public void testBadPicture() throws Exception {
FrameValue sharpnessFrame = createFrame(FrameType.single(), new int[] { 1 }).asFrameValue();
sharpnessFrame.setValue(10f);
FrameValue oEFrame = createFrame(FrameType.single(), new int[] { 1 }).asFrameValue();
oEFrame.setValue(0.39f);
FrameValue uEFrame = createFrame(FrameType.single(), new int[] { 1 }).asFrameValue();
uEFrame.setValue(0.25f);
FrameValue colorFrame = createFrame(FrameType.single(), new int[] { 1 }).asFrameValue();
colorFrame.setValue(2.1f);
FrameValue contrastFrame = createFrame(FrameType.single(), new int[] { 1 }).asFrameValue();
contrastFrame.setValue(0.18f);
FrameValue motionFrame = createFrame(FrameType.array(), new int[] { 1 }).asFrameValue();
float[] motionFloatArray = { 0.0f, 0.0f, 0.0f };
motionFrame.setValue(motionFloatArray);
injectInputFrame("sharpness", sharpnessFrame);
injectInputFrame("overExposure", oEFrame);
injectInputFrame("underExposure", uEFrame);
injectInputFrame("colorfulness", colorFrame);
injectInputFrame("contrastRating", contrastFrame);
injectInputFrame("motionValues", motionFrame);
process();
assertEquals("Bad Picture", (String) getOutputFrame("goodOrBadPic").asFrameValue().getValue());
}
Aggregations