Tango: added sketchfab links, Color Radius is used when texturing optimized mesh

This commit is contained in:
matlabbe
2017-02-27 16:53:05 -05:00
parent 2565239a1b
commit 6c9572714f
5 changed files with 96 additions and 11 deletions

View File

@@ -2,7 +2,7 @@
<!-- BEGIN_INCLUDE(manifest) -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.introlab.rtabmap"
android:versionCode="37"
android:versionCode="38"
android:versionName="@RTABMAP_VERSION@">
<uses-permission android:name="android.permission.CAMERA" />

View File

@@ -1823,6 +1823,59 @@ bool RTABMapApp::exportMesh(
}
else
{
if(optimizedColorRadius > 0.0f && optimizedCleanWhitePolygons)
{
LOGI("Removing polygons too far from the cloud");
// transfer color from point cloud to mesh
pcl::search::KdTree<pcl::PointXYZRGBNormal>::Ptr tree (new pcl::search::KdTree<pcl::PointXYZRGBNormal>(true));
tree->setInputCloud(mergedClouds);
pcl::PointCloud<pcl::PointXYZ>::Ptr optimizedCloud(new pcl::PointCloud<pcl::PointXYZ>);
pcl::fromPCLPointCloud2(mesh->cloud, *optimizedCloud);
std::vector<bool> closePts(optimizedCloud->size());
for(unsigned int i=0; i<optimizedCloud->size(); ++i)
{
std::vector<int> kIndices;
std::vector<float> kDistances;
pcl::PointXYZRGBNormal pt;
pt.x = optimizedCloud->at(i).x;
pt.y = optimizedCloud->at(i).y;
pt.z = optimizedCloud->at(i).z;
tree->radiusSearch(pt, optimizedColorRadius, kIndices, kDistances);
if(kIndices.size())
{
closePts.at(i) = true;
}
else
{
closePts.at(i) = false;
}
}
// remove far polygons
std::vector<pcl::Vertices> filteredPolygons(mesh->polygons.size());
int oi=0;
for(unsigned int i=0; i<mesh->polygons.size(); ++i)
{
bool keepPolygon = true;
for(unsigned int j=0; j<mesh->polygons[i].vertices.size(); ++j)
{
if(!closePts.at(mesh->polygons[i].vertices[j]))
{
keepPolygon = false;
break;
}
}
if(keepPolygon)
{
filteredPolygons[oi++] = mesh->polygons[i];
}
}
filteredPolygons.resize(oi);
mesh->polygons = filteredPolygons;
LOGI("Removing polygons too far from the cloud...done! %fs", timer.ticks());
}
LOGI("Texturing...");
textureMesh = rtabmap::util3d::createTextureMesh(
mesh,

View File

@@ -109,7 +109,7 @@
<string name="pref_key_opt_decimation_factor">pref_key_opt_decimation_factor</string>
<string name="pref_default_opt_decimation_factor">60</string>
<string name="pref_key_opt_color_radius">pref_key_opt_color_radius</string>
<string name="pref_default_opt_color_radius">0.2</string>
<string name="pref_default_opt_color_radius">0.05</string>
<string name="pref_key_opt_clean_white">pref_key_opt_clean_white</string>
<string name="pref_default_opt_clean_white">true</string>
<string name="pref_key_gain_max_radius">pref_key_gain_max_radius</string>
@@ -554,7 +554,7 @@
<string name="pref_title_opt_decimation_factor">Mesh Decimation Factor</string>
<string name="pref_summary_opt_decimation_factor">Reduce the number of the output polygons on plane areas by this factor. Only used when exporting with texture. This also reduces texture projection time.</string>
<string name="pref_title_opt_color_radius">Color Radius</string>
<string name="pref_summary_opt_color_radius">Radius used to transfer nearest color from the point cloud to reconstructed mesh.</string>
<string name="pref_summary_opt_color_radius">Radius used to transfer nearest color from the point cloud to reconstructed mesh. When exporting with texture, if Clean Mesh is also enabled, this will limit the number of polygons textured in holes.</string>
<string name="pref_title_opt_clean_white">Clean Mesh</string>
<string name="pref_summary_opt_clean_white">Clean mesh from textureless or colorless reconstructed polygons.</string>
@@ -597,7 +597,9 @@
<item>"1 m"</item>
<item>"0.5 m"</item>
<item>"0.2 m"</item>
<item>"0.1 m"</item>
<item>"0.05 m"</item>
<item>"0.025 m"</item>
<item>"0.01 m"</item>
<item>"Disabled"</item>
</string-array>
@@ -607,7 +609,9 @@
<item>"1"</item>
<item>"0.5"</item>
<item>"0.2"</item>
<item>"0.1"</item>
<item>"0.05"</item>
<item>"0.025"</item>
<item>"0.01"</item>
<item>"-1"</item>
</string-array>

View File

@@ -55,8 +55,12 @@ import android.os.Debug;
import android.os.IBinder;
import android.preference.PreferenceManager;
import android.text.Editable;
import android.text.Html;
import android.text.InputType;
import android.text.SpannableString;
import android.text.TextPaint;
import android.text.method.LinkMovementMethod;
import android.text.util.Linkify;
import android.util.Log;
import android.view.Display;
import android.view.Menu;
@@ -128,6 +132,7 @@ public class RTABMapActivity extends Activity implements OnClickListener {
private long mOnPauseStamp = 0;
private boolean mOnPause = false;
private Date mDateOnPause = new Date();
private boolean mBlockBack = true;
private MenuItem mItemSave;
private MenuItem mItemOpen;
@@ -344,6 +349,20 @@ public class RTABMapActivity extends Activity implements OnClickListener {
}
}
@Override
public void onBackPressed() {
if(mBlockBack)
{
mToast.makeText(this, "Press Back once more to exit", mToast.LENGTH_LONG).show();
mBlockBack = false;
}
else
{
super.onBackPressed();
}
}
@Override
protected void onPause() {
super.onPause();
@@ -1565,12 +1584,12 @@ public class RTABMapActivity extends Activity implements OnClickListener {
{
mToast.makeText(getActivity(), String.format("Cloud assembled and voxelized at %s m.", cloudVoxelSizeStr), mToast.LENGTH_LONG).show();
}
// Visualize the result?
new AlertDialog.Builder(getActivity())
AlertDialog d = new AlertDialog.Builder(getActivity())
.setCancelable(false)
.setTitle("Export Successful!")
.setMessage("Do you want visualize the result before saving to file or sharing to Sketchfab?")
.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() {
public void onClick(DialogInterface dialog, int which) {
mExportedOBJ = isOBJ;
@@ -1588,10 +1607,10 @@ public class RTABMapActivity extends Activity implements OnClickListener {
updateState(State.STATE_IDLE);
RTABMapLib.postExportation(false);
new AlertDialog.Builder(getActivity())
AlertDialog d2 = new AlertDialog.Builder(getActivity())
.setCancelable(false)
.setTitle("Save to...")
.setMessage("Do you want to share to Sketchfab or save it on the device?")
.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();
@@ -1606,10 +1625,16 @@ public class RTABMapActivity extends Activity implements OnClickListener {
public void onClick(DialogInterface dialog, int which) {
}
})
.show();
.create();
d2.show();
// Make the textview clickable. Must be called after show()
((TextView)d2.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance());
}
})
.show();
.create();
d.show();
// Make the textview clickable. Must be called after show()
((TextView)d.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance());
}
else
{
@@ -1665,6 +1690,7 @@ public class RTABMapActivity extends Activity implements OnClickListener {
{
Intent intent = new Intent(getActivity(), SettingsActivity.class);
startActivity(intent);
mBlockBack = true;
}
else if(itemId == R.id.about)
{
@@ -1926,6 +1952,7 @@ public class RTABMapActivity extends Activity implements OnClickListener {
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent(getActivity(), SettingsActivity.class);
startActivity(intent);
mBlockBack = true;
}
})
.setNegativeButton("Close", new DialogInterface.OnClickListener() {
@@ -1987,5 +2014,6 @@ public class RTABMapActivity extends Activity implements OnClickListener {
}
startActivityForResult(intent, SKETCHFAB_ACTIVITY_CODE);
mBlockBack = true;
}
}

View File

@@ -303,7 +303,7 @@ public class SketchfabActivity extends Activity implements OnClickListener {
{
Log.i(RTABMapActivity.TAG, String.format("Zipped files = %d MB", fileSizeMB));
builder.setMessage(String.format("Total size to upload = %d MB. %sDo you want to continue?\n\n"
+ "Tip: To reduce the model size, you can also look at the Settings->Exporting options to reduce the output size.", fileSizeMB,
+ "Tip: To reduce the model size, you can also look at the Settings->Exporting options.", fileSizeMB,
fileSizeMB>=50?"Note that for size over 50 MB, a Sketchfab PRO account is required, otherwise the upload may fail. ":""));
}