Bad computer! BAD OpenCV!! I know exactly what math needs to be done, and I don't know if you noticed, but your documentation for that particular function strongly suggests it does some least squares optimization thing.
|Objective: solve for the matrix that lets you transform original grumpy cat image to aligned grumpy cat image.|
|Now that's what I'm talkin' about! And I even got to put the eyebrow markers by her little cat eyebrows.|
So, I finally rewrote the damn alignment code: https://gist.github.com/ktuite/7225703
The secret objective of this post is actually to profess my love for C/C++ libraries like GSL (the GNU Scientific Library). (I also like the Approximate Nearest Neighbor Library ANN.) It's kind of hard to learn, with matrix multiplies looking kinda like this: gsl_blas_dgemm(CblasNoTrans, CblasTrans, 1.0, m_gsl_dst, m_gsl_src, 0.0, A); but it's sooooo reliable! And fast! And educational! OpenCV constantly disappoints me, but these other libraries feel like wielding sharp swords forged by the elders.
I basically learned linear algebra from trying to decode and use that part of GSL. If you look at my alignment code, you'll see my (wo-)man-handling of matrices to get my answer. I think there's another way to do it with a least-squares solver, but that's something I still need to look into/teach myself/get my hands dirty with.