So, I am working on an Android app. Basically, I have two textureId, one as input and one as output, with the width and the height. All I need to do is to is to access to the input GL texture with OpenCV, let's say to do an object detection task, and then pass the content to output GL texture. So, what is the fastest way to do that?
I managed to solve the problem by creating a Mat variable and filling the data with an unsigned char * with glReadPixels but, as you know, that method is too slow.
Is there any way to perform the same task? You can think outside of the common route.
Like maybe by the use of OpenCL with cl::ImageGL if it's possible or whatever it should be supported on Android.
For those who may need/want the source or just simply know better what I am talking about, here is the source:
void testProgram(JNIEnv* env, jnit texIn, jint texOut, jint w, jint h){
}
I managed to solve the problem by creating a Mat variable and filling the data with an unsigned char * with glReadPixels but, as you know, that method is too slow.
Is there any way to perform the same task? You can think outside of the common route.
Like maybe by the use of OpenCL with cl::ImageGL if it's possible or whatever it should be supported on Android.
For those who may need/want the source or just simply know better what I am talking about, here is the source:
void testProgram(JNIEnv* env, jnit texIn, jint texOut, jint w, jint h){
static cv::Mat mat;
mat.create(h, w, CV_8UC4);
glReadPixels(0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, mat.data);
//glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texOut);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, mat.data);
mat.create(h, w, CV_8UC4);
glReadPixels(0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, mat.data);
//glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texOut);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, mat.data);
}