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
5aff563a
Commit
5aff563a
authored
Mar 09, 2016
by
Josejulio Martínez Magaña
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code cleanup and refactoring of some classes.
parent
cf363454
Changes
18
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
190 additions
and
153 deletions
+190
-153
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+3
-3
EarIdentifier.java
...c/main/java/com/aluxoft/earrecognition/EarIdentifier.java
+6
-6
EarCaptureActivity.java
...aluxoft/earrecognition/activities/EarCaptureActivity.java
+5
-12
SIFTActivity.java
...a/com/aluxoft/earrecognition/activities/SIFTActivity.java
+15
-13
SelectFollowupActivity.java
...oft/earrecognition/activities/SelectFollowupActivity.java
+11
-6
EarFeature.java
...in/java/com/aluxoft/earrecognition/common/EarFeature.java
+6
-2
NameDistance.java
.../java/com/aluxoft/earrecognition/common/NameDistance.java
+12
-11
Patient.java
.../main/java/com/aluxoft/earrecognition/common/Patient.java
+8
-2
PatientHashMap.java
...ava/com/aluxoft/earrecognition/common/PatientHashMap.java
+32
-0
TopMatchesList.java
...ava/com/aluxoft/earrecognition/common/TopMatchesList.java
+6
-2
IntentTransferFeatures.java
...luxoft/earrecognition/intents/IntentTransferFeatures.java
+14
-14
EarDataLoader.java
...java/com/aluxoft/earrecognition/loader/EarDataLoader.java
+0
-23
PatientLoaderCommcare.java
.../aluxoft/earrecognition/loader/PatientLoaderCommcare.java
+18
-17
FileCache.java
...main/java/com/aluxoft/earrecognition/utils/FileCache.java
+6
-13
ImageUtils.java
...ain/java/com/aluxoft/earrecognition/utils/ImageUtils.java
+5
-3
OpenCvUtils.java
...in/java/com/aluxoft/earrecognition/utils/OpenCvUtils.java
+5
-3
TestConstants.java
app/src/main/java/com/aluxoft/test/TestConstants.java
+0
-23
readme.txt
app/src/main/java/readme.txt
+38
-0
No files found.
app/src/main/AndroidManifest.xml
View file @
5aff563a
...
...
@@ -34,7 +34,7 @@
</activity>
<!-- Take photo intent (Register) -->
<activity
android:name=
".intents.IntentTransfer
ing
Features"
<activity
android:name=
".intents.IntentTransferFeatures"
android:screenOrientation=
"portrait"
>
<intent-filter>
<action
android:name=
"com.auriclon.features"
/>
...
...
@@ -43,7 +43,7 @@
</activity>
<!-- Private API -->
<!-- Call by IntentTransfer
ing
Features (Follow-up) -->
<!-- Call by IntentTransferFeatures (Follow-up) -->
<activity
android:name=
".activities.SelectFollowupActivity"
android:screenOrientation=
"portrait"
>
<intent-filter>
...
...
@@ -51,7 +51,7 @@
<category
android:name=
"android.intent.category.DEFAULT"
/>
</intent-filter>
</activity>
<!-- Call by IntentTransfer
ing
Features, IntentSearchFeatures (Follow-up/Register) -->
<!-- Call by IntentTransferFeatures, IntentSearchFeatures (Follow-up/Register) -->
<activity
android:name=
".activities.SIFTActivity"
android:screenOrientation=
"portrait"
>
<intent-filter>
...
...
app/src/main/java/com/aluxoft/earrecognition/EarIdentifier.java
View file @
5aff563a
package
com
.
aluxoft
.
earrecognition
;
import
com.aluxoft.earrecognition.common.
EarData
;
import
com.aluxoft.earrecognition.common.
PatientHashMap
;
import
com.aluxoft.earrecognition.common.EarFeature
;
import
com.aluxoft.earrecognition.common.
EarId
List
;
import
com.aluxoft.earrecognition.common.
TopMatches
List
;
import
com.aluxoft.earrecognition.utils.OpenCvUtils
;
import
org.opencv.core.Mat
;
...
...
@@ -16,13 +16,13 @@ import org.opencv.highgui.Highgui;
*/
public
class
EarIdentifier
{
private
EarData
database
;
private
PatientHashMap
database
;
public
EarIdentifier
(
EarData
_database
)
{
public
EarIdentifier
(
PatientHashMap
_database
)
{
this
.
database
=
_database
;
}
public
void
setDatabase
(
EarData
_database
)
{
public
void
setDatabase
(
PatientHashMap
_database
)
{
this
.
database
=
_database
;
}
...
...
@@ -31,7 +31,7 @@ public class EarIdentifier {
* @param feature The result of the identification.
* @return
*/
public
EarId
List
identify
(
EarFeature
feature
)
{
public
TopMatches
List
identify
(
EarFeature
feature
)
{
return
null
;
}
...
...
app/src/main/java/com/aluxoft/earrecognition/activities/EarCaptureActivity.java
View file @
5aff563a
/*
Copyright by Boston University, 2016
Authors: Josejulio Martínez, Daniel Kornhauser
Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
*/
package
com
.
aluxoft
.
earrecognition
.
activities
;
import
android.app.Activity
;
import
android.content.ActivityNotFoundException
;
import
android.content.Intent
;
import
android.net.Uri
;
import
android.os.Bundle
;
import
android.view.View
;
import
android.view.View.OnClickListener
;
import
android.widget.Button
;
import
android.widget.Toast
;
import
com.aluxoft.earrecognition.EarIdentifier
;
import
com.aluxoft.earrecognition.R
;
import
com.aluxoft.earrecognition.loader.EarDataLoaderCommcare
;
import
com.aluxoft.earrecognition.utils.ImageUtils
;
import
com.crashlytics.android.Crashlytics
;
import
io.fabric.sdk.android.Fabric
;
import
java.io.File
;
import
java.io.IOException
;
/**
* Activity where we capture ear for recognition.
...
...
app/src/main/java/com/aluxoft/earrecognition/activities/SIFTActivity.java
View file @
5aff563a
/*
Copyright by Boston University, 2016
Authors: Josejulio Martínez, Daniel Kornhauser
Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
*/
package
com
.
aluxoft
.
earrecognition
.
activities
;
import
android.app.Activity
;
...
...
@@ -7,19 +12,16 @@ import android.os.Bundle;
import
com.aluxoft.earrecognition.EarIdentifier
;
import
com.aluxoft.earrecognition.R
;
import
com.aluxoft.earrecognition.common.
EarData
;
import
com.aluxoft.earrecognition.common.
PatientHashMap
;
import
com.aluxoft.earrecognition.common.EarFeature
;
import
com.aluxoft.earrecognition.common.
EarId
List
;
import
com.aluxoft.earrecognition.common.
TopMatches
List
;
import
com.aluxoft.earrecognition.common.NameDistance
;
import
com.aluxoft.earrecognition.common.Person
;
import
com.aluxoft.earrecognition.loader.EarDataLoaderCommcare
;
import
com.aluxoft.earrecognition.loader.PatientLoaderCommcare
;
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
;
import
java.util.List
;
import
java.util.concurrent.Callable
;
...
...
@@ -45,9 +47,9 @@ public class SIFTActivity extends Activity {
loading
.
setCancelable
(
false
);
loading
.
setProgressStyle
(
ProgressDialog
.
STYLE_SPINNER
);
Task
.
callInBackground
(
new
Callable
<
EarId
List
>()
{
Task
.
callInBackground
(
new
Callable
<
TopMatches
List
>()
{
@Override
public
EarId
List
call
()
throws
Exception
{
public
TopMatches
List
call
()
throws
Exception
{
// Sift
EarIdentifier
identifier
=
new
EarIdentifier
(
null
);
Intent
intent
=
SIFTActivity
.
this
.
getIntent
();
...
...
@@ -69,13 +71,13 @@ public class SIFTActivity extends Activity {
imageFile
.
delete
();
// Compares the current features with the database.
EarData
data
=
new
EarData
LoaderCommcare
().
load
(
SIFTActivity
.
this
);
PatientHashMap
data
=
new
Patient
LoaderCommcare
().
load
(
SIFTActivity
.
this
);
data
.
computeDistance
(
earFeature
);
ArrayList
<
NameDistance
>
distances
=
new
ArrayList
<>(
data
.
getPersons
().
values
());
ArrayList
<
NameDistance
>
distances
=
new
ArrayList
<>(
data
.
values
());
Collections
.
sort
(
distances
);
EarIdList
result
=
new
EarId
List
();
TopMatchesList
result
=
new
TopMatches
List
();
List
<
NameDistance
>
topN
=
distances
.
subList
(
0
,
Math
.
min
(
kTopN
,
distances
.
size
()));
result
.
setTop
(
topN
);
...
...
@@ -84,9 +86,9 @@ public class SIFTActivity extends Activity {
return
result
;
}
}).
continueWith
(
new
Continuation
<
EarId
List
,
Object
>()
{
}).
continueWith
(
new
Continuation
<
TopMatches
List
,
Object
>()
{
@Override
public
Object
then
(
Task
<
EarId
List
>
task
)
throws
Exception
{
public
Object
then
(
Task
<
TopMatches
List
>
task
)
throws
Exception
{
Intent
intent
=
new
Intent
(
"com.auriclon.activity_select_user"
);
intent
.
putExtra
(
"list"
,
new
Gson
().
toJson
(
task
.
getResult
()));
setResult
(
0
,
intent
);
...
...
app/src/main/java/com/aluxoft/earrecognition/activities/SelectFollowupActivity.java
View file @
5aff563a
/*
Copyright by Boston University, 2016
Authors: Josejulio Martínez, Daniel Kornhauser
Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
*/
package
com
.
aluxoft
.
earrecognition
.
activities
;
import
android.app.Activity
;
...
...
@@ -10,7 +15,7 @@ import android.widget.Button;
import
android.widget.ListView
;
import
com.aluxoft.earrecognition.R
;
import
com.aluxoft.earrecognition.common.
EarId
List
;
import
com.aluxoft.earrecognition.common.
TopMatches
List
;
import
com.aluxoft.earrecognition.common.NameDistance
;
import
com.google.gson.Gson
;
...
...
@@ -22,12 +27,12 @@ import java.util.UUID;
*/
public
class
SelectFollowupActivity
extends
Activity
{
public
EarIdList
earId
List
=
null
;
public
TopMatchesList
topMatches
List
=
null
;
private
static
final
int
COMMCARE_REGISTER
=
1
;
private
static
final
int
COMMCARE_FOLLOW_UP
=
2
;
//private
EarIdList earId
List;
//private
TopMatchesList topMatches
List;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
...
...
@@ -35,13 +40,13 @@ public class SelectFollowupActivity extends Activity {
setContentView
(
R
.
layout
.
activity_select_user
);
String
list
=
this
.
getIntent
().
getStringExtra
(
"list"
);
this
.
earIdList
=
new
Gson
().
fromJson
(
list
,
EarId
List
.
class
);
this
.
topMatchesList
=
new
Gson
().
fromJson
(
list
,
TopMatches
List
.
class
);
Button
registerButton
=
(
Button
)
findViewById
(
R
.
id
.
register_commcare
);
ArrayAdapter
<
NameDistance
>
arrayAdapter
=
new
ArrayAdapter
<
NameDistance
>(
this
,
android
.
R
.
layout
.
simple_list_item_1
,
this
.
earId
List
.
getTop
()
this
.
topMatches
List
.
getTop
()
);
ListView
topNListView
=
(
ListView
)
findViewById
(
R
.
id
.
topNListView
);
...
...
@@ -52,7 +57,7 @@ public class SelectFollowupActivity extends Activity {
@Override
public
void
onItemClick
(
AdapterView
<?>
parent
,
View
view
,
int
position
,
long
id
)
{
Intent
intent
=
new
Intent
();
intent
.
putExtra
(
"case_id"
,
earIdList
.
getTop
().
get
(
position
).
person
.
getCaseId
());
intent
.
putExtra
(
"case_id"
,
topMatchesList
.
getTop
().
get
(
position
).
patient
.
getCaseId
());
SelectFollowupActivity
.
this
.
setResult
(
Activity
.
RESULT_OK
,
intent
);
finish
();
}
...
...
app/src/main/java/com/aluxoft/earrecognition/common/EarFeature.java
View file @
5aff563a
/*
Copyright by Boston University, 2016
Authors: Josejulio Martínez, Daniel Kornhauser
Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
*/
package
com
.
aluxoft
.
earrecognition
.
common
;
import
com.google.gson.Gson
;
...
...
@@ -11,8 +16,7 @@ import org.opencv.features2d.DescriptorMatcher;
import
java.util.ArrayList
;
/**
* Represents Ear Features
*
* Contains ear features and handles its own (de)serialization.
*/
public
class
EarFeature
{
...
...
app/src/main/java/com/aluxoft/earrecognition/common/NameDistance.java
View file @
5aff563a
/*
Copyright by Boston University, 2016
Authors: Josejulio Martínez, Daniel Kornhauser
Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
*/
package
com
.
aluxoft
.
earrecognition
.
common
;
/**
*
Created by josejuliomartinez on 14/10/15
.
*
Tuple for storing Patient and distance relative to a feature
.
*/
public
class
NameDistance
implements
Comparable
<
NameDistance
>
{
public
double
distance
=
0
;
public
Person
person
=
null
;
public
NameDistance
()
{
}
public
Patient
patient
=
null
;
public
NameDistance
(
double
distance
,
P
erson
person
)
{
this
.
set
(
distance
,
p
erson
);
public
NameDistance
(
double
distance
,
P
atient
patient
)
{
this
.
set
(
distance
,
p
atient
);
}
public
void
set
(
double
distance
,
P
erson
person
)
{
public
void
set
(
double
distance
,
P
atient
patient
)
{
this
.
distance
=
distance
;
this
.
p
erson
=
person
;
this
.
p
atient
=
patient
;
}
@Override
...
...
@@ -33,6 +34,6 @@ public class NameDistance implements Comparable<NameDistance> {
@Override
public
String
toString
()
{
return
this
.
p
erson
.
getName
();
return
this
.
p
atient
.
getName
();
}
}
\ No newline at end of file
app/src/main/java/com/aluxoft/earrecognition/common/P
erson
.java
→
app/src/main/java/com/aluxoft/earrecognition/common/P
atient
.java
View file @
5aff563a
/*
Copyright by Boston University, 2016
Authors: Josejulio Martínez, Daniel Kornhauser
Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
*/
package
com
.
aluxoft
.
earrecognition
.
common
;
import
java.util.ArrayList
;
/**
* Created by josejuliomartinez on 07/10/15.
* Patient data.
* Populated by PatientLoaderCommcare in PatientHashMap.
*/
public
class
P
erson
{
public
class
P
atient
{
private
String
caseId
;
private
String
name
;
...
...
app/src/main/java/com/aluxoft/earrecognition/common/
EarData
.java
→
app/src/main/java/com/aluxoft/earrecognition/common/
PatientHashMap
.java
View file @
5aff563a
/*
Copyright by Boston University, 2016
Authors: Josejulio Martínez, Daniel Kornhauser
Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
*/
package
com
.
aluxoft
.
earrecognition
.
common
;
import
java.util.HashMap
;
/**
*
Created by josejuliomartinez on 06/10/15
.
*
The database of all the ears
.
*
Hashmap to store patients with their NameDistance
.
*
Populated by PatientLoaderCommcare
.
*/
public
class
EarData
{
private
HashMap
<
String
,
NameDistance
>
persons
=
new
HashMap
<
String
,
NameDistance
>();
public
void
addPerson
(
Person
person
)
{
this
.
persons
.
put
(
person
.
getCaseId
(),
new
NameDistance
(
0.0
,
person
));
}
public
class
PatientHashMap
extends
HashMap
<
String
,
NameDistance
>
{
public
HashMap
<
String
,
NameDistance
>
getPersons
(
)
{
return
this
.
persons
;
public
void
addPatient
(
Patient
patient
)
{
this
.
put
(
patient
.
getCaseId
(),
new
NameDistance
(
0.0
,
patient
))
;
}
public
void
computeDistance
(
EarFeature
feature
)
{
for
(
String
caseId
:
this
.
persons
.
keySet
())
{
NameDistance
tuple
=
this
.
persons
.
get
(
caseId
);
for
(
String
caseId
:
this
.
keySet
())
{
NameDistance
tuple
=
this
.
get
(
caseId
);
double
minDistance
=
Double
.
MAX_VALUE
;
for
(
EarFeature
feature2
:
tuple
.
p
erson
.
getFeatures
())
{
for
(
EarFeature
feature2
:
tuple
.
p
atient
.
getFeatures
())
{
minDistance
=
Math
.
min
(
feature
.
distance
(
feature2
),
minDistance
);
}
tuple
.
distance
=
minDistance
;
...
...
app/src/main/java/com/aluxoft/earrecognition/common/
EarId
List.java
→
app/src/main/java/com/aluxoft/earrecognition/common/
TopMatches
List.java
View file @
5aff563a
/*
Copyright by Boston University, 2016
Authors: Josejulio Martínez, Daniel Kornhauser
Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
*/
package
com
.
aluxoft
.
earrecognition
.
common
;
import
java.util.List
;
/**
* Represents top 10 Ear ID matches.
*
*/
public
class
EarId
List
{
public
class
TopMatches
List
{
// Store EarFeatures
// Store Top-x
...
...
app/src/main/java/com/aluxoft/earrecognition/intents/IntentTransfer
ing
Features.java
→
app/src/main/java/com/aluxoft/earrecognition/intents/IntentTransferFeatures.java
View file @
5aff563a
...
...
@@ -19,8 +19,8 @@ import android.widget.Toast;
import
com.aluxoft.earrecognition.EarIdentifier
;
import
com.aluxoft.earrecognition.R
;
import
com.aluxoft.earrecognition.common.
EarId
List
;
import
com.aluxoft.earrecognition.loader.
EarData
LoaderCommcare
;
import
com.aluxoft.earrecognition.common.
TopMatches
List
;
import
com.aluxoft.earrecognition.loader.
Patient
LoaderCommcare
;
import
com.aluxoft.earrecognition.utils.FileCache
;
import
com.aluxoft.earrecognition.utils.ImageUtils
;
import
com.google.gson.Gson
;
...
...
@@ -37,7 +37,7 @@ import java.util.UUID;
*
* Takes the photo, sends to SIFT activity and returns.
*/
public
class
IntentTransfer
ing
Features
extends
Activity
{
public
class
IntentTransferFeatures
extends
Activity
{
public
static
final
int
KEY_REQUEST_IMAGE
=
1
;
public
static
final
int
KEY_SIFT_ACTIVITY_LOADER
=
2
;
...
...
@@ -66,9 +66,9 @@ public class IntentTransferingFeatures extends Activity {
@Override
public
void
onClick
(
View
v
)
{
if
(!
EarDataLoaderCommcare
.
checkConnection
(
IntentTransfering
Features
.
this
))
{
if
(!
PatientLoaderCommcare
.
checkConnection
(
IntentTransfer
Features
.
this
))
{
if
(
loginInCommCareToast
==
null
||
loginInCommCareToast
.
getView
().
getWindowVisibility
()
!=
View
.
VISIBLE
)
{
loginInCommCareToast
=
Toast
.
makeText
(
IntentTransfer
ing
Features
.
this
,
loginInCommCareToast
=
Toast
.
makeText
(
IntentTransferFeatures
.
this
,
"Please login in CommCare application to proceed."
,
Toast
.
LENGTH_LONG
);
loginInCommCareToast
.
show
();
...
...
@@ -87,7 +87,7 @@ public class IntentTransferingFeatures extends Activity {
try
{
startActivityForResult
(
i
,
KEY_REQUEST_IMAGE
);
}
catch
(
ActivityNotFoundException
e
)
{
Toast
.
makeText
(
IntentTransfer
ing
Features
.
this
,
"No Camera"
,
Toast
.
LENGTH_SHORT
).
show
();
Toast
.
makeText
(
IntentTransferFeatures
.
this
,
"No Camera"
,
Toast
.
LENGTH_SHORT
).
show
();
}
}
});
...
...
@@ -114,14 +114,14 @@ public class IntentTransferingFeatures extends Activity {
"odk_intent_data"
,
FileUtils
.
readFileToString
(
FileCache
.
getFile
(
IntentTransfer
ing
Features
.
this
.
getApplicationContext
(),
.
getFile
(
IntentTransferFeatures
.
this
.
getApplicationContext
(),
FileCache
.
FileCacheType
.
Features
)
)
);
IntentTransfer
ing
Features
.
this
.
setResult
(
Activity
.
RESULT_OK
,
returningIntent
);
IntentTransferFeatures
.
this
.
setResult
(
Activity
.
RESULT_OK
,
returningIntent
);
finish
();
}
catch
(
Exception
e
)
{
Toast
.
makeText
(
IntentTransfer
ing
Features
.
this
,
Toast
.
makeText
(
IntentTransferFeatures
.
this
,
"An error occurred when loading the features."
,
Toast
.
LENGTH_LONG
);
cachePictureButton
.
setEnabled
(
false
);
}
...
...
@@ -130,7 +130,7 @@ public class IntentTransferingFeatures extends Activity {
}
if
(
this
.
getLastNonConfigurationInstance
()
!=
null
)
{
location
=
((
IntentTransfer
ing
Features
)
this
.
getLastNonConfigurationInstance
()).
location
;
location
=
((
IntentTransferFeatures
)
this
.
getLastNonConfigurationInstance
()).
location
;
}
if
(
savedInstanceState
!=
null
)
{
...
...
@@ -156,7 +156,7 @@ public class IntentTransferingFeatures extends Activity {
// Fetches features from SIFT activity to return to CommCare
_showTransferringMessage
();
String
list
=
data
.
getStringExtra
(
"list"
);
EarIdList
earIdList
=
new
Gson
().
fromJson
(
list
,
EarId
List
.
class
);
TopMatchesList
topMatchesList
=
new
Gson
().
fromJson
(
list
,
TopMatches
List
.
class
);
Intent
returningIntent
=
new
Intent
(
getIntent
());
Bundle
responses
=
new
Bundle
();
...
...
@@ -165,15 +165,15 @@ public class IntentTransferingFeatures extends Activity {
returningIntent
.
putExtra
(
"odk_intent_data"
,
earId
List
.
getCurrentFeature
().
serializeFeatures
()
topMatches
List
.
getCurrentFeature
().
serializeFeatures
()
);
IntentTransfer
ing
Features
.
this
.
setResult
(
Activity
.
RESULT_OK
,
returningIntent
);
IntentTransferFeatures
.
this
.
setResult
(
Activity
.
RESULT_OK
,
returningIntent
);
finish
();
}
}
private
void
_showTransferringMessage
()
{
loading
=
ProgressDialog
.
show
(
IntentTransfer
ing
Features
.
this
,
loading
=
ProgressDialog
.
show
(
IntentTransferFeatures
.
this
,
"Transferring"
,
"Please wait while transferring the features..."
);
loading
.
setCancelable
(
false
);
loading
.
setProgressStyle
(
ProgressDialog
.
STYLE_SPINNER
);
...
...
app/src/main/java/com/aluxoft/earrecognition/loader/EarDataLoader.java
deleted
100644 → 0
View file @
cf363454
package
com
.
aluxoft
.
earrecognition
.
loader
;
import
android.app.Activity
;
import
com.aluxoft.earrecognition.common.EarData
;
/**
* Loads Case Id data from CommCare
*
*/
abstract
public
class
EarDataLoader
{
public
abstract
EarData
load
(
Activity
current
);
/**
* Updates the database (only implemented if we can update the database)
* @param database
*/
public
void
update
(
EarData
database
)
{
}
}
app/src/main/java/com/aluxoft/earrecognition/loader/
EarData
LoaderCommcare.java
→
app/src/main/java/com/aluxoft/earrecognition/loader/
Patient
LoaderCommcare.java
View file @
5aff563a
/*
Copyright by Boston University, 2016
Authors: Josejulio Martínez, Daniel Kornhauser
Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
*/
package
com
.
aluxoft
.
earrecognition
.
loader
;
import
android.app.Activity
;
import
android.database.Cursor
;
import
android.net.Uri
;
import
com.aluxoft.earrecognition.common.
EarData
;
import
com.aluxoft.earrecognition.common.
PatientHashMap
;
import
com.aluxoft.earrecognition.common.EarFeature
;
import
com.aluxoft.earrecognition.common.P
erson
;
import
com.aluxoft.earrecognition.common.P
atient
;
/**
* Created by josejuliomartinez on 13/10/15.
*/
public
class
EarDataLoaderCommcare
extends
EarDataLoader
{
public
class
PatientLoaderCommcare
{
public
static
boolean
checkConnection
(
Activity
current
)
{
Cursor
c
=
current
.
managedQuery
(
Uri
.
parse
(
"content://org.commcare.dalvik.case/casedb/case"
),
null
,
null
,
null
,
null
);
return
c
!=
null
;
}
@Override
public
EarData
load
(
Activity
current
)
{
public
PatientHashMap
load
(
Activity
current
)
{
EarData
earData
=
new
EarData
();
PatientHashMap
patientHashMap
=
new
PatientHashMap
();
Cursor
c
=
current
.
managedQuery
(
Uri
.
parse
(
"content://org.commcare.dalvik.case/casedb/case"
),
null
,
null
,
null
,
null
);
if
(
c
==
null
)
{
// Throw an exception (Unable to connect to commcare)
return
earData
;
return
patientHashMap
;
}
String
caseId
;
...
...
@@ -59,14 +60,14 @@ public class EarDataLoaderCommcare extends EarDataLoader {
if
(
/*gender == null || */
features
==
null
)
{
continue
;
}
P
erson
person
=
new
Person
();
p
erson
.
setCaseId
(
caseId
);
p
erson
.
setName
(
name
);
p
erson
.
setGender
(
gender
);
p
erson
.
addFeature
(
new
EarFeature
(
features
));
earData
.
addPerson
(
person
);
P
atient
patient
=
new
Patient
();
p
atient
.
setCaseId
(
caseId
);
p
atient
.
setName
(
name
);
p
atient
.
setGender
(
gender
);
p
atient
.
addFeature
(
new
EarFeature
(
features
));
patientHashMap
.
addPatient
(
patient
);
}
return
earData
;
return
patientHashMap
;
}
}
app/src/main/java/com/aluxoft/earrecognition/utils/FileCache.java
View file @
5aff563a
/*
Copyright by Boston University, 2016
Authors: Josejulio Martínez, Daniel Kornhauser
Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
*/
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
;
...
...
@@ -32,7 +28,7 @@ public class FileCache extends File {
private
String
filename
;
private
FileCacheType
(
String
filename
)
{
FileCacheType
(
String
filename
)
{
this
.
filename
=
filename
;
}
}
...
...
@@ -72,7 +68,4 @@ public class FileCache extends File {
}
}
}
app/src/main/java/com/aluxoft/earrecognition/utils/ImageUtils.java
View file @
5aff563a
/*
Copyright by Boston University, 2016
Authors: Josejulio Martínez, Daniel Kornhauser
Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
*/
package
com
.
aluxoft
.
earrecognition
.
utils
;
import
android.os.Environment
;
...
...
@@ -7,9 +12,6 @@ import java.io.IOException;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
/**
* Created by josejuliomartinez on 08/10/15.
*/
public
class
ImageUtils
{
public
static
File
createTempImageFile
()
throws
IOException
{
...
...
app/src/main/java/com/aluxoft/earrecognition/utils/OpenCvUtils.java
View file @
5aff563a
/*
Copyright by Boston University, 2016
Authors: Josejulio Martínez, Daniel Kornhauser
Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
*/
package
com
.
aluxoft
.
earrecognition
.
utils
;
import
org.opencv.core.Mat
;
import
org.opencv.core.Size
;
import
org.opencv.imgproc.Imgproc
;
/**
* Created by josejuliomartinez on 08/10/15.
*/
public
class
OpenCvUtils
{
public
static
void
resizeMat
(
Mat
image
,
double
maxWidth
,
double
maxHeight
)
{
...
...
app/src/main/java/com/aluxoft/test/TestConstants.java
deleted
100644 → 0
View file @
cf363454
/**
* Created by josejuliomartinez on 24/09/15.
*/
package
com
.
aluxoft
.
test
;
public
class
TestConstants
{
// ----- For testing purposes ----------------------------------------
static
final
String
image1
=
"/storage/emulated/0/DCIM/Camera/000_down_ear.jpg"
;
static
final
String
image2
=
"/storage/emulated/0/DCIM/Camera/001_front_ear.jpg"
;
static
final
String
image3
=
"/storage/emulated/0/DCIM/Camera/000_front_ear.jpg"
;
static
final
String
image4
=
"/storage/emulated/0/DCIM/Camera/test_1.png"
;
static
final
String
image5
=
"/storage/emulated/0/DCIM/Camera/test_3.png"
;
static
final
String
image6
=
"/storage/emulated/0/DCIM/Camera/test_2.png"
;
static
final
String
image_patty_01
=
"/storage/emulated/0/DCIM/Camera/PATTY_01.jpg"
;
static
final
String
image_patty_02
=
"/storage/emulated/0/DCIM/Camera/PATTY_02.jpg"
;
static
final
String
image_elena_01
=
"/storage/emulated/0/DCIM/Camera/ELENA_01.jpg"
;
static
final
String
image_elena_02
=
"/storage/emulated/0/DCIM/Camera/ELENA_02.jpg"
;
// ---------------------------------------------------------------------
}
app/src/main/java/readme.txt
0 → 100644
View file @
5aff563a
I Entry points:
---------------
A IntentSearchFeatures:
Called by CommCare to identify ear during followup
1 EarCaptureActivity
Camera to capture ear image or choose last taken photo.
2 SIFTActivity
Receives images from EarCaptureActivity
Computes EarFeature of image and retrieves features with PatientLoaderCommCare
For every Patient in PatientHashMap calculates the Distance with the EarFeature
Sends TopMatchesList to next activity
3 SelectFollowupActivity
Receives and displays TopMatchesList for selection of patient.
Returns selected match or register instruction to CommCare
B IntentTransferFeatures:
Called by CommCare to store features during registration
1 EarCaptureActivity
Camera to capture ear image or choose last taken photo.
2 SIFTActivity
Computes features of image and return them to CommCare
II Utils:
--------
FileCache
Handles temporary files for images and features.
ImageUtils
Handles camera image location and name
OpenCvUtils
Resizes matrix to speed up features
\ No newline at end of file
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