SLAMflex SE  0.1.0
SLAMflex provides detection and tracking of dominant planes for smartphone devices. This plane can then be used to show AR content relative to the plane orientation. The detection of plane is performed in the field of view of the smartphone camera. In subsequent frames it is tracked. The interface returns the plane position and orientation.
ShiTomasi.cpp
Go to the documentation of this file.
1 // Copyright 2008 Isis Innovation Limited
2 #include "ShiTomasi.h"
3 #include <math.h>
4 
5 using namespace CVD;
6 
8  int nHalfBoxSize,
9  ImageRef irCenter)
10 {
11  double dXX = 0;
12  double dYY = 0;
13  double dXY = 0;
14 
15  ImageRef irStart = irCenter - ImageRef(nHalfBoxSize, nHalfBoxSize);
16  ImageRef irEnd = irCenter + ImageRef(nHalfBoxSize, nHalfBoxSize);
17 
18  ImageRef ir;
19  for(ir.y = irStart.y; ir.y<=irEnd.y; ir.y++)
20  for(ir.x = irStart.x; ir.x<=irEnd.x; ir.x++)
21  {
22  double dx = image[ir + ImageRef(1,0)] - image[ir - ImageRef(1,0)];
23  double dy = image[ir + ImageRef(0,1)] - image[ir - ImageRef(0,1)];
24  dXX += dx*dx;
25  dYY += dy*dy;
26  dXY += dx*dy;
27  }
28 
29  int nPixels = (irEnd - irStart + ImageRef(1,1)).area();
30  dXX = dXX / (2.0 * nPixels);
31  dYY = dYY / (2.0 * nPixels);
32  dXY = dXY / (2.0 * nPixels);
33 
34  // Find and return smaller eigenvalue:
35  return 0.5 * (dXX + dYY - sqrt( (dXX + dYY) * (dXX + dYY) - 4 * (dXX * dYY - dXY * dXY) ));
36 };
37 
int y
The y co-ordinate.
Definition: image_ref.h:180
int x
The x co-ordinate.
Definition: image_ref.h:179
double FindShiTomasiScoreAtPoint(BasicImage< byte > &image, int nHalfBoxSize, ImageRef irCenter)
Definition: ShiTomasi.cpp:7
Definition: abs.h:24
ImageRef ir(const TooN::Vector< 2 > &v)