migrated code to public repository
This commit is contained in:
parent
a7df82d7a4
commit
f34dc653e5
233 changed files with 16279 additions and 186 deletions
41
code/recording/util/GazeHelper/.gitignore
vendored
Normal file
41
code/recording/util/GazeHelper/.gitignore
vendored
Normal file
|
@ -0,0 +1,41 @@
|
|||
.gradle
|
||||
/local.properties
|
||||
/.idea/workspace.xml
|
||||
/.idea/libraries
|
||||
.DS_Store
|
||||
/build
|
||||
/captures
|
||||
|
||||
### Android ###
|
||||
# Built application files
|
||||
*.apk
|
||||
*.ap_
|
||||
|
||||
# Files for the Dalvik VM
|
||||
*.dex
|
||||
|
||||
# Java class files
|
||||
*.class
|
||||
|
||||
# Generated files
|
||||
bin/
|
||||
gen/
|
||||
|
||||
# Gradle files
|
||||
.gradle/
|
||||
build/
|
||||
|
||||
# Local configuration file (sdk path, etc)
|
||||
local.properties
|
||||
|
||||
# Proguard folder generated by Eclipse
|
||||
proguard/
|
||||
|
||||
# Log Files
|
||||
*.log
|
||||
|
||||
# Android Studio Navigation editor temp files
|
||||
.navigation/
|
||||
|
||||
### Android Patch ###
|
||||
gen-external-apklibs
|
1
code/recording/util/GazeHelper/.idea/.name
generated
Normal file
1
code/recording/util/GazeHelper/.idea/.name
generated
Normal file
|
@ -0,0 +1 @@
|
|||
GazeHelper
|
22
code/recording/util/GazeHelper/.idea/compiler.xml
generated
Normal file
22
code/recording/util/GazeHelper/.idea/compiler.xml
generated
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<resourceExtensions />
|
||||
<wildcardResourcePatterns>
|
||||
<entry name="!?*.java" />
|
||||
<entry name="!?*.form" />
|
||||
<entry name="!?*.class" />
|
||||
<entry name="!?*.groovy" />
|
||||
<entry name="!?*.scala" />
|
||||
<entry name="!?*.flex" />
|
||||
<entry name="!?*.kt" />
|
||||
<entry name="!?*.clj" />
|
||||
<entry name="!?*.aj" />
|
||||
</wildcardResourcePatterns>
|
||||
<annotationProcessing>
|
||||
<profile default="true" name="Default" enabled="false">
|
||||
<processorPath useClasspath="true" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
</component>
|
||||
</project>
|
3
code/recording/util/GazeHelper/.idea/copyright/profiles_settings.xml
generated
Normal file
3
code/recording/util/GazeHelper/.idea/copyright/profiles_settings.xml
generated
Normal file
|
@ -0,0 +1,3 @@
|
|||
<component name="CopyrightManager">
|
||||
<settings default="" />
|
||||
</component>
|
19
code/recording/util/GazeHelper/.idea/gradle.xml
generated
Normal file
19
code/recording/util/GazeHelper/.idea/gradle.xml
generated
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="distributionType" value="LOCAL" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="gradleHome" value="$APPLICATION_HOME_DIR$/gradle/gradle-2.2.1" />
|
||||
<option name="gradleJvm" value="1.8" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
<option value="$PROJECT_DIR$/app" />
|
||||
</set>
|
||||
</option>
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
22
code/recording/util/GazeHelper/.idea/misc.xml
generated
Normal file
22
code/recording/util/GazeHelper/.idea/misc.xml
generated
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="EntryPointsManager">
|
||||
<entry_points version="2.0" />
|
||||
</component>
|
||||
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
|
||||
<OptionsSetting value="true" id="Add" />
|
||||
<OptionsSetting value="true" id="Remove" />
|
||||
<OptionsSetting value="true" id="Checkout" />
|
||||
<OptionsSetting value="true" id="Update" />
|
||||
<OptionsSetting value="true" id="Status" />
|
||||
<OptionsSetting value="true" id="Edit" />
|
||||
<ConfirmationsSetting value="0" id="Add" />
|
||||
<ConfirmationsSetting value="0" id="Remove" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
<option name="id" value="Android" />
|
||||
</component>
|
||||
</project>
|
9
code/recording/util/GazeHelper/.idea/modules.xml
generated
Normal file
9
code/recording/util/GazeHelper/.idea/modules.xml
generated
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/GazeHelper.iml" filepath="$PROJECT_DIR$/GazeHelper.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
6
code/recording/util/GazeHelper/.idea/vcs.xml
generated
Normal file
6
code/recording/util/GazeHelper/.idea/vcs.xml
generated
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="" />
|
||||
</component>
|
||||
</project>
|
19
code/recording/util/GazeHelper/GazeHelper.iml
Normal file
19
code/recording/util/GazeHelper/GazeHelper.iml
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module external.linked.project.id="GazeHelper" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="java-gradle" name="Java-Gradle">
|
||||
<configuration>
|
||||
<option name="BUILD_FOLDER_PATH" value="$MODULE_DIR$/build" />
|
||||
<option name="BUILDABLE" value="false" />
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
1
code/recording/util/GazeHelper/app/.gitignore
vendored
Normal file
1
code/recording/util/GazeHelper/app/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/build
|
95
code/recording/util/GazeHelper/app/app.iml
Normal file
95
code/recording/util/GazeHelper/app/app.iml
Normal file
|
@ -0,0 +1,95 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module external.linked.project.id=":app" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="GazeHelper" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="android-gradle" name="Android-Gradle">
|
||||
<configuration>
|
||||
<option name="GRADLE_PROJECT_PATH" value=":app" />
|
||||
</configuration>
|
||||
</facet>
|
||||
<facet type="android" name="Android">
|
||||
<configuration>
|
||||
<option name="SELECTED_BUILD_VARIANT" value="debug" />
|
||||
<option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />
|
||||
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
|
||||
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
|
||||
<option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" />
|
||||
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugAndroidTest" />
|
||||
<option name="COMPILE_JAVA_TEST_TASK_NAME" value="compileDebugAndroidTestSources" />
|
||||
<option name="TEST_SOURCE_GEN_TASK_NAME" value="generateDebugAndroidTestSources" />
|
||||
<option name="ALLOW_USER_CONFIGURATION" value="false" />
|
||||
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
|
||||
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
|
||||
<option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res" />
|
||||
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="false">
|
||||
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
|
||||
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/androidTest/debug" />
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/debug" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/debug" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/debug" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/debug" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/androidTest/debug" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/coverage-instrumented-classes" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.0.1/jars" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/23.0.1/jars" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/libs" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/ndk" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" exported="" name="support-v4-23.0.1" level="project" />
|
||||
<orderEntry type="library" exported="" name="appcompat-v7-23.0.1" level="project" />
|
||||
<orderEntry type="library" exported="" name="support-annotations-23.0.1" level="project" />
|
||||
</component>
|
||||
</module>
|
25
code/recording/util/GazeHelper/app/build.gradle
Normal file
25
code/recording/util/GazeHelper/app/build.gradle
Normal file
|
@ -0,0 +1,25 @@
|
|||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 23
|
||||
buildToolsVersion "22.0.1"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "gazehelper.android.mmbrian.com.gazehelper"
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 23
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||
compile 'com.android.support:appcompat-v7:23.0.1'
|
||||
}
|
17
code/recording/util/GazeHelper/app/proguard-rules.pro
vendored
Normal file
17
code/recording/util/GazeHelper/app/proguard-rules.pro
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in /home/mmbrian/Android/Sdk/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="gazehelper.android.mmbrian.com.gazehelper" >
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme" >
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:label="@string/app_name" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
|
@ -0,0 +1,108 @@
|
|||
package gazehelper.android.mmbrian.com.gazehelper;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.media.AudioManager;
|
||||
import android.media.ToneGenerator;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.ViewFlipper;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
|
||||
public class MainActivity extends Activity {
|
||||
|
||||
public static final String CLASS_TAG = "GazeHelper";
|
||||
|
||||
ViewFlipper flipper;
|
||||
Button btn_start;
|
||||
EditText txt_gaze_dur, txt_bgaze_dur, txt_ngaze;
|
||||
TextView txt_stats;
|
||||
|
||||
int gaze_dur, bgaze_dur, ngaze, cgaze;
|
||||
long total_dur, start_time;
|
||||
|
||||
static Timer timer;
|
||||
ToneGenerator toneG;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
flipper = (ViewFlipper)findViewById(R.id.flipper);
|
||||
|
||||
txt_gaze_dur = (EditText)findViewById(R.id.txt_gaze_dur);
|
||||
txt_bgaze_dur = (EditText)findViewById(R.id.txt_bgaze_dur);
|
||||
txt_ngaze = (EditText)findViewById(R.id.txt_ngaze);
|
||||
|
||||
txt_stats = (TextView)findViewById(R.id.txt_stats);
|
||||
|
||||
timer = new Timer("Gaze Timer");
|
||||
toneG = new ToneGenerator(AudioManager.STREAM_MUSIC, 100);
|
||||
|
||||
btn_start = (Button)findViewById(R.id.btn_start);
|
||||
btn_start.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
txt_stats.setText("Starting...");
|
||||
|
||||
gaze_dur = Integer.valueOf(txt_gaze_dur.getText().toString());
|
||||
bgaze_dur = Integer.valueOf(txt_bgaze_dur.getText().toString());
|
||||
ngaze = Integer.valueOf(txt_ngaze.getText().toString());
|
||||
total_dur = (ngaze * gaze_dur + (ngaze - 1) * bgaze_dur) * 1000; // in milliseconds
|
||||
|
||||
flipper.showNext();
|
||||
|
||||
cgaze = 0;
|
||||
start_time = -1;
|
||||
Log.d(CLASS_TAG, "Started...");
|
||||
timer = new Timer("Gaze Timer");
|
||||
timer.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateUI();
|
||||
}
|
||||
});
|
||||
}
|
||||
}, bgaze_dur * 1000, (gaze_dur + bgaze_dur) * 1000); // initial delay, recall delay
|
||||
// first gaze is after 2 bgaze durations, later gazes start after a bgaze
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void updateUI() {
|
||||
Log.d(CLASS_TAG, cgaze + "/" + ngaze);
|
||||
if (cgaze++ >= ngaze) {
|
||||
txt_stats.setText("Finished :)");
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
flipper.showPrevious();
|
||||
}
|
||||
});
|
||||
}
|
||||
}, gaze_dur * 1000);
|
||||
timer.cancel();
|
||||
return;
|
||||
}
|
||||
toneG.startTone(ToneGenerator.TONE_CDMA_ALERT_CALL_GUARD, 200);
|
||||
|
||||
// if (start_time < 0)
|
||||
// start_time = System.currentTimeMillis();
|
||||
// txt_stats.setText((System.currentTimeMillis()-start_time)/1000 + "");
|
||||
txt_stats.setText("Gaze at Target #" + cgaze);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">
|
||||
|
||||
<ViewFlipper
|
||||
android:id="@+id/flipper"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:layout_centerInParent="true">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/txt_gaze_dur"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="Gaze Duration (Seconds)"
|
||||
android:inputType="number"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/txt_bgaze_dur"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="Between-Gaze Duration (Seconds)"
|
||||
android:inputType="number"/>
|
||||
<EditText
|
||||
android:id="@+id/txt_ngaze"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="Number of Targets"
|
||||
android:inputType="number"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_start"
|
||||
style="@android:style/TextAppearance.DeviceDefault.Medium"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Start"/>
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txt_stats"
|
||||
style="@android:style/TextAppearance.DeviceDefault.Large"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:gravity="center"
|
||||
android:text=""/>
|
||||
</ViewFlipper>
|
||||
|
||||
|
||||
</RelativeLayout>
|
|
@ -0,0 +1,6 @@
|
|||
<resources>
|
||||
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
|
||||
(such as screen margins) for screens with more than 820dp of available width. This
|
||||
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
|
||||
<dimen name="activity_horizontal_margin">64dp</dimen>
|
||||
</resources>
|
|
@ -0,0 +1,5 @@
|
|||
<resources>
|
||||
<!-- Default screen margins, per the Android Design guidelines. -->
|
||||
<dimen name="activity_horizontal_margin">16dp</dimen>
|
||||
<dimen name="activity_vertical_margin">16dp</dimen>
|
||||
</resources>
|
|
@ -0,0 +1,6 @@
|
|||
<resources>
|
||||
<string name="app_name">GazeHelper</string>
|
||||
|
||||
<string name="hello_world">Hello world!</string>
|
||||
<string name="action_settings">Settings</string>
|
||||
</resources>
|
|
@ -0,0 +1,8 @@
|
|||
<resources>
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
</style>
|
||||
|
||||
</resources>
|
19
code/recording/util/GazeHelper/build.gradle
Normal file
19
code/recording/util/GazeHelper/build.gradle
Normal file
|
@ -0,0 +1,19 @@
|
|||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:1.2.3'
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
}
|
18
code/recording/util/GazeHelper/gradle.properties
Normal file
18
code/recording/util/GazeHelper/gradle.properties
Normal file
|
@ -0,0 +1,18 @@
|
|||
# Project-wide Gradle settings.
|
||||
|
||||
# IDE (e.g. Android Studio) users:
|
||||
# Gradle settings configured through the IDE *will override*
|
||||
# any settings specified in this file.
|
||||
|
||||
# For more details on how to configure your build environment visit
|
||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||
|
||||
# Specifies the JVM arguments used for the daemon process.
|
||||
# The setting is particularly useful for tweaking memory settings.
|
||||
# Default value: -Xmx10248m -XX:MaxPermSize=256m
|
||||
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
|
||||
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. More details, visit
|
||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||
# org.gradle.parallel=true
|
6
code/recording/util/GazeHelper/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
6
code/recording/util/GazeHelper/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
#Wed Apr 10 15:27:10 PDT 2013
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
|
164
code/recording/util/GazeHelper/gradlew
vendored
Normal file
164
code/recording/util/GazeHelper/gradlew
vendored
Normal file
|
@ -0,0 +1,164 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS=""
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn ( ) {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die ( ) {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
esac
|
||||
|
||||
# For Cygwin, ensure paths are in UNIX format before anything is touched.
|
||||
if $cygwin ; then
|
||||
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
|
||||
fi
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >&-
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >&-
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
case $i in
|
||||
(0) set -- ;;
|
||||
(1) set -- "$args0" ;;
|
||||
(2) set -- "$args0" "$args1" ;;
|
||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
|
||||
function splitJvmOpts() {
|
||||
JVM_OPTS=("$@")
|
||||
}
|
||||
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
|
||||
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
|
||||
|
||||
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
|
90
code/recording/util/GazeHelper/gradlew.bat
vendored
Normal file
90
code/recording/util/GazeHelper/gradlew.bat
vendored
Normal file
|
@ -0,0 +1,90 @@
|
|||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windowz variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
if "%@eval[2+2]" == "4" goto 4NT_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
goto execute
|
||||
|
||||
:4NT_args
|
||||
@rem Get arguments from the 4NT Shell from JP Software
|
||||
set CMD_LINE_ARGS=%$
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
1
code/recording/util/GazeHelper/settings.gradle
Normal file
1
code/recording/util/GazeHelper/settings.gradle
Normal file
|
@ -0,0 +1 @@
|
|||
include ':app'
|
102
code/recording/util/SingleMarkerVisualizer/CalibrationBoard.pde
Normal file
102
code/recording/util/SingleMarkerVisualizer/CalibrationBoard.pde
Normal file
|
@ -0,0 +1,102 @@
|
|||
|
||||
float marker_image_width;
|
||||
float screen_border_width;
|
||||
|
||||
float mark_pause; // seconds
|
||||
|
||||
// Represents a 9-point grid calibration board
|
||||
class CalibrationBoard {
|
||||
PVector[] marks;
|
||||
float xgap, ygap, xOffset, yOffset;
|
||||
|
||||
// standard order for 9point grid, starting from center and then clockwise
|
||||
int[] inds = new int[] {1, 2, 3, 8, 0, 4, 7, 6, 5};
|
||||
public void shuffleCalibrationOrder() { // Fisher–Yates shuffle
|
||||
for (int i = inds.length - 1; i > 0; i--)
|
||||
{
|
||||
int index = int(random(0, i + 1));
|
||||
int tmp = inds[index];
|
||||
inds[index] = inds[i];
|
||||
inds[i] = tmp;
|
||||
}
|
||||
}
|
||||
public void generateInds(int grid_width) {
|
||||
inds = new int[grid_width*grid_width];
|
||||
for (int i=0; i<inds.length; i++) {
|
||||
inds[i] = i;
|
||||
}
|
||||
}
|
||||
|
||||
public CalibrationBoard(int mode, int grid_width, float xOffset, float yOffset, float xgap, float ygap) {
|
||||
if (mode == 1) {
|
||||
this.xOffset = xOffset;
|
||||
this.yOffset = yOffset;
|
||||
generateInds(grid_width);
|
||||
shuffleCalibrationOrder();
|
||||
|
||||
if (xgap == -1 || ygap == -1) {
|
||||
computeGridMarks(grid_width, false);
|
||||
} else {
|
||||
this.xgap = xgap;
|
||||
this.ygap = ygap;
|
||||
computeGridMarks(grid_width, true);
|
||||
}
|
||||
} else {
|
||||
int num = grid_width; // num of calibration points
|
||||
inds = new int[num];
|
||||
for (int i=0; i<inds.length; i++)
|
||||
inds[i] = i;
|
||||
generateRandomMarks();
|
||||
}
|
||||
}
|
||||
|
||||
public void generateRandomMarks() {
|
||||
float w = width - 2*screen_border_width - marker_image_width;
|
||||
float xOffset = screen_border_width + marker_image_width/2.;
|
||||
float h = height - 2*screen_border_width - marker_image_width;
|
||||
float yOffset = screen_border_width + marker_image_width/2.;
|
||||
float x, y;
|
||||
marks = new PVector[inds.length];
|
||||
for (int i=0; i<inds.length; i++) {
|
||||
x = random(0, w);
|
||||
y = random(0, h);
|
||||
marks[inds[i]] = new PVector(x + xOffset, y + yOffset);
|
||||
}
|
||||
}
|
||||
|
||||
public void computeGridMarks(int grid_width, boolean custom_gap_size) {
|
||||
float w = width - 2*screen_border_width;
|
||||
float h = height - 2*screen_border_width;
|
||||
if (!custom_gap_size) {
|
||||
xgap = (w - grid_width*marker_image_width)/float(grid_width-1);
|
||||
ygap = (h - grid_width*marker_image_width)/float(grid_width-1);
|
||||
}
|
||||
marks = new PVector[grid_width*grid_width];
|
||||
float x, y;
|
||||
int c = 0;
|
||||
for (int i=0; i<grid_width; i++) {
|
||||
y = i * (ygap + marker_image_width) + screen_border_width + yOffset;
|
||||
y += marker_image_width/2.;
|
||||
for (int j=0; j<grid_width; j++) {
|
||||
x = j * (xgap + marker_image_width) + screen_border_width + xOffset;
|
||||
x += marker_image_width/2.;
|
||||
marks[inds[c++]] = new PVector(x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void drawMarks() {
|
||||
for (int i=0; i<marks.length; i++) {
|
||||
drawMark(marks[i]);
|
||||
fill(0);
|
||||
//text(i + "", marks[i].x + 3, marks[i].y - 5);
|
||||
}
|
||||
}
|
||||
|
||||
private void drawMark(PVector pos) {
|
||||
int w = 13;
|
||||
stroke(0);
|
||||
line(pos.x - w, pos.y, pos.x + w, pos.y);
|
||||
line(pos.x, pos.y - w, pos.x, pos.y + w);
|
||||
}
|
||||
}
|
69
code/recording/util/SingleMarkerVisualizer/Marker.pde
Normal file
69
code/recording/util/SingleMarkerVisualizer/Marker.pde
Normal file
|
@ -0,0 +1,69 @@
|
|||
|
||||
int marker_stroke_weight;
|
||||
int marker_stroke_width;
|
||||
float marker_move_step;
|
||||
|
||||
class Marker {
|
||||
PVector p, c;
|
||||
float w, h;
|
||||
PImage image;
|
||||
|
||||
PVector dest;
|
||||
boolean onDest;
|
||||
|
||||
public Marker(PImage img) {
|
||||
this.image = img;
|
||||
this.w = img.width;
|
||||
this.h = img.height;
|
||||
this.c = new PVector(width/2., height/2.);
|
||||
this.p = new PVector(c.x - w/2., c.y - h/2.);
|
||||
this.dest = this.p;
|
||||
this.onDest = true;
|
||||
}
|
||||
|
||||
public void draw() {
|
||||
image(image, p.x, p.y);
|
||||
stroke(255, 0, 0);
|
||||
strokeWeight(marker_stroke_weight);
|
||||
line(c.x - marker_stroke_width, c.y, c.x + marker_stroke_width, c.y);
|
||||
line(c.x, c.y - marker_stroke_width, c.x, c.y + marker_stroke_width);
|
||||
}
|
||||
|
||||
public void update() {
|
||||
if (p.x != dest.x || p.y != dest.y) {
|
||||
onDest = false;
|
||||
PVector diff = dest.get();
|
||||
diff.sub(p);
|
||||
if (diff.mag() > marker_move_step) {
|
||||
diff.normalize();
|
||||
moveX(diff.x * marker_move_step);
|
||||
moveY(diff.y * marker_move_step);
|
||||
} else {
|
||||
setX(dest.x);
|
||||
setY(dest.y);
|
||||
}
|
||||
} else {
|
||||
onDest = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void moveX(float step) {
|
||||
this.p.x += step;
|
||||
this.c.x += step;
|
||||
}
|
||||
|
||||
public void moveY(float step) {
|
||||
this.p.y += step;
|
||||
this.c.y += step;
|
||||
}
|
||||
|
||||
public void setX(float x) {
|
||||
this.p.x = x;
|
||||
this.c.x = x + w/2.;
|
||||
}
|
||||
|
||||
public void setY(float y) {
|
||||
this.p.y = y;
|
||||
this.c.y = y + h/2.;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,177 @@
|
|||
Marker marker;
|
||||
CalibrationBoard gc, gc_test;
|
||||
String status = "not started";
|
||||
|
||||
int mark_pause_start = -1;
|
||||
int curr_mark = 0;
|
||||
boolean pause = true;
|
||||
boolean finished = false;
|
||||
boolean display_marks = true;
|
||||
boolean calibration_mode = true;
|
||||
boolean display_stats = true;
|
||||
|
||||
float start_delay = 3;
|
||||
int count_down_begin;
|
||||
|
||||
void setup() {
|
||||
fullScreen();
|
||||
//size(640, 480);
|
||||
frameRate(60);
|
||||
screen_border_width = 0;
|
||||
mark_pause = 2.0; // in seconds
|
||||
marker_stroke_weight = 4;
|
||||
marker_stroke_width = 13;
|
||||
marker_move_step = 7;
|
||||
|
||||
|
||||
PImage img = loadImage("1023.png");
|
||||
marker_image_width = img.width;
|
||||
marker = new Marker(img);
|
||||
|
||||
gc = new CalibrationBoard(1, 5, 0, 0, -1, -1); // means 5-point grid
|
||||
gc_test = new CalibrationBoard(1, 4, (gc.xgap + marker_image_width)/2., (gc.ygap + marker_image_width)/2., gc.xgap, gc.ygap);
|
||||
|
||||
resetMarker();
|
||||
}
|
||||
|
||||
void reset() {
|
||||
mark_pause_start = -1;
|
||||
curr_mark = 0;
|
||||
pause = true;
|
||||
finished = false;
|
||||
display_marks = true;
|
||||
calibration_mode = true;
|
||||
|
||||
gc = new CalibrationBoard(1, 5, 0, 0, -1, -1); // means 5-point grid
|
||||
gc_test = new CalibrationBoard(1, 4, (gc.xgap + marker_image_width)/2., (gc.ygap + marker_image_width)/2., gc.xgap, gc.ygap);
|
||||
resetMarker();
|
||||
}
|
||||
|
||||
void resetMarker() {
|
||||
float x, y;
|
||||
if (calibration_mode) {
|
||||
x = gc.marks[curr_mark].x - marker_image_width/2.;
|
||||
y = gc.marks[curr_mark].y - marker_image_width/2.;
|
||||
} else {
|
||||
x = gc_test.marks[curr_mark].x - marker_image_width/2.;
|
||||
y = gc_test.marks[curr_mark].y - marker_image_width/2.;
|
||||
}
|
||||
marker.dest = new PVector(x, y);
|
||||
marker.setX(x);
|
||||
marker.setY(y);
|
||||
}
|
||||
|
||||
|
||||
void draw() {
|
||||
background(255);
|
||||
if (!finished) {
|
||||
marker.draw();
|
||||
marker.update();
|
||||
}
|
||||
|
||||
if (!pause) {
|
||||
if (frameCount - count_down_begin > start_delay * frameRate) {
|
||||
status = "started";
|
||||
if (marker.onDest) {
|
||||
if (mark_pause_start < 0) {
|
||||
mark_pause_start = frameCount;
|
||||
} else {
|
||||
status = ((frameCount - mark_pause_start) / frameRate) + "";
|
||||
if (frameCount - mark_pause_start > mark_pause * frameRate) {
|
||||
if ((calibration_mode && curr_mark < gc.inds.length-1) || (!calibration_mode && curr_mark < gc_test.inds.length-1)) {
|
||||
PVector destC;
|
||||
if (calibration_mode) {
|
||||
destC = gc.marks[++curr_mark];
|
||||
} else {
|
||||
destC = gc_test.marks[++curr_mark];
|
||||
}
|
||||
marker.dest = new PVector(destC.x - marker_image_width/2., destC.y - marker_image_width/2.);
|
||||
} else {
|
||||
status = "finished";
|
||||
finished = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
status = "moving";
|
||||
mark_pause_start = -1;
|
||||
}
|
||||
} else {
|
||||
text(((frameCount - count_down_begin)/frameRate) + "/" + start_delay, width/2, height-7);
|
||||
}
|
||||
} else {
|
||||
status = "paused";
|
||||
}
|
||||
|
||||
if (display_marks) {
|
||||
gc.drawMarks();
|
||||
gc_test.drawMarks();
|
||||
}
|
||||
|
||||
//fill(255, 0, 0);
|
||||
//noStroke();
|
||||
//ellipse(marker.dest.x, marker.dest.y, 5, 5);
|
||||
|
||||
//fill(0, 0, 255);
|
||||
//for (PVector m: gc.marks) {
|
||||
// ellipse(m.x - marker_image_width/2., m.y - marker_image_width/2., 5, 5);
|
||||
//}
|
||||
|
||||
|
||||
if (finished) {
|
||||
fill(255, 0, 0);
|
||||
} else if (pause) {
|
||||
fill(0);
|
||||
} else {
|
||||
fill(0, 0, 255);
|
||||
}
|
||||
|
||||
if (display_stats) {
|
||||
text("status: " + status, 3, 13);
|
||||
String progress;
|
||||
if (calibration_mode) {
|
||||
progress = (curr_mark+1) + "/" + gc.inds.length;
|
||||
} else {
|
||||
progress = (curr_mark+1) + "/" + gc_test.inds.length;
|
||||
}
|
||||
text(progress, 3, height-7);
|
||||
}
|
||||
}
|
||||
|
||||
void keyPressed() {
|
||||
println(keyCode);
|
||||
switch (keyCode) {
|
||||
case 32: // Space Button
|
||||
pause = !pause;
|
||||
display_marks = false;
|
||||
if (!pause)
|
||||
count_down_begin = frameCount;
|
||||
break;
|
||||
case 77: // M key
|
||||
display_marks = !display_marks;
|
||||
break;
|
||||
case 67: // C key
|
||||
curr_mark = 0;
|
||||
calibration_mode = true;
|
||||
println("calibration mode");
|
||||
resetMarker();
|
||||
break;
|
||||
case 84: // T key
|
||||
curr_mark = 0;
|
||||
calibration_mode = false;
|
||||
println("test mode");
|
||||
resetMarker();
|
||||
break;
|
||||
case 82: // R key
|
||||
reset();
|
||||
break;
|
||||
case 83: // S key
|
||||
saveFrame("screenshot_###.png");
|
||||
break;
|
||||
case 72: // H key
|
||||
display_stats = !display_stats;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
mode.id=processing.mode.java.JavaMode
|
||||
mode=Java
|
0
code/recording/util/__init__.py
Normal file
0
code/recording/util/__init__.py
Normal file
18
code/recording/util/check_pupil_positions.py
Normal file
18
code/recording/util/check_pupil_positions.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
from __future__ import division
|
||||
import numpy as np
|
||||
import os, sys
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
path = sys.argv[1]
|
||||
time_stamps = np.load(os.path.join(path, 'world_timestamps.npy'))
|
||||
pts = np.load(os.path.join(path, 'pupil_positions.npy'))
|
||||
valid = filter(lambda e: e[1] > 0, pts) # filter all with zero confidence
|
||||
csum = sum(e[1] for e in pts)
|
||||
print 'Ratio: %s' % round(len(valid)*100/len(pts), 2) + '%'
|
||||
if len(valid):
|
||||
print 'Average Confidence:', csum/len(valid)
|
||||
print 'Frames: %s' % len(time_stamps)
|
||||
except Exception, err:
|
||||
print 'Something went wrong.'
|
||||
print err
|
201
code/recording/util/markers/marker.py
Normal file
201
code/recording/util/markers/marker.py
Normal file
|
@ -0,0 +1,201 @@
|
|||
import os, sys
|
||||
import Image
|
||||
from random import sample
|
||||
|
||||
'''
|
||||
IMPORTANT:
|
||||
- When printing images generated with this code you HAVE to ignore page margins! (use GIMP)
|
||||
- Markers on a board must be separated by white borders or ArUco won't detect them
|
||||
'''
|
||||
|
||||
ARUCO_MARKER_CREATOR = '/home/mmbrian/temp/aruco-1.3.0/build/utils/aruco_create_marker '
|
||||
DESTINATION_DIR = '/home/mmbrian/HiWi/etra2016_mohsen/code/recording/util/markers/'
|
||||
DEFAULT_MARKER_SIZE_IN_PIXELS = 64
|
||||
DEFAULT_MARKER_BORDER_IN_PIXELS = 7 # only applies for random boards
|
||||
DEFAULT_MARKER_SIZE_IN_MM = 40
|
||||
A4_PADDING_IN_PIXELS = 50
|
||||
|
||||
|
||||
def createMarker(marker_id, size_in_pixels, format = 'png'):
|
||||
assert marker_id >= 0 and marker_id < 1024, 'Invalid Marker ID. Must be in Range 0-1023'
|
||||
cmd = ARUCO_MARKER_CREATOR + '{0} ' + DESTINATION_DIR + '{0}.' + format + ' {1} 0'
|
||||
os.popen(cmd.format(marker_id, size_in_pixels))
|
||||
|
||||
def handleMarkers():
|
||||
'''
|
||||
Usage:
|
||||
marker.py num_of_markers size_in_pixels
|
||||
marker.py -i marker_id size_in_pixels
|
||||
'''
|
||||
if len(sys.argv) > 3:
|
||||
try:
|
||||
createMarker(int(sys.argv[2]), int(sys.argv[3]))
|
||||
except:
|
||||
print 'Usage: marker.py -i marker_id size_in_pixels'
|
||||
else:
|
||||
try:
|
||||
num = int(sys.argv[1])
|
||||
assert num>0 and num<=1024
|
||||
except:
|
||||
print 'Invalid number of markers. please specify a number between 1 and 1024'
|
||||
return
|
||||
|
||||
size = DEFAULT_MARKER_SIZE_IN_PIXELS
|
||||
try:
|
||||
size = int(sys.argv[2])
|
||||
print 'Marker size set to', size, 'px'
|
||||
except:
|
||||
print 'Marker size set to default size', size, 'px'
|
||||
|
||||
print 'Creating', num, 'random markers...'
|
||||
|
||||
generateRandomMarkers(num, size)
|
||||
|
||||
def generateRandomMarkers(num, size):
|
||||
# for i in range(num):
|
||||
for i, _id in enumerate(sorted(sample(range(1024), num))):
|
||||
createMarker(_id, size)
|
||||
print i+1, '/', num
|
||||
print 'Finished.'
|
||||
|
||||
def computeDimensions():
|
||||
A4W, A4H = 210, 297 # A4 dimension in millimeters
|
||||
MM2IN = 25.4 # millimeters per inch
|
||||
dpi = -1 # Must be given (use xdpyinfo under linux)
|
||||
marker_width = -1 # Arbitrary value which must be given by user (in millimeters)
|
||||
|
||||
try:
|
||||
dpi = int(sys.argv[2])
|
||||
assert dpi>0
|
||||
except:
|
||||
print sys.argv
|
||||
print 'Invalid dpi.'
|
||||
return
|
||||
|
||||
marker_width = DEFAULT_MARKER_SIZE_IN_MM
|
||||
try:
|
||||
marker_width = int(sys.argv[3])
|
||||
print 'Marker size set to', marker_width, 'mm'
|
||||
except:
|
||||
print 'Marker size set to default size', marker_width, 'mm'
|
||||
|
||||
# Width and Height of A4 image in pixels
|
||||
xWidth = A4W / MM2IN * dpi
|
||||
yWidth = A4H / MM2IN * dpi
|
||||
# Marker width in pixels
|
||||
mWidth = marker_width / MM2IN * dpi
|
||||
|
||||
e = mWidth - int(mWidth) # subpixel error in marker width
|
||||
eMM = e / dpi * MM2IN # subpixel error in millimeters (report to user)
|
||||
print 'Marker size finally set to', marker_width - eMM, 'mm'
|
||||
|
||||
# Converting pixel values to real integers
|
||||
xWidth, yWidth, mWidth = int(xWidth), int(yWidth), int(mWidth)
|
||||
return xWidth, yWidth, mWidth
|
||||
|
||||
def removeMarkers():
|
||||
print 'Removing old markers...'
|
||||
os.popen('rm ' + DESTINATION_DIR + '*.png') # Removing previous markers
|
||||
|
||||
def generateGrid():
|
||||
'''
|
||||
Generates a picture of a 9-point calibration grid using random markers, the size of which is
|
||||
calculated such that after printing the marker size is of a specified length in millimeters
|
||||
|
||||
Usage: marker.py dpi marker_size_in_mm
|
||||
'''
|
||||
xWidth, yWidth, mWidth = computeDimensions()
|
||||
|
||||
# Create markers with this pixel size
|
||||
removeMarkers()
|
||||
print 'Generating new markers...'
|
||||
generateRandomMarkers(9, mWidth)
|
||||
|
||||
# Stitch markers and generate grid
|
||||
print 'Creating grid...'
|
||||
markers = []
|
||||
for f in os.listdir(DESTINATION_DIR):
|
||||
if f.endswith('.png'):
|
||||
markers.append(Image.open(f))
|
||||
|
||||
grid = Image.new("RGB", (xWidth, yWidth), (255, 255, 255))
|
||||
for row in range(3):
|
||||
if row == 0:
|
||||
y = A4_PADDING_IN_PIXELS
|
||||
elif row == 1:
|
||||
y = (yWidth - mWidth) / 2
|
||||
else:
|
||||
y = yWidth - A4_PADDING_IN_PIXELS - mWidth
|
||||
for col in range(3):
|
||||
if col == 0:
|
||||
x = A4_PADDING_IN_PIXELS
|
||||
elif col == 1:
|
||||
x = (xWidth - mWidth) / 2
|
||||
else:
|
||||
x = xWidth - A4_PADDING_IN_PIXELS - mWidth
|
||||
|
||||
grid.paste(markers[row*3+col], (x, y))
|
||||
|
||||
grid.save(DESTINATION_DIR + 'grid_board/grid.jpg')
|
||||
print 'Finished.'
|
||||
|
||||
def generateRandomBoard():
|
||||
xWidth, yWidth, mWidth = computeDimensions()
|
||||
# Get number of random markers
|
||||
try:
|
||||
n = int(sys.argv[4])
|
||||
assert n>0 and n<150 # no more than 150 markers allowed
|
||||
except:
|
||||
print 'Please choose between 1 to 20 markers'
|
||||
return
|
||||
|
||||
# Create markers with this pixel size
|
||||
removeMarkers()
|
||||
print 'Generating new markers...'
|
||||
generateRandomMarkers(n, mWidth)
|
||||
|
||||
# Stitch markers and generate board
|
||||
print 'Creating board...'
|
||||
markers = []
|
||||
for f in os.listdir(DESTINATION_DIR):
|
||||
if f.endswith('.png'):
|
||||
markers.append(Image.open(f))
|
||||
|
||||
board = Image.new("RGB", (xWidth, yWidth), (255, 255, 255))
|
||||
# Now we have to randomly append markers to board in a way that they do not collide
|
||||
# To simplify this, we gridify the image based on marker size and choose a random sample
|
||||
# of grids (not entirely random but in case markers are small enough it gives a good sample)
|
||||
w = (xWidth - 2*A4_PADDING_IN_PIXELS) / mWidth
|
||||
h = (yWidth - 2*A4_PADDING_IN_PIXELS) / mWidth
|
||||
w, h = int(w), int(h) # w and h are maximum row and column size for the grid
|
||||
# Now markers would take w*mWidth pixels in a row with no borders, applying border size:
|
||||
w = ((xWidth - 2*A4_PADDING_IN_PIXELS) - (w-1)*DEFAULT_MARKER_BORDER_IN_PIXELS) / mWidth
|
||||
h = ((yWidth - 2*A4_PADDING_IN_PIXELS) - (h-1)*DEFAULT_MARKER_BORDER_IN_PIXELS) / mWidth
|
||||
w, h = int(w), int(h) # w and h now also count for marker borders
|
||||
|
||||
xOffset = A4_PADDING_IN_PIXELS + ((xWidth - 2*A4_PADDING_IN_PIXELS) - w*mWidth - (w-1)*DEFAULT_MARKER_BORDER_IN_PIXELS)/2
|
||||
yOffset = A4_PADDING_IN_PIXELS + ((yWidth - 2*A4_PADDING_IN_PIXELS) - h*mWidth - (h-1)*DEFAULT_MARKER_BORDER_IN_PIXELS)/2
|
||||
grids = [(xOffset + c*mWidth + c*DEFAULT_MARKER_BORDER_IN_PIXELS,
|
||||
yOffset + r*mWidth + r*DEFAULT_MARKER_BORDER_IN_PIXELS) for r in xrange(h) for c in xrange(w)]
|
||||
print len(grids), 'possible positions exist for markers...'
|
||||
|
||||
n = min(n, len(grids))
|
||||
for i, pos in enumerate(sample(grids, n)):
|
||||
board.paste(markers[i], pos)
|
||||
|
||||
board.save(DESTINATION_DIR + 'random_board/board.jpg')
|
||||
print 'Finished.'
|
||||
|
||||
def main():
|
||||
assert len(sys.argv) > 1, 'Invalid number of arguments.'
|
||||
|
||||
if sys.argv[1] == 'grid':
|
||||
generateGrid()
|
||||
elif sys.argv[1] == 'rand':
|
||||
generateRandomBoard()
|
||||
else:
|
||||
handleMarkers()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
44
code/recording/util/tools.py
Normal file
44
code/recording/util/tools.py
Normal file
|
@ -0,0 +1,44 @@
|
|||
from __future__ import division
|
||||
import numpy as np
|
||||
|
||||
'''
|
||||
Reference: https://stackoverflow.com/questions/22354094/pythonic-way-of-detecting-outliers-in-one-dimensional-observation-data
|
||||
'''
|
||||
|
||||
def is_outlier(points, thresh=3.5):
|
||||
"""
|
||||
Returns a boolean array with True if points are outliers and False
|
||||
otherwise.
|
||||
|
||||
Parameters:
|
||||
-----------
|
||||
points : An numobservations by numdimensions array of observations
|
||||
thresh : The modified z-score to use as a threshold. Observations with
|
||||
a modified z-score (based on the median absolute deviation) greater
|
||||
than this value will be classified as outliers.
|
||||
|
||||
Returns:
|
||||
--------
|
||||
mask : A numobservations-length boolean array.
|
||||
|
||||
References:
|
||||
----------
|
||||
Boris Iglewicz and David Hoaglin (1993), "Volume 16: How to Detect and
|
||||
Handle Outliers", The ASQC Basic References in Quality Control:
|
||||
Statistical Techniques, Edward F. Mykytka, Ph.D., Editor.
|
||||
"""
|
||||
if len(points.shape) == 1:
|
||||
points = points[:,None]
|
||||
median = np.median(points, axis=0)
|
||||
diff = np.sum((points - median)**2, axis=-1)
|
||||
diff = np.sqrt(diff)
|
||||
med_abs_deviation = np.median(diff)
|
||||
|
||||
modified_z_score = 0.6745 * diff / med_abs_deviation
|
||||
|
||||
return modified_z_score > thresh
|
||||
|
||||
|
||||
def moving_average(interval, window_size):
|
||||
window = np.ones(int(window_size))/float(window_size)
|
||||
return np.convolve(interval, window, 'same')
|
Loading…
Add table
Add a link
Reference in a new issue