Book Image

Mastering OpenCV Android Application Programming

Book Image

Mastering OpenCV Android Application Programming

Overview of this book

Table of Contents (16 chapters)
Mastering OpenCV Android Application Programming
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
6
Working with Image Alignment and Stitching
Index

Implementing on Android


Open the LensActivity.java file. First, we will declare and initialize our Button and ImageView. Then, will add onClickListener to the button. We will call the ImageCapture intent, which will open the camera app to click on the image as follows:

ivImage = (ImageView)findViewById(R.id.ivImage);
Button bClickImage, bLoadImage;

bClickImage = (Button)findViewById(R.id.bClickImage);
bLoadImage = (Button)findViewById(R.id.bLoadImage);

bClickImage.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        Intent intent = new 
        Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        errorMsg = null;
        File imagesFolder = new File(FILE_LOCATION);
        imagesFolder.mkdirs();
        File image = new File(imagesFolder, "image_10.jpg");
        fileUri = Uri.fromFile(image);
        Log.d("LensActivity", "File URI = " + fileUri.toString());
        intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); 

        // start the...