|
|
|
@ -22,7 +22,7 @@ import android.util.Log; |
|
|
|
|
import android.view.SurfaceHolder; |
|
|
|
|
|
|
|
|
|
class FdView extends SampleCvViewBase { |
|
|
|
|
private static final String TAG = "Sample::FdView"; |
|
|
|
|
private static final String TAG = "Sample-FD::View"; |
|
|
|
|
private Mat mRgba; |
|
|
|
|
private Mat mGray; |
|
|
|
|
private File mCascadeFile; |
|
|
|
@ -39,25 +39,19 @@ class FdView extends SampleCvViewBase { |
|
|
|
|
private float mRelativeFaceSize = 0; |
|
|
|
|
private int mAbsoluteFaceSize = 0; |
|
|
|
|
|
|
|
|
|
public void setMinFaceSize(float faceSize) |
|
|
|
|
{ |
|
|
|
|
public void setMinFaceSize(float faceSize) { |
|
|
|
|
mRelativeFaceSize = faceSize; |
|
|
|
|
mAbsoluteFaceSize = 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void setDetectorType(int type) |
|
|
|
|
{ |
|
|
|
|
if (mDetectorType != type) |
|
|
|
|
{ |
|
|
|
|
public void setDetectorType(int type) { |
|
|
|
|
if (mDetectorType != type) { |
|
|
|
|
mDetectorType = type; |
|
|
|
|
|
|
|
|
|
if (type == NATIVE_DETECTOR) |
|
|
|
|
{ |
|
|
|
|
if (type == NATIVE_DETECTOR) { |
|
|
|
|
Log.i(TAG, "Detection Based Tracker enabled"); |
|
|
|
|
mNativeDetector.start(); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
} else { |
|
|
|
|
Log.i(TAG, "Cascade detector enabled"); |
|
|
|
|
mNativeDetector.stop(); |
|
|
|
|
} |
|
|
|
@ -114,11 +108,9 @@ class FdView extends SampleCvViewBase { |
|
|
|
|
capture.retrieve(mRgba, Highgui.CV_CAP_ANDROID_COLOR_FRAME_RGBA); |
|
|
|
|
capture.retrieve(mGray, Highgui.CV_CAP_ANDROID_GREY_FRAME); |
|
|
|
|
|
|
|
|
|
if (mAbsoluteFaceSize == 0) |
|
|
|
|
{ |
|
|
|
|
if (mAbsoluteFaceSize == 0) { |
|
|
|
|
int height = mGray.rows(); |
|
|
|
|
if (Math.round(height * mRelativeFaceSize) > 0); |
|
|
|
|
{ |
|
|
|
|
if (Math.round(height * mRelativeFaceSize) > 0) { |
|
|
|
|
mAbsoluteFaceSize = Math.round(height * mRelativeFaceSize); |
|
|
|
|
} |
|
|
|
|
mNativeDetector.setMinFaceSize(mAbsoluteFaceSize); |
|
|
|
@ -126,19 +118,16 @@ class FdView extends SampleCvViewBase { |
|
|
|
|
|
|
|
|
|
MatOfRect faces = new MatOfRect(); |
|
|
|
|
|
|
|
|
|
if (mDetectorType == JAVA_DETECTOR) |
|
|
|
|
{ |
|
|
|
|
if (mDetectorType == JAVA_DETECTOR) { |
|
|
|
|
if (mJavaDetector != null) |
|
|
|
|
mJavaDetector.detectMultiScale(mGray, faces, 1.1, 2, 2 // TODO: objdetect.CV_HAAR_SCALE_IMAGE
|
|
|
|
|
, new Size(mAbsoluteFaceSize, mAbsoluteFaceSize), new Size()); |
|
|
|
|
mJavaDetector.detectMultiScale(mGray, faces, 1.1, 2, 2, // TODO: objdetect.CV_HAAR_SCALE_IMAGE
|
|
|
|
|
new Size(mAbsoluteFaceSize, mAbsoluteFaceSize), new Size()); |
|
|
|
|
} |
|
|
|
|
else if (mDetectorType == NATIVE_DETECTOR) |
|
|
|
|
{ |
|
|
|
|
else if (mDetectorType == NATIVE_DETECTOR) { |
|
|
|
|
if (mNativeDetector != null) |
|
|
|
|
mNativeDetector.detect(mGray, faces); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
else { |
|
|
|
|
Log.e(TAG, "Detection method is not selected!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|