I want to send a photo in open cv saved in cv::Mat object to android phone and I want to show it in an ImageView on android side I succeed to send the photo data and I received them in an array of integers (int[]) on android But my problem How to make bitmap from them to show as I don't know the construction of photo in android and its relation with open cv Mat;
问问题
67 次
1 回答
0
首先,将 Mat 转换为 Android Bitmap(这是 OpenCV 的 Android 界面的代码):
try {
Utils.matToBitmap(mat, bitmap);
} catch (Exception e) {
bitmap.recycle();
bitmap = null;
}
然后,将 Bitmap 设置为 ImageView 的内容(您已在 XML 布局文件中定义):
ImageView imageView = (ImageView) findViewById(R.id.imageView);
imageView.setImageBitmap(bitmap);
如果您将 OpenCV 的 C++ 接口与 Native Development Kit 一起使用,最好在 C++ 中执行第一步并从 C++ 方法返回位图,然后像以前一样在 Java 中执行第二步。
于 2013-04-25T16:17:06.930 回答