-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Divide project in "imagesample" and "realtimesample"
- Loading branch information
Showing
80 changed files
with
728 additions
and
164 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
app/src/main/java/com/suaro/pidroidapp/camera/entity/Flash.kt
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#Thu Jan 21 20:28:18 CET 2021 | ||
#Wed Feb 24 21:16:13 CET 2021 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
.../suaro/pidroid/ExampleInstrumentedTest.kt → .../suaro/pidroid/ExampleInstrumentedTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
...ro/pidroidapp/capturer/view/CanvasView.kt → .../java/com/suaro/imagesample/CanvasView.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...uaro/pidroidapp/capturer/entity/Circle.kt → ...main/java/com/suaro/imagesample/Circle.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package com.suaro.pidroidapp.capturer.entity | ||
package com.suaro.imagesample | ||
|
||
import com.suaro.pidroid.core.Point | ||
|
||
|
93 changes: 93 additions & 0 deletions
93
imagesample/src/main/java/com/suaro/imagesample/ImageActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package com.suaro.imagesample | ||
|
||
import android.graphics.Bitmap | ||
import android.graphics.Rect | ||
import android.graphics.drawable.BitmapDrawable | ||
import android.os.Bundle | ||
import android.os.Handler | ||
import android.widget.ImageView | ||
import androidx.appcompat.app.AppCompatActivity | ||
import com.suaro.pidroid.Pidroid | ||
import com.suaro.pidroid.core.FaceDetectionResult | ||
import com.suaro.pidroid.core.PidroidConfig | ||
|
||
|
||
class ImageActivity : AppCompatActivity() { | ||
|
||
private lateinit var imageTest: ImageView | ||
private lateinit var canvasView: CanvasView | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_image) | ||
|
||
imageTest = findViewById(R.id.photo) | ||
canvasView = findViewById(R.id.canvas_view) | ||
setupNative() | ||
} | ||
|
||
private fun setupNative() { | ||
val pidroidConfig = PidroidConfig() | ||
Pidroid.setup(this, pidroidConfig) | ||
} | ||
|
||
override fun onPause() { | ||
super.onPause() | ||
} | ||
|
||
override fun onResume() { | ||
super.onResume() | ||
val handler: Handler = Handler(); | ||
|
||
handler.postDelayed({ | ||
val drawable: BitmapDrawable = imageTest.getDrawable() as BitmapDrawable | ||
val bitmap: Bitmap = drawable.bitmap | ||
canvasView.setAspectRatio(bitmap.width, bitmap.height) | ||
val dinfo = callDetectFace(bitmap) | ||
drawResult(dinfo) | ||
|
||
}, 1000) | ||
} | ||
|
||
override fun onDestroy() { | ||
super.onDestroy() | ||
} | ||
|
||
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 | ||
} | ||
|
||
fun drawResult(info: FaceDetectionResult) { | ||
canvasView.faces.clear() | ||
canvasView.eyes.clear() | ||
canvasView.landmarks.clear() | ||
|
||
if (info.detected) { | ||
for (face in info.faces) { | ||
val rect = Rect( | ||
face.topLeft.x, | ||
face.topLeft.y, | ||
face.topLeft.x + face.width, | ||
face.topLeft.y + face.height | ||
) | ||
canvasView.faces.add(rect) | ||
for (eye in face.eyes) { | ||
canvasView.eyes.add(Circle(eye.center, eye.radius)) | ||
} | ||
|
||
for (landmark in face.landmarks) { | ||
canvasView.landmarks.add(Circle(landmark.center, landmark.radius)) | ||
} | ||
} | ||
|
||
} | ||
|
||
canvasView.redraw() | ||
|
||
} | ||
|
||
} |
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<resources> | ||
<string name="app_name">PiDroid Image Sample</string> | ||
</resources> |
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...java/com/suaro/pidroid/ExampleUnitTest.kt → ...java/com/suaro/pidroid/ExampleUnitTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package com.suaro.pidroidapp | ||
package com.suaro.imagesample | ||
|
||
import org.junit.Test | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
plugins { | ||
id 'com.android.application' | ||
id 'kotlin-android' | ||
} | ||
|
||
android { | ||
signingConfigs { | ||
pidroid { | ||
keyAlias 'androiddebugkey' | ||
keyPassword 'android' | ||
storeFile file('/home/adrian/.android/debug.keystore') | ||
storePassword 'android' | ||
} | ||
} | ||
compileSdkVersion 30 | ||
buildToolsVersion "30.0.3" | ||
|
||
defaultConfig { | ||
applicationId "com.suaro.realtimesample" | ||
minSdkVersion 23 | ||
targetSdkVersion 30 | ||
versionCode 1 | ||
versionName "1.0" | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled true | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-build.pro' | ||
signingConfig signingConfigs.pidroid | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
kotlinOptions { | ||
jvmTarget = '1.8' | ||
} | ||
} | ||
|
||
dependencies { | ||
|
||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" | ||
implementation 'androidx.core:core-ktx:1.3.2' | ||
implementation 'androidx.appcompat:appcompat:1.2.0' | ||
implementation 'com.google.android.material:material:1.3.0' | ||
implementation project(path: ':pidroid') | ||
testImplementation 'junit:junit:4.+' | ||
androidTestImplementation 'androidx.test.ext:junit:1.1.2' | ||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' | ||
} |
Oops, something went wrong.