51 #include <visp3/core/vpDebug.h> 53 #include <visp3/core/vpBSpline.h> 55 #include <visp3/core/vpImage.h> 56 #include <visp3/io/vpImageIo.h> 57 #include <visp3/core/vpImagePoint.h> 58 #include <visp3/core/vpDisplay.h> 59 #ifdef VISP_HAVE_MODULE_GUI 60 # include <visp3/gui/vpDisplayGTK.h> 61 # include <visp3/gui/vpDisplayGDI.h> 62 # include <visp3/gui/vpDisplayOpenCV.h> 63 # include <visp3/gui/vpDisplayD3D.h> 64 # include <visp3/gui/vpDisplayX.h> 67 #include <visp3/io/vpParseArgv.h> 68 #include <visp3/core/vpIoTools.h> 72 #if defined(VISP_HAVE_X11) || defined(VISP_HAVE_GTK) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_OPENCV) || 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);
125 bool getOptions(
int argc,
const char **argv,
bool &click_allowed,
bool &display)
132 case 'c': click_allowed =
false;
break;
133 case 'd': display =
false;
break;
134 case 'h': usage(argv[0], NULL);
return false;
break;
137 usage(argv[0], optarg_);
142 if ((c == 1) || (c == -1)) {
144 usage(argv[0], NULL);
145 std::cerr <<
"ERROR: " << std::endl;
146 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
155 main(
int argc,
const char ** argv)
158 bool opt_click_allowed =
true;
159 bool opt_display =
true;
162 if (getOptions(argc, argv, opt_click_allowed,
163 opt_display) ==
false) {
174 #ifdef VISP_HAVE_MODULE_GUI 175 #if defined VISP_HAVE_X11 177 #elif defined VISP_HAVE_GTK 179 #elif defined VISP_HAVE_GDI 181 #elif defined VISP_HAVE_OPENCV 183 #elif defined VISP_HAVE_D3D9 189 display.
init(I, 100, 100,
"Display image") ;
196 std::list<double> knots;
209 std::list<vpImagePoint> controlPoints;
212 controlPoints.push_back(pt);
214 controlPoints.push_back(pt);
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);
232 std::cout <<
"The parameters are :" <<std::endl;
233 std::cout <<
"p : " << bSpline.
get_p() <<std::endl;
234 std::cout <<
"" <<std::endl;
235 std::cout <<
"The knot vector :" <<std::endl;
236 std::list<double> knots_cur;
238 unsigned int i_display=0;
239 for(std::list<double>::const_iterator it=knots_cur.begin(); it!=knots_cur.end(); ++it, ++i_display){
240 std::cout << i_display <<
" ---> " << *it << std::endl;
242 std::cout <<
"The control points are :" <<std::endl;
243 std::list<vpImagePoint> controlPoints_cur;
246 for(std::list<vpImagePoint>::const_iterator it=controlPoints_cur.begin(); it!=controlPoints_cur.end(); ++it, ++i_display){
247 std::cout << i_display <<
" ---> " << *it << std::endl;
250 unsigned int i = bSpline.
findSpan(5/2.0);
251 std::cout <<
"The knot interval number for the value u = 5/2 is : " << i <<std::endl;
253 vpBasisFunction *N = NULL;
255 std::cout <<
"The nonvanishing basis functions N(u=5/2) are :" << std::endl;
256 for (
unsigned int j = 0; j < bSpline.
get_p()+1; j++)
257 std::cout << N[j].value << std::endl;
259 vpBasisFunction **N2 = NULL;
261 std::cout <<
"The first derivatives of the basis functions N'(u=5/2) are :" << std::endl;
262 for (
unsigned int j = 0; j < bSpline.
get_p()+1; j++)
263 std::cout << N2[1][j].value << std::endl;
265 std::cout <<
"The second derivatives of the basis functions N''(u=5/2) are :" << std::endl;
266 for (
unsigned int j = 0; j < bSpline.
get_p()+1; j++)
267 std::cout << N2[2][j].value << std::endl;
269 if (opt_display && opt_click_allowed)
278 for(std::list<vpImagePoint>::const_iterator it=controlPoints.begin(); it!= controlPoints.end(); ++it){
285 if (N != NULL)
delete[] N;
288 for (
unsigned int j = 0; j <= 2; j++)
296 std::cout <<
"Catch an exception: " << e << std::endl;
304 std::cout <<
"This example requires a video device. " 306 <<
"You should install X11, GTK, OpenCV, GDI or Direct3D" 308 <<
"to be able to execute this example." static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
Display for windows using GDI (available on any windows 32 platform).
Use the X11 console to display images on unix-like OS. Thus to enable this class X11 should be instal...
error that can be emited by ViSP classes.
static const vpColor green
static void flush(const vpImage< unsigned char > &I)
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)
unsigned int get_p() const
static vpBasisFunction ** computeDersBasisFuns(double l_u, unsigned int l_i, unsigned int l_p, unsigned int l_der, std::vector< double > &l_knots)
static unsigned int findSpan(double l_u, unsigned int l_p, std::vector< double > &l_knots)
void get_controlPoints(std::list< vpImagePoint > &list) const
Display for windows using Direct3D 3rd party. Thus to enable this class Direct3D should be installed...
static void display(const vpImage< unsigned char > &I)
static vpBasisFunction * computeBasisFuns(double l_u, unsigned int l_i, unsigned int l_p, std::vector< double > &l_knots)
The vpDisplayOpenCV allows to display image using the OpenCV library. Thus to enable this class OpenC...
void set_p(unsigned int degree)
The vpDisplayGTK allows to display image using the GTK 3rd party library. Thus to enable this class G...
void set_controlPoints(const std::list< vpImagePoint > &list)
static void displayCross(const vpImage< unsigned char > &I, const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness=1)
Class that provides tools to compute and manipulate a B-Spline curve.
void init(vpImage< unsigned char > &I, int winx=-1, int winy=-1, const std::string &title="")
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
void set_knots(const std::list< double > &list)
void get_knots(std::list< double > &list) const
void set_ij(const double ii, const double jj)
static vpImagePoint computeCurvePoint(double l_u, unsigned int l_i, unsigned int l_p, std::vector< double > &l_knots, std::vector< vpImagePoint > &l_controlPoints)