Newer
Older
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
resultPoint.x = (mControlWidget->getCalibCoord3DSwapX() ? -1 : 1) * (camInWorld.x + lambda * pBCInWorld.x);
resultPoint.y = (mControlWidget->getCalibCoord3DSwapY() ? -1 : 1) * (camInWorld.y + lambda * pBCInWorld.y);
resultPoint.z = (mControlWidget->getCalibCoord3DSwapZ() ? -1 : 1) * (camInWorld.z + lambda * pBCInWorld.z);
}//////////////// End old method
return resultPoint;
}
/**
* Transformiert den angegebenen 3D-Punkt mit der Rotation und Translation
* um Umrechnungen zwischen verschiedenen Koordinatensystemen zu ermglichen
*/
Point3f ExtrCalibration::transformRT(Point3f p)
{
// ToDo: use projectPoints();
double rvec_array[3], rotation_matrix[9];
rvec_array[0] = mControlWidget->getCalibExtrRot1();
rvec_array[1] = mControlWidget->getCalibExtrRot2();
rvec_array[2] = mControlWidget->getCalibExtrRot3();
Mat rvec(3,1,CV_64F, rvec_array);
Mat rot_mat(3,3,CV_64F);
// Transform the rotation vector into a rotation matrix with opencvs rodrigues method
Rodrigues(rvec,rot_mat);
rotation_matrix[0] = rot_mat.at<double>(0,0);
rotation_matrix[1] = rot_mat.at<double>(0,1);
rotation_matrix[2] = rot_mat.at<double>(0,2);
rotation_matrix[3] = rot_mat.at<double>(1,0);
rotation_matrix[4] = rot_mat.at<double>(1,1);
rotation_matrix[5] = rot_mat.at<double>(1,2);
rotation_matrix[6] = rot_mat.at<double>(2,0);
rotation_matrix[7] = rot_mat.at<double>(2,1);
rotation_matrix[8] = rot_mat.at<double>(2,2);
Point3f point3D;
point3D.x = rotation_matrix[0] * p.x +
rotation_matrix[3] * p.y +
rotation_matrix[6] * p.z -
mControlWidget->trans1->value();//translation_vector2[0];
point3D.y = rotation_matrix[1] * p.x +
rotation_matrix[4] * p.y +
rotation_matrix[7] * p.z -
mControlWidget->trans2->value();//translation_vector2[1];
point3D.z = rotation_matrix[2] * p.x +
rotation_matrix[5] * p.y +
rotation_matrix[8] * p.z -
mControlWidget->trans3->value();//translation_vector2[2];
return point3D;
}
bool ExtrCalibration::isOutsideImage(Point2f p2d)
{
int bS = mMainWindow->getImage() ? mMainWindow->getImageBorderSize() : 0;
if( mMainWindow->getImage())
{
if( !isnormal(p2d.x) || !isnormal(p2d.y) || !isnormal(p2d.x) || !isnormal(p2d.y) )
return true;
if (isnan(p2d.x) || isnan(p2d.y) || isinf(p2d.x) || isinf(p2d.y))
return true;
//return p2d.x < 0 || p2d.x > mMainWindow->getImage()->width() || p2d.y < 0 || p2d.y > mMainWindow->getImage()->height();
return p2d.x < -bS || p2d.x > mMainWindow->getImage()->width()-bS || p2d.y < -bS || p2d.y > mMainWindow->getImage()->height()-bS;
}else
{
return false;
}
}