title: Use OpenCV matrix for OpenGL ES texture
body: <p>I am trying to write an AR application, so far I've used opencv for image warping and things, but warping video frames one by one is computationally expensive. Therefore I am trying to migrate to opengl for augmentation.</p>
  
  <p>So far I tried to get camera frame data, convert it to opencv matrix in java part, and then create a texture from it in the native code. It kinda works, but there are some strange marks in the result : 
  <img src="https://i.stack.imgur.com/iyTks.png" alt="enter image description here"></p>
  
  <p>as @Micka suggested , here is my code snippet:</p>
  
  <p>java part : </p>
  
  <pre><code>public void onPreviewFrame(byte[] frame, Camera arg1) {
      mFrame.put(0, 0, frame);
      processFrame(mFrame.getNativeObjAddr());
  }
  </code></pre>
  
  <p>native part :</p>
  
  <pre><code>JNIEXPORT void JNICALL Java_com_..._CameraPreviewer_processFrame( JNIEnv* env, jobject thiz, jlong addr)
      cv::Mat&amp; mFrame = *(cv::Mat*)addr;
      cv::cvtColor(mFrame, buffer[(bI) % 30], cv::COLOR_YUV2BGR_NV21);
  }
  </code></pre>
  
  <p>and onDrawFrame Renderer (native):</p>
  
  <pre><code>{
      ...
      cvtColor(buffer[(bI) % 30], frame, CV_BGR2BGR565);
      glTexSubImage2D(GL_TEXTURE_2D, 0, (1024-frameWidth)/2, (1024-frameHeight)/2, frameWidth, frameHeight, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, frame.ptr());
      ...
  }
  </code></pre>