Java openCV - Error while conevrting Bitmap to Mat

前端 未结 2 1402
予麋鹿
予麋鹿 2021-01-07 15:00

I am using Java openCV, and i try to load a photo and run the template matching over it. The template matching method deals with Mat objects, so i need to load the images an

相关标签:
2条回答
  • 2021-01-07 15:32

    You need to convert your bitmap to the RGBA format:

    Bitmap bmp32 = i.copy(Bitmap.Config.ARGB_8888, true);
    

    Actually it is the most discussed problem on Android-OpenCV user-group: https://groups.google.com/group/android-opencv/

    The fix for this problem is already available in OpenCV trunk and will be included into the next release of OpenCV.

    Also you can read image using the OpenCV API:

    Mat image = Highgui.imread("/sdcard/TVguide/Detection/detected.jpg");
    
    0 讨论(0)
  • 2021-01-07 15:32

    loading using OpenCV is quicker (20%-40%) than loading using BitmapFactory and transforming to OpenCV Mat

    Mat image = Highgui.imread("/sdcard/TVguide/Detection/detected.jpg");

    0 讨论(0)
提交回复
热议问题