Esempio n. 1
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) {}
        });
  }
Esempio n. 2
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
   }
 }
 static {
   if (!OpenCVLoader.initDebug()) {
     Log.d(TAG, "Unable to load OpenCV!");
   } else {
     Log.i(TAG, "OpenCV loaded successfully");
     core.initOnyx();
   }
 }
 @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);
   }
 }
Esempio n. 5
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);
    }
  }
  @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);
  }
Esempio n. 7
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;
  }
  @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);
  }
Esempio n. 9
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
   }
 }
 static {
   if (!OpenCVLoader.initDebug()) {
     Log.e(TAG, "Error Initializing OpenCV");
   }
 }
  @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();
    }
  }