Exemplo 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);
    // }
  }
Exemplo 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;
  }
Exemplo n.º 4
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);
  }
Exemplo n.º 6
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);
 }
  /** 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);
  }
  @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);
    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);
  }
Exemplo n.º 10
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);
  }
  /** 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
  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);
  }
Exemplo n.º 13
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);
  }
Exemplo n.º 14
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);
  }
Exemplo n.º 15
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;
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    isTraining = getIntent().getBooleanExtra("Training", true);
    setContentView(R.layout.face_detect_surface_view);

    screenWidth = MainPageActivity.getScreenHeight();
    screenHeight = MainPageActivity.getScreenWidth();

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

    captureButton = (ImageView) findViewById(R.id.capturebutton);
    captureText = (TextView) findViewById(R.id.capturetext);
    captureButton.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            closeSoftInput();
            if (capturingImage) {
              captureText.setText("Start Capturing");
              capturingImage = false;
              captureButton.setImageResource(R.drawable.capturestart);
            } else {
              captureText.setText("Stop Capturing");
              captureButton.setImageResource(R.drawable.capturestop);
              capturingImage = true;
            }
          }
        });

    backButton = (ImageView) findViewById(R.id.backbutton);
    backButton.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            goBack();
          }
        });

    saveButton = (Button) findViewById(R.id.addtodbbutton);
    saveButton.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            closeSoftInput();
            if (isTraining) {
              insertToDatabase();
            } else {
              // deleteFromDatabase();
              updateThisPerson();
            }
          }
        });

    nameEdit = (EditText) findViewById(R.id.nameedit);
    nameEdit.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);

    deleteButton = (Button) findViewById(R.id.deletefromdbbutton);
    resetImagesForTraining();
    initOtherViews();
    if (!isTraining) {
      final int personIndex = getIntent().getIntExtra("personIndex", -1);
      new Thread(
              new Runnable() {

                @Override
                public void run() {
                  FaceDetectionUtils.faceDataSource.open();
                  persons = FaceDetectionUtils.faceDataSource.getAllPersons();
                  FaceDetectionUtils.faceDataSource.close();
                  thisPerson = persons.get(personIndex);
                  setImagesForDatabaseEdit();
                  FaceDetectionActivity.this.runOnUiThread(
                      new Runnable() {

                        @Override
                        public void run() {
                          nameEdit.setText(thisPerson.getName());
                          saveButton.setText("Update this person");
                        }
                      });
                }
              })
          .start();
      deleteButton.setVisibility(View.VISIBLE);
      deleteButton.setOnClickListener(
          new OnClickListener() {

            @Override
            public void onClick(View v) {
              closeSoftInput();
              deleteFromDatabase();
            }
          });
    }
    mOpenCvCameraView.enableView();
    bgLayout = (LinearLayout) findViewById(R.id.face_detect_layout);
    bgLayout.setOnTouchListener(
        new View.OnTouchListener() {

          @Override
          public boolean onTouch(View v, MotionEvent event) {
            closeSoftInput();
            return false;
          }
        });
  }
Exemplo n.º 17
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
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_face_recognition);

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    initializeGraphicComponents();

    route = new Route();

    SupportMapFragment mapFragment =
        (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.fragmentMap);
    mapFragment.getMapAsync(this);

    mLocationRequest = Utilities.createLocationRequest(getResources());

    // ATTENTION: This "addApi(AppIndex.API)"was auto-generated to implement the App Indexing API.
    // See https://g.co/AppIndexing/AndroidStudio for more information.
    if (mGoogleApiClient == null) {
      mGoogleApiClient =
          new GoogleApiClient.Builder(this)
              .addApi(LocationServices.API)
              .addConnectionCallbacks(this)
              .addOnConnectionFailedListener(this)
              .addApi(AppIndex.API)
              .build();
    }
    mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);

    gSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
    mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);

    textToSpeech =
        new TextToSpeech(
            getApplicationContext(),
            new TextToSpeech.OnInitListener() {
              @Override
              public void onInit(int status) {
                if (status != TextToSpeech.ERROR) {
                  textToSpeech.setLanguage(Locale.ENGLISH);
                }
              }
            });

    bt = new Bluetooth(this, mHandler);
    connectService();

    ivAddToRoute.setOnLongClickListener(this);

    openCvCameraView = (CameraBridgeViewBase) findViewById(R.id.jcvFaceDetection);
    openCvCameraView.setCvCameraViewListener(this);

    /*handler1.postDelayed(*/
    runnable =
        new Runnable() {
          public void run() {
            try {
              int listSize = facesInASecond.size();
              int trues = Collections.frequency(facesInASecond, true);
              // int falses = Collections.frequency(facesInASecond, false);

              final double faceRatio = ((double) trues / (double) listSize) * (double) 100;

              if (faceRatio > 65) {
                faceDetected = true;
                if (!textToSpeech.isSpeaking())
                  textToSpeech.speak("Please get out the way", TextToSpeech.QUEUE_FLUSH, null);

              } else {
                faceDetected = false;
              }

              runOnUiThread(
                  new Runnable() // start actions in UI thread
                  {

                    @Override
                    public void run() {
                      if (faceDetected)
                        if (!command.equals("STOP")) {
                          Utilities.setDirectionImage("STOP", ivDirection, bt);
                          command = "STOP";
                        }
                      if (!(faceRatio == Double.NaN))
                        tvFaceRatio.setText(
                            "Face ratio: " + String.format("%.02f", faceRatio) + "%");
                      else tvFaceRatio.setText("Face ratio: " + 0 + "%");
                    }
                  });

              Log.d("RATIO", "" + faceRatio);
              Log.d("face state", " " + faceDetected);
              facesInASecond.clear();
            } catch (Exception e) {
              //  Log.e("ERROR", e.printStackTrace() + "");
              e.printStackTrace();
            }
            handler1.postDelayed(this, 1000); // 1 second
          }
        };

    handler1.postDelayed(runnable, 1000);

    /// lathos topothetisi den kerdizw kati apo to thread
    directionThread =
        new Thread(
            new Runnable() {

              @Override
              public void run() {
                while (!Thread.interrupted())
                  try {
                    Thread.sleep(
                        Preferences.loadPrefsInt(
                            "COMMUNICATION_LOOP_REPEAT_TIME", 300, getApplicationContext()));
                    runOnUiThread(
                        new Runnable() // start actions in UI thread
                        {

                          @Override
                          public void run() {
                            if (robotLocation != null
                                && (!route.isEmpty())
                                && running
                                && textToSpeech != null) {

                              if (!faceDetected)
                                command =
                                    Utilities.giveDirection(
                                        compassBearingDegrees,
                                        ivDirection,
                                        ivCompass,
                                        route,
                                        robotLocation,
                                        getApplicationContext(),
                                        command,
                                        mMap,
                                        getResources(),
                                        tvDistance,
                                        textToSpeech,
                                        bt,
                                        false);

                              // END OF PATH REACHED - FINISH PROGRAM
                              if (command.equals("FINISH")) {
                                mMap.clear();
                                tvDistance.setText("---m");
                                if (running)
                                  running =
                                      Utilities.playStopButtonHandler(
                                          route, running, ivPlayStop, getApplicationContext());

                                route.clearRoute();

                                Utilities.setDirectionImage("STOP", ivDirection, bt);
                              }
                            }
                          }
                        });
                  } catch (InterruptedException e) {
                    e.printStackTrace();
                    Log.e(TAG, "run: Direction Thread interrupted");
                    break;
                  }
              }
            });

    directionThread.start();
  }