Skip to content

Commit

Permalink
Divide project in "imagesample" and "realtimesample"
Browse files Browse the repository at this point in the history
  • Loading branch information
Suaro committed Feb 24, 2021
1 parent 952f22d commit e4ab284
Show file tree
Hide file tree
Showing 80 changed files with 728 additions and 164 deletions.
94 changes: 0 additions & 94 deletions app/src/main/java/com/suaro/pidroidapp/ImageActivity.kt

This file was deleted.

5 changes: 0 additions & 5 deletions app/src/main/java/com/suaro/pidroidapp/camera/entity/Flash.kt

This file was deleted.

3 changes: 0 additions & 3 deletions app/src/main/res/values/strings.xml

This file was deleted.

4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
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.
4 changes: 2 additions & 2 deletions app/build.gradle → imagesample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ android {
buildToolsVersion "30.0.3"

defaultConfig {
applicationId "com.suaro.pidroidapp"
minSdkVersion 23
applicationId "com.suaro.imagesample"
minSdkVersion 16
targetSdkVersion 30
versionCode 1
versionName "1.0"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.suaro.pidroidapp
package com.suaro.imagesample

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.suaro.pidroidapp">
package="com.suaro.imagesample">
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera"
android:required="true" />
Expand All @@ -15,7 +15,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.PiDroid" >
<activity android:name="com.suaro.pidroidapp.ImageActivity"
<activity android:name="com.suaro.imagesample.ImageActivity"
android:configChanges="keyboardHidden|orientation"
android:screenOrientation="portrait">
<intent-filter>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package com.suaro.pidroidapp.capturer.view
package com.suaro.imagesample

import android.content.Context
import android.graphics.*
import android.util.AttributeSet
import android.view.View
import com.suaro.pidroidapp.capturer.entity.Circle
import com.suaro.pidroid.core.Point

class CanvasView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0): View(context, attrs, defStyleAttr) {
Expand Down
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

Expand Down
93 changes: 93 additions & 0 deletions imagesample/src/main/java/com/suaro/imagesample/ImageActivity.kt
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
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

</ImageView>

<FrameLayout
android:id="@+id/capturer_fragment"
<com.suaro.imagesample.CanvasView
android:id="@+id/canvas_view"
android:layout_width="0dp"
android:layout_height="0dp"
android:adjustViewBounds="true"
Expand All @@ -29,8 +29,7 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
>
</FrameLayout>
/>


</androidx.constraintlayout.widget.ConstraintLayout>
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions imagesample/src/main/res/values/strings.xml
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.
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

Expand Down
6 changes: 3 additions & 3 deletions pidroid/src/main/java/com/suaro/pidroid/core/PidroidConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ class PidroidConfig {
var minsize: Int = 150
var maxsize: Int = 1000

var angle: Float = 0f
// var angle: Float = 0f

var scalefactor: Float = 1.1f
var stridefactor: Float = 0.1f

var qthreshold: Float = 3.0f

var perturbs: Int = 63;
var perturbs: Int = 10;

var clustering: Boolean = true

var pupilDetectionEnable: Boolean = true
var landmarkDetectionEnable: Boolean = true

var prominentFaceOnly: Boolean = false
var prominentFaceOnly: Boolean = true
}
1 change: 1 addition & 0 deletions realtimesample/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
54 changes: 54 additions & 0 deletions realtimesample/build.gradle
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'
}
Loading

0 comments on commit e4ab284

Please sign in to comment.