50 #include <visp3/core/vpDebug.h>
52 #include <visp3/core/vpBSpline.h>
54 #include <visp3/core/vpDisplay.h>
55 #include <visp3/core/vpImage.h>
56 #include <visp3/core/vpImagePoint.h>
57 #include <visp3/io/vpImageIo.h>
58 #ifdef VISP_HAVE_MODULE_GUI
59 #include <visp3/gui/vpDisplayD3D.h>
60 #include <visp3/gui/vpDisplayGDI.h>
61 #include <visp3/gui/vpDisplayGTK.h>
62 #include <visp3/gui/vpDisplayOpenCV.h>
63 #include <visp3/gui/vpDisplayX.h>
68 #include <visp3/core/vpIoTools.h>
69 #include <visp3/io/vpParseArgv.h>
71 #if defined(VISP_HAVE_X11) || defined(VISP_HAVE_GTK) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_OPENCV) || \
72 defined(VISP_HAVE_D3D9)
75 #define GETOPTARGS "cdh"
77 void usage(
const char *name,
const char *badparam);
78 bool getOptions(
int argc,
const char **argv,
bool &click_allowed,
bool &display);
88 void usage(
const char *name,
const char *badparam)
91 Describe a curve thanks to a BSpline.\n\
94 %s [-c] [-d] [-h]\n", name);
99 Disable the mouse click. Useful to automaze the \n\
100 execution of this program without humain intervention.\n\
103 Turn off the display.\n\
109 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
124 bool getOptions(
int argc,
const char **argv,
bool &click_allowed,
bool &display)
132 click_allowed =
false;
138 usage(argv[0], NULL);
143 usage(argv[0], optarg_);
149 if ((c == 1) || (c == -1)) {
151 usage(argv[0], NULL);
152 std::cerr <<
"ERROR: " << std::endl;
153 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
160 int main(
int argc,
const char **argv)
163 bool opt_click_allowed =
true;
164 bool opt_display =
true;
167 if (getOptions(argc, argv, opt_click_allowed, opt_display) ==
false) {
178 #ifdef VISP_HAVE_MODULE_GUI
179 #if defined VISP_HAVE_X11
181 #elif defined VISP_HAVE_GTK
183 #elif defined VISP_HAVE_GDI
185 #elif defined VISP_HAVE_OPENCV
187 #elif defined VISP_HAVE_D3D9
193 display.init(I, 100, 100,
"Display image");
200 std::list<double> knots;
213 std::list<vpImagePoint> controlPoints;
216 controlPoints.push_back(pt);
218 controlPoints.push_back(pt);
220 controlPoints.push_back(pt);
222 controlPoints.push_back(pt);
224 controlPoints.push_back(pt);
226 controlPoints.push_back(pt);
228 controlPoints.push_back(pt);
230 controlPoints.push_back(pt);
236 std::cout <<
"The parameters are :" << std::endl;
237 std::cout <<
"p : " << bSpline.
get_p() << std::endl;
238 std::cout <<
"" << std::endl;
239 std::cout <<
"The knot vector :" << std::endl;
240 std::list<double> knots_cur;
242 unsigned int i_display = 0;
243 for (std::list<double>::const_iterator it = knots_cur.begin(); it != knots_cur.end(); ++it, ++i_display) {
244 std::cout << i_display <<
" ---> " << *it << std::endl;
246 std::cout <<
"The control points are :" << std::endl;
247 std::list<vpImagePoint> controlPoints_cur;
250 for (std::list<vpImagePoint>::const_iterator it = controlPoints_cur.begin(); it != controlPoints_cur.end();
252 std::cout << i_display <<
" ---> " << *it << std::endl;
255 unsigned int i = bSpline.
findSpan(5 / 2.0);
256 std::cout <<
"The knot interval number for the value u = 5/2 is : " << i << std::endl;
258 vpBasisFunction *N = NULL;
260 std::cout <<
"The nonvanishing basis functions N(u=5/2) are :" << std::endl;
261 for (
unsigned int j = 0; j < bSpline.
get_p() + 1; j++)
262 std::cout << N[j].value << std::endl;
264 vpBasisFunction **N2 = NULL;
266 std::cout <<
"The first derivatives of the basis functions N'(u=5/2) are :" << std::endl;
267 for (
unsigned int j = 0; j < bSpline.
get_p() + 1; j++)
268 std::cout << N2[1][j].value << std::endl;
270 std::cout <<
"The second derivatives of the basis functions N''(u=5/2) are :" << std::endl;
271 for (
unsigned int j = 0; j < bSpline.
get_p() + 1; j++)
272 std::cout << N2[2][j].value << std::endl;
274 if (opt_display && opt_click_allowed) {
281 for (std::list<vpImagePoint>::const_iterator it = controlPoints.begin(); it != controlPoints.end(); ++it) {
291 for (
unsigned int j = 0; j <= 2; j++)
298 std::cout <<
"Catch an exception: " << e << std::endl;
306 std::cout <<
"You do not have X11, GTK, or OpenCV, or GDI (Graphical Device Interface) functionalities to display images..." << std::endl;
307 std::cout <<
"Tip if you are on a unix-like system:" << std::endl;
308 std::cout <<
"- Install X11, configure again ViSP using cmake and build again this example" << std::endl;
309 std::cout <<
"Tip if you are on a windows-like system:" << std::endl;
310 std::cout <<
"- Install GDI, configure again ViSP using cmake and build again this example" << std::endl;