jhansireddy / AndroidScannerDemo

ScanLibrary is an android document scanning library built on top of OpenCV, using the app you will be able to select the exact edges and crop the document accordingly from the selected 4 edges and change the perspective transformation of the cropped image.
MIT License
1.07k stars 472 forks source link

Could not implement in imageview #58

Open ajay1295 opened 6 years ago

ajay1295 commented 6 years ago

I'm currently working on Document scanner app. My app will first open opencv camera, it will detect document in camera screen and captured image will display in next screen in imageview. I want to apply this scanLibrary on this imageview. But i cannot. Can somebody help me to that?

    ` public class CameraButton extends CameraScreen  {
     private FloatingActionButton btnCamera;
     private ImageView imgview;
     private static final int REQUEST_CODE = 99;
     @Override
     protected void onCreate(Bundle savedInstanceState) {
    super.onCreate( savedInstanceState );
    setContentView( R.layout.activity_camera_button );

    btnCamera = (FloatingActionButton) findViewById( R.id.btnCamera );
    imgview = (ImageView) findViewById( R.id.imgview );
    byte[] byteArray = getIntent().getByteArrayExtra( "image" );
    Bitmap bitmap = BitmapFactory.decodeByteArray( byteArray, 0, byteArray.length );
    Bitmap b = Bitmap.createScaledBitmap( bitmap, 600, 600, true );

    imgview.setImageBitmap( b );

    Intent intent = new Intent(this, ScanActivity.class);
    intent.putExtra( ScanConstants.SELECTED_BITMAP, byteArray );
    startActivityForResult(intent, REQUEST_CODE);

    btnCamera = (FloatingActionButton) findViewById( R.id.btnCamera );
    btnCamera.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            startActivity(new Intent(CameraButton.this, CameraScreen.class));
        }
    });
     }
       @Override
      protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == REQUEST_CODE && resultCode == Activity.RESULT_OK) {
        Uri uri = data.getExtras().getParcelable(ScanConstants.SCANNED_RESULT);
        Bitmap bitmap = null;
        try {
            bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), uri);
            getContentResolver().delete(uri, null, null);
            imgview.setImageBitmap(bitmap);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

 }`