Exemplo n.º 1
0
  @Override
  public void onResume() {
    super.onResume();
    OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mLoaderCallback);
    Log.i(TAG, "called onResume");
    // Obtener el driver para poder enviar datos al arduino
    this.sendDriver = UsbSerialProber.acquire(this.manager);

    Log.i(TAG, "Resumed, sendDriver=" + sendDriver);

    // manejo del driver para escribir
    if (sendDriver == null) {
      Log.i(TAG, "No se encontro dispositivo");
    } else {
      try {
        sendDriver.open();
      } catch (IOException e) {
        Log.e(TAG, "Error configurando el dispositivo: " + e.getMessage(), e);
        try {
          sendDriver.close();
        } catch (IOException e2) {
          // Ignore.
        }
        sendDriver = null;
        return;
      }
    }
  }
Exemplo n.º 2
0
  /** Called when the activity is first created. */
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mLoaderCallback);
    currentView = 0;

    mGestureSensor = new CameraGestureSensor(this);
    mGestureSensor.addGestureListener(this);
    mGestureSensor.enableClickByColor(true);
    mGestureSensor.addClickListener(this);

    mOpenCVInitiated = false;

    imageView = (ImageView) findViewById(R.id.ImageView01);
    imageView.setImageResource(pics[currentView]);

    ga = (Gallery) findViewById(R.id.Gallery01);
    ga.setAdapter(new ImageAdapter(this));
    ga.setOnItemClickListener(
        new OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> adapter, View givenView, int index, long arg3) {
            Toast.makeText(getBaseContext(), "A click was recieved!", Toast.LENGTH_SHORT).show();
            imageView.setImageResource(pics[index]);
            currentView = index;
          }
        });
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // define some application variables
    activity = this;
    context = activity.getApplicationContext();
    resources = context.getResources();
    packageName = context.getPackageName();

    // dynamically load resources
    R_drawable_left07 = resources.getIdentifier("left07", "drawable", packageName);
    R_drawable_left08 = resources.getIdentifier("left08", "drawable", packageName);
    R_id_imageView1 = resources.getIdentifier("imageView1", "id", packageName);

    // dynamical version of setContentView(R.layout.activity_main);
    // LayoutInflater inflater = LayoutInflater.from(context);
    // View appearance = inflater.inflate(resources.getIdentifier("activity_main", "layout",
    // packageName),null);

    this.setContentView(resources.getIdentifier("activity_main", "layout", packageName));

    // init opencv and start actions (see mLoaderCallback below)
    OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_9, this, mLoaderCallback);

    /*
    String msg = getIntent().getStringExtra("de-michaelskoehler-imgtrafo-test");

       // my alert hello world
       new AlertDialog.Builder(this).setTitle("Delete entry").setMessage(msg).show();
       */
  }
 @Override
 public void onResume() {
   super.onResume();
   Log.d(TAG, "On Resume");
   // startMarkerDetectionProcess();
   Log.i(TAG, "Trying to load OpenCV library");
   if (!OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_2, this, mOpenCVCallBack)) {
     Log.e(TAG, "Cannot connect to OpenCV Manager");
   }
 }
 @Override
 public void onResume() {
   super.onResume();
   if (!OpenCVLoader.initDebug()) {
     Log.d(TAG, "Internal OpenCV library not found. Using OpenCV Manager for initialization");
     OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_3_0_0, this, mLoaderCallback);
   } else {
     Log.d(TAG, "OpenCV library found inside package. Using it!");
     mLoaderCallback.onManagerConnected(LoaderCallbackInterface.SUCCESS);
   }
 }
Exemplo n.º 6
0
  @Override
  public void onResume() {
    super.onResume();

    if (!OpenCVLoader.initDebug()) {
      Timber.d("Internal OpenCV library not found.");
      OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_3_1_0, this, mLoaderCallback);
    } else {
      Timber.d("OpenCV library found in package.");
      mLoaderCallback.onManagerConnected(LoaderCallbackInterface.SUCCESS);
    }
  }
Exemplo n.º 7
0
 @Override
 public void onResume() {
   super.onResume();
   OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mLoaderCallback);
   for (int i = 0; i < 480; i++) {
     for (int j = 0; j < 640; j++) {
       data[i][j] = (float) -5000.0;
     }
   }
   if (mThermal.start(this)) {
     hasThermal = true;
   } else {
     hasThermal = false;
   }
 }
  @Override
  public void onResume() {
    super.onResume();
    if (!OpenCVLoader.initDebug()) {
      OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_10, this, mLoaderCallback);
    } else {
      mLoaderCallback.onManagerConnected(LoaderCallbackInterface.SUCCESS);
    }

    if (mGoogleApiClient.isConnected()) startLocationUpdates();

    // Legacy compass sensor
    /*mSensorManager.registerListener(this, mSensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION),
    SensorManager.SENSOR_DELAY_GAME);*/

    mSensorManager.registerListener(this, gSensor, SensorManager.SENSOR_DELAY_UI);
    mSensorManager.registerListener(this, mSensor, SensorManager.SENSOR_DELAY_UI);
    mSensorManager.registerListener(
        this,
        mSensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE),
        SensorManager.SENSOR_DELAY_UI);
  }
Exemplo n.º 9
0
 @Override
 protected void onResume() {
   super.onResume();
   OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mLoaderCallback);
 }
Exemplo n.º 10
0
 @Override
 public void onResume() {
   super.onResume();
   OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_6, this, mLoaderCallback);
 }
Exemplo n.º 11
0
 @Override
 public void onResume() {
   super.onResume();
   createProgressDialog();
   OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mLoaderCallback);
 }
Exemplo n.º 12
0
  @Override
  public void surfaceCreated(SurfaceHolder arg0) {
    // TODO Auto-generated method stub
    OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, getActivity(), mLoaderCallback);
    mCamera = Camera.open();
    Camera.Parameters parameters = mCamera.getParameters();

    List<android.hardware.Camera.Size> sizes = parameters.getSupportedPreviewSizes();
    // if portrait frameSize , width is less than height
    Size frameSize =
        calculateCameraFrameSize(sizes, mSurface.getWidth(), mSurface.getHeight(), true);

    parameters.setPreviewSize((int) frameSize.height, (int) frameSize.width);
    parameters.set("orientation", "portrait");
    parameters.setPreviewFormat(ImageFormat.NV21);

    mFrameWidth = (int) frameSize.width;
    mFrameHeight = (int) frameSize.height;

    mCamera.setDisplayOrientation(90);

    try {
      mCamera.setPreviewDisplay(mHolder);
      mCamera.setParameters(parameters);
      mCamera.setPreviewCallback(this);
    } catch (Exception e) {

    }

    mZoomBar.setMax(mCamera.getParameters().getMaxZoom());
    mZoomBar.setProgress(mCamera.getParameters().getZoom());
    mZoomBar.setOnSeekBarChangeListener(
        new OnSeekBarChangeListener() {

          @Override
          public void onProgressChanged(SeekBar arg0, int arg1, boolean arg2) {
            // TODO Auto-generated method stub
            // modify zoom
            Camera.Parameters params = mCamera.getParameters();
            params.setZoom(arg1);
            mCamera.setParameters(params);

            mZoomBar.setProgress(arg1);
          }

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

          }

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

          }
        });

    mCamera.startPreview();
    mCamera.autoFocus(mAutoFocusCallback);
  }