 #include <cuda_runtime.h>
 
 #include "frame.h"
+#include "clamp.h"
+#include "geom_matrix.h"
 
 using namespace std;
 
 namespace popart {
 
 namespace identification {
-
-struct matrix3x3
-{
-    float val[3][3];
-
-    __host__ __device__
-    matrix3x3( ) { }
-
-    __host__ __device__
-    matrix3x3( const float mx[3][3] ) {
-        #pragma unroll
-        for( int i=0; i<3; i++ ) {
-            #pragma unroll
-            for( int j=0; j<3; j++ ) {
-                val[i][j] = mx[i][j];
-            }
-        }
-    }
-
-    __host__ __device__
-    inline float& operator()(int y, int x) {
-        return val[y][x];
-    }
-
-    __host__ __device__
-    inline const float& operator()(int y, int x) const {
-        return val[y][x];
-    }
-};
 
 struct CutStruct
 {

        }

        // Bilinear interpolation
        cut_signals[i] = popart::identification::getPixelBilinear( src, xRes, yRes );

        x += stepX;
        y += stepY;
    }
}

__global__
void idGetSignals( matrix3x3 mHomography, matrix3x3 mInvHomography, cv::cuda::PtrStepSzb src, float* d, const int vCutsSize, const int vCutMaxVecLen )
{
    int myCut = blockIdx.x * 32 + threadIdx.y;


    readable  = true;

    // Get the rectified signals along the image cuts
    popart::geometry::matrix3x3 mHomography( hom );
    popart::geometry::matrix3x3 mInvHomography;
    mHomography.invert( mInvHomography );

    dim3 block;
    dim3 grid;
