使用Android摄像头拍摄的图像后,转换成位图来垫位图、转换成、摄像头、图像

由网友(专业挖墙角)分享简介:板坯B =新垫();。BMP位= getIntent()getExtras()getParcelable(image_send);@覆盖保护无效的onCreate(包savedInstanceState){super.onCreate(savedInstanceState);的setContentView(R.l...

 板坯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);
}
易宏摄像头监控录像软件下载 易宏摄像头监控录像软件1.3 官方版 腾牛下载

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.

阅读全文

相关推荐

最新文章