Exemplo n.º 1
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;
          }
        });
  }
Exemplo n.º 2
0
 @Override
 public void onManagerConnected(int status) {
   switch (status) {
     case LoaderCallbackInterface.SUCCESS:
       {
         mOpenCVInitiated = true;
         CameraGestureSensor.loadLibrary();
         mGestureSensor.start();
       }
       break;
     default:
       {
         super.onManagerConnected(status);
       }
       break;
   }
 }
Exemplo n.º 3
0
 /**
  * Called when the activity is paused. The gesture detector is stopped so that the camera is no
  * longer working to recognize gestures.
  */
 @Override
 public void onPause() {
   super.onPause();
   if (!mOpenCVInitiated) return;
   mGestureSensor.stop();
 }
Exemplo n.º 4
0
 /** Called when the activity is resumed. The gesture detector is initialized. */
 @Override
 public void onResume() {
   super.onResume();
   if (!mOpenCVInitiated) return;
   mGestureSensor.start();
 }