1#ifndef LIB3D_OTS_COLMAPWRAPPER_H
2#define LIB3D_OTS_COLMAPWRAPPER_H
22#include <QTemporaryDir>
23#include <QTemporaryFile>
24#include <QtConcurrent>
25#include <QCryptographicHash>
28#include <opencv2/core.hpp>
39 class ColmapWrapperControlsFactory;
41 namespace colmapwrapper {
44 class NewProductDialog;
98 enum ESetupTestResult {
116 std::string displayName;
256 explicit ColmapWrapper(
const QString iSettingsFile =
"lib3D_ColmapWrapper.ini",
257 const bool iSettingsOnly =
false);
274 bool testSettings(
const SSettings* settings, SSetupResults* results);
278 void restoreDefaultSettings();
280 void loadDefaultSettings();
282 QMultiMap<QString,QString> imageSequencePaths()
const;
344 bool getSetupSuccessful();
422 void setLocalPresetSequence(QString name, QString path);
504 void addJobList(
const std::vector<SJob> &iJobList);
554 SSequence getLocalPresetSequence()
const;
638 void exportJobs(cv::FileStorage &ioFileStorage)
const;
643 void exportJob(cv::FileStorage &ioFileStorage,
const SJob &iJob)
const;
649 void importJob(
const cv::FileNode &iFileNode,
SJob &oJob)
const;
655 bool hasSequence(
const std::string iSeqName)
const;
798 QWidget* parent =
nullptr, QPushButton* rhs =
nullptr);
808 QWidget* parent =
nullptr, QToolButton* rhs =
nullptr);
818 QWidget* parent =
nullptr, QPushButton* rhs =
nullptr);
828 QWidget* parent =
nullptr, QToolButton* rhs =
nullptr);
838 QWidget* parent =
nullptr, QAction* rhs =
nullptr);
864 void enableNewProductButtons(
bool enabled);
889 void onSetupChanged();
Wrapperclass for integration of COLMAP.
Definition colmapwrapper.h:53
QString remoteColmapBinPath() const
Returns absolute path to COLMAP binary on remote machine.
Definition colmapwrapper.cpp:1133
std::vector< SSequence > getFinishedSequenceList() const
Definition colmapwrapper.cpp:952
QString mRemoteUsr
User on remote server.
Definition colmapwrapper.h:756
std::vector< SSequence > mAvailableSequences
List of available sequences.
Definition colmapwrapper.h:762
bool hasProduct(const std::string iSeqName, const ColmapWrapper::EProductType iPdctType) const
Returns true, if product with given of given type is available in sequence.
Definition colmapwrapper.cpp:843
void setConnectionType(const EConnectionType &connection)
Set connection type to Metashape.
Definition colmapwrapper.cpp:1074
void setRemoteAddr(const QString &remoteAddr)
Set address of remote server. If empty it assumed that Metashape runs on local machine.
Definition colmapwrapper.cpp:1203
bool mSetupSuccessful
current status of the setup, true if colmap can be used
Definition colmapwrapper.h:773
QString getFirstMatchingFileNameWithWildcard(const QString &path, QString baseName) const
Return the first file with a wildcard suffix.
Definition colmapwrapper.cpp:586
void writeSettings()
Write settings to settings-file specified in the ColmapWrapper().
Definition colmapwrapper.cpp:439
SWorker mPyWorker
Member object of Python worker.
Definition colmapwrapper.h:728
void jobListUpdate()
Signal that the list of outstanding jobs is updated and should be reloaded.
QString localOpenMVSBinPath() const
Returns absolute path to OpenMVS binary on local machine.
Definition colmapwrapper.cpp:1086
void clearAvailableSequenceList()
Remove all available sequences from list.
Definition colmapwrapper.cpp:1342
SJob * getJobPtrAtIdx(int iIdx)
Returns job at given index.
Definition colmapwrapper.cpp:1311
void importJob(const cv::FileNode &iFileNode, SJob &oJob) const
Import job from given cv::FileNode object.
Definition colmapwrapper.cpp:812
QTemporaryDir * mpTempDir
Pointer to temporary directory.
Definition colmapwrapper.h:716
int getIndexOfJob(const SJob &iJob)
Definition colmapwrapper.cpp:865
void setSyncInterval(int intervalInSeconds)
Set interval (in seconds) in which the client and server should be synchronized.
Definition colmapwrapper.cpp:1004
void addJob(const SJob &iJob)
Add new job to the end of the list.
Definition colmapwrapper.cpp:1221
void setChecksDisabled(const bool noChecks)
Set the use of expert mode.
Definition colmapwrapper.cpp:922
bool hasSequence(const std::string iSeqName) const
Returns true, if sequence with given sequence name is available.
Definition colmapwrapper.cpp:832
void clearWorkerStateFile()
Clear worker state file (colmap_worker_state.yaml) in workspace.
Definition colmapwrapper.cpp:468
QTimer mCheckWorkerTimer
Timer object to chech worker file server and client.
Definition colmapwrapper.h:725
bool checkWorkerState()
Method to check worker state.
Definition colmapwrapper.cpp:1029
QString mntPntRemoteWorkspacePath() const
Returns path to mount point of remote workspace on local machine.
Definition colmapwrapper.cpp:975
QString mRemoteWorkspacePath
Absolute path to workspace on remote machine.
Definition colmapwrapper.h:696
QList< QPair< QString, QString > > mCustomCommands
input field for custom commands
Definition colmapwrapper.h:713
bool hasScriptFilesInstalled()
check if script files are already installed
Definition colmapwrapper.cpp:1529
void readWorkQueueFromFile()
Read work queue from file (colmap_work_queue.yaml) in workspace.
Definition colmapwrapper.cpp:621
std::vector< SJob > mJobs
List of job pointers.
Definition colmapwrapper.h:767
bool isRemoteWorkspaceMounted(QString iRemoteWorkspacePath) const
Returns true, if remote workspace is mounted. False, otherwise.
Definition colmapwrapper.cpp:1019
void setLocalOpenMVSBinPath(const QString &openMVSBinPath)
Set absolute path to OpenMVS binary folder on local machine.
Definition colmapwrapper.cpp:1116
QString remoteOpenMVSBinPath() const
Returns absolute path to OpenMVS binary on remote machine.
Definition colmapwrapper.cpp:1139
EConnectionType mConnectionType
Connection to location of Metashape.
Definition colmapwrapper.h:749
bool mNoChecks
flag wether to use expert mode, in which some 'user-guidance' features ar deactivated
Definition colmapwrapper.h:707
bool mUseRobustMode
flag wether to use robust mode
Definition colmapwrapper.h:710
bool moveJobOneDown(const SJob &iJob)
Move given Job one down in queue.
Definition colmapwrapper.cpp:1263
void addJobList(const std::vector< SJob > &iJobList)
Append list of Jobs to the end of the current list.
Definition colmapwrapper.cpp:1227
bool testSettings(const SSettings *settings, SSetupResults *results)
Definition colmapwrapper.cpp:133
void setLocalColmapBinPath(const QString &colmapBinPath)
Set absolute path to COLMAP binary on local machine.
Definition colmapwrapper.cpp:1099
void applySettings(const SSettings *settings)
switchWorkspace tries to switch to the local/remote workspace.
Definition colmapwrapper.cpp:893
void setRemoteUsr(const QString &remoteUsr)
Set user on remote server.
Definition colmapwrapper.cpp:1215
void installScriptFilesIntoWorkspace()
Method to install script files into workspace.
Definition colmapwrapper.cpp:1468
int mSyncInterval
Interval of background synchronization between server and client.
Definition colmapwrapper.h:759
void init()
Initialization routine.
Definition colmapwrapper.cpp:84
bool moveJobOneUp(const SJob &iJob)
Move given Job one up in queue.
Definition colmapwrapper.cpp:1236
QString mLocalColmapBinPath
Absolute path to COLMAP binary on local machine.
Definition colmapwrapper.h:734
EConnectionType connectionType() const
Returns type of connection to COLMAP.
Definition colmapwrapper.cpp:1068
QString mLocalOpenMVSBinPath
Absolute path to OpenMVS binary folder on local machine.
Definition colmapwrapper.h:737
virtual ~ColmapWrapper()
Destructor.
Definition colmapwrapper.cpp:76
int removeFinishedJobs()
Remove finished jobs from list.
Definition colmapwrapper.cpp:1323
void setLocalWorkspacePath(const QString &localWorkspacePath)
Set absolute path to workspace on local machine.
Definition colmapwrapper.cpp:1166
QString remoteAddr() const
Returns address of remote server.
Definition colmapwrapper.cpp:1197
void setRemoteOpenMVSBinPath(const QString &openMVSBinPath)
Set absolute path to OpenMVS binary folder on remote machine.
Definition colmapwrapper.cpp:1154
EWorkerState
Enum holding worker states.
Definition colmapwrapper.h:82
@ WORKER_RUNNING
Definition colmapwrapper.h:84
@ WORKER_IDLE
Definition colmapwrapper.h:83
@ WORKER_FAILED
Definition colmapwrapper.h:85
EWorkerState getWorkerState() const
Get state of worker.
Definition colmapwrapper.cpp:969
void startProcessing()
Method to invoke processing of job queue by COLMAP.
Definition colmapwrapper.cpp:1365
ui::ColmapWrapperControlsFactory * getOrCreateUiControlsFactory()
Method to get or create a pointer to a factory object that allows to create ui controls for the Colma...
Definition colmapwrapper.cpp:1585
int getNumJobs() const
Returns Number of Jobs in Queue.
Definition colmapwrapper.cpp:1317
QStringList mPyWorkerArguments
Arguments for Python worker.
Definition colmapwrapper.h:731
void settingsApplied()
Signal that new colmap settings have been applied.
int syncInterval() const
Returns interval (in seconds) in which the client and server should be synchronized.
Definition colmapwrapper.cpp:993
void exportJobs(cv::FileStorage &ioFileStorage) const
Export jobs within mJobs into given cv::FileStorage object.
Definition colmapwrapper.cpp:781
QString remoteWorkspacePath() const
Returns absolute path to workspace on remote machine.
Definition colmapwrapper.cpp:1182
void setMntPntRemoteWorkspacePath(const QString &mntPntRemoteWorkspacePath)
Set path to mount point of remote workspace.
Definition colmapwrapper.cpp:987
void exportJob(cv::FileStorage &ioFileStorage, const SJob &iJob) const
Export given job into given cv::FileStorage object.
Definition colmapwrapper.cpp:791
EProductType
Enum holding product types that can be processed with Agisoft Metashape.
Definition colmapwrapper.h:91
@ MESHED_MODEL
Definition colmapwrapper.h:94
@ CAMERA_POSES
Definition colmapwrapper.h:92
@ DENSE_CLOUD
Definition colmapwrapper.h:93
@ CUSTOM_COMMAND
Definition colmapwrapper.h:95
void workspaceStatusUpdate()
Signal that the state of the workspace has updated.
static ColmapWrapper::EProductType QString2EProductType(const QString iStr)
Convert string to product type.
Definition colmapwrapper.cpp:884
QProcess * mpPyWorkerProcess
Process for Python worker.
Definition colmapwrapper.h:719
bool areChecksDisabled() const
Returns true if expert mode is activated.
Definition colmapwrapper.cpp:928
void setRemoteWorkspacePath(const QString &remoteWorkspacePath)
Set absolute path to workspace on remote machine.
Definition colmapwrapper.cpp:1188
void openColmapLogFile()
Method to open COLMAP Log File.
Definition colmapwrapper.cpp:1453
QString mRemoteOpenMVSBinPath
Absolute path to OpenMVS binary folder on remote machine.
Definition colmapwrapper.h:743
bool useRobustMode()
Returns wether robustMode should be used.
Definition colmapwrapper.cpp:946
EJobState
Enum holding job states.
Definition colmapwrapper.h:71
@ JOB_RUNNING
Definition colmapwrapper.h:73
@ JOB_PENDING
Definition colmapwrapper.h:74
@ JOB_DONE
Definition colmapwrapper.h:72
@ JOB_FAILED
Definition colmapwrapper.h:75
QString localWorkspacePath() const
Returns absolute path to workspace on local machine.
Definition colmapwrapper.cpp:1160
QString remoteUsr() const
Returns user on remote server which is allowed to run COLMAP.
Definition colmapwrapper.cpp:1209
void moveJobInQueue(const int fromidx, const int toIdx)
Move job in queue.
Definition colmapwrapper.cpp:859
void setRemoteColmapBinPath(const QString &remoteColmapBinPath)
Set absolute path to COLMAP binary on remote machine.
Definition colmapwrapper.cpp:1145
void readSettings()
Read settings from settings-file specified in the ColmapWrapper().
Definition colmapwrapper.cpp:394
EConnectionType
Enum holding the type of connection to COLMAP.
Definition colmapwrapper.h:63
@ SSH
Definition colmapwrapper.h:65
@ LOCAL
Definition colmapwrapper.h:64
void settingsTested(bool valid)
settingsTested is emitted once all tests have finished.
void sequenceListUpdate()
Signal that the list of available sequences is updated and should be reloaded.
void writeWorkQueueToFile()
Write work queue to file (colmap_work_queue.yaml) in workspace.
Definition colmapwrapper.cpp:520
bool deleteJob(const SJob &iJob)
Delete given Job.
Definition colmapwrapper.cpp:1283
QString mRemoteColmapBinPath
Absolute path to COLMAP binary on remote machine.
Definition colmapwrapper.h:740
QString mLocalWorkspacePath
Absolute path to workspace on local machine.
Definition colmapwrapper.h:693
QString mMntPntRemoteWorkspacePath
Absolute path to temporary mount location of remote directory.
Definition colmapwrapper.h:746
ui::ColmapWrapperControlsFactory * mpUiControls
Pointer to UiControlsFactory object.
Definition colmapwrapper.h:770
QList< QPair< QString, QString > > customCommands() const
Returns custom command.
Definition colmapwrapper.cpp:981
QString mRemoteAddr
Definition colmapwrapper.h:753
QProcess * mpMountProcess
Process for mounting operations.
Definition colmapwrapper.h:722
QString getProductFilePath(QString iSeqName, const EProductType &iProdType)
Get path of file for given product in sequence.
Definition colmapwrapper.cpp:1348
void afterSettingsChanged()
Sync files and update job list after colmap wrapper settings changed.
Definition colmapwrapper.cpp:773
void setCustomCommands(QList< QPair< QString, QString > > customCommands)
Set the custom command.
Definition colmapwrapper.cpp:940
bool setUseRobustMode() const
Set wether robustMode should be used.
QString localColmapBinPath() const
Returns absolute path to COLMAP binary on local machine.
Definition colmapwrapper.cpp:1080
std::vector< SJob > getJobList() const
Get list with available (i.e. already processed) sequences.
Definition colmapwrapper.cpp:963
void readWorkerStateFromFile()
Read worker state from file (colmap_worker_state.yaml) in workspace.
Definition colmapwrapper.cpp:676
QSettings mSettings
Settings object.
Definition colmapwrapper.h:704
void setupStatusUpdate()
Signal that the setup has changed.
void workerStateUpdate()
Signal that the state of the MetashapeWorker has updated.
static QString EProductType2QString(const ColmapWrapper::EProductType iType)
Convert product type to string.
Definition colmapwrapper.cpp:878
Class providing ui elements for controlling ColmapWrapper.
Definition colmapwrapper.h:784
QToolButton * createNewProductToolButton(ETheme iTheme=LIGHT, QWidget *parent=nullptr, QToolButton *rhs=nullptr)
Create a QToolButton that opens the "New Product" dialog.
Definition colmapwrapper.cpp:1633
QPushButton * createNewProductPushButton(ETheme iTheme=LIGHT, QWidget *parent=nullptr, QPushButton *rhs=nullptr)
Create a QPushButton that opens the "New Product" dialog.
Definition colmapwrapper.cpp:1594
lib3d::ots::ColmapWrapper * mpMsWrapper
Member pointer to MetashapeWrapper.
Definition colmapwrapper.h:893
QSharedPointer< colmapwrapper::SettingsDialog > mpMsWrapperSettingsDialog
MetashapeWrapperSettingsDialog Member.
Definition colmapwrapper.h:899
void updateIconTheme(ETheme iTheme)
Method to update icon themes.
Definition colmapwrapper.cpp:1755
QToolButton * createSettingsToolButton(ETheme iTheme=LIGHT, QWidget *parent=nullptr, QToolButton *rhs=nullptr)
Create a QToolButton that opens the settings dialog.
Definition colmapwrapper.cpp:1692
QWidget * createViewWidget(QWidget *parent=nullptr)
Create ViewWidget for interaction with MetashapeWrapper.
Definition colmapwrapper.cpp:1746
void showSettingsDialog()
Slot to show "Settings" dialog.
Definition colmapwrapper.cpp:1779
QPushButton * createSettingsPushButton(ETheme iTheme=LIGHT, QWidget *parent=nullptr, QPushButton *rhs=nullptr)
Create a QPushButton that opens the settings dialog.
Definition colmapwrapper.cpp:1663
void showNewProductDialog()
Slot to show "New Product" dialog.
Definition colmapwrapper.cpp:1789
void updateToLightTheme()
Signal to update ui to light theme.
void updateToDarkTheme()
Signal to update ui to dark theme.
QSharedPointer< colmapwrapper::NewProductDialog > mpMsWrapperNewProductDialog
MetashapeWrapperNewProductDialog Member.
Definition colmapwrapper.h:896
QAction * createSettingsAction(ETheme iTheme=LIGHT, QWidget *parent=nullptr, QAction *rhs=nullptr)
Create a QAction that opens the settings dialog.
Definition colmapwrapper.cpp:1720
Struct holding information of a single job.
Definition colmapwrapper.h:111
EJobState state
State in which the job is currently in.
Definition colmapwrapper.h:125
uint step
current step of job.
Definition colmapwrapper.h:131
uint eta
ETA (expected time of arrival) for current step in ms.
Definition colmapwrapper.h:134
std::string sequenceName
Name of sequence to which the job / product is assiciated.
Definition colmapwrapper.h:114
uint progress
Progress of this job (in %).
Definition colmapwrapper.h:128
std::map< std::string, std::string > parameters
Parameters for computation of the product.
Definition colmapwrapper.h:122
EProductType product
Product type that is computed by this job.
Definition colmapwrapper.h:119
Struct holding information of a single product.
Definition colmapwrapper.h:152
EProductType type
Type of the product.
Definition colmapwrapper.h:155
bool isFinished
True, if product is finished.
Definition colmapwrapper.h:158
Struct holding information of a single sequence.
Definition colmapwrapper.h:165
std::string imagePath
Path to the images of the sequence.
Definition colmapwrapper.h:170
std::vector< SProduct > products
Products available (already processed) for the named sequence.
Definition colmapwrapper.h:173
std::string name
Sequence name.
Definition colmapwrapper.h:167
Definition colmapwrapper.h:177
QString remoteOpenMVSBinPath
Absolute path to OpenMVS binary on remote machine.
Definition colmapwrapper.h:188
int syncInterval
Interval of background synchronization between server and client.
Definition colmapwrapper.h:213
EConnectionType connectionType
Connection to location of Metashape.
Definition colmapwrapper.h:200
QString localOpenMVSBinPath
Absolute path to OpenMVS binary on local machine.
Definition colmapwrapper.h:185
QString remoteColmapBinPath
Absolute path to COLMAP binary on remote machine.
Definition colmapwrapper.h:182
QString mntPntRemoteWorkspacePath
Absolute path to temporary mount location of remote directory.
Definition colmapwrapper.h:197
QList< QPair< QString, QString > > customCommands
Custom command for 3d reconstruction.
Definition colmapwrapper.h:210
QString remoteAddr
Definition colmapwrapper.h:204
QString localWorkspacePath
Absolute path to workspace on local machine.
Definition colmapwrapper.h:191
QString remoteWorkspacePath
Absolute path to workspace on remote machine.
Definition colmapwrapper.h:194
QString remoteUsr
User on remote server.
Definition colmapwrapper.h:207
QString localColmapBinPath
Absolute path to COLMAP binary on local machine.
Definition colmapwrapper.h:179
Definition colmapwrapper.h:217
QPair< ESetupTestResult, QString > remoteOpenMVSBinPath
Absolute path to COLMAP binary on remote machine.
Definition colmapwrapper.h:228
QPair< ESetupTestResult, QString > fileSystemMount
remote workspace mounted
Definition colmapwrapper.h:243
QPair< ESetupTestResult, QString > remoteWorkspacePath
Absolute path to workspace on remote machine.
Definition colmapwrapper.h:234
QPair< ESetupTestResult, QString > localWorkspacePath
Absolute path to workspace on local machine.
Definition colmapwrapper.h:231
QPair< ESetupTestResult, QString > sshConnection
Connection to server.
Definition colmapwrapper.h:240
QPair< ESetupTestResult, QString > localColmapBinPath
Absolute path to COLMAP binary on local machine.
Definition colmapwrapper.h:219
QPair< ESetupTestResult, QString > localOpenMVSBinPath
Absolute path to COLMAP binary on local machine.
Definition colmapwrapper.h:225
QPair< ESetupTestResult, QString > mntPntRemoteWorkspacePath
Absolute path to temporary mount location of remote directory.
Definition colmapwrapper.h:237
QPair< ESetupTestResult, QString > remoteColmapBinPath
Absolute path to COLMAP binary on remote machine.
Definition colmapwrapper.h:222
Struct holding information of current worker state.
Definition colmapwrapper.h:140
EWorkerState state
State of the worker.
Definition colmapwrapper.h:143
SJob * currentlyRunningJob
Pointer of the currently processed job within ColmapWrapper::mJobs.
Definition colmapwrapper.h:146