Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose methods in calibration widgets #192

Merged
merged 5 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,38 @@ class CameraIntrinsicCalibrationWidget : public QMainWindow
explicit CameraIntrinsicCalibrationWidget(QWidget* parent = nullptr);
~CameraIntrinsicCalibrationWidget();

/**
* @brief Loads the calibration configuration from file
* @throws Exception on failure
*/
void loadConfig(const std::string& config_file);

/**
* @brief Loads the calibration observations from file
* @throws Exception on failure
*/
void loadObservations(const std::string& obserations_file);

private:
void loadConfig();
void loadObservations();
/**
* @brief Performs the calibration
* @throws Exception on failure
*/
void calibrate();

/**
* @brief Saves the calibration results
* @throws Exception on failure
*/
void saveResults(const std::string& file);

private:
void onLoadConfig();
void onLoadObservations();
void onCalibrate();
void onSaveResults();

void loadTargetFinder();
void drawImage(QTreeWidgetItem* item, int col);
void saveResults();

Ui::CameraIntrinsicCalibration* ui_;
TargetFinderWidget* target_finder_widget_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,38 @@ class ExtrinsicHandEyeCalibrationWidget : public QMainWindow
explicit ExtrinsicHandEyeCalibrationWidget(QWidget* parent = nullptr);
~ExtrinsicHandEyeCalibrationWidget();

/**
* @brief Loads the calibration configuration from file
* @throws Exception on failure
*/
void loadConfig(const std::string& config_file);

/**
* @brief Loads the calibration observations from file
* @throws Exception on failure
*/
void loadObservations(const std::string& observations_file);

private:
void loadConfig();
void loadObservations();
/**
* @brief Performs the calibration
* @throws Exception on failure
*/
void calibrate();

/**
* @brief Saves results of the calibration
* @throws Exception on failure
*/
void saveResults(const std::string& file);

private:
void onLoadConfig();
void onLoadObservations();
void onCalibrate();
void onSaveResults();

void loadTargetFinder();
void drawImage(QTreeWidgetItem* item, int col);
void saveResults();

Ui::ExtrinsicHandEyeCalibration* ui_;
TargetFinderWidget* target_finder_widget_;
Expand Down
62 changes: 57 additions & 5 deletions gui/src/app/camera_intrinsic_calibration_app.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include <industrial_calibration/gui/camera_intrinsic_calibration_widget.h>
#include <QApplication>
#include <QMessageBox>
#include <QTextStream>
#include <signal.h>

void handleSignal(int /*sig*/) { QApplication::instance()->quit(); }
Expand All @@ -15,11 +17,61 @@ int main(int argc, char** argv)
industrial_calibration::CameraIntrinsicCalibrationWidget w;
w.setWindowTitle("Camera Intrinsic Calibration");
w.setWindowIcon(QIcon(":/icons/icon.jpg"));
w.showMaximized();

// Attempt to load configuration and observations files if available
if (argc > 1) w.loadConfig(argv[1]);
if (argc > 2) w.loadObservations(argv[2]);
// Attempt to run headless if the configuration file (argv[1]), observation file (argv[2]), and results file (argv[3])
// are specified
if (argc > 3)
{
try
{
w.loadConfig(argv[1]);
w.loadObservations(argv[2]);
w.calibrate();
w.saveResults(argv[3]);
QMessageBox::StandardButton ret = QMessageBox::question(nullptr, "Calibration",
"Successfully completed calibration and saved results. "
"View results in the GUI?");
if (ret == QMessageBox::StandardButton::Yes)
{
w.showMaximized();
return app.exec();
}
}
catch (const std::exception& ex)
{
QString question;
QTextStream ss(&question);
ss << "Error: " << ex.what() << "\n\nOpen GUI to fix?";

return app.exec();
QMessageBox::StandardButton ret = QMessageBox::question(nullptr, "Error", question);
if (ret == QMessageBox::StandardButton::Yes)
{
w.showMaximized();
return app.exec();
}
}
}
else
{
w.showMaximized();

// Attempt to load configuration and observations files if available
try
{
if (argc > 1)
{
w.loadConfig(argv[1]);
QMessageBox::information(nullptr, "Configuration", "Successfully loaded calibration configuration");
}
if (argc > 2) w.loadObservations(argv[2]);
}
catch (const std::exception& ex)
{
QMessageBox::warning(nullptr, "Error", ex.what());
}

return app.exec();
}

return 0;
}
62 changes: 57 additions & 5 deletions gui/src/app/extrinsic_hand_eye_calibration_app.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include <industrial_calibration/gui/extrinsic_hand_eye_calibration_widget.h>
#include <QApplication>
#include <QMessageBox>
#include <QTextStream>
#include <signal.h>

void handleSignal(int /*sig*/) { QApplication::instance()->quit(); }
Expand All @@ -15,11 +17,61 @@ int main(int argc, char** argv)
industrial_calibration::ExtrinsicHandEyeCalibrationWidget w;
w.setWindowTitle("Extrinsic Hand Eye Calibration");
w.setWindowIcon(QIcon(":/icons/icon.jpg"));
w.showMaximized();

// Attempt to load configuration and observations files, if available
if (argc > 1) w.loadConfig(argv[1]);
if (argc > 2) w.loadObservations(argv[2]);
// Attempt to run headless if the configuration file (argv[1]), observation file (argv[2]), and results file (argv[3])
// are specified
if (argc > 3)
{
try
{
w.loadConfig(argv[1]);
w.loadObservations(argv[2]);
w.calibrate();
w.saveResults(argv[3]);
QMessageBox::StandardButton ret = QMessageBox::question(nullptr, "Calibration",
"Successfully completed calibration and saved results. "
"View results in the GUI?");
if (ret == QMessageBox::StandardButton::Yes)
{
w.showMaximized();
return app.exec();
}
}
catch (const std::exception& ex)
{
QString question;
QTextStream ss(&question);
ss << "Error: " << ex.what() << "\n\nOpen GUI to fix?";

return app.exec();
QMessageBox::StandardButton ret = QMessageBox::question(nullptr, "Error", question);
if (ret == QMessageBox::StandardButton::Yes)
{
w.show();
return app.exec();
}
}
}
else
{
w.showMaximized();

// Attempt to load configuration and observations files if available
try
{
if (argc > 1)
{
w.loadConfig(argv[1]);
QMessageBox::information(nullptr, "Configuration", "Successfully loaded calibration configuration");
}
if (argc > 2) w.loadObservations(argv[2]);
}
catch (const std::exception& ex)
{
QMessageBox::warning(nullptr, "Error", ex.what());
}

return app.exec();
}

return 0;
}
Loading