77 m_nPixelsSearchDistance = 15;
92 m_pCalibration = pCalibration;
100 printf(
"error: input image must be grayscale image for CRAPiD::Track\n");
107 printf(
"error: calibration does not match image in CRAPiD::Track\n");
113 const unsigned char *pixels = pEdgeImage->
pixels;
114 const int width = pEdgeImage->
width;
115 const int height = pEdgeImage->
height;
117 for (
int i = 0; i < nOutlinePoints; i += 2)
136 const int nControlPoints = int(length_ / m_nPixelsDelta) - 1;
137 if (nControlPoints < 1)
146 Vec2d u_ = { p1_.
x - p2_.
x, p1_.
y - p2_.
y };
150 Vec2d n = { p1_.
y - p2_.
y, p2_.
x - p1_.
x };
156 for (
int j = 0; j < nControlPoints; j++)
174 for (k = 0; k < m_nPixelsSearchDistance; k++)
179 x = int(pn1.
x + 0.5f);
180 y = int(pn1.
y + 0.5f);
181 if (x > 0 && x < width && y > 0 && y < height && pixels[y * width + x])
188 x = int(pn2.
x + 0.5f);
189 y = int(pn2.
y + 0.5f);
190 if (x > 0 && x < width && y > 0 && y < height && pixels[y * width + x])
205 pRAPiDElement->
l = float(l);
218 return RAPiD(rapidList, m_pCalibration, rotation, translation);
225 printf(
"error: not enough input points for RAPiD::RAPiD\n");
239 const int nPoints = elementList.
GetSize();
252 for (i = 0; i < nPoints; i++)
263 const float xc = x + t.
x;
264 const float yc = y + t.
y;
265 const float zc = z + t.
z;
267 const float u0 = fx * xc / zc;
268 const float v0 = fy * yc / zc;
270 const float nx = pElement->
n.
x;
271 const float ny = pElement->
n.
y;
273 const float c1 = (-nx * u0 * y - ny * (fy * z + v0 * y)) / zc;
274 const float c2 = (nx * (fx * z + u0 * x) + ny * v0 * x) / zc;
275 const float c3 = (-nx * fx * y + ny * fy * x) / zc;
276 const float c4 = (nx * fx) / zc;
277 const float c5 = (ny * fy) / zc;
278 const float c6 = (-nx * u0 - ny * v0) / zc;
280 const float l = pElement->
l;
311 for (i = 0; i < nPoints; i++)
334 delete [] pNewPoints;
bool AddElement(CDynamicArrayElement *pElement, bool bAddUniqueOnly=false, bool bManageMemory=true)
Data structure for the representation of a 2D vector.
void MulMatMat(const CFloatMatrix *A, const CFloatMatrix *B, CFloatMatrix *pResultMatrix, bool bTransposeB=false)
void Zero(CByteImage *pImage, const MyRegion *pROI=0)
Sets all values in a CByteImage to zero.
void NormalizeVec(Vec2d &vec)
Vec3d m_translation_inverse
Translation vector of the inverted extrinsic transformation.
static bool RAPiD(CDynamicArray &elementList, const CCalibration *pCalibration, Mat3d &rotation, Vec3d &translation)
bool Track(const CByteImage *pEdgeImage, Vec3d *pOutlinePoints, int nOutlinePoints, Mat3d &rotation, Vec3d &translation)
float Length(const Vec3d &vec)
void SolveLinearLeastSquaresSVD(const CFloatMatrix *A, const CFloatVector *b, CFloatVector *x)
void WorldToImageCoordinates(const Vec3d &worldPoint, Vec2d &imagePoint, bool bUseDistortionParameters=true) const
Transforms 3D world coordinates to 2D image coordinates.
void AddToMat(CFloatMatrix *pMatrix, const CFloatMatrix *pMatrixToAdd)
const CCameraParameters & GetCameraParameters() const
Gives access to the camera parameters.
void NormalizeVec(Vec3d &vec)
static bool CalculateOptimalTransformation(const Vec3d *pSourcePoints, const Vec3d *pTargetPoints, int nPoints, Mat3d &rotation, Vec3d &translation)
void SubtractVecVec(const Vec3d &vector1, const Vec3d &vector2, Vec3d &result)
void MulMatMat(const Mat3d &matrix1, const Mat3d &matrix2, Mat3d &result)
void SubtractFromVec(Vec2d &vec, const Vec2d &vectorToSubtract)
ImageType type
The type of the image.
Data structure for the representation of a matrix of values of the data type float.
int width
The width of the image in pixels.
int height
The height of the image in pixels.
CDynamicArrayElement * GetElement(int nElement)
void Transpose(const CFloatMatrix *pMatrix, CFloatMatrix *pResultMatrix)
void MulVecScalar(const Vec2d &vec, float scalar, Vec2d &result)
Data structure for the representation of a 3D vector.
void MulMatVec(const Mat3d &matrix, const Vec3d &vec, Vec3d &result)
Camera model parameters and functions for a single camera.
void Init(const CCalibration *pCalibration)
unsigned char * pixels
The pointer to the the pixels.
void AddVecVec(const Vec3d &vector1, const Vec3d &vector2, Vec3d &result)
Mat3d m_rotation_inverse
Rotation matrix of the inverted extrinsic transformation.
Data structure for the representation of a vector of values of the data type float.
float Distance(const Vec2d &vector1, const Vec2d &vector2)
void AddToVec(Vec3d &vec, const Vec3d &vectorToAdd)
Data structure for the representation of a 3x3 matrix.
Data structure for the representation of 8-bit grayscale images and 24-bit RGB (or HSV) color images ...
void SetVec(Vec2d &vec, float x, float y)
void MulVecScalar(const Vec3d &vec, float scalar, Vec3d &result)
void AddToVec(Vec2d &vec, const Vec2d &vectorToAdd)
void SetVec(Vec3d &vec, float x, float y, float z)
void CrossProduct(const Vec3d &vector1, const Vec3d &vector2, Vec3d &result)
Struct containing all parameters of the camera model.