Ask Your Question

dramaticlook's profile - activity

2016-02-18 04:48:30 -0600 commented question OpenCV 3.1 UMat assignment

Thanks for highlighting the error. What do you think about the case UMat * or UMat being a global variable? Also how can i access the data of a UMat? Is it supposed to be in mat.u.data ?

2016-02-18 00:46:43 -0600 asked a question OpenCV 3.1 UMat assignment

I am trying to implement a performance upgrade to the project of my company. The project depends on OpenCV and recently I have successfully upgraded to OpenCV 3.1 to use UMat. Though I cant find a complete tutorial on it except basic operations. So I am stuck at the following:

   Mat m (width, height, type, someData, step);
    cv::UMat * ptr = new cv::UMat (width, height, type);
    //dont ask me why the hell we are using a pointer to the smart mat object (my project leader insists)

This doesnt work

  ptr->setTo (m);

Neither does this:

m.copyTo(*ptr);

These cause an exception.

ptr=&m.getUMat(cv::ACCESS_RW);

And this one results with a two dimensional mat with 0 rows and 0 cols... Also another case is:

some global cv::UMat gloMat; //initialized
function()
{
cv::UMat mat;
gloMat.copyTo(mat); //doesnt work!!! same result 2 dims 0 rows 0 cols

gloMat.getMat(cv::ACCESS_READ).copyTo (mat.getMat(cv::ACCESS_WRITE)); // this doesnt work as well !!!
return mat;
}

Need help. Thanks in advance!!!!

2013-01-20 03:55:13 -0600 asked a question OpenCV Stereo Matching Essential Matrix weird values

I have a stereo setup using OpenCV and two webcams (The one in the book Lerning OpenCV by H&Z). I computed essential and fundamental matrices, intrinces extrinces etc using BM correspondancy algorithm. Now I want to find the matching point of a pixel in left image in the other image. To do this I have defined the following function, which is incomplete since my primary aim is to calculate real world distance.

void StereoVision::findEpipolarLineForXY(int x, int y ,int lr)   
{

if(calibrationDone)
{
CvPoint3D32f p1={x,y,1};
qDebug("%d,_,_,%d",p1.x,p1.y);

CvMat pt1=cvMat(3,1,CV_64FC1,&p1);
qDebug("-");
CvMat e=_E;
qDebug("pt1:");
PrintMat(&pt1);
qDebug("e:");
PrintMat(&e);

//CvMat * corLine;
//CvMat* pt2=e*pt1;

CvMat *pt2 = cvCreateMat( e.rows, pt1.cols, CV_64FC1);
qDebug("pt2:");
PrintMat(pt2);
qDebug("--%d--->%d",pt2->rows,pt2->cols);

cvMatMul( &e, &pt1, pt2 );

qDebug("--%d--->%d",pt2->cols,pt2->data);
//const CvMat* f=&_F;
qDebug("---");
//cvComputeCorrespondEpilines(&mat,lr,f,corLine);
qDebug("----");
//qDebug("%d,,,%d",corLine->height,corLine->rows);

}

}

 void StereoVision::PrintMat(CvMat *A)
   {
   int i, j;

for (i = 0; i < A->rows; i++)
{
    QDebug dbg(QtDebugMsg);
    dbg<<"\n";
    switch (CV_MAT_DEPTH(A->type))
    {
    case CV_32F:
    case CV_64F:
        for (j = 0; j < A->cols; j++)
            dbg <<"%8.3f "<< ((float)cvGetReal2D(A, i, j));
        break;
    case CV_8U:
    case CV_16U:
        for(j = 0; j < A->cols; j++)
            dbg <<"%6d"<<((int)cvGetReal2D(A, i, j));
        break;
    default:
        break;
    }
    dbg.~QDebug();
}
qDebug("");
}
I want to know why essential matrix is a bad one? all output is below:

350,,,317

0,,,1081466880

-

pt1:

%8.3f 350

%8.3f 317

%8.3f 1

e:

%8.3f 0 %8.3f inf %8.3f 0

%8.3f 0 %8.3f 0 %8.3f 0

%8.3f 0 %8.3f 0 %8.3f 0

pt2:

%8.3f -inf

%8.3f -inf

%8.3f -inf

--3--->1

--1--->44201616

Also Id like to know if im on the right path to find the 3D distance of the pixel in real world coordinates?