How to get croped image captured from CAMERA - android

How to get the crop image which are bounded within a section which are shown in Image.
I want my app to capture an image of a book page, which contain 4 image patterns at the corners. I want it to first match those pattern and then to remove all the part which is not available inside the boundary of those 4 images.

I recommend you to use OpenCV for Android library.
Take a look at these SO discussions:
Detecting paper on image:
OpenCV C++/Obj-C: Detecting a sheet of paper / Square Detection
Detecting logo:
Logo recognition - how to improve performance

Do this,
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra("crop", "true");
startActivityForResult(intent, TAKE_PICTURE);

This tutorial does it all, toy can download the sources as well:http://mobile.tutsplus.com/tutorials/android/capture-and-crop-an-image-with-the-device-camera/

Related

How to crop image with known path based on user selection

in my app I capture a photo using intent MediaStore.ACTION_IMAGE_CAPTURE and I save image into external storage that is private to my app. I also save the path to taken picture.
In next step I would like to crop 3 pictures from this photo but I cannot figure out how to do it. I found this article Crop an Image by passing the image file path in Android but the answer uses com.android.camera.action.CROP, which is often not supported. I would like to crop it like this
Bitmap bmp=BitmapFactory.decodeResource(getResources(), R.drawable.xyz);
resizedbitmap1=Bitmap.createBitmap(bmp, 0,0,yourwidth, yourheight);
but I need to crop picture according to user selection. Can anyone help me with this? I am pretty stuck here.
So I ended up using some third party library for cropping pictures. I recommend you to do the same. You will find plenty of them on github, choose according to your preferences.

Taking photo intent with cropped image preview

I am making an application where I need to take a photo and then crop a 100x100 area from it. Right now I am making an intent call for taking a picture and then I create a CropActivity that will crop it.
I was wondering if default photo application could be set crop taken picture and show a border on screen to identify an area which is supposed to be cropped before taking the picture.
Maybe with some extras? I dont know. I search ong enought, but didnt find anything to do this in one step WITH preview.
(please do not post solutions, how to crop image separately and without a preview, I already know)
I was wondering if default photo application could be set crop taken picture and show a border on screen to identify an area which is supposed to be cropped
There are well over 1 billion Android devices, spread across over a thousand device models. Those have hundreds of "default photo applications", as a mix of pre-installed apps and other camera apps that users installed and made be their default.
None have to support any sort of crop-related extras.
You can save path of image(i.e. Uri) in a string then putExtra this with your intent as:
String mUri = "android.media.whatever";
Intent mIntent.putExtra("imgUri", mUri);
and then in receiver side you can get the image using:
Bitmap img = BitmapFactory.decodeFile(getIntent().getStringExtra("imgUri");

Are there any libraries for resizing a photo to a square

Are there any libraries for resizing a photo to a square (similar to instagram)?
So the user can choose what is visible/size of the square by swiping and resizing a grid.
Anyone here familiar with a librarie for this purpose?
Any help is welcome.
found it :)
https://github.com/biokys/cropimage
EDIT
There is a build in crop intent:
Intent cropIntent = new Intent("com.android.camera.action.CROP");

Android:small size image taken by camera

I have called an intent by passing action "android.media.action.IMAGE_CAPTURE"
i.e. intent.setAction("android.media.action.IMAGE_CAPTURE");and the image I get is small size.and i want to get Full Sized image of 730X1115 size.How can I get that.
Have you tried using
Intent cameraIntent = new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA);
Though both your code and this redirects you to the Native Camera there is been much difference with the quality considerations. May be you should give it a try.
I have scaled that image by giving the dimensions of the border in which it gets fit.

How do I crop an image whose URI is known in Android?

I want image being shown in imageview to be selected with particular portion(and only selected portion needs to highlighted and other portion to be semi transparent) and that portion can also be resized as needed or done done by user on touch event.
Now, the selected portion of image is needed to be croped and then show and save that cropped image.
EDIT:
I used Intent to open the image and crop it using intent.putExtra("crop","true");
But while passing intent I want to open image whose URI is already known instead of opening the whole album of image gallery.
Can anyone suggest, how can I open particular URI through intent passing for opening image.
Thanks in advance.
Regarding the last part of your question, if you're on the very latest Gingerbread (2.3.3, API level 10), you can use BitmapRegionDecoder to crop an image.
It's useful because, until this API existed, you had to load the entire image into memory before you could crop. With 5mpix and 8mpix cameras this is usually impossible without subsampling (i.e. the cropped image loses lots of resolution).
UPDATE: Changed my answer after question was edited and more precisely described.
Issue you are facing with has long history, also at SO:
unable to find com.android.camera.CropImage activity in android
One answer has described what you need. Please note that you are using intent that is not part of the official SDK, and you may encounter different kind of issues. Issue I experienced was using crop immediatelly after image was taken by the camera. Also, it is not compatible through different Android versions, so if you get it working for 1.5 maybe it will not work for 2.3. Other useful links:
http://groups.google.com/group/android-developers/browse_thread/thread/2dd647523926192c/569f36b5b28f2661?lnk=gst&q=Crop+image+intent#569f36b5b28f2661
http://groups.google.com/group/android-developers/browse_thread/thread/2dd647523926192c/dcbe5aef29eddad6?lnk=gst&q=Crop+image+intent#dcbe5aef29eddad6
http://groups.google.com/group/android-developers/browse_thread/thread/d7b6a133c164aa17/184bf3b85da2ce58?lnk=gst&q=Crop+image+intent#184bf3b85da2ce58
Check out my answer to this question. It doesn't deal with the touch-to-resize aspect of your question, but handles drawing parts of an image over the original image.
Bottom line is, you don't want to use an ImageView, since that's mainly for displaying a static image with various scaling properties. You're better off using a custom view with an overridden draw() method.
For Cropping image
private void cropImage() {
// Use existing crop activity.
Intent intent = new Intent("com.android.camera.action.CROP");
intent.setDataAndType(capturedImageUri, IMAGE_UNSPECIFIED);
// Specify image size
intent.putExtra("outputX", IMAGE_DIMENSION);
intent.putExtra("outputY", IMAGE_DIMENSION);
// Specify aspect ratio, 1:1
intent.putExtra("aspectX", 1);
intent.putExtra("aspectY", 1);
intent.putExtra("scale", true);
intent.putExtra("return-data", true);
// REQUEST_CODE_CROP_PHOTO is an integer tag you defined to
// identify the activity in onActivityResult() when it returns
startActivityForResult(intent, REQ_CODE_CROP_PHOTO);
}

Categories

Resources