Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
Add Real time GIF.
Remove angle parameter.
  • Loading branch information
Suaro committed Feb 24, 2021
1 parent f0997c7 commit e07167c
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 3 deletions.
Binary file added .github/images/pidroid_real_time.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 Suaro
Copyright (c) 2021 Adrián Suárez Parra (Suaro)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
59 changes: 59 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,69 @@ Still in progress..

## Usage

### Basic usage

Pidroid library provides singleton object called "Pidroid". First, you need setup library in your Activity onCreate.

```kotlin
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(...)

// Do some stuff...

val pidroidConfig = PidroidConfig()
Pidroid.setup(this, pidroidConfig)
}
```

After setup finish, you can call detectFace function like this (example with Bitmap):

```kotlin
fun callDetectFace(bitmap: Bitmap): FaceDetectionResult {
val pixels = IntArray(bitmap.width * bitmap.height * 4)
bitmap.getPixels(pixels, 0, bitmap.width, 0, 0, bitmap.width, bitmap.height)
var dInfo = FaceDetectionResult()
Pidroid.detectFace(pixels, bitmap.width, bitmap.height, dInfo)
return dInfo
}

```

### Parameters

All configuration parameters are in PidroidConfig class.

| Parameter name | Description | Default value |
|------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------|
| minsize | Min radius of faces detected | 150 |
| maxsize | Max radius of faces detected | 1000 |
| prominentFaceOnly | Parameter that determines if you want to return only the most predominant face | False |
| clustering | This parameter groups detections to prevent a face from being detected multiple times | True |
| stridefactor | This parameter determines how many pixels the sliding window is moved to detect. For example, if the value is 0.1 and the image is 1000 pixels wide, the sliding window will move every 100 pixels. | 0.1 |
| scalefactor | The PICO algorithm searches for different face sizes starting from minsize to maxsize. This parameter determines how much the search size increases each iteration. | 1.1 |
| qthreshold | Minimum threshold to consider a region as a face. | 3.0 |
| perturbs | The detection of pupils and landmarks, start from an initial region to predict the exact position. This initial region is disturbed N times to increase the precision of detection. This also makes the method slower the larger this parameter grows. | 24 |
| pupilDetectionEnable | This parameter enable pupil detection | True |
| landmarkDetectionEnable | This parameter enable landmark detection. Its mandatory pupilDetectionEnable to True to detect landmarks. | True |

### Examples

In this project you will find two sample applications. The first is a simple application that performs the prediction on a bitmap and draws the result.
The second opens the camera and performs face, pupil and landmark detection in real time using a separate Thread so as not to block the UI.

README in construction... ;)


## Author

* Adrián Suárez Parra (https://linkedin.com/in/adriansp3)

## License
Copyright © 2021 Adrián Suárez Parra (Suaro)

This software is distributed under the MIT license. See the [LICENSE](https://github.com/Suaro/pidroid/blob/master/LICENSE) file for the full license text.

[forks-shield]: https://img.shields.io/github/forks/Suaro/pidroid.svg?style=for-the-badge
[forks-url]: https://github.com/Suaro/pidroid/network/members
[stars-shield]: https://img.shields.io/github/stars/Suaro/pidroid.svg?style=for-the-badge
Expand Down
5 changes: 3 additions & 2 deletions pidroid/src/main/cpp/pidroid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ int pidroidlib::Pidroid::loadClasses(JNIEnv *env) {
return -1;
}
jPidroidConfig.classRef = (jclass) env->NewGlobalRef(dCascadeClass);
jPidroidConfig.angle = env->GetFieldID(dCascadeClass, "angle", "F");
//jPidroidConfig.angle = env->GetFieldID(dCascadeClass, "angle", "F");
jPidroidConfig.maxsize = env->GetFieldID(dCascadeClass, "maxsize", "I");
jPidroidConfig.minsize = env->GetFieldID(dCascadeClass, "minsize", "I");
jPidroidConfig.perturbs = env->GetFieldID(dCascadeClass, "perturbs", "I");
Expand All @@ -243,7 +243,8 @@ pidroidlib::Pidroid::setup(JNIEnv *env, jobject thiz, jobject pidroidConfig, job
.maxSize = env->GetIntField(pidroidConfig, jPidroidConfig.maxsize),
.shiftFactor = env->GetFloatField(pidroidConfig, jPidroidConfig.stridefactor),
.scaleFactor = env->GetFloatField(pidroidConfig, jPidroidConfig.scalefactor),
.angle = env->GetFloatField(pidroidConfig, jPidroidConfig.angle),
//.angle = env->GetFloatField(pidroidConfig, jPidroidConfig.angle),
.angle = 0,
.minThreshold = env->GetFloatField(pidroidConfig, jPidroidConfig.qthreshold)
};

Expand Down

0 comments on commit e07167c

Please sign in to comment.