Advertisement
Guest User

TrackerActivity

a guest
Sep 12th, 2014
366
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.34 KB | None | 0 0
  1. package edu.uab.cvc.androiddocscan.views;
  2.  
  3.  
  4. import org.opencv.android.CameraBridgeViewBase.CvCameraViewFrame;
  5. import org.opencv.android.CameraBridgeViewBase.CvCameraViewListener2;
  6. import org.opencv.android.OpenCVLoader;
  7. import org.opencv.core.Mat;
  8.  
  9. import android.app.Activity;
  10. import android.os.Bundle;
  11. import android.util.Log;
  12. import android.view.View;
  13. import android.view.WindowManager;
  14. import edu.uab.cvc.androiddocscan.R;
  15. import edu.uab.cvc.androiddocscan.controllers.AppContextFactory;
  16. import edu.uab.cvc.androiddocscan.controllers.Context;
  17.  
  18. public class TrackerActivity extends Activity implements CvCameraViewListener2 {
  19.     private static final String TAG = "Tracker::Activity";
  20.     private JavaCamResView openCVCameraView;
  21.     private MyLoaderCallback loaderCallback;
  22.    
  23.     private String [] librariesToLoad = {"tracker"};
  24.    
  25.     Context appContext;
  26.  
  27.     public TrackerActivity() {
  28.         Log.i(TAG, "Instantiated new " + this.getClass());     
  29.         appContext = (new AppContextFactory()).create();
  30.  
  31.     }
  32.  
  33.     public void onClickImage(View view) {
  34.         openCVCameraView.autoFocus();
  35.  
  36.     }
  37.  
  38.     public void onClick(View view) {
  39.     }
  40.  
  41.     /** Called when the activity is first created. */
  42.     @Override
  43.     public void onCreate(Bundle savedInstanceState) {
  44.         Log.i(TAG, "called onCreate");
  45.         super.onCreate(savedInstanceState);
  46.         getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  47.  
  48.         setContentView(R.layout.tracker_surface_view);     
  49.        
  50.         /* Initialise opencv camera and loader modules */
  51.         openCVCameraView = (JavaCamResView) findViewById(R.id.id_activity_surface_view);
  52.         loaderCallback = new MyLoaderCallback(this,librariesToLoad,openCVCameraView);
  53.         OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, loaderCallback);
  54.         openCVCameraView.setCvCameraViewListener(this);
  55.  
  56.     }
  57.    
  58.    
  59.     @Override
  60.     public void onPause() {
  61.         super.onPause();
  62.         if (openCVCameraView != null)
  63.             openCVCameraView.disableView();
  64.     }
  65.  
  66.     @Override
  67.     public void onResume() {
  68.         super.onResume();
  69.        
  70.     }
  71.  
  72.     @Override
  73.     public void onDestroy() {
  74.         super.onDestroy();
  75.         openCVCameraView.disableView();
  76.     }
  77.  
  78.     @Override
  79.     public void onCameraViewStarted(int width, int height) {
  80.     }
  81.  
  82.     @Override
  83.     public void onCameraViewStopped() {
  84.     }
  85.  
  86.     @Override
  87.     public Mat onCameraFrame(CvCameraViewFrame frame) {
  88.         Mat outputFrame = frame.rgba().clone();
  89.         return outputFrame;
  90.     }
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement