@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);
   }
 }
Пример #2
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);
    }
  }
Пример #3
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;
      }
    }
  }
  @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();
       */
  }
Пример #5
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main_screen);

    if (!OpenCVLoader.initDebug()) {
      Log.e(this.getClass().getSimpleName(), "  OpenCVLoader.initDebug(), not working.");
    } else {
      Log.d(this.getClass().getSimpleName(), "  OpenCVLoader.initDebug(), working.");
    }

    checkImgButton = (Button) findViewById(R.id.checkImgBtn);
    checkImgButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Intent intent = new Intent(MainScreen.this, OpenCVCameraActivity.class);
            startActivity(intent);
          }
        });

    openGLButton = (Button) findViewById(R.id.openGLButton);
    openGLButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {}
        });
  }
Пример #6
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;
          }
        });
  }
 static {
   if (!OpenCVLoader.initDebug()) {
     Log.d(TAG, "Unable to load OpenCV!");
   } else {
     Log.i(TAG, "OpenCV loaded successfully");
     core.initOnyx();
   }
 }
Пример #8
0
 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
   }
 }
 @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()) {
      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);
  }
Пример #11
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
  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);
  }
Пример #13
0
  private void prepareSpherify(Bitmap bitmap) {

    int insideCircleOutRadius;
    int topY, footY, withinHeight;

    if (!OpenCVLoader.initDebug()) {
      // Handle initialization error
      AppFunctions.showToast(activity.getApplicationContext(), "OpenGL initialization error!");
      activity.finish();
    }

    if (srcImage == null) {
      srcImage = new Mat();

      srcImage.create(bitmap.getHeight(), bitmap.getWidth(), CvType.CV_8UC3);
      Bitmap myBitmap32 = bitmap.copy(Bitmap.Config.ARGB_8888, true);
      Utils.bitmapToMat(myBitmap32, srcImage);

      Imgproc.cvtColor(srcImage, srcImage, Imgproc.COLOR_BGR2RGB, 4);
    }

    Utils.bitmapToMat(bitmap, srcImage);
    // cropImage();
    seamlessEdges(srcImage);
    mSrcWidth = srcImage.cols();
    mSrcHeight = srcImage.rows();

    halfGenImageSize = genImageSize / 2;
    spherifiedImage = new Mat();
    spherifiedImage.create(genImageSize, genImageSize, CvType.CV_8UC4);

    insideCircleOutRadius = (int) (genImageSize / 12);

    topY = (int) (mSrcHeight * (topMargin));
    footY = (int) (mSrcHeight * (footMargin));
    withinHeight = topY - footY;
    scale = withinHeight / ((double) (croppedImageSize / 2 - insideCircleOutRadius));
    offset = (int) (footY - scale * insideCircleOutRadius);
    numProcesses = Runtime.getRuntime().availableProcessors();
    if (numProcesses < 3) numProcesses = 1;
    else numProcesses = 3;
  }
Пример #14
0
 static {
   if (!OpenCVLoader.initDebug()) {
     Log.e(TAG, "Failed to initialize OpenCV!");
   }
   System.loadLibrary("MDig");
 }
 // Khoi dong OpenCV
 static {
   if (!OpenCVLoader.initDebug()) {
     // Handle initialization error
   }
 }
Пример #16
0
 static {
   if (!OpenCVLoader.initDebug()) {
     Log.e(TAG, "Error Initializing OpenCV");
   }
 }
Пример #17
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);
  }
Пример #18
0
 @Override
 public void onResume() {
   super.onResume();
   OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_6, this, mLoaderCallback);
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (!OpenCVLoader.initDebug()) {
      Log.e(this.getClass().getSimpleName(), "  OpenCVLoader.initDebug(), not working.");
    } else {
      Log.d(this.getClass().getSimpleName(), "  OpenCVLoader.initDebug(), working.");
    }

    receivedUsbAttachmentNotifications = new ConcurrentLinkedQueue<UsbDevice>();
    eventLoop = null;

    setContentView(R.layout.activity_ftc_controller);

    utility = new Utility(this);
    context = this;
    entireScreenLayout = (LinearLayout) findViewById(R.id.entire_screen);
    buttonMenu = (ImageButton) findViewById(R.id.menu_buttons);
    buttonMenu.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            openOptionsMenu();
          }
        });

    textDeviceName = (TextView) findViewById(R.id.textDeviceName);
    textWifiDirectStatus = (TextView) findViewById(R.id.textWifiDirectStatus);
    textRobotStatus = (TextView) findViewById(R.id.textRobotStatus);
    textOpMode = (TextView) findViewById(R.id.textOpMode);
    textErrorMessage = (TextView) findViewById(R.id.textErrorMessage);
    textGamepad[0] = (TextView) findViewById(R.id.textGamepad1);
    textGamepad[1] = (TextView) findViewById(R.id.textGamepad2);
    mOpenCvCameraView = (CameraBridgeViewBase) findViewById(R.id.camerapreview);
    immersion = new ImmersiveMode(getWindow().getDecorView());
    dimmer = new Dimmer(this);
    dimmer.longBright();
    Restarter restarter = new RobotRestarter();

    updateUI = new UpdateUI(this, dimmer);
    updateUI.setRestarter(restarter);
    updateUI.setTextViews(
        textWifiDirectStatus,
        textRobotStatus,
        textGamepad,
        textOpMode,
        textErrorMessage,
        textDeviceName);
    callback = updateUI.new Callback();

    PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
    preferences = PreferenceManager.getDefaultSharedPreferences(this);

    WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
    wifiLock = wifiManager.createWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF, "");

    hittingMenuButtonBrightensScreen();

    if (USE_DEVICE_EMULATION) {
      HardwareFactory.enableDeviceEmulation();
    }
  }
Пример #20
0
 @Override
 protected void onResume() {
   super.onResume();
   OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mLoaderCallback);
 }
 @Override
 public void onResume() {
   super.onResume();
   createProgressDialog();
   OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mLoaderCallback);
 }