-
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.
Add first version of face detection, landmarks and pupil detection.
- Loading branch information
Suaro
authored and
ADRIAN SUAREZ PARRA
committed
Feb 23, 2021
1 parent
f3322df
commit 8b7954e
Showing
106 changed files
with
4,085 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 |
---|---|---|
@@ -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,57 @@ | ||
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.pidroidapp" | ||
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.2.1' | ||
implementation 'androidx.constraintlayout:constraintlayout:2.0.4' | ||
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' | ||
} |
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,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
24 changes: 24 additions & 0 deletions
24
app/src/androidTest/java/com/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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.suaro.pidroidapp | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
|
||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
import org.junit.Assert.* | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* See [testing documentation](http://d.android.com/tools/testing). | ||
*/ | ||
@RunWith(AndroidJUnit4::class) | ||
class ExampleInstrumentedTest { | ||
@Test | ||
fun useAppContext() { | ||
// Context of the app under test. | ||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext | ||
assertEquals("com.suaro.pidroidapp", appContext.packageName) | ||
} | ||
} |
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,28 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.suaro.pidroidapp"> | ||
<uses-permission android:name="android.permission.CAMERA" /> | ||
<uses-feature android:name="android.hardware.camera" | ||
android:required="true" /> | ||
<permission android:name="android.permission.FLASHLIGHT" | ||
android:permissionGroup="android.permission-group.HARDWARE_CONTROLS" | ||
android:protectionLevel="normal" /> | ||
<uses-feature android:name="android.hardware.camera.flash" android:required="false" /> | ||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/Theme.PiDroid" > | ||
<activity android:name="com.suaro.pidroidapp.MainActivity" | ||
android:configChanges="keyboardHidden|orientation" | ||
android:screenOrientation="portrait"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
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,94 @@ | ||
package com.suaro.pidroidapp | ||
|
||
import android.content.res.AssetManager | ||
import android.graphics.Bitmap | ||
import android.graphics.drawable.BitmapDrawable | ||
import android.os.Bundle | ||
import android.os.Handler | ||
import android.util.Log | ||
import android.widget.FrameLayout | ||
import android.widget.ImageView | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.fragment.app.FragmentTransaction | ||
import com.suaro.pidroid.Pidroid | ||
import com.suaro.pidroid.core.PidroidConfig | ||
import com.suaro.pidroidapp.camera.Camera | ||
import com.suaro.pidroidapp.capturer.Capturer | ||
import com.suaro.pidroidapp.capturer.view.CapturerFragment | ||
import com.suaro.pidroidapp.core.CameraPreviewListener | ||
import java.util.* | ||
|
||
|
||
class ImageActivity : AppCompatActivity(), Camera.View, Capturer.View{ | ||
|
||
private lateinit var capturerLayout: FrameLayout | ||
private lateinit var imageTest: ImageView | ||
|
||
private lateinit var capturerFragment: CapturerFragment | ||
|
||
private var cameraPreviewListenerList: ArrayList<CameraPreviewListener>? = null | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(com.suaro.pidroidapp.R.layout.activity_image) | ||
|
||
capturerLayout = findViewById(R.id.capturer_fragment) | ||
imageTest = findViewById(R.id.photo) | ||
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(); | ||
onCameraStart() | ||
handler.postDelayed({ | ||
val drawable: BitmapDrawable = imageTest.getDrawable() as BitmapDrawable | ||
val bitmap: Bitmap = drawable.bitmap | ||
onPreviewFrame(bitmap) | ||
}, 1000) | ||
|
||
} | ||
|
||
override fun onDestroy() { | ||
super.onDestroy() | ||
} | ||
|
||
override fun onCameraStart() { | ||
loadCapturerFragment() | ||
} | ||
|
||
override fun onPreviewFrame(bitmap: Bitmap) { | ||
cameraPreviewListenerList!!.forEach { | ||
it.onPreviewFrame(bitmap) | ||
} | ||
} | ||
|
||
override fun onCapturerFinish() { | ||
Log.i("Capturer", "Finish") | ||
} | ||
|
||
|
||
fun loadCapturerFragment() { | ||
capturerFragment = CapturerFragment.newInstance(); | ||
val transaction: FragmentTransaction = supportFragmentManager.beginTransaction() | ||
transaction.replace(R.id.capturer_fragment, capturerFragment) | ||
transaction.commit() | ||
} | ||
|
||
fun addCameraPreviewListener(listener: CameraPreviewListener) { | ||
if (cameraPreviewListenerList == null) { | ||
cameraPreviewListenerList = ArrayList<CameraPreviewListener>() | ||
} | ||
cameraPreviewListenerList!!.add(listener) | ||
} | ||
} |
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,92 @@ | ||
package com.suaro.pidroidapp | ||
|
||
import android.content.res.AssetManager | ||
import android.graphics.Bitmap | ||
import android.os.Bundle | ||
import android.util.Log | ||
import android.widget.FrameLayout | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.fragment.app.FragmentTransaction | ||
import com.suaro.pidroid.Pidroid | ||
import com.suaro.pidroid.core.PidroidConfig | ||
import com.suaro.pidroidapp.camera.Camera | ||
import com.suaro.pidroidapp.camera.view.CameraFragment | ||
import com.suaro.pidroidapp.capturer.Capturer | ||
import com.suaro.pidroidapp.capturer.view.CapturerFragment | ||
import com.suaro.pidroidapp.core.CameraPreviewListener | ||
import java.util.* | ||
|
||
|
||
class MainActivity : AppCompatActivity(), Camera.View, Capturer.View{ | ||
|
||
private lateinit var capturerLayout: FrameLayout | ||
private lateinit var cameraLayout: FrameLayout | ||
|
||
private lateinit var capturerFragment: CapturerFragment | ||
private lateinit var cameraFragment: CameraFragment | ||
|
||
private var cameraPreviewListenerList: ArrayList<CameraPreviewListener>? = null | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_main) | ||
|
||
cameraLayout = findViewById(R.id.camera_fragment) | ||
capturerLayout = findViewById(R.id.capturer_fragment) | ||
|
||
setupNative() | ||
loadCameraFragment() | ||
} | ||
|
||
private fun setupNative() { | ||
val pidroidConfig = PidroidConfig() | ||
Pidroid.setup(this, pidroidConfig) | ||
} | ||
|
||
override fun onPause() { | ||
super.onPause() | ||
} | ||
|
||
override fun onResume() { | ||
super.onResume() | ||
} | ||
|
||
override fun onDestroy() { | ||
super.onDestroy() | ||
} | ||
|
||
override fun onCameraStart() { | ||
loadCapturerFragment() | ||
} | ||
|
||
override fun onPreviewFrame(bitmap: Bitmap) { | ||
cameraPreviewListenerList!!.forEach { | ||
it.onPreviewFrame(bitmap) | ||
} | ||
} | ||
|
||
override fun onCapturerFinish() { | ||
Log.i("Capturer", "Finish") | ||
} | ||
|
||
fun loadCameraFragment() { | ||
cameraFragment = CameraFragment.newInstance(); | ||
val transaction: FragmentTransaction = supportFragmentManager.beginTransaction() | ||
transaction.replace(R.id.camera_fragment, cameraFragment) | ||
transaction.commit() | ||
} | ||
|
||
fun loadCapturerFragment() { | ||
capturerFragment = CapturerFragment.newInstance(); | ||
val transaction: FragmentTransaction = supportFragmentManager.beginTransaction() | ||
transaction.replace(R.id.capturer_fragment, capturerFragment) | ||
transaction.commit() | ||
} | ||
|
||
fun addCameraPreviewListener(listener: CameraPreviewListener) { | ||
if (cameraPreviewListenerList == null) { | ||
cameraPreviewListenerList = ArrayList<CameraPreviewListener>() | ||
} | ||
cameraPreviewListenerList!!.add(listener) | ||
} | ||
} |
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,14 @@ | ||
package com.suaro.pidroidapp.camera | ||
|
||
import android.graphics.Bitmap | ||
|
||
interface Camera { | ||
interface View{ | ||
fun onCameraStart() | ||
fun onPreviewFrame(bitmap: Bitmap) | ||
} | ||
|
||
interface Presenter { | ||
|
||
} | ||
} |
Oops, something went wrong.