void PointSolver2::solve (cv::Mat &inputImage, Point3 &startPos, Quaternion &startOrientation)
{
	assert (inputImage.type() == CV_8UC1);

	position0 = startPos;
	orientation0 = startOrientation;
	image = inputImage;

	prepareImage ();

#define ITERATION 5

	for (int np=0; np<ITERATION; np++) {
		currentViewMatrix = createViewMatrix (position0, orientation0);

		projectLines ();
		findNearestLinePerPoint ();
		prepareMatrices ();
		solveForCorrection ();
	}
//	currentViewMatrix = createViewMatrix (position0, orientation0);
	debugDraw ("/tmp/draw.png", &position0, &orientation0);

	return;
}
EdgePrewitt::EdgePrewitt(PNM*img, ImageViewer* iv) :
    EdgeGradient(img, iv)
{
    prepareMatrices();
}
EdgePrewitt::EdgePrewitt(PNM*img) :
    EdgeGradient(img)
{
    prepareMatrices();
}
EdgeRoberts::EdgeRoberts(PNM* img, ImageViewer* iv) :
    EdgeGradient(img, iv)
{
    prepareMatrices();
}
EdgeRoberts::EdgeRoberts(PNM* img) :
    EdgeGradient(img)
{
    prepareMatrices();
}
EdgeSobel::EdgeSobel(PNM* img) :
    EdgeGradient(img)
{
    prepareMatrices();
}
EdgeSobel::EdgeSobel(PNM* img, ImageViewer* iv) :
    EdgeGradient(img, iv)
{
    prepareMatrices();
}