1

I want to use a Mat object generated using openCV in JOGL, and therefore I need to convert it to a ByteBuffer of GL_RGBA type. what options do I have to do this?

1 Answer 1

6

i'm not sure, if a byte[] does the trick, but here we go:

Mat m; 


byte[] bytes = new byte[ m.rows() * m.cols() * m.channels() ];

m.get(0,0, bytes);

(also note, that unless you're on android, opencv images tend to be 24bit bgr, not rgba, so you probably need to change the flag passed to JOGL, when uploading the texture)

Sign up to request clarification or add additional context in comments.

1 Comment

He can still use the byte array to fill a direct NIO byte buffer that he can pass to JOGL, it seems to be correct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.