Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package edu.uab.cvc.androiddocscan.views;
- import org.opencv.android.CameraBridgeViewBase.CvCameraViewFrame;
- import org.opencv.android.CameraBridgeViewBase.CvCameraViewListener2;
- import org.opencv.android.OpenCVLoader;
- import org.opencv.core.Mat;
- import android.app.Activity;
- import android.os.Bundle;
- import android.util.Log;
- import android.view.View;
- import android.view.WindowManager;
- import edu.uab.cvc.androiddocscan.R;
- import edu.uab.cvc.androiddocscan.controllers.AppContextFactory;
- import edu.uab.cvc.androiddocscan.controllers.Context;
- public class TrackerActivity extends Activity implements CvCameraViewListener2 {
- private static final String TAG = "Tracker::Activity";
- private JavaCamResView openCVCameraView;
- private MyLoaderCallback loaderCallback;
- private String [] librariesToLoad = {"tracker"};
- Context appContext;
- public TrackerActivity() {
- Log.i(TAG, "Instantiated new " + this.getClass());
- appContext = (new AppContextFactory()).create();
- }
- public void onClickImage(View view) {
- openCVCameraView.autoFocus();
- }
- public void onClick(View view) {
- }
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- Log.i(TAG, "called onCreate");
- super.onCreate(savedInstanceState);
- getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
- setContentView(R.layout.tracker_surface_view);
- /* Initialise opencv camera and loader modules */
- openCVCameraView = (JavaCamResView) findViewById(R.id.id_activity_surface_view);
- loaderCallback = new MyLoaderCallback(this,librariesToLoad,openCVCameraView);
- OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, loaderCallback);
- openCVCameraView.setCvCameraViewListener(this);
- }
- @Override
- public void onPause() {
- super.onPause();
- if (openCVCameraView != null)
- openCVCameraView.disableView();
- }
- @Override
- public void onResume() {
- super.onResume();
- }
- @Override
- public void onDestroy() {
- super.onDestroy();
- openCVCameraView.disableView();
- }
- @Override
- public void onCameraViewStarted(int width, int height) {
- }
- @Override
- public void onCameraViewStopped() {
- }
- @Override
- public Mat onCameraFrame(CvCameraViewFrame frame) {
- Mat outputFrame = frame.rgba().clone();
- return outputFrame;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement