本文介绍了使用Android摄像头拍摄的图像后,转换成位图来垫的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
板坯B =新垫();
。BMP位= getIntent()getExtras()getParcelable(image_send);
@覆盖
保护无效的onCreate(包savedInstanceState){
super.onCreate(savedInstanceState);
的setContentView(R.layout.activity_display_image);
垫TMP =新材料(bmp.getWidth(),bmp.getHeight(),CvType.CV_8UC1);
Utils.bitmapToMat(BMP,TMP);
Imgproc.cvtColor(TMP,TMP,Imgproc.COLOR_RGB2GRAY);
//Imgproc.cvtColor(tmp,TMP,Imgproc.COLOR_GRAY2RGB,4);
Utils.matToBitmap(TMP,BMP);
IV =(ImageView的)findViewById(R.id.imageView1);
iv.setImageBitmap(BMP);
}
无法显示BMP。我的应用程序拍照后停止。
解决方案
进口org.opencv.android.Utils;
位图bmp32 = bmpGallery.copy(Bitmap.Config.ARGB_8888,真正的);
Utils.bitmapToMat(bmp32,imgMAT);
我希望这会帮助你。
Mat b = new Mat();
Bitmap bmp = getIntent().getExtras().getParcelable("image_send");
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_display_image);
Mat tmp = new Mat (bmp.getWidth(), bmp.getHeight(), CvType.CV_8UC1);
Utils.bitmapToMat(bmp, tmp);
Imgproc.cvtColor(tmp, tmp, Imgproc.COLOR_RGB2GRAY);
//Imgproc.cvtColor(tmp, tmp, Imgproc.COLOR_GRAY2RGB, 4);
Utils.matToBitmap(tmp, bmp);
iv = (ImageView) findViewById(R.id.imageView1);
iv.setImageBitmap(bmp);
}
Can't display the bmp. My app has stopped after taking a picture.
解决方案
import org.opencv.android.Utils;
Bitmap bmp32 = bmpGallery.copy(Bitmap.Config.ARGB_8888, true);
Utils.bitmapToMat(bmp32, imgMAT);
I hope that will help you.
这篇关于使用Android摄像头拍摄的图像后,转换成位图来垫的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!