55 #include <visp/vpDebug.h>
57 #include <visp/vpBSpline.h>
59 #include <visp/vpImage.h>
60 #include <visp/vpImageIo.h>
61 #include <visp/vpImagePoint.h>
62 #include <visp/vpDisplayGTK.h>
63 #include <visp/vpDisplayGDI.h>
64 #include <visp/vpDisplayOpenCV.h>
65 #include <visp/vpDisplayD3D.h>
66 #include <visp/vpDisplayX.h>
68 #include <visp/vpParseArgv.h>
69 #include <visp/vpIoTools.h>
73 #if defined(VISP_HAVE_X11) || defined(VISP_HAVE_GTK) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_OPENCV) || defined(VISP_HAVE_D3D9)
76 #define GETOPTARGS "cdh"
86 void usage(
const char *name,
const char *badparam)
89 Describe a curve thanks to a BSpline.\n\
92 %s [-c] [-d] [-h]\n", name);
97 Disable the mouse click. Useful to automaze the \n\
98 execution of this program without humain intervention.\n\
101 Turn off the display.\n\
107 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
123 bool getOptions(
int argc,
const char **argv,
bool &click_allowed,
bool &display)
130 case 'c': click_allowed =
false;
break;
131 case 'd': display =
false;
break;
132 case 'h': usage(argv[0], NULL);
return false;
break;
135 usage(argv[0], optarg);
140 if ((c == 1) || (c == -1)) {
142 usage(argv[0], NULL);
143 std::cerr <<
"ERROR: " << std::endl;
144 std::cerr <<
" Bad argument " << optarg << std::endl << std::endl;
153 main(
int argc,
const char ** argv)
155 bool opt_click_allowed =
true;
156 bool opt_display =
true;
159 if (getOptions(argc, argv, opt_click_allowed,
160 opt_display) ==
false) {
170 #if defined VISP_HAVE_X11
172 #elif defined VISP_HAVE_GTK
174 #elif defined VISP_HAVE_GDI
176 #elif defined VISP_HAVE_OPENCV
178 #elif defined VISP_HAVE_D3D9
185 display.
init(I, 100, 100,
"Display image") ;
197 std::list<double> knots;
210 std::list<vpImagePoint> controlPoints;
213 controlPoints.push_back(pt);
215 controlPoints.push_back(pt);
217 controlPoints.push_back(pt);
219 controlPoints.push_back(pt);
221 controlPoints.push_back(pt);
223 controlPoints.push_back(pt);
225 controlPoints.push_back(pt);
227 controlPoints.push_back(pt);
233 std::cout <<
"The parameters are :" <<std::endl;
234 std::cout <<
"p : " << bSpline.
get_p() <<std::endl;
235 std::cout <<
"" <<std::endl;
236 std::cout <<
"The knot vector :" <<std::endl;
237 std::list<double> knots_cur;
239 unsigned int i_display=0;
240 for(std::list<double>::const_iterator it=knots_cur.begin(); it!=knots_cur.end(); ++it, ++i_display){
241 std::cout << i_display <<
" ---> " << *it << std::endl;
243 std::cout <<
"The control points are :" <<std::endl;
244 std::list<vpImagePoint> controlPoints_cur;
247 for(std::list<vpImagePoint>::const_iterator it=controlPoints_cur.begin(); it!=controlPoints_cur.end(); ++it, ++i_display){
248 std::cout << i_display <<
" ---> " << *it << std::endl;
251 unsigned int i = bSpline.
findSpan(5/2.0);
252 std::cout <<
"The knot interval number for the value u = 5/2 is : " << i <<std::endl;
254 vpBasisFunction *N = NULL;
256 std::cout <<
"The nonvanishing basis functions N(u=5/2) are :" << std::endl;
257 for (
unsigned int j = 0; j < bSpline.
get_p()+1; j++)
258 std::cout << N[j].value << std::endl;
260 vpBasisFunction **N2 = NULL;
262 std::cout <<
"The first derivatives of the basis functions N'(u=5/2) are :" << std::endl;
263 for (
unsigned int j = 0; j < bSpline.
get_p()+1; j++)
264 std::cout << N2[1][j].value << std::endl;
266 std::cout <<
"The second 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[2][j].value << std::endl;
270 if (opt_display && opt_click_allowed)
280 for(std::list<vpImagePoint>::const_iterator it=controlPoints.begin(); it!= controlPoints.end(); ++it){
287 if (N != NULL)
delete[] N;
290 for (
unsigned int j = 0; j <= 2; j++)
301 std::cout <<
"This example requires a video device. "
303 <<
"You should install X11, GTK, OpenCV, GDI or Direct3D"
305 <<
"to be able to execute this example."