Tango: added multi-texturing support (#189)

This commit is contained in:
matlabbe
2017-06-10 21:45:51 -04:00
parent 774afe9fdd
commit 9554597948
8 changed files with 215 additions and 60 deletions

View File

@@ -1873,14 +1873,15 @@ double sqr(uchar v)
return double(v)*double(v);
}
cv::Mat RTABMapApp::mergeTextures(
std::vector<cv::Mat> RTABMapApp::mergeTextures(
pcl::TextureMesh & mesh,
int textureSize,
int textureCount,
const std::vector<std::map<int, pcl::PointXY> > & vertexToPixels) const
{
UASSERT(textureSize> 0);
LOGD("textureSize = %d materials=%d", textureSize, mesh.tex_materials.size());
cv::Mat globalTexture;
LOGD("textureSize = %d textureCount=%d materials=%d", textureSize, textureCount, mesh.tex_materials.size());
std::vector<cv::Mat> globalTextures;
if(mesh.tex_materials.size() >= 1)
{
std::vector<int> textures(mesh.tex_materials.size(), -1);
@@ -1914,14 +1915,19 @@ cv::Mat RTABMapApp::mergeTextures(
{
float scale = 0.0f;
std::vector<bool> materialsKept;
rtabmap::util3d::concatenateTextureMaterials(mesh, imageSize, textureSize, 1, scale, &materialsKept);
rtabmap::util3d::concatenateTextureMaterials(mesh, imageSize, textureSize, textureCount, scale, &materialsKept);
LOGD("scale=%f materials=%d", scale, (int)mesh.tex_materials.size());
if(scale && mesh.tex_materials.size()==1)
if(scale && mesh.tex_materials.size())
{
int materials = (int)mesh.tex_materials.size();
int cols = float(textureSize)/(scale*imageSize.width);
int rows = float(textureSize)/(scale*imageSize.height);
globalTexture = cv::Mat(textureSize, textureSize, imageType, cv::Scalar::all(255));
cv::Mat globalTextureMask = cv::Mat(textureSize, textureSize, CV_8UC1, cv::Scalar::all(0));
globalTextures.resize(materials);
for(int i=0; i<materials; ++i)
{
globalTextures[i] = cv::Mat(textureSize, textureSize, imageType, cv::Scalar::all(255));
}
// make a blank texture
cv::Mat emptyImage(int(imageSize.height*scale), int(imageSize.width*scale), imageType, cv::Scalar::all(255));
@@ -1933,8 +1939,11 @@ cv::Mat RTABMapApp::mergeTextures(
{
if(materialsKept.at(i))
{
int indexMaterial = oi / (cols*rows);
UASSERT(indexMaterial < materials);
int u = oi%cols * emptyImage.cols;
int v = oi/cols * emptyImage.rows;
int v = ((oi/cols) % rows ) * emptyImage.rows;
UASSERT(u < textureSize-emptyImage.cols);
UASSERT(v < textureSize-emptyImage.rows);
newCamIndex[i] = oi;
@@ -1967,13 +1976,12 @@ cv::Mat RTABMapApp::mergeTextures(
cv::cvtColor(resizedImage,resizedImageColor,CV_GRAY2RGB);
resizedImage = resizedImageColor;
}
UASSERT(resizedImage.type() == globalTexture.type());
resizedImage.copyTo(globalTexture(cv::Rect(u, v, resizedImage.cols, resizedImage.rows)));
emptyImageMask.copyTo(globalTextureMask(cv::Rect(u, v, emptyImageMask.cols, emptyImageMask.rows)));
UASSERT(resizedImage.type() == globalTextures[indexMaterial].type());
resizedImage.copyTo(globalTextures[indexMaterial](cv::Rect(u, v, resizedImage.cols, resizedImage.rows)));
}
else
{
emptyImage.copyTo(globalTexture(cv::Rect(u, v, emptyImage.cols, emptyImage.rows)));
emptyImage.copyTo(globalTextures[indexMaterial](cv::Rect(u, v, emptyImage.cols, emptyImage.rows)));
}
++oi;
}
@@ -1988,6 +1996,7 @@ cv::Mat RTABMapApp::mergeTextures(
if(vertexToPixels.size())
{
LOGD("gain compensation");
// gain compensation
const int num_images = static_cast<int>(oi);
cv::Mat_<int> N(num_images, num_images); N.setTo(0);
@@ -2019,13 +2028,15 @@ cv::Mat RTABMapApp::mergeTextures(
N(i, j) += 1;
N(j, i) += 1;
int indexMaterial = i / (cols*rows);
// uv in globalTexture
int ui = iter->second.x*emptyImage.cols + imageOrigin[iter->first].x;
int vi = (1.0-iter->second.y)*emptyImage.rows + imageOrigin[iter->first].y;
int uj = jter->second.x*emptyImage.cols + imageOrigin[jter->first].x;
int vj = (1.0-jter->second.y)*emptyImage.rows + imageOrigin[jter->first].y;
cv::Vec3b * pt1 = globalTexture.ptr<cv::Vec3b>(vi,ui);
cv::Vec3b * pt2 = globalTexture.ptr<cv::Vec3b>(vj,uj);
cv::Vec3b * pt1 = globalTextures[indexMaterial].ptr<cv::Vec3b>(vi,ui);
cv::Vec3b * pt2 = globalTextures[indexMaterial].ptr<cv::Vec3b>(vj,uj);
I(i, j) += std::sqrt(static_cast<double>(sqr(pt1->val[0]) + sqr(pt1->val[1]) + sqr(pt1->val[2])));
I(j, i) += std::sqrt(static_cast<double>(sqr(pt2->val[0]) + sqr(pt2->val[1]) + sqr(pt2->val[2])));
@@ -2044,9 +2055,16 @@ cv::Mat RTABMapApp::mergeTextures(
for(int i=0; i<num_images; ++i)
{
for(int j=i+1; j<num_images; ++j)
for(int j=i; j<num_images; ++j)
{
if(N(i, j))
if(i == j)
{
if(N(i,j) == 0)
{
N(i,j) = 1;
}
}
else if(N(i, j))
{
I(i, j) /= N(i, j);
I(j, i) /= N(j, i);
@@ -2113,7 +2131,8 @@ cv::Mat RTABMapApp::mergeTextures(
int u = imageOrigin[t].x;
int v = imageOrigin[t].y;
cv::Mat roi = globalTexture(cv::Rect(u, v, emptyImage.cols, emptyImage.rows));
int indexMaterial = newCamIndex[t] / (cols*rows);
cv::Mat roi = globalTextures[indexMaterial](cv::Rect(u, v, emptyImage.cols, emptyImage.rows));
std::vector<cv::Mat> channels;
cv::split(roi, channels);
@@ -2127,6 +2146,7 @@ cv::Mat RTABMapApp::mergeTextures(
progressionStatus_.increment();
// blending BGR
LOGD("blending");
int decimation = 0;
// determinate decimation to apply
@@ -2168,7 +2188,13 @@ cv::Mat RTABMapApp::mergeTextures(
if(decimation>0)
{
cv::Mat blendGains(globalTexture.rows/decimation, globalTexture.cols/decimation, CV_32FC3, cv::Scalar::all(1.0f));
LOGD("blending decimation=%d", decimation);
std::vector<cv::Mat> blendGains(materials);
for(int i=0; i<materials;++i)
{
blendGains[i] = cv::Mat(globalTextures[i].rows/decimation, globalTextures[i].cols/decimation, CV_32FC3, cv::Scalar::all(1.0f));
}
for(unsigned int p=0; p<vertexToPixels.size(); ++p)
{
if(vertexToPixels[p].size() > 1)
@@ -2191,7 +2217,8 @@ cv::Mat RTABMapApp::mergeTextures(
{
weight = 0.0f;
}
cv::Vec3b * pt = globalTexture.ptr<cv::Vec3b>(v,u);
int indexMaterial = newCamIndex[iter->first] / (cols*rows);
cv::Vec3b * pt = globalTextures[indexMaterial].ptr<cv::Vec3b>(v,u);
gainsB[k] = static_cast<double>(pt->val[0]) * weight;
gainsG[k] = static_cast<double>(pt->val[1]) * weight;
gainsR[k] = static_cast<double>(pt->val[2]) * weight;
@@ -2215,11 +2242,12 @@ cv::Mat RTABMapApp::mergeTextures(
{
int u = iter->second.x*emptyImage.cols + imageOrigin[iter->first].x;
int v = (1.0-iter->second.y)*emptyImage.rows + imageOrigin[iter->first].y;
cv::Vec3b * pt = globalTexture.ptr<cv::Vec3b>(v,u);
int indexMaterial = newCamIndex[iter->first] / (cols*rows);
cv::Vec3b * pt = globalTextures[indexMaterial].ptr<cv::Vec3b>(v,u);
float gB = targetColor[0]/(pt->val[0]==0?1.0f:pt->val[0]);
float gG = targetColor[1]/(pt->val[1]==0?1.0f:pt->val[1]);
float gR = targetColor[2]/(pt->val[2]==0?1.0f:pt->val[2]);
cv::Vec3f * ptr = blendGains.ptr<cv::Vec3f>(v/decimation, u/decimation);
cv::Vec3f * ptr = blendGains[indexMaterial].ptr<cv::Vec3f>(v/decimation, u/decimation);
ptr->val[0] = (gB>1.3f)?1.3f:(gB<0.7f)?0.7f:gB;
ptr->val[1] = (gG>1.3f)?1.3f:(gG<0.7f)?0.7f:gG;
ptr->val[2] = (gR>1.3f)?1.3f:(gR<0.7f)?0.7f:gR;
@@ -2229,11 +2257,15 @@ cv::Mat RTABMapApp::mergeTextures(
}
}
cv::Mat dst;
cv::blur(blendGains, dst, cv::Size(3,3));
cv::resize(dst, blendGains, globalTexture.size(), 0, 0, cv::INTER_LINEAR);
LOGD("blending multiply");
for(int i=0; i<materials; ++i)
{
cv::Mat dst;
cv::blur(blendGains[i], dst, cv::Size(3,3));
cv::resize(dst, blendGains[i], globalTextures[i].size(), 0, 0, cv::INTER_LINEAR);
cv::multiply(globalTexture, blendGains, globalTexture, 1.0, CV_8UC3);
cv::multiply(globalTextures[i], blendGains[i], globalTextures[i], 1.0, CV_8UC3);
}
}
progressionStatus_.increment();
}
@@ -2252,7 +2284,7 @@ cv::Mat RTABMapApp::mergeTextures(
UERROR("No image size set!");
}
}
return globalTexture;
return globalTextures;
}
void RTABMapApp::cancelProcessing()
@@ -2267,6 +2299,7 @@ bool RTABMapApp::exportMesh(
bool regenerateCloud,
bool meshing,
int textureSize,
int textureCount,
int normalK,
bool optimized,
float optimizedVoxelSize,
@@ -2336,7 +2369,7 @@ bool RTABMapApp::exportMesh(
pcl::PolygonMesh::Ptr polygonMesh(new pcl::PolygonMesh);
pcl::TextureMesh::Ptr textureMesh(new pcl::TextureMesh);
std::vector<std::map<int, pcl::PointXY> > vertexToPixels;
cv::Mat globalTexture;
std::vector<cv::Mat> globalTextures;
int totalPolygons = 0;
{
if(optimized)
@@ -3046,7 +3079,7 @@ bool RTABMapApp::exportMesh(
if(textureSize>0 && totalPolygons && textureMesh->tex_materials.size())
{
LOGI("Merging %d textures...", (int)textureMesh->tex_materials.size());
globalTexture = mergeTextures(*textureMesh, textureSize, vertexToPixels);
globalTextures = mergeTextures(*textureMesh, textureSize, textureCount, vertexToPixels);
if(progressionStatus_.isCanceled())
{
@@ -3058,18 +3091,28 @@ bool RTABMapApp::exportMesh(
return false;
}
LOGD("Saving texture(s) (%d)", (int)globalTextures.size());
std::string baseName = uSplit(UFile::getName(filePath), '.').front();
std::string textureDirectory = UDirectory::getDir(filePath);
std::string fullPath = textureDirectory+UDirectory::separator()+baseName+".jpg";
textureMesh->tex_materials[0].tex_file = baseName+".jpg";
LOGI("Saving texture to %s.", fullPath.c_str());
if(!cv::imwrite(fullPath, globalTexture))
UASSERT(textureMesh->tex_materials.size() == globalTextures.size());
for(unsigned int i=0; i<textureMesh->tex_materials.size(); ++i)
{
LOGI("Failed saving %s!", fullPath.c_str());
}
else
{
LOGI("Saved %s (%d bytes).", fullPath.c_str(), globalTexture.total()*globalTexture.channels());
std::string baseNameNum = baseName;
if(textureMesh->tex_materials.size()>1)
{
baseNameNum+=uNumber2Str(i);
}
std::string fullPath = textureDirectory+UDirectory::separator()+baseNameNum+".jpg";
textureMesh->tex_materials[i].tex_file = baseNameNum+".jpg";
LOGI("Saving texture to %s.", fullPath.c_str());
if(!cv::imwrite(fullPath, globalTextures[i]))
{
LOGI("Failed saving %s!", fullPath.c_str());
}
else
{
LOGI("Saved %s (%d bytes).", fullPath.c_str(), globalTextures[i].total()*globalTextures[i].channels());
}
}
}
if(progressionStatus_.isCanceled())
@@ -3108,14 +3151,54 @@ bool RTABMapApp::exportMesh(
}
else if(textureMesh->tex_materials.size())
{
UASSERT(textureMesh->tex_polygons.size() && (int)textureMesh->tex_polygons[0].size() == totalPolygons);
LOGI("Saving obj (%d vertices, %d polygons) to %s.", (int)textureMesh->cloud.data.size()/textureMesh->cloud.point_step, totalPolygons, filePath.c_str());
success = pcl::io::saveOBJFile(filePath, *textureMesh) == 0;
if(success)
{
LOGI("Saved obj to %s!", filePath.c_str());
exportedMesh_ = textureMesh;
exportedTexture_ = globalTexture;
if(globalTextures.size() == 1)
{
exportedTexture_ = globalTextures[0];
}
else if(globalTextures.size() > 1)
{
// Visualization doesn't support more than one material, so concatenate to 1
std::vector<bool> materialsKept;
float scale = 0.0f;
cv::Size imageSize = globalTextures[0].size();
int imageType = CV_8UC3;
rtabmap::util3d::concatenateTextureMaterials(*exportedMesh_, imageSize, textureSize, 1, scale, &materialsKept);
if(scale && exportedMesh_->tex_materials.size() == 1)
{
int cols = float(textureSize)/(scale*imageSize.width);
int rows = float(textureSize)/(scale*imageSize.height);
exportedTexture_ = cv::Mat(textureSize, textureSize, imageType, cv::Scalar::all(255));
// make a blank texture
cv::Size resizedImageSize(int(imageSize.width*scale), int(imageSize.height*scale));
int oi=0;
for(int i=0; i<(int)globalTextures.size(); ++i)
{
if(materialsKept.at(i))
{
int u = oi%cols * resizedImageSize.width;
int v = ((oi/cols) % rows ) * resizedImageSize.height;
UASSERT(u < textureSize-resizedImageSize.width);
UASSERT(v < textureSize-resizedImageSize.height);
cv::Mat resizedImage;
cv::resize(globalTextures[i], resizedImage, resizedImageSize, 0.0f, 0.0f, cv::INTER_AREA);
UASSERT(resizedImage.type() == exportedTexture_.type());
resizedImage.copyTo(exportedTexture_(cv::Rect(u, v, resizedImage.cols, resizedImage.rows)));
++oi;
}
}
}
}
}
else
{

View File

@@ -146,8 +146,9 @@ class RTABMapApp : public UEventsHandler {
void resetMapping();
void save(const std::string & databasePath);
cv::Mat mergeTextures(pcl::TextureMesh & mesh,
std::vector<cv::Mat> mergeTextures(pcl::TextureMesh & mesh,
int textureSize,
int textureCount,
const std::vector<std::map<int, pcl::PointXY> > & vertexToPixels) const;
void cancelProcessing();
bool exportMesh(
@@ -156,6 +157,7 @@ class RTABMapApp : public UEventsHandler {
bool regenerateCloud,
bool meshing,
int textureSize,
int textureCount,
int normalK,
bool optimized,
float optimizedVoxelSize,

View File

@@ -335,6 +335,7 @@ Java_com_introlab_rtabmap_RTABMapLib_exportMesh(
bool regenerateCloud,
bool meshing,
int textureSize,
int textureCount,
int normalK,
bool optimized,
float optimizedVoxelSize,
@@ -355,6 +356,7 @@ Java_com_introlab_rtabmap_RTABMapLib_exportMesh(
regenerateCloud,
meshing,
textureSize,
textureCount,
normalK,
optimized,
optimizedVoxelSize,

View File

@@ -227,6 +227,14 @@
android:entryValues="@array/pref_texture_size_values"
android:defaultValue="@string/pref_default_texture_size"/>
<ListPreference
android:key="@string/pref_key_texture_count"
android:title="@string/pref_title_texture_count"
android:summary="@string/pref_summary_texture_count"
android:entries="@array/pref_texture_count_keys"
android:entryValues="@array/pref_texture_count_values"
android:defaultValue="@string/pref_default_texture_count"/>
<ListPreference
android:key="@string/pref_key_normal_k"
android:title="@string/pref_title_normal_k"

View File

@@ -109,6 +109,8 @@
<string name="pref_default_cloud_voxel">0.01</string>
<string name="pref_key_texture_size">pref_key_texture_size</string>
<string name="pref_default_texture_size">4096</string>
<string name="pref_key_texture_count">pref_key_texture_count</string>
<string name="pref_default_texture_count">1</string>
<string name="pref_key_normal_k">pref_key_normal_k</string>
<string name="pref_default_normal_k">18</string>
<string name="pref_key_max_texture_distance">pref_key_max_texture_distance</string>
@@ -565,6 +567,8 @@
<string name="pref_summary_cloud_voxel">If you don\'t need a very precise point cloud, you can set this to reduce the output point cloud size. This is also used for optimized mesh.</string>
<string name="pref_title_texture_size">Texture Size</string>
<string name="pref_summary_texture_size">If the map is large, you may want to increase this to maximize the texture resolution.</string>
<string name="pref_title_texture_count">Maximum Output Textures</string>
<string name="pref_summary_texture_count">Note that all textures are still merged into one for visualization, but exported in multiple files.</string>
<string name="pref_title_normal_k">Normal K</string>
<string name="pref_summary_normal_k">K-nearest neighbors used for normal computation when a mesh is created.</string>
<string name="pref_title_max_texture_distance">Max Texture Distance</string>
@@ -606,6 +610,26 @@
<item>"2048"</item>
<item>"1024"</item>
</string-array>
<string-array name="pref_texture_count_keys">
<item>"8"</item>
<item>"7"</item>
<item>"6"</item>
<item>"5"</item>
<item>"4"</item>
<item>"3"</item>
<item>"2"</item>
<item>"1"</item>
</string-array>
<string-array name="pref_texture_count_values">
<item>"8"</item>
<item>"7"</item>
<item>"6"</item>
<item>"5"</item>
<item>"4"</item>
<item>"3"</item>
<item>"2"</item>
<item>"1"</item>
</string-array>
<string-array name="pref_normal_k_values">
<item>"30"</item>
<item>"24"</item>

View File

@@ -109,7 +109,7 @@ public class RTABMapActivity extends Activity implements OnClickListener {
public static final String EXTRA_VALUE_ADF = "ADF_LOAD_SAVE_PERMISSION";
public static final String RTABMAP_TMP_DB = "rtabmap.tmp.db";
public static final String RTABMAP_TMP_DIR = "tmp/";
public static final String RTABMAP_TMP_DIR = "tmp";
public static final String RTABMAP_TMP_FILENAME = "map";
public static final String RTABMAP_SDCARD_PATH = "/sdcard/";
public static final String RTABMAP_EXPORT_DIR = "Export/";
@@ -627,6 +627,7 @@ public class RTABMapActivity extends Activity implements OnClickListener {
break;
case R.id.close_visualization_button:
updateState(State.STATE_IDLE);
RTABMapLib.postExportation(false);
break;
case R.id.button_saveOnDevice:
saveOnDevice();
@@ -1094,7 +1095,7 @@ public class RTABMapActivity extends Activity implements OnClickListener {
private RTABMapActivity getActivity() {return this;}
private String[] loadFileList(String directory) {
private String[] loadFileList(String directory, final boolean databasesOnly) {
File path = new File(directory);
String fileList[];
try {
@@ -1109,7 +1110,14 @@ public class RTABMapActivity extends Activity implements OnClickListener {
@Override
public boolean accept(File dir, String filename) {
File sel = new File(dir, filename);
return filename.compareTo(RTABMAP_TMP_DB) != 0 && filename.endsWith(".db");
if(databasesOnly)
{
return filename.compareTo(RTABMAP_TMP_DB) != 0 && filename.endsWith(".db");
}
else
{
return sel.isFile();
}
}
};
@@ -1242,7 +1250,6 @@ public class RTABMapActivity extends Activity implements OnClickListener {
mItemModes.setEnabled(true);
mButtonPause.setVisibility(mHudVisible?View.VISIBLE:View.INVISIBLE);
mItemDataRecorderMode.setEnabled(mButtonPause.isChecked());
RTABMapLib.postExportation(false);
break;
}
mButtonFirst.setVisibility(mHudVisible?View.VISIBLE:View.INVISIBLE);
@@ -1713,7 +1720,7 @@ public class RTABMapActivity extends Activity implements OnClickListener {
}
else if(itemId == R.id.open)
{
final String[] files = loadFileList(mWorkingDirectory);
final String[] files = loadFileList(mWorkingDirectory, true);
if(files.length > 0)
{
String[] filesWithSize = new String[files.length];
@@ -1774,6 +1781,7 @@ public class RTABMapActivity extends Activity implements OnClickListener {
final String cloudVoxelSizeStr = sharedPref.getString(getString(R.string.pref_key_cloud_voxel), getString(R.string.pref_default_cloud_voxel));
final float cloudVoxelSize = Float.parseFloat(cloudVoxelSizeStr);
final int textureSize = isOBJ?Integer.parseInt(sharedPref.getString(getString(R.string.pref_key_texture_size), getString(R.string.pref_default_texture_size))):0;
final int textureCount = Integer.parseInt(sharedPref.getString(getString(R.string.pref_key_texture_count), getString(R.string.pref_default_texture_count)));
final int normalK = Integer.parseInt(sharedPref.getString(getString(R.string.pref_key_normal_k), getString(R.string.pref_default_normal_k)));
final float maxTextureDistance = Float.parseFloat(sharedPref.getString(getString(R.string.pref_key_max_texture_distance), getString(R.string.pref_default_max_texture_distance)));
final int minTextureClusterSize = Integer.parseInt(sharedPref.getString(getString(R.string.pref_key_min_texture_cluster_size), getString(R.string.pref_default_min_texture_cluster_size)));
@@ -1793,10 +1801,24 @@ public class RTABMapActivity extends Activity implements OnClickListener {
mExportProgressDialog.show();
updateState(State.STATE_PROCESSING);
final String tmpPath = mWorkingDirectory + RTABMAP_TMP_DIR + RTABMAP_TMP_FILENAME + extension;
final String tmpPath = mWorkingDirectory + RTABMAP_TMP_DIR + "/" + RTABMAP_TMP_FILENAME + extension;
File tmpDir = new File(mWorkingDirectory + RTABMAP_TMP_DIR);
tmpDir.mkdirs();
String[] fileNames = loadFileList(mWorkingDirectory + RTABMAP_TMP_DIR, false);
if(!DISABLE_LOG) Log.i(TAG, String.format("Deleting %d files in \"%s\"", fileNames.length, mWorkingDirectory + RTABMAP_TMP_DIR));
for(int i=0; i<fileNames.length; ++i)
{
File f = new File(mWorkingDirectory + RTABMAP_TMP_DIR + "/" + fileNames[i]);
if(f.delete())
{
if(!DISABLE_LOG) Log.i(TAG, String.format("Deleted \"%s\"", f.getPath()));
}
else
{
if(!DISABLE_LOG) Log.i(TAG, String.format("Failed deleting \"%s\"", f.getPath()));
}
}
File exportDir = new File(mWorkingDirectory + RTABMAP_EXPORT_DIR);
exportDir.mkdirs();
@@ -1811,6 +1833,7 @@ public class RTABMapActivity extends Activity implements OnClickListener {
regenerateCloud,
meshing,
textureSize,
textureCount,
normalK,
optimized,
optimizedVoxelSize,
@@ -2043,22 +2066,32 @@ public class RTABMapActivity extends Activity implements OnClickListener {
final String zipOutput = mWorkingDirectory+RTABMAP_EXPORT_DIR+fileName+".zip";
pathHuman = mWorkingDirectoryHuman + RTABMAP_EXPORT_DIR + fileName + ".zip";
String[] filesToZip = new String[3];
filesToZip[0] = mWorkingDirectory + RTABMAP_TMP_DIR + RTABMAP_TMP_FILENAME + ".obj";
filesToZip[1] = mWorkingDirectory + RTABMAP_TMP_DIR + RTABMAP_TMP_FILENAME + ".mtl";
filesToZip[2] = mWorkingDirectory + RTABMAP_TMP_DIR + RTABMAP_TMP_FILENAME + ".jpg";
File toZIPFile = new File(zipOutput);
toZIPFile.delete();
try
String[] fileNames = loadFileList(mWorkingDirectory + RTABMAP_TMP_DIR, false);
if(fileNames.length > 0)
{
Util.zip(filesToZip, zipOutput);
mToast.makeText(getActivity(), String.format("Mesh \"%s\" successfully exported!", pathHuman), mToast.LENGTH_LONG).show();
String[] filesToZip = new String[fileNames.length];
for(int i=0; i<fileNames.length; ++i)
{
filesToZip[i] = mWorkingDirectory + RTABMAP_TMP_DIR + "/" + fileNames[i];
}
File toZIPFile = new File(zipOutput);
toZIPFile.delete();
try
{
Util.zip(filesToZip, zipOutput);
mToast.makeText(getActivity(), String.format("Mesh \"%s\" successfully exported!", pathHuman), mToast.LENGTH_LONG).show();
}
catch(IOException e)
{
mToast.makeText(getActivity(), String.format("Exporting mesh \"%s\" failed! Error=%s", pathHuman, e.getMessage()), mToast.LENGTH_LONG).show();
success = false;
}
}
catch(IOException e)
else
{
mToast.makeText(getActivity(), String.format("Exporting mesh \"%s\" failed! Error=%s", pathHuman, e.getMessage()), mToast.LENGTH_LONG).show();
mToast.makeText(getActivity(), String.format("Exporting mesh \"%s\" failed! No files found in tmp directory!?", pathHuman), mToast.LENGTH_LONG).show();
success = false;
}
}
@@ -2069,7 +2102,7 @@ public class RTABMapActivity extends Activity implements OnClickListener {
File toPLYFile = new File(path);
toPLYFile.delete();
File fromPLYFile = new File(mWorkingDirectory + RTABMAP_TMP_DIR + RTABMAP_TMP_FILENAME + ".ply");
File fromPLYFile = new File(mWorkingDirectory + RTABMAP_TMP_DIR + "/" + RTABMAP_TMP_FILENAME + ".ply");
try
{

View File

@@ -97,6 +97,7 @@ public class RTABMapLib
boolean regenerateCloud,
boolean meshing,
int textureSize,
int textureCount,
int normalK,
boolean optimized,
float optimizedVoxelSize,

View File

@@ -206,6 +206,7 @@ public class SettingsActivity extends PreferenceActivity implements OnSharedPref
((Preference)findPreference(getString(R.string.pref_key_cloud_voxel))).setSummary("("+((ListPreference)findPreference(getString(R.string.pref_key_cloud_voxel))).getEntry() + ") "+getString(R.string.pref_summary_cloud_voxel));
((Preference)findPreference(getString(R.string.pref_key_texture_size))).setSummary("("+((ListPreference)findPreference(getString(R.string.pref_key_texture_size))).getEntry() + ") "+getString(R.string.pref_summary_texture_size));
((Preference)findPreference(getString(R.string.pref_key_texture_count))).setSummary("("+((ListPreference)findPreference(getString(R.string.pref_key_texture_count))).getEntry() + ") "+getString(R.string.pref_summary_texture_count));
((Preference)findPreference(getString(R.string.pref_key_normal_k))).setSummary("("+((ListPreference)findPreference(getString(R.string.pref_key_normal_k))).getEntry() + ") "+getString(R.string.pref_summary_normal_k));
((Preference)findPreference(getString(R.string.pref_key_max_texture_distance))).setSummary("("+((ListPreference)findPreference(getString(R.string.pref_key_max_texture_distance))).getEntry() + ") "+getString(R.string.pref_summary_max_texture_distance));
((Preference)findPreference(getString(R.string.pref_key_min_texture_cluster_size))).setSummary("("+((ListPreference)findPreference(getString(R.string.pref_key_min_texture_cluster_size))).getEntry() + ") "+getString(R.string.pref_summary_min_texture_cluster_size));
@@ -262,6 +263,7 @@ public class SettingsActivity extends PreferenceActivity implements OnSharedPref
if(key.compareTo(getString(R.string.pref_key_cloud_voxel))==0) pref.setSummary("("+((ListPreference)pref).getEntry() + ") "+getString(R.string.pref_summary_cloud_voxel));
if(key.compareTo(getString(R.string.pref_key_texture_size))==0) pref.setSummary("("+((ListPreference)pref).getEntry() + ") "+getString(R.string.pref_summary_texture_size));
if(key.compareTo(getString(R.string.pref_key_texture_count))==0) pref.setSummary("("+((ListPreference)pref).getEntry() + ") "+getString(R.string.pref_summary_texture_count));
if(key.compareTo(getString(R.string.pref_key_normal_k))==0) pref.setSummary("("+((ListPreference)pref).getEntry() + ") "+getString(R.string.pref_summary_normal_k));
if(key.compareTo(getString(R.string.pref_key_max_texture_distance))==0) pref.setSummary("("+((ListPreference)pref).getEntry() + ") "+getString(R.string.pref_summary_max_texture_distance));
if(key.compareTo(getString(R.string.pref_key_min_texture_cluster_size))==0) pref.setSummary("("+((ListPreference)pref).getEntry() + ") "+getString(R.string.pref_summary_min_texture_cluster_size));