To modify the Facedetection example Project for example >
2. Modify the Fdactivity.java file <1> Add static functions
static { Log.i(TAG,"OpenCV library load!"); if (!OpenCVLoader.initDebug()) { Log.i(TAG,"OpenCV load not successfully"); } else { System.loadLibrary("detection_based_tracker");// load other libraries}}
<2>Remove the last sentence of the Fdactivity.java Onresume () method and not let it go to OpenCV Manager
@Overridepublic void onResume() {super.onResume();
//OpenCVLoader.initAsync(OpenCVLoader.OpenCV_VERSION_2_4_3, this, mLoaderCallback);//
}
<3> Modifying the OnCreate () method of Fdactivity.java
public void onCreate(Bundle savedInstanceState) { Log.i(TAG,"called onCreate");super.onCreate(savedInstanceState);getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);setContentView(R.layout.face_detect_surface_view);
// add start
try {//load Cascade file from application resources InputStream is = Getresources (). Openrawresource (R.raw.lbpcascade_fr Ontalface); File Cascadedir = Getdir ("Cascade", context.mode_private); Mcascadefile = new File (Cascadedir, "lbpcascade_frontalface.xml"); FileOutputStream OS = new FileOutputStream (mcascadefile); byte[] buffer = new byte[4096]; int bytesread; while ((bytesread = is.read (buffer))! =-1) {os.write (buffer, 0, bytesread);} Is.close (); Os.close (); Mjavadetector = new Cascadeclassifier (Mcascadefile.getabsolutepath ()); if (Mjavadetector.empty ()) {LOG.E (tag, "Failed to load Cascade classifier"); mjavadetector = null;} else LOG.I (tag, "Loade D Cascade classifier from "+ Mcascadefile.getabsolutepath ()); Mnativedetector = new Detectionbasedtracker (Mcascadefile.getabsolutepath (), 0);//Hujiaweicascadedir.delete (); } catch (IOException e) {e.printstacktrace (); LOG.E (TAG, "Failed to load cascade. Exception thrown: "+ e);}
//add end
mOpenCVCameraView = (CameraBridgeViewBase) findViewById(R.id.fd_activity_surface_view);mOpenCVCameraView.enableView();
// add.
mOpenCVCameraView.setCvCameraViewListener(this);}
Android and OPENCV Integrated Development (2) How to remove the OpenCV Manager package---