Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
a947bcc
integrated a faster OpenCV HAAR FD as new activity
aloruss1 Jul 17, 2018
d5d315b
Added two activity buttons in OpenCV based activity
aloruss1 Jul 18, 2018
e9c207f
Two buttons functionality in OpenCV activity, taking out not related …
aloruss1 Jul 18, 2018
8ec42f7
Fixed different frame size across OCV-FDT & OCV-SAMFDT activities
mdivietro Jul 30, 2018
43a8e82
OCV-SAMFDT_cleaned up code
mdivietro Jul 31, 2018
f72fd0b
OCV-FDT activity with MF tracker (no improvement)
mdivietro Aug 3, 2018
e485577
files to test OpenCV based activites
aloruss1 Aug 8, 2018
9eb5bde
Old activity speeded up (OCV-FDT, with MedianFlow tracker)
mdivietro Aug 9, 2018
0e95c08
Reduced updating time of MF tracker in OCV-FDT (improved speed)
mdivietro Aug 9, 2018
63ad9bf
update HAAR detection based tracker to return detected faces even whe…
aloruss1 Aug 10, 2018
781acb0
Further improvement of speed (OCV-FDT)
mdivietro Aug 21, 2018
11478f0
added tests for Google Vision activity
aloruss1 Aug 23, 2018
682bb58
Haar Detection in a separate thread
mdivietro Aug 24, 2018
4793c16
Detection and Tracking into separate threads
mdivietro Aug 28, 2018
d3b1ce5
Speeded up Detection (parallelized OCV_FDT)
mdivietro Aug 31, 2018
fc4e05a
merge of the complete OpenCV activities
aloruss1 Sep 3, 2018
9c8e894
Merge branch 'OCV-FDT_opencvTracking' into OCV-FDT
aloruss1 Sep 3, 2018
51fb86b
modified AS activity tests to test on TB-50 sequences from http://cvl…
aloruss1 Sep 10, 2018
1eac4a0
changes as requested by README file
aloruss1 Sep 20, 2018
7b5914b
merge of OpenCV and GMS activity test code into master
aloruss1 Sep 21, 2018
f5f7de7
modified link to jniLibs website in travis.yml and uncommented copy c…
aloruss1 Sep 21, 2018
531e34c
Update build.gradle
aloruss1 Sep 21, 2018
a0cf591
Update build.gradle
aloruss1 Sep 26, 2018
f9502cc
Update build.gradle
aloruss1 Sep 26, 2018
c4cb2fc
Update .travis.yml
aloruss1 Oct 5, 2018
f916491
Update .travis.yml
aloruss1 Oct 5, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ before_install:
- mkdir -p $ANDROID_HOME/licenses
- echo "8933bad161af4178b1185d1a37fbf41ea5269c55" > $ANDROID_HOME/licenses/android-sdk-license
- echo "d56f5187479451eabf01fb78af6dfcb131a6481e" >> $ANDROID_HOME/licenses/android-sdk-license
- sdkmanager --list || true
install:
- echo y | sdkmanager "ndk-bundle"
- echo y | sdkmanager "cmake;3.6.4111459"
- echo y | sdkmanager "lldb;3.1"
- sdkmanager --list || true


android:
components:
Expand All @@ -43,10 +46,11 @@ before_script:
# - export OPENCV_ANDROID_SDK=$(pwd)/OpenCV-android-sdk
- export OPENCV_ANDROID_SDK=$(pwd)/opencv3-android-sdk-with-contrib-master/OpenCV-android-sdk
#
- wget --no-check-certificate 'https://docs.google.com/uc?export=download&id=13ZlJvIRBpxydJcm64tS_czQm3e0SBwVu' -O jniLibss.zip
# - wget --no-check-certificate 'https://docs.google.com/uc?export=download&id=13ZlJvIRBpxydJcm64tS_czQm3e0SBwVu' -O jniLibss.zip
- wget --no-check-certificate 'http://www.webito.net/opencvlibs/openalprJniLibs.zip' -O jniLibss.zip
- unzip jniLibss.zip
- export OPENALPR_LIBS=$(pwd)/jniLibs

script:
- cd FaceTracker
- ./gradlew build
Expand Down
11 changes: 6 additions & 5 deletions FaceTracker/app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ include_directories($ENV{OPENCV_ANDROID_SDK}/sdk/native/jni/include)
add_library( lib_opencv SHARED IMPORTED )
set_target_properties(lib_opencv PROPERTIES IMPORTED_LOCATION $ENV{OPENCV_ANDROID_SDK}/sdk/native/libs/${ANDROID_ABI}/libopencv_java3.so)


find_library( # Sets the name of the path variable.
log-lib

Expand Down Expand Up @@ -53,6 +54,7 @@ add_library( # Sets the name of the library.
# file are automatically included.
src/main/cpp/native-lib.cpp )


target_link_libraries( # Specifies the target library.
native-lib

Expand All @@ -65,7 +67,6 @@ target_link_libraries( # Specifies the target library.
${log-lib} )



add_library( # Sets the name of the library.
OCV-native-lib

Expand All @@ -75,8 +76,8 @@ add_library( # Sets the name of the library.
# Provides a relative path to your source file(s).
# Associated headers in the same location as their source
# file are automatically included.
src/main/cpp/OCV-native-lib.cpp
)
src/main/cpp/OCV-native-lib.cpp )


target_link_libraries(
OCV-native-lib
Expand All @@ -85,6 +86,7 @@ target_link_libraries(

${log-lib} )


add_library( # Sets the name of the library.
OCV-DetectionBasedTracker

Expand All @@ -94,8 +96,7 @@ add_library( # Sets the name of the library.
# Provides a relative path to your source file(s).
# Associated headers in the same location as their source
# file are automatically included.
src/main/cpp/DetectionBasedTracker_jni.cpp
)
src/main/cpp/DetectionBasedTracker_jni.cpp )

target_link_libraries(
OCV-DetectionBasedTracker
Expand Down
13 changes: 7 additions & 6 deletions FaceTracker/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,19 @@ android {
externalNativeBuild {
cmake {
cppFlags "-frtti -fexceptions -std=c++11"
abiFilters 'x86_64', 'armeabi-v7a', 'arm64-v8a'
arguments "-DANDROID_STL=gnustl_shared"
// abiFilters 'x86_64', 'armeabi-v7a', 'arm64-v8a'
abiFilters 'armeabi-v7a'
arguments "-DANDROID_STL=c++_static"
}
}
signingConfig signingConfigs.config

// Specifies the application ID for the test APK.
testApplicationId "org.opencv.android.facetracker"
// testApplicationId "opencv.android.fdt"
// testApplicationId "org.opencv.android.facetracker"
// Specifies the fully-qualified class name of the test instrumentation runner.
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"


}


Expand Down Expand Up @@ -67,13 +68,13 @@ android {
jniLibs.srcDirs = [
'src/main/jniLibs']
resources.srcDirs=[
'src/main/resources', 'src/main/res/raw']}
'src/main/resources', 'src/main/res/raw']
}
androidTest { // AL (
java.srcDir file('src/androidTest/java')
resources.srcDir file('src/androidTest/assets')
} // AL )
}

configurations.all {
resolutionStrategy.force 'com.android.support:support-annotations:23.4.0'
}
Expand Down
4 changes: 2 additions & 2 deletions FaceTracker/app/jni/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ target_include_directories(tensorflow_detector PRIVATE

add_custom_command(TARGET tensorflow_detector POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
"$ENV{OPENALPR_LIBS}"
${CMAKE_SOURCE_DIR}/src/main/jniLibs)
"$ENV{OPENALPR_LIBS}"
${CMAKE_SOURCE_DIR}/src/main/jniLibs)

target_link_libraries(tensorflow_detector
android
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,32 +1,127 @@
package com.google.android.gms.samples.vision.face.facetracker;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Environment;
import android.support.test.InstrumentationRegistry;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.util.Log;

import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;

import android.util.SparseArray;
import com.google.android.gms.vision.Detector;
import com.google.android.gms.vision.face.FaceDetector;
import com.google.android.gms.vision.Frame;
import com.google.android.gms.vision.face.Face;

import static junit.framework.Assert.assertEquals;

@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {

private static final String TAG = "GMS-Test";
private Detector<Face> mDetector;
private String filename = "GMS-SolvayRes.png";
private String AppResPath = "/myAppRes/";

/*
@Test
public void useAppContext() throws Exception {
Log.i(TAG, "In useAppContext ");
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.google.android.gms.samples.vision.face.facetracker", appContext.getPackageName());
}


@Rule
public ActivityTestRule<FaceTrackerActivity> activityRule = new ActivityTestRule(FaceTrackerActivity.class);

@Test
public void callAddContext() {
Log.i(TAG, "In callAddContext ");
FaceTrackerActivity activity = activityRule.getActivity();
// int res = activity.nativeAdd(1,2);
// assertEquals(3, res);
// int res = activity.nativeAdd(1,2);
// assertEquals(3, res);
}
*/

@Test
public void gmsDetectionTest() throws IOException {

Context testContext = InstrumentationRegistry.getInstrumentation().getContext();
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext().getApplicationContext();

//InputStream testInput = testContext.getAssets().open("11.png");
InputStream testInput = testContext.getAssets().open("SolvayConf.jpg");
Bitmap bitmap = BitmapFactory.decodeStream(testInput);
Log.d(TAG, bitmap.getWidth() + " " + bitmap.getHeight());

FaceDetector mDetector = new FaceDetector.Builder(appContext) // using testContext didn't work
.setTrackingEnabled(true)
.setClassificationType(FaceDetector.NO_CLASSIFICATIONS)
.setProminentFaceOnly(false)
.setMode(FaceDetector.ACCURATE_MODE)
.setMinFaceSize(0.015f)
.build();

SparseArray<Face> faces = null;

if (!mDetector.isOperational()) {
Log.i(TAG, "Detector is NOT operational ");
} else {
Frame frame = new Frame.Builder().setBitmap(bitmap).build();
faces = mDetector.detect(frame);
mDetector.release();
Log.i(TAG, "GMS-TEST Number of faces = " + faces.size());
}

Bitmap mutableBitmap = bitmap.copy(Bitmap.Config.ARGB_8888, true);
Canvas canvas = new Canvas(mutableBitmap); // Create a canvas instance pointing to the bitmap

Paint paint = new Paint();
paint.setColor(Color.RED);
paint.setStrokeWidth(5.0f);
paint.setStyle(Paint.Style.STROKE);

// all that is drawn on canvas it is also on the bitmap
for(int i=0; i < faces.size(); i++){
int key = faces.keyAt(i);
Face face = faces.get(key); // get object by the key
// Face face = mFaces.get(i);

canvas.drawRect(face.getPosition().x, face.getPosition().y,
face.getPosition().x + face.getWidth(),
face.getPosition().y + face.getHeight(), paint);
}

try {
// get SD Card dir
String SDCardPath = Environment.getExternalStorageDirectory().toString();
new File(SDCardPath + AppResPath).mkdirs();
File imageFile = new File(SDCardPath + AppResPath + filename);
Log.i(TAG,"file= " + imageFile);

FileOutputStream outStream = new FileOutputStream(imageFile);
// compress BitMap and write image to the OutputStream
mutableBitmap.compress(Bitmap.CompressFormat.PNG, 80, outStream); // 100 = full quality

outStream.flush();
outStream.close();

} catch (Exception e) {
e.printStackTrace();
}
}
}
Loading