NewHandwave


Source link: https://github.com/jtkac/NewHandwave

NewHandwave

All Credit for the C files Goes to the original Kritts/Handwave Repo

Handwave was originally intended to be a library that would use a phone's front facing camera to detect a gesture that happens overtop the phone. Generally done with your hand, you can wave your hand up, down, left, right, and further out then towards your phone which registers as a click. The motions are simplified to implement in your project with an interface that may be passed in via parameters. See the usage examples below.

I have made a big update in improving the methodology used in the original library (it is a library now and not a project).

The Library now uses a programmatic instance of JavaCameraView (newer) instead of CameraBridgeViewBase

The sensing of motion is now more accurate (opposed to swiping up and it picks up left/right more easily).

I have added convenience methods for initializing when imported as a library and checking permissions > Android M.

I have accounted for OpenCVManager not loading the correct version of OpenCV.

Added pass filters for better accuracy

For more compare this with https://github.com/kritts/HandWave

Usage on a seperate project:

  1. Download the library to your computer

  2. Open the project you want to add this to

  3. File -> New -> Import Module

  4. Check Both -> OK -> Wait for the libraries to index

  5. Right Click your app module -> Open Module Settings

  6. Click the dependencies tab

  7. Click the + icon and select the module option

  8. Add Both the openCV module and the NewHandwave module

  9. The library is now usable in your project (See below for instructions)

Manifest:

  <uses-permission android:name="android.permission.CAMERA" /> 

Activity/Fragment usage:



  YourActivity implements CameraGestureSensor.Listener, ClickSensor.Listener

 @Override

 protected void onCreate(Bundle savedInstanceState) {

  super.onCreate(savedInstanceState);

  setContentView(R.layout.activity_main);

  if (PermissionUtility.checkCameraPermission(this)) {

//The third passing in represents a separate click sensor which is not required if you just want the hand motions

LocalOpenCV loader = new LocalOpenCV(YourActivity.this, YourActivity.this, YourActivity.this);

  
}

 
}

@Override

 public void onResume() {

  super.onResume();

  if (PermissionUtility.checkCameraPermission(this)) {

LocalOpenCV loader = new LocalOpenCV(YourActivity.this, YourActivity.this, YourActivity.this);

  
}

 
}
 

Customize the following to correspond to the actions the sensor picks up:



 @Override

 public void onGestureUp(CameraGestureSensor caller, long gestureLength) {

  Log.i(TAG, "Up");

  runOnUiThread(new Runnable() {

@Override

public void run() {

 Toast.makeText(YourActivity.this, "Hand Motion Up", Toast.LENGTH_SHORT).show();

}

  
}
);

 
}

  @Override

 public void onGestureDown(CameraGestureSensor caller, long gestureLength) {

  Log.i(TAG, "Down");

  runOnUiThread(new Runnable() {

@Override

public void run() {

 Toast.makeText(YourActivity.this, "Hand Motion Down", Toast.LENGTH_SHORT).show();

}

  
}
);

  
}

  @Override

 public void onGestureLeft(CameraGestureSensor caller, long gestureLength) {

  Log.i(TAG, "Left");

  runOnUiThread(new Runnable() {

@Override

public void run() {

 Toast.makeText(YourActivity.this, "Hand Motion Left", Toast.LENGTH_SHORT).show();

}

  
}
);

 
}

  @Override

 public void onGestureRight(CameraGestureSensor caller, long gestureLength) {

  Log.i(TAG, "RIght");

  runOnUiThread(new Runnable() {

@Override

public void run() {

 Toast.makeText(YourActivity.this, "Hand Motion Right", Toast.LENGTH_SHORT).show();

}

  
}
);

 
}

  @Override

 public void onSensorClick(ClickSensor caller) {

  Log.i(TAG, "Click");

  runOnUiThread(new Runnable() {

@Override

public void run() {

 Toast.makeText(MainActivity.this, "CLICK!", Toast.LENGTH_SHORT).show();

}

  
}
);

 
}
 

Enjoy!

Copyright 2014 Krittika D'Silva

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Resources

Wrappers for Android adapters to simply its api at a minimum.

Simplify usage of RecyclerView with various types of adapters.

A sample of how to mimic the way that the contacts app handles a Fast-Scroller for a RecyclerView.

Stag improves Gson performance by automatically generating reflection-less TypeAdapters for your model objects.

A library with chart components.

Use this library to change colors of your vector drawables easily from your code.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes