Demonstration of the wireframe simulator.
#include <stdlib.h>
#include <visp3/core/vpCameraParameters.h>
#include <visp3/core/vpConfig.h>
#include <visp3/core/vpHomogeneousMatrix.h>
#include <visp3/core/vpImage.h>
#include <visp3/core/vpIoTools.h>
#include <visp3/core/vpMath.h>
#include <visp3/gui/vpDisplayD3D.h>
#include <visp3/gui/vpDisplayGDI.h>
#include <visp3/gui/vpDisplayGTK.h>
#include <visp3/gui/vpDisplayOpenCV.h>
#include <visp3/gui/vpDisplayX.h>
#include <visp3/io/vpImageIo.h>
#include <visp3/io/vpParseArgv.h>
#include <visp3/robot/vpWireFrameSimulator.h>
#define GETOPTARGS "cdh"
#ifdef VISP_HAVE_DISPLAY
#ifdef ENABLE_VISP_NAMESPACE
#endif
void usage(const char *name, const char *badparam);
bool getOptions(int argc, const char **argv, bool &display, bool &click);
void usage(const char *name, const char *badparam)
{
fprintf(stdout, "\n\
Demonstration of the wireframe simulator.\n\
\n\
The goal of this example is to present the basic functionalities of the wire frame simulator.\n\
\n\
SYNOPSIS\n\
%s [-c] [-d] [-h]\n",
name);
fprintf(stdout, "\n\
OPTIONS: Default\n\
-c \n\
Disable mouse click.\n\
\n\
-d \n\
Turn off the display.\n\
\n\
-h\n\
Print the help.\n");
if (badparam)
fprintf(stdout, "\nERROR: Bad parameter [%s]\n", badparam);
}
bool getOptions(int argc, const char **argv, bool &display, bool &click)
{
const char *optarg_;
int c;
switch (c) {
case 'c':
click = false;
break;
case 'd':
display = false;
break;
case 'h':
usage(argv[0], nullptr);
return false;
break;
default:
usage(argv[0], optarg_);
return false;
break;
}
}
if ((c == 1) || (c == -1)) {
usage(argv[0], nullptr);
std::cerr << "ERROR: " << std::endl;
std::cerr << " Bad argument " << optarg_ << std::endl << std::endl;
return false;
}
return true;
}
int main(int argc, const char **argv)
{
try {
bool opt_display = true;
bool opt_click = true;
if (getOptions(argc, argv, opt_display, opt_click) == false) {
return EXIT_FAILURE;
}
#if defined(VISP_HAVE_X11)
vpDisplayX display[3];
#elif defined(HAVE_OPENCV_HIGHGUI)
#elif defined(VISP_HAVE_GDI)
#elif defined(VISP_HAVE_D3D9)
#elif defined(VISP_HAVE_GTK)
#endif
if (opt_display) {
display[0].init(Iint, 100, 100, "The internal view");
display[1].init(Iext1, 100, 100, "The first external view");
display[2].init(Iext2, 100, 100, "The second external view");
}
if (opt_display) {
}
std::cout << std::endl;
std::cout << "Here are presented the effect of the basic functions of "
"the simulator"
<< std::endl;
std::cout << std::endl;
if (opt_display) {
if (opt_click) {
std::cout << "Click on the internal view window to continue. the "
"object will move. The external cameras are fixed. The "
"main camera moves too because the homogeneous matrix "
"cMo didn't change."
<< std::endl;
}
}
if (opt_display) {
}
std::cout << std::endl;
if (opt_display) {
if (opt_click) {
std::cout << "Click on the internal view window to continue" << std::endl;
}
}
std::cout << std::endl;
std::cout << "Now you can move the main external camera. Click inside "
"the corresponding window with one of the three buttons of "
"your mouse and move the pointer."
<< std::endl;
std::cout << std::endl;
std::cout << "Click on the internal view window when you are finished" << std::endl;
if (opt_display && opt_click) {
}
}
std::cout << std::endl;
std::cout << "You have seen the main capabilities of the simulator. "
"Other specific functionalities are available. Please "
"refers to the html documentation to access the list of all "
"functions"
<< std::endl;
return EXIT_SUCCESS;
}
std::cout << "Catch an exception: " << e << std::endl;
return EXIT_SUCCESS;
}
}
#else
int main()
{
std::cout << "You do not have X11, or GDI (Graphical Device Interface), or GTK functionalities to display images..."
<< std::endl;
std::cout << "Tip if you are on a unix-like system:" << std::endl;
std::cout << "- Install X11, configure again ViSP using cmake and build again this example" << std::endl;
std::cout << "Tip if you are on a windows-like system:" << std::endl;
std::cout << "- Install GDI, configure again ViSP using cmake and build again this example" << std::endl;
return EXIT_SUCCESS;
}
#endif
Generic class defining intrinsic camera parameters.
static const vpColor blue
static const vpColor green
Display for windows using Direct3D 3rd party. Thus to enable this class Direct3D should be installed....
Display for windows using GDI (available on any windows 32 platform).
The vpDisplayGTK allows to display image using the GTK 3rd party library. Thus to enable this class G...
The vpDisplayOpenCV allows to display image using the OpenCV library. Thus to enable this class OpenC...
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
static void display(const vpImage< unsigned char > &I)
static void flush(const vpImage< unsigned char > &I)
static void setWindowPosition(const vpImage< unsigned char > &I, int winx, int winy)
error that can be emitted by ViSP classes.
Implementation of an homogeneous matrix and operations on such kind of matrices.
static double rad(double deg)
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)
Implementation of a wire frame simulator. Compared to the vpSimulator class, it does not require thir...
void setCameraPositionRelObj(const vpHomogeneousMatrix &cMo_)
void getInternalImage(vpImage< unsigned char > &I)
void initScene(const vpSceneObject &obj, const vpSceneDesiredObject &desiredObject)
void setCurrentViewColor(const vpColor &col)
void setCameraColor(const vpColor &col)
void setDesiredViewColor(const vpColor &col)
void setExternalCameraPosition(const vpHomogeneousMatrix &cam_Mf)
void set_fMo(const vpHomogeneousMatrix &fMo_)
void setDesiredCameraPosition(const vpHomogeneousMatrix &cdMo_)
void setInternalCameraParameters(const vpCameraParameters &cam)
void setExternalCameraParameters(const vpCameraParameters &cam)
void getExternalImage(vpImage< unsigned char > &I)