Ask Your Question

Ropeburn's profile - activity

2014-11-11 20:55:58 -0600 asked a question OpenCV cv:solvePnP to GLM matrix to render image with PCL pointcloud

I am having trouble converting the rotation and translation matrices returned by cv:solvePnP into an OpenGL (GLM) modelview matrix. I am trying to render the checkerboard texture over the checkerboard in the point cloud and my conversation is either not right or I am missing a step some where. The GL camera should be at the location of the camera in world space and is looking up the positive Z axis. What am I doing wrong?

  {
  Pnt2DLst point2DLst;
  bool     found = false;

   found = cv::findChessboardCorners(_image,_boardSize,point2DLst,
                                     cv::CALIB_CB_ADAPTIVE_THRESH | cv::CALIB_CB_FAST_CHECK | cv::CALIB_CB_NORMALIZE_IMAGE);  

    if (found)
    {
    Pnt3DLst  point3DLst;
    cv::Mat   vRc;
    cv::Mat   vTc;

      create3DBoardPoints(point3DLst);

      found = cv::solvePnP(point3DLst,point2DLst,_cM,_dC,vRc,vTc);

      if (found)
      {
      cv::Mat       mRod; 

        cv::Rodrigues(vRc,mRod);

        {
        glm::vec3 vT = glm::vec3(-(float)((double *) vTc.data)[0], 
                                 -(float)((double *) vTc.data)[1], 
                                 -(float)((double *) vTc.data)[2]);
        glm::mat3 mR = glm::mat3( (float)((double *)mRod.data)[0],  
                                  (float)((double *)mRod.data)[3],  
                                  (float)((double *)mRod.data)[6],
                                  (float)((double *)mRod.data)[1], 
                                 -(float)((double *)mRod.data)[4], 
                                  (float)((double *)mRod.data)[7],
                                  (float)((double *)mRod.data)[2],  
                                  (float)((double *)mRod.data)[5], 
                                 -(float)((double *)mRod.data)[8]);
        glm::mat4 mT = glm::translate(glm::mat4(mR),vT / 1000.0f);  // convert to meters

          _pRO->setImageTransform(mT);
        }     
      }
    }
  }

image description image description

2014-11-11 14:58:46 -0600 asked a question Convert OpenCV SolvePnP matrix to OpenGL to render over PCL model

I'm having trouble understanding how to correctly make an OpenGL modelview matrix from the rotation and translation matrix returned by cv::solvePnP. This is how I think it should be done....

  {
  Pnt2DLst point2DLst;
  bool     found = false;

   found = cv::findChessboardCorners(_image,_boardSize,point2DLst,
                                     cv::CALIB_CB_ADAPTIVE_THRESH | cv::CALIB_CB_FAST_CHECK | cv::CALIB_CB_NORMALIZE_IMAGE);  

    if (found)
    {
    Pnt3DLst  point3DLst;
    cv::Mat   vRc;
    cv::Mat   vTc;

      create3DBoardPoints(point3DLst);

      found = cv::solvePnP(point3DLst,point2DLst,_cM,_dC,vRc,vTc);

      if (found)
      {
      cv::Mat       mRod; 

        cv::Rodrigues(vRc,mRod);

        {
        glm::vec3 vT = glm::vec3(-(float)((double *) vTc.data)[0], 
                                 -(float)((double *) vTc.data)[1], 
                                 -(float)((double *) vTc.data)[2]);
        glm::mat3 mR = glm::mat3( (float)((double *)mRod.data)[0],  
                                  (float)((double *)mRod.data)[3],  
                                  (float)((double *)mRod.data)[6],
                                  (float)((double *)mRod.data)[1], 
                                 -(float)((double *)mRod.data)[4],  
                                  (float)((double *)mRod.data)[7],
                                  (float)((double *)mRod.data)[2],  
                                  (float)((double *)mRod.data)[5], 
                                 -(float)((double *)mRod.data)[8]);
        glm::mat4 mT = glm::translate(glm::mat4(mR),vT / 1000.0f);  // convert to meters

          printf("%7.3f, %7.3f, %7.3f, %7.3f\n",mT[0].x,mT[1].x,mT[2].x,mT[3].x);
          printf("%7.3f, %7.3f, %7.3f, %7.3f\n",mT[0].y,mT[1].y,mT[2].y,mT[3].y);
          printf("%7.3f, %7.3f, %7.3f, %7.3f\n",mT[0].z,mT[1].z,mT[2].z,mT[3].z);
          printf("%7.3f, %7.3f, %7.3f, %7.3f\n",mT[0].w,mT[1].w,mT[2].w,mT[3].w);

          _pRO->setImageTransform(mT);
        }     
      }
    }
  }

My checker boarder does not line up with the checkerboard in the point cloud. image description image description

What am I doing wrong?

PS. My camera is pointing up the positive z-axis.

2014-10-30 08:53:41 -0600 commented answer 3x3 color matching matrix

This answer is still a bit value. You are suggesting converting all 24 captured macbeth values to HSV and then plotting the deviation from the actual macbeth values. How does this give me a 3x3 color matrix? Also why isn't color matching already a function within OpenCV? Is there an example in color or a detail description in a pdf somewhere. Most mentions of color matching just gloss over the creation of the matrix without going into detailed steps.

2014-10-28 11:23:26 -0600 received badge  Student (source)
2014-10-28 10:16:56 -0600 answered a question videocapture open 64 fails

I just verified that the 'with' options are the same for the 32 and 64 bit compiles.

2014-10-28 10:09:26 -0600 asked a question 3x3 color matching matrix

I am trying to color calibrate a couple of webcameras to a macbeth chart. I have a list of 24 colors from each camera and the macbeth color values. How does one go about finding the solution for the 3x3 color matching matrix (one for each camera) that can be applied to correct the camera colors to match the macbeth. The application of the matrix is casual, how does one determine/solve/create it. Thomas.

2014-10-28 09:55:31 -0600 commented answer videocapture open 64 fails

Yes, those are all checked. Did not resolve the issue. Thanks though. I am assuming that someone out there is using the 64bit version that they compiled.

2014-10-24 15:04:09 -0600 commented question videocapture open 64 fails

Anybody? Ideas?

2014-10-20 15:46:44 -0600 commented question videocapture open 64 fails

I'm building both 32 bit and 64 bit systems with the Cmake generated solutions, so I'm not sure I understand what you are really asking. I've even included /DHAVE_DSHOW /DHAVE_VIDEOINPUT which has no effect.

2014-10-20 13:33:13 -0600 received badge  Editor (source)
2014-10-20 13:30:59 -0600 asked a question videocapture open 64 fails

How come the 64 bit compile of starter_video fails to open any of the webcams I have, yet the 32 bit compile has no problem seeing any of them? I'm on Windows 8 with VS 2012. Same behavior with OpenCV 2.4.5, 2.4.9 and 3.0 alpha. What gives?