diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bdb51de --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +../.idea/ +Camera2/.gradle/ +.idea/ +app/build/ +build/ \ No newline at end of file diff --git a/Camera2/Camera2.iml b/Camera2/Camera2.iml index 605036e..15df989 100644 --- a/Camera2/Camera2.iml +++ b/Camera2/Camera2.iml @@ -13,7 +13,7 @@ - + \ No newline at end of file diff --git a/Camera2/app/app.iml b/Camera2/app/app.iml index 7b05e1b..55df901 100644 --- a/Camera2/app/app.iml +++ b/Camera2/app/app.iml @@ -22,25 +22,26 @@ - - - + + + - + + - - + + - + @@ -55,6 +56,13 @@ + + + + + + + @@ -62,13 +70,6 @@ - - - - - - - @@ -76,59 +77,105 @@ - + + + + + + + + + + - + + + + - + - + + + + - + + + + + + - + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Camera2/app/build.gradle b/Camera2/app/build.gradle index 6e42be3..e78febf 100644 --- a/Camera2/app/build.gradle +++ b/Camera2/app/build.gradle @@ -1,12 +1,12 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 25 - buildToolsVersion "25.0.2" + compileSdkVersion 28 + buildToolsVersion "28.0.3" defaultConfig { applicationId "com.example.ezequiel.camera2" minSdkVersion 16 - targetSdkVersion 25 + targetSdkVersion 28 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" @@ -20,11 +20,12 @@ android { } dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) - androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { + implementation fileTree(dir: 'libs', include: ['*.jar']) + androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.2', { exclude group: 'com.android.support', module: 'support-annotations' }) - compile 'com.android.support:appcompat-v7:25.3.0' - compile 'com.google.android.gms:play-services-vision:10.2.0' - testCompile 'junit:junit:4.12' + implementation 'com.android.support:appcompat-v7:28.0.0' + implementation 'com.android.support:support-v4:28.0.0' + implementation 'com.google.android.gms:play-services-vision:17.0.2' + testImplementation 'junit:junit:4.12' } diff --git a/Camera2/app/src/main/java/com/example/ezequiel/camera2/MainActivity.java b/Camera2/app/src/main/java/com/example/ezequiel/camera2/MainActivity.java index 74d7264..5c5d33a 100644 --- a/Camera2/app/src/main/java/com/example/ezequiel/camera2/MainActivity.java +++ b/Camera2/app/src/main/java/com/example/ezequiel/camera2/MainActivity.java @@ -81,13 +81,13 @@ protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.activity_main); context = getApplicationContext(); - takePictureButton = (Button) findViewById(R.id.btn_takepicture); - switchButton = (Button) findViewById(R.id.btn_switch); - videoButton = (Button) findViewById(R.id.btn_video); - mPreview = (CameraSourcePreview) findViewById(R.id.preview); - mGraphicOverlay = (GraphicOverlay) findViewById(R.id.faceOverlay); - cameraVersion = (TextView) findViewById(R.id.cameraVersion); - ivAutoFocus = (ImageView) findViewById(R.id.ivAutoFocus); + takePictureButton = findViewById(R.id.btn_takepicture); + switchButton = findViewById(R.id.btn_switch); + videoButton = findViewById(R.id.btn_video); + mPreview = findViewById(R.id.preview); + mGraphicOverlay = findViewById(R.id.faceOverlay); + cameraVersion = findViewById(R.id.cameraVersion); + ivAutoFocus = findViewById(R.id.ivAutoFocus); if(checkGooglePlayAvailability()) { requestPermissionThenOpenCamera(); @@ -151,7 +151,7 @@ public void onClick(View v) { final CameraSource.PictureCallback cameraSourcePictureCallback = new CameraSource.PictureCallback() { @Override public void onPictureTaken(Bitmap picture) { - Log.d(TAG, "Taken picture is here!"); + Log.d(TAG, "Picture is taken here!"); runOnUiThread(new Runnable() { @Override public void run() { @@ -280,7 +280,7 @@ public void run() { @TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public void onPictureTaken(Image image) { - Log.d(TAG, "Taken picture is here!"); + Log.d(TAG, "Picture is taken here!"); runOnUiThread(new Runnable() { @Override public void run() { diff --git a/Camera2/app/src/main/java/com/example/ezequiel/camera2/others/Camera2Source.java b/Camera2/app/src/main/java/com/example/ezequiel/camera2/others/Camera2Source.java index 7bbebc1..f8dcda2 100644 --- a/Camera2/app/src/main/java/com/example/ezequiel/camera2/others/Camera2Source.java +++ b/Camera2/app/src/main/java/com/example/ezequiel/camera2/others/Camera2Source.java @@ -32,7 +32,6 @@ import android.os.Handler; import android.os.HandlerThread; import android.os.SystemClock; -import android.support.annotation.IntDef; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.RequiresPermission; @@ -41,7 +40,6 @@ import android.util.SparseIntArray; import android.view.MotionEvent; import android.view.Surface; -import android.widget.Toast; import com.example.ezequiel.camera2.utils.Utils; import com.google.android.gms.common.images.Size; @@ -50,8 +48,6 @@ import java.io.IOException; import java.lang.Thread.State; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; import java.nio.ByteBuffer; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -1443,7 +1439,9 @@ private class PictureDoneCallback implements ImageReader.OnImageAvailableListene @Override public void onImageAvailable(ImageReader reader) { if(mDelegate != null) { - mDelegate.onPictureTaken(reader.acquireNextImage()); + Image img = reader.acquireNextImage(); + mDelegate.onPictureTaken(img); + img.close(); } } diff --git a/Camera2/app/src/main/java/com/example/ezequiel/camera2/others/FaceGraphic.java b/Camera2/app/src/main/java/com/example/ezequiel/camera2/others/FaceGraphic.java index 53d50fe..76007fd 100644 --- a/Camera2/app/src/main/java/com/example/ezequiel/camera2/others/FaceGraphic.java +++ b/Camera2/app/src/main/java/com/example/ezequiel/camera2/others/FaceGraphic.java @@ -15,7 +15,6 @@ import android.graphics.PorterDuff; import com.example.ezequiel.camera2.R; -import com.example.ezequiel.camera2.others.GraphicOverlay; import com.google.android.gms.vision.face.Face; import com.google.android.gms.vision.face.Landmark; @@ -30,27 +29,27 @@ public class FaceGraphic extends GraphicOverlay.Graphic { private Resources resources; private int faceId; - PointF facePosition; - float faceWidth; - float faceHeight; - PointF faceCenter; - float isSmilingProbability = -1; - float eyeRightOpenProbability = -1; - float eyeLeftOpenProbability = -1; - float eulerZ; - float eulerY; - PointF leftEyePos = null; - PointF rightEyePos = null; - PointF noseBasePos = null; - PointF leftMouthCorner = null; - PointF rightMouthCorner = null; - PointF mouthBase = null; - PointF leftEar = null; - PointF rightEar = null; - PointF leftEarTip = null; - PointF rightEarTip = null; - PointF leftCheek = null; - PointF rightCheek = null; + private PointF facePosition; + private float faceWidth; + private float faceHeight; + private PointF faceCenter; + private float isSmilingProbability = -1; + private float eyeRightOpenProbability = -1; + private float eyeLeftOpenProbability = -1; + private float eulerZ; + private float eulerY; + private PointF leftEyePos = null; + private PointF rightEyePos = null; + private PointF noseBasePos = null; + private PointF leftMouthCorner = null; + private PointF rightMouthCorner = null; + private PointF mouthBase = null; + private PointF leftEar = null; + private PointF rightEar = null; + private PointF leftEarTip = null; + private PointF rightEarTip = null; + private PointF leftCheek = null; + private PointF rightCheek = null; private volatile Face mFace; diff --git a/Camera2/app/src/main/java/com/example/ezequiel/camera2/utils/Utils.java b/Camera2/app/src/main/java/com/example/ezequiel/camera2/utils/Utils.java index 57e256d..0b0c7b6 100644 --- a/Camera2/app/src/main/java/com/example/ezequiel/camera2/utils/Utils.java +++ b/Camera2/app/src/main/java/com/example/ezequiel/camera2/utils/Utils.java @@ -14,8 +14,6 @@ import com.google.android.gms.common.images.Size; -import java.util.ArrayList; - public class Utils { public static int dpToPx(int dp) { diff --git a/Camera2/build.gradle b/Camera2/build.gradle index 6514a0b..771004f 100644 --- a/Camera2/build.gradle +++ b/Camera2/build.gradle @@ -3,9 +3,13 @@ buildscript { repositories { jcenter() + maven { + url 'https://maven.google.com/' + name 'Google' + } } dependencies { - classpath 'com.android.tools.build:gradle:2.3.3' + classpath 'com.android.tools.build:gradle:3.2.1' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files @@ -15,6 +19,10 @@ buildscript { allprojects { repositories { jcenter() + maven { + url 'https://maven.google.com/' + name 'Google' + } } } diff --git a/Camera2/gradle/wrapper/gradle-wrapper.properties b/Camera2/gradle/wrapper/gradle-wrapper.properties index 9827544..fa0b03b 100644 --- a/Camera2/gradle/wrapper/gradle-wrapper.properties +++ b/Camera2/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Tue Mar 21 12:45:03 ART 2017 +#Thu Dec 20 16:19:16 CST 2018 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip diff --git a/Camera2/local.properties b/Camera2/local.properties index 51960e9..912b503 100644 --- a/Camera2/local.properties +++ b/Camera2/local.properties @@ -1,12 +1,8 @@ -## This file is automatically generated by Android Studio. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must *NOT* be checked into Version Control Systems, -# as it contains information specific to your local configuration. -# -# Location of the SDK. This is only used by Gradle. -# For customization when using a Version Control System, please read the -# header note. -#Fri Feb 24 18:50:43 ART 2017 -ndk.dir=C\:\\Users\\Ezequiel\\AppData\\Local\\Android\\Sdk\\ndk-bundle -sdk.dir=C\:\\Users\\Ezequiel\\AppData\\Local\\Android\\Sdk +## This file must *NOT* be checked into Version Control Systems, +# as it contains information specific to your local configuration. +# +# Location of the SDK. This is only used by Gradle. +# For customization when using a Version Control System, please read the +# header note. +#Thu Dec 20 15:56:11 CST 2018 +sdk.dir=/Users/stephenakers/Library/Android/sdk