title: Drawing 3D boxes on chessboard - OpenCV, LibGdx and java
body: <p>I'm new to opencv. I'm working with it in java, which is a pain, since most of the example and resources around the internet is in C++.</p>
  
  <p>Currently my project involves recognizing a chessboard and then be able to draw on specific parts of the board.</p>
  
  <p>I've gotten so far as to get the corners through the Calib3d part of the library. But this is where i get stuck. My question is how do i convert the corners info i got (Which is the corners placement on the 2D image) to something i can use in a 3D space to draw on with LibGdx?</p>
  
  <p>Following is my code (in snippets):</p>
  
  <pre><code>public class chessboardDrawer implements ApplicationListner{
  ... //Fields are here
  
  MatOfPoint2f corners = new MatOfPoint2f();
  MatOfPoint3f objectPoints = new MatOfPoint3f();
  
  public void create(){
      webcam = new VideoCapture(0);
      ... //Program sleeps to make sure camera is ready
  
  }
  
  public void render(){
      //Fetch webcam image
      webcam.read(webcamImage);
      //Grayscale the image
      Imgproc.cvtColor(webcamImage, greyImage, Imgproc.COLOR_BGR2GRAY);
      //Check if image contains a chessboard of with 9x6 corners
      boolean foundCorners = Calib3d.findChessboardCorners(greyImage, 
      new Size(9,6), 
      corners, Calib3d.CALIB_CB_FAST_CHECK | Calib3d.CALIB_CB_ADAPTIVE_THRESH);
  
      if(foundCorners){
          for(int i = 0; i &lt; corners.height; i++){
              //This is where i have to convert the corners 
              //to something i can use in libGdx to draw boxes
              //And insert them into the objectPoints variable
          }
      }
      //Show the corners on the webcamIamge
      Calib3d.drawChessboardCorners(webcamImage, new Size(9,6), corners, true);
      //Helper library to show the webcamImage
      UtilAR.imDrawBackground(webcamImage);
  }
  }
  </code></pre>
  
  <p>Any help?</p>