#include <cstdlib>
#include <visp3/core/vpConfig.h>
#include <visp3/core/vpIoTools.h>
#include <visp3/gui/vpDisplayGDI.h>
#include <visp3/gui/vpDisplayOpenCV.h>
#include <visp3/gui/vpDisplayX.h>
#include <visp3/io/vpImageIo.h>
#include <visp3/mbt/vpMbGenericTracker.h>
#include <visp3/io/vpVideoReader.h>
int main(int argc, char **argv)
{
#if defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020300)
try {
std::string opt_videoname_left = "teabox_left.mp4";
std::string opt_videoname_right = "teabox_right.mp4";
for (int i = 0; i < argc; i++) {
if (std::string(argv[i]) == "--name" && i + 2 < argc) {
opt_videoname_left = std::string(argv[i + 1]);
opt_videoname_right = std::string(argv[i + 2]);
} else if (std::string(argv[i]) == "--tracker" && i + 2 < argc) {
opt_tracker1 = atoi(argv[i + 1]);
opt_tracker2 = atoi(argv[i + 2]);
} else if (std::string(argv[i]) == "--help") {
std::cout << "\nUsage: " << argv[0]
<< " [--name <video name left> <video name right>]"
" [--tracker <1=egde|2=klt|3=hybrid> <1=egde|2=klt|3=hybrid>]"
" [--help]\n"
<< std::endl;
return EXIT_SUCCESS;
}
}
if ((opt_tracker1 < 1 || opt_tracker1 > 3) && (opt_tracker2 < 1 || opt_tracker2 > 3)) {
std::cerr << "Wrong tracker type. Correct values are: "
"1=egde|2=keypoint|3=hybrid."
<< std::endl;
return EXIT_SUCCESS;
}
if (!parentname.empty()) {
objectname_left = parentname + "/" + objectname_left;
}
std::cout << "Video name: " << opt_videoname_left << " ; " << opt_videoname_right << std::endl;
std::cout << "Tracker requested config files: " << objectname_left << ".[init, cao]"
<< " and " << objectname_right << ".[init, cao]" << std::endl;
std::cout << "Tracker optional config files: " << opt_videoname_left << ".ppm"
<< " and " << opt_videoname_right << ".ppm" << std::endl;
#if defined(VISP_HAVE_X11)
#elif defined(VISP_HAVE_GDI)
#else
#endif
display_left.
init(I_left, 100, 100,
"Model-based tracker (Left)");
display_right.
init(I_right, 110 + (
int)I_left.
getWidth(), 100,
"Model-based tracker (Right)");
std::vector<int> trackerTypes(2);
trackerTypes[0] = opt_tracker1;
trackerTypes[1] = opt_tracker2;
#if !defined(VISP_HAVE_MODULE_KLT)
if (opt_tracker >= 2) {
std::cout << "klt and hybrid model-based tracker are not available "
"since visp_klt module is missing"
<< std::endl;
return EXIT_SUCCESS;
}
#endif
tracker.
loadConfigFile(objectname_left +
".xml", objectname_right +
".xml");
tracker.
loadModel(objectname_left +
".cao", objectname_right +
".cao");
std::ifstream file_cRightMcLeft("cRightMcLeft.txt");
cRightMcLeft.
load(file_cRightMcLeft);
std::map<std::string, vpHomogeneousMatrix> mapOfCameraTransformationMatrix;
mapOfCameraTransformationMatrix["Camera2"] = cRightMcLeft;
tracker.
initClick(I_left, I_right, objectname_left +
".init", objectname_right +
".init",
true);
while (!g_left.
end() && !g_right.
end()) {
tracker.
track(I_left, I_right);
tracker.
getPose(cLeftMo, cRightMo);
break;
}
}
std::cerr <<
"Catch a ViSP exception: " << e.
what() << std::endl;
}
#else
(void)argc;
(void)argv;
std::cout << "Install OpenCV and rebuild ViSP to use this example." << std::endl;
#endif
}