mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-08 12:30:20 +08:00
Android: simplified default workflow (open -> scan -> optimize/export -> save)
This commit is contained in:
@@ -602,11 +602,7 @@ public class RTABMapActivity extends FragmentActivity implements OnClickListener
|
|||||||
RTABMapLib.openDatabase(nativeApplication, tmpDatabase, databaseInMemory, false);
|
RTABMapLib.openDatabase(nativeApplication, tmpDatabase, databaseInMemory, false);
|
||||||
|
|
||||||
final String[] files = Util.loadFileList(mWorkingDirectory, true);
|
final String[] files = Util.loadFileList(mWorkingDirectory, true);
|
||||||
if(files.length > 0)
|
if(files.length == 0)
|
||||||
{
|
|
||||||
openDatabase();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
mButtonLibrary.setVisibility(View.INVISIBLE);
|
mButtonLibrary.setVisibility(View.INVISIBLE);
|
||||||
}
|
}
|
||||||
@@ -1554,7 +1550,7 @@ public class RTABMapActivity extends FragmentActivity implements OnClickListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(mButtonStop!=null && mButtonStop.getVisibility() == View.VISIBLE)
|
if(mState == State.STATE_MAPPING || mState == State.STATE_VISUALIZING_CAMERA)
|
||||||
{
|
{
|
||||||
long currentTime = System.currentTimeMillis()/1000;
|
long currentTime = System.currentTimeMillis()/1000;
|
||||||
if(loopClosureId > 0)
|
if(loopClosureId > 0)
|
||||||
@@ -1910,7 +1906,7 @@ public class RTABMapActivity extends FragmentActivity implements OnClickListener
|
|||||||
|
|
||||||
private RTABMapActivity getActivity() {return this;}
|
private RTABMapActivity getActivity() {return this;}
|
||||||
|
|
||||||
private void standardOptimization() {
|
private void standardOptimization(final boolean withStandardMeshExport) {
|
||||||
|
|
||||||
mExportProgressDialog.setTitle("Post-Processing");
|
mExportProgressDialog.setTitle("Post-Processing");
|
||||||
mExportProgressDialog.setMessage(String.format("Please wait while optimizing..."));
|
mExportProgressDialog.setMessage(String.format("Please wait while optimizing..."));
|
||||||
@@ -1929,9 +1925,21 @@ public class RTABMapActivity extends FragmentActivity implements OnClickListener
|
|||||||
if(loopDetected >= 0)
|
if(loopDetected >= 0)
|
||||||
{
|
{
|
||||||
mTotalLoopClosures+=loopDetected;
|
mTotalLoopClosures+=loopDetected;
|
||||||
mProgressDialog.setTitle("Post-Processing");
|
if(withStandardMeshExport)
|
||||||
mProgressDialog.setMessage(String.format("Optimization done! Increasing visual appeal..."));
|
{
|
||||||
mProgressDialog.show();
|
export(true, true, false, true, 200000);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mProgressDialog.setTitle("Post-Processing");
|
||||||
|
mProgressDialog.setMessage(String.format("Optimization done! Increasing visual appeal..."));
|
||||||
|
mProgressDialog.show();
|
||||||
|
|
||||||
|
if(mOpenedDatabasePath.isEmpty())
|
||||||
|
{
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if(loopDetected < 0)
|
else if(loopDetected < 0)
|
||||||
{
|
{
|
||||||
@@ -2271,16 +2279,24 @@ public class RTABMapActivity extends FragmentActivity implements OnClickListener
|
|||||||
// Do standard post processing?
|
// Do standard post processing?
|
||||||
AlertDialog d2 = new AlertDialog.Builder(getActivity())
|
AlertDialog d2 = new AlertDialog.Builder(getActivity())
|
||||||
.setCancelable(false)
|
.setCancelable(false)
|
||||||
.setTitle("Mapping Paused! Optimize Now?")
|
.setTitle("Mapping Stopped! Optimize Now?")
|
||||||
.setMessage("Do you want to do standard map optimization now? This can be also done later using \"Optimize\" menu.")
|
.setMessage("Do you want to do standard graph and mesh optimizations now? This can be also done later using \"Optimize\" and \"Export\" menus.")
|
||||||
|
.setNeutralButton("Only Graph", new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
standardOptimization(false);
|
||||||
|
}
|
||||||
|
})
|
||||||
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
|
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
standardOptimization();
|
standardOptimization(true);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.setNegativeButton("No", new DialogInterface.OnClickListener() {
|
.setNegativeButton("No", new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
// do nothing...
|
if(mOpenedDatabasePath.isEmpty())
|
||||||
|
{
|
||||||
|
save();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.create();
|
.create();
|
||||||
@@ -2300,7 +2316,7 @@ public class RTABMapActivity extends FragmentActivity implements OnClickListener
|
|||||||
int itemId = item.getItemId();
|
int itemId = item.getItemId();
|
||||||
if (itemId == R.id.post_processing_standard)
|
if (itemId == R.id.post_processing_standard)
|
||||||
{
|
{
|
||||||
standardOptimization();
|
standardOptimization(false);
|
||||||
}
|
}
|
||||||
else if (itemId == R.id.detect_more_loop_closures)
|
else if (itemId == R.id.detect_more_loop_closures)
|
||||||
{
|
{
|
||||||
@@ -2482,67 +2498,7 @@ public class RTABMapActivity extends FragmentActivity implements OnClickListener
|
|||||||
}
|
}
|
||||||
else if (itemId == R.id.save)
|
else if (itemId == R.id.save)
|
||||||
{
|
{
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
save();
|
||||||
builder.setCancelable(false);
|
|
||||||
builder.setTitle("RTAB-Map Database Name (*.db):");
|
|
||||||
final EditText input = new EditText(this);
|
|
||||||
input.setInputType(InputType.TYPE_CLASS_TEXT);
|
|
||||||
if(mOpenedDatabasePath.isEmpty())
|
|
||||||
{
|
|
||||||
String timeStamp = new SimpleDateFormat("yyMMdd-HHmmss").format(mDateOnPause);
|
|
||||||
input.setText(timeStamp);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
File f = new File(mOpenedDatabasePath);
|
|
||||||
String name = f.getName();
|
|
||||||
input.setText(name.substring(0,name.lastIndexOf(".")));
|
|
||||||
}
|
|
||||||
input.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
|
|
||||||
input.setSelectAllOnFocus(true);
|
|
||||||
input.selectAll();
|
|
||||||
builder.setView(input);
|
|
||||||
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which)
|
|
||||||
{
|
|
||||||
final String fileName = input.getText().toString();
|
|
||||||
dialog.dismiss();
|
|
||||||
if(!fileName.isEmpty())
|
|
||||||
{
|
|
||||||
File newFile = new File(mWorkingDirectory + fileName + ".db");
|
|
||||||
if(newFile.exists())
|
|
||||||
{
|
|
||||||
AlertDialog d2 = new AlertDialog.Builder(getActivity())
|
|
||||||
.setCancelable(false)
|
|
||||||
.setTitle("File Already Exists")
|
|
||||||
.setMessage("Do you want to overwrite the existing file?")
|
|
||||||
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
saveDatabase(fileName);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.setNegativeButton("No", new DialogInterface.OnClickListener() {
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
dialog.dismiss();
|
|
||||||
resetNoTouchTimer(true);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.create();
|
|
||||||
d2.setCanceledOnTouchOutside(false);
|
|
||||||
d2.show();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
saveDatabase(fileName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
AlertDialog alertToShow = builder.create();
|
|
||||||
alertToShow.setCanceledOnTouchOutside(false);
|
|
||||||
alertToShow.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
|
|
||||||
alertToShow.show();
|
|
||||||
}
|
}
|
||||||
else if(itemId == R.id.resume)
|
else if(itemId == R.id.resume)
|
||||||
{
|
{
|
||||||
@@ -3042,75 +2998,36 @@ public class RTABMapActivity extends FragmentActivity implements OnClickListener
|
|||||||
notificationManager.notify(0, n);
|
notificationManager.notify(0, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Visualize the result?
|
// Visualize the result
|
||||||
AlertDialog d = new AlertDialog.Builder(getActivity())
|
resetNoTouchTimer(true);
|
||||||
.setCancelable(false)
|
mSavedRenderingType = mItemRenderingPointCloud.isChecked()?0:mItemRenderingMesh.isChecked()?1:2;
|
||||||
.setTitle("Export Successful! (" + (endTime-startTime) + " sec)")
|
if(!meshing)
|
||||||
.setMessage(Html.fromHtml("Do you want visualize the result before saving to file or sharing to <a href=\"https://sketchfab.com/about\">Sketchfab</a>?"))
|
{
|
||||||
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
|
mItemRenderingPointCloud.setChecked(true);
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
}
|
||||||
resetNoTouchTimer(true);
|
else if(!isOBJ)
|
||||||
mSavedRenderingType = mItemRenderingPointCloud.isChecked()?0:mItemRenderingMesh.isChecked()?1:2;
|
{
|
||||||
if(!meshing)
|
mItemRenderingMesh.setChecked(true);
|
||||||
{
|
}
|
||||||
mItemRenderingPointCloud.setChecked(true);
|
else // isOBJ
|
||||||
}
|
{
|
||||||
else if(!isOBJ)
|
mItemRenderingTextureMesh.setChecked(true);
|
||||||
{
|
}
|
||||||
mItemRenderingMesh.setChecked(true);
|
if(!optimizedCleanWhitePolygons)
|
||||||
}
|
{
|
||||||
else // isOBJ
|
mButtonLighting.setChecked(true);
|
||||||
{
|
RTABMapLib.setLighting(nativeApplication, true);
|
||||||
mItemRenderingTextureMesh.setChecked(true);
|
}
|
||||||
}
|
updateState(State.STATE_VISUALIZING);
|
||||||
if(!optimizedCleanWhitePolygons)
|
RTABMapLib.postExportation(nativeApplication, true);
|
||||||
{
|
if(mButtonCameraView.getSelectedItemPosition() == 0)
|
||||||
mButtonLighting.setChecked(true);
|
{
|
||||||
RTABMapLib.setLighting(nativeApplication, true);
|
setCamera(2);
|
||||||
}
|
}
|
||||||
updateState(State.STATE_VISUALIZING);
|
if(mOpenedDatabasePath.isEmpty())
|
||||||
RTABMapLib.postExportation(nativeApplication, true);
|
{
|
||||||
if(mButtonCameraView.getSelectedItemPosition() == 0)
|
save();
|
||||||
{
|
}
|
||||||
setCamera(2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.setNegativeButton("No", new DialogInterface.OnClickListener() {
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
updateState(State.STATE_IDLE);
|
|
||||||
RTABMapLib.postExportation(nativeApplication, false);
|
|
||||||
|
|
||||||
AlertDialog d2 = new AlertDialog.Builder(getActivity())
|
|
||||||
.setCancelable(false)
|
|
||||||
.setTitle("Save to...")
|
|
||||||
.setMessage(Html.fromHtml("Do you want to share to <a href=\"https://sketchfab.com/about\">Sketchfab</a> or save it on device?"))
|
|
||||||
.setPositiveButton("Share to Sketchfab", new DialogInterface.OnClickListener() {
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
shareToSketchfab();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.setNegativeButton("Save on device", new DialogInterface.OnClickListener() {
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
saveOnDevice();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.setNeutralButton("Cancel", new DialogInterface.OnClickListener() {
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
resetNoTouchTimer(true);
|
|
||||||
}
|
|
||||||
}).create();
|
|
||||||
d2.setCanceledOnTouchOutside(false);
|
|
||||||
d2.show();
|
|
||||||
// Make the textview clickable. Must be called after show()
|
|
||||||
((TextView)d2.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance());
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.create();
|
|
||||||
d.setCanceledOnTouchOutside(false);
|
|
||||||
d.show();
|
|
||||||
// Make the textview clickable. Must be called after show()
|
|
||||||
((TextView)d.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance());
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -3131,6 +3048,78 @@ public class RTABMapActivity extends FragmentActivity implements OnClickListener
|
|||||||
});
|
});
|
||||||
exportThread.start();
|
exportThread.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void save()
|
||||||
|
{
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
|
builder.setCancelable(false);
|
||||||
|
builder.setTitle("RTAB-Map Database Name (*.db):");
|
||||||
|
final EditText input = new EditText(this);
|
||||||
|
input.setInputType(InputType.TYPE_CLASS_TEXT);
|
||||||
|
if(mOpenedDatabasePath.isEmpty())
|
||||||
|
{
|
||||||
|
String timeStamp = new SimpleDateFormat("yyMMdd-HHmmss").format(mDateOnPause);
|
||||||
|
input.setText(timeStamp);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
File f = new File(mOpenedDatabasePath);
|
||||||
|
String name = f.getName();
|
||||||
|
input.setText(name.substring(0,name.lastIndexOf(".")));
|
||||||
|
}
|
||||||
|
input.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
|
||||||
|
input.setSelectAllOnFocus(true);
|
||||||
|
input.selectAll();
|
||||||
|
builder.setView(input);
|
||||||
|
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which)
|
||||||
|
{
|
||||||
|
//do nothing
|
||||||
|
}
|
||||||
|
});
|
||||||
|
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which)
|
||||||
|
{
|
||||||
|
final String fileName = input.getText().toString();
|
||||||
|
dialog.dismiss();
|
||||||
|
if(!fileName.isEmpty())
|
||||||
|
{
|
||||||
|
File newFile = new File(mWorkingDirectory + fileName + ".db");
|
||||||
|
if(newFile.exists())
|
||||||
|
{
|
||||||
|
AlertDialog d2 = new AlertDialog.Builder(getActivity())
|
||||||
|
.setCancelable(false)
|
||||||
|
.setTitle("File Already Exists")
|
||||||
|
.setMessage("Do you want to overwrite the existing file?")
|
||||||
|
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
saveDatabase(fileName);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setNegativeButton("No", new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
dialog.dismiss();
|
||||||
|
resetNoTouchTimer(true);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.create();
|
||||||
|
d2.setCanceledOnTouchOutside(false);
|
||||||
|
d2.show();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
saveDatabase(fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
AlertDialog alertToShow = builder.create();
|
||||||
|
alertToShow.setCanceledOnTouchOutside(false);
|
||||||
|
alertToShow.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
|
||||||
|
alertToShow.show();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@param context : it is the reference where this method get called
|
@param context : it is the reference where this method get called
|
||||||
@@ -3202,38 +3191,14 @@ public class RTABMapActivity extends FragmentActivity implements OnClickListener
|
|||||||
AlertDialog d2 = new AlertDialog.Builder(getActivity())
|
AlertDialog d2 = new AlertDialog.Builder(getActivity())
|
||||||
.setCancelable(false)
|
.setCancelable(false)
|
||||||
.setTitle("Database saved!")
|
.setTitle("Database saved!")
|
||||||
.setMessage(String.format("Database \"%s\" (%d MB) successfully saved on the SD-CARD! Share it?", newDatabasePathHuman, fileSizeMB))
|
.setMessage(String.format("Database \"%s\" (%d MB) successfully saved on the SD-CARD!", newDatabasePathHuman, fileSizeMB))
|
||||||
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
|
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
// Send to...
|
// do nothing
|
||||||
Intent shareIntent = new Intent();
|
|
||||||
shareIntent.setAction(Intent.ACTION_SEND);
|
|
||||||
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(f));
|
|
||||||
shareIntent.setType("application/octet-stream");
|
|
||||||
startActivity(Intent.createChooser(shareIntent, "Sharing..."));
|
|
||||||
|
|
||||||
resetNoTouchTimer(true);
|
|
||||||
if(!mItemDataRecorderMode.isChecked())
|
|
||||||
{
|
|
||||||
mOpenedDatabasePath = newDatabasePath;
|
|
||||||
}
|
|
||||||
mProgressDialog.dismiss();
|
|
||||||
updateState(previousState);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.setNegativeButton("No", new DialogInterface.OnClickListener() {
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
resetNoTouchTimer(true);
|
|
||||||
if(!mItemDataRecorderMode.isChecked())
|
|
||||||
{
|
|
||||||
mOpenedDatabasePath = newDatabasePath;
|
|
||||||
}
|
|
||||||
mProgressDialog.dismiss();
|
|
||||||
updateState(previousState);
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.create();
|
.create();
|
||||||
d2.setCanceledOnTouchOutside(false);
|
d2.setCanceledOnTouchOutside(true);
|
||||||
d2.show();
|
d2.show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -3388,7 +3353,7 @@ public class RTABMapActivity extends FragmentActivity implements OnClickListener
|
|||||||
|
|
||||||
AlertDialog d = new AlertDialog.Builder(getActivity())
|
AlertDialog d = new AlertDialog.Builder(getActivity())
|
||||||
.setCancelable(false)
|
.setCancelable(false)
|
||||||
.setTitle("Database saved!")
|
.setTitle("Mesh Saved!")
|
||||||
.setMessage(String.format("Mesh \"%s\" (%d MB) successfully exported on the SD-CARD! Share it?", pathHuman, fileSizeMB))
|
.setMessage(String.format("Mesh \"%s\" (%d MB) successfully exported on the SD-CARD! Share it?", pathHuman, fileSizeMB))
|
||||||
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
|
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
|||||||
Reference in New Issue
Block a user