Passes the ear features to the next Actitivity.

parent 180e5455
......@@ -7,6 +7,9 @@ import android.os.Bundle;
import com.aluxoft.earrecognition.EarIdentifier;
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.util.concurrent.Callable;
......@@ -29,25 +32,33 @@ public class SIFTActivity extends Activity {
loading.setCancelable(false);
loading.setProgressStyle(ProgressDialog.STYLE_SPINNER);
Task.callInBackground(new Callable<Object>() {
Task.callInBackground(new Callable<EarIdList>() {
@Override
public Object call() throws Exception {
synchronized (this) {
// Sift
EarIdentifier identifier = new EarIdentifier(null);
Intent intent = SIFTActivity.this.getIntent();
Bundle extras = intent.getExtras();
String imagePath = (String)extras.get("image_path");
String features = identifier.computeFeatures(imagePath);
// Once we have the features, we can delete the image.
new File(imagePath).delete();
}
return null;
public EarIdList call() throws Exception {
// Sift
EarIdentifier identifier = new EarIdentifier(null);
Intent intent = SIFTActivity.this.getIntent();
Bundle extras = intent.getExtras();
String imagePath = (String)extras.get("image_path");
EarFeature earFeature = identifier.computeFeatures(imagePath);
// Once we have the features, we can delete the image.
new File(imagePath).delete();
// Compares the current features with the database.
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
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.putExtra("list", new Gson().toJson(task.getResult()));
startActivity(intent);
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