Ejemplo n.º 1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    Log.i(TAG, "called onCreate");
    super.onCreate(savedInstanceState);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    setContentView(R.layout.activity_recharge_return);
    mOpenCvCameraView = (CameraBridgeViewBase) findViewById(R.id.ReturnRechargeCvView);
    mOpenCvCameraView.setVisibility(SurfaceView.VISIBLE);
    mOpenCvCameraView.setCvCameraViewListener(this);

    // create a File object for the parent directory
    File logDirectory = new File("/sdcard/Logs/");
    logDirectory.mkdirs();
    File PicDirectory = new File("/sdcard/TestPics/");
    PicDirectory.mkdirs();

    /** Logging used by the class */
    log = Logger.getLogger(RechargeReturn.class.getName());
    try {
      Handler handler = new FileHandler("/sdcard/Logs/RechargeReturn.log", 2000000, 1);
      log.addHandler(handler);
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    doBindService();

    twist = new Twist();

    // Start clock time for frame time
    startTime = System.currentTimeMillis();
  }
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    if (D) Log.i(TAG, "called onCreate");
    super.onCreate(savedInstanceState);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    setContentView(R.layout.activity_main);
    startActivity(new Intent(this, SplashViewActivity.class));

    // mCamera = openFrontFacingCamera();

    mOpenCvCameraView = (CameraBridgeViewBase) findViewById(R.id.java_surface_view);
    mOpenCvCameraView.setVisibility(SurfaceView.VISIBLE);
    if (!D) {
      android.view.ViewGroup.LayoutParams params = mOpenCvCameraView.getLayoutParams();
      params.width = LayoutParams.FILL_PARENT;
      params.height = LayoutParams.FILL_PARENT;
      mOpenCvCameraView.setLayoutParams(params);
    }
    mOpenCvCameraView.setCvCameraViewListener(this);
    mMatchImageUtil = new MatchImageUtil(this);

    mOpenCvCameraView.setOnClickListener(this);

    // {
    //	Intent intent = new Intent(MainActivity.this,PlayerViewDemoActivity.class);
    //	intent.putExtra("video_uri", "3dnxG6fxXi8");
    //	startActivity(intent);
    // }
  }
Ejemplo n.º 3
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    String toastMesage = new String();

    if (item == mItemSwitchCamera) {
      mOpenCvCameraView.setVisibility(SurfaceView.GONE);
      mIsJavaCamera = !mIsJavaCamera;

      if (mIsJavaCamera) {
        mOpenCvCameraView = (CameraBridgeViewBase) findViewById(R.id.java_surface_view);
        toastMesage = "Java Camera";
      } else {
        mOpenCvCameraView = (CameraBridgeViewBase) findViewById(R.id.native_surface_view);
        toastMesage = "Native Camera";
      }

      mOpenCvCameraView.setVisibility(SurfaceView.VISIBLE);
      mOpenCvCameraView.setCvCameraViewListener(this);
      mOpenCvCameraView.enableView();
      Toast toast = Toast.makeText(this, toastMesage, Toast.LENGTH_LONG);
      toast.show();
    }

    return true;
  }
Ejemplo n.º 4
0
 public void startStopAppOnClick(View view) {
   if ((startStopBtn.getText().toString())
       .equals(getResources().getString(R.string.START_APP_STRING))) {
     mOpenCvCameraView.setVisibility(SurfaceView.VISIBLE);
     startStopBtn.setText(R.string.STOP_APP_STRING);
   } else {
     mOpenCvCameraView.setVisibility(SurfaceView.INVISIBLE);
     startStopBtn.setText(R.string.START_APP_STRING);
   }
 }
Ejemplo n.º 5
0
 /** Appelée lorque l'activité est créée */
 @Override
 public void onCreate(Bundle savedInstanceState) {
   Log.i(TAG, "called onCreate");
   compteur = 0;
   super.onCreate(savedInstanceState);
   getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
   setContentView(R.layout.open_surface_view);
   mOpenCvCameraView = (CameraBridgeViewBase) findViewById(R.id.open_activity_java_surface_view);
   mOpenCvCameraView.setVisibility(SurfaceView.VISIBLE);
   mOpenCvCameraView.setCvCameraViewListener(this);
 }
Ejemplo n.º 6
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    setContentView(R.layout.surface_view);

    if (mIsJavaCamera)
      mOpenCvCameraView = (CameraBridgeViewBase) findViewById(R.id.java_surface_view);
    else mOpenCvCameraView = (CameraBridgeViewBase) findViewById(R.id.native_surface_view);

    mOpenCvCameraView.setVisibility(SurfaceView.VISIBLE);

    mOpenCvCameraView.setCvCameraViewListener(this);
  }
        @Override
        public void onManagerConnected(int status) {
          switch (status) {
            case LoaderCallbackInterface.SUCCESS:
              {
                if (D) Log.i(TAG, "OpenCV loaded successfully");

                mOpenCvCameraView.enableView();

                Handler postHandler = new Handler();
                postHandler.postDelayed(
                    new Runnable() {
                      @Override
                      public void run() {
                        // TODO Auto-generated method stub
                        mMatchImageUtil.loadCachedFiles();
                        mProgressDialog.dismiss();
                      }
                    },
                    50);
              }
              break;
            default:
              {
                super.onManagerConnected(status);
              }
              break;
          }
        }
  private void initializeOpenCVDependencies() {

    try {

      InputStream is = getResources().openRawResource(R.raw.lbpcascade_frontalface);
      File cascadeDir = getDir("cascade", Context.MODE_PRIVATE);
      File 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();

      // Load the cascade classifier
      cascadeClassifier = new CascadeClassifier(mCascadeFile.getAbsolutePath());
    } catch (Exception e) {
      Log.e("OpenCVActivity", "Error loading cascade", e);
    }

    openCvCameraView.enableView();
  }
Ejemplo n.º 9
0
 public void onDestroy() {
   /** Emergency stop */
   sendTwist(new Twist(0, 0, 0, 0, 0, 0));
   super.onDestroy();
   doUnbindService();
   if (mOpenCvCameraView != null) mOpenCvCameraView.disableView();
 }
Ejemplo n.º 10
0
 @Override
 public void onManagerConnected(int status) {
   switch (status) {
     case LoaderCallbackInterface.SUCCESS:
       {
         Log.i(TAG, "OpenCV loaded successfully");
         mOpenCvCameraView.enableView();
         mOpenCvCameraView.setOnTouchListener(CanDetectActivity.this);
       }
       break;
     default:
       {
         super.onManagerConnected(status);
       }
       break;
   }
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    setContentView(R.layout.activity_open_cv);

    if (!OpenCVLoader.initDebug()) {
      // Handle initialization error
      Log.i(TAG, "::onCreate:" + "intialise error :" + "Handle initialization error");
    }

    mOpenCvCameraView =
        (CameraBridgeViewBase) findViewById(R.id.tutorial1_activity_native_surface_view);

    mOpenCvCameraView.setVisibility(SurfaceView.VISIBLE);

    mOpenCvCameraView.setCvCameraViewListener(this);
  }
Ejemplo n.º 12
0
  /** 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.face_detect_surface_view);

    mOpenCvCameraView = (CameraBridgeViewBase) findViewById(R.id.fd_activity_surface_view);
    mOpenCvCameraView.setCvCameraViewListener(this);

    mMethodSeekbar = (SeekBar) findViewById(R.id.methodSeekBar);
    mValue = (TextView) findViewById(R.id.method);

    mMethodSeekbar.setOnSeekBarChangeListener(
        new OnSeekBarChangeListener() {

          @Override
          public void onStopTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub

          }

          @Override
          public void onStartTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub

          }

          @Override
          public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            method = progress;
            switch (method) {
              case 0:
                mValue.setText("TM_SQDIFF");
                break;
              case 1:
                mValue.setText("TM_SQDIFF_NORMED");
                break;
              case 2:
                mValue.setText("TM_CCOEFF");
                break;
              case 3:
                mValue.setText("TM_CCOEFF_NORMED");
                break;
              case 4:
                mValue.setText("TM_CCORR");
                break;
              case 5:
                mValue.setText("TM_CCORR_NORMED");
                break;
            }
          }
        });
  }
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    setContentView(R.layout.activity_cameratest);

    mOpenCvCameraView = (CameraBridgeViewBase) findViewById(R.id.surfaceView);
    mOpenCvCameraView.setCvCameraViewListener(this);
  }
        @Override
        public void onManagerConnected(int status) {
          switch (status) {
            case LoaderCallbackInterface.SUCCESS:
              {
                Log.i(TAG, "OpenCV loaded successfully");

                /* Now enable camera view to start receiving frames */
                mOpenCvCameraView.setOnTouchListener(PuzzleActivity.this);
                mOpenCvCameraView.enableView();
              }
              break;
            default:
              {
                super.onManagerConnected(status);
              }
              break;
          }
        }
Ejemplo n.º 15
0
  /** 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.face_detect_surface_view);

    // //
    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);
    }

    mOpenCvCameraView = (CameraBridgeViewBase) findViewById(R.id.fd_activity_surface_view);
    mOpenCvCameraView.enableView(); //
    mOpenCvCameraView.setCvCameraViewListener(this);
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    Log.d(TAG, "************************ Creating and seting view");
    mOpenCvCameraView = (CameraBridgeViewBase) new JavaCameraView(this, -1);
    setContentView(mOpenCvCameraView);
    mOpenCvCameraView.setCvCameraViewListener(this);
    mPuzzle15 = new PuzzleProcessor(Settings.getGridSize(this));
    mPuzzle15.prepareNewGame();
  }
  /** 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.image_manipulations_surface_view);

    mOpenCvCameraView =
        (CameraBridgeViewBase) findViewById(R.id.image_manipulations_activity_surface_view);
    mOpenCvCameraView.setCvCameraViewListener(this);
  }
Ejemplo n.º 18
0
  /** 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.tutorial1_surface_view);
    startStopBtn = (Button) findViewById(R.id.buttonStartStop);
    startStopBtn.setText(R.string.START_APP_STRING);

    if (mIsJavaCamera)
      mOpenCvCameraView =
          (CameraBridgeViewBase) findViewById(R.id.tutorial1_activity_java_surface_view);
    else
      mOpenCvCameraView =
          (CameraBridgeViewBase) findViewById(R.id.tutorial1_activity_native_surface_view);

    mOpenCvCameraView.setVisibility(SurfaceView.INVISIBLE);

    mOpenCvCameraView.setCvCameraViewListener(this);
  }
Ejemplo n.º 19
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    String toastMesage = new String();
    Log.i(TAG, "called onOptionsItemSelected; selected item: " + item);

    if (item == mItemSwitchCamera) {
      mOpenCvCameraView.setVisibility(SurfaceView.GONE);
      mIsJavaCamera = !mIsJavaCamera;

      mOpenCvCameraView = (CameraBridgeViewBase) findViewById(R.id.camview);
      toastMesage = "Java Camera";

      mOpenCvCameraView.setVisibility(SurfaceView.VISIBLE);
      mOpenCvCameraView.setCvCameraViewListener(this);
      mOpenCvCameraView.enableView();
      Toast toast = Toast.makeText(this, toastMesage, Toast.LENGTH_LONG);
      toast.show();
    }

    return true;
  }
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    Log.i(TAG, "called onCreate");
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    setContentView(R.layout.activity_main);

    mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();

    mOpenCvCameraView = (CameraBridgeViewBase) findViewById(R.id.camerapreview);
    mOpenCvCameraView.setCvCameraViewListener(this);
  }
Ejemplo n.º 21
0
        @Override
        public void onManagerConnected(int status) {
          switch (status) {
            case LoaderCallbackInterface.SUCCESS:
              {
                Log.i(TAG, "OpenCV loaded successfully");
                /*
                //Ce qui suit concerne la reconnaissance d'objet, à commenter si non souhaité
                try {
                    // On charge le fichier XML contenant les données du classifieur (on l'a ajouté au dossier res/raw)
                    InputStream is = getResources().openRawResource(R.raw.banana);
                    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();

                    mCascadeClassifier = new CascadeClassifier(mCascadeFile.getAbsolutePath());
                    if (mCascadeClassifier.empty()) {
                        Log.e(TAG, "Failed to load cascade classifier");
                        mCascadeClassifier = null;
                    } else
                        Log.i(TAG, "Loaded cascade classifier from " + mCascadeFile.getAbsolutePath());

                    cascadeDir.delete();

                } catch (IOException e) {
                    e.printStackTrace();
                    Log.e(TAG, "Failed to load cascade. Exception thrown: " + e);
                }
                //Fin de la partie sur la reconnaissance d'image
                 */
                mOpenCvCameraView.enableView();
              }
              break;
            default:
              {
                super.onManagerConnected(status);
              }
              break;
          }
        }
Ejemplo n.º 22
0
 @Override
 public void onManagerConnected(int status) {
   switch (status) {
     case LoaderCallbackInterface.SUCCESS:
       {
         // Log.i(TAG, "OpenCV loaded successfully");
         mOpenCvCameraView.enableView();
       }
       break;
     default:
       {
         super.onManagerConnected(status);
       }
       break;
   }
 }
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    Log.i(TAG, "called onCreate");
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    setContentView(R.layout.color_blob_detection_surface_view);

    mOpenCvCameraView =
        (CameraBridgeViewBase) findViewById(R.id.color_blob_detection_activity_surface_view);
    mOpenCvCameraView.setCvCameraViewListener(this);
    hehe = (TextView) findViewById(R.id.hehe);
    imageView = (ImageView) findViewById(R.id.imageView);
    imageView.setImageResource(R.drawable.red1);
  }
        @Override
        public void onManagerConnected(int status) {
          switch (status) {
            case LoaderCallbackInterface.SUCCESS:
              {
                // OpenCV loaded successfully!
                // Load native library AFTER OpenCV initialization

                initialize();

                mOpenCvCameraView.enableView();
              }
              break;
            default:
              {
                super.onManagerConnected(status);
              }
              break;
          }
        }
Ejemplo n.º 25
0
  /** 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.camera_layout);

    mOpenCvCameraView = (CameraBridgeViewBase) findViewById(R.id.camview);

    mOpenCvCameraView.setMaxFrameSize(640, 480);

    mOpenCvCameraView.setVisibility(SurfaceView.VISIBLE);

    mOpenCvCameraView.setCvCameraViewListener(this);

    mCamButton = (ImageButton) findViewById(R.id.scanButtton);
    mCancleButton = (ImageButton) findViewById(R.id.cancelButton);

    mCamButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (hasScanBase == false) {
              if (takeScanBase == false) {
                // Toast.makeText(CameraActivity.this, "Taking background image",
                // Toast.LENGTH_SHORT).show();
                takeScanBase = true;
                mCamButton.setBackgroundResource(R.drawable.checkbox);
                if (hasThermal) mThermal.setLaser(true);
              }
            } else {
              mOpenCvCameraView.disableView();
              (new ProccessImg(data)).execute();
              if (hasThermal) mThermal.setLaser(false);
            }
          }
        });

    mCancleButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {

            if (hasThermal) mThermal.setLaser(false);

            if (hasScanBase == true) {
              hasScanBase = false;
              mCamButton.setBackgroundResource(R.drawable.camera_very_small);
            } else {
              finish();
            }
          }
        });

    for (int i = 0; i < 480; i++) {
      for (int j = 0; j < 640; j++) {
        data[i][j] = (float) -5000.0;
      }
    }
  }
 @Override
 public void onPause() {
   super.onPause();
   if (mOpenCvCameraView != null) mOpenCvCameraView.disableView();
 }
Ejemplo n.º 27
0
 public void onDestroy() {
   super.onDestroy();
   mOpenCvCameraView.disableView();
 }
Ejemplo n.º 28
0
 @Override
 public void onDestroy() {
   super.onDestroy();
   // apaga camara
   if (mOpenCvCameraView != null) mOpenCvCameraView.disableView();
 }
 public void onDestroy() {
   super.onDestroy();
   if (mOpenCvCameraView != null) mOpenCvCameraView.disableView();
 }
Ejemplo n.º 30
0
 @Override
 public void onPause() {
   if (hasThermal) mThermal.stop();
   if (mOpenCvCameraView != null) mOpenCvCameraView.disableView();
   super.onPause();
 }