AndroidScannerDemo
AndroidScannerDemo copied to clipboard
Could not implement in imageview
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();
}
}
}
}`