diff --git a/src/Utils/ofxHomographyHelper/ofxHomographyHelper.cpp b/src/Utils/ofxHomographyHelper/ofxHomographyHelper.cpp new file mode 100644 index 0000000..7a92707 --- /dev/null +++ b/src/Utils/ofxHomographyHelper/ofxHomographyHelper.cpp @@ -0,0 +1,174 @@ +/* + * ofxHomographyHelper.cpp + * Created by Elliot Woods on 26/11/2010. + * + * Based entirely on arturo castro's homography implementation + * Created 08/01/2010, arturo castro + * + * http://www.openframeworks.cc/forum/viewtopic.php?f=9&t=3121 + */ + +#include "ofxHomographyHelper.h" + +void ofxHomographyHelper::gaussian_elimination(float *input, int n) +{ + // ported to c from pseudocode in + // http://en.wikipedia.org/wiki/Gaussian_elimination + + float * A = input; + int i = 0; + int j = 0; + int m = n-1; + while (i < m && j < n){ + // Find pivot in column j, starting in row i: + int maxi = i; + for(int k = i+1; k fabs(A[maxi*n+j])){ + maxi = k; + } + } + if (A[maxi*n+j] != 0){ + //swap rows i and maxi, but do not change the value of i + if(i!=maxi) + for(int k=0;k=0;i--){ + for(int j=i+1;j