Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
Ear recognition
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Boston University
Ear recognition
Commits
c473fb88
Commit
c473fb88
authored
Nov 25, 2015
by
Josejulio Martínez Magaña
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improves the way we store the features for handing them to the registration form.
parent
3fe79632
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
102 additions
and
7 deletions
+102
-7
build.gradle
app/build.gradle
+1
-0
SIFTActivity.java
...a/com/aluxoft/earrecognition/activities/SIFTActivity.java
+14
-1
SelectFollowupActivity.java
...oft/earrecognition/activities/SelectFollowupActivity.java
+0
-4
IntentTransferingFeatures.java
...oft/earrecognition/intents/IntentTransferingFeatures.java
+9
-2
FileCache.java
...main/java/com/aluxoft/earrecognition/utils/FileCache.java
+78
-0
No files found.
app/build.gradle
View file @
c473fb88
...
...
@@ -29,4 +29,5 @@ dependencies {
compile
project
(
':openCVLibrary2411'
)
compile
'com.parse.bolts:bolts-android:1.2.1'
compile
'com.google.code.gson:gson:2.3'
compile
group:
'commons-io'
,
name:
'commons-io'
,
version:
'2.0.1'
}
app/src/main/java/com/aluxoft/earrecognition/activities/SIFTActivity.java
View file @
c473fb88
...
...
@@ -13,9 +13,11 @@ import com.aluxoft.earrecognition.common.EarIdList;
import
com.aluxoft.earrecognition.common.NameDistance
;
import
com.aluxoft.earrecognition.common.Person
;
import
com.aluxoft.earrecognition.loader.EarDataLoaderCommcare
;
import
com.aluxoft.earrecognition.utils.FileCache
;
import
com.google.gson.Gson
;
import
java.io.File
;
import
java.nio.channels.FileChannel
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Collections
;
...
...
@@ -52,8 +54,19 @@ public class SIFTActivity extends Activity {
Bundle
extras
=
intent
.
getExtras
();
String
imagePath
=
(
String
)
extras
.
get
(
"image_path"
);
EarFeature
earFeature
=
identifier
.
computeFeatures
(
imagePath
);
File
imageFile
=
new
File
(
imagePath
);
FileCache
.
getFile
(
SIFTActivity
.
this
.
getApplicationContext
(),
FileCache
.
FileCacheType
.
Image
)
.
replaceContent
(
imageFile
);
FileCache
.
getFile
(
SIFTActivity
.
this
,
FileCache
.
FileCacheType
.
Features
)
.
replaceContent
(
earFeature
.
serializeFeatures
());
// Once we have the features, we can delete the image.
new
File
(
imagePath
)
.
delete
();
imageFile
.
delete
();
// Compares the current features with the database.
EarData
data
=
new
EarDataLoaderCommcare
().
load
(
SIFTActivity
.
this
);
...
...
app/src/main/java/com/aluxoft/earrecognition/activities/SelectFollowupActivity.java
View file @
c473fb88
...
...
@@ -20,8 +20,6 @@ import com.google.gson.Gson;
*/
public
class
SelectFollowupActivity
extends
Activity
{
public
static
String
currentSerializedEar
;
public
EarIdList
earIdList
=
null
;
private
static
final
int
COMMCARE_REGISTER
=
1
;
...
...
@@ -36,8 +34,6 @@ public class SelectFollowupActivity extends Activity {
String
list
=
this
.
getIntent
().
getStringExtra
(
"list"
);
this
.
earIdList
=
new
Gson
().
fromJson
(
list
,
EarIdList
.
class
);
SelectFollowupActivity
.
currentSerializedEar
=
this
.
earIdList
.
getCurrentFeature
().
serializeFeatures
();
Button
registerButton
=
(
Button
)
findViewById
(
R
.
id
.
register_commcare
);
ArrayAdapter
<
NameDistance
>
arrayAdapter
=
new
ArrayAdapter
<
NameDistance
>(
...
...
app/src/main/java/com/aluxoft/earrecognition/intents/IntentTransferingFeatures.java
View file @
c473fb88
...
...
@@ -6,6 +6,9 @@ import android.content.Intent;
import
android.os.Bundle
;
import
com.aluxoft.earrecognition.activities.SelectFollowupActivity
;
import
com.aluxoft.earrecognition.utils.FileCache
;
import
org.apache.commons.io.FileUtils
;
import
java.util.concurrent.Callable
;
...
...
@@ -40,8 +43,12 @@ public class IntentTransferingFeatures extends Activity {
Intent
returningIntent
=
new
Intent
(
getIntent
());
returningIntent
.
putExtra
(
"odk_intent_data"
,
//"Hello World"
SelectFollowupActivity
.
currentSerializedEar
FileUtils
.
readFileToString
(
FileCache
.
getFile
(
IntentTransferingFeatures
.
this
.
getApplicationContext
(),
FileCache
.
FileCacheType
.
Features
)
)
);
IntentTransferingFeatures
.
this
.
setResult
(
Activity
.
RESULT_OK
,
returningIntent
);
finish
();
...
...
app/src/main/java/com/aluxoft/earrecognition/utils/FileCache.java
0 → 100644
View file @
c473fb88
package
com
.
aluxoft
.
earrecognition
.
utils
;
import
android.app.Application
;
import
android.content.Context
;
import
android.os.Environment
;
import
org.apache.commons.io.FileUtils
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.PrintWriter
;
import
java.nio.channels.FileChannel
;
/**
* Created by josejuliomartinez on 25/11/15.
*/
public
class
FileCache
extends
File
{
private
static
final
long
invalidationThreshold
;
static
{
// One hour.
invalidationThreshold
=
1000
*
60
*
60
;
}
public
enum
FileCacheType
{
Image
(
"Auriclon_image_file.jpg"
),
Features
(
"Auriclon_features_file.json"
);
private
String
filename
;
private
FileCacheType
(
String
filename
)
{
this
.
filename
=
filename
;
}
}
private
FileCache
(
File
dir
,
String
name
)
{
super
(
dir
,
name
);
}
public
static
FileCache
getFile
(
Context
context
,
FileCacheType
type
)
{
File
dir
=
context
.
getCacheDir
();
return
new
FileCache
(
dir
,
type
.
filename
);
}
public
boolean
isValid
()
{
return
(
System
.
currentTimeMillis
()
-
this
.
lastModified
())
<
FileCache
.
invalidationThreshold
;
}
public
boolean
replaceContent
(
String
content
)
{
try
{
this
.
delete
();
this
.
createNewFile
();
FileUtils
.
writeStringToFile
(
this
,
content
);
}
catch
(
IOException
e
)
{
return
false
;
}
return
true
;
}
public
boolean
replaceContent
(
File
imageFile
)
{
try
{
this
.
delete
();
this
.
createNewFile
();
FileUtils
.
copyFile
(
imageFile
,
this
,
false
);
return
true
;
}
catch
(
IOException
exception
)
{
return
false
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment