1

我正在开发一个 Android 应用程序,该应用程序Bitmap将从ImageView. 将其转换Bitmap为 JavaCV IplImage,然后转换为灰度,如下所示:

IplImage image = IplImage.create(width, height, IPL_DEPTH_8U, 4);
bitmap.copyPixelsToBuffer(image.getByteBuffer());
IplImage _3image = IplImage.create(width, height, IPL_DEPTH_8U, 3);
IplImage _1image = IplImage.create(width, height, IPL_DEPTH_8U, 1);
cvCvtColor(image, _3image, CV_BGRA2BGR);
cvCvtColor(_3image, _1image, CV_RGB2GRAY);

但是RuntimeException: Buffer not large enough for pixels当我这样做时我得到了

Bitmap x = Bitmap.createBitmap(width, height, Config.ARGB_8888);            
x.copyPixelsFromBuffer(_1image.getByteBuffer());

任何帮助,将不胜感激。谢谢你。

4

0 回答 0