編輯:關於Android編程
以修改FaceDetection例子工程為例>
2,修改FdActivity.java文件 <1>增加靜態函數OpenCV_CAMERA_MODULES:=
on
OpenCV_INSTALL_MODULES:=
on
OpenCV_LIB_TYPE:=
SHARED
include ${OpenCVROOT}/sdk/native/jni/OpenCV.mk
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>刪除FdActivity.java的OnResume()方法的最後那句,不讓它去訪問OpenCV Manager
<3>修改FdActivity.java的OnCreate()方法@Override public void onResume() { super.onResume();
//OpenCVLoader.initAsync(OpenCVLoader.OpenCV_VERSION_2_4_3, this, mLoaderCallback);//
}
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_frontalface); 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,"Loaded cascade classifier from"+ mCascadeFile.getAbsolutePath()); mNativeDetector = new DetectionBasedTracker(mCascadeFile.getAbsolutePath(), 0);// hujiawei cascadeDir.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); }
在tv上開發gridview有焦點放大這個效果還是很普遍的做法,今天就講下這個實現方案,當然要實現這個效果有很多種,我這裡只是講其中的一種實現方案,也是比較簡單而且容易看
項目中最近用到各種圖表,本來打算用第三方的,例如MPAndroid,這是一個十分強大的圖表庫,應用起來十分方便,但是最終發現和設計不太一樣,沒辦法,只能自己寫了。今天將寫
本篇教程中使用到的Android Studio版本為1.0, Eclipse ADT版本23.0.4。請嘗試更新到該版本。Android Studio默認使用 Gradl
一.Service簡介service可以說是一個在後台運行的Activity,它不是一個單獨的進程,它只需要應用告訴它要在後台做什麼就可以了,它要實現和用戶的交互的話需要