Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to display Opencv Camera captured image in another screen?

I'm trying to display processed mat into imageview in another activity. First i'm converting mat to bitmap and then passing bitmap value in imageview. But it is not showing anything in image view. Help me which step i am missing.

CameraScreen Activity

    btnCapture = (FloatingActionButton) findViewById(;
    btnCapture.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            String timestamp = new SimpleDateFormat("ddMMyyyy_HHmmss", Locale.US).format(new Date());
            File imgFolder = new File(FILE_LOCATION);
            String fileName = FILE_LOCATION +
                    "/Scan" + timestamp + ".jpg";
            Toast.makeText(CameraScreen.this, fileName + " saved", Toast.LENGTH_SHORT).show();
            cropped = mRgba.submat( bounding_rect );
            Imgproc.cvtColor( cropped, cropped, Imgproc.COLOR_BGR2RGBA );
            Core.flip(cropped.t() , cropped, 1);
            Imgcodecs.imwrite(fileName, cropped);
            bitmap = Bitmap.createBitmap( cropped.cols(), cropped.rows(), Bitmap.Config.ARGB_8888 );
            Utils.matToBitmap(cropped, bitmap);
            Intent intent = new Intent( CameraScreen.this, CameraButton.class );
            startActivity( intent );
    }) ;

This is the Activity where i want to display image

   public class CameraButton extends CameraScreen {
   private ImageView imgview;
   private FloatingActionButton btnCamera;

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate( savedInstanceState );
    setContentView( R.layout.activity_camera_button );

    btnCamera = (FloatingActionButton) findViewById( );
    imgview = (ImageView) findViewById( );
    imgview.setImageBitmap( bitmap );

    btnCamera.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            startActivity(new Intent(CameraButton.this, CameraScreen.class));