|
|
@ -15,7 +15,7 @@ import android.view.Window; |
|
|
|
import android.view.WindowManager; |
|
|
|
import android.view.WindowManager; |
|
|
|
|
|
|
|
|
|
|
|
public class FdActivity extends Activity { |
|
|
|
public class FdActivity extends Activity { |
|
|
|
private static final String TAG = "Sample-FD::Activity"; |
|
|
|
private static final String TAG = "OCVSample::Activity"; |
|
|
|
|
|
|
|
|
|
|
|
private MenuItem mItemFace50; |
|
|
|
private MenuItem mItemFace50; |
|
|
|
private MenuItem mItemFace40; |
|
|
|
private MenuItem mItemFace40; |
|
|
@ -42,6 +42,7 @@ public class FdActivity extends Activity { |
|
|
|
mView.setDetectorType(mDetectorType); |
|
|
|
mView.setDetectorType(mDetectorType); |
|
|
|
mView.setMinFaceSize(0.2f); |
|
|
|
mView.setMinFaceSize(0.2f); |
|
|
|
setContentView(mView); |
|
|
|
setContentView(mView); |
|
|
|
|
|
|
|
|
|
|
|
// Check native OpenCV camera
|
|
|
|
// Check native OpenCV camera
|
|
|
|
if( !mView.openCamera() ) { |
|
|
|
if( !mView.openCamera() ) { |
|
|
|
AlertDialog ad = new AlertDialog.Builder(mAppContext).create(); |
|
|
|
AlertDialog ad = new AlertDialog.Builder(mAppContext).create(); |
|
|
@ -56,6 +57,7 @@ public class FdActivity extends Activity { |
|
|
|
ad.show(); |
|
|
|
ad.show(); |
|
|
|
} |
|
|
|
} |
|
|
|
} break; |
|
|
|
} break; |
|
|
|
|
|
|
|
|
|
|
|
/** OpenCV loader cannot start Google Play **/ |
|
|
|
/** OpenCV loader cannot start Google Play **/ |
|
|
|
case LoaderCallbackInterface.MARKET_ERROR: |
|
|
|
case LoaderCallbackInterface.MARKET_ERROR: |
|
|
|
{ |
|
|
|
{ |
|
|
@ -80,28 +82,27 @@ public class FdActivity extends Activity { |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
public FdActivity() { |
|
|
|
public FdActivity() { |
|
|
|
Log.i(TAG, "Instantiated new " + this.getClass()); |
|
|
|
|
|
|
|
mDetectorName = new String[2]; |
|
|
|
mDetectorName = new String[2]; |
|
|
|
mDetectorName[FdView.JAVA_DETECTOR] = "Java"; |
|
|
|
mDetectorName[FdView.JAVA_DETECTOR] = "Java"; |
|
|
|
mDetectorName[FdView.NATIVE_DETECTOR] = "Native (tracking)"; |
|
|
|
mDetectorName[FdView.NATIVE_DETECTOR] = "Native (tracking)"; |
|
|
|
|
|
|
|
Log.i(TAG, "Instantiated new " + this.getClass()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void onPause() { |
|
|
|
protected void onPause() { |
|
|
|
Log.i(TAG, "onPause"); |
|
|
|
Log.i(TAG, "called onPause"); |
|
|
|
if (mView != null) |
|
|
|
if (null != mView) |
|
|
|
mView.releaseCamera(); |
|
|
|
mView.releaseCamera(); |
|
|
|
super.onPause(); |
|
|
|
super.onPause(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void onResume() { |
|
|
|
protected void onResume() { |
|
|
|
Log.i(TAG, "onResume"); |
|
|
|
Log.i(TAG, "called onResume"); |
|
|
|
super.onResume(); |
|
|
|
super.onResume(); |
|
|
|
|
|
|
|
|
|
|
|
Log.i(TAG, "Trying to load OpenCV library"); |
|
|
|
Log.i(TAG, "Trying to load OpenCV library"); |
|
|
|
if (!OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_2, this, mOpenCVCallBack)) |
|
|
|
if (!OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_2, this, mOpenCVCallBack)) { |
|
|
|
{ |
|
|
|
|
|
|
|
Log.e(TAG, "Cannot connect to OpenCV Manager"); |
|
|
|
Log.e(TAG, "Cannot connect to OpenCV Manager"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -109,7 +110,7 @@ public class FdActivity extends Activity { |
|
|
|
/** Called when the activity is first created. */ |
|
|
|
/** Called when the activity is first created. */ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onCreate(Bundle savedInstanceState) { |
|
|
|
public void onCreate(Bundle savedInstanceState) { |
|
|
|
Log.i(TAG, "onCreate"); |
|
|
|
Log.i(TAG, "called onCreate"); |
|
|
|
super.onCreate(savedInstanceState); |
|
|
|
super.onCreate(savedInstanceState); |
|
|
|
requestWindowFeature(Window.FEATURE_NO_TITLE); |
|
|
|
requestWindowFeature(Window.FEATURE_NO_TITLE); |
|
|
|
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); |
|
|
|
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); |
|
|
@ -117,7 +118,7 @@ public class FdActivity extends Activity { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public boolean onCreateOptionsMenu(Menu menu) { |
|
|
|
public boolean onCreateOptionsMenu(Menu menu) { |
|
|
|
Log.i(TAG, "onCreateOptionsMenu"); |
|
|
|
Log.i(TAG, "called onCreateOptionsMenu"); |
|
|
|
mItemFace50 = menu.add("Face size 50%"); |
|
|
|
mItemFace50 = menu.add("Face size 50%"); |
|
|
|
mItemFace40 = menu.add("Face size 40%"); |
|
|
|
mItemFace40 = menu.add("Face size 40%"); |
|
|
|
mItemFace30 = menu.add("Face size 30%"); |
|
|
|
mItemFace30 = menu.add("Face size 30%"); |
|
|
@ -128,7 +129,7 @@ public class FdActivity extends Activity { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public boolean onOptionsItemSelected(MenuItem item) { |
|
|
|
public boolean onOptionsItemSelected(MenuItem item) { |
|
|
|
Log.i(TAG, "Menu Item selected " + item); |
|
|
|
Log.i(TAG, "called onOptionsItemSelected; selected item: " + item); |
|
|
|
if (item == mItemFace50) |
|
|
|
if (item == mItemFace50) |
|
|
|
mView.setMinFaceSize(0.5f); |
|
|
|
mView.setMinFaceSize(0.5f); |
|
|
|
else if (item == mItemFace40) |
|
|
|
else if (item == mItemFace40) |
|
|
@ -137,8 +138,7 @@ public class FdActivity extends Activity { |
|
|
|
mView.setMinFaceSize(0.3f); |
|
|
|
mView.setMinFaceSize(0.3f); |
|
|
|
else if (item == mItemFace20) |
|
|
|
else if (item == mItemFace20) |
|
|
|
mView.setMinFaceSize(0.2f); |
|
|
|
mView.setMinFaceSize(0.2f); |
|
|
|
else if (item == mItemType) |
|
|
|
else if (item == mItemType) { |
|
|
|
{ |
|
|
|
|
|
|
|
mDetectorType = (mDetectorType + 1) % mDetectorName.length; |
|
|
|
mDetectorType = (mDetectorType + 1) % mDetectorName.length; |
|
|
|
item.setTitle(mDetectorName[mDetectorType]); |
|
|
|
item.setTitle(mDetectorName[mDetectorType]); |
|
|
|
mView.setDetectorType(mDetectorType); |
|
|
|
mView.setDetectorType(mDetectorType); |
|
|
|