31 #include "CameraAvailability.h" 37 #include <media/NdkImage.h> 39 #ifdef RTABMAP_ARENGINE 54 #include <opencv2/opencv_modules.hpp> 65 #include <pcl/common/common.h> 66 #include <pcl/filters/extract_indices.h> 67 #include <pcl/io/ply_io.h> 68 #include <pcl/io/obj_io.h> 69 #include <pcl/surface/poisson.h> 70 #include <pcl/surface/vtk_smoothing/vtk_mesh_quadric_decimation.h> 92 parameters.insert(
rtabmap::ParametersPair(rtabmap::Parameters::kRtabmapPublishLikelihood(), std::string(
"false")));
100 parameters.insert(
rtabmap::ParametersPair(rtabmap::Parameters::kMemCompressionParallelized(), std::string(
"false")));
102 parameters.insert(
rtabmap::ParametersPair(rtabmap::Parameters::kRGBDOptimizeFromGraphEnd(), std::string(
"true")));
104 parameters.insert(
rtabmap::ParametersPair(rtabmap::Parameters::kRGBDProximityPathMaxNeighbors(), std::string(
"0")));
105 parameters.insert(
rtabmap::ParametersPair(rtabmap::Parameters::kRGBDProximityBySpace(), std::string(
"false")));
111 if(parameters.find(rtabmap::Parameters::kOptimizerStrategy()) != parameters.end())
113 if(parameters.at(rtabmap::Parameters::kOptimizerStrategy()).compare(
"2") == 0)
119 else if(parameters.at(rtabmap::Parameters::kOptimizerStrategy()).compare(
"1") == 0)
139 parameters.insert(
rtabmap::ParametersPair(rtabmap::Parameters::kIcpCorrespondenceRatio(), std::string(
"0.49")));
140 parameters.insert(
rtabmap::ParametersPair(rtabmap::Parameters::kIcpMaxCorrespondenceDistance(), std::string(
"0.05")));
208 env->GetJavaVM(&
jvm);
211 LOGI(
"RTABMapApp::RTABMapApp()");
231 LOGI(
"RTABMapApp::RTABMapApp() end");
235 LOGI(
"~RTABMapApp() begin");
255 LOGI(
"~RTABMapApp() end");
261 LOGI(
"Set orientation: display=%d camera=%d -> %d", displayRotation, cameraRotation, (
int)rotation);
271 int RTABMapApp::openDatabase(
const std::string & databasePath,
bool databaseInMemory,
bool optimize,
const std::string & databaseSource)
273 LOGW(
"Opening database %s (inMemory=%d, optimize=%d)", databasePath.c_str(), databaseInMemory?1:0, optimize?1:0);
286 bool restartThread =
false;
302 optMesh_.reset(
new pcl::TextureMesh);
311 std::vector<std::vector<std::vector<RTABMAP_PCL_INDEX> > > polygons;
312 #if PCL_VERSION_COMPARE(>=, 1, 8, 0) 313 std::vector<std::vector<Eigen::Vector2f, Eigen::aligned_allocator<Eigen::Vector2f> > > texCoords;
315 std::vector<std::vector<Eigen::Vector2f> > texCoords;
318 if(!databaseSource.empty())
325 if(!cloudMat.empty())
327 LOGI(
"Open: Found optimized mesh! Visualizing it.");
335 else if(
optMesh_->tex_polygons.size())
337 LOGI(
"Open: Polygon mesh");
340 else if(!
optMesh_->cloud.data.empty())
342 LOGI(
"Open: Point cloud");
348 LOGI(
"Open: No optimized mesh found.");
374 LOGI(
"Erasing database \"%s\"...", databasePath.c_str());
376 if(!databaseSource.empty())
378 LOGI(
"Copying database source \"%s\" to \"%s\"...", databaseSource.c_str(), databasePath.c_str());
388 LOGI(
"Initializing database...");
391 if(parameters.find(rtabmap::Parameters::kRtabmapDetectionRate()) != parameters.end())
397 std::map<int, rtabmap::Signature> signatures;
398 std::map<int, rtabmap::Transform> poses;
399 std::multimap<int, rtabmap::Link> links;
400 LOGI(
"Loading full map from database...");
413 if(signatures.size() && poses.empty())
415 LOGE(
"Failed to optimize the graph!");
420 LOGI(
"Creating the meshes (%d)....", (
int)poses.size());
425 for(std::map<int, rtabmap::Transform>::iterator iter=poses.begin(); iter!=poses.end() && status>=0; ++iter)
429 int id = iter->first;
430 if(!iter->second.isNull())
448 pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud;
449 pcl::IndicesPtr indices(
new std::vector<int>);
458 indices->resize(cloud->size());
459 for(
unsigned int i=0; i<cloud->size(); ++i)
464 if(cloud->size() && indices->size())
466 std::vector<pcl::Vertices> polygons;
467 std::vector<pcl::Vertices> polygonsLowRes;
478 inserted.first->second.cloud = cloud;
479 inserted.first->second.indices = indices;
480 inserted.first->second.polygons = polygons;
481 inserted.first->second.polygonsLowRes = polygonsLowRes;
482 inserted.first->second.visible =
true;
483 inserted.first->second.cameraModel = data.
cameraModels()[0];
484 inserted.first->second.gains[0] = 1.0;
485 inserted.first->second.gains[1] = 1.0;
486 inserted.first->second.gains[2] = 1.0;
492 cv::resize(data.
imageRaw(), inserted.first->second.texture, reducedSize, 0, 0, CV_INTER_LINEAR);
496 inserted.first->second.texture = data.
imageRaw();
499 LOGI(
"Created cloud %d (%fs)",
id, timer.
ticks());
503 LOGI(
"Cloud %d not added to created meshes",
id);
508 UWARN(
"Cloud %d is empty",
id);
513 UERROR(
"Failed to uncompress data!");
519 UWARN(
"Data for node %d not found",
id);
524 UWARN(
"Pose %d is null !?",
id);
535 UERROR(
"Exception! msg=\"%s\"", e.what());
538 catch (
const cv::Exception & e)
540 UERROR(
"Exception! msg=\"%s\"", e.what());
543 catch (
const std::exception & e)
545 UERROR(
"Exception! msg=\"%s\"", e.what());
561 if(optimize && status>=0)
566 LOGI(
"Polygon filtering...");
571 if(iter->second.polygons.size())
580 LOGI(
"Open: add rtabmap event to update the scene");
618 if(poses.empty() || status>0)
630 if(cameraDriver == 0)
639 if(cameraDriver == 1)
641 #ifdef RTABMAP_ARCORE 648 if(cameraDriver == 2)
650 #ifdef RTABMAP_ARENGINE 680 if (TangoService_setBinder(env, iBinder) != TANGO_SUCCESS) {
681 UERROR(
"TangoHandler::ConnectTango, TangoService_setBinder error");
687 UERROR(
"RTAB-Map is not built with Tango support!");
692 #ifdef RTABMAP_ARCORE 695 UERROR(
"RTAB-Map is not built with ARCore support!");
700 #ifdef RTABMAP_ARENGINE 703 UERROR(
"RTAB-Map is not built with AREngine support!");
739 if(height >= 480 && width % 20 == 0 && height % 20 == 0)
743 else if(width % 10 == 0 && height % 10 == 0)
747 else if(width % 15 == 0 && height % 15 == 0)
753 UERROR(
"Could not set decimation to high (size=%dx%d)", width, height);
758 if(height >= 480 && width % 10 == 0 && height % 10 == 0)
762 else if(width % 5 == 0 && height % 5 == 0)
768 UERROR(
"Could not set decimation to medium (size=%dx%d)", width, height);
773 if(height >= 480 && width % 5 == 0 && height % 5 == 0)
777 else if(width % 3 == 0 && width % 3 == 0)
781 else if(width % 2 == 0 && width % 2 == 0)
787 UERROR(
"Could not set decimation to low (size=%dx%d)", width, height);
793 LOGI(
"Start camera thread");
801 UERROR(
"Failed camera initialization!");
807 LOGI(
"stopCamera()");
821 const std::vector<pcl::Vertices> & polygons,
824 std::vector<int> vertexToCluster(cloudSize, 0);
825 std::map<int, std::list<int> > clusters;
826 int lastClusterID = 0;
828 for(
unsigned int i=0; i<polygons.size(); ++i)
831 for(
unsigned int j=0;j<polygons[i].vertices.size(); ++j)
833 if(vertexToCluster[polygons[i].
vertices[j]]>0)
835 clusterID = vertexToCluster[polygons[i].vertices[j]];
841 clusters.at(clusterID).push_back(i);
845 clusterID = ++lastClusterID;
846 std::list<int> polygons;
847 polygons.push_back(i);
848 clusters.insert(std::make_pair(clusterID, polygons));
850 for(
unsigned int j=0;j<polygons[i].vertices.size(); ++j)
852 vertexToCluster[polygons[i].vertices[j]] = clusterID;
856 unsigned int biggestClusterSize = 0;
857 for(std::map<
int, std::list<int> >::iterator iter=clusters.begin(); iter!=clusters.end(); ++iter)
859 LOGD(
"cluster %d = %d", iter->first, (
int)iter->second.size());
861 if(iter->second.size() > biggestClusterSize)
863 biggestClusterSize = iter->second.size();
866 unsigned int minClusterSize = (
unsigned int)(
float(biggestClusterSize)*
clusterRatio_);
867 LOGI(
"Biggest cluster %d -> minClusterSize(ratio=%f)=%d",
870 std::vector<pcl::Vertices> filteredPolygons(polygons.size());
872 for(std::map<
int, std::list<int> >::iterator iter=clusters.begin(); iter!=clusters.end(); ++iter)
874 if(iter->second.size() >= minClusterSize)
876 for(std::list<int>::iterator jter=iter->second.begin(); jter!=iter->second.end(); ++jter)
878 filteredPolygons[oi++] = polygons[*jter];
882 filteredPolygons.resize(oi);
883 return filteredPolygons;
888 const std::vector<pcl::Vertices> & polygons,
892 std::vector<std::set<int> > neighbors;
893 std::vector<std::set<int> > vertexToPolygons;
901 unsigned int biggestClusterSize = 0;
902 for(std::list<std::list<int> >::iterator iter=clusters.begin(); iter!=clusters.end(); ++iter)
904 if(iter->size() > biggestClusterSize)
906 biggestClusterSize = iter->size();
909 unsigned int minClusterSize = (
unsigned int)(
float(biggestClusterSize)*
clusterRatio_);
910 LOGI(
"Biggest cluster = %d -> minClusterSize(ratio=%f)=%d",
913 std::vector<pcl::Vertices> filteredPolygons(polygons.size());
915 for(std::list<std::list<int> >::iterator jter=clusters.begin(); jter!=clusters.end(); ++jter)
917 if(jter->size() >= minClusterSize)
919 for(std::list<int>::iterator kter=jter->begin(); kter!=jter->end(); ++kter)
921 filteredPolygons[oi++] = polygons.at(*kter);
925 filteredPolygons.resize(oi);
926 return filteredPolygons;
962 delete rtabmapEvent_;
977 cv::Mat depth = cv::Mat::zeros(mesh.
cloud->height, mesh.
cloud->width, CV_32FC1);
979 for(
unsigned int i=0; i<mesh.
indices->size(); ++i)
981 int index = mesh.
indices->at(i);
983 if(mesh.
cloud->at(index).x > 0)
986 depth.at<
float>(index) = pt.z;
991 LOGI(
"smoothMesh() Bilateral filtering of %d, time=%fs",
id, t.
ticks());
993 if(!depth.empty() && mesh.
indices->size())
995 pcl::IndicesPtr newIndices(
new std::vector<int>(mesh.
indices->size()));
997 for(
unsigned int i=0; i<mesh.
indices->size(); ++i)
999 int index = mesh.
indices->at(i);
1001 pcl::PointXYZRGB & pt = mesh.
cloud->at(index);
1003 if(depth.at<
float>(index) > 0)
1005 newPt.z = depth.at<
float>(index);
1007 newIndices->at(oi++) = index;
1011 newPt.x = newPt.y = newPt.z = std::numeric_limits<float>::quiet_NaN();
1017 newIndices->resize(oi);
1021 std::vector<pcl::Vertices> polygons;
1026 LOGI(
"smoothMesh() Reconstructing the mesh of %d, time=%fs",
id, t.
ticks());
1031 UERROR(
"smoothMesh() Failed to smooth surface %d",
id);
1039 UTimer tGainCompensation;
1040 LOGI(
"Gain compensation...");
1043 std::map<int, pcl::PointCloud<pcl::PointXYZRGB>::Ptr > clouds;
1044 std::map<int, pcl::IndicesPtr> indices;
1047 clouds.insert(std::make_pair(iter->first, iter->second.cloud));
1048 indices.insert(std::make_pair(iter->first, iter->second.indices));
1050 std::map<int, rtabmap::Transform> poses;
1051 std::multimap<int, rtabmap::Link> links;
1057 for(std::map<
int, pcl::PointCloud<pcl::PointXYZRGB>::Ptr>::const_iterator iter=clouds.begin(); iter!=clouds.end(); ++iter)
1059 int from = iter->first;
1060 std::map<int, pcl::PointCloud<pcl::PointXYZRGB>::Ptr>::const_iterator jter = iter;
1062 for(;jter!=clouds.end(); ++jter)
1064 int to = jter->first;
1072 if(clouds.size() > 1 && links.size())
1074 compensator.
feed(clouds, indices, links);
1075 LOGI(
"Gain compensation... compute gain: links=%d, time=%fs", (
int)links.size(), tGainCompensation.
ticks());
1080 if(!iter->second.cloud->empty())
1082 if(clouds.size() > 1 && links.size())
1084 compensator.
getGain(iter->first, &iter->second.gains[0], &iter->second.gains[1], &iter->second.gains[2]);
1085 LOGI(
"%d mesh has gain %f,%f,%f", iter->first, iter->second.gains[0], iter->second.gains[1], iter->second.gains[2]);
1089 LOGI(
"Gain compensation... applying gain: meshes=%d, time=%fs", (
int)
createdMeshes_.size(), tGainCompensation.
ticks());
1095 std::list<rtabmap::RtabmapEvent*> rtabmapEvents;
1099 #ifdef DEBUG_RENDERING_PERFORMANCE 1104 bool notifyDataLoaded =
false;
1105 bool notifyCameraStarted =
false;
1113 const float* uvsTransformed = 0;
1122 #ifdef RTABMAP_ARCORE 1131 #ifdef RTABMAP_ARCORE 1151 pcl::IndicesPtr indices(
new std::vector<int>);
1154 occlusionMesh.
cloud.reset(
new pcl::PointCloud<pcl::PointXYZRGB>());
1155 pcl::copyPointCloud(*cloud, *occlusionMesh.
cloud);
1156 occlusionMesh.
indices = indices;
1161 UERROR(
"invalid occlusionModel: %f %f %f %f %dx%d", occlusionModel.
fx(), occlusionModel.
fy(), occlusionModel.
cx(), occlusionModel.
cy(), occlusionModel.
imageWidth(), occlusionModel.
imageHeight());
1185 LOGI(
"Process odom events");
1190 notifyCameraStarted =
true;
1209 notifyCameraStarted =
true;
1224 LOGI(
"Adding optimized mesh to opengl (%d points, %d polygons, %d tex_coords, materials=%d texture=%dx%d)...",
1227 optMesh_->tex_coordinates.size()!=1?0:(int)
optMesh_->tex_coordinates[0].size(),
1228 (int)
optMesh_->tex_materials.size(),
1234 mesh.
cloud.reset(
new pcl::PointCloud<pcl::PointXYZRGB>);
1235 mesh.
normals.reset(
new pcl::PointCloud<pcl::Normal>);
1240 if(
optMesh_->tex_coordinates.size())
1249 pcl::IndicesPtr indices(
new std::vector<int>);
1250 pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud(
new pcl::PointCloud<pcl::PointXYZRGB>);
1251 pcl::fromPCLPointCloud2(
optMesh_->cloud, *cloud);
1263 if(rtabmapEvents.size())
1271 std::map<int, rtabmap::Transform>::const_iterator iter = stats.
poses().find(
optRefId_);
1277 int fastMovement = (int)
uValue(stats.
data(), rtabmap::Statistics::kMemoryFast_movement(), 0.0f);
1278 int loopClosure = (int)
uValue(stats.
data(), rtabmap::Statistics::kLoopAccepted_hypothesis_id(), 0.0f);
1279 int rejected = (int)
uValue(stats.
data(), rtabmap::Statistics::kLoopRejectedHypothesis(), 0.0f);
1280 int landmark = (int)
uValue(stats.
data(), rtabmap::Statistics::kLoopLandmark_detected(), 0.0f);
1321 if(rtabmapEvents.size())
1325 rtabmapEvents.pop_back();
1327 for(std::list<rtabmap::RtabmapEvent*>::iterator iter=rtabmapEvents.begin(); iter!=rtabmapEvents.end(); ++iter)
1331 rtabmapEvents.clear();
1340 optMesh_.reset(
new pcl::TextureMesh);
1357 if(rtabmapEvents.front()->getStats().refImageId()>0 && rtabmapEvents.front()->getStats().refImageId() <
createdMeshes_.rbegin()->first)
1359 LOGI(
"Detected new database! new=%d old=%d", rtabmapEvents.front()->getStats().refImageId(),
createdMeshes_.rbegin()->first);
1364 #ifdef DEBUG_RENDERING_PERFORMANCE 1365 if(rtabmapEvents.size())
1367 LOGW(
"begin and getting rtabmap events %fs", time.
ticks());
1374 LOGI(
"Clearing all rendering data...");
1388 LOGI(
"Clearing meshes...");
1393 notifyDataLoaded =
true;
1412 if(added.size() != meshes)
1414 LOGI(
"added (%d) != meshes (%d)", (
int)added.size(), meshes);
1421 LOGI(
"Re-add mesh %d to OpenGL context", iter->first);
1432 if(!textureRaw.empty())
1437 LOGD(
"resize image from %dx%d to %dx%d", textureRaw.cols, textureRaw.rows, reducedSize.width, reducedSize.height);
1438 cv::resize(textureRaw, iter->second.texture, reducedSize, 0, 0, CV_INTER_LINEAR);
1442 iter->second.texture = textureRaw;
1449 iter->second.texture = cv::Mat();
1454 else if(notifyDataLoaded)
1463 if(rtabmapEvents.size())
1465 #ifdef DEBUG_RENDERING_PERFORMANCE 1466 LOGW(
"Process rtabmap events %fs", time.
ticks());
1468 LOGI(
"Process rtabmap events");
1472 std::map<int, rtabmap::SensorData> bufferedSensorData;
1475 for(std::list<rtabmap::RtabmapEvent*>::iterator iter=rtabmapEvents.begin(); iter!=rtabmapEvents.end(); ++iter)
1480 int smallMovement = (int)
uValue(stats.
data(), rtabmap::Statistics::kMemorySmall_movement(), 0.0f);
1481 int fastMovement = (int)
uValue(stats.
data(), rtabmap::Statistics::kMemoryFast_movement(), 0.0f);
1482 int rehearsalMerged = (int)
uValue(stats.
data(), rtabmap::Statistics::kMemoryRehearsal_merged(), 0.0f);
1484 smallMovement == 0 && rehearsalMerged == 0 && fastMovement == 0)
1499 int loopClosure = (int)
uValue(stats.
data(), rtabmap::Statistics::kLoopAccepted_hypothesis_id(), 0.0f);
1500 int rejected = (int)
uValue(stats.
data(), rtabmap::Statistics::kLoopRejectedHypothesis(), 0.0f);
1501 int landmark = (int)
uValue(stats.
data(), rtabmap::Statistics::kLoopLandmark_detected(), 0.0f);
1529 #ifdef DEBUG_RENDERING_PERFORMANCE 1530 LOGW(
"Looking for data to load (%d) %fs", (
int)bufferedSensorData.size(), time.
ticks());
1533 std::map<int, rtabmap::Transform> posesWithMarkers = rtabmapEvents.back()->getStats().poses();
1534 if(!rtabmapEvents.back()->getStats().mapCorrection().isNull())
1536 mapToOdom_ = rtabmapEvents.back()->getStats().mapCorrection();
1540 for(std::map<int, rtabmap::Transform>::iterator iter=posesWithMarkers.begin(); iter!=posesWithMarkers.end(); ++iter)
1544 std::map<int, rtabmap::Transform>::iterator jter =
rawPoses_.find(iter->first);
1556 std::map<int, rtabmap::Transform> poses(posesWithMarkers.lower_bound(0), posesWithMarkers.end());
1557 const std::multimap<int, rtabmap::Link> & links = rtabmapEvents.back()->getStats().constraints();
1563 #ifdef DEBUG_RENDERING_PERFORMANCE 1564 LOGW(
"Update graph: %fs", time.
ticks());
1569 std::set<std::string> strIds;
1570 for(std::map<int, rtabmap::Transform>::iterator iter=poses.begin(); iter!=poses.end(); ++iter)
1572 int id = iter->first;
1573 if(!iter->second.isNull())
1580 std::map<int, rtabmap::Mesh>::iterator meshIter =
createdMeshes_.find(
id);
1583 meshIter->second.visible =
true;
1588 bufferedSensorData.find(
id) != bufferedSensorData.end())
1592 cv::Mat tmpA, depth;
1599 #ifdef DEBUG_RENDERING_PERFORMANCE 1600 LOGW(
"Decompressing data: %fs", time.
ticks());
1606 pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud;
1607 pcl::IndicesPtr indices(
new std::vector<int>);
1616 indices->resize(cloud->size());
1617 for(
unsigned int i=0; i<cloud->size(); ++i)
1622 #ifdef DEBUG_RENDERING_PERFORMANCE 1625 if(cloud->size() && indices->size())
1627 std::vector<pcl::Vertices> polygons;
1628 std::vector<pcl::Vertices> polygonsLowRes;
1632 #ifdef DEBUG_RENDERING_PERFORMANCE 1633 LOGW(
"Creating mesh, %d polygons (%fs)", (
int)polygons.size(), time.
ticks());
1636 #ifdef DEBUG_RENDERING_PERFORMANCE 1637 LOGW(
"Creating mesh, %d polygons (%fs)", (
int)polygons.size(), time.
ticks());
1645 inserted.first->second.cloud = cloud;
1646 inserted.first->second.indices = indices;
1647 inserted.first->second.polygons = polygons;
1648 inserted.first->second.polygonsLowRes = polygonsLowRes;
1649 inserted.first->second.visible =
true;
1650 inserted.first->second.cameraModel = data.
cameraModels()[0];
1651 inserted.first->second.gains[0] = 1.0;
1652 inserted.first->second.gains[1] = 1.0;
1653 inserted.first->second.gains[2] = 1.0;
1659 cv::resize(data.
imageRaw(), inserted.first->second.texture, reducedSize, 0, 0, CV_INTER_LINEAR);
1660 #ifdef DEBUG_RENDERING_PERFORMANCE 1661 LOGW(
"resize image from %dx%d to %dx%d (%fs)", data.
imageRaw().cols, data.
imageRaw().rows, reducedSize.width, reducedSize.height, time.
ticks());
1666 inserted.first->second.texture = data.
imageRaw();
1680 #ifdef DEBUG_RENDERING_PERFORMANCE 1681 LOGW(
"Adding mesh to scene: %fs", time.
ticks());
1691 if(poses.size() > 2)
1695 for(std::multimap<int, rtabmap::Link>::const_iterator iter=links.begin(); iter!=links.end(); ++iter)
1699 int oldId = iter->second.to()>iter->second.from()?iter->second.from():iter->second.to();
1711 for(std::set<int>::const_iterator iter=addedClouds.begin();
1712 iter!=addedClouds.end();
1715 if(*iter > 0 && poses.find(*iter) == poses.end())
1718 std::map<int, rtabmap::Mesh>::iterator meshIter =
createdMeshes_.find(*iter);
1720 meshIter->second.visible =
false;
1727 for(std::set<int>::const_iterator iter=addedMarkers.begin();
1728 iter!=addedMarkers.end();
1731 if(posesWithMarkers.find(*iter) == posesWithMarkers.end())
1736 for(std::map<int, rtabmap::Transform>::const_iterator iter=posesWithMarkers.begin();
1737 iter!=posesWithMarkers.end() && iter->first<0;
1740 int id = iter->first;
1763 pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud;
1764 pcl::IndicesPtr indices(
new std::vector<int>);
1773 indices->resize(cloud->size());
1774 for(
unsigned int i=0; i<cloud->size(); ++i)
1780 if(cloud->size() && indices->size())
1782 LOGI(
"Created odom cloud (rgb=%dx%d depth=%dx%d cloud=%dx%d)",
1785 (int)cloud->width, (
int)cloud->height);
1791 UERROR(
"Generated cloud is empty!");
1796 UERROR(
"Odom data images are empty!");
1807 main_scene_.
updateGains(iter->first, iter->second.gains[0], iter->second.gains[1], iter->second.gains[2]);
1810 notifyDataLoaded =
true;
1815 LOGI(
"Bilateral filtering...");
1820 if(iter->second.cloud->size() && iter->second.indices->size())
1828 notifyDataLoaded =
true;
1833 LOGI(
"Polygon filtering...");
1839 if(iter->second.polygons.size())
1846 notifyDataLoaded =
true;
1857 if(rtabmapEvents.size())
1862 rtabmapEvents.pop_back();
1864 for(std::list<rtabmap::RtabmapEvent*>::iterator iter=rtabmapEvents.begin(); iter!=rtabmapEvents.end(); ++iter)
1868 rtabmapEvents.clear();
1874 UERROR(
"TangoPoseEventNotReceived");
1885 cv::Mat image(h, w, CV_8UC4);
1886 glReadPixels(0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, image.data);
1887 cv::flip(image, image, 0);
1888 cv::cvtColor(image, image, CV_RGBA2BGRA);
1892 int offset = (w-h)/2;
1897 int offset = (h-w)/2;
1901 LOGI(
"Saving screenshot %dx%d...", roi.cols, roi.rows);
1910 double renderTime = fpsTime.
elapsed();
1911 if(0.2 - renderTime > 0.0)
1913 uSleep((0.2 - renderTime)*1000);
1920 double updateInterval = 1.0;
1930 if(interval >= updateInterval)
1941 return notifyDataLoaded||notifyCameraStarted?1:0;
1945 for(std::list<rtabmap::RtabmapEvent*>::iterator iter=rtabmapEvents.begin(); iter!=rtabmapEvents.end(); ++iter)
1949 rtabmapEvents.clear();
1950 UERROR(
"Exception! msg=\"%s\"", e.what());
1953 catch(
const cv::Exception & e)
1955 for(std::list<rtabmap::RtabmapEvent*>::iterator iter=rtabmapEvents.begin(); iter!=rtabmapEvents.end(); ++iter)
1959 rtabmapEvents.clear();
1960 UERROR(
"Exception! msg=\"%s\"", e.what());
1963 catch(
const std::exception & e)
1965 for(std::list<rtabmap::RtabmapEvent*>::iterator iter=rtabmapEvents.begin(); iter!=rtabmapEvents.end(); ++iter)
1969 rtabmapEvents.clear();
1970 UERROR(
"Exception! msg=\"%s\"", e.what());
1982 float x0,
float y0,
float x1,
float y1) {
2073 std::map<int, rtabmap::Transform> poses;
2074 std::multimap<int, rtabmap::Link> links;
2083 LOGI(
"Send rtabmap event to update graph...");
2219 std::string compatibleKey = key;
2225 if(iter->second.first)
2228 compatibleKey = iter->second.second;
2229 LOGW(
"Parameter name changed: \"%s\" -> \"%s\". Please update the code accordingly. Value \"%s\" is still set to the new parameter name.",
2230 iter->first.c_str(), iter->second.second.c_str(), value.c_str());
2234 if(iter->second.second.empty())
2236 UERROR(
"Parameter \"%s\" doesn't exist anymore!",
2237 iter->first.c_str());
2241 UERROR(
"Parameter \"%s\" doesn't exist anymore! You may look at this similar parameter: \"%s\"",
2242 iter->first.c_str(), iter->second.second.c_str());
2249 LOGI(
"%s",
uFormat(
"Setting param \"%s\" to \"%s\"", compatibleKey.c_str(), value.c_str()).c_str());
2256 UERROR(
uFormat(
"Key \"%s\" doesn't exist!", compatibleKey.c_str()).c_str());
2281 LOGI(
"Saving database to %s", databasePath.c_str());
2285 LOGI(
"Taking screenshot...");
2289 UERROR(
"Failed to take a screenshot after 2 sec!");
2311 if(appendModeBackup || dataRecorderModeBackup || localizationModeBackup)
2332 UWARN(
"Processing canceled!");
2337 float cloudVoxelSize,
2338 bool regenerateCloud,
2344 float optimizedVoxelSize,
2346 int optimizedMaxPolygons,
2347 float optimizedColorRadius,
2348 bool optimizedCleanWhitePolygons,
2349 int optimizedMinClusterSize,
2350 float optimizedMaxTextureDistance,
2351 int optimizedMinTextureClusterSize,
2352 bool blockRendering)
2361 std::multimap<int, rtabmap::Link> links;
2369 UERROR(
"Empty optimized poses!");
2383 bool success =
false;
2388 totalSteps+=poses.size();
2393 totalSteps += poses.size();
2399 if(optimizedMaxPolygons > 0)
2409 totalSteps+=poses.size()+1;
2414 totalSteps += poses.size()+1;
2424 pcl::PolygonMesh::Ptr polygonMesh(
new pcl::PolygonMesh);
2425 pcl::TextureMesh::Ptr textureMesh(
new pcl::TextureMesh);
2426 std::vector<std::map<int, pcl::PointXY> > vertexToPixels;
2427 cv::Mat globalTextures;
2428 int totalPolygons = 0;
2432 std::map<int, rtabmap::Transform> cameraPoses;
2433 std::map<int, rtabmap::CameraModel> cameraModels;
2434 std::map<int, cv::Mat> cameraDepths;
2437 LOGI(
"Assemble clouds (%d)...", (
int)poses.size());
2441 pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr mergedClouds(
new pcl::PointCloud<pcl::PointXYZRGBNormal>);
2442 for(std::map<int, rtabmap::Transform>::iterator iter=poses.begin();
2446 std::map<int, rtabmap::Mesh>::iterator jter =
createdMeshes_.find(iter->first);
2447 pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud(
new pcl::PointCloud<pcl::PointXYZRGB>);
2448 pcl::IndicesPtr indices(
new std::vector<int>);
2452 gains[0] = gains[1] = gains[2] = 1.0f;
2455 cloud = jter->second.cloud;
2456 indices = jter->second.indices;
2457 model = jter->second.cameraModel;
2458 gains[0] = jter->second.gains[0];
2459 gains[1] = jter->second.gains[1];
2460 gains[2] = jter->second.gains[2];
2478 pcl::PointCloud<pcl::PointXYZRGB>::Ptr transformedCloud(
new pcl::PointCloud<pcl::PointXYZRGB>);
2479 if(optimizedVoxelSize > 0.0
f)
2488 pcl::copyPointCloud(*cloud, *indices, *transformedCloud);
2492 Eigen::Vector3f viewpoint( iter->second.x(), iter->second.y(), iter->second.z());
2495 pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr cloudWithNormals(
new pcl::PointCloud<pcl::PointXYZRGBNormal>);
2496 pcl::concatenateFields(*transformedCloud, *normals, *cloudWithNormals);
2498 if(textureSize == 0 && (gains[0] != 1.0 || gains[1] != 1.0 || gains[2] != 1.0))
2500 for(
unsigned int i=0; i<cloudWithNormals->size(); ++i)
2502 pcl::PointXYZRGBNormal & pt = cloudWithNormals->at(i);
2510 if(mergedClouds->size() == 0)
2512 *mergedClouds = *cloudWithNormals;
2516 *mergedClouds += *cloudWithNormals;
2519 cameraPoses.insert(std::make_pair(iter->first, iter->second));
2520 cameraModels.insert(std::make_pair(iter->first, model));
2523 cameraDepths.insert(std::make_pair(iter->first, depth));
2526 LOGI(
"Assembled %d points (%d/%d total=%d)", (
int)cloudWithNormals->size(), ++cloudCount, (int)poses.size(), (int)mergedClouds->size());
2530 UERROR(
"Cloud %d not found or empty", iter->first);
2544 LOGI(
"Assembled clouds (%d)... done! %fs (total points=%d)", (
int)cameraPoses.size(), timer.
ticks(), (int)mergedClouds->size());
2546 if(mergedClouds->size()>=3)
2548 if(optimizedDepth == 0)
2552 float mapLength =
uMax3(max[0]-min[0], max[1]-min[1], max[2]-min[2]);
2553 optimizedDepth = 12;
2554 for(
int i=6; i<12; ++i)
2556 if(mapLength/
float(1<<i) < 0.03
f)
2562 LOGI(
"optimizedDepth=%d (map length=%f)", optimizedDepth, mapLength);
2566 LOGI(
"Mesh reconstruction...");
2567 pcl::PolygonMesh::Ptr mesh(
new pcl::PolygonMesh);
2568 pcl::Poisson<pcl::PointXYZRGBNormal> poisson;
2569 poisson.setDepth(optimizedDepth);
2570 poisson.setInputCloud(mergedClouds);
2571 poisson.reconstruct(*mesh);
2572 LOGI(
"Mesh reconstruction... done! %fs (%d polygons)", timer.
ticks(), (int)mesh->polygons.size());
2586 if(mesh->polygons.size())
2588 totalPolygons=(int)mesh->polygons.size();
2590 if(optimizedMaxPolygons > 0 && optimizedMaxPolygons < (
int)mesh->polygons.size())
2593 unsigned int count = mesh->polygons.size();
2594 float factor = 1.0f-float(optimizedMaxPolygons)/float(count);
2595 LOGI(
"Mesh decimation (max polygons %d/%d -> factor=%f)...", optimizedMaxPolygons, (
int)count, factor);
2599 pcl::PolygonMesh::Ptr output(
new pcl::PolygonMesh);
2600 pcl::MeshQuadricDecimationVTK mqd;
2601 mqd.setTargetReductionFactor(factor);
2602 mqd.setInputMesh(mesh);
2603 mqd.process (*output);
2611 LOGI(
"Mesh decimated (factor=%f) from %d to %d polygons (%fs)", factor, count, (
int)mesh->polygons.size(), timer.
ticks());
2612 if(count < mesh->polygons.size())
2614 UWARN(
"Decimated mesh has more polygons than before!");
2617 UWARN(
"RTAB-Map is not built with PCL-VTK module so mesh decimation cannot be used!");
2633 rtabmap::util3d::denseMeshPostProcessing<pcl::PointXYZRGBNormal>(
2638 optimizedColorRadius,
2640 optimizedCleanWhitePolygons,
2641 optimizedMinClusterSize);
2645 LOGI(
"Texturing... cameraPoses=%d, cameraDepths=%d", (
int)cameraPoses.size(), (int)cameraDepths.size());
2651 optimizedMaxTextureDistance,
2654 optimizedMinTextureClusterSize,
2655 std::vector<float>(),
2658 LOGI(
"Texturing... done! %fs", timer.
ticks());
2671 if(textureMesh->tex_coordinates.size() && optimizedCleanWhitePolygons)
2673 LOGI(
"Cleanup mesh...");
2675 LOGI(
"Cleanup mesh... done! %fs", timer.
ticks());
2679 for(
unsigned int t=0; t<textureMesh->tex_polygons.size(); ++t)
2681 totalPolygons+=textureMesh->tex_polygons[t].size();
2686 totalPolygons = (int)mesh->polygons.size();
2693 UERROR(
"Merged cloud too small (%d points) to create polygons!", (
int)mergedClouds->size());
2698 pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr mergedClouds(
new pcl::PointCloud<pcl::PointXYZRGBNormal>);
2702 textureMesh->tex_materials.resize(poses.size());
2703 textureMesh->tex_polygons.resize(poses.size());
2704 textureMesh->tex_coordinates.resize(poses.size());
2707 int polygonsStep = 0;
2709 for(std::map<int, rtabmap::Transform>::iterator iter=poses.begin();
2713 LOGI(
"Assembling cloud %d (total=%d)...", iter->first, (
int)poses.size());
2715 std::map<int, rtabmap::Mesh>::iterator jter =
createdMeshes_.find(iter->first);
2716 pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud(
new pcl::PointCloud<pcl::PointXYZRGB>);
2717 std::vector<pcl::Vertices> polygons;
2718 float gains[3] = {1.0f};
2721 cloud = jter->second.cloud;
2722 polygons= jter->second.polygons;
2723 if(cloud->size() && polygons.size() == 0)
2727 gains[0] = jter->second.gains[0];
2728 gains[1] = jter->second.gains[1];
2729 gains[2] = jter->second.gains[2];
2742 if(cloud->size() && polygons.size())
2745 pcl::PointCloud<pcl::PointXYZRGB>::Ptr outputCloud(
new pcl::PointCloud<pcl::PointXYZRGB>);
2746 std::vector<pcl::Vertices> outputPolygons;
2751 pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr cloudWithNormals(
new pcl::PointCloud<pcl::PointXYZRGBNormal>);
2752 pcl::concatenateFields(*outputCloud, *normals, *cloudWithNormals);
2754 UASSERT(outputPolygons.size());
2756 totalPolygons+=outputPolygons.size();
2758 if(textureSize == 0)
2763 if(gains[0] != 1.0
f || gains[1] != 1.0
f || gains[2] != 1.0
f)
2765 for(
unsigned int i=0; i<cloudWithNormals->size(); ++i)
2767 pcl::PointXYZRGBNormal & pt = cloudWithNormals->at(i);
2774 if(mergedClouds->size() == 0)
2776 *mergedClouds = *cloudWithNormals;
2777 polygonMesh->polygons = outputPolygons;
2787 unsigned int polygonSize = outputPolygons.front().vertices.size();
2788 textureMesh->tex_polygons[oi].resize(outputPolygons.size());
2789 textureMesh->tex_coordinates[oi].resize(outputPolygons.size() * polygonSize);
2790 for(
unsigned int j=0; j<outputPolygons.size(); ++j)
2792 pcl::Vertices
vertices = outputPolygons[j];
2793 UASSERT(polygonSize == vertices.vertices.size());
2794 for(
unsigned int k=0; k<vertices.vertices.size(); ++k)
2797 UASSERT(vertices.vertices[k] < denseToOrganizedIndices.size());
2798 int originalVertex = denseToOrganizedIndices[vertices.vertices[k]];
2799 textureMesh->tex_coordinates[oi][j*vertices.vertices.size()+k] = Eigen::Vector2f(
2800 float(originalVertex % cloud->width) /
float(cloud->width),
2801 float(cloud->height - originalVertex / cloud->width) /
float(cloud->height));
2803 vertices.vertices[k] += polygonsStep;
2805 textureMesh->tex_polygons[oi][j] =
vertices;
2808 polygonsStep += outputCloud->size();
2811 if(mergedClouds->size() == 0)
2813 *mergedClouds = *transformedCloud;
2817 *mergedClouds += *transformedCloud;
2820 textureMesh->tex_materials[oi].tex_illum = 1;
2821 textureMesh->tex_materials[oi].tex_name =
uFormat(
"material_%d", iter->first);
2822 textureMesh->tex_materials[oi].tex_file =
uNumber2Str(iter->first);
2828 UERROR(
"Mesh not found for mesh %d", iter->first);
2842 if(textureSize == 0)
2844 if(mergedClouds->size())
2846 pcl::toPCLPointCloud2(*mergedClouds, polygonMesh->cloud);
2850 polygonMesh->polygons.clear();
2855 textureMesh->tex_materials.resize(oi);
2856 textureMesh->tex_polygons.resize(oi);
2858 if(mergedClouds->size())
2860 pcl::toPCLPointCloud2(*mergedClouds, textureMesh->cloud);
2867 if(textureSize>0 && totalPolygons && textureMesh->tex_materials.size())
2869 LOGI(
"Merging %d textures...", (
int)textureMesh->tex_materials.size());
2872 std::map<int, cv::Mat>(),
2873 std::map<
int, std::vector<rtabmap::CameraModel> >(),
2879 true, 10.0f,
true ,
true, 0, 0, 0,
false,
2896 if(textureSize == 0)
2898 UASSERT((
int)polygonMesh->polygons.size() == totalPolygons);
2899 if(polygonMesh->polygons.size())
2902 pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr cloud(
new pcl::PointCloud<pcl::PointXYZRGBNormal>);
2903 pcl::fromPCLPointCloud2(polygonMesh->cloud, *cloud);
2905 std::vector<std::vector<std::vector<RTABMAP_PCL_INDEX> > > polygons(1);
2906 polygons[0].resize(polygonMesh->polygons.size());
2907 for(
unsigned int p=0; p<polygonMesh->polygons.size(); ++p)
2909 polygons[0][p] = polygonMesh->polygons[p].vertices;
2917 else if(textureMesh->tex_materials.size())
2919 pcl::PointCloud<pcl::PointNormal>::Ptr cloud(
new pcl::PointCloud<pcl::PointNormal>);
2920 pcl::fromPCLPointCloud2(textureMesh->cloud, *cloud);
2924 std::vector<std::vector<std::vector<RTABMAP_PCL_INDEX> > > polygons(textureMesh->tex_polygons.size());
2925 for(
unsigned int t=0; t<textureMesh->tex_polygons.size(); ++t)
2927 polygons[t].resize(textureMesh->tex_polygons[t].size());
2928 for(
unsigned int p=0; p<textureMesh->tex_polygons[t].size(); ++p)
2930 polygons[t][p] = textureMesh->tex_polygons[t][p].vertices;
2939 UERROR(
"Failed exporting texture mesh! There are no textures!");
2944 UERROR(
"Failed exporting mesh! There are no polygons!");
2949 pcl::PointCloud<pcl::PointXYZRGB>::Ptr mergedClouds(
new pcl::PointCloud<pcl::PointXYZRGB>);
2950 for(std::map<int, rtabmap::Transform>::iterator iter=poses.begin();
2954 std::map<int, rtabmap::Mesh>::iterator jter=
createdMeshes_.find(iter->first);
2955 pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud(
new pcl::PointCloud<pcl::PointXYZRGB>);
2956 pcl::IndicesPtr indices(
new std::vector<int>);
2958 gains[0] = gains[1] = gains[2] = 1.0f;
2963 gains[0] = jter->second.gains[0];
2964 gains[1] = jter->second.gains[1];
2965 gains[2] = jter->second.gains[2];
2979 cloud = jter->second.cloud;
2980 indices = jter->second.indices;
2981 gains[0] = jter->second.gains[0];
2982 gains[1] = jter->second.gains[1];
2983 gains[2] = jter->second.gains[2];
2995 if(cloud->size() && indices->size())
2998 pcl::PointCloud<pcl::PointXYZRGB>::Ptr transformedCloud(
new pcl::PointCloud<pcl::PointXYZRGB>);
2999 if(cloudVoxelSize > 0.0
f)
3008 pcl::copyPointCloud(*cloud, *indices, *transformedCloud);
3012 if(gains[0] != 1.0
f || gains[1] != 1.0
f || gains[2] != 1.0
f)
3015 for(
unsigned int i=0; i<transformedCloud->size(); ++i)
3017 pcl::PointXYZRGB & pt = transformedCloud->at(i);
3026 if(mergedClouds->size() == 0)
3028 *mergedClouds = *transformedCloud;
3032 *mergedClouds += *transformedCloud;
3048 if(mergedClouds->size())
3050 if(cloudVoxelSize > 0.0
f)
3065 UERROR(
"Merged cloud is empty!");
3076 catch (std::exception &
e)
3078 UERROR(
"Out of memory! %s", e.what());
3095 if(success && poses.size())
3108 LOGI(
"postExportation(visualize=%d)", visualize?1:0);
3109 optMesh_.reset(
new pcl::TextureMesh);
3117 std::vector<std::vector<std::vector<RTABMAP_PCL_INDEX> > > polygons;
3118 #if PCL_VERSION_COMPARE(>=, 1, 8, 0) 3119 std::vector<std::vector<Eigen::Vector2f, Eigen::aligned_allocator<Eigen::Vector2f> > > texCoords;
3121 std::vector<std::vector<Eigen::Vector2f> > texCoords;
3127 if(!cloudMat.empty())
3129 LOGI(
"postExportation: Found optimized mesh! Visualizing it.");
3139 LOGI(
"postExportation: No optimized mesh found.");
3166 LOGI(
"writeExportedMesh: dir=%s name=%s", directory.c_str(), name.c_str());
3169 bool success =
false;
3171 pcl::PolygonMesh::Ptr polygonMesh(
new pcl::PolygonMesh);
3172 pcl::TextureMesh::Ptr textureMesh(
new pcl::TextureMesh);
3174 std::vector<std::vector<std::vector<RTABMAP_PCL_INDEX> > > polygons;
3175 #if PCL_VERSION_COMPARE(>=, 1, 8, 0) 3176 std::vector<std::vector<Eigen::Vector2f, Eigen::aligned_allocator<Eigen::Vector2f> > > texCoords;
3178 std::vector<std::vector<Eigen::Vector2f> > texCoords;
3184 if(!cloudMat.empty())
3186 LOGI(
"writeExportedMesh: Found optimized mesh!");
3187 if(textures.empty())
3198 LOGI(
"writeExportedMesh: No optimized mesh found.");
3202 if(polygonMesh->cloud.data.size())
3206 LOGI(
"Saving ply (%d vertices, %d polygons) to %s.", (
int)polygonMesh->cloud.data.size()/polygonMesh->cloud.point_step, (int)polygonMesh->polygons.size(), filePath.c_str());
3207 success = pcl::io::savePLYFileBinary(filePath, *polygonMesh) == 0;
3210 LOGI(
"Saved ply to %s!", filePath.c_str());
3214 UERROR(
"Failed saving ply to %s!", filePath.c_str());
3217 else if(textureMesh->cloud.data.size())
3220 LOGD(
"Saving texture(s) (%d)", textures.empty()?0:textures.cols/textures.rows);
3221 UASSERT(textures.empty() || textures.cols % textures.rows == 0);
3222 UASSERT((
int)textureMesh->tex_materials.size() == textures.cols/textures.rows);
3223 for(
unsigned int i=0; i<textureMesh->tex_materials.size(); ++i)
3225 std::string baseNameNum = name;
3226 if(textureMesh->tex_materials.size()>1)
3231 textureMesh->tex_materials[i].tex_file = baseNameNum+
".jpg";
3232 LOGI(
"Saving texture to %s.", fullPath.c_str());
3233 success = cv::imwrite(fullPath, textures(
cv::Range::all(), cv::Range(i*textures.rows, (i+1)*textures.rows)));
3236 LOGI(
"Failed saving %s!", fullPath.c_str());
3240 LOGI(
"Saved %s.", fullPath.c_str());
3247 pcl::PointCloud<pcl::PointNormal>::Ptr cloud(
new pcl::PointCloud<pcl::PointNormal>);
3248 pcl::fromPCLPointCloud2(textureMesh->cloud, *cloud);
3249 cloud =
rtabmap::util3d::transformPointCloud(cloud,
rtabmap::Transform(1,0,0,0, 0,0,1,0, 0,-1,0,0));
3250 pcl::toPCLPointCloud2(*cloud, textureMesh->cloud);
3252 int totalPolygons = 0;
3253 for(
unsigned int i=0;i<textureMesh->tex_polygons.size(); ++i)
3255 totalPolygons += textureMesh->tex_polygons[i].size();
3257 LOGI(
"Saving obj (%d vertices, %d polygons) to %s.", (
int)textureMesh->cloud.data.size()/textureMesh->cloud.point_step, totalPolygons, filePath.c_str());
3258 success = pcl::io::saveOBJFile(filePath, *textureMesh) == 0;
3262 LOGI(
"Saved obj to %s!", filePath.c_str());
3266 UERROR(
"Failed saving obj to %s!", filePath.c_str());
3277 LOGI(
"postProcessing(%d)", approach);
3278 int returnedValue = 0;
3281 std::map<int, rtabmap::Transform> poses;
3282 std::multimap<int, rtabmap::Link> links;
3285 if(approach == -1 || approach == 2)
3300 if(returnedValue >=0)
3306 std::map<int, rtabmap::Signature> signatures;
3313 poses = sba->
optimizeBA(poses.rbegin()->first, poses, links, signatures);
3318 UERROR(
"g2o not available!");
3321 else if(approach!=4 && approach!=5 && approach != 7)
3335 LOGI(
"PostProcessing, sending rtabmap event to update graph...");
3340 else if(approach!=4 && approach!=5 && approach != 7)
3345 if(returnedValue >=0)
3349 if(approach == -1 || approach == 4)
3355 if(approach == -1 || approach == 5 || approach == 6)
3369 return returnedValue;
3373 float x,
float y,
float z,
float qx,
float qy,
float qz,
float qw)
3385 float x,
float y,
float z,
float qx,
float qy,
float qz,
float qw,
3386 float fx,
float fy,
float cx,
float cy,
3388 void * yPlane,
void * uPlane,
void * vPlane,
int yPlaneLen,
int rgbWidth,
int rgbHeight,
int rgbFormat,
3389 void * depth,
int depthLen,
int depthWidth,
int depthHeight,
int depthFormat,
3390 float * points,
int pointsLen)
3392 #ifdef RTABMAP_ARCORE 3396 if(fx > 0.0
f && fy > 0.0
f && cx > 0.0
f && cy > 0.0
f && stamp > 0.0
f && yPlane && vPlane && yPlaneLen == rgbWidth*rgbHeight)
3398 if(rgbFormat == AR_IMAGE_FORMAT_YUV_420_888 &&
3399 depthFormat == AIMAGE_FORMAT_DEPTH16)
3403 LOGD(
"y=%p u=%p v=%p yLen=%d y->v=%ld", yPlane, uPlane, vPlane, yPlaneLen, (
long)vPlane-(
long)yPlane);
3405 if((
long)vPlane-(
long)yPlane != yPlaneLen)
3408 cv::Mat yuv(rgbHeight+rgbHeight/2, rgbWidth, CV_8UC1);
3409 memcpy(yuv.data, yPlane, yPlaneLen);
3410 memcpy(yuv.data+yPlaneLen, vPlane, rgbHeight/2*rgbWidth);
3411 cv::cvtColor(yuv, outputRGB, CV_YUV2BGR_NV21);
3415 cv::cvtColor(cv::Mat(rgbHeight+rgbHeight/2, rgbWidth, CV_8UC1, yPlane), outputRGB, CV_YUV2BGR_NV21);
3419 cv::Mat outputDepth;
3420 if(depthHeight>0 && depthWidth>0)
3422 outputDepth = cv::Mat(depthHeight, depthWidth, CV_16UC1);
3425 for (
int y = 0; y < outputDepth.rows; ++y)
3427 for (
int x = 0; x < outputDepth.cols; ++x)
3429 uint16_t depthSample = dataShort[y*outputDepth.cols + x];
3430 uint16_t depthRange = (depthSample & 0x1FFF);
3431 outputDepth.at<
uint16_t>(y,x) = depthRange;
3435 if(!outputRGB.empty())
3442 LOGI(
"pointCloudData size=%d", pointsLen);
3444 std::vector<cv::KeyPoint> kpts;
3445 std::vector<cv::Point3f> kpts3;
3447 if(points && pointsLen>0)
3449 if(outputDepth.empty())
3469 UERROR(
"Missing image information!");
3473 UERROR(
"Not built with ARCore!");
3482 if(event->
getClassName().compare(
"OdometryEvent") == 0)
3484 LOGI(
"Received OdometryEvent!");
3494 LOGI(
"Received RtabmapEvent event! status=%d",
status_.first);
3503 LOGW(
"Received RtabmapEvent event but ignoring it while we are initializing...status=%d",
status_.first);
3518 if(event->
getClassName().compare(
"CameraInfoEvent") == 0)
3523 bool success =
false;
3527 jint
rs =
jvm->AttachCurrentThread(&env,
NULL);
3528 if(rs == JNI_OK && env)
3533 jmethodID methodID = env->GetMethodID(clazz,
"cameraEventCallback",
"(ILjava/lang/String;Ljava/lang/String;)V" );
3538 env->NewStringUTF(tangoEvent->
key().c_str()),
3539 env->NewStringUTF(tangoEvent->
value().c_str()));
3544 jvm->DetachCurrentThread();
3548 UERROR(
"Failed to call RTABMapActivity::tangoEventCallback");
3552 if(event->
getClassName().compare(
"RtabmapEventInit") == 0)
3556 LOGI(
"Received RtabmapEventInit! Status=%d info=%s", (
int)
status_.first,
status_.second.c_str());
3559 bool success =
false;
3563 jint
rs =
jvm->AttachCurrentThread(&env,
NULL);
3564 if(rs == JNI_OK && env)
3569 jmethodID methodID = env->GetMethodID(clazz,
"rtabmapInitEventCallback",
"(ILjava/lang/String;)V" );
3574 env->NewStringUTF(
status_.second.c_str()));
3579 jvm->DetachCurrentThread();
3583 UERROR(
"Failed to call RTABMapActivity::rtabmapInitEventsCallback");
3587 if(event->
getClassName().compare(
"PostRenderEvent") == 0)
3589 LOGI(
"Received PostRenderEvent!");
3591 int loopClosureId = 0;
3592 int featuresExtracted = 0;
3599 uInsert(
bufferedStatsData_, std::make_pair<std::string, float>(rtabmap::Statistics::kMemoryWorking_memory_size(),
uValue(stats.
data(), rtabmap::Statistics::kMemoryWorking_memory_size(), 0.0f)));
3600 uInsert(
bufferedStatsData_, std::make_pair<std::string, float>(rtabmap::Statistics::kMemoryShort_time_memory_size(),
uValue(stats.
data(), rtabmap::Statistics::kMemoryShort_time_memory_size(), 0.0f)));
3601 uInsert(
bufferedStatsData_, std::make_pair<std::string, float>(rtabmap::Statistics::kKeypointDictionary_size(),
uValue(stats.
data(), rtabmap::Statistics::kKeypointDictionary_size(), 0.0f)));
3603 uInsert(
bufferedStatsData_, std::make_pair<std::string, float>(rtabmap::Statistics::kLoopHighest_hypothesis_id(),
uValue(stats.
data(), rtabmap::Statistics::kLoopHighest_hypothesis_id(), 0.0f)));
3604 uInsert(
bufferedStatsData_, std::make_pair<std::string, float>(rtabmap::Statistics::kMemoryDatabase_memory_used(),
uValue(stats.
data(), rtabmap::Statistics::kMemoryDatabase_memory_used(), 0.0f)));
3605 uInsert(
bufferedStatsData_, std::make_pair<std::string, float>(rtabmap::Statistics::kLoopVisual_inliers(),
uValue(stats.
data(), rtabmap::Statistics::kLoopVisual_inliers(), 0.0f)));
3606 uInsert(
bufferedStatsData_, std::make_pair<std::string, float>(rtabmap::Statistics::kLoopVisual_matches(),
uValue(stats.
data(), rtabmap::Statistics::kLoopVisual_matches(), 0.0f)));
3607 uInsert(
bufferedStatsData_, std::make_pair<std::string, float>(rtabmap::Statistics::kLoopRejectedHypothesis(),
uValue(stats.
data(), rtabmap::Statistics::kLoopRejectedHypothesis(), 0.0f)));
3608 uInsert(
bufferedStatsData_, std::make_pair<std::string, float>(rtabmap::Statistics::kLoopOptimization_max_error(),
uValue(stats.
data(), rtabmap::Statistics::kLoopOptimization_max_error(), 0.0f)));
3609 uInsert(
bufferedStatsData_, std::make_pair<std::string, float>(rtabmap::Statistics::kLoopOptimization_max_error_ratio(),
uValue(stats.
data(), rtabmap::Statistics::kLoopOptimization_max_error_ratio(), 0.0f)));
3610 uInsert(
bufferedStatsData_, std::make_pair<std::string, float>(rtabmap::Statistics::kMemoryRehearsal_sim(),
uValue(stats.
data(), rtabmap::Statistics::kMemoryRehearsal_sim(), 0.0f)));
3611 uInsert(
bufferedStatsData_, std::make_pair<std::string, float>(rtabmap::Statistics::kLoopHighest_hypothesis_value(),
uValue(stats.
data(), rtabmap::Statistics::kLoopHighest_hypothesis_value(), 0.0f)));
3612 uInsert(
bufferedStatsData_, std::make_pair<std::string, float>(rtabmap::Statistics::kMemoryDistance_travelled(),
uValue(stats.
data(), rtabmap::Statistics::kMemoryDistance_travelled(), 0.0f)));
3613 uInsert(
bufferedStatsData_, std::make_pair<std::string, float>(rtabmap::Statistics::kMemoryFast_movement(),
uValue(stats.
data(), rtabmap::Statistics::kMemoryFast_movement(), 0.0f)));
3614 uInsert(
bufferedStatsData_, std::make_pair<std::string, float>(rtabmap::Statistics::kLoopLandmark_detected(),
uValue(stats.
data(), rtabmap::Statistics::kLoopLandmark_detected(), 0.0f)));
3623 int databaseMemoryUsed = (int)
uValue(
bufferedStatsData_, rtabmap::Statistics::kMemoryDatabase_memory_used(), 0.0f);
3628 float optimizationMaxErrorRatio =
uValue(
bufferedStatsData_, rtabmap::Statistics::kLoopOptimization_max_error_ratio(), 0.0
f);
3635 float x=0.0f,y=0.0f,z=0.0f,
roll=0.0f,
pitch=0.0f,
yaw=0.0f;
3636 if(!currentPose.
isNull())
3642 UINFO(
"Send statistics to GUI");
3643 bool success =
false;
3647 jint
rs =
jvm->AttachCurrentThread(&env,
NULL);
3648 if(rs == JNI_OK && env)
3653 jmethodID methodID = env->GetMethodID(clazz,
"updateStatsCallback",
"(IIIIFIIIIIIFIFIFFFFIIFFFFFF)V" );
3673 optimizationMaxError,
3674 optimizationMaxErrorRatio,
3688 jvm->DetachCurrentThread();
3692 UERROR(
"Failed to call RTABMapActivity::updateStatsCallback");
void save(const std::string &databasePath)
GLM_FUNC_DECL T roll(detail::tquat< T, P > const &x)
std::vector< int > RTABMAP_EXP filterNaNPointsFromMesh(const pcl::PointCloud< pcl::PointXYZRGB > &cloud, const std::vector< pcl::Vertices > &polygons, pcl::PointCloud< pcl::PointXYZRGB > &outputCloud, std::vector< pcl::Vertices > &outputPolygons)
void OnTouchEvent(int touch_count, tango_gl::GestureCamera::TouchEvent event, float x0, float y0, float x1, float y1)
static const std::map< std::string, std::pair< bool, std::string > > & getRemovedParameters()
const std::string & value() const
void setCameraColor(bool enabled)
int getViewPortWidth() const
void setMaxGainRadius(float value)
int openDatabase(const std::string &databasePath, bool databaseInMemory, bool optimize, const std::string &databaseSource=std::string())
void setWireframe(bool enabled)
void addMesh(int id, const rtabmap::Mesh &mesh, const rtabmap::Transform &pose, bool createWireframe=false)
rtabmap::CameraModel cameraModel
std::vector< Eigen::Vector2f > texCoords
void setAppendMode(bool enabled)
void setGridVisible(bool visible)
bool isMeshTexturing() const
void updateCloudPolygons(int id, const std::vector< pcl::Vertices > &polygons)
void OnTouchEvent(int touch_count, tango_gl::GestureCamera::TouchEvent event, float x0, float y0, float x1, float y1)
rtabmap::LogHandler * logHandler_
static void post(UEvent *event, bool async=true, const UEventsSender *sender=0)
GLM_FUNC_DECL genType min(genType const &x, genType const &y)
cv::Point3f RTABMAP_EXP transformPoint(const cv::Point3f &pt, const Transform &transform)
int setMappingParameter(const std::string &key, const std::string &value)
void SetViewPort(int width, int height)
void addEnvSensor(int type, float value)
void SetupViewPort(int w, int h)
double lastPoseEventTime_
void setSmoothing(bool enabled)
const LaserScan & laserScanCompressed() const
static const rtabmap::Transform optical_T_opengl(1.0f, 0.0f, 0.0f, 0.0f, 0.0f,-1.0f, 0.0f, 0.0f, 0.0f, 0.0f,-1.0f, 0.0f)
pcl::PointCloud< pcl::PointXYZ >::Ptr RTABMAP_EXP transformPointCloud(const pcl::PointCloud< pcl::PointXYZ >::Ptr &cloud, const Transform &transform)
std::set< int > getAddedMarkers() const
void setCloudPose(int id, const rtabmap::Transform &pose)
void RTABMAP_EXP getMinMax3D(const cv::Mat &laserScan, cv::Point3f &min, cv::Point3f &max)
int lastDrawnCloudsCount_
void postCameraPoseEvent(float x, float y, float z, float qx, float qy, float qz, float qw)
std::vector< pcl::Vertices > filterOrganizedPolygons(const std::vector< pcl::Vertices > &polygons, int cloudSize) const
pcl::PointCloud< pcl::PointXYZRGB >::Ptr cloud
int detectMoreLoopClosures(float clusterRadius=0.5f, float clusterAngle=M_PI/6.0f, int iterations=1, bool intraSession=true, bool interSession=true, const ProgressState *state=0)
virtual std::map< int, Transform > optimizeBA(int rootId, const std::map< int, Transform > &poses, const std::multimap< int, Link > &links, const std::map< int, CameraModel > &models, std::map< int, cv::Point3f > &points3DMap, const std::map< int, std::map< int, FeatureBA > > &wordReferences, std::set< int > *outliers=0)
SensorData getNodeData(int locationId, bool images, bool scan, bool userData, bool occupancyGrid) const
void setGraphOptimization(bool enabled)
int getViewPortHeight() const
cv::Mat loadOptimizedMesh(std::vector< std::vector< std::vector< RTABMAP_PCL_INDEX > > > *polygons=0, std::vector< std::vector< Eigen::Vector2f > > *texCoords=0, cv::Mat *textures=0) const
void setGridColor(float r, float g, float b)
int proximityDetectionId() const
ScreenRotation GetAndroidRotationFromColorCameraToDisplay(ScreenRotation display_rotation, int color_camera_rotation)
void setWireframe(bool enabled)
std::pair< std::string, std::string > ParametersPair
void setGraphVisible(bool visible)
const Signature & getLastSignatureData() const
static std::string separator()
rtabmap::ParametersMap getRtabmapParameters()
bool isMapRendering() const
void setDepthFromMotion(bool enabled)
bool hasMesh(int id) const
static int erase(const std::string &filePath)
void setBackfaceCulling(bool enabled)
GLM_FUNC_DECL genType e()
float UTILITE_EXP uStr2Float(const std::string &str)
GLM_FUNC_DECL bool all(vecType< bool, P > const &v)
static const float vertices[]
cv::Mat getImageCompressed(int signatureId) const
std::map< std::string, std::string > ParametersMap
std::string UTILITE_EXP uBool2Str(bool boolean)
cv::Mat RTABMAP_EXP fastBilateralFiltering(const cv::Mat &depth, float sigmaS=15.0f, float sigmaR=0.05f, bool earlyDivision=false)
void setScreenRotation(rtabmap::ScreenRotation colorCameraToDisplayRotation)
void init(const ParametersMap ¶meters, const std::string &databasePath="", bool loadDatabaseParameters=false)
std::vector< pcl::Vertices > filterPolygons(const std::vector< pcl::Vertices > &polygons, int cloudSize) const
GLM_FUNC_DECL T angle(detail::tquat< T, P > const &x)
std::map< std::string, float > bufferedStatsData_
void setConstraints(const std::multimap< int, Link > &constraints)
BackgroundRenderer * background_renderer_
Some conversion functions.
pcl::TextureMesh::Ptr RTABMAP_EXP assembleTextureMesh(const cv::Mat &cloudMat, const std::vector< std::vector< std::vector< RTABMAP_PCL_INDEX > > > &polygons, const std::vector< std::vector< Eigen::Vector2f > > &texCoords, cv::Mat &textures, bool mergeTextures=false)
bool acquire(int n=1, int ms=0)
const LaserScan & laserScanRaw() const
std::list< rtabmap::RtabmapEvent * > rtabmapEvents_
GLM_FUNC_DECL T pitch(detail::tquat< T, P > const &x)
void setCloudDensityLevel(int value)
void poseReceived(const Transform &pose)
bool hasCloud(int id) const
const cv::Mat & imageRaw() const
void InitializeGLContent()
double getGain(int id, double *r=0, double *g=0, double *b=0) const
int postProcessing(int approach)
std::vector< pcl::Vertices > polygons
static bool isAvailable(Optimizer::Type type)
pcl::TextureMesh::Ptr optMesh_
void setData(const SensorData &data, const Transform &pose)
void setRenderingTextureDecimation(int value)
const std::map< int, Transform > & getLocalOptimizedPoses() const
void post(UEvent *event, bool async=true) const
void setMeshRendering(bool enabled, bool withTexture)
void getGraph(std::map< int, Transform > &poses, std::multimap< int, Link > &constraints, bool optimized, bool global, std::map< int, Signature > *signatures=0, bool withImages=false, bool withScan=false, bool withUserData=false, bool withGrid=false, bool withWords=true, bool withGlobalDescriptors=true) const
void removeMarker(int id)
void setClusterRatio(float value)
void setOrthoCropFactor(float value)
pcl::PointCloud< pcl::PointXYZ >::Ptr RTABMAP_EXP cloudFromDepth(const cv::Mat &imageDepth, const CameraModel &model, int decimation=1, float maxDepth=0.0f, float minDepth=0.0f, std::vector< int > *validIndices=0)
void setLighting(bool enabled)
void savePreviewImage(const cv::Mat &image) const
void setOrthoCropFactor(float value)
bool openConnection(const std::string &url, bool overwritten=false)
#define UASSERT(condition)
void setGPS(const rtabmap::GPS &gps)
Wrappers of STL for convenient functions.
const std::map< std::string, float > & data() const
void updateGains(int id, float gainR, float gainG, float gainB)
const Transform & pose() const
pcl::PointCloud< pcl::PointXYZRGB >::Ptr RTABMAP_EXP laserScanToPointCloudRGB(const LaserScan &laserScan, const Transform &transform=Transform(), unsigned char r=100, unsigned char g=100, unsigned char b=100)
static const rtabmap::Transform opengl_world_T_rtabmap_world(0.0f,-1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f,-1.0f, 0.0f, 0.0f, 0.0f)
void InitializeGlContent(GLuint textureId)
std::list< std::list< int > > RTABMAP_EXP clusterPolygons(const std::vector< std::set< int > > &neighborPolygons, int minClusterSize=0)
T uMax3(const T &a, const T &b, const T &c)
void setPointSize(float value)
bool filterPolygonsOnNextRender_
const std::multimap< int, int > & getWords() const
void close(bool databaseSaved=true, const std::string &ouputDatabasePath="")
bool takeScreenshotOnNextRender_
void RTABMAP_EXP appendMesh(pcl::PointCloud< pcl::PointXYZRGBNormal > &cloudA, std::vector< pcl::Vertices > &polygonsA, const pcl::PointCloud< pcl::PointXYZRGBNormal > &cloudB, const std::vector< pcl::Vertices > &polygonsB)
void setPoses(const std::map< int, Transform > &poses)
const rtabmap::RtabmapEvent * getRtabmapEvent() const
boost::mutex rtabmapMutex_
virtual std::string getClassName() const =0
void SetCameraPose(const rtabmap::Transform &pose)
bool clearSceneOnNextRender_
bool hasMarker(int id) const
void setOptimizedPoses(const std::map< int, Transform > &poses)
pcl::PointCloud< pcl::Normal >::Ptr normals
void setMapRendering(bool enabled)
static LaserScan scanFromPointCloudData(const float *pointCloudData, int points, const Transform &pose, const CameraModel &model, const cv::Mat &rgb, std::vector< cv::KeyPoint > *kpts=0, std::vector< cv::Point3f > *kpts3D=0)
const Statistics & getStatistics() const
void setBlending(bool enabled)
pcl::PointCloud< pcl::PointXYZRGB >::Ptr RTABMAP_EXP cloudRGBFromSensorData(const SensorData &sensorData, int decimation=1, float maxDepth=0.0f, float minDepth=0.0f, std::vector< int > *validIndices=0, const ParametersMap &stereoParameters=ParametersMap(), const std::vector< float > &roiRatios=std::vector< float >())
void addCloud(int id, const pcl::PointCloud< pcl::PointXYZRGB >::Ptr &cloud, const pcl::IndicesPtr &indices, const rtabmap::Transform &pose)
void setBackgroundColor(float r, float g, float b)
void setTrajectoryMode(bool enabled)
bool startCamera(JNIEnv *env, jobject iBinder, jobject context, jobject activity, int driver)
virtual bool handleEvent(UEvent *event)
cv::Mat RTABMAP_EXP computeNormals(const cv::Mat &laserScan, int searchK, float searchRadius)
void setCloudVisible(int id, bool visible)
static void copy(const std::string &from, const std::string &to)
std::map< int, rtabmap::Transform > rawPoses_
void setMaxCloudDepth(float value)
void setGridRotation(float value)
Transform localTransform() const
int renderingTextureDecimation_
void updateGraph(const std::map< int, rtabmap::Transform > &poses, const std::multimap< int, rtabmap::Link > &links)
bool isMeshRendering() const
void setBackfaceCulling(bool enabled)
void setPointSize(float size)
void setRawScanSaved(bool enabled)
void SetCameraType(tango_gl::GestureCamera::CameraType camera_type)
std::set< int > getAddedClouds() const
bool isBuiltWith(int cameraDriver) const
cv::Mat RTABMAP_EXP compressData2(const cv::Mat &data)
virtual void setScreenRotationAndSize(ScreenRotation colorCameraToDisplayRotation, int width, int height)
void postOdometryEvent(float x, float y, float z, float qx, float qy, float qz, float qw, float fx, float fy, float cx, float cy, double stamp, void *yPlane, void *uPlane, void *vPlane, int yPlaneLen, int rgbWidth, int rgbHeight, int rgbFormat, void *depth, int depthLen, int depthWidth, int depthHeight, int depthFormat, float *points, int pointsLen)
bool hasTexture(int id) const
int loopClosureId() const
std::vector< pcl::Vertices > RTABMAP_EXP organizedFastMesh(const pcl::PointCloud< pcl::PointXYZ >::Ptr &cloud, double angleTolerance, bool quad, int trianglePixelSize, const Eigen::Vector3f &viewpoint=Eigen::Vector3f(0, 0, 0))
virtual bool init(const std::string &calibrationFolder=".", const std::string &cameraName="")
int gainCompensationOnNextRender_
bool uContains(const std::list< V > &list, const V &value)
bool postExportation(bool visualize)
void addMarker(int id, const rtabmap::Transform &pose)
cv::Mat loadOptimizedMesh(std::vector< std::vector< std::vector< RTABMAP_PCL_INDEX > > > *polygons=0, std::vector< std::vector< Eigen::Vector2f > > *texCoords=0, cv::Mat *textures=0) const
void setBackgroundColor(float gray)
static DBDriver * create(const ParametersMap ¶meters=ParametersMap())
GLM_FUNC_DECL detail::tquat< T, P > rotation(detail::tvec3< T, P > const &orig, detail::tvec3< T, P > const &dest)
void parseParameters(const ParametersMap ¶meters)
void setMeshRendering(bool enabled, bool withTexture)
const VWDictionary * getVWDictionary() const
void setNodesFiltering(bool enabled)
boost::mutex meshesMutex_
cv::Mat RTABMAP_EXP mergeTextures(pcl::TextureMesh &mesh, const std::map< int, cv::Mat > &images, const std::map< int, CameraModel > &calibrations, const Memory *memory=0, const DBDriver *dbDriver=0, int textureSize=4096, int textureCount=1, const std::vector< std::map< int, pcl::PointXY > > &vertexToPixels=std::vector< std::map< int, pcl::PointXY > >(), bool gainCompensation=true, float gainBeta=10.0f, bool gainRGB=true, bool blending=true, int blendingDecimation=0, int brightnessContrastRatioLow=0, int brightnessContrastRatioHigh=0, bool exposureFusion=false, const ProgressState *state=0, unsigned char blankValue=255, std::map< int, std::map< int, cv::Vec4d > > *gains=0, std::map< int, std::map< int, cv::Mat > > *blendingGains=0, std::pair< float, float > *contrastValues=0)
double lastPostRenderEventTime_
void registerToEventsManager()
void setMapCloudShown(bool shown)
void setFrustumVisible(bool visible)
void uSleep(unsigned int ms)
const std::map< int, Transform > & poses() const
bool isValidForProjection() const
pcl::TextureMesh::Ptr RTABMAP_EXP createTextureMesh(const pcl::PolygonMesh::Ptr &mesh, const std::map< int, Transform > &poses, const std::map< int, CameraModel > &cameraModels, const std::map< int, cv::Mat > &cameraDepths, float maxDistance=0.0f, float maxDepthError=0.0f, float maxAngle=0.0f, int minClusterSize=50, const std::vector< float > &roiRatios=std::vector< float >(), const ProgressState *state=0, std::vector< std::map< int, pcl::PointXY > > *vertexToPixels=0, bool distanceToCamPolicy=false)
static const ParametersMap & getDefaultParameters()
rtabmap::RtabmapThread * rtabmapThread_
const std::vector< CameraModel > & cameraModels() const
const Transform & getPose() const
boost::mutex cameraMutex_
void setDetectorRate(float rate)
static const rtabmap::Transform rtabmap_world_T_opengl_world(0.0f, 0.0f,-1.0f, 0.0f,-1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f)
GLM_FUNC_DECL genType max(genType const &x, genType const &y)
SensorData & sensorData()
void RTABMAP_EXP cleanTextureMesh(pcl::TextureMesh &textureMesh, int minClusterSize)
void setJavaObjects(JavaVM *jvm, jobject rtabmap)
int Render(const float *uvsTransformed=0, glm::mat4 arViewMatrix=glm::mat4(0), glm::mat4 arProjectionMatrix=glm::mat4(0), const rtabmap::Mesh &occlusionMesh=rtabmap::Mesh())
const Signature * getLastWorkingSignature() const
void setMinCloudDepth(float value)
const CameraModel & getCameraModel() const
void setTraceVisible(bool visible)
void SetCameraType(tango_gl::GestureCamera::CameraType camera_type)
const Transform & getDeviceTColorCamera() const
rtabmap::Transform GetCameraPose() const
void RTABMAP_EXP createPolygonIndexes(const std::vector< pcl::Vertices > &polygons, int cloudSize, std::vector< std::set< int > > &neighborPolygons, std::vector< std::set< int > > &vertexPolygons)
Given a set of polygons, create two indexes: polygons to neighbor polygons and vertices to polygons...
tango_gl::GestureCamera::CameraType GetCameraType() const
rtabmap::Transform mapToOdom_
rtabmap::ScreenRotation getScreenRotation() const
std::pair< rtabmap::RtabmapEventInit::Status, std::string > status_
const Memory * getMemory() const
rtabmap::RtabmapEvent * rtabmapEvent_
void setOnlineBlending(bool enabled)
void feed(const pcl::PointCloud< pcl::PointXYZRGB >::Ptr &cloudA, const pcl::PointCloud< pcl::PointXYZRGB >::Ptr &cloudB, const Transform &transformB)
bool exportedMeshUpdated_
void close(bool databaseSaved, const std::string &databasePath="")
std::map< int, rtabmap::Mesh > createdMeshes_
void gainCompensation(bool full=false)
void updateMesh(int id, const rtabmap::Mesh &mesh)
void setDataRecorderMode(bool enabled)
GLM_FUNC_DECL T yaw(detail::tquat< T, P > const &x)
void setGraphVisible(bool visible)
bool writeExportedMesh(const std::string &directory, const std::string &name)
bool cameraJustInitialized_
boost::mutex renderingMutex_
static jobject RTABMapActivity
void setMarkerPose(int id, const rtabmap::Transform &pose)
void setMeshTriangleSize(int value)
void unregisterFromEventsManager()
void setGridVisible(bool visible)
float getDetectorRate() const
void join(bool killFirst=false)
bool exportMesh(float cloudVoxelSize, bool regenerateCloud, bool meshing, int textureSize, int textureCount, int normalK, bool optimized, float optimizedVoxelSize, int optimizedDepth, int optimizedMaxPolygons, float optimizedColorRadius, bool optimizedCleanWhitePolygons, int optimizedMinClusterSize, float optimizedMaxTextureDistance, int optimizedMinTextureClusterSize, bool blockRendering)
RTABMapApp(JNIEnv *env, jobject caller_activity)
float meshAngleToleranceDeg_
std::list< rtabmap::Transform > poseEvents_
bool smoothMesh(int id, rtabmap::Mesh &mesh)
void setGridRotation(float angleDeg)
USemaphore screenshotReady_
void setFullResolution(bool enabled)
pcl::PointCloud< pcl::PointXYZ >::Ptr RTABMAP_EXP voxelize(const pcl::PointCloud< pcl::PointXYZ >::Ptr &cloud, const pcl::IndicesPtr &indices, float voxelSize)
void setMeshAngleTolerance(float value)
const Transform & mapCorrection() const
std::list< rtabmap::OdometryEvent > odomEvents_
void addEnvSensor(int type, float value)
void setScreenRotation(int displayRotation, int cameraRotation)
const std::string & key() const
std::string UTILITE_EXP uFormat(const char *fmt,...)
rtabmap::Rtabmap * rtabmap_
std::string UTILITE_EXP uNumber2Str(unsigned int number)
bool bilateralFilteringOnNextRender_
rtabmap::ParametersMap mappingParameters_
rtabmap::ProgressionStatus progressionStatus_
void setLighting(bool enabled)
rtabmap::CameraMobile * camera_
rtabmap::Transform * optRefPose_
static Optimizer * create(const ParametersMap ¶meters)
void saveOptimizedMesh(const cv::Mat &cloud, const std::vector< std::vector< std::vector< RTABMAP_PCL_INDEX > > > &polygons=std::vector< std::vector< std::vector< RTABMAP_PCL_INDEX > > >(), const std::vector< std::vector< Eigen::Vector2f > > &texCoords=std::vector< std::vector< Eigen::Vector2f > >(), const cv::Mat &textures=cv::Mat()) const
V uValue(const std::map< K, V > &m, const K &key, const V &defaultValue=V())
void setFeatures(const std::vector< cv::KeyPoint > &keypoints, const std::vector< cv::Point3f > &keypoints3D, const cv::Mat &descriptors)
void setGPS(const GPS &gps)
pcl::PolygonMesh::Ptr RTABMAP_EXP assemblePolygonMesh(const cv::Mat &cloudMat, const std::vector< std::vector< RTABMAP_PCL_INDEX > > &polygons)
PostRenderEvent(rtabmap::RtabmapEvent *event=0)
const std::map< int, VisualWord * > & getVisualWords() const
void setPausedMapping(bool paused)
int getDatabaseMemoryUsed() const
cv::Mat RTABMAP_EXP uncompressImage(const cv::Mat &bytes)
void addStatistic(const std::string &name, float value)
void uInsert(std::map< K, V > &map, const std::pair< K, V > &pair)
void setOdomCloudShown(bool shown)
void setLocalizationMode(bool enabled)
void increment(int count=1) const
const Transform & localTransform() const
virtual std::string getClassName() const
LaserScan RTABMAP_EXP laserScanFromPointCloud(const pcl::PCLPointCloud2 &cloud, bool filterNaNs=true, bool is2D=false, const Transform &transform=Transform())
void setCanceled(bool canceled)