我想将private Mat mRgba;
转换为private Bitmap bmp;
,然后将图像裁剪到相机视图中的imageview中,它没有错误,它可以在我的设备上运行,但它没有正确显示
,不改变图像,这是我的代码
public void onCreate(Bundle savedInstanceState) {
Log.i(TAG, "called onCreate");
super.onCreate(savedInstanceState);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
setContentView(R.layout.tutorial1_surface_view);
if (mIsJavaCamera)
mOpenCvCameraView = (CameraBridgeViewBase) findViewById(R.id.tutorial1_activity_java_surface_view);
mOpenCvCameraView.setVisibility(SurfaceView.VISIBLE);
mOpenCvCameraView.setCvCameraViewListener(this);
}
public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
mRgba = inputFrame.rgba();
mGray = inputFrame.gray();
return mRgba;
}
public void onCameraViewStarted(int width, int height) {
mGray = new Mat();
mRgba = new Mat(height, width, CvType.CV_8UC4);
@Override
public boolean onTouch(View v, MotionEvent event) {
Mat tmp = new Mat (480, 800, CvType.CV_8U, new Scalar(4));
try {
//Imgproc.cvtColor(seedsImage, tmp, Imgproc.COLOR_RGB2BGRA);
Imgproc.cvtColor(mRgba, tmp, Imgproc.COLOR_RGBA2BGRA, 4);
bmp = Bitmap.createBitmap(tmp.cols(), tmp.rows(), Bitmap.Config.ARGB_8888);
Utils.matToBitmap(tmp, bmp);
ImageView Img = (ImageView)findViewById(R.id.imageView1);
Img.setImageBitmap(bmp);
}
catch (Exception e){Log.d("Exception",e.getMessage());}
}
return false;
}
感谢您的帮助