├── android-studio-root
├── .idea
│ ├── .name
│ ├── copyright
│ │ └── profiles_settings.xml
│ ├── scopes
│ │ └── scope_settings.xml
│ ├── encodings.xml
│ ├── vcs.xml
│ ├── compiler.xml
│ ├── gradle.xml
│ ├── modules.xml
│ └── misc.xml
├── app
│ ├── .gitignore
│ ├── src
│ │ ├── main
│ │ │ ├── res
│ │ │ │ ├── values
│ │ │ │ │ ├── strings.xml
│ │ │ │ │ └── styles.xml
│ │ │ │ ├── drawable-hdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ ├── drawable-mdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ ├── drawable-xhdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ └── drawable-xxhdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ └── AndroidManifest.xml
│ │ └── androidTest
│ │ │ └── java
│ │ │ └── cs
│ │ │ └── cmu
│ │ │ └── edu
│ │ │ └── diamondandroid
│ │ │ └── ApplicationTest.java
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── app.iml
├── performance
│ ├── .gitignore
│ ├── jni
│ ├── add-filters-to-res.sh
│ ├── src
│ │ └── main
│ │ │ ├── res
│ │ │ ├── values
│ │ │ │ └── strings.xml
│ │ │ ├── drawable-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── drawable-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── drawable-xhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── drawable-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ └── layout
│ │ │ │ └── activity_main.xml
│ │ │ ├── AndroidManifest.xml
│ │ │ └── java
│ │ │ └── edu
│ │ │ └── cmu
│ │ │ └── cs
│ │ │ └── diamond
│ │ │ └── android
│ │ │ └── performance
│ │ │ └── MainActivity.java
│ ├── proguard-rules.pro
│ ├── build.gradle
│ ├── performance.iml
│ └── facerecognition.iml
├── facerecognition
│ ├── .gitignore
│ ├── src
│ │ └── main
│ │ │ ├── res
│ │ │ ├── drawable-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── drawable-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── drawable-xhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── drawable-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── values
│ │ │ │ └── strings.xml
│ │ │ └── layout
│ │ │ │ └── activity_main.xml
│ │ │ ├── java
│ │ │ └── edu
│ │ │ │ └── cmu
│ │ │ │ └── cs
│ │ │ │ └── diamond
│ │ │ │ └── android
│ │ │ │ └── examples
│ │ │ │ └── facialrecognition
│ │ │ │ ├── Const.java
│ │ │ │ ├── CameraPreview.java
│ │ │ │ └── MainActivity.java
│ │ │ └── AndroidManifest.xml
│ ├── jni
│ │ ├── .gitignore
│ │ ├── build-modifications
│ │ │ ├── diamond-core-filters
│ │ │ │ ├── filters
│ │ │ │ │ ├── rgbimg
│ │ │ │ │ │ └── Android.mk
│ │ │ │ │ ├── img_diff
│ │ │ │ │ │ └── Android.mk
│ │ │ │ │ ├── null
│ │ │ │ │ │ └── Android.mk
│ │ │ │ │ ├── num_attr
│ │ │ │ │ │ └── Android.mk
│ │ │ │ │ ├── thumbnailer
│ │ │ │ │ │ └── Android.mk
│ │ │ │ │ ├── shingling
│ │ │ │ │ │ └── Android.mk
│ │ │ │ │ ├── text_attr
│ │ │ │ │ │ └── Android.mk
│ │ │ │ │ ├── ocv_face
│ │ │ │ │ │ └── Android.mk
│ │ │ │ │ ├── dog_texture
│ │ │ │ │ │ └── Android.mk
│ │ │ │ │ ├── rgb_histogram
│ │ │ │ │ │ └── Android.mk
│ │ │ │ │ ├── perceptual_hash
│ │ │ │ │ │ └── Android.mk
│ │ │ │ │ ├── gabor_texture
│ │ │ │ │ │ └── Android.mk
│ │ │ │ │ └── base.mk
│ │ │ │ └── lib
│ │ │ │ │ ├── memstream.h
│ │ │ │ │ ├── getline.h
│ │ │ │ │ ├── index.html
│ │ │ │ │ ├── Android.mk
│ │ │ │ │ ├── fmemopen.h
│ │ │ │ │ ├── fmemopen.c
│ │ │ │ │ ├── getline.c
│ │ │ │ │ └── memstream.c
│ │ │ ├── archive-util.c.diff
│ │ │ └── libfilter-Android.mk
│ │ └── build.sh
│ ├── proguard-rules.pro
│ ├── build.gradle
│ ├── add-filters-to-res.sh
│ └── facerecognition.iml
├── diamondandroidlibrary
│ ├── .gitignore
│ ├── src
│ │ └── main
│ │ │ ├── res
│ │ │ ├── values
│ │ │ │ └── strings.xml
│ │ │ ├── drawable-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── drawable-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── drawable-xhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ └── drawable-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── AndroidManifest.xml
│ │ │ └── java
│ │ │ └── edu
│ │ │ └── cmu
│ │ │ └── cs
│ │ │ └── diamond
│ │ │ └── android
│ │ │ ├── FilterException.java
│ │ │ ├── token
│ │ │ ├── Token.java
│ │ │ ├── GetToken.java
│ │ │ ├── OmitToken.java
│ │ │ ├── ResultToken.java
│ │ │ ├── SetToken.java
│ │ │ └── LogToken.java
│ │ │ ├── TagEnum.java
│ │ │ └── Filter.java
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── diamondandroidlibrary.iml
├── settings.gradle
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── .gitignore
├── build.gradle
├── gradle.properties
├── android-studio-root.iml
├── diamond-android-new.iml
├── gradlew.bat
└── gradlew
├── attic
├── diamond-android-library
│ ├── .gitignore
│ ├── ic_launcher-web.png
│ ├── libs
│ │ ├── commons-io-2.4.jar
│ │ └── android-support-v4.jar
│ ├── res
│ │ ├── drawable-hdpi
│ │ │ └── ic_launcher.png
│ │ ├── drawable-mdpi
│ │ │ └── ic_launcher.png
│ │ ├── drawable-xhdpi
│ │ │ └── ic_launcher.png
│ │ ├── drawable-xxhdpi
│ │ │ └── ic_launcher.png
│ │ ├── values
│ │ │ └── strings.xml
│ │ └── layout
│ │ │ └── activity_main.xml
│ ├── .settings
│ │ └── org.eclipse.jdt.core.prefs
│ ├── .classpath
│ ├── project.properties
│ ├── src
│ │ └── edu
│ │ │ └── cmu
│ │ │ └── cs
│ │ │ └── diamond
│ │ │ └── android
│ │ │ ├── FilterException.java
│ │ │ ├── token
│ │ │ ├── Token.java
│ │ │ ├── GetToken.java
│ │ │ ├── OmitToken.java
│ │ │ ├── ResultToken.java
│ │ │ ├── SetToken.java
│ │ │ └── LogToken.java
│ │ │ ├── TagEnum.java
│ │ │ └── Filter.java
│ ├── compile-install-run-log.sh
│ ├── proguard-project.txt
│ ├── .project
│ ├── AndroidManifest.xml
│ ├── add-filters-to-res.sh
│ └── build.xml
└── examples
│ └── face-detection
│ ├── .gitignore
│ ├── ic_launcher-web.png
│ ├── libs
│ ├── commons-io-2.4.jar
│ └── android-support-v4.jar
│ ├── res
│ ├── drawable-hdpi
│ │ └── ic_launcher.png
│ ├── drawable-mdpi
│ │ └── ic_launcher.png
│ ├── drawable-xhdpi
│ │ └── ic_launcher.png
│ ├── drawable-xxhdpi
│ │ └── ic_launcher.png
│ ├── values
│ │ └── strings.xml
│ └── layout
│ │ └── activity_main.xml
│ ├── .settings
│ └── org.eclipse.jdt.core.prefs
│ ├── src
│ └── edu
│ │ └── cmu
│ │ └── cs
│ │ └── diamond
│ │ └── android
│ │ └── examples
│ │ └── facialrecognition
│ │ ├── Const.java
│ │ ├── CameraPreview.java
│ │ └── MainActivity.java
│ ├── .classpath
│ ├── project.properties
│ ├── proguard-project.txt
│ ├── .project
│ ├── AndroidManifest.xml
│ └── build.xml
├── images
├── overview.ai
├── overview.png
└── face-detection-example.png
└── LICENSE
/android-studio-root/.idea/.name:
--------------------------------------------------------------------------------
1 | Diamond Android
--------------------------------------------------------------------------------
/android-studio-root/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/android-studio-root/performance/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/android-studio-root/facerecognition/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/android-studio-root/performance/jni:
--------------------------------------------------------------------------------
1 | ../facerecognition/jni
--------------------------------------------------------------------------------
/android-studio-root/diamondandroidlibrary/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/android-studio-root/performance/add-filters-to-res.sh:
--------------------------------------------------------------------------------
1 | ../facerecognition/add-filters-to-res.sh
--------------------------------------------------------------------------------
/attic/diamond-android-library/.gitignore:
--------------------------------------------------------------------------------
1 | bin
2 | *.log
3 | local.properties
4 | res/raw
5 | gen
6 |
--------------------------------------------------------------------------------
/attic/examples/face-detection/.gitignore:
--------------------------------------------------------------------------------
1 | bin
2 | *.log
3 | local.properties
4 | res/raw
5 | gen
6 |
--------------------------------------------------------------------------------
/images/overview.ai:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmusatyalab/diamond-android/HEAD/images/overview.ai
--------------------------------------------------------------------------------
/images/overview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmusatyalab/diamond-android/HEAD/images/overview.png
--------------------------------------------------------------------------------
/android-studio-root/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':diamondandroidlibrary', ':facerecognition', ':performance'
2 |
--------------------------------------------------------------------------------
/images/face-detection-example.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmusatyalab/diamond-android/HEAD/images/face-detection-example.png
--------------------------------------------------------------------------------
/android-studio-root/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/android-studio-root/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Diamond Android
3 |
4 |
--------------------------------------------------------------------------------
/attic/diamond-android-library/ic_launcher-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmusatyalab/diamond-android/HEAD/attic/diamond-android-library/ic_launcher-web.png
--------------------------------------------------------------------------------
/attic/examples/face-detection/ic_launcher-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmusatyalab/diamond-android/HEAD/attic/examples/face-detection/ic_launcher-web.png
--------------------------------------------------------------------------------
/android-studio-root/diamondandroidlibrary/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | DiamondAndroidLibrary
3 |
4 |
--------------------------------------------------------------------------------
/android-studio-root/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmusatyalab/diamond-android/HEAD/android-studio-root/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/attic/diamond-android-library/libs/commons-io-2.4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmusatyalab/diamond-android/HEAD/attic/diamond-android-library/libs/commons-io-2.4.jar
--------------------------------------------------------------------------------
/attic/examples/face-detection/libs/commons-io-2.4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmusatyalab/diamond-android/HEAD/attic/examples/face-detection/libs/commons-io-2.4.jar
--------------------------------------------------------------------------------
/attic/diamond-android-library/libs/android-support-v4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmusatyalab/diamond-android/HEAD/attic/diamond-android-library/libs/android-support-v4.jar
--------------------------------------------------------------------------------
/attic/examples/face-detection/libs/android-support-v4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmusatyalab/diamond-android/HEAD/attic/examples/face-detection/libs/android-support-v4.jar
--------------------------------------------------------------------------------
/attic/diamond-android-library/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmusatyalab/diamond-android/HEAD/attic/diamond-android-library/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/attic/diamond-android-library/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmusatyalab/diamond-android/HEAD/attic/diamond-android-library/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/attic/diamond-android-library/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmusatyalab/diamond-android/HEAD/attic/diamond-android-library/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/attic/diamond-android-library/res/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmusatyalab/diamond-android/HEAD/attic/diamond-android-library/res/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/attic/examples/face-detection/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmusatyalab/diamond-android/HEAD/attic/examples/face-detection/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/attic/examples/face-detection/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmusatyalab/diamond-android/HEAD/attic/examples/face-detection/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/attic/examples/face-detection/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmusatyalab/diamond-android/HEAD/attic/examples/face-detection/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/attic/examples/face-detection/res/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmusatyalab/diamond-android/HEAD/attic/examples/face-detection/res/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android-studio-root/app/src/main/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmusatyalab/diamond-android/HEAD/android-studio-root/app/src/main/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android-studio-root/app/src/main/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmusatyalab/diamond-android/HEAD/android-studio-root/app/src/main/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android-studio-root/app/src/main/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmusatyalab/diamond-android/HEAD/android-studio-root/app/src/main/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android-studio-root/app/src/main/res/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmusatyalab/diamond-android/HEAD/android-studio-root/app/src/main/res/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android-studio-root/.idea/scopes/scope_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/android-studio-root/performance/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | DiamondDroid_Performance
4 |
5 |
--------------------------------------------------------------------------------
/android-studio-root/performance/src/main/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmusatyalab/diamond-android/HEAD/android-studio-root/performance/src/main/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android-studio-root/performance/src/main/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmusatyalab/diamond-android/HEAD/android-studio-root/performance/src/main/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android-studio-root/performance/src/main/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmusatyalab/diamond-android/HEAD/android-studio-root/performance/src/main/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android-studio-root/performance/src/main/res/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmusatyalab/diamond-android/HEAD/android-studio-root/performance/src/main/res/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android-studio-root/facerecognition/src/main/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmusatyalab/diamond-android/HEAD/android-studio-root/facerecognition/src/main/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android-studio-root/facerecognition/src/main/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmusatyalab/diamond-android/HEAD/android-studio-root/facerecognition/src/main/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android-studio-root/facerecognition/src/main/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmusatyalab/diamond-android/HEAD/android-studio-root/facerecognition/src/main/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android-studio-root/facerecognition/src/main/res/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmusatyalab/diamond-android/HEAD/android-studio-root/facerecognition/src/main/res/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android-studio-root/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/android-studio-root/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/android-studio-root/diamondandroidlibrary/src/main/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmusatyalab/diamond-android/HEAD/android-studio-root/diamondandroidlibrary/src/main/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android-studio-root/diamondandroidlibrary/src/main/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmusatyalab/diamond-android/HEAD/android-studio-root/diamondandroidlibrary/src/main/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android-studio-root/diamondandroidlibrary/src/main/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmusatyalab/diamond-android/HEAD/android-studio-root/diamondandroidlibrary/src/main/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android-studio-root/diamondandroidlibrary/src/main/res/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmusatyalab/diamond-android/HEAD/android-studio-root/diamondandroidlibrary/src/main/res/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android-studio-root/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | /local.properties
3 | /.idea/workspace.xml
4 | /.idea/libraries
5 | .DS_Store
6 | /build
7 |
8 | # Diamond Android filters
9 | facerecognition/src/main/res/raw
10 | performance/src/main/res/raw
11 |
--------------------------------------------------------------------------------
/attic/diamond-android-library/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | DiamondDroid
5 | Hello world!
6 |
7 |
8 |
--------------------------------------------------------------------------------
/attic/diamond-android-library/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
3 | org.eclipse.jdt.core.compiler.compliance=1.6
4 | org.eclipse.jdt.core.compiler.source=1.6
5 |
--------------------------------------------------------------------------------
/attic/examples/face-detection/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
3 | org.eclipse.jdt.core.compiler.compliance=1.6
4 | org.eclipse.jdt.core.compiler.source=1.6
5 |
--------------------------------------------------------------------------------
/android-studio-root/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/android-studio-root/facerecognition/jni/.gitignore:
--------------------------------------------------------------------------------
1 | *.tar.gz
2 | obj
3 | toolchain
4 | OpenCV-2.4.9-android-sdk/
5 | diamond-core-filters/
6 | glib/
7 | libarchive-3.1.2/
8 | libjpeg-turbo-1.3.1/
9 | libpng-1.6.15/
10 | opendiamond/
11 | tiff-4.0.3/
12 | zlib-1.2.8/
13 |
--------------------------------------------------------------------------------
/android-studio-root/facerecognition/jni/build-modifications/diamond-core-filters/filters/rgbimg/Android.mk:
--------------------------------------------------------------------------------
1 | LOCAL_PATH := $(call my-dir)
2 | include $(CLEAR_VARS)
3 | include ../base.mk
4 | LOCAL_SRC_FILES := fil_rgb.c
5 | LOCAL_MODULE := rgbimg
6 | include $(BUILD_EXECUTABLE)
7 |
--------------------------------------------------------------------------------
/android-studio-root/facerecognition/jni/build-modifications/diamond-core-filters/filters/img_diff/Android.mk:
--------------------------------------------------------------------------------
1 | LOCAL_PATH := $(call my-dir)
2 | include $(CLEAR_VARS)
3 | include ../base.mk
4 | LOCAL_SRC_FILES := fil_img_diff.c
5 | LOCAL_MODULE := img_diff
6 | include $(BUILD_EXECUTABLE)
7 |
--------------------------------------------------------------------------------
/android-studio-root/facerecognition/jni/build-modifications/diamond-core-filters/filters/null/Android.mk:
--------------------------------------------------------------------------------
1 | LOCAL_PATH := $(call my-dir)
2 | include $(CLEAR_VARS)
3 | include ../base.mk
4 | LOCAL_SRC_FILES := fil_null.c image.c
5 | LOCAL_MODULE := null_filter
6 | include $(BUILD_EXECUTABLE)
7 |
--------------------------------------------------------------------------------
/android-studio-root/facerecognition/jni/build-modifications/diamond-core-filters/filters/num_attr/Android.mk:
--------------------------------------------------------------------------------
1 | LOCAL_PATH := $(call my-dir)
2 | include $(CLEAR_VARS)
3 | include ../base.mk
4 | LOCAL_SRC_FILES := fil_num_attr.c
5 | LOCAL_MODULE := num_attr
6 | include $(BUILD_EXECUTABLE)
7 |
--------------------------------------------------------------------------------
/android-studio-root/facerecognition/jni/build-modifications/diamond-core-filters/filters/thumbnailer/Android.mk:
--------------------------------------------------------------------------------
1 | LOCAL_PATH := $(call my-dir)
2 | include $(CLEAR_VARS)
3 | include ../base.mk
4 | LOCAL_SRC_FILES := fil_thumb.c
5 | LOCAL_MODULE := thumbnailer
6 | include $(BUILD_EXECUTABLE)
7 |
--------------------------------------------------------------------------------
/android-studio-root/facerecognition/jni/build-modifications/diamond-core-filters/filters/shingling/Android.mk:
--------------------------------------------------------------------------------
1 | LOCAL_PATH := $(call my-dir)
2 | include $(CLEAR_VARS)
3 | include ../base.mk
4 | LOCAL_SRC_FILES := fil_shingling.c rabin.c
5 | LOCAL_MODULE := shingling
6 | include $(BUILD_EXECUTABLE)
7 |
--------------------------------------------------------------------------------
/android-studio-root/facerecognition/jni/build-modifications/diamond-core-filters/filters/text_attr/Android.mk:
--------------------------------------------------------------------------------
1 | LOCAL_PATH := $(call my-dir)
2 | include $(CLEAR_VARS)
3 | include ../base.mk
4 | LOCAL_SRC_FILES := fil_text_attr.c regex.c
5 | LOCAL_MODULE := text_attr
6 | include $(BUILD_EXECUTABLE)
7 |
--------------------------------------------------------------------------------
/android-studio-root/facerecognition/jni/build-modifications/diamond-core-filters/filters/ocv_face/Android.mk:
--------------------------------------------------------------------------------
1 | LOCAL_PATH := $(call my-dir)
2 | include $(CLEAR_VARS)
3 | include ../base.mk
4 | LOCAL_SRC_FILES := fil_ocv.c opencv_face_tools.c
5 | LOCAL_MODULE := ocv_face
6 | include $(BUILD_EXECUTABLE)
7 |
--------------------------------------------------------------------------------
/android-studio-root/facerecognition/jni/build-modifications/diamond-core-filters/filters/dog_texture/Android.mk:
--------------------------------------------------------------------------------
1 | LOCAL_PATH := $(call my-dir)
2 | include $(CLEAR_VARS)
3 | include ../base.mk
4 | LOCAL_SRC_FILES := fil_texture.c texture_tools.c
5 | LOCAL_MODULE := dog_texture
6 | include $(BUILD_EXECUTABLE)
7 |
--------------------------------------------------------------------------------
/android-studio-root/facerecognition/jni/build-modifications/diamond-core-filters/filters/rgb_histogram/Android.mk:
--------------------------------------------------------------------------------
1 | LOCAL_PATH := $(call my-dir)
2 | include $(CLEAR_VARS)
3 | include ../base.mk
4 | LOCAL_SRC_FILES := fil_rgb_histo.c rgb_histo.c
5 | LOCAL_MODULE := rgb_histogram
6 | include $(BUILD_EXECUTABLE)
7 |
--------------------------------------------------------------------------------
/android-studio-root/facerecognition/jni/build-modifications/diamond-core-filters/filters/perceptual_hash/Android.mk:
--------------------------------------------------------------------------------
1 | LOCAL_PATH := $(call my-dir)
2 | include $(CLEAR_VARS)
3 | include ../base.mk
4 | LOCAL_SRC_FILES := fil_texture.c texture_tools.c
5 | LOCAL_MODULE := perceptual_hash
6 | include $(BUILD_EXECUTABLE)
7 |
--------------------------------------------------------------------------------
/android-studio-root/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Apr 10 15:27:10 PDT 2013
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
7 |
--------------------------------------------------------------------------------
/attic/examples/face-detection/src/edu/cmu/cs/diamond/android/examples/facialrecognition/Const.java:
--------------------------------------------------------------------------------
1 | package edu.cmu.cs.diamond.android.examples.facialrecognition;
2 |
3 | public class Const {
4 | public static int MIN_FPS = 32;
5 | public static int IMAGE_WIDTH = 320;
6 | public static int IMAGE_HEIGHT = 240;
7 | }
--------------------------------------------------------------------------------
/attic/examples/face-detection/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | DiamondDroid_FacialRecognition
4 | Face detected!
5 | No face detected.
6 |
--------------------------------------------------------------------------------
/android-studio-root/performance/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/android-studio-root/facerecognition/jni/build-modifications/diamond-core-filters/lib/memstream.h:
--------------------------------------------------------------------------------
1 | #if defined(__linux__)
2 | # include
3 | #endif
4 |
5 | #include
6 |
7 | #if _POSIX_C_SOURCE < 200809L
8 |
9 | FILE *open_memstream(char **ptr, size_t *sizeloc);
10 |
11 | #endif /* _POSIX_C_SOURCE < 200809L */
12 |
--------------------------------------------------------------------------------
/android-studio-root/facerecognition/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | DiamondDroid_FacialRecognition
4 | Face detected!
5 | No face detected.
6 |
--------------------------------------------------------------------------------
/android-studio-root/facerecognition/jni/build-modifications/diamond-core-filters/lib/getline.h:
--------------------------------------------------------------------------------
1 | #ifndef GETLINE_H
2 | #define GETLINE_H
3 |
4 | #include
5 |
6 | extern ssize_t getdelim(char **lineptr, size_t *n, int delim, FILE *stream);
7 |
8 | extern ssize_t getline(char **lineptr, size_t *n, FILE *stream);
9 |
10 | #endif /* GETLINE_H */
11 |
12 |
--------------------------------------------------------------------------------
/android-studio-root/facerecognition/jni/build-modifications/diamond-core-filters/filters/gabor_texture/Android.mk:
--------------------------------------------------------------------------------
1 | LOCAL_PATH := $(call my-dir)
2 | include $(CLEAR_VARS)
3 | include ../base.mk
4 | LOCAL_SRC_FILES := \
5 | fil_gab_texture.cc \
6 | gabor.cc \
7 | gabor_filter.cc \
8 | gabor_tools.cc
9 | LOCAL_MODULE := gabor_texture
10 | include $(BUILD_EXECUTABLE)
11 |
--------------------------------------------------------------------------------
/android-studio-root/diamondandroidlibrary/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/android-studio-root/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/android-studio-root/facerecognition/jni/build-modifications/archive-util.c.diff:
--------------------------------------------------------------------------------
1 | 149c149
2 | < if (mbtowc(NULL, NULL, 1) == -1) { /* Reset the shift state. */
3 | ---
4 | > if (mbrtowc(NULL, NULL, 1, NULL) == -1) { /* Reset the shift state. */
5 | 164c164
6 | < if (try_wc && (n = mbtowc(&wc, p, length)) != -1) {
7 | ---
8 | > if (try_wc && (n = mbrtowc(&wc, p, length, NULL)) != -1) {
9 |
--------------------------------------------------------------------------------
/android-studio-root/facerecognition/jni/build-modifications/libfilter-Android.mk:
--------------------------------------------------------------------------------
1 | LOCAL_PATH:= $(call my-dir)
2 | GLIB_TOP:= ../../glib
3 |
4 | include $(CLEAR_VARS)
5 |
6 | LOCAL_SRC_FILES:= lf_protocol.c lf_wrapper.c lib_filter.c
7 |
8 | LOCAL_MODULE := libfilter
9 |
10 | LOCAL_C_INCLUDES := \
11 | $(GLIB_TOP) \
12 | $(GLIB_TOP)/glib \
13 | $(GLIB_TOP)/android
14 |
15 | LOCAL_CFLAGS := -std=c99
16 |
17 | include $(BUILD_STATIC_LIBRARY)
18 |
--------------------------------------------------------------------------------
/attic/diamond-android-library/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
11 |
12 |
--------------------------------------------------------------------------------
/attic/diamond-android-library/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/attic/examples/face-detection/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/android-studio-root/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:1.0.0'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/attic/diamond-android-library/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system edit
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 | #
10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
12 |
13 | # Project target.
14 | target=android-19
15 | android.library=true
16 |
--------------------------------------------------------------------------------
/attic/examples/face-detection/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system edit
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 | #
10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
12 |
13 | # Project target.
14 | target=android-19
15 | android.library.reference.1=../../diamond-android-library
16 |
--------------------------------------------------------------------------------
/android-studio-root/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 21
5 | buildToolsVersion "21.1.2"
6 |
7 | defaultConfig {
8 | applicationId "cs.cmu.edu.diamondandroid"
9 | minSdkVersion 15
10 | targetSdkVersion 21
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | compile 'com.android.support:appcompat-v7:21.0.3'
25 | }
26 |
--------------------------------------------------------------------------------
/android-studio-root/diamondandroidlibrary/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 21
5 | buildToolsVersion "21.1.2"
6 |
7 | defaultConfig {
8 | minSdkVersion 15
9 | targetSdkVersion 21
10 | versionCode 1
11 | versionName "1.0"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | compile fileTree(include: ['*.jar'], dir: 'libs')
23 | compile 'com.android.support:appcompat-v7:21.0.3'
24 | compile 'org.apache.directory.studio:org.apache.commons.io:2.4'
25 | }
26 |
--------------------------------------------------------------------------------
/android-studio-root/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/bamos/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/android-studio-root/facerecognition/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/bamos/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/android-studio-root/performance/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/bamos/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/attic/diamond-android-library/src/edu/cmu/cs/diamond/android/FilterException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Diamond Android - Diamond filters for the Android platform
3 | *
4 | * Copyright (c) 2013-2014 Carnegie Mellon University
5 | * All Rights Reserved.
6 | *
7 | * This software is distributed under the terms of the Eclipse Public
8 | * License, Version 1.0 which can be found in the file named LICENSE.
9 | * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS SOFTWARE CONSTITUTES
10 | * RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT
11 | */
12 |
13 | package edu.cmu.cs.diamond.android;
14 |
15 | public class FilterException extends Exception {
16 | private static final long serialVersionUID = 1L;
17 | public FilterException(String msg) {
18 | super(msg);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/android-studio-root/diamondandroidlibrary/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/bamos/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/attic/diamond-android-library/src/edu/cmu/cs/diamond/android/token/Token.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Diamond Android - Diamond filters for the Android platform
3 | *
4 | * Copyright (c) 2013-2014 Carnegie Mellon University
5 | * All Rights Reserved.
6 | *
7 | * This software is distributed under the terms of the Eclipse Public
8 | * License, Version 1.0 which can be found in the file named LICENSE.
9 | * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS SOFTWARE CONSTITUTES
10 | * RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT
11 | */
12 |
13 | package edu.cmu.cs.diamond.android.token;
14 |
15 | import edu.cmu.cs.diamond.android.TagEnum;
16 |
17 | public class Token {
18 | public TagEnum tag;
19 |
20 | public Token(TagEnum tag) {
21 | this.tag = tag;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/android-studio-root/facerecognition/src/main/java/edu/cmu/cs/diamond/android/examples/facialrecognition/Const.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Diamond Android - Android library for running Diamond filters
3 | *
4 | * Copyright (c) 2013-2014 Carnegie Mellon University
5 | * All Rights Reserved.
6 | *
7 | * This software is distributed under the terms of the Eclipse Public
8 | * License, Version 1.0 which can be found in the file named LICENSE.
9 | * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS SOFTWARE CONSTITUTES
10 | * RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT
11 | */
12 |
13 | package edu.cmu.cs.diamond.android.examples.facialrecognition;
14 |
15 | public class Const {
16 | public static int MIN_FPS = 32;
17 | public static int IMAGE_WIDTH = 320;
18 | public static int IMAGE_HEIGHT = 240;
19 | }
20 |
--------------------------------------------------------------------------------
/android-studio-root/diamondandroidlibrary/src/main/java/edu/cmu/cs/diamond/android/FilterException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Diamond Android - Android library for running Diamond filters
3 | *
4 | * Copyright (c) 2013-2014 Carnegie Mellon University
5 | * All Rights Reserved.
6 | *
7 | * This software is distributed under the terms of the Eclipse Public
8 | * License, Version 1.0 which can be found in the file named LICENSE.
9 | * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS SOFTWARE CONSTITUTES
10 | * RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT
11 | */
12 |
13 | package edu.cmu.cs.diamond.android;
14 |
15 | public class FilterException extends Exception {
16 | private static final long serialVersionUID = 1L;
17 | public FilterException(String msg) {
18 | super(msg);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/attic/diamond-android-library/compile-install-run-log.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Diamond Android - Diamond filters for the Android platform
4 | #
5 | # Copyright (c) 2013-2014 Carnegie Mellon University
6 | # All Rights Reserved.
7 | #
8 | # This software is distributed under the terms of the Eclipse Public
9 | # License, Version 1.0 which can be found in the file named LICENSE.
10 | # ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS SOFTWARE CONSTITUTES
11 | # RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT
12 |
13 | set -x
14 | PKG='edu.cmu.cs.encoding'
15 | ACTIVITY='EncodingBenchmarkActivity'
16 | ant debug &> ant.log || exit 1
17 | adb uninstall $PKG
18 | adb install bin/$ACTIVITY-debug.apk &> adb-install.log || exit 3
19 | adb shell am start -n $PKG/.$ACTIVITY || exit 4
20 | adb logcat | grep 'Gabriel'
21 |
--------------------------------------------------------------------------------
/android-studio-root/diamondandroidlibrary/src/main/java/edu/cmu/cs/diamond/android/token/Token.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Diamond Android - Android library for running Diamond filters
3 | *
4 | * Copyright (c) 2013-2014 Carnegie Mellon University
5 | * All Rights Reserved.
6 | *
7 | * This software is distributed under the terms of the Eclipse Public
8 | * License, Version 1.0 which can be found in the file named LICENSE.
9 | * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS SOFTWARE CONSTITUTES
10 | * RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT
11 | */
12 |
13 | package edu.cmu.cs.diamond.android.token;
14 |
15 | import edu.cmu.cs.diamond.android.TagEnum;
16 |
17 | public class Token {
18 | public TagEnum tag;
19 |
20 | public Token(TagEnum tag) {
21 | this.tag = tag;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/attic/diamond-android-library/src/edu/cmu/cs/diamond/android/token/GetToken.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Diamond Android - Diamond filters for the Android platform
3 | *
4 | * Copyright (c) 2013-2014 Carnegie Mellon University
5 | * All Rights Reserved.
6 | *
7 | * This software is distributed under the terms of the Eclipse Public
8 | * License, Version 1.0 which can be found in the file named LICENSE.
9 | * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS SOFTWARE CONSTITUTES
10 | * RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT
11 | */
12 |
13 | package edu.cmu.cs.diamond.android.token;
14 |
15 | import edu.cmu.cs.diamond.android.TagEnum;
16 |
17 | public class GetToken extends Token {
18 | public String var;
19 | public GetToken(String var) {
20 | super(TagEnum.GET);
21 | this.var = var;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/attic/diamond-android-library/src/edu/cmu/cs/diamond/android/token/OmitToken.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Diamond Android - Diamond filters for the Android platform
3 | *
4 | * Copyright (c) 2013-2014 Carnegie Mellon University
5 | * All Rights Reserved.
6 | *
7 | * This software is distributed under the terms of the Eclipse Public
8 | * License, Version 1.0 which can be found in the file named LICENSE.
9 | * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS SOFTWARE CONSTITUTES
10 | * RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT
11 | */
12 |
13 | package edu.cmu.cs.diamond.android.token;
14 |
15 | import edu.cmu.cs.diamond.android.TagEnum;
16 |
17 | public class OmitToken extends Token {
18 | public String var;
19 | public OmitToken(String var) {
20 | super(TagEnum.OMIT);
21 | this.var = var;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/android-studio-root/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/attic/diamond-android-library/src/edu/cmu/cs/diamond/android/token/ResultToken.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Diamond Android - Diamond filters for the Android platform
3 | *
4 | * Copyright (c) 2013-2014 Carnegie Mellon University
5 | * All Rights Reserved.
6 | *
7 | * This software is distributed under the terms of the Eclipse Public
8 | * License, Version 1.0 which can be found in the file named LICENSE.
9 | * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS SOFTWARE CONSTITUTES
10 | * RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT
11 | */
12 |
13 | package edu.cmu.cs.diamond.android.token;
14 |
15 | import edu.cmu.cs.diamond.android.TagEnum;
16 |
17 | public class ResultToken extends Token {
18 | public double var;
19 | public ResultToken(double var) {
20 | super(TagEnum.RESULT);
21 | this.var = var;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/android-studio-root/diamondandroidlibrary/src/main/java/edu/cmu/cs/diamond/android/token/GetToken.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Diamond Android - Android library for running Diamond filters
3 | *
4 | * Copyright (c) 2013-2014 Carnegie Mellon University
5 | * All Rights Reserved.
6 | *
7 | * This software is distributed under the terms of the Eclipse Public
8 | * License, Version 1.0 which can be found in the file named LICENSE.
9 | * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS SOFTWARE CONSTITUTES
10 | * RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT
11 | */
12 |
13 | package edu.cmu.cs.diamond.android.token;
14 |
15 | import edu.cmu.cs.diamond.android.TagEnum;
16 |
17 | public class GetToken extends Token {
18 | public String var;
19 | public GetToken(String var) {
20 | super(TagEnum.GET);
21 | this.var = var;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/android-studio-root/diamondandroidlibrary/src/main/java/edu/cmu/cs/diamond/android/token/OmitToken.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Diamond Android - Android library for running Diamond filters
3 | *
4 | * Copyright (c) 2013-2014 Carnegie Mellon University
5 | * All Rights Reserved.
6 | *
7 | * This software is distributed under the terms of the Eclipse Public
8 | * License, Version 1.0 which can be found in the file named LICENSE.
9 | * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS SOFTWARE CONSTITUTES
10 | * RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT
11 | */
12 |
13 | package edu.cmu.cs.diamond.android.token;
14 |
15 | import edu.cmu.cs.diamond.android.TagEnum;
16 |
17 | public class OmitToken extends Token {
18 | public String var;
19 | public OmitToken(String var) {
20 | super(TagEnum.OMIT);
21 | this.var = var;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/android-studio-root/diamondandroidlibrary/src/main/java/edu/cmu/cs/diamond/android/token/ResultToken.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Diamond Android - Android library for running Diamond filters
3 | *
4 | * Copyright (c) 2013-2014 Carnegie Mellon University
5 | * All Rights Reserved.
6 | *
7 | * This software is distributed under the terms of the Eclipse Public
8 | * License, Version 1.0 which can be found in the file named LICENSE.
9 | * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS SOFTWARE CONSTITUTES
10 | * RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT
11 | */
12 |
13 | package edu.cmu.cs.diamond.android.token;
14 |
15 | import edu.cmu.cs.diamond.android.TagEnum;
16 |
17 | public class ResultToken extends Token {
18 | public double var;
19 | public ResultToken(double var) {
20 | super(TagEnum.RESULT);
21 | this.var = var;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/android-studio-root/facerecognition/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
9 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/android-studio-root/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/attic/diamond-android-library/src/edu/cmu/cs/diamond/android/token/SetToken.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Diamond Android - Diamond filters for the Android platform
3 | *
4 | * Copyright (c) 2013-2014 Carnegie Mellon University
5 | * All Rights Reserved.
6 | *
7 | * This software is distributed under the terms of the Eclipse Public
8 | * License, Version 1.0 which can be found in the file named LICENSE.
9 | * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS SOFTWARE CONSTITUTES
10 | * RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT
11 | */
12 |
13 | package edu.cmu.cs.diamond.android.token;
14 |
15 | import edu.cmu.cs.diamond.android.TagEnum;
16 |
17 | public class SetToken extends Token {
18 | public String var;
19 | public byte[] buf;
20 | public SetToken(String var, byte[] buf) {
21 | super(TagEnum.SET);
22 | this.var = var;
23 | this.buf = buf;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/attic/diamond-android-library/src/edu/cmu/cs/diamond/android/token/LogToken.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Diamond Android - Diamond filters for the Android platform
3 | *
4 | * Copyright (c) 2013-2014 Carnegie Mellon University
5 | * All Rights Reserved.
6 | *
7 | * This software is distributed under the terms of the Eclipse Public
8 | * License, Version 1.0 which can be found in the file named LICENSE.
9 | * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS SOFTWARE CONSTITUTES
10 | * RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT
11 | */
12 |
13 | package edu.cmu.cs.diamond.android.token;
14 |
15 | import edu.cmu.cs.diamond.android.TagEnum;
16 |
17 | public class LogToken extends Token {
18 | public int level;
19 | public String msg;
20 | public LogToken(int level, String msg) {
21 | super(TagEnum.LOG);
22 | this.level = level;
23 | this.msg = msg;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/attic/diamond-android-library/proguard-project.txt:
--------------------------------------------------------------------------------
1 | # To enable ProGuard in your project, edit project.properties
2 | # to define the proguard.config property as described in that file.
3 | #
4 | # Add project specific ProGuard rules here.
5 | # By default, the flags in this file are appended to flags specified
6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt
7 | # You can edit the include path and order by changing the ProGuard
8 | # include property in project.properties.
9 | #
10 | # For more details, see
11 | # http://developer.android.com/guide/developing/tools/proguard.html
12 |
13 | # Add any project specific keep options here:
14 |
15 | # If your project uses WebView with JS, uncomment the following
16 | # and specify the fully qualified class name to the JavaScript interface
17 | # class:
18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
19 | # public *;
20 | #}
21 |
--------------------------------------------------------------------------------
/attic/examples/face-detection/proguard-project.txt:
--------------------------------------------------------------------------------
1 | # To enable ProGuard in your project, edit project.properties
2 | # to define the proguard.config property as described in that file.
3 | #
4 | # Add project specific ProGuard rules here.
5 | # By default, the flags in this file are appended to flags specified
6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt
7 | # You can edit the include path and order by changing the ProGuard
8 | # include property in project.properties.
9 | #
10 | # For more details, see
11 | # http://developer.android.com/guide/developing/tools/proguard.html
12 |
13 | # Add any project specific keep options here:
14 |
15 | # If your project uses WebView with JS, uncomment the following
16 | # and specify the fully qualified class name to the JavaScript interface
17 | # class:
18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
19 | # public *;
20 | #}
21 |
--------------------------------------------------------------------------------
/android-studio-root/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/android-studio-root/diamondandroidlibrary/src/main/java/edu/cmu/cs/diamond/android/token/SetToken.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Diamond Android - Android library for running Diamond filters
3 | *
4 | * Copyright (c) 2013-2014 Carnegie Mellon University
5 | * All Rights Reserved.
6 | *
7 | * This software is distributed under the terms of the Eclipse Public
8 | * License, Version 1.0 which can be found in the file named LICENSE.
9 | * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS SOFTWARE CONSTITUTES
10 | * RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT
11 | */
12 |
13 | package edu.cmu.cs.diamond.android.token;
14 |
15 | import edu.cmu.cs.diamond.android.TagEnum;
16 |
17 | public class SetToken extends Token {
18 | public String var;
19 | public byte[] buf;
20 | public SetToken(String var, byte[] buf) {
21 | super(TagEnum.SET);
22 | this.var = var;
23 | this.buf = buf;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/android-studio-root/diamondandroidlibrary/src/main/java/edu/cmu/cs/diamond/android/token/LogToken.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Diamond Android - Android library for running Diamond filters
3 | *
4 | * Copyright (c) 2013-2014 Carnegie Mellon University
5 | * All Rights Reserved.
6 | *
7 | * This software is distributed under the terms of the Eclipse Public
8 | * License, Version 1.0 which can be found in the file named LICENSE.
9 | * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS SOFTWARE CONSTITUTES
10 | * RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT
11 | */
12 |
13 | package edu.cmu.cs.diamond.android.token;
14 |
15 | import edu.cmu.cs.diamond.android.TagEnum;
16 |
17 | public class LogToken extends Token {
18 | public int level;
19 | public String msg;
20 | public LogToken(int level, String msg) {
21 | super(TagEnum.LOG);
22 | this.level = level;
23 | this.msg = msg;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/android-studio-root/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/android-studio-root/performance/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
10 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/android-studio-root/app/src/androidTest/java/cs/cmu/edu/diamondandroid/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Diamond Android - Android library for running Diamond filters
3 | *
4 | * Copyright (c) 2013-2014 Carnegie Mellon University
5 | * All Rights Reserved.
6 | *
7 | * This software is distributed under the terms of the Eclipse Public
8 | * License, Version 1.0 which can be found in the file named LICENSE.
9 | * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS SOFTWARE CONSTITUTES
10 | * RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT
11 | */
12 |
13 | package cs.cmu.edu.diamondandroid;
14 |
15 | import android.app.Application;
16 | import android.test.ApplicationTestCase;
17 |
18 | /**
19 | * Testing Fundamentals
20 | */
21 | public class ApplicationTest extends ApplicationTestCase {
22 | public ApplicationTest() {
23 | super(Application.class);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/android-studio-root/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | Android API 21 Platform
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/attic/diamond-android-library/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | DiamondAndroid
4 |
5 |
6 |
7 |
8 |
9 | com.android.ide.eclipse.adt.ResourceManagerBuilder
10 |
11 |
12 |
13 |
14 | com.android.ide.eclipse.adt.PreCompilerBuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.jdt.core.javabuilder
20 |
21 |
22 |
23 |
24 | com.android.ide.eclipse.adt.ApkBuilder
25 |
26 |
27 |
28 |
29 |
30 | com.android.ide.eclipse.adt.AndroidNature
31 | org.eclipse.jdt.core.javanature
32 |
33 |
34 |
--------------------------------------------------------------------------------
/android-studio-root/android-studio-root.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/android-studio-root/diamond-android-new.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/attic/examples/face-detection/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | DiamondAndroidFaceDetection
4 |
5 |
6 |
7 |
8 |
9 | com.android.ide.eclipse.adt.ResourceManagerBuilder
10 |
11 |
12 |
13 |
14 | com.android.ide.eclipse.adt.PreCompilerBuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.jdt.core.javabuilder
20 |
21 |
22 |
23 |
24 | com.android.ide.eclipse.adt.ApkBuilder
25 |
26 |
27 |
28 |
29 |
30 | com.android.ide.eclipse.adt.AndroidNature
31 | org.eclipse.jdt.core.javanature
32 |
33 |
34 |
--------------------------------------------------------------------------------
/attic/diamond-android-library/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
17 |
18 |
21 |
22 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/android-studio-root/facerecognition/jni/build-modifications/diamond-core-filters/lib/index.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/android-studio-root/performance/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 21
5 | buildToolsVersion "21.1.2"
6 |
7 | defaultConfig {
8 | applicationId "edu.cmu.cs.diamond.android.performance"
9 | minSdkVersion 15
10 | targetSdkVersion 21
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | task buildJni(type: Exec) {
23 | commandLine 'sh', './jni/build.sh'
24 | commandLine 'sh', './add-filters-to-res.sh'
25 | }
26 |
27 | dependencies {
28 | compile fileTree(include: ['*.jar'], dir: 'libs')
29 | compile 'com.android.support:appcompat-v7:21.0.3'
30 | compile project(':diamondandroidlibrary')
31 | compile files("src/main/res/raw/dog_texture") {
32 | builtBy 'buildJni'
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/android-studio-root/facerecognition/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 21
5 | buildToolsVersion "21.1.2"
6 |
7 | defaultConfig {
8 | applicationId "edu.cmu.cs.diamond.android.examples.facialrecognition"
9 | minSdkVersion 15
10 | targetSdkVersion 21
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | task buildJni(type: Exec) {
23 | commandLine 'sh', './jni/build.sh'
24 | commandLine 'sh', './add-filters-to-res.sh'
25 | }
26 |
27 | dependencies {
28 | compile fileTree(include: ['*.jar'], dir: 'libs')
29 | compile 'com.android.support:appcompat-v7:21.0.3'
30 | compile project(':diamondandroidlibrary')
31 | compile files("src/main/res/raw/dog_texture") {
32 | builtBy 'buildJni'
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/android-studio-root/facerecognition/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
15 |
16 |
24 |
25 |
--------------------------------------------------------------------------------
/attic/examples/face-detection/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
15 |
16 |
24 |
25 |
--------------------------------------------------------------------------------
/attic/diamond-android-library/src/edu/cmu/cs/diamond/android/TagEnum.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Diamond Android - Diamond filters for the Android platform
3 | *
4 | * Copyright (c) 2013-2014 Carnegie Mellon University
5 | * All Rights Reserved.
6 | *
7 | * This software is distributed under the terms of the Eclipse Public
8 | * License, Version 1.0 which can be found in the file named LICENSE.
9 | * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS SOFTWARE CONSTITUTES
10 | * RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT
11 | */
12 |
13 | package edu.cmu.cs.diamond.android;
14 |
15 | public enum TagEnum {
16 | INIT("init-success"),
17 | GET("get-attribute"),
18 | SET("set-attribute"),
19 | OMIT("omit-attribute"),
20 | SESSIONGET("get-session-variables"),
21 | SESSIONUPDATE("update-session-variables"),
22 | LOG("log"),
23 | RESULT("result"),
24 | UNKNOWN("unknown");
25 |
26 | public final String str;
27 | TagEnum(String str) { this.str = str; }
28 |
29 | public static TagEnum findByStr(String str) {
30 | for (TagEnum t : values()) {
31 | if (t.str.equals(str)) return t;
32 | }
33 | return UNKNOWN;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/android-studio-root/diamondandroidlibrary/src/main/java/edu/cmu/cs/diamond/android/TagEnum.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Diamond Android - Android library for running Diamond filters
3 | *
4 | * Copyright (c) 2013-2014 Carnegie Mellon University
5 | * All Rights Reserved.
6 | *
7 | * This software is distributed under the terms of the Eclipse Public
8 | * License, Version 1.0 which can be found in the file named LICENSE.
9 | * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS SOFTWARE CONSTITUTES
10 | * RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT
11 | */
12 |
13 | package edu.cmu.cs.diamond.android;
14 |
15 | public enum TagEnum {
16 | INIT("init-success"),
17 | GET("get-attribute"),
18 | SET("set-attribute"),
19 | OMIT("omit-attribute"),
20 | SESSIONGET("get-session-variables"),
21 | SESSIONUPDATE("update-session-variables"),
22 | LOG("log"),
23 | RESULT("result"),
24 | UNKNOWN("unknown");
25 |
26 | public final String str;
27 | TagEnum(String str) { this.str = str; }
28 |
29 | public static TagEnum findByStr(String str) {
30 | for (TagEnum t : values()) {
31 | if (t.str.equals(str)) return t;
32 | }
33 | return UNKNOWN;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/attic/examples/face-detection/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
11 |
12 |
16 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/android-studio-root/facerecognition/jni/build-modifications/diamond-core-filters/filters/base.mk:
--------------------------------------------------------------------------------
1 | ROOT = ../../..
2 | OPENDIAMOND := $(ROOT)/opendiamond
3 | CV := $(ROOT)/OpenCV-2.4.9-android-sdk
4 | GLIB := $(ROOT)/glib
5 | LARCHIVE := $(ROOT)/libarchive-3.1.2
6 | LJPEG := $(ROOT)/libjpeg-turbo-1.3.1
7 | LTIFF := $(ROOT)/tiff-4.0.3
8 | LPNG := $(ROOT)/libpng-1.6.15
9 |
10 | LOCAL_LDLIBS := \
11 | $(OPENDIAMOND)/libfilter/obj/local/armeabi/libfilter.a \
12 | ../../lib/obj/local/armeabi/libhelper.a \
13 | $(wildcard $(CV)/sdk/native/libs/armeabi/*.a) \
14 | $(wildcard $(CV)/sdk/native/libs/armeabi/*.a) \
15 | $(wildcard $(CV)/sdk/native/3rdparty/libs/armeabi/*.a) \
16 | $(LJPEG)/.libs/libjpeg.a \
17 | $(LTIFF)/libtiff/.libs/libtiff.a \
18 | $(LTIFF)/port/.libs/libport.a \
19 | $(LPNG)/.libs/libpng16.a \
20 | $(LARCHIVE)/.libs/libarchive.a \
21 | $(wildcard $(GLIB)/obj/local/armeabi/*.a) \
22 | $(ROOT)/toolchain/arm-linux-androideabi/lib/libstdc++.a \
23 | -llog -lz
24 |
25 | LOCAL_C_INCLUDES := \
26 | ../../include \
27 | $(LARCHIVE)/libarchive \
28 | $(OPENDIAMOND)/libfilter \
29 | $(LJPEG) \
30 | $(LTIFF)/libtiff \
31 | $(LPNG) \
32 | $(CV)/sdk/native/jni/include \
33 | $(CV)/sdk/native/jni/include/opencv2/imgproc
34 |
35 | LOCAL_CFLAGS := -std=gnu99
36 |
--------------------------------------------------------------------------------
/attic/diamond-android-library/add-filters-to-res.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Diamond Android - Diamond filters for the Android platform
4 | #
5 | # Copyright (c) 2013-2014 Carnegie Mellon University
6 | # All Rights Reserved.
7 | #
8 | # This software is distributed under the terms of the Eclipse Public
9 | # License, Version 1.0 which can be found in the file named LICENSE.
10 | # ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS SOFTWARE CONSTITUTES
11 | # RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT
12 |
13 | RES_DIR=res/raw
14 |
15 | die() { echo $*; exit -1; }
16 | addFilter() {
17 | if [[ $# == 1 ]]; then
18 | local FULL_PATH=$PWD/jni/diamond-core-filters/filters/$1/obj/local/armeabi/$1
19 | else
20 | local FULL_PATH=$PWD/jni/diamond-core-filters/filters/$1/obj/local/armeabi/$2
21 | fi
22 | [[ -f $FULL_PATH ]] || die "Unable to find filter: '$1'"
23 | echo $1
24 | cp $FULL_PATH $RES_DIR
25 | }
26 |
27 | mkdir -p $RES_DIR
28 |
29 | addFilter dog_texture
30 | addFilter gabor_texture
31 | addFilter img_diff
32 | addFilter null null_filter
33 | addFilter num_attr
34 | addFilter ocv_face
35 | addFilter rgb_histogram
36 | addFilter rgbimg
37 | addFilter shingling
38 | addFilter text_attr
39 | addFilter thumbnailer
40 |
41 | echo "haarcascade_frontalface"
42 | cp $PWD/jni/diamond-core-filters/predicates/ocv_face/haarcascade_frontalface.xml $RES_DIR/haarcascade_frontalface
43 |
--------------------------------------------------------------------------------
/android-studio-root/facerecognition/add-filters-to-res.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Diamond Android - Android library for running Diamond filters
4 | #
5 | # Copyright (c) 2013-2014 Carnegie Mellon University
6 | # All Rights Reserved.
7 | #
8 | # This software is distributed under the terms of the Eclipse Public
9 | # License, Version 1.0 which can be found in the file named LICENSE.
10 | # ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS SOFTWARE CONSTITUTES
11 | # RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT
12 |
13 | RES_DIR=src/main/res/raw
14 |
15 | die() { echo $*; exit -1; }
16 | addFilter() {
17 | if [[ $# == 1 ]]; then
18 | local FULL_PATH=$PWD/jni/diamond-core-filters/filters/$1/obj/local/armeabi/$1
19 | else
20 | local FULL_PATH=$PWD/jni/diamond-core-filters/filters/$1/obj/local/armeabi/$2
21 | fi
22 | [[ -f $FULL_PATH ]] || die "Unable to find filter: '$1'"
23 | echo $1
24 | cp $FULL_PATH $RES_DIR
25 | }
26 |
27 | mkdir -p $RES_DIR
28 |
29 | addFilter dog_texture
30 | addFilter gabor_texture
31 | addFilter img_diff
32 | addFilter null null_filter
33 | addFilter num_attr
34 | addFilter ocv_face
35 | addFilter rgb_histogram
36 | addFilter rgbimg
37 | addFilter shingling
38 | addFilter text_attr
39 | addFilter thumbnailer
40 |
41 | echo "haarcascade_frontalface"
42 | cp $PWD/jni/diamond-core-filters/predicates/ocv_face/haarcascade_frontalface.xml $RES_DIR/haarcascade_frontalface
43 |
--------------------------------------------------------------------------------
/android-studio-root/facerecognition/jni/build-modifications/diamond-core-filters/lib/Android.mk:
--------------------------------------------------------------------------------
1 | LOCAL_PATH := $(call my-dir)
2 | OPENDIAMOND := ../../opendiamond
3 | CV := ../../OpenCV-2.4.9-android-sdk
4 | GLIB := ../../glib
5 | LJPEG := ../../libjpeg-turbo-1.3.1
6 | LTIFF := ../../tiff-4.0.3
7 | LPNG := ../../libpng-1.6.15
8 | LARCHIVE := ../../libarchive-3.1.2
9 |
10 | include $(CLEAR_VARS)
11 |
12 | LOCAL_SRC_FILES := \
13 | libfilimage/examples.c \
14 | libfilimage/fil_image_tools.c \
15 | libfilimage/image_draw.c \
16 | libfilimage/image_tools.c \
17 | libfilimage/readjpeg.c \
18 | libfilimage/readpng.c \
19 | libfilimage/readtiff.c \
20 | libfilimage/rgb.c \
21 | libfilimage/readjpeg.h \
22 | libfilimage/readpng.h \
23 | libfilimage/readtiff.h \
24 | libocvimage/lib_ocvimage.c \
25 | libresults/lib_results.c \
26 | memstream.c \
27 | fmemopen.c \
28 | getline.c
29 |
30 | LOCAL_LDLIBS := \
31 | $(OPENDIAMOND)/libfilter/obj/local/armeabi/libfilter.a \
32 | $(GLIB)/obj/local/armeabi/libglib-2.0.a \
33 | $(GLIB)/obj/local/armeabi/libgmodule-2.0.a \
34 | $(GLIB)/obj/local/armeabi/libgobject-2.0.a \
35 | $(GLIB)/obj/local/armeabi/libgthread-2.0.a \
36 | $(GLIB)/obj/local/armeabi/libpcre.a \
37 | $(CV)/obj/local/armeabi/libcv.a \
38 | $(CV)/obj/local/armeabi/libcvaux.a \
39 | $(CV)/obj/local/armeabi/libcvhighgui.a \
40 | $(CV)/obj/local/armeabi/libcvml.a \
41 | $(CV)/obj/local/armeabi/libcxcore.a \
42 | $(CV)/obj/local/armeabi/libopencv.a \
43 | $(CV)/obj/local/armeabi/libstdc++.a \
44 | $(LJPEG)/.libs/libjpeg.a \
45 | $(LTIFF)/libtiff/.libs/libtiff.a \
46 | $(LPNG)/.libs/libpng16.a
47 |
48 | LOCAL_MODULE := libhelper
49 |
50 | LOCAL_C_INCLUDES := \
51 | ../include \
52 | $(OPENDIAMOND)/libfilter \
53 | $(LJPEG) \
54 | $(LTIFF)/libtiff \
55 | $(LPNG) \
56 | $(CV)/sdk/native/jni/include \
57 | $(LARCHIVE)/libarchive
58 |
59 | LOCAL_CFLAGS := -std=gnu99
60 |
61 | LOCAL_LDLIBS := -lz
62 |
63 | include $(BUILD_STATIC_LIBRARY)
64 |
--------------------------------------------------------------------------------
/android-studio-root/facerecognition/jni/build-modifications/diamond-core-filters/lib/fmemopen.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright 2011-2014 NimbusKit
3 | // Originally ported from https://github.com/ingenuitas/python-tesseract/blob/master/fmemopen.c
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 | //
17 |
18 | #ifndef FMEMOPEN_H_
19 | #define FMEMOPEN_H_
20 |
21 | #if defined __cplusplus
22 | extern "C" {
23 | #endif
24 |
25 | /**
26 | * A BSD port of the fmemopen Linux method using funopen.
27 | *
28 | * man docs for fmemopen:
29 | * http://linux.die.net/man/3/fmemopen
30 | *
31 | * man docs for funopen:
32 | * https://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man3/funopen.3.html
33 | *
34 | * This method is ported from ingenuitas' python-tesseract project.
35 | *
36 | * You must call fclose on the returned file pointer or memory will be leaked.
37 | *
38 | * @param buf The data that will be used to back the FILE* methods. Must be at least
39 | * @c size bytes.
40 | * @param size The size of the @c buf data.
41 | * @param mode The permitted stream operation modes.
42 | * @return A pointer that can be used in the fread/fwrite/fseek/fclose family of methods.
43 | * If a failure occurred NULL will be returned.
44 | * @ingroup NimbusMemoryMappping
45 | */
46 | FILE *fmemopen(void *buf, size_t size, const char *mode);
47 |
48 | #ifdef __cplusplus
49 | }
50 | #endif
51 |
52 | #endif // #ifndef FMEMOPEN_H_
53 |
--------------------------------------------------------------------------------
/android-studio-root/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/android-studio-root/facerecognition/jni/build-modifications/diamond-core-filters/lib/fmemopen.c:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright 2011-2014 NimbusKit
3 | // Originally ported from https://github.com/ingenuitas/python-tesseract/blob/master/fmemopen.c
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 | //
17 |
18 | #include
19 | #include
20 | #include
21 | #include
22 |
23 | struct fmem {
24 | size_t pos;
25 | size_t size;
26 | char *buffer;
27 | };
28 | typedef struct fmem fmem_t;
29 |
30 | static int readfn(void *handler, char *buf, int size) {
31 | fmem_t *mem = handler;
32 | size_t available = mem->size - mem->pos;
33 |
34 | if (size > available) {
35 | size = available;
36 | }
37 | memcpy(buf, mem->buffer + mem->pos, sizeof(char) * size);
38 | mem->pos += size;
39 |
40 | return size;
41 | }
42 |
43 | static int writefn(void *handler, const char *buf, int size) {
44 | fmem_t *mem = handler;
45 | size_t available = mem->size - mem->pos;
46 |
47 | if (size > available) {
48 | size = available;
49 | }
50 | memcpy(mem->buffer + mem->pos, buf, sizeof(char) * size);
51 | mem->pos += size;
52 |
53 | return size;
54 | }
55 |
56 | static fpos_t seekfn(void *handler, fpos_t offset, int whence) {
57 | size_t pos;
58 | fmem_t *mem = handler;
59 |
60 | switch (whence) {
61 | case SEEK_SET: {
62 | if (offset >= 0) {
63 | pos = (size_t)offset;
64 | } else {
65 | pos = 0;
66 | }
67 | break;
68 | }
69 | case SEEK_CUR: {
70 | if (offset >= 0 || (size_t)(-offset) <= mem->pos) {
71 | pos = mem->pos + (size_t)offset;
72 | } else {
73 | pos = 0;
74 | }
75 | break;
76 | }
77 | case SEEK_END: pos = mem->size + (size_t)offset; break;
78 | default: return -1;
79 | }
80 |
81 | if (pos > mem->size) {
82 | return -1;
83 | }
84 |
85 | mem->pos = pos;
86 | return (fpos_t)pos;
87 | }
88 |
89 | static int closefn(void *handler) {
90 | free(handler);
91 | return 0;
92 | }
93 |
94 | FILE *fmemopen(void *buf, size_t size, const char *mode) {
95 | // This data is released on fclose.
96 | fmem_t* mem = (fmem_t *) malloc(sizeof(fmem_t));
97 |
98 | // Zero-out the structure.
99 | memset(mem, 0, sizeof(fmem_t));
100 |
101 | mem->size = size;
102 | mem->buffer = buf;
103 |
104 | // funopen's man page: https://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man3/funopen.3.html
105 | return funopen(mem, readfn, writefn, seekfn, closefn);
106 | }
107 |
--------------------------------------------------------------------------------
/android-studio-root/facerecognition/jni/build-modifications/diamond-core-filters/lib/getline.c:
--------------------------------------------------------------------------------
1 | /* getline.c
2 | *
3 | * getdelim(), getline() - read a delimited record from stream, ersatz implementation
4 | *
5 | * For more details, see: http://pubs.opengroup.org/onlinepubs/9699919799/functions/getline.html
6 | *
7 | * (w) Ivan Radanovic
8 | *
9 | * =============
10 | *
11 | * This is free and unencumbered software released into the public domain.
12 | *
13 | * Anyone is free to copy, modify, publish, use, compile, sell, or
14 | * distribute this software, either in source code form or as a compiled
15 | * binary, for any purpose, commercial or non-commercial, and by any
16 | * means.
17 | *
18 | * In jurisdictions that recognize copyright laws, the author or authors
19 | * of this software dedicate any and all copyright interest in the
20 | * software to the public domain. We make this dedication for the benefit
21 | * of the public at large and to the detriment of our heirs and
22 | * successors. We intend this dedication to be an overt act of
23 | * relinquishment in perpetuity of all present and future rights to this
24 | * software under copyright law.
25 | *
26 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
27 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
28 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
29 | * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
30 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
31 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
32 | * OTHER DEALINGS IN THE SOFTWARE.
33 | *
34 | * For more information, please refer to
35 | */
36 |
37 | #include "getline.h"
38 | #include
39 | #include
40 | #include
41 |
42 | ssize_t getdelim(char **lineptr, size_t *n, int delim, FILE *stream) {
43 | char c, *cur_pos, *new_lineptr;
44 | size_t new_lineptr_len;
45 |
46 | if (lineptr == NULL || n == NULL || stream == NULL) {
47 | errno = EINVAL;
48 | return -1;
49 | }
50 |
51 | if (*lineptr == NULL) {
52 | *n = 128; /* init len */
53 | if ((*lineptr = (char *)malloc(*n)) == NULL) {
54 | errno = ENOMEM;
55 | return -1;
56 | }
57 | }
58 |
59 | cur_pos = *lineptr;
60 | for (;;) {
61 | c = getc(stream);
62 |
63 | if (ferror(stream) || (c == EOF && cur_pos == *lineptr))
64 | return -1;
65 |
66 | if (c == EOF)
67 | break;
68 |
69 | if ((*lineptr + *n - cur_pos) < 2) {
70 | if (SSIZE_MAX / 2 < *n) {
71 | #ifdef EOVERFLOW
72 | errno = EOVERFLOW;
73 | #else
74 | errno = ERANGE; /* no EOVERFLOW defined */
75 | #endif
76 | return -1;
77 | }
78 | new_lineptr_len = *n * 2;
79 |
80 | if ((new_lineptr = (char *)realloc(*lineptr, new_lineptr_len)) == NULL) {
81 | errno = ENOMEM;
82 | return -1;
83 | }
84 | *lineptr = new_lineptr;
85 | *n = new_lineptr_len;
86 | }
87 |
88 | *cur_pos++ = c;
89 |
90 | if (c == delim)
91 | break;
92 | }
93 |
94 | *cur_pos = '\0';
95 | return (ssize_t)(cur_pos - *lineptr);
96 | }
97 |
98 | ssize_t getline(char **lineptr, size_t *n, FILE *stream) {
99 | return getdelim(lineptr, n, '\n', stream);
100 | }
101 |
102 |
--------------------------------------------------------------------------------
/attic/examples/face-detection/build.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
29 |
30 |
31 |
35 |
36 |
37 |
38 |
39 |
40 |
49 |
50 |
51 |
52 |
56 |
57 |
69 |
70 |
71 |
89 |
90 |
91 |
92 |
93 |
--------------------------------------------------------------------------------
/attic/diamond-android-library/build.xml:
--------------------------------------------------------------------------------
1 |
12 |
13 |
14 |
15 |
16 |
19 |
20 |
21 |
41 |
42 |
43 |
47 |
48 |
49 |
50 |
51 |
52 |
61 |
62 |
63 |
64 |
68 |
69 |
81 |
82 |
83 |
101 |
102 |
103 |
104 |
105 |
--------------------------------------------------------------------------------
/attic/examples/face-detection/src/edu/cmu/cs/diamond/android/examples/facialrecognition/CameraPreview.java:
--------------------------------------------------------------------------------
1 | package edu.cmu.cs.diamond.android.examples.facialrecognition;
2 |
3 | import java.io.IOException;
4 | import java.util.List;
5 |
6 | import android.content.Context;
7 | import android.hardware.Camera;
8 | import android.hardware.Camera.PreviewCallback;
9 | import android.hardware.Camera.Size;
10 | import android.util.AttributeSet;
11 | import android.util.Log;
12 | import android.view.SurfaceHolder;
13 | import android.view.SurfaceView;
14 |
15 | public class CameraPreview extends SurfaceView implements
16 | SurfaceHolder.Callback {
17 | private static final String LOG_TAG = "GabrielCameraPreview";
18 | /*
19 | * Galaxy Nexus
20 | * 320x240 : 2 Mbps, 24 FPS
21 | * 640x480 : 3 Mbps, 10 FPS
22 | * 800x480 : 2.5Mbps, 7.5 FPS
23 | */
24 |
25 | public SurfaceHolder mHolder;
26 | public Camera mCamera = null;
27 | public List supportingFPS = null;
28 | public List supportingSize = null;
29 |
30 | public void close() {
31 | if (mCamera != null) {
32 | mCamera.stopPreview();
33 | mCamera.release();
34 | mCamera = null;
35 | }
36 | }
37 |
38 | @SuppressWarnings("deprecation")
39 | public CameraPreview(Context context, AttributeSet attrs) {
40 | super(context, attrs);
41 | Log.d(LOG_TAG, "Context : " + context);
42 | if (mCamera == null) {
43 |
44 | // Launching Camera App using voice command need to wait.
45 | // See more at https://code.google.com/p/google-glass-api/issues/list
46 | try {
47 | Thread.sleep(1000);
48 | } catch (InterruptedException e) {}
49 | mCamera = Camera.open();
50 | }
51 |
52 | mHolder = getHolder();
53 | mHolder.addCallback(this);
54 | mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
55 | }
56 |
57 | @Override
58 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
59 | // TODO Auto-generated method stub
60 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
61 | }
62 |
63 | public void changeConfiguration(int[] range, Size imageSize, Integer imageFormat) {
64 | Camera.Parameters parameters = mCamera.getParameters();
65 | if (range != null){
66 | Log.d(LOG_TAG, "frame rate configuration : " + range[0] + "," + range[1]);
67 | parameters.setPreviewFpsRange(range[0], range[1]);
68 | }
69 | if (imageSize != null){
70 | Log.d(LOG_TAG, "image size configuration : " + imageSize.width + "," + imageSize.height);
71 | parameters.setPreviewSize(imageSize.width, imageSize.height);
72 | }
73 | if (imageFormat != null) {
74 | parameters.setPictureFormat(imageFormat);
75 | }
76 | mCamera.setParameters(parameters);
77 | }
78 |
79 | public void surfaceCreated(SurfaceHolder holder) {
80 |
81 | if (mCamera == null) {
82 | mCamera = Camera.open();
83 | // mCamera.setDisplayOrientation(90);
84 | }
85 | if (mCamera != null) {
86 | try {
87 | mCamera.setPreviewDisplay(holder);
88 | // set fps to capture
89 | Camera.Parameters parameters = mCamera.getParameters();
90 | parameters.setRotation(180);
91 | List supportedFps = parameters.getSupportedPreviewFpsRange();
92 | if(this.supportingFPS == null)
93 | this.supportingFPS = supportedFps;
94 | int index = 0, fpsDiff = Integer.MAX_VALUE;
95 | for (int i = 0; i < supportedFps.size(); i++){
96 | int[] frameRate = supportedFps.get(i);
97 | int diff = Math.abs(Const.MIN_FPS*1000 - frameRate[0]);
98 | if (diff < fpsDiff){
99 | fpsDiff = diff;
100 | index = i;
101 | }
102 | }
103 | int[] targetRange = supportedFps.get(index);
104 |
105 | List supportedSizes = parameters.getSupportedPreviewSizes();
106 | if(this.supportingSize == null)
107 | this.supportingSize = supportedSizes;
108 | index = 0;
109 | int sizeDiff = Integer.MAX_VALUE;
110 | for (int i = 0; i < supportedSizes.size(); i++){
111 | Camera.Size size = supportedSizes.get(i);
112 | int diff = Math.abs(size.width - Const.IMAGE_WIDTH);
113 | if (diff < sizeDiff){
114 | sizeDiff = diff;
115 | index = i;
116 | }
117 | }
118 | Camera.Size target_size = supportedSizes.get(index);
119 | //List supportedFormat = parameters.getSupportedPreviewFormats();
120 |
121 | changeConfiguration(targetRange, target_size, null);
122 | mCamera.startPreview();
123 |
124 | } catch (IOException exception) {
125 | Log.e(LOG_TAG, "exception:surfaceCreated Camera Open ");
126 | this.close();
127 | }
128 | }
129 | }
130 |
131 | public void surfaceDestroyed(SurfaceHolder holder) {
132 | mCamera.release();
133 | this.close();
134 | }
135 |
136 | public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
137 | /*
138 | * Camera.Parameters parameters = mCamera.getParameters();
139 | * parameters.setPreviewSize(w, h); mCamera.setParameters(parameters);
140 | * mCamera.startPreview();
141 | */
142 | }
143 |
144 | public void setPreviewCallback(PreviewCallback previewCallback) {
145 | if (this.mCamera != null){
146 | mCamera.setPreviewCallback(previewCallback);
147 | }
148 | }
149 |
150 | public Camera getCamera() {
151 | return mCamera;
152 | }
153 | }
--------------------------------------------------------------------------------
/android-studio-root/facerecognition/jni/build.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Diamond Android - Android library for running Diamond filters
4 | #
5 | # Copyright (c) 2013-2014 Carnegie Mellon University
6 | # All Rights Reserved.
7 | #
8 | # This software is distributed under the terms of the Eclipse Public
9 | # License, Version 1.0 which can be found in the file named LICENSE.
10 | # ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS SOFTWARE CONSTITUTES
11 | # RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT
12 |
13 | set -x -e
14 |
15 | die() { echo $*; exit -1; }
16 |
17 | patch_f() {
18 | set +e
19 | patch --dry-run -N $1 $2
20 | if [[ $? == 0 ]]; then
21 | patch -N $1 $2
22 | fi
23 | set -e
24 | }
25 |
26 | cd $(dirname "$0")
27 |
28 | if [[ ! -d toolchain ]]; then
29 | $ANDROID_NDK/build/tools/make-standalone-toolchain.sh \
30 | --install-dir=$PWD/toolchain
31 | fi
32 |
33 | # Add the standalone toolchain to the path.
34 | pathadd() { PATH="${PATH:+"$PATH:"}$1"; }
35 | pathadd "$PWD/toolchain/bin"
36 | command -v arm-linux-androideabi-gcc &> /dev/null || exit -1
37 | export SYSROOT=$PWD/toolchain/sysroot
38 | export CC=arm-linux-androideabi-gcc
39 | export CXX=arm-linux-androideabi-g++
40 | export LD=arm-linux-androideabi-ld
41 | export RANLIB=arm-linux-androideabi-ranlib
42 | export AR=arm-linux-androideabi-ar
43 | export CROSS_PREFIX=arm-linux-androideabi-
44 | export CFLAGS='-march=armv7-a -mfloat-abi=softfp -mfpu=neon'
45 | export LDFLAGS='-Wl,--fix-cortex-a8'
46 |
47 | if [[ ! -d glib ]]; then
48 | git clone https://github.com/ieei/glib.git
49 | fi
50 | cd glib
51 | git checkout 63c09f42414ca0214187926bf376bc8de1e71a52
52 | mv Android.mk{,.old}
53 | echo "TARGET_FORMAT_STRING_CFLAGS := -Wformat -Wno-error" > Android.mk
54 | sed 's/GLIB\_BUILD\_STATIC := .*/GLIB\_BUILD\_STATIC := true/' Android.mk.old \
55 | >> Android.mk
56 | echo "APP_MODULES=libglib-2.0" > Application.mk
57 | ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=./Android.mk \
58 | || die "glib build failed."
59 | cd ..
60 |
61 | if [[ ! -d opendiamond ]]; then
62 | git clone https://github.com/cmusatyalab/opendiamond.git
63 | fi
64 | cd opendiamond
65 | git checkout a52d4d08ec39b49d6759bdbc5068fe37b611aa7b
66 | cd libfilter
67 | cp ../../build-modifications/libfilter-Android.mk ./Android.mk
68 | ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=./Android.mk \
69 | || die "libfilter build failed."
70 | cd ../..
71 |
72 | if [[ ! -d OpenCV-2.4.9-android-sdk ]]; then
73 | wget http://downloads.sourceforge.net/project/opencvlibrary/opencv-android/2.4.9/OpenCV-2.4.9-android-sdk.zip
74 | unzip OpenCV*.zip
75 | rm OpenCV*.zip
76 | fi
77 |
78 | if [[ ! -e libarchive-3.1.2.tar.gz ]]; then
79 | wget http://www.libarchive.org/downloads/libarchive-3.1.2.tar.gz
80 | tar xvfz libarchive*.gz
81 | fi
82 | cd libarchive-3.1.2
83 | cd libarchive
84 | mv archive_read_disk_posix.c{,.old}
85 | cat > archive_read_disk_posix.c<
88 | #define statvfs statfs
89 | #define fstatvfs fstatfs
90 | #endif
91 | EOF
92 | cat archive_read_disk_posix.c.old >> archive_read_disk_posix.c
93 | cd ..
94 | patch_f tar/util.c ../build-modifications/archive-util.c.diff
95 | ./configure --enable-static --host=arm-linux --without-xml2
96 | make -j8 || die "libarchive build failed."
97 | cd ..
98 |
99 | if [[ ! -d libjpeg-turbo-1.3.1 ]]; then
100 | wget http://downloads.sourceforge.net/project/libjpeg-turbo/1.3.1/libjpeg-turbo-1.3.1.tar.gz
101 | tar xvfz libjpeg*.gz
102 | rm libjpeg*.gz
103 | fi
104 | cd libjpeg-turbo-1.3.1
105 | ./configure --enable-static --target=armv5te-android-gcc --host=arm-linux
106 | make -j8 || die "jpeg-6b build failed."
107 | cd ..
108 | #CFLAGS+=" -I$PWD/libjpeg-turbo-1.3.1/"
109 |
110 | if [[ ! -d tiff-4.0.3 ]]; then
111 | wget ftp://ftp.remotesensing.org/pub/libtiff/tiff-4.0.3.tar.gz
112 | tar xvfz tiff*.gz
113 | fi
114 | cd tiff-4.0.3
115 | ./configure --enable-static --host=arm-linux \
116 | --with-jpeg-include-dir=$PWD/../libjpeg-turbo-1.3.1 \
117 | --with-jpeg-lib-dir=$PWD/../libjpeg-turbo-1.3.1/.libs
118 | make -j8 || die "tiff build failed."
119 | cd ..
120 |
121 | if [[ ! -d libpng-1.6.15 ]]; then
122 | wget http://prdownloads.sourceforge.net/libpng/libpng-1.6.15.tar.gz
123 | tar xvfz libpng*.gz
124 | fi
125 | cd libpng-1.6.15
126 | ./configure --enable-static --host=arm-linux
127 | make -j8 || die "libpng build failed."
128 | cd ..
129 |
130 | if [[ ! -d diamond-core-filters ]]; then
131 | git clone https://github.com/cmusatyalab/diamond-core-filters.git
132 | fi
133 | cd diamond-core-filters
134 | git checkout 15e63cf2797e674553a0a5cfbfd82f31c535a95b
135 | cd lib
136 | cp ../../build-modifications/diamond-core-filters/lib/* .
137 | ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=./Android.mk \
138 | || die "diamond-core-filters/lib build failed."
139 | cd ../..
140 |
141 | cd diamond-core-filters/filters
142 | cp ../../build-modifications/diamond-core-filters/filters/base.mk .
143 | cd text_attr
144 | sed -i -e 's/#include /#include "_regex.h"/' fil_text_attr.c
145 | cd ..
146 | buildFilter() {
147 | cd $1
148 | cp ../../../build-modifications/diamond-core-filters/filters/$1/* .
149 | ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=./Android.mk \
150 | || die "$1 build failed."
151 | cd ..
152 | }
153 | buildFilter dog_texture
154 | buildFilter gabor_texture
155 | buildFilter img_diff
156 | buildFilter null
157 | buildFilter num_attr
158 | buildFilter ocv_face
159 | buildFilter rgb_histogram
160 | buildFilter rgbimg
161 | buildFilter shingling
162 | buildFilter text_attr
163 | buildFilter thumbnailer
164 |
--------------------------------------------------------------------------------
/android-studio-root/facerecognition/src/main/java/edu/cmu/cs/diamond/android/examples/facialrecognition/CameraPreview.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Diamond Android - Android library for running Diamond filters
3 | *
4 | * Copyright (c) 2013-2014 Carnegie Mellon University
5 | * All Rights Reserved.
6 | *
7 | * This software is distributed under the terms of the Eclipse Public
8 | * License, Version 1.0 which can be found in the file named LICENSE.
9 | * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS SOFTWARE CONSTITUTES
10 | * RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT
11 | */
12 |
13 | package edu.cmu.cs.diamond.android.examples.facialrecognition;
14 |
15 | import java.io.IOException;
16 | import java.util.List;
17 |
18 | import android.content.Context;
19 | import android.hardware.Camera;
20 | import android.hardware.Camera.PreviewCallback;
21 | import android.hardware.Camera.Size;
22 | import android.util.AttributeSet;
23 | import android.util.Log;
24 | import android.view.SurfaceHolder;
25 | import android.view.SurfaceView;
26 |
27 | public class CameraPreview extends SurfaceView implements
28 | SurfaceHolder.Callback {
29 | private static final String LOG_TAG = "GabrielCameraPreview";
30 | /*
31 | * Galaxy Nexus
32 | * 320x240 : 2 Mbps, 24 FPS
33 | * 640x480 : 3 Mbps, 10 FPS
34 | * 800x480 : 2.5Mbps, 7.5 FPS
35 | */
36 |
37 | public SurfaceHolder mHolder;
38 | public Camera mCamera = null;
39 | public List supportingFPS = null;
40 | public List supportingSize = null;
41 |
42 | public void close() {
43 | if (mCamera != null) {
44 | mCamera.stopPreview();
45 | mCamera.release();
46 | mCamera = null;
47 | }
48 | }
49 |
50 | @SuppressWarnings("deprecation")
51 | public CameraPreview(Context context, AttributeSet attrs) {
52 | super(context, attrs);
53 | Log.d(LOG_TAG, "Context : " + context);
54 | if (mCamera == null) {
55 |
56 | // Launching Camera App using voice command need to wait.
57 | // See more at https://code.google.com/p/google-glass-api/issues/list
58 | try {
59 | Thread.sleep(1000);
60 | } catch (InterruptedException e) {}
61 | mCamera = Camera.open();
62 | }
63 |
64 | mHolder = getHolder();
65 | mHolder.addCallback(this);
66 | mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
67 | }
68 |
69 | @Override
70 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
71 | // TODO Auto-generated method stub
72 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
73 | }
74 |
75 | public void changeConfiguration(int[] range, Size imageSize, Integer imageFormat) {
76 | Camera.Parameters parameters = mCamera.getParameters();
77 | if (range != null){
78 | Log.d(LOG_TAG, "frame rate configuration : " + range[0] + "," + range[1]);
79 | parameters.setPreviewFpsRange(range[0], range[1]);
80 | }
81 | if (imageSize != null){
82 | Log.d(LOG_TAG, "image size configuration : " + imageSize.width + "," + imageSize.height);
83 | parameters.setPreviewSize(imageSize.width, imageSize.height);
84 | }
85 | if (imageFormat != null) {
86 | parameters.setPictureFormat(imageFormat);
87 | }
88 | mCamera.setParameters(parameters);
89 | }
90 |
91 | public void surfaceCreated(SurfaceHolder holder) {
92 |
93 | if (mCamera == null) {
94 | mCamera = Camera.open();
95 | // mCamera.setDisplayOrientation(90);
96 | }
97 | if (mCamera != null) {
98 | try {
99 | mCamera.setPreviewDisplay(holder);
100 | // set fps to capture
101 | Camera.Parameters parameters = mCamera.getParameters();
102 | parameters.setRotation(180);
103 | List supportedFps = parameters.getSupportedPreviewFpsRange();
104 | if(this.supportingFPS == null)
105 | this.supportingFPS = supportedFps;
106 | int index = 0, fpsDiff = Integer.MAX_VALUE;
107 | for (int i = 0; i < supportedFps.size(); i++){
108 | int[] frameRate = supportedFps.get(i);
109 | int diff = Math.abs(Const.MIN_FPS*1000 - frameRate[0]);
110 | if (diff < fpsDiff){
111 | fpsDiff = diff;
112 | index = i;
113 | }
114 | }
115 | int[] targetRange = supportedFps.get(index);
116 |
117 | List supportedSizes = parameters.getSupportedPreviewSizes();
118 | if(this.supportingSize == null)
119 | this.supportingSize = supportedSizes;
120 | index = 0;
121 | int sizeDiff = Integer.MAX_VALUE;
122 | for (int i = 0; i < supportedSizes.size(); i++){
123 | Camera.Size size = supportedSizes.get(i);
124 | int diff = Math.abs(size.width - Const.IMAGE_WIDTH);
125 | if (diff < sizeDiff){
126 | sizeDiff = diff;
127 | index = i;
128 | }
129 | }
130 | Camera.Size target_size = supportedSizes.get(index);
131 | //List supportedFormat = parameters.getSupportedPreviewFormats();
132 |
133 | changeConfiguration(targetRange, target_size, null);
134 | mCamera.startPreview();
135 |
136 | } catch (IOException exception) {
137 | Log.e(LOG_TAG, "exception:surfaceCreated Camera Open ");
138 | this.close();
139 | }
140 | }
141 | }
142 |
143 | public void surfaceDestroyed(SurfaceHolder holder) {
144 | mCamera.release();
145 | this.close();
146 | }
147 |
148 | public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
149 | /*
150 | * Camera.Parameters parameters = mCamera.getParameters();
151 | * parameters.setPreviewSize(w, h); mCamera.setParameters(parameters);
152 | * mCamera.startPreview();
153 | */
154 | }
155 |
156 | public void setPreviewCallback(PreviewCallback previewCallback) {
157 | if (this.mCamera != null){
158 | mCamera.setPreviewCallback(previewCallback);
159 | }
160 | }
161 |
162 | public Camera getCamera() {
163 | return mCamera;
164 | }
165 | }
166 |
--------------------------------------------------------------------------------
/android-studio-root/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/attic/examples/face-detection/src/edu/cmu/cs/diamond/android/examples/facialrecognition/MainActivity.java:
--------------------------------------------------------------------------------
1 | package edu.cmu.cs.diamond.android.examples.facialrecognition;
2 |
3 | import java.io.ByteArrayOutputStream;
4 | import java.io.IOException;
5 | import java.io.InputStream;
6 | import java.util.HashMap;
7 | import java.util.Map;
8 |
9 | import org.apache.commons.io.IOUtils;
10 |
11 | import edu.cmu.cs.diamond.android.Filter;
12 | import edu.cmu.cs.diamond.android.FilterException;
13 | import edu.cmu.cs.diamond.android.examples.facialrecognition.R;
14 | import android.app.Activity;
15 | import android.content.Context;
16 | import android.graphics.ImageFormat;
17 | import android.graphics.Rect;
18 | import android.graphics.YuvImage;
19 | import android.hardware.Camera;
20 | import android.hardware.Camera.PreviewCallback;
21 | import android.hardware.Camera.Size;
22 | import android.os.Bundle;
23 | import android.util.Log;
24 | import android.view.WindowManager;
25 | import android.widget.TextView;
26 |
27 | public class MainActivity extends Activity {
28 | private final String TAG = this.getClass().getSimpleName();
29 |
30 | private Context context;
31 |
32 | private CameraPreview mCamera;
33 | private TextView mClassificationText;
34 |
35 | private Object frameLock = new Object();
36 | private byte[] frameBuffer;
37 | public boolean isRunning = true;
38 |
39 | private PreviewCallback previewCallback = new PreviewCallback() {
40 | public void onPreviewFrame(byte[] frame, Camera cam) {
41 | synchronized (frameLock) {
42 | frameBuffer = frame;
43 | frameLock.notify();
44 | }
45 | }
46 | };
47 |
48 | private Thread processingThread = new Thread() {
49 | public void run() {
50 | String[] faceFilterArgs = {"1.2", "24", "24", "1", "2"};
51 | InputStream ocvXmlIS = context.getResources().openRawResource(R.raw.haarcascade_frontalface);
52 | Filter rgbFilter, faceFilter;
53 | try {
54 | rgbFilter = new Filter(R.raw.rgbimg, context, "RGB", null, null);
55 | byte[] ocvXml = IOUtils.toByteArray(ocvXmlIS);
56 | faceFilter = new Filter(R.raw.ocv_face, context, "OCVFace",
57 | faceFilterArgs, ocvXml);
58 | } catch (IOException e1) {
59 | Log.e(TAG, "Unable to create filter subprocess.");
60 | e1.printStackTrace();
61 | return;
62 | }
63 |
64 | while (isRunning) {
65 | byte[] data = null;
66 | synchronized(frameLock) {
67 | while (frameBuffer == null){
68 | try {
69 | frameLock.wait();
70 | } catch (InterruptedException e) {}
71 | }
72 | data = frameBuffer;
73 | frameBuffer = null;
74 | }
75 | Log.d(TAG, "Got frame, trying to detect face.");
76 | Size cameraImageSize = mCamera.getCamera().getParameters().getPreviewSize();
77 | YuvImage image = new YuvImage(data, ImageFormat.NV21,
78 | cameraImageSize.width, cameraImageSize.height, null);
79 | ByteArrayOutputStream tmpBuffer = new ByteArrayOutputStream();
80 | image.compressToJpeg(new Rect(0, 0, image.getWidth(), image.getHeight()), 90, tmpBuffer);
81 | byte[] jpgFrame = tmpBuffer.toByteArray();
82 | boolean faceInFrame = false;
83 | try {
84 | faceInFrame = isFace(jpgFrame, rgbFilter, faceFilter);
85 | } catch (Exception e) {
86 | mClassificationText.setText("Detection exception.");
87 | e.printStackTrace();
88 | }
89 |
90 | final String classification;
91 | if (faceInFrame) {
92 | Log.i(TAG, "Face detected.");
93 | classification = getString(R.string.classificationTrue);
94 | } else {
95 | Log.i(TAG, "No face detected.");
96 | classification = getString(R.string.classificationFalse);
97 | }
98 | runOnUiThread(new Runnable() {
99 | public void run() {
100 | mClassificationText.setText(classification);
101 | mClassificationText.invalidate();
102 | }
103 | });
104 | }
105 | }
106 | };
107 |
108 | @Override
109 | protected void onCreate(Bundle savedInstanceState) {
110 | super.onCreate(savedInstanceState);
111 | context = this.getApplicationContext();
112 |
113 | setContentView(R.layout.activity_main);
114 | getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED+
115 | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON+
116 | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
117 |
118 |
119 | mCamera = (CameraPreview) findViewById(R.id.cameraPreview);
120 | // mCamera.changeConfiguration(null, null, ImageFormat.NV21);
121 | mClassificationText = (TextView) findViewById(R.id.classificationText);
122 |
123 | mCamera.setPreviewCallback(previewCallback);
124 | processingThread.start();
125 | }
126 |
127 | @Override
128 | protected void onStop() {
129 | super.onStop();
130 | isRunning = false;
131 | try {
132 | processingThread.join();
133 | } catch (InterruptedException e) {
134 | // TODO Auto-generated catch block
135 | e.printStackTrace();
136 | }
137 | }
138 |
139 | private boolean isFace(byte[] jpegImage, Filter rgbFilter, Filter faceFilter) throws IOException, FilterException {
140 | final Map m = new HashMap();
141 | Log.d(TAG, "Sending JPEG image to RGB filter.");
142 | Log.d(TAG, "JPEG image size: " + String.valueOf(jpegImage.length) + " bytes.");
143 |
144 | m.put("", jpegImage);
145 | rgbFilter.process(m);
146 | byte[] rgbImage = m.get("_rgb_image.rgbimage");
147 |
148 | Log.d(TAG, "Obtained RGB image from RGB filter.");
149 | Log.d(TAG, "RGB image size: " + String.valueOf(rgbImage.length) + " bytes.");
150 |
151 | Log.d(TAG, "Sending RGB image to OCV face filter.");
152 | double faceRecognized = faceFilter.process(m);
153 | return Math.abs(faceRecognized-1.0d) < 1E-6;
154 | }
155 | }
--------------------------------------------------------------------------------
/android-studio-root/performance/src/main/java/edu/cmu/cs/diamond/android/performance/MainActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Diamond Android - Android library for running Diamond filters
3 | *
4 | * Copyright (c) 2013-2014 Carnegie Mellon University
5 | * All Rights Reserved.
6 | *
7 | * This software is distributed under the terms of the Eclipse Public
8 | * License, Version 1.0 which can be found in the file named LICENSE.
9 | * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS SOFTWARE CONSTITUTES
10 | * RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT
11 | */
12 |
13 | package edu.cmu.cs.diamond.android.performance;
14 |
15 | import java.io.ByteArrayOutputStream;
16 | import java.io.File;
17 | import java.io.FileNotFoundException;
18 | import java.io.IOException;
19 | import java.io.InputStream;
20 | import java.io.PrintWriter;
21 | import java.util.ArrayList;
22 | import java.util.HashMap;
23 | import java.util.Map;
24 |
25 | import org.apache.commons.io.FileUtils;
26 | import org.apache.commons.io.IOUtils;
27 |
28 | import edu.cmu.cs.diamond.android.Filter;
29 | import edu.cmu.cs.diamond.android.FilterException;
30 | import android.app.Activity;
31 | import android.content.Context;
32 | import android.graphics.ImageFormat;
33 | import android.graphics.Rect;
34 | import android.graphics.YuvImage;
35 | import android.hardware.Camera;
36 | import android.hardware.Camera.PreviewCallback;
37 | import android.hardware.Camera.Size;
38 | import android.os.Bundle;
39 | import android.util.Log;
40 | import android.view.WindowManager;
41 | import android.widget.TextView;
42 |
43 | public class MainActivity extends Activity {
44 | private final String TAG = this.getClass().getSimpleName();
45 |
46 | private Context context;
47 |
48 | private Thread processingThread = new Thread() {
49 | public void run() {
50 | InputStream ocvXmlIS = context.getResources().openRawResource(R.raw.haarcascade_frontalface);
51 | InputStream exampleImagesIS = context.getResources().openRawResource(R.raw.filters_zip);
52 | Filter rgbFilter, dogFilter, gaborFilter, imgDiffFilter, faceFilter, rgbHistFilter,
53 | shinglingFilter;
54 | try {
55 | rgbFilter = new Filter(R.raw.rgbimg, context, "RGB", null, null);
56 |
57 | byte[] ocvXml = IOUtils.toByteArray(ocvXmlIS);
58 | byte[] exampleImages = IOUtils.toByteArray(exampleImagesIS);
59 |
60 | // scale, box_width, box_height, step, min_matches, max_distance, num_channels, metric
61 | String[] dogArgs = {"0.5", "24", "24", "2", "1", "0.5", "3", "pairwise"};
62 | dogFilter = new Filter(R.raw.dog_texture, context, "DoG", dogArgs, exampleImages);
63 |
64 | // xdim, ydim, step, min_matches, max_distance,
65 | // num_angles, num_freq, radius, max_freq, min_freq
66 | String[] gaborArgs = {"24", "24", "2", "1", "0.5", "3", "2", "2", "2", "0.5", "0.5"};
67 | gaborFilter = new Filter(R.raw.gabor_texture, context, "gabor", gaborArgs, exampleImages);
68 |
69 | // TODO: imgDiff
70 |
71 | // xsize, ysize, stride, support
72 | String[] faceFilterArgs = {"1.2", "24", "24", "1", "2"};
73 | faceFilter = new Filter(R.raw.ocv_face, context, "OCVFace",
74 | faceFilterArgs, ocvXml);
75 |
76 | // TODO: rgbHist
77 |
78 | // TODO: shingling
79 | } catch (IOException e1) {
80 | Log.e(TAG, "Unable to create filter subprocess.");
81 | e1.printStackTrace();
82 | return;
83 | }
84 | Filter[] profilingFilters = {faceFilter, dogFilter}; //gaborFilter};
85 |
86 | PrintWriter results;
87 | try {
88 | results = new PrintWriter("/sdcard/diamond-performance.csv");
89 | } catch (FileNotFoundException e) {
90 | Log.e(TAG, "Unable to create result writer.");
91 | e.printStackTrace();
92 | return;
93 | }
94 |
95 | File imgDir = new File("/sdcard/public-domain-landscapes/");
96 | ArrayList rgbImages = new ArrayList();
97 | ArrayList durations = new ArrayList();
98 | ArrayList imgNames = new ArrayList();
99 | final Map m = new HashMap();
100 | for (String relImgStr : imgDir.list()) {
101 | try {
102 | String imgStr = imgDir.getAbsolutePath()+"/"+relImgStr;
103 | byte[] imgBytes = FileUtils.readFileToByteArray(new File(imgStr));
104 | long start = System.currentTimeMillis();
105 | m.put("",imgBytes);
106 | rgbFilter.process(m);
107 | byte[] rgbImage = m.get("_rgb_image.rgbimage");
108 | rgbImages.add(rgbImage);
109 | imgNames.add(relImgStr);
110 | durations.add(System.currentTimeMillis()-start);
111 | break; // TODO
112 | } catch (Exception e) {
113 | Log.e(TAG, "Unable to read file: "+relImgStr);
114 | e.printStackTrace();
115 | return;
116 | }
117 | }
118 |
119 | String resultStr = imgNames.toString();
120 | resultStr = resultStr.substring(1,resultStr.length()-1);
121 | results.println("imgNames, "+resultStr);
122 | resultStr = durations.toString();
123 | resultStr = resultStr.substring(1,resultStr.length()-1);
124 | results.println("rgbImg, "+resultStr);
125 |
126 | durations.clear();
127 | for (Filter filter : profilingFilters) {
128 | for (byte[] img : rgbImages) {
129 | try {
130 | m.put("_rgb_image.rgbimage", img);
131 | long start = System.currentTimeMillis();
132 | filter.process(m);
133 | durations.add(System.currentTimeMillis()-start);
134 | } catch (Exception e) {
135 | Log.e(TAG, "Error running filter");
136 | e.printStackTrace();
137 | return;
138 | }
139 | }
140 | resultStr = durations.toString();
141 | resultStr = resultStr.substring(1,resultStr.length()-1);
142 | results.println(filter.name+", "+resultStr);
143 | }
144 | results.close();
145 | }
146 | };
147 |
148 | @Override
149 | protected void onCreate(Bundle savedInstanceState) {
150 | super.onCreate(savedInstanceState);
151 | context = this.getApplicationContext();
152 |
153 | if (!processingThread.isAlive()) processingThread.start();
154 | }
155 | }
156 |
--------------------------------------------------------------------------------
/android-studio-root/app/app.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
--------------------------------------------------------------------------------
/android-studio-root/facerecognition/src/main/java/edu/cmu/cs/diamond/android/examples/facialrecognition/MainActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Diamond Android - Android library for running Diamond filters
3 | *
4 | * Copyright (c) 2013-2014 Carnegie Mellon University
5 | * All Rights Reserved.
6 | *
7 | * This software is distributed under the terms of the Eclipse Public
8 | * License, Version 1.0 which can be found in the file named LICENSE.
9 | * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS SOFTWARE CONSTITUTES
10 | * RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT
11 | */
12 |
13 | package edu.cmu.cs.diamond.android.examples.facialrecognition;
14 |
15 | import java.io.ByteArrayOutputStream;
16 | import java.io.IOException;
17 | import java.io.InputStream;
18 | import java.util.HashMap;
19 | import java.util.Map;
20 |
21 | import org.apache.commons.io.IOUtils;
22 |
23 | import edu.cmu.cs.diamond.android.Filter;
24 | import edu.cmu.cs.diamond.android.FilterException;
25 | import edu.cmu.cs.diamond.android.examples.facialrecognition.R;
26 | import android.app.Activity;
27 | import android.content.Context;
28 | import android.graphics.ImageFormat;
29 | import android.graphics.Rect;
30 | import android.graphics.YuvImage;
31 | import android.hardware.Camera;
32 | import android.hardware.Camera.PreviewCallback;
33 | import android.hardware.Camera.Size;
34 | import android.os.Bundle;
35 | import android.util.Log;
36 | import android.view.WindowManager;
37 | import android.widget.TextView;
38 |
39 | public class MainActivity extends Activity {
40 | private final String TAG = this.getClass().getSimpleName();
41 |
42 | private Context context;
43 |
44 | private CameraPreview mCamera;
45 | private TextView mClassificationText;
46 |
47 | private Object frameLock = new Object();
48 | private byte[] frameBuffer;
49 | public boolean isRunning = true;
50 |
51 | private PreviewCallback previewCallback = new PreviewCallback() {
52 | public void onPreviewFrame(byte[] frame, Camera cam) {
53 | synchronized (frameLock) {
54 | frameBuffer = frame;
55 | frameLock.notify();
56 | }
57 | }
58 | };
59 |
60 | private Thread processingThread = new Thread() {
61 | public void run() {
62 | String[] faceFilterArgs = {"1.2", "24", "24", "1", "2"};
63 | InputStream ocvXmlIS = context.getResources().openRawResource(R.raw.haarcascade_frontalface);
64 | Filter rgbFilter, faceFilter;
65 | try {
66 | rgbFilter = new Filter(R.raw.rgbimg, context, "RGB", null, null);
67 | byte[] ocvXml = IOUtils.toByteArray(ocvXmlIS);
68 | faceFilter = new Filter(R.raw.ocv_face, context, "OCVFace",
69 | faceFilterArgs, ocvXml);
70 | } catch (IOException e1) {
71 | Log.e(TAG, "Unable to create filter subprocess.");
72 | e1.printStackTrace();
73 | return;
74 | }
75 |
76 | while (isRunning) {
77 | byte[] data = null;
78 | synchronized(frameLock) {
79 | while (frameBuffer == null){
80 | try {
81 | frameLock.wait();
82 | } catch (InterruptedException e) {}
83 | }
84 | data = frameBuffer;
85 | frameBuffer = null;
86 | }
87 | Log.d(TAG, "Got frame, trying to detect face.");
88 | Size cameraImageSize = mCamera.getCamera().getParameters().getPreviewSize();
89 | YuvImage image = new YuvImage(data, ImageFormat.NV21,
90 | cameraImageSize.width, cameraImageSize.height, null);
91 | ByteArrayOutputStream tmpBuffer = new ByteArrayOutputStream();
92 | image.compressToJpeg(new Rect(0, 0, image.getWidth(), image.getHeight()), 90, tmpBuffer);
93 | byte[] jpgFrame = tmpBuffer.toByteArray();
94 | boolean faceInFrame = false;
95 | try {
96 | faceInFrame = isFace(jpgFrame, rgbFilter, faceFilter);
97 | } catch (Exception e) {
98 | mClassificationText.setText("Detection exception.");
99 | e.printStackTrace();
100 | }
101 |
102 | final String classification;
103 | if (faceInFrame) {
104 | Log.i(TAG, "Face detected.");
105 | classification = getString(R.string.classificationTrue);
106 | } else {
107 | Log.i(TAG, "No face detected.");
108 | classification = getString(R.string.classificationFalse);
109 | }
110 | runOnUiThread(new Runnable() {
111 | public void run() {
112 | mClassificationText.setText(classification);
113 | mClassificationText.invalidate();
114 | }
115 | });
116 | }
117 | }
118 | };
119 |
120 | @Override
121 | protected void onCreate(Bundle savedInstanceState) {
122 | super.onCreate(savedInstanceState);
123 | context = this.getApplicationContext();
124 |
125 | setContentView(R.layout.activity_main);
126 | getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED+
127 | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON+
128 | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
129 |
130 |
131 | mCamera = (CameraPreview) findViewById(R.id.cameraPreview);
132 | // mCamera.changeConfiguration(null, null, ImageFormat.NV21);
133 | mClassificationText = (TextView) findViewById(R.id.classificationText);
134 |
135 | mCamera.setPreviewCallback(previewCallback);
136 | processingThread.start();
137 | }
138 |
139 | @Override
140 | protected void onStop() {
141 | super.onStop();
142 | isRunning = false;
143 | try {
144 | processingThread.join();
145 | } catch (InterruptedException e) {
146 | // TODO Auto-generated catch block
147 | e.printStackTrace();
148 | }
149 | }
150 |
151 | private boolean isFace(byte[] jpegImage, Filter rgbFilter, Filter faceFilter) throws IOException, FilterException {
152 | final Map m = new HashMap();
153 | Log.d(TAG, "Sending JPEG image to RGB filter.");
154 | Log.d(TAG, "JPEG image size: " + String.valueOf(jpegImage.length) + " bytes.");
155 |
156 | m.put("", jpegImage);
157 | rgbFilter.process(m);
158 | byte[] rgbImage = m.get("_rgb_image.rgbimage");
159 |
160 | Log.d(TAG, "Obtained RGB image from RGB filter.");
161 | Log.d(TAG, "RGB image size: " + String.valueOf(rgbImage.length) + " bytes.");
162 |
163 | Log.d(TAG, "Sending RGB image to OCV face filter.");
164 | double faceRecognized = faceFilter.process(m);
165 | return Math.abs(faceRecognized-1.0d) < 1E-6;
166 | }
167 | }
168 |
--------------------------------------------------------------------------------
/android-studio-root/diamondandroidlibrary/diamondandroidlibrary.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
--------------------------------------------------------------------------------
/android-studio-root/performance/performance.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
--------------------------------------------------------------------------------
/android-studio-root/performance/facerecognition.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
--------------------------------------------------------------------------------
/android-studio-root/facerecognition/facerecognition.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
--------------------------------------------------------------------------------
/android-studio-root/facerecognition/jni/build-modifications/diamond-core-filters/lib/memstream.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This software is available from http://piumarta.com/software/memstream/
3 | * under the MIT license.
4 | *
5 | * The MIT License (MIT)
6 | *
7 | * Copyright (c) 2013 Ian Piumarta
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in
17 | * all copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | * THE SOFTWARE.
26 | *
27 | * ----------------------------------------------------------------------------
28 | *
29 | * Compile this file and link the object with your program. On a recent
30 | * GNU/Linux machine the object file will be empty. On anything derived from
31 | * 4.4BSD (Darwin, the Three BSDs, etc.) it will contain an implementation of
32 | * open_memstream() as described in the POSIX and Linux manual pages. On
33 | * anything else it will probably cause a compilation error.
34 | *
35 | * ----------------------------------------------------------------------------
36 | *
37 | * OPEN_MEMSTREAM(3) BSD and Linux Library Functions OPEN_MEMSTREAM(3)
38 | *
39 | * SYNOPSIS
40 | * #include "memstream.h"
41 | *
42 | * FILE *open_memstream(char **bufp, size_t *sizep);
43 | *
44 | * DESCRIPTION
45 | * The open_memstream() function opens a stream for writing to a buffer.
46 | * The buffer is dynamically allocated (as with malloc(3)), and
47 | * automatically grows as required. After closing the stream, the caller
48 | * should free(3) this buffer.
49 | *
50 | * When the stream is closed (fclose(3)) or flushed (fflush(3)), the
51 | * locations pointed to by bufp and sizep are updated to contain,
52 | * respectively, a pointer to the buffer and the current size of the
53 | * buffer. These values remain valid only as long as the caller performs
54 | * no further output on the stream. If further output is performed, then
55 | * the stream must again be flushed before trying to access these
56 | * variables.
57 | *
58 | * A null byte is maintained at the end of the buffer. This byte is not
59 | * included in the size value stored at sizep.
60 | *
61 | * The stream's file position can be changed with fseek(3) or fseeko(3).
62 | * Moving the file position past the end of the data already written fills
63 | * the intervening space with zeros.
64 | *
65 | * RETURN VALUE
66 | * Upon successful completion open_memstream() returns a FILE pointer.
67 | * Otherwise, NULL is returned and errno is set to indicate the error.
68 | *
69 | * CONFORMING TO
70 | * POSIX.1-2008
71 | *
72 | * ----------------------------------------------------------------------------
73 | */
74 |
75 | #include "memstream.h"
76 |
77 | #if _POSIX_C_SOURCE < 200809L
78 |
79 | #include
80 | #include
81 | #include
82 | #include
83 | #include
84 |
85 | #define min(X, Y) (((X) < (Y)) ? (X) : (Y))
86 |
87 | struct memstream
88 | {
89 | int position;
90 | int size;
91 | int capacity;
92 | char *contents;
93 | char **ptr;
94 | size_t *sizeloc;
95 | };
96 |
97 | #if MEMSTREAM_DEBUG
98 | static void memstream_print(struct memstream *ms)
99 | {
100 | printf("memstream %p {", ms);
101 | printf(" %i", ms->position);
102 | printf(" %i", ms->size);
103 | printf(" %i", ms->capacity);
104 | printf(" %p", ms->contents);
105 | printf(" }\n");
106 | }
107 | # define memstream_info(ARGS) printf ARGS
108 | #else
109 | # define memstream_print(ms)
110 | # define memstream_info(ARGS)
111 | #endif
112 |
113 | #define memstream_check(MS) if (!(MS)->contents) { errno= ENOMEM; return -1; }
114 |
115 | static int memstream_grow(struct memstream *ms, int minsize)
116 | {
117 | int newcap= ms->capacity * 2; memstream_check(ms);
118 | while (newcap <= minsize) newcap *= 2; memstream_info(("grow %p to %i\n", ms, newcap));
119 | ms->contents= realloc(ms->contents, newcap);
120 | if (!ms->contents) return -1; /* errno == ENOMEM */
121 | memset(ms->contents + ms->capacity, 0, newcap - ms->capacity);
122 | ms->capacity= newcap;
123 | *ms->ptr= ms->contents; /* size has not changed */
124 | return 0;
125 | }
126 |
127 | static int memstream_read(void *cookie, char *buf, int count)
128 | {
129 | struct memstream *ms= (struct memstream *)cookie; memstream_check(ms);
130 | int n= min(ms->size - ms->position, count); memstream_info(("memstream_read %p %i\n", ms, count));
131 | if (n < 1) return 0;
132 | memcpy(buf, ms->contents, n);
133 | ms->position += n; memstream_print(ms);
134 | return n;
135 | }
136 |
137 | static int memstream_write(void *cookie, const char *buf, int count)
138 | {
139 | struct memstream *ms= (struct memstream *)cookie; memstream_check(ms);
140 | if (ms->capacity <= ms->position + count)
141 | if (memstream_grow(ms, ms->position + count) < 0) /* errno == ENOMEM */
142 | return -1;
143 | memcpy(ms->contents + ms->position, buf, count); memstream_info(("memstream_write %p %i\n", ms, count));
144 | ms->position += count;
145 | if (ms->size < ms->position) *ms->sizeloc= ms->size= ms->position; memstream_print(ms);
146 | assert(ms->size < ms->capacity);
147 | assert(ms->contents[ms->size] == 0);
148 | return count;
149 | }
150 |
151 | static fpos_t memstream_seek(void *cookie, fpos_t offset, int whence)
152 | {
153 | struct memstream *ms= (struct memstream *)cookie;
154 | fpos_t pos= 0; memstream_check(ms);
155 | memstream_info(("memstream_seek %p %i %i\n", ms, (int)offset, whence));
156 | switch (whence) {
157 | case SEEK_SET: pos= offset; break;
158 | case SEEK_CUR: pos= ms->position + offset; break;
159 | case SEEK_END: pos= ms->size + offset; break;
160 | default: errno= EINVAL; return -1;
161 | }
162 | if (pos >= ms->capacity) memstream_grow(ms, pos);
163 | ms->position= pos;
164 | if (ms->size < ms->position) *ms->sizeloc= ms->size= ms->position; memstream_print(ms); memstream_info(("=> %i\n", (int)pos));
165 | assert(ms->size < ms->capacity && ms->contents[ms->size] == 0);
166 | return pos;
167 | }
168 |
169 | static int memstream_close(void *cookie)
170 | {
171 | struct memstream *ms= (struct memstream *)cookie; if (!ms->contents) { free(ms); errno= ENOMEM; return -1; }
172 | ms->size= min(ms->size, ms->position);
173 | *ms->ptr= ms->contents;
174 | *ms->sizeloc= ms->size; assert(ms->size < ms->capacity);
175 | ms->contents[ms->size]= 0;
176 | free(ms);
177 | return 0;
178 | }
179 |
180 | FILE *open_memstream(char **ptr, size_t *sizeloc)
181 | {
182 | if (ptr && sizeloc) {
183 | struct memstream *ms= calloc(1, sizeof(struct memstream));
184 | FILE *fp= 0; if (!ms) return 0; /* errno == ENOMEM */
185 | ms->position= ms->size= 0;
186 | ms->capacity= 4096;
187 | ms->contents= calloc(ms->capacity, 1); if (!ms->contents) { free(ms); return 0; } /* errno == ENOMEM */
188 | ms->ptr= ptr;
189 | ms->sizeloc= sizeloc;
190 | memstream_print(ms);
191 | fp= funopen(ms, memstream_read, memstream_write, memstream_seek, memstream_close);
192 | if (!fp) {
193 | free(ms->contents);
194 | free(ms);
195 | return 0; /* errno set by funopen */
196 | }
197 | *ptr= ms->contents;
198 | *sizeloc= ms->size;
199 | return fp;
200 | }
201 | errno= EINVAL;
202 | return 0;
203 | }
204 |
205 | #endif /* _POSIX_C_SOURCE < 200809L */
206 |
--------------------------------------------------------------------------------
/attic/diamond-android-library/src/edu/cmu/cs/diamond/android/Filter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Diamond Android - Diamond filters for the Android platform
3 | *
4 | * Copyright (c) 2013-2014 Carnegie Mellon University
5 | * All Rights Reserved.
6 | *
7 | * This software is distributed under the terms of the Eclipse Public
8 | * License, Version 1.0 which can be found in the file named LICENSE.
9 | * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS SOFTWARE CONSTITUTES
10 | * RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT
11 | */
12 |
13 | package edu.cmu.cs.diamond.android;
14 |
15 | import java.io.BufferedReader;
16 | import java.io.File;
17 | import java.io.FileOutputStream;
18 | import java.io.IOException;
19 | import java.io.InputStream;
20 | import java.io.InputStreamReader;
21 | import java.io.OutputStream;
22 | import java.security.MessageDigest;
23 | import java.util.Map;
24 |
25 | import org.apache.commons.io.FileUtils;
26 | import org.apache.commons.io.IOUtils;
27 |
28 | import edu.cmu.cs.diamond.android.token.*;
29 | import android.content.Context;
30 | import android.content.res.Resources;
31 | import android.util.Log;
32 |
33 | public class Filter {
34 | private final String TAG = this.getClass().getSimpleName();
35 |
36 | public Process proc;
37 | private InputStream is;
38 | private OutputStream os;
39 | private File tempDir;
40 |
41 | public Filter(int resourceId, Context context, String name, String[] args, byte[] blob) throws IOException {
42 | Resources r = context.getResources();
43 | String resourceName = r.getResourceEntryName(resourceId);
44 | File f = context.getFileStreamPath(resourceName);
45 |
46 | if (!f.exists()) {
47 | InputStream ins = r.openRawResource(resourceId);
48 | byte[] buf = IOUtils.toByteArray(ins);
49 | FileOutputStream fos = context.openFileOutput(resourceName, Context.MODE_PRIVATE);
50 | IOUtils.write(buf, fos);
51 | context.getFileStreamPath(resourceName).setExecutable(true);
52 | fos.close();
53 | }
54 |
55 | ProcessBuilder pb = new ProcessBuilder(f.getAbsolutePath());
56 | Map env = pb.environment();
57 | tempDir = File.createTempFile("filter", null, context.getCacheDir());
58 | tempDir.delete(); // Delete file and create directory.
59 | if (!tempDir.mkdir()) {
60 | throw new IOException("Unable to create temporary directory.");
61 | }
62 | env.put("TEMP", tempDir.getAbsolutePath());
63 | env.put("TMPDIR", tempDir.getAbsolutePath());
64 | proc = pb.start();
65 | is = proc.getInputStream();
66 | os = proc.getOutputStream();
67 |
68 | sendInt(1);
69 | sendString(name);
70 | sendStringArray(args);
71 | sendBinary(blob);
72 |
73 | while (this.getNextToken().tag != TagEnum.INIT);
74 | Log.d(TAG, "Filter initialized.");
75 | }
76 |
77 | public void destroy() {
78 | proc.destroy();
79 | try {
80 | FileUtils.deleteDirectory(tempDir);
81 | } catch (IOException e) {
82 | Log.i(TAG, "Failed to destroy temporary directory '"
83 | + tempDir.getAbsolutePath() + "'.");
84 | }
85 | }
86 |
87 | // public static void loadFilters(Context context) throws IOException {
88 | // Resources r = context.getResources();
89 | // for (FilterEnum f : FilterEnum.values()) {
90 | // InputStream ins = r.openRawResource(f.id);
91 | // String name = r.getResourceEntryName(f.id);
92 | // byte[] buf = IOUtils.toByteArray(ins);
93 | // FileOutputStream fos = context.openFileOutput(name, Context.MODE_PRIVATE);
94 | // IOUtils.write(buf, fos);
95 | // context.getFileStreamPath(name).setExecutable(true);
96 | // }
97 | // }
98 |
99 | public double process(Map m) throws IOException, FilterException {
100 | while (true) {
101 | Token t = this.getNextToken();
102 | switch (t.tag) {
103 | case GET:
104 | GetToken gt = (GetToken) t;
105 | if (!m.containsKey(gt.var)) {
106 | throw new FilterException("Value not found in map.");
107 | }
108 | this.sendBinary(m.get(gt.var));
109 | break;
110 | case SET:
111 | SetToken st = (SetToken) t;
112 | m.put(st.var, st.buf);
113 | break;
114 | case RESULT:
115 | ResultToken rt = (ResultToken) t;
116 | return rt.var;
117 | case OMIT:
118 | OmitToken ot = (OmitToken) t;
119 | this.sendBoolean(m.containsKey(ot.var));
120 | case LOG:
121 | break;
122 | default:
123 | throw new FilterException("Unimplemented Token found.");
124 | }
125 | }
126 | }
127 |
128 | private void sendBlank() throws IOException {
129 | IOUtils.write("\n", os);
130 | os.flush();
131 | }
132 |
133 | private void sendBoolean(boolean b) throws IOException {
134 | if (b) sendString("true");
135 | else sendString("false");
136 | }
137 |
138 | private void sendString(String s) throws IOException {
139 | IOUtils.write(Integer.toString(s.length()), os);
140 | sendBlank();
141 | IOUtils.write(s, os);
142 | sendBlank();
143 | os.flush();
144 | }
145 |
146 | private void sendStringArray(String[] a) throws IOException {
147 | if (a != null) {
148 | for (String s : a) sendString(s);
149 | }
150 | sendBlank();
151 | }
152 |
153 | private void sendInt(int i) throws IOException { sendString(Integer.toString(i)); }
154 | private void sendDouble(double d) throws IOException { sendString(Double.toString(d)); }
155 |
156 | private static String getHash(byte[] b) {
157 | try {
158 | MessageDigest md = MessageDigest.getInstance("MD5");
159 | byte[] array = md.digest(b);
160 | StringBuffer sb = new StringBuffer();
161 | for (int i = 0; i < array.length; ++i) {
162 | sb.append(Integer.toHexString((array[i] & 0xFF) | 0x100).substring(1,3));
163 | }
164 | return sb.toString();
165 | } catch (java.security.NoSuchAlgorithmException e) {
166 | }
167 | return null;
168 | }
169 |
170 | private void sendBinary(byte[] b) throws IOException {
171 | if (b == null) {
172 | IOUtils.write("0", os);
173 | }
174 | else {
175 | Log.d(TAG, "SendingBinary: " + getHash(b));
176 | IOUtils.write(Integer.toString(b.length), os);
177 | }
178 | sendBlank();
179 | if (b != null) {
180 | os.write(b);
181 | }
182 | sendBlank();
183 | }
184 |
185 |
186 | private String readLine() throws IOException {
187 | StringBuilder buf = new StringBuilder();
188 | char c = 0;
189 | do {
190 | c = (char) is.read();
191 | if (c != '\n' && c != '\0') buf.append(c);
192 | } while (c != '\n' && c != '\0');
193 | return buf.toString();
194 | }
195 |
196 | private String readTagStr() throws IOException {
197 | return readLine();
198 | }
199 |
200 | private String readString() throws NumberFormatException, IOException {
201 | int len = Integer.parseInt(readLine());
202 | byte[] buf = new byte[len];
203 | int readLen = IOUtils.read(is, buf, 0, len);
204 | if (len != readLen) {
205 | throw new RuntimeException("Error reading all bytes from the InputStream.");
206 | }
207 | is.read();
208 | return new String(buf);
209 | }
210 |
211 | private double readDouble() throws NumberFormatException, IOException {
212 | return Double.parseDouble(readString());
213 | }
214 | private int readInt() throws NumberFormatException, IOException {
215 | return Integer.parseInt(readString());
216 | }
217 |
218 | private byte[] readByteArray() throws IOException {
219 | int len = Integer.parseInt(readLine());
220 | byte[] buf = new byte[len];
221 | int readLen = IOUtils.read(is, buf, 0, len);
222 | if (len != readLen) {
223 | throw new RuntimeException("Error reading all bytes from the InputStream.");
224 | }
225 | is.read();
226 | return buf;
227 | }
228 |
229 | private Token getNextToken() throws IOException {
230 | String tagString = readTagStr();
231 | Log.d(TAG, "=== getNextToken");
232 | Log.d(TAG, "tag: " + tagString);
233 | TagEnum tag = TagEnum.findByStr(tagString);
234 | switch (tag) {
235 | case INIT:
236 | return new Token(tag);
237 | case LOG:
238 | int logLevel = readInt();
239 | String msg = readString();
240 | Log.d(TAG, " msg: " + msg);
241 | return new LogToken(logLevel, msg);
242 | case GET:
243 | String getVar = readString();
244 | Log.d(TAG, " var: " + getVar);
245 | return new GetToken(getVar);
246 | case SET:
247 | String setVar = readString();
248 | Log.d(TAG, " set: " + setVar);
249 | byte[] buf = readByteArray();
250 | Log.d(TAG, " buf.len: " + String.valueOf(buf.length));
251 | return new SetToken(setVar, buf);
252 | case RESULT:
253 | double resVar = readDouble();
254 | return new ResultToken(resVar);
255 | case OMIT:
256 | String omitVar = readString();
257 | Log.d(TAG, " var: " + omitVar);
258 | return new OmitToken(omitVar);
259 | default:
260 | Log.i(TAG, "getNextToken: Warning: " + tagString + " unimplemented.");
261 | return new Token(tag);
262 | }
263 | }
264 |
265 | public void dumpStdoutAndStderr() throws IOException {
266 | new Thread(new Runnable() {
267 | public void run() {
268 | try {
269 | while (true) {
270 | Log.d(TAG, "stdout: "+readLine());
271 | }
272 | } catch (IOException e) { e.printStackTrace(); }
273 | }
274 | }).start();
275 |
276 | new Thread(new Runnable() {
277 | public void run() {
278 | try {
279 | BufferedReader err_br = new BufferedReader(new InputStreamReader(
280 | proc.getErrorStream()));
281 | while (true) {
282 | Log.d(TAG, "stderr: "+err_br.readLine());
283 | }
284 | } catch (IOException e) { e.printStackTrace(); }
285 | }
286 | }).start();
287 | }
288 | }
289 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Eclipse Public License - v 1.0
2 |
3 | THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
4 |
5 | 1. DEFINITIONS
6 |
7 | "Contribution" means:
8 |
9 | a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
10 | b) in the case of each subsequent Contributor:
11 |
12 | i) changes to the Program, and
13 |
14 | ii) additions to the Program;
15 |
16 | where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
17 |
18 | "Contributor" means any person or entity that distributes the Program.
19 |
20 | "Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
21 |
22 | "Program" means the Contributions distributed in accordance with this Agreement.
23 |
24 | "Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
25 |
26 | 2. GRANT OF RIGHTS
27 |
28 | a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
29 |
30 | b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
31 |
32 | c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
33 |
34 | d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
35 |
36 | 3. REQUIREMENTS
37 |
38 | A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
39 |
40 | a) it complies with the terms and conditions of this Agreement; and
41 |
42 | b) its license agreement:
43 |
44 | i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
45 |
46 | ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
47 |
48 | iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
49 |
50 | iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
51 |
52 | When the Program is made available in source code form:
53 |
54 | a) it must be made available under this Agreement; and
55 |
56 | b) a copy of this Agreement must be included with each copy of the Program.
57 |
58 | Contributors may not remove or alter any copyright notices contained within the Program.
59 |
60 | Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
61 |
62 | 4. COMMERCIAL DISTRIBUTION
63 |
64 | Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
65 |
66 | For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
67 |
68 | 5. NO WARRANTY
69 |
70 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
71 |
72 | 6. DISCLAIMER OF LIABILITY
73 |
74 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
75 |
76 | 7. GENERAL
77 |
78 | If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
79 |
80 | If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
81 |
82 | All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
83 |
84 | Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
85 |
86 | This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
87 |
88 |
89 |
--------------------------------------------------------------------------------
/android-studio-root/diamondandroidlibrary/src/main/java/edu/cmu/cs/diamond/android/Filter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Diamond Android - Android library for running Diamond filters
3 | *
4 | * Copyright (c) 2013-2014 Carnegie Mellon University
5 | * All Rights Reserved.
6 | *
7 | * This software is distributed under the terms of the Eclipse Public
8 | * License, Version 1.0 which can be found in the file named LICENSE.
9 | * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS SOFTWARE CONSTITUTES
10 | * RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT
11 | */
12 |
13 | package edu.cmu.cs.diamond.android;
14 |
15 | import java.io.BufferedReader;
16 | import java.io.File;
17 | import java.io.FileOutputStream;
18 | import java.io.IOException;
19 | import java.io.InputStream;
20 | import java.io.InputStreamReader;
21 | import java.io.OutputStream;
22 | import java.security.MessageDigest;
23 | import java.util.Map;
24 |
25 | import org.apache.commons.io.FileUtils;
26 | import org.apache.commons.io.IOUtils;
27 |
28 | import edu.cmu.cs.diamond.android.token.*;
29 | import android.content.Context;
30 | import android.content.res.Resources;
31 | import android.util.Log;
32 |
33 | public class Filter {
34 | private final String TAG = this.getClass().getSimpleName();
35 |
36 | public Process proc;
37 | public String name;
38 | private InputStream is;
39 | private OutputStream os;
40 | private File tempDir;
41 |
42 | public Filter(int resourceId, Context context, String name, String[] args, byte[] blob) throws IOException {
43 | this.name = name;
44 | Resources r = context.getResources();
45 | String resourceName = r.getResourceEntryName(resourceId);
46 | File f = context.getFileStreamPath(resourceName);
47 |
48 | if (!f.exists()) {
49 | InputStream ins = r.openRawResource(resourceId);
50 | byte[] buf = IOUtils.toByteArray(ins);
51 | FileOutputStream fos = context.openFileOutput(resourceName, Context.MODE_PRIVATE);
52 | IOUtils.write(buf, fos);
53 | context.getFileStreamPath(resourceName).setExecutable(true);
54 | fos.close();
55 | }
56 |
57 | ProcessBuilder pb = new ProcessBuilder(f.getAbsolutePath());
58 | Map env = pb.environment();
59 | tempDir = File.createTempFile("filter", null, context.getCacheDir());
60 | tempDir.delete(); // Delete file and create directory.
61 | if (!tempDir.mkdir()) {
62 | throw new IOException("Unable to create temporary directory.");
63 | }
64 | env.put("TEMP", tempDir.getAbsolutePath());
65 | env.put("TMPDIR", tempDir.getAbsolutePath());
66 | proc = pb.start();
67 | is = proc.getInputStream();
68 | os = proc.getOutputStream();
69 |
70 | sendInt(1);
71 | sendString(name);
72 | sendStringArray(args);
73 | sendBinary(blob);
74 |
75 | while (this.getNextToken().tag != TagEnum.INIT);
76 | Log.d(TAG, "Filter initialized.");
77 | }
78 |
79 | public void destroy() {
80 | proc.destroy();
81 | try {
82 | FileUtils.deleteDirectory(tempDir);
83 | } catch (IOException e) {
84 | Log.i(TAG, "Failed to destroy temporary directory '"
85 | + tempDir.getAbsolutePath() + "'.");
86 | }
87 | }
88 |
89 | // public static void loadFilters(Context context) throws IOException {
90 | // Resources r = context.getResources();
91 | // for (FilterEnum f : FilterEnum.values()) {
92 | // InputStream ins = r.openRawResource(f.id);
93 | // String name = r.getResourceEntryName(f.id);
94 | // byte[] buf = IOUtils.toByteArray(ins);
95 | // FileOutputStream fos = context.openFileOutput(name, Context.MODE_PRIVATE);
96 | // IOUtils.write(buf, fos);
97 | // context.getFileStreamPath(name).setExecutable(true);
98 | // }
99 | // }
100 |
101 | public double process(Map m) throws IOException, FilterException {
102 | while (true) {
103 | Token t = this.getNextToken();
104 | switch (t.tag) {
105 | case GET:
106 | GetToken gt = (GetToken) t;
107 | if (!m.containsKey(gt.var)) {
108 | throw new FilterException("Value not found in map.");
109 | }
110 | this.sendBinary(m.get(gt.var));
111 | break;
112 | case SET:
113 | SetToken st = (SetToken) t;
114 | m.put(st.var, st.buf);
115 | break;
116 | case RESULT:
117 | ResultToken rt = (ResultToken) t;
118 | return rt.var;
119 | case OMIT:
120 | OmitToken ot = (OmitToken) t;
121 | this.sendBoolean(m.containsKey(ot.var));
122 | case LOG:
123 | break;
124 | default:
125 | throw new FilterException("Unimplemented Token found.");
126 | }
127 | }
128 | }
129 |
130 | private void sendBlank() throws IOException {
131 | IOUtils.write("\n", os);
132 | os.flush();
133 | }
134 |
135 | private void sendBoolean(boolean b) throws IOException {
136 | if (b) sendString("true");
137 | else sendString("false");
138 | }
139 |
140 | private void sendString(String s) throws IOException {
141 | IOUtils.write(Integer.toString(s.length()), os);
142 | sendBlank();
143 | IOUtils.write(s, os);
144 | sendBlank();
145 | os.flush();
146 | }
147 |
148 | private void sendStringArray(String[] a) throws IOException {
149 | if (a != null) {
150 | for (String s : a) sendString(s);
151 | }
152 | sendBlank();
153 | }
154 |
155 | private void sendInt(int i) throws IOException { sendString(Integer.toString(i)); }
156 | private void sendDouble(double d) throws IOException { sendString(Double.toString(d)); }
157 |
158 | private static String getHash(byte[] b) {
159 | try {
160 | MessageDigest md = MessageDigest.getInstance("MD5");
161 | byte[] array = md.digest(b);
162 | StringBuffer sb = new StringBuffer();
163 | for (int i = 0; i < array.length; ++i) {
164 | sb.append(Integer.toHexString((array[i] & 0xFF) | 0x100).substring(1,3));
165 | }
166 | return sb.toString();
167 | } catch (java.security.NoSuchAlgorithmException e) {
168 | }
169 | return null;
170 | }
171 |
172 | private void sendBinary(byte[] b) throws IOException {
173 | if (b == null) {
174 | IOUtils.write("0", os);
175 | }
176 | else {
177 | Log.d(TAG, "SendingBinary: " + getHash(b));
178 | IOUtils.write(Integer.toString(b.length), os);
179 | }
180 | sendBlank();
181 | if (b != null) {
182 | os.write(b);
183 | }
184 | sendBlank();
185 | }
186 |
187 |
188 | private String readLine() throws IOException {
189 | StringBuilder buf = new StringBuilder();
190 | char c = 0;
191 | do {
192 | c = (char) is.read();
193 | if (c == 65535) {
194 | throw new RuntimeException("Character is 65535 in readLine");
195 | }
196 | if (c != '\n' && c != '\0') buf.append(c);
197 | } while (c != '\n' && c != '\0');
198 | return buf.toString();
199 | }
200 |
201 | private String readTagStr() throws IOException {
202 | return readLine();
203 | }
204 |
205 | private String readString() throws NumberFormatException, IOException {
206 | int len = Integer.parseInt(readLine());
207 | byte[] buf = new byte[len];
208 | int readLen = IOUtils.read(is, buf, 0, len);
209 | if (len != readLen) {
210 | throw new RuntimeException("Error reading all bytes from the InputStream.");
211 | }
212 | is.read();
213 | return new String(buf);
214 | }
215 |
216 | private double readDouble() throws NumberFormatException, IOException {
217 | return Double.parseDouble(readString());
218 | }
219 | private int readInt() throws NumberFormatException, IOException {
220 | return Integer.parseInt(readString());
221 | }
222 |
223 | private byte[] readByteArray() throws IOException {
224 | int len = Integer.parseInt(readLine());
225 | byte[] buf = new byte[len];
226 | int readLen = IOUtils.read(is, buf, 0, len);
227 | if (len != readLen) {
228 | throw new RuntimeException("Error reading all bytes from the InputStream.");
229 | }
230 | is.read();
231 | return buf;
232 | }
233 |
234 | private Token getNextToken() throws IOException {
235 | String tagString = readTagStr();
236 | Log.d(TAG, "=== getNextToken");
237 | Log.d(TAG, "tag: " + tagString);
238 | TagEnum tag = TagEnum.findByStr(tagString);
239 | switch (tag) {
240 | case INIT:
241 | return new Token(tag);
242 | case LOG:
243 | int logLevel = readInt();
244 | String msg = readString();
245 | Log.d(TAG, " msg: " + msg);
246 | return new LogToken(logLevel, msg);
247 | case GET:
248 | String getVar = readString();
249 | Log.d(TAG, " var: " + getVar);
250 | return new GetToken(getVar);
251 | case SET:
252 | String setVar = readString();
253 | Log.d(TAG, " set: " + setVar);
254 | byte[] buf = readByteArray();
255 | Log.d(TAG, " buf.len: " + String.valueOf(buf.length));
256 | return new SetToken(setVar, buf);
257 | case RESULT:
258 | double resVar = readDouble();
259 | return new ResultToken(resVar);
260 | case OMIT:
261 | String omitVar = readString();
262 | Log.d(TAG, " var: " + omitVar);
263 | return new OmitToken(omitVar);
264 | default:
265 | Log.i(TAG, "getNextToken: Warning: " + tagString + " unimplemented.");
266 | return new Token(tag);
267 | }
268 | }
269 |
270 | public void dumpStdoutAndStderr() throws IOException {
271 | new Thread(new Runnable() {
272 | public void run() {
273 | try {
274 | while (true) {
275 | Log.d(TAG, "stdout: "+readLine());
276 | }
277 | } catch (IOException e) { e.printStackTrace(); }
278 | }
279 | }).start();
280 |
281 | new Thread(new Runnable() {
282 | public void run() {
283 | try {
284 | BufferedReader err_br = new BufferedReader(new InputStreamReader(
285 | proc.getErrorStream()));
286 | while (true) {
287 | Log.d(TAG, "stderr: "+err_br.readLine());
288 | }
289 | } catch (IOException e) { e.printStackTrace(); }
290 | }
291 | }).start();
292 | }
293 | }
294 |
--------------------------------------------------------------------------------