Skip to content

Commit

Permalink
Merge remote-tracking branch 'pr-florent/master' into add_apps
Browse files Browse the repository at this point in the history
  • Loading branch information
fspindle committed Oct 2, 2023
2 parents a108a15 + 55a9cd7 commit b678d10
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 17 deletions.
12 changes: 12 additions & 0 deletions tutorial/calibration/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@ foreach(cpp ${tutorial_cpp})
endif()
endforeach()

install(PROGRAMS
${CMAKE_CURRENT_BINARY_DIR}/tutorial-chessboard-pose
DESTINATION bin
RENAME compute-chessboard-poses
)

install(PROGRAMS
${CMAKE_CURRENT_BINARY_DIR}/tutorial-hand-eye-calibration
DESTINATION bin
RENAME compute-hand-eye-calibration
)

if(VISP_HAVE_REALSENSE2)
# Add specific build flag to turn off warnings coming from librealsense 3rd party and its dependencies
list(APPEND CXX_FLAGS_MUTE_WARNINGS "/wd4244")
Expand Down
59 changes: 42 additions & 17 deletions tutorial/calibration/tutorial-chessboard-pose.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ void usage(const char **argv, int error)
<< std::endl
<< " Example: \"pose_cPo_%d.yaml\"." << std::endl
<< std::endl
<< " --no_interactive To compute the chessboard poses without interactive validation by the user."
<< std::endl
<< " --help, -h Print this helper message." << std::endl
<< std::endl;
if (error) {
Expand All @@ -91,6 +93,7 @@ int main(int argc, const char **argv)
std::string opt_intrinsic_file = "camera.xml";
std::string opt_camera_name = "Camera";
std::string opt_output_pose_files = "pose_cPo_%d.yaml";
bool interactive = true;

for (int i = 1; i < argc; i++) {
if (std::string(argv[i]) == "-w" && i + 1 < argc) {
Expand Down Expand Up @@ -121,6 +124,9 @@ int main(int argc, const char **argv)
opt_camera_name = std::string(argv[i + 1]);
i++;
}
else if (std::string(argv[i]) == "--no_interactive") {
interactive = false;
}
else if (std::string(argv[i]) == "--help" || std::string(argv[i]) == "-h") {
usage(argv, 0);
return EXIT_SUCCESS;
Expand Down Expand Up @@ -159,12 +165,22 @@ int main(int argc, const char **argv)
reader.open(I);

#ifdef VISP_HAVE_X11
vpDisplayX d(I);
vpDisplayX* d;
#elif defined(VISP_HAVE_GDI)
vpDisplayGDI* d;
#elif defined(HAVE_OPENCV_HIGHGUI)
vpDisplayOpenCV* d=0x0;
#endif

if (interactive) {
#ifdef VISP_HAVE_X11
d = new vpDisplayX(I);
#elif defined(VISP_HAVE_GDI)
vpDisplayGDI d(I);
d = new vpDisplayGDI(I);
#elif defined(HAVE_OPENCV_HIGHGUI)
vpDisplayOpenCV d(I);
d = new vpDisplayOpenCV(I);
#endif
}

std::vector<vpPoint> corners_pts;
calcChessboardCorners(opt_chessboard_width, opt_chessboard_height, opt_chessboard_square_size, corners_pts);
Expand Down Expand Up @@ -239,13 +255,15 @@ int main(int argc, const char **argv)
vpImageConvert::convert(matImg, I);
}

vpDisplay::display(I);
if (interactive) {
vpDisplay::display(I);

vpDisplay::displayText(I, 20, 20, "Left click for the next image, right click to quit.", vpColor::red);
if (found)
vpDisplay::displayFrame(I, cMo, cam, 0.05, vpColor::none, 3);
vpDisplay::displayText(I, 20, 20, "Left click for the next image, right click to quit.", vpColor::red);
if (found)
vpDisplay::displayFrame(I, cMo, cam, 0.05, vpColor::none, 3);

vpDisplay::flush(I);
vpDisplay::flush(I);
}

if (found) {
vpPoseVector pose_vec(cMo);
Expand All @@ -256,18 +274,25 @@ int main(int argc, const char **argv)
pose_vec.saveYAML(s, pose_vec);
}

vpMouseButton::vpMouseButtonType button;
if (vpDisplay::getClick(I, button, true)) {
switch (button) {
case vpMouseButton::button3:
quit = true;
break;

default:
if (interactive) {
vpMouseButton::vpMouseButtonType button;
if (vpDisplay::getClick(I, button, true)) {
switch (button) {
case vpMouseButton::button3:
quit = true;
break;

default:
break;
}
} else {
break;
}
}
} while (!quit && !reader.end());
} while (!quit && !reader.end());
if (interactive){
if (d) delete d;
}
}
catch (const vpException &e) {
std::cout << "Catch an exception: " << e.getMessage() << std::endl;
Expand Down

0 comments on commit b678d10

Please sign in to comment.