Skip to content

Commit

Permalink
add min detection confidence attribute. see #3
Browse files Browse the repository at this point in the history
  • Loading branch information
Riccardo Ciovati committed Jan 9, 2015
1 parent 6b1be96 commit 62a69b9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
11 changes: 10 additions & 1 deletion library/src/main/java/it/subito/masaccio/MasaccioImageView.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ public class MasaccioImageView extends ImageView {

private float mStartY;

private float mMinConfidence;

public MasaccioImageView(final Context context) {

super(context);
Expand Down Expand Up @@ -202,6 +204,11 @@ public void setAnimationInterpolator(final Interpolator interpolator) {
}
}

public void setMinConfidence(float minConfidence){

mMinConfidence = minConfidence;
}

public void setCenterFace(final boolean enabled) {

final boolean isUpdate = (mAutoFaceDetection != enabled);
Expand Down Expand Up @@ -541,7 +548,7 @@ private void getFaceOffsets(final Face[] faces, final float[] offsets, final flo

Face bestFace = null;

float maxConfidence = 0;
float maxConfidence = mMinConfidence;

for (final Face face : faces) {

Expand Down Expand Up @@ -694,6 +701,8 @@ private void init(final AttributeSet attrs, final int defStyle) {
final boolean autoFaceDetection =
typedArray.getBoolean(R.styleable.MasaccioImageView_center_face, false);

mMinConfidence = typedArray.getFloat(R.styleable.MasaccioImageView_min_confidence, 0);

mStartScale = typedArray.getFloat(R.styleable.MasaccioImageView_pre_scale, -1);
mStartX = typedArray.getFloat(R.styleable.MasaccioImageView_pre_translate_x, 0);
mStartY = typedArray.getFloat(R.styleable.MasaccioImageView_pre_translate_y, 0);
Expand Down
1 change: 1 addition & 0 deletions library/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<attr name="animation_duration" format="reference|integer"/>
<attr name="animation_interpolator" format="reference"/>
<attr name="cyclic_animation" format="reference|boolean"/>
<attr name="min_confidence" format="reference|float"/>
</declare-styleable>

</resources>

0 comments on commit 62a69b9

Please sign in to comment.