This repository has been archived by the owner on Jul 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Remove producer and viewer clients from pipeline tests #5
Open
duongnamduong
wants to merge
7
commits into
develop
Choose a base branch
from
feat/cleaner-exit-on-escape
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b89fbe9
Pipeline tests: same behavior for pressing esc than ctrl+C
jim-bcom d180248
Remove producer and viewer clients from pipeline tests
56f9ce2
Remove redundant includes. Use _STOP check when stopping pipeline by …
77b1044
save output maps of mapping sample and extension sample in the binary…
77970b1
Give same delayTime value of 300 for all SolARDeviceDataLoaders
jim-bcom f5c71ff
Place samples-produced maps in bin/ directory
jim-bcom d49bf74
Merge pull request #7 from SolarFramework/feat/organize-maps-output
duongnamduong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
#include <boost/log/core.hpp> | ||
#include <boost/thread/thread.hpp> | ||
#include <signal.h> | ||
#include <thread> | ||
|
||
#include "core/Log.h" | ||
#include "api/pipeline/IMappingPipeline.h" | ||
|
@@ -34,109 +35,6 @@ namespace xpcf=org::bcom::xpcf; | |
|
||
#define INDEX_USE_CAMERA 0 | ||
|
||
// Global XPCF Component Manager | ||
SRef<xpcf::IComponentManager> gXpcfComponentManager = 0; | ||
|
||
// Global Mapping Pipeline instance | ||
SRef<pipeline::IMappingPipeline> gMappingPipeline = 0; | ||
|
||
// Global client threads | ||
xpcf::DelegateTask * gClientProducerTask = 0; | ||
xpcf::DelegateTask * gClientViewerTask = 0; | ||
|
||
// Viewer used by viewer client | ||
SRef<api::display::I3DPointsViewer> gViewer3D = 0; | ||
// Point clouds and keyframe poses used by client viewer | ||
std::vector<SRef<CloudPoint>> gPointClouds; | ||
std::vector<Transform3Df> gKeyframePoses; | ||
|
||
// Components used by producer client | ||
SRef<input::devices::IARDevice> gArDevice = 0; | ||
SRef<display::IImageViewer> 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<SRef<Image>> images; | ||
std::vector<Transform3Df> 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> 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<display::I3DPointsViewer>(); | ||
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 +43,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 +53,82 @@ 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<pipeline::IMappingPipeline>(); | ||
|
||
LOG_INFO("Mapping pipeline component created"); | ||
SRef<xpcf::IComponentManager> 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<pipeline::IMappingPipeline>(); | ||
LOG_INFO("Mapping pipeline created"); | ||
auto gArDevice = componentMgr->resolve<input::devices::IARDevice>(); | ||
LOG_INFO("AR device component created"); | ||
auto trackableLoader = componentMgr->resolve<input::files::ITrackableLoader>(); | ||
LOG_INFO("Trackable loader component created"); | ||
auto gImageViewer = componentMgr->resolve<display::IImageViewer>(); | ||
LOG_INFO("Image viewer component created"); | ||
auto g3DViewer = componentMgr->resolve<display::I3DPointsViewer>(); | ||
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<Trackable> 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<input::devices::IARDevice>(); | ||
LOG_INFO("Producer client: AR device component created"); | ||
|
||
auto trackableLoader = gXpcfComponentManager->resolve<input::files::ITrackableLoader>(); | ||
LOG_INFO("Producer client: Trackable loader component created"); | ||
|
||
gImageViewer = gXpcfComponentManager->resolve<display::IImageViewer>(); | ||
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<Trackable> 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<SRef<Image>> images; | ||
std::vector<Transform3Df> poses; | ||
std::chrono::system_clock::time_point timestamp; | ||
if (gArDevice->getData(images, poses, timestamp) != FrameworkReturnCode::_SUCCESS) { | ||
LOG_ERROR("Error during capture"); | ||
break; | ||
} | ||
SRef<Image> image = images[INDEX_USE_CAMERA]; | ||
Transform3Df pose = poses[INDEX_USE_CAMERA]; | ||
// display image | ||
if (gImageViewer->display(image) != FrameworkReturnCode::_SUCCESS) break; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. LOG_ERROR ? If it's an error, this path should not lead to return 0. |
||
// mapping | ||
gMappingPipeline->mappingProcessRequest(image, pose); | ||
// get map | ||
std::vector<SRef<CloudPoint>> pointCloud; | ||
std::vector<Transform3Df> keyframePoses; | ||
if (gMappingPipeline->getDataForVisualization(pointCloud, keyframePoses) == FrameworkReturnCode::_SUCCESS) { | ||
if (g3DViewer->display(pointCloud, keyframePoses[keyframePoses.size() - 1], keyframePoses) != FrameworkReturnCode::_SUCCESS) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. LOG_ERROR() ? |
||
break; | ||
} | ||
} | ||
|
||
std::vector<SRef<CloudPoint>> pointCloud; | ||
std::vector<Transform3Df> keyframePoses; | ||
if (gMappingPipeline->getDataForVisualization(pointCloud, keyframePoses) == FrameworkReturnCode::_SUCCESS) { | ||
LOG_INFO("Number of cloud points: {}", pointCloud.size()); | ||
LOG_INFO("Number of keyframes: {}", keyframePoses.size()); | ||
while (g3DViewer->display(pointCloud, keyframePoses[keyframePoses.size() - 1], keyframePoses) == FrameworkReturnCode::_SUCCESS); | ||
} | ||
jim-bcom marked this conversation as resolved.
Show resolved
Hide resolved
|
||
gMappingPipeline->stop(); | ||
} | ||
catch (xpcf::Exception & e) { | ||
LOG_ERROR("The following exception has been caught {}", e.what()); | ||
|
42 changes: 0 additions & 42 deletions
42
...ono/tests/SolARPipelineTest_Mapping_Mono/SolARPipelineTest_Mapping_Mono_Producer_conf.xml
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this comes from my previous commit, check whether you can remove it.