From 4239373aedb5f95e7edcc3c75920eb3e265b667c Mon Sep 17 00:00:00 2001 From: Eino-Ville Talvala Date: Fri, 8 Jun 2012 14:35:13 -0700 Subject: Add property to override backdropper effect threshold. Also, change the default background mean to be the first incoming frame. Bug: 6600585 Change-Id: I2181e75711d48d01f48e3fb1d604eb467f08fda4 --- .../filterpacks/videoproc/BackDropperFilter.java | 28 ++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'media') diff --git a/media/mca/filterpacks/java/android/filterpacks/videoproc/BackDropperFilter.java b/media/mca/filterpacks/java/android/filterpacks/videoproc/BackDropperFilter.java index 52c9fda..78f7f3e 100644 --- a/media/mca/filterpacks/java/android/filterpacks/videoproc/BackDropperFilter.java +++ b/media/mca/filterpacks/java/android/filterpacks/videoproc/BackDropperFilter.java @@ -29,6 +29,7 @@ import android.filterfw.core.ShaderProgram; import android.filterfw.format.ImageFormat; import android.opengl.GLES20; import android.os.SystemClock; +import android.os.SystemProperties; import android.util.Log; import java.lang.ArrayIndexOutOfBoundsException; @@ -510,6 +511,20 @@ public class BackDropperFilter extends Filter { super(name); mLogVerbose = Log.isLoggable(TAG, Log.VERBOSE); + + String adjStr = SystemProperties.get("ro.media.effect.bgdropper.adj"); + if (adjStr.length() > 0) { + try { + mAcceptStddev += Float.parseFloat(adjStr); + if (mLogVerbose) { + Log.v(TAG, "Adjusting accept threshold by " + adjStr + + ", now " + mAcceptStddev); + } + } catch (NumberFormatException e) { + Log.e(TAG, + "Badly formatted property ro.media.effect.bgdropper.adj: " + adjStr); + } + } } @Override @@ -695,7 +710,6 @@ public class BackDropperFilter extends Filter { mBgUpdateVarianceProgram.setHostValue("bg_adapt_rate", mAdaptRateLearning); mBgUpdateVarianceProgram.setHostValue("fg_adapt_rate", mAdaptRateLearning); mFrameCount = 0; - mStartLearning = false; } // Select correct pingpong buffers @@ -720,6 +734,11 @@ public class BackDropperFilter extends Filter { mBgInput.setTextureParameter(GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR_MIPMAP_NEAREST); + if (mStartLearning) { + copyShaderProgram.process(mVideoInput, mBgMean[inputIndex]); + mStartLearning = false; + } + // Process shaders Frame[] distInputs = { mVideoInput, mBgMean[inputIndex], mBgVariance[inputIndex] }; mBgDistProgram.process(distInputs, mDistance); @@ -765,7 +784,12 @@ public class BackDropperFilter extends Filter { ByteBuffer mMaskAverageByteBuffer = mMaskAverage.getData(); byte[] mask_average = mMaskAverageByteBuffer.array(); int bi = (int)(mask_average[3] & 0xFF); - if (mLogVerbose) Log.v(TAG, String.format("Mask_average is %d", bi)); + + if (mLogVerbose) { + Log.v(TAG, + String.format("Mask_average is %d, threshold is %d", + bi, DEFAULT_LEARNING_DONE_THRESHOLD)); + } if (bi >= DEFAULT_LEARNING_DONE_THRESHOLD) { mStartLearning = true; // Restart learning -- cgit v1.1