Passes the ear features to the next Actitivity.

parent 180e5455
...@@ -7,6 +7,9 @@ import android.os.Bundle; ...@@ -7,6 +7,9 @@ import android.os.Bundle;
import com.aluxoft.earrecognition.EarIdentifier; import com.aluxoft.earrecognition.EarIdentifier;
import com.aluxoft.earrecognition.R; import com.aluxoft.earrecognition.R;
import com.aluxoft.earrecognition.common.EarFeature;
import com.aluxoft.earrecognition.common.EarIdList;
import com.google.gson.Gson;
import java.io.File; import java.io.File;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
...@@ -29,25 +32,33 @@ public class SIFTActivity extends Activity { ...@@ -29,25 +32,33 @@ public class SIFTActivity extends Activity {
loading.setCancelable(false); loading.setCancelable(false);
loading.setProgressStyle(ProgressDialog.STYLE_SPINNER); loading.setProgressStyle(ProgressDialog.STYLE_SPINNER);
Task.callInBackground(new Callable<Object>() { Task.callInBackground(new Callable<EarIdList>() {
@Override @Override
public Object call() throws Exception { public EarIdList call() throws Exception {
synchronized (this) { // Sift
// Sift EarIdentifier identifier = new EarIdentifier(null);
EarIdentifier identifier = new EarIdentifier(null); Intent intent = SIFTActivity.this.getIntent();
Intent intent = SIFTActivity.this.getIntent(); Bundle extras = intent.getExtras();
Bundle extras = intent.getExtras(); String imagePath = (String)extras.get("image_path");
String imagePath = (String)extras.get("image_path"); EarFeature earFeature = identifier.computeFeatures(imagePath);
String features = identifier.computeFeatures(imagePath); // Once we have the features, we can delete the image.
// Once we have the features, we can delete the image. new File(imagePath).delete();
new File(imagePath).delete();
} // Compares the current features with the database.
return null; EarIdList result = new EarIdList();
// Generate the top-x.
// Pass results to next activity.
result.setCurrentFeature(earFeature);
return result;
} }
}).continueWith(new Continuation<Object, Object>() { }).continueWith(new Continuation<EarIdList, Object>() {
@Override @Override
public Object then(Task<Object> task) throws Exception { public Object then(Task<EarIdList> task) throws Exception {
Intent intent = new Intent("com.auriclon.activity_select_user"); Intent intent = new Intent("com.auriclon.activity_select_user");
intent.putExtra("list", new Gson().toJson(task.getResult()));
startActivity(intent); startActivity(intent);
return null; return null;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment