Home Preparing bitmap byte[] data to pass to jni
Reply: 1

Preparing bitmap byte[] data to pass to jni

Ber12345 Published in 2018-01-07 01:16:06Z

I would like to pass a bitmap from my android class to my native c++ class through the jni, and then perform opencv processing the other side.

I don't understand how to prepare the data to go into a byte[] array, using something like getPixels. Do I need to consider RGB?

ADM Reply to 2018-01-07 02:27:20Z

You have to convert Bitmap to Mat. org.opencv.android.Utils class having the utility conversion method . It takes Bitmap as parameter of type ARGB_8888 or RGB_565.

import org.opencv.android.Utils;
private void convertToMat(Bitmap bitmap){
    Mat mat = new Mat();
    Bitmap bmp32 = bitmap.copy(Bitmap.Config.ARGB_8888, true);
    Utils.bitmapToMat(bmp32, mat);

This is just one way . Have a look into This thread for more. Thx

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.350669 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO