diff --git a/MapExtension/SolARSample_Mapping_MapExtension_Mono/SolARSample_Mapping_MapExtension_Mono_conf.xml b/MapExtension/SolARSample_Mapping_MapExtension_Mono/SolARSample_Mapping_MapExtension_Mono_conf.xml index ae997a8..3c989ea 100644 --- a/MapExtension/SolARSample_Mapping_MapExtension_Mono/SolARSample_Mapping_MapExtension_Mono_conf.xml +++ b/MapExtension/SolARSample_Mapping_MapExtension_Mono/SolARSample_Mapping_MapExtension_Mono_conf.xml @@ -243,7 +243,7 @@ - + diff --git a/MapExtension/SolARSample_Mapping_MapExtension_Mono/main.cpp b/MapExtension/SolARSample_Mapping_MapExtension_Mono/main.cpp index 5cf4d5c..0584bf2 100644 --- a/MapExtension/SolARSample_Mapping_MapExtension_Mono/main.cpp +++ b/MapExtension/SolARSample_Mapping_MapExtension_Mono/main.cpp @@ -399,7 +399,8 @@ int main(int argc, char *argv[]) break; } - // Save map + // Save map extension + mapper->bindTo()->getProperty("directory")->setStringValue("output/extension-map"); mapper->saveToFile(); } diff --git a/MapFusion/SolARSample_Mapping_FloatingMapFusion_Mono/SolARSample_Mapping_FloatingMapFusion_Mono_conf.xml b/MapFusion/SolARSample_Mapping_FloatingMapFusion_Mono/SolARSample_Mapping_FloatingMapFusion_Mono_conf.xml index 3a4cc91..96f2a24 100644 --- a/MapFusion/SolARSample_Mapping_FloatingMapFusion_Mono/SolARSample_Mapping_FloatingMapFusion_Mono_conf.xml +++ b/MapFusion/SolARSample_Mapping_FloatingMapFusion_Mono/SolARSample_Mapping_FloatingMapFusion_Mono_conf.xml @@ -251,7 +251,7 @@ - + @@ -262,7 +262,7 @@ - + diff --git a/MapFusion/SolARSample_Mapping_LocalMapFusion_Mono/SolARSample_Mapping_LocalMapFusion_Mono_conf.xml b/MapFusion/SolARSample_Mapping_LocalMapFusion_Mono/SolARSample_Mapping_LocalMapFusion_Mono_conf.xml index 29d45e5..4b6606d 100644 --- a/MapFusion/SolARSample_Mapping_LocalMapFusion_Mono/SolARSample_Mapping_LocalMapFusion_Mono_conf.xml +++ b/MapFusion/SolARSample_Mapping_LocalMapFusion_Mono/SolARSample_Mapping_LocalMapFusion_Mono_conf.xml @@ -247,7 +247,7 @@ - + diff --git a/Mapping/SolARPipeline_Mapping_Mono/src/PipelineMappingMonoProcessing.cpp b/Mapping/SolARPipeline_Mapping_Mono/src/PipelineMappingMonoProcessing.cpp index 192b416..68e5f68 100644 --- a/Mapping/SolARPipeline_Mapping_Mono/src/PipelineMappingMonoProcessing.cpp +++ b/Mapping/SolARPipeline_Mapping_Mono/src/PipelineMappingMonoProcessing.cpp @@ -171,12 +171,12 @@ namespace MAPPING { } FrameworkReturnCode PipelineMappingMonoProcessing::stop() { - - LOG_DEBUG("PipelineMappingMonoProcessing::stop"); - - LOG_DEBUG("Stop mapping processing task"); - m_mappingTask->stop(); - + LOG_DEBUG("PipelineMappingMonoProcessing::stop"); + if (isBootstrapFinished()) { + globalBundleAdjustment(); + } + LOG_DEBUG("Stop mapping processing task"); + m_mappingTask->stop(); return FrameworkReturnCode::_SUCCESS; } @@ -357,9 +357,9 @@ namespace MAPPING { std::vector> duplicatedPointsIndices; if (m_loopDetector->detect(keyframe, detectedLoopKeyframe, sim3Transform, duplicatedPointsIndices) == FrameworkReturnCode::_SUCCESS) { // detected loop keyframe - LOG_DEBUG("Detected loop keyframe id: {}", detectedLoopKeyframe->getId()); - LOG_DEBUG("Nb of duplicatedPointsIndices: {}", duplicatedPointsIndices.size()); - LOG_DEBUG("sim3Transform: \n{}", sim3Transform.matrix()); + LOG_INFO("Detected loop keyframe id: {}", detectedLoopKeyframe->getId()); + LOG_INFO("Nb of duplicatedPointsIndices: {}", duplicatedPointsIndices.size()); + LOG_INFO("sim3Transform: \n{}", sim3Transform.matrix()); // performs loop correction Transform3Df keyframeOldPose = keyframe->getPose(); m_loopCorrector->correct(keyframe, detectedLoopKeyframe, sim3Transform, duplicatedPointsIndices); @@ -381,18 +381,7 @@ namespace MAPPING { if (keyframe) { m_tracking->updateReferenceKeyframe(keyframe); } - } - else { - LOG_DEBUG("***** No (image, pose) pair to process *****"); - - // Data to store ? - if (m_dataToStore) { - m_dataToStore = false; - - // Bundle adjustment, map pruning and global map udate - globalBundleAdjustment(); - } - } + } } } diff --git a/Mapping/SolARPipeline_Mapping_Mono/tests/SolARPipelineTest_Mapping_Mono/SolARPipelineTestMappingMono_main.cpp b/Mapping/SolARPipeline_Mapping_Mono/tests/SolARPipelineTest_Mapping_Mono/SolARPipelineTestMappingMono_main.cpp index bf608af..848b2e9 100644 --- a/Mapping/SolARPipeline_Mapping_Mono/tests/SolARPipelineTest_Mapping_Mono/SolARPipelineTestMappingMono_main.cpp +++ b/Mapping/SolARPipeline_Mapping_Mono/tests/SolARPipelineTest_Mapping_Mono/SolARPipelineTestMappingMono_main.cpp @@ -12,12 +12,7 @@ */ #include -#include "xpcf/threading/BaseTask.h" -#include #include -#include -#include - #include "core/Log.h" #include "api/pipeline/IMappingPipeline.h" #include "api/input/devices/IARDevice.h" @@ -34,109 +29,6 @@ namespace xpcf=org::bcom::xpcf; #define INDEX_USE_CAMERA 0 -// Global XPCF Component Manager -SRef gXpcfComponentManager = 0; - -// Global Mapping Pipeline instance -SRef gMappingPipeline = 0; - -// Global client threads -xpcf::DelegateTask * gClientProducerTask = 0; -xpcf::DelegateTask * gClientViewerTask = 0; - -// Viewer used by viewer client -SRef gViewer3D = 0; -// Point clouds and keyframe poses used by client viewer -std::vector> gPointClouds; -std::vector gKeyframePoses; - -// Components used by producer client -SRef gArDevice = 0; -SRef gImageViewer = 0; -// Indicates if producer client has images to send to mapping pipeline -bool gImageToSend = true; -// Nb of images sent by producer client -int gNbImages = 0; - -// Fonction for producer client thread -auto fnClientProducer = []() { - - std::vector> images; - std::vector poses; - std::chrono::system_clock::time_point timestamp; - - // Still images to process? - if (gImageToSend) { - // Get data from hololens files - if (gArDevice->getData(images, poses, timestamp) == FrameworkReturnCode::_SUCCESS) { - -// gNbImages ++; -// LOG_INFO("Producer client: Send (image, pose) num {} to mapping pipeline", gNbImages); - - SRef image = images[INDEX_USE_CAMERA]; - Transform3Df pose = poses[INDEX_USE_CAMERA]; - - gMappingPipeline->mappingProcessRequest(image, pose); - - if (gImageViewer->display(image) == SolAR::FrameworkReturnCode::_STOP) { - gClientProducerTask->stop(); - } - } - else { - gImageToSend = false; - LOG_INFO("Producer client: no more images to send"); - } - } -}; - -// Fonction for viewer client thread -auto fnClientViewer = []() { - - // Try to get point clouds and key frame poses to display - if (gMappingPipeline->getDataForVisualization(gPointClouds, gKeyframePoses) == FrameworkReturnCode::_SUCCESS) { - - if (gViewer3D == 0) { - gViewer3D = gXpcfComponentManager->resolve(); - LOG_INFO("Viewer client: I3DPointsViewer component created"); - } - - // Display new data - gViewer3D->display(gPointClouds, gKeyframePoses[gKeyframePoses.size()-1], gKeyframePoses, {}, {}); - } -}; - -// Function called when interruption signal is triggered -static void SigInt(int signo) { - - LOG_INFO("\n\n===> Program interruption\n"); - - LOG_INFO("Stop producer client thread"); - - if (gClientProducerTask != 0) - gClientProducerTask->stop(); - - LOG_INFO("Stop viewer client thread"); - - if (gClientViewerTask != 0) - gClientViewerTask->stop(); - - LOG_INFO("Stop mapping pipeline process"); - - if (gMappingPipeline != 0) - gMappingPipeline->stop(); - - boost::this_thread::sleep(boost::posix_time::milliseconds(1000)); - - LOG_INFO("End of test"); - - exit(0); -} - - -/// -/// \brief Test application for SolARMappingPipeline -/// - int main(int argc, char ** argv) { #if NDEBUG @@ -145,11 +37,8 @@ int main(int argc, char ** argv) LOG_ADD_LOG_TO_CONSOLE(); - // Signal interruption function (Ctrl + C) - signal(SIGINT, SigInt); - // Default configuration file - char * config_file = (char *)"SolARPipelineTest_Mapping_Mono_Processing_conf.xml"; + char * config_file = (char *)"SolARPipelineTest_Mapping_Mono_conf.xml"; if (argc > 1) { // Get mapping pipeline configuration file path and name from main args @@ -158,102 +47,89 @@ int main(int argc, char ** argv) try { LOG_INFO("Get Component Manager instance"); - - gXpcfComponentManager = xpcf::getComponentManagerInstance(); - - LOG_INFO("Load Mapping Pipeline configuration file"); - - if (gXpcfComponentManager->load(config_file) == org::bcom::xpcf::_SUCCESS) - { - // Create Mapping Pipeline component - gMappingPipeline = gXpcfComponentManager->resolve(); - - LOG_INFO("Mapping pipeline component created"); + SRef componentMgr = xpcf::getComponentManagerInstance(); + xpcf::XPCFErrorCode errorLoad = componentMgr->load(config_file); + if (errorLoad != xpcf::_SUCCESS) + { + LOG_ERROR("Failed to load the configuration file {}", config_file); + return -1; + } + auto gMappingPipeline = componentMgr->resolve(); + LOG_INFO("Mapping pipeline created"); + auto gArDevice = componentMgr->resolve(); + LOG_INFO("AR device component created"); + auto trackableLoader = componentMgr->resolve(); + LOG_INFO("Trackable loader component created"); + auto gImageViewer = componentMgr->resolve(); + LOG_INFO("Image viewer component created"); + auto g3DViewer = componentMgr->resolve(); + LOG_INFO("3D viewer component created"); + // Start device + if (gArDevice->start() != FrameworkReturnCode::_SUCCESS) { + LOG_ERROR("Cannot start AR device loader"); + return -1; + } + // Load camera intrinsics parameters + CameraParameters camParams; + camParams = gArDevice->getParameters(INDEX_USE_CAMERA); + // Set camera parameters + gMappingPipeline->setCameraParameters(camParams); + // Load trackable + SRef trackableObject = trackableLoader->loadTrackable(); + // Check and set trackable + if (trackableObject) { + LOG_INFO("Fiducial marker created: url = {}", trackableObject->getURL()); + gMappingPipeline->setObjectToTrack(trackableObject); } else { - LOG_ERROR("Failed to load the configuration file {}", config_file); + LOG_ERROR("Error while loading fiducial marker"); return -1; } - // Manage producer client thread - if (gXpcfComponentManager->load("SolARPipelineTest_Mapping_Mono_Producer_conf.xml") == org::bcom::xpcf::_SUCCESS) - { - LOG_INFO("Producer client configuration file loaded"); - - gArDevice = gXpcfComponentManager->resolve(); - LOG_INFO("Producer client: AR device component created"); - - auto trackableLoader = gXpcfComponentManager->resolve(); - LOG_INFO("Producer client: Trackable loader component created"); - - gImageViewer = gXpcfComponentManager->resolve(); - LOG_INFO("Producer client: Image viewer component created"); - - // Connect remotely to the HoloLens streaming app - if (gArDevice->start() == FrameworkReturnCode::_SUCCESS) { - - // Load camera intrinsics parameters - CameraParameters camParams; - camParams = gArDevice->getParameters(0); - - LOG_INFO("Producer client: Set mapping pipeline camera parameters"); - gMappingPipeline->setCameraParameters(camParams); - - LOG_INFO("Producer client: Load fiducial marker description file"); - SRef trackableObject = trackableLoader->loadTrackable(); - - if (trackableObject != 0) { - LOG_INFO("Producer client: Fiducial marker created: url = {}", trackableObject->getURL()); - - LOG_INFO("Producer client: Set mapping pipeline fiducial marker"); - gMappingPipeline->setObjectToTrack(trackableObject); - - LOG_INFO("Producer client: Start mapping pipeline"); - - if (gMappingPipeline->start() == FrameworkReturnCode::_SUCCESS) { - LOG_INFO("Start producer client thread"); - - gClientProducerTask = new xpcf::DelegateTask(fnClientProducer); - gClientProducerTask->start(); - } - else { - LOG_ERROR("Cannot start mapping pipeline"); - } - } - else { - LOG_ERROR("Error while loading fiducial marker"); - return -1; - } - } - else { - LOG_ERROR("Cannot start AR device loader"); - return -1; - } - } - else { - LOG_ERROR("Failed to load the producer client configuration file"); - return -1; - } - - // Manage viewer client thread - if (gXpcfComponentManager->load("SolARPipelineTest_Mapping_Mono_Viewer_conf.xml") == org::bcom::xpcf::_SUCCESS) - { - LOG_INFO("Viewer client configuration file loaded"); - - LOG_INFO("Start viewer client thread"); - - gClientViewerTask = new xpcf::DelegateTask(fnClientViewer); - gClientViewerTask->start(); - } - else { - LOG_ERROR("Failed to load the viewer client configuration file"); - return -1; - } - - LOG_INFO("\n\n***** Control+C to stop *****\n"); - - // Wait for interruption - while (true); + if (gMappingPipeline->start() != FrameworkReturnCode::_SUCCESS) { + LOG_ERROR("Cannot start mapping pipeline"); + return -1; + } + + while (true) { + // get data + std::vector> images; + std::vector poses; + std::chrono::system_clock::time_point timestamp; + if (gArDevice->getData(images, poses, timestamp) != FrameworkReturnCode::_SUCCESS) { + LOG_ERROR("Error during capture"); + break; + } + SRef image = images[INDEX_USE_CAMERA]; + Transform3Df pose = poses[INDEX_USE_CAMERA]; + // display image + if (gImageViewer->display(image) == FrameworkReturnCode::_STOP) break; + // mapping + gMappingPipeline->mappingProcessRequest(image, pose); + // get map + std::vector> pointCloud; + std::vector keyframePoses; + if (gMappingPipeline->getDataForVisualization(pointCloud, keyframePoses) == FrameworkReturnCode::_SUCCESS) { + if (g3DViewer->display(pointCloud, keyframePoses[keyframePoses.size() - 1], keyframePoses) == FrameworkReturnCode::_STOP) + break; + } + } + + while (true) { + std::vector> pointCloud; + std::vector keyframePoses; + if ((gMappingPipeline->getDataForVisualization(pointCloud, keyframePoses) != FrameworkReturnCode::_SUCCESS) || + (g3DViewer->display(pointCloud, keyframePoses[keyframePoses.size() - 1], keyframePoses) == FrameworkReturnCode::_STOP)) + break; + } + + std::vector> pointCloud; + std::vector keyframePoses; + gMappingPipeline->getDataForVisualization(pointCloud, keyframePoses); + LOG_INFO("Number of cloud points: {}", pointCloud.size()); + LOG_INFO("Number of keyframes: {}", keyframePoses.size()); + + gMappingPipeline->stop(); } catch (xpcf::Exception & e) { LOG_ERROR("The following exception has been caught {}", e.what()); diff --git a/Mapping/SolARPipeline_Mapping_Mono/tests/SolARPipelineTest_Mapping_Mono/SolARPipelineTest_Mapping_Mono.pro b/Mapping/SolARPipeline_Mapping_Mono/tests/SolARPipelineTest_Mapping_Mono/SolARPipelineTest_Mapping_Mono.pro index 052ab93..1e5d10c 100644 --- a/Mapping/SolARPipeline_Mapping_Mono/tests/SolARPipelineTest_Mapping_Mono/SolARPipelineTest_Mapping_Mono.pro +++ b/Mapping/SolARPipeline_Mapping_Mono/tests/SolARPipelineTest_Mapping_Mono/SolARPipelineTest_Mapping_Mono.pro @@ -58,9 +58,8 @@ win32 { } config_files.path = $${TARGETDEPLOYDIR} -config_files.files= $$files($${PWD}/SolARPipelineTest_Mapping_Mono_Producer_conf.xml)\ - $$files($${PWD}/SolARPipelineTest_Mapping_Mono_Viewer_conf.xml)\ - $$files($${PWD}/SolARPipelineTest_Mapping_Mono_Processing_conf.xml) +config_files.files= $$files($${PWD}/SolARPipelineTest_Mapping_Mono_conf.xml) + INSTALLS += config_files linux { diff --git a/Mapping/SolARPipeline_Mapping_Mono/tests/SolARPipelineTest_Mapping_Mono/SolARPipelineTest_Mapping_Mono_Producer_conf.xml b/Mapping/SolARPipeline_Mapping_Mono/tests/SolARPipelineTest_Mapping_Mono/SolARPipelineTest_Mapping_Mono_Producer_conf.xml deleted file mode 100644 index 2f6896a..0000000 --- a/Mapping/SolARPipeline_Mapping_Mono/tests/SolARPipelineTest_Mapping_Mono/SolARPipelineTest_Mapping_Mono_Producer_conf.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Mapping/SolARPipeline_Mapping_Mono/tests/SolARPipelineTest_Mapping_Mono/SolARPipelineTest_Mapping_Mono_Viewer_conf.xml b/Mapping/SolARPipeline_Mapping_Mono/tests/SolARPipelineTest_Mapping_Mono/SolARPipelineTest_Mapping_Mono_Viewer_conf.xml deleted file mode 100644 index c8e5b59..0000000 --- a/Mapping/SolARPipeline_Mapping_Mono/tests/SolARPipelineTest_Mapping_Mono/SolARPipelineTest_Mapping_Mono_Viewer_conf.xml +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - - - - - - - - - - - - 0 - 0 - 0 - - - - 0 - 255 - 0 - - - 255 - 255 - 255 - - - - - - - - - - 128 - 0 - 255 - - - 0 - 0 - 255 - - - - - - - diff --git a/Mapping/SolARPipeline_Mapping_Mono/tests/SolARPipelineTest_Mapping_Mono/SolARPipelineTest_Mapping_Mono_Processing_conf.xml b/Mapping/SolARPipeline_Mapping_Mono/tests/SolARPipelineTest_Mapping_Mono/SolARPipelineTest_Mapping_Mono_conf.xml similarity index 86% rename from Mapping/SolARPipeline_Mapping_Mono/tests/SolARPipelineTest_Mapping_Mono/SolARPipelineTest_Mapping_Mono_Processing_conf.xml rename to Mapping/SolARPipeline_Mapping_Mono/tests/SolARPipelineTest_Mapping_Mono/SolARPipelineTest_Mapping_Mono_conf.xml index 809cbc8..20fcf02 100644 --- a/Mapping/SolARPipeline_Mapping_Mono/tests/SolARPipelineTest_Mapping_Mono/SolARPipelineTest_Mapping_Mono_Processing_conf.xml +++ b/Mapping/SolARPipeline_Mapping_Mono/tests/SolARPipelineTest_Mapping_Mono/SolARPipelineTest_Mapping_Mono_conf.xml @@ -9,6 +9,18 @@ + + + + + + + + + + + + @@ -201,9 +213,17 @@ + + + + + + + + @@ -226,6 +246,20 @@ + + + + + + + + + + + + + + @@ -244,7 +278,7 @@ - + @@ -256,7 +290,7 @@ - + @@ -323,16 +357,16 @@ - + - + - + @@ -386,6 +420,46 @@ + + + + + + 0 + 0 + 0 + + + + 0 + 255 + 0 + + + 255 + 255 + 255 + + + + + + + + + + 128 + 0 + 255 + + + 0 + 0 + 255 + + + + diff --git a/Mapping/SolARPipeline_Mapping_Multi/tests/SolARPipelineTest_Mapping_Multi/SolARPipelineTestMappingMulti_main.cpp b/Mapping/SolARPipeline_Mapping_Multi/tests/SolARPipelineTest_Mapping_Multi/SolARPipelineTestMappingMulti_main.cpp index 531072a..2dcc18c 100644 --- a/Mapping/SolARPipeline_Mapping_Multi/tests/SolARPipelineTest_Mapping_Multi/SolARPipelineTestMappingMulti_main.cpp +++ b/Mapping/SolARPipeline_Mapping_Multi/tests/SolARPipelineTest_Mapping_Multi/SolARPipelineTestMappingMulti_main.cpp @@ -12,12 +12,7 @@ */ #include -#include "xpcf/threading/BaseTask.h" -#include #include -#include -#include - #include "core/Log.h" #include "api/pipeline/IMappingPipeline.h" #include "api/input/devices/IARDevice.h" @@ -34,229 +29,106 @@ namespace xpcf=org::bcom::xpcf; #define INDEX_USE_CAMERA 0 -// Global XPCF Component Manager -SRef gXpcfComponentManager = 0; - -// Global Mapping Pipeline Multithreads instance -SRef gMappingPipelineMulti = 0; - -// Global client threads -xpcf::DelegateTask * gClientProducerTask = 0; -xpcf::DelegateTask * gClientViewerTask = 0; - -// Viewer used by viewer client -SRef gViewer3D = 0; -// Point clouds and keyframe poses used by client viewer -std::vector> gPointClouds; -std::vector gKeyframePoses; - -// Components used by producer client -SRef gArDevice = 0; -SRef gImageViewer = 0; -// Indicates if producer client has images to send to mapping pipeline -bool gImageToSend = true; -// Nb of images sent by producer client -int gNbImages = 0; - - -// Fonction for producer client thread -auto fnClientProducer = []() { - - std::vector> images; - std::vector poses; - std::chrono::system_clock::time_point timestamp; - - // Still images to process? - if (gImageToSend) { - // Get data from hololens files - if (gArDevice->getData(images, poses, timestamp) == FrameworkReturnCode::_SUCCESS) { - - gNbImages ++; - LOG_DEBUG("Producer client: Send (image, pose) num {} to mapping pipeline", gNbImages); - - SRef image = images[INDEX_USE_CAMERA]; - Transform3Df pose = poses[INDEX_USE_CAMERA]; - - gMappingPipelineMulti->mappingProcessRequest(image, pose); - - if (gImageViewer->display(image) == SolAR::FrameworkReturnCode::_STOP) { - gClientProducerTask->stop(); - } - } - else { - gImageToSend = false; - LOG_INFO("Producer client: no more images to send"); - } - } -}; - -// Fonction for viewer client thread -auto fnClientViewer = []() { - - // Try to get point clouds and key frame poses to display - if (gMappingPipelineMulti->getDataForVisualization(gPointClouds, gKeyframePoses) == FrameworkReturnCode::_SUCCESS) { - - if (gViewer3D == 0) { - gViewer3D = gXpcfComponentManager->resolve(); - LOG_INFO("Viewer client: I3DPointsViewer component created"); - } - - // Display new data - gViewer3D->display(gPointClouds, gKeyframePoses[gKeyframePoses.size()-1], gKeyframePoses, {}, {}); - - } -}; - -// Function called when interruption signal is triggered -static void SigInt(int signo) { - - LOG_INFO("\n\n===> Program interruption\n"); - - LOG_INFO("Stop producer client thread"); - - if (gClientProducerTask != 0) - gClientProducerTask->stop(); - - LOG_INFO("Stop viewer client thread"); - - if (gClientViewerTask != 0) - gClientViewerTask->stop(); - - LOG_INFO("Stop mapping pipeline process"); - - if (gMappingPipelineMulti != 0) - gMappingPipelineMulti->stop(); - - boost::this_thread::sleep(boost::posix_time::milliseconds(1000)); - - LOG_INFO("End of test"); - - exit(0); -} - - -/// -/// \brief Test application for SolARMappingPipeline -/// - int main(int argc, char ** argv) { #if NDEBUG boost::log::core::get()->set_logging_enabled(false); #endif - LOG_ADD_LOG_TO_CONSOLE(); - // Signal interruption function (Ctrl + C) - signal(SIGINT, SigInt); - - // Default configuration file - char * config_file = (char *)"SolARPipelineTest_Mapping_Multi_Processing_conf.xml"; + // Default configuration file + char * config_file = (char *)"SolARPipelineTest_Mapping_Multi_conf.xml"; - if (argc > 1) { - // Get mapping pipeline configuration file path and name from main args - config_file = argv[1]; - } + if (argc > 1) { + // Get mapping pipeline configuration file path and name from main args + config_file = argv[1]; + } try { - LOG_INFO("Get Component Manager instance"); - - gXpcfComponentManager = xpcf::getComponentManagerInstance(); - - LOG_INFO("Load Mapping Pipeline Multithreads configuration file"); - - if (gXpcfComponentManager->load(config_file) == org::bcom::xpcf::_SUCCESS) - { - // Create Mapping Pipeline component - gMappingPipelineMulti = gXpcfComponentManager->resolve(); - - LOG_INFO("Mapping pipeline multithreads component created"); - } - else { - LOG_ERROR("Failed to load the configuration file {}", config_file); - return -1; - } - - // Manage producer client thread - if (gXpcfComponentManager->load("SolARPipelineTest_Mapping_Multi_Producer_conf.xml") == org::bcom::xpcf::_SUCCESS) - { - LOG_INFO("Producer client configuration file loaded"); - - gArDevice = gXpcfComponentManager->resolve(); - LOG_INFO("Producer client: AR device component created"); - - auto trackableLoader = gXpcfComponentManager->resolve(); - LOG_INFO("Producer client: Trackable loader component created"); - - gImageViewer = gXpcfComponentManager->resolve(); - LOG_INFO("Producer client: Image viewer component created"); - - // Connect remotely to the HoloLens streaming app - if (gArDevice->start() == FrameworkReturnCode::_SUCCESS) { - - // Load camera intrinsics parameters - CameraParameters camParams; - camParams = gArDevice->getParameters(0); - - LOG_INFO("Producer client: Set mapping pipeline camera parameters"); - gMappingPipelineMulti->setCameraParameters(camParams); - - LOG_INFO("Producer client: Load fiducial marker description file"); - SRef trackableObject = trackableLoader->loadTrackable(); - - if (trackableObject != 0) { - LOG_INFO("Producer client: Fiducial marker created: url = {}", trackableObject->getURL()); - - LOG_INFO("Producer client: Set mapping pipeline fiducial marker"); - gMappingPipelineMulti->setObjectToTrack(trackableObject); - - LOG_INFO("Producer client: Start mapping pipeline"); - - if (gMappingPipelineMulti->start() == FrameworkReturnCode::_SUCCESS) { - LOG_INFO("Start producer client thread"); - - gClientProducerTask = new xpcf::DelegateTask(fnClientProducer); - gClientProducerTask->start(); - } - else { - LOG_ERROR("Cannot start mapping pipeline"); - } - } - else { - LOG_ERROR("Error while loading fiducial marker"); - return -1; - } - } - else { - LOG_ERROR("Cannot start AR device loader"); - return -1; - } - } - else { - LOG_ERROR("Failed to load the producer client configuration file"); - return -1; - } - - // Manage viewer client thread - if (gXpcfComponentManager->load("SolARPipelineTest_Mapping_Multi_Viewer_conf.xml") == org::bcom::xpcf::_SUCCESS) - { - LOG_INFO("Viewer client configuration file loaded"); - - LOG_INFO("Start viewer client thread"); - - gClientViewerTask = new xpcf::DelegateTask(fnClientViewer); - gClientViewerTask->start(); - } - else { - LOG_ERROR("Failed to load the viewer client configuration file"); - return -1; - } - - LOG_INFO("\n\n***** Control+C to stop *****\n"); - - // Wait for interruption - while (true); - + LOG_INFO("Get Component Manager instance"); + SRef componentMgr = xpcf::getComponentManagerInstance(); + xpcf::XPCFErrorCode errorLoad = componentMgr->load(config_file); + if (errorLoad != xpcf::_SUCCESS) + { + LOG_ERROR("Failed to load the configuration file {}", config_file); + return -1; + } + auto gMappingPipeline = componentMgr->resolve(); + LOG_INFO("Mapping pipeline created"); + auto gArDevice = componentMgr->resolve(); + LOG_INFO("AR device component created"); + auto trackableLoader = componentMgr->resolve(); + LOG_INFO("Trackable loader component created"); + auto gImageViewer = componentMgr->resolve(); + LOG_INFO("Image viewer component created"); + auto g3DViewer = componentMgr->resolve(); + LOG_INFO("3D viewer component created"); + // Start device + if (gArDevice->start() != FrameworkReturnCode::_SUCCESS) { + LOG_ERROR("Cannot start AR device loader"); + return -1; + } + // Load camera intrinsics parameters + CameraParameters camParams; + camParams = gArDevice->getParameters(INDEX_USE_CAMERA); + // Set camera parameters + gMappingPipeline->setCameraParameters(camParams); + // Load trackable + SRef trackableObject = trackableLoader->loadTrackable(); + // Check and set trackable + if (trackableObject) { + LOG_INFO("Fiducial marker created: url = {}", trackableObject->getURL()); + gMappingPipeline->setObjectToTrack(trackableObject); + } + else { + LOG_ERROR("Error while loading fiducial marker"); + return -1; + } + + if (gMappingPipeline->start() != FrameworkReturnCode::_SUCCESS) { + LOG_ERROR("Cannot start mapping pipeline"); + return -1; + } + + while (true) { + // get data + std::vector> images; + std::vector poses; + std::chrono::system_clock::time_point timestamp; + if (gArDevice->getData(images, poses, timestamp) != FrameworkReturnCode::_SUCCESS) { + LOG_ERROR("Error during capture"); + break; + } + SRef image = images[INDEX_USE_CAMERA]; + Transform3Df pose = poses[INDEX_USE_CAMERA]; + // display image + if (gImageViewer->display(image) == FrameworkReturnCode::_STOP) break; + // mapping + gMappingPipeline->mappingProcessRequest(image, pose); + // get map + std::vector> pointCloud; + std::vector keyframePoses; + if (gMappingPipeline->getDataForVisualization(pointCloud, keyframePoses) == FrameworkReturnCode::_SUCCESS) { + if (g3DViewer->display(pointCloud, keyframePoses[keyframePoses.size() - 1], keyframePoses) == FrameworkReturnCode::_STOP) + break; + } + } + + while (true) { + std::vector> pointCloud; + std::vector keyframePoses; + if ((gMappingPipeline->getDataForVisualization(pointCloud, keyframePoses) != FrameworkReturnCode::_SUCCESS) || + (g3DViewer->display(pointCloud, keyframePoses[keyframePoses.size() - 1], keyframePoses) == FrameworkReturnCode::_STOP)) + break; + } + + std::vector> pointCloud; + std::vector keyframePoses; + gMappingPipeline->getDataForVisualization(pointCloud, keyframePoses); + LOG_INFO("Number of cloud points: {}", pointCloud.size()); + LOG_INFO("Number of keyframes: {}", keyframePoses.size()); + + gMappingPipeline->stop(); } catch (xpcf::Exception & e) { LOG_ERROR("The following exception has been caught {}", e.what()); diff --git a/Mapping/SolARPipeline_Mapping_Multi/tests/SolARPipelineTest_Mapping_Multi/SolARPipelineTest_Mapping_Multi.pro b/Mapping/SolARPipeline_Mapping_Multi/tests/SolARPipelineTest_Mapping_Multi/SolARPipelineTest_Mapping_Multi.pro index a466b93..6aa1c68 100644 --- a/Mapping/SolARPipeline_Mapping_Multi/tests/SolARPipelineTest_Mapping_Multi/SolARPipelineTest_Mapping_Multi.pro +++ b/Mapping/SolARPipeline_Mapping_Multi/tests/SolARPipelineTest_Mapping_Multi/SolARPipelineTest_Mapping_Multi.pro @@ -58,9 +58,8 @@ win32 { } config_files.path = $${TARGETDEPLOYDIR} -config_files.files= $$files($${PWD}/SolARPipelineTest_Mapping_Multi_Producer_conf.xml)\ - $$files($${PWD}/SolARPipelineTest_Mapping_Multi_Viewer_conf.xml)\ - $$files($${PWD}/SolARPipelineTest_Mapping_Multi_Processing_conf.xml) +config_files.files= $$files($${PWD}/SolARPipelineTest_Mapping_Multi_conf.xml) + INSTALLS += config_files linux { diff --git a/Mapping/SolARPipeline_Mapping_Multi/tests/SolARPipelineTest_Mapping_Multi/SolARPipelineTest_Mapping_Multi_Producer_conf.xml b/Mapping/SolARPipeline_Mapping_Multi/tests/SolARPipelineTest_Mapping_Multi/SolARPipelineTest_Mapping_Multi_Producer_conf.xml deleted file mode 100644 index 2f6896a..0000000 --- a/Mapping/SolARPipeline_Mapping_Multi/tests/SolARPipelineTest_Mapping_Multi/SolARPipelineTest_Mapping_Multi_Producer_conf.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Mapping/SolARPipeline_Mapping_Multi/tests/SolARPipelineTest_Mapping_Multi/SolARPipelineTest_Mapping_Multi_Viewer_conf.xml b/Mapping/SolARPipeline_Mapping_Multi/tests/SolARPipelineTest_Mapping_Multi/SolARPipelineTest_Mapping_Multi_Viewer_conf.xml deleted file mode 100644 index c8e5b59..0000000 --- a/Mapping/SolARPipeline_Mapping_Multi/tests/SolARPipelineTest_Mapping_Multi/SolARPipelineTest_Mapping_Multi_Viewer_conf.xml +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - - - - - - - - - - - - 0 - 0 - 0 - - - - 0 - 255 - 0 - - - 255 - 255 - 255 - - - - - - - - - - 128 - 0 - 255 - - - 0 - 0 - 255 - - - - - - - diff --git a/Mapping/SolARPipeline_Mapping_Multi/tests/SolARPipelineTest_Mapping_Multi/SolARPipelineTest_Mapping_Multi_Processing_conf.xml b/Mapping/SolARPipeline_Mapping_Multi/tests/SolARPipelineTest_Mapping_Multi/SolARPipelineTest_Mapping_Multi_conf.xml similarity index 83% rename from Mapping/SolARPipeline_Mapping_Multi/tests/SolARPipelineTest_Mapping_Multi/SolARPipelineTest_Mapping_Multi_Processing_conf.xml rename to Mapping/SolARPipeline_Mapping_Multi/tests/SolARPipelineTest_Mapping_Multi/SolARPipelineTest_Mapping_Multi_conf.xml index 5578099..959efe6 100644 --- a/Mapping/SolARPipeline_Mapping_Multi/tests/SolARPipelineTest_Mapping_Multi/SolARPipelineTest_Mapping_Multi_Processing_conf.xml +++ b/Mapping/SolARPipeline_Mapping_Multi/tests/SolARPipelineTest_Mapping_Multi/SolARPipelineTest_Mapping_Multi_conf.xml @@ -1,14 +1,26 @@ - - + + + + + + + + + + + + + + @@ -201,14 +213,22 @@ + + + + + + + + - + @@ -226,6 +246,20 @@ + + + + + + + + + + + + + + @@ -244,7 +278,7 @@ - + @@ -256,19 +290,27 @@ - + - + - + - + + + + + + + + + @@ -283,7 +325,7 @@ - + @@ -315,16 +357,16 @@ - + - + - + @@ -378,6 +420,46 @@ + + + + + + 0 + 0 + 0 + + + + 0 + 255 + 0 + + + 255 + 255 + 255 + + + + + + + + + + 128 + 0 + 255 + + + 0 + 0 + 255 + + + + diff --git a/Mapping/SolARSample_Mapping_Mono/SolARSample_Mapping_Mono_conf.xml b/Mapping/SolARSample_Mapping_Mono/SolARSample_Mapping_Mono_conf.xml index c65cd52..16023ea 100644 --- a/Mapping/SolARSample_Mapping_Mono/SolARSample_Mapping_Mono_conf.xml +++ b/Mapping/SolARSample_Mapping_Mono/SolARSample_Mapping_Mono_conf.xml @@ -240,7 +240,7 @@ - + @@ -260,7 +260,7 @@ - + diff --git a/Mapping/SolARSample_Mapping_Multi/SolARSample_Mapping_Multi_conf.xml b/Mapping/SolARSample_Mapping_Multi/SolARSample_Mapping_Multi_conf.xml index a926ebd..620729d 100644 --- a/Mapping/SolARSample_Mapping_Multi/SolARSample_Mapping_Multi_conf.xml +++ b/Mapping/SolARSample_Mapping_Multi/SolARSample_Mapping_Multi_conf.xml @@ -240,7 +240,7 @@ - + @@ -260,7 +260,7 @@ - +