00001
00008 #include <blort/Recognizer3D/PoseCv.hh>
00009
00010
00011 namespace P
00012 {
00013
00014
00015
00016
00017
00018
00019 PoseCv::PoseCv()
00020 {
00021 R = cvCreateMat( 3, 3, CV_32F );
00022 t = cvCreateMat( 3, 1, CV_32F );
00023 n = cvCreateMat( 3, 1, CV_32F );
00024 }
00025
00026
00027 PoseCv::PoseCv(cv::Mat translation, cv::Mat rotation)
00028 {
00029 R = cvCreateMat( 3, 3, CV_32F );
00030 t = cvCreateMat( 3, 1, CV_32F );
00031 n = cvCreateMat( 3, 1, CV_32F );
00032
00033 for(int i=0; i<rotation.rows; ++i)
00034 for(int j=0; j<rotation.cols; ++j)
00035 cvmSet(R,i,j,rotation.at<float>(i,j));
00036
00037 for(int i=0; i<translation.rows; ++i)
00038 for(int j=0; j<translation.cols; ++j)
00039 cvmSet(t,i,j,translation.at<float>(i,j));
00040
00041 cvmSet(n,0,0,1);
00042 cvmSet(n,1,0,0);
00043 cvmSet(n,2,0,0);
00044 }
00045
00046 PoseCv::~PoseCv()
00047 {
00048 cvReleaseMat(&R);
00049 cvReleaseMat(&t);
00050 cvReleaseMat(&n);
00051 }
00052
00053
00054
00055
00056
00057
00058 void InitializePoseCv(PoseCv &pose)
00059 {
00060 cvmSet(pose.R,0,0,1); cvmSet(pose.R,0,1,0); cvmSet(pose.R,0,2,0);
00061 cvmSet(pose.R,1,0,0); cvmSet(pose.R,1,1,1); cvmSet(pose.R,1,2,0);
00062 cvmSet(pose.R,2,0,0); cvmSet(pose.R,2,1,0); cvmSet(pose.R,2,2,1);
00063
00064 cvmSet(pose.t,0,0,0);
00065 cvmSet(pose.t,1,0,0);
00066 cvmSet(pose.t,2,0,0);
00067
00068 cvmSet(pose.n,0,0,1);
00069 cvmSet(pose.n,1,0,0);
00070 cvmSet(pose.n,2,0,0);
00071
00072
00073 }
00074
00075 void DeletePoseCv(Array<PoseCv*> &ps)
00076 {
00077 for (unsigned i=0; i<ps.Size(); i++)
00078 delete ps[i];
00079 ps.Clear();
00080 }
00081
00082
00083 }
00084
00085
00086