BitmapToMat can open only ARGB_8888 Bitmap objects (Feature #1283)
Description
It appears that the BitmapToMat
function cannot open images that don't have the Bitmap.Config.ARGB_8888
Config. Calling the function on images with other types, such as RGB_565
, results in the Mat
object having zero size and one channel. Using Bitmap.copy
to convert the image to ARGB_8888
before calling the function fixes the problem.
Here is an example log output for the source code I attached:
$ adb logcat 08-06 03:18:21.506 18438 18438 D OpenBitmaps: /mnt/sdcard/Images/windsor_chair_0002.jpg: exists=true 08-06 03:18:21.506 18438 18438 D OpenBitmaps: /mnt/sdcard/Images/windsor_chair_0002.jpg: 300x180 08-06 03:18:21.506 18438 18438 D OpenBitmaps: /mnt/sdcard/Images/windsor_chair_0002.jpg: 0.0x0.0
Android 2.3.3 was used. Here is the processor info:
$ adb shell cat /proc/cpuinfo Processor : ARMv7 Processor rev 2 (v7l) BogoMIPS : 299.95 Features : swp half thumb fastmult vfp edsp neon vfpv3 CPU implementer : 0x41 CPU architecture: 7 CPU variant : 0x3 CPU part : 0xc08 CPU revision : 2 Hardware : mapphone_CDMA Revision : 0000 Serial : 0000000000000000
Associated revisions
#1283, Mat <->Bitmap converters are updated to support CV_8UC(1,3,4) & non-continuous Mat-s and RGBA_8888 & RGB_565 Bitmaps; Android samples project files are updated according to the latest SDK req-s.
#1283, Mat <->Bitmap converters Java tests.
#1283, adding JavaDoc comments for Mat <->Bitmap converters.
Merge pull request #1283 from melody-rain:new_mog_mog2
History
Updated by Kirill Kornyakov over 13 years ago
Andrey, could you look at this?
Updated by Andrey Kamaev over 13 years ago
Currently OpenCV supports only ARGB_8888 Bitmap format.
- Status deleted (
Open)
Updated by Andrey Kamaev over 13 years ago
Regarding attached file - you can read image using following code:
mat = Highgui.imread(filename);
Updated by Alexander Shishkov about 13 years ago
- Description changed from It appears that the [[BitmapToMat]] function cannot open images that don'... to It appears that the BitmapToMat function cannot open images that don't ha... More
Updated by Andrey Pavlenko about 13 years ago
I need to add tests for these converters before closing the record.
Updated by Andrey Pavlenko about 13 years ago
- Target version set to 2.4.0
- % Done changed from 0 to 90
Updated by Andrey Pavlenko about 13 years ago
- Status set to Done
Updated by Andrey Kamaev about 13 years ago
- Description changed from It appears that the BitmapToMat function cannot open images that don't ha... to It appears that the @BitmapToMat@ function cannot open images that don't ... More