This is Android lib to help all projects can easy integrate Camera with face detection feature.
- Maven repository: jCenter
- Group: com.github.bonnguyen
- Artifact ID: camerafacedetection
- Only supported take one picture for one time
- Display the result on screen
Release versions are available from jCenter repository, so just add the "compile..." statement to your project. For snapshots, please add our bintray snapshots repository url first: https://dl.bintray.com/bonnguyen/maven
repositories{
maven {
url 'https://dl.bintray.com/bonnguyen/maven'
}
}
And put it in App dependencies:
dependencies {
...
compile 'com.github.bonnguyen:camerafacedetection:1.0.0'
...
}
Easy to integrate with your project. In your XML layout, you can put the FaceDetectionView
<com.bonnguyen.camerafacedetection.FaceDetectionView
android:id="@+id/ivPhoto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/ic_no_photo" />
In Java code
ivPhoto = (FaceDetectionView) findViewById(R.id.ivPhoto);
ivPhoto.setOnClickListener(this);
....
@Override
public void onClick(View view) {
if (view == ivPhoto) {
Intent intent = new Intent(this, AndroidCameraActivity.class);
startActivityForResult(intent, REQUEST_CAMERA);
}
}
And get the result after take:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
if (requestCode == REQUEST_CAMERA && data.hasExtra("url")) {
String photoPath = data.getStringExtra("url");
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
Bitmap bitmap = BitmapFactory.decodeFile(photoPath, options);
ivPhoto.setImageBitmap(bitmap);
}
}
}
Any ideas/bugs/etc, as well as pull requests, are welcome in the issues section.
Bon Nguyen - nguyennhatbon07t1@gmail.com
The MIT License (MIT)
Copyright (c) 2016 Bon Nguyen.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.