Android and OPENCV Integrated Development (2) How to remove the OpenCV Manager package---

Source: Internet
Author: User

To modify the Facedetection example Project for example >

  • 1, modify makefile "android.mk" ( under the JNI directory )
  • OpenCV_CAMERA_MODULES:=onOpenCV_INSTALL_MODULES:=onOpenCV_LIB_TYPE:=SHAREDinclude ${OpenCVROOT}/sdk/native/jni/OpenCV.mk
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---

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.