Ask Your Question

DevYourWorld's profile - activity

2020-04-23 16:50:55 -0600 received badge  Notable Question (source)
2017-12-31 09:55:27 -0600 received badge  Popular Question (source)
2015-02-09 06:42:10 -0600 received badge  Student (source)
2015-02-09 05:11:50 -0600 asked a question OpenCV to Vuforia's coordinates

Hello,

Some times ago I made a small application using Vuforia (a tracker). Yesterday, I wanted to add another tracker to my App. To do so, I used markers and OpenCV's method: "cv::solvePnP".

But it seems, that OpenCV does not return the same kind of matrix as Vuforia. With Vuforia, with the same marker, having aproximately a perpendicular angle between the camera and the marker I get the following matrix:

-0.017389 -0.999035 -0.040332 0.000000
-0.999714 0.016710 0.017124 0.000000
-0.016433 0.040618 -0.999040 0.000000
40.201080 -5.577782 1467.874268 1.000000

While OpenCV gives me the following:

0.999559 -0.003280 -0.029498 0.000000
0.000455 0.995451 -0.095279 0.000000
0.095223 0.000000 0.995013 0.000000
0.043068 -0.982356 4.211450 1.000000

Playing with matrixes is not what I am the best at. So I was wondering if someone could help me to convert my OpenCV matrix to something close to a Vuforia Matrix. If possible, explainations would be great for my personal knowledge. Else I'll just take it as is, for now the important point for me is that it works as I espect it to do.

Best regards.

2015-01-20 07:39:03 -0600 received badge  Editor (source)
2015-01-20 07:38:14 -0600 asked a question cv::solvePnP to GLM matrix : What am I doind wrong?

Hello everyone,

I have a problem building a GLM matrix using solvePnP. I'll first give you my code and then explain what goes wrong:

double modelview[16];
std::vector<cv::Point3f> objectPoints;
std::vector<cv::Point2f> imagePoints;
float _cameraMatrix[3*3] = {0.0366305783, 0, 0,
0, -0.0206046999, 0,
0, -0.00416666688, 1.00160134};

objectPoints.push_back(cv::Point3f(-25.f, 25.f, 0.f));
objectPoints.push_back(cv::Point3f(25.f, 25.f, 0.f));
objectPoints.push_back(cv::Point3f(25.f, -25.f, 0.f));
objectPoints.push_back(cv::Point3f(-25.f, -25.f, 0.f));
imagePoints.push_back(cv::Point2f(-48.7127075, 23.487133));
imagePoints.push_back(cv::Point2f(-46.6150055, -60.381012));
imagePoints.push_back(cv::Point2f(72.2412414, -58.0478134));
imagePoints.push_back(cv::Point2f(65.8430176, 28.7145424));

cv::Mat cameraMatrix(3, 3, cv::DataType<float>::type, _cameraMatrix);
cv::Mat distCoeffs = cv::Mat::zeros(1, 4, cv::DataType<float>::type);
cv::Mat rvec, tvec;

cv::solvePnP(objectPoints, imagePoints, cameraMatrix, distCoeffs, rvec, tvec, false, cv::SOLVEPNP_EPNP);

/* rvec = 2.305942566970259e-06;
 1.574367085806425e-05;
 1.527203451641959*/

cv::Mat rotation, viewMatrix(4, 4, CV_64F);
cv::Rodrigues(rvec, rotation);



for(unsigned int row=0; row<3; ++row)
{
    for(unsigned int col=0; col<3; ++col)
    {
        viewMatrix.at<double>(row, col) = rotation.at<double>(row, col);
    }
    viewMatrix.at<double>(row, 3) = tvec.at<double>(row, 0);
}
viewMatrix.at<double>(3, 3) = 1.0f;

cv::Mat glViewMatrix = cv::Mat::zeros(4, 4, CV_64F);
cv::transpose(viewMatrix , glViewMatrix);

for (int i = 0; i < 4 ; i++)
    for (int j = 0 ; j < 4 ; j++)
        modelview[i*4+j] = viewMatrix.at<double>(i, j);
/* modelview = {
    0.043579069512384938, -0.99904998101322906, 0.000011743141222015021, 3.8334346801028909,
    0.99904998104300324, 0.043579069611845073, 0.000008351097188959756, 11.220754374564033,
    -0.000008854918656845795, 0.000011368051970337058, 0.99999999989617883, 0.014603401623283486,
    2.1219957924474693E-314, 4.9406564584124654E-324, 0, 1
}*/

My problem is that modelview[2], modelview[6], modelview[8] and modelview[9] are always equal to 0 (here it is rounded to 0 anyway). And modelview[10] is always 1.

What am I doing wrong? Why does only X and Y seems to be rotated? Why does my Z coordinate is always near to 0?

2015-01-20 07:11:38 -0600 received badge  Scholar (source)
2015-01-20 06:00:01 -0600 commented question How to specify modules with CMake?

Okay, that solved my problem, thank you very much! :) How can I mark it as solved when a comment solved my problem?

2015-01-20 02:49:59 -0600 asked a question How to specify modules with CMake?

Hello,

I'm not a very huge CMake user, and the OpenCV CMakeList seems too huge to retro-engeneer it. What I want to do is to build a minimal version of OpenCV in order to use the cv::solvePnP method ( https://github.com/Itseez/opencv/blob... ). So, I want to build an OpenCV version just with "core" and "calib3d" modules. This version has to work on iOS and Android, so I though I had to modify the python script ( https://github.com/Itseez/opencv/blob... ). My problem is that the CMakeLists are so huge I can't even see what to add/modify in the script.

Does someone has an answer?