1. download from http://www.ics.forth.gr/~lourakis/levmar/
At the time that I am writing this blog, current version is levmar-2.4 and ubuntu 9.04.
2.
NOTE :
- you have to install "liblapack-dev" to prevent
Just add "-u MAIN__" to Makefile. So change from
3. Test by compile demo
NOTE :
dlevmar_dif(costFunc, p0, x0, mlevmar, nlevmar, 1000, opts, info, NULL, NULL, NULL); // no Jacobian
void costFunc(double *p, double *tran_x, int m, int n, void *data);
what levmar did is change p, we have change tran_x.
levmar will compare tran_x to x0 then change p again to optimize p0. ( by minimize sum(tran_xi-x0i)^2 )
Therefore, you can put any order of params into p0, x0. For example, you can put x0 = [x; x'] or x0 = [x'; x] or whatever.
At the time that I am writing this blog, current version is levmar-2.4 and ubuntu 9.04.
2.
$ make
NOTE :
- you have to install "liblapack-dev" to prevent
/usr/bin/ld: cannot find -llapack- install "libf2c2-dev" to prevent
/usr/bin/ld: cannot find -lf2cbut you also have a problem with f2c anyway
/usr/lib/gcc/i486-linux-gnu/4.3.3/../../../../lib/libf2c.so: undefined reference to `MAIN__'following suggestion here.
Just add "-u MAIN__" to Makefile. So change from
lmdemo: $(DEMOBJS) liblevmar.ato
$(CC) $(LDFLAGS) $(DEMOBJS) -o lmdemo -llevmar $(LIBS) -lm
lmdemo: $(DEMOBJS) liblevmar.a
$(CC) $(LDFLAGS) $(DEMOBJS) -o lmdemo -llevmar $(LIBS) -lm -u MAIN__
3. Test by compile demo
$ gcc lmdemo.c -o lmdemo1 -L/mnt/disk/AIT/OpenCV/levmar-2 -lm -llapack -llevmar
NOTE :
dlevmar_dif(costFunc, p0, x0, mlevmar, nlevmar, 1000, opts, info, NULL, NULL, NULL); // no Jacobian
void costFunc(double *p, double *tran_x, int m, int n, void *data);
what levmar did is change p, we have change tran_x.
levmar will compare tran_x to x0 then change p again to optimize p0. ( by minimize sum(tran_xi-x0i)^2 )
Therefore, you can put any order of params into p0, x0. For example, you can put x0 = [x; x'] or x0 = [x'; x] or whatever.
ความคิดเห็น