11

I am looking for some kind of auto trim/crop functionality in android. Which detects a object in captured image and creates a square box around object for cropping. I have found face detection apis in android, but my problem is captured images are documents/pages not human faces so how can I detected documents or any other object from captured picture.

I am thinking of any algorithms for object detection or some color detection. Is there any apis or libraries available for it.

I have tried following link but not found any desired output.

Find and Crop relevant image area automatically (Java / Android)

https://github.com/biokys/cropimage

Any small hint would also help me alot. Please help. Thanks in advance

Community
  • 1
  • 1
Dory
  • 7,462
  • 7
  • 33
  • 55
  • http://stackoverflow.com/questions/8147332/how-to-crop-images-without-using-intent-in-android/8147564#8147564 @ArunKumar – MKJParekh Mar 25 '14 at 11:19

2 Answers2

1

Use OpenCV for android.

You can use the Watershed (Imgproc.watershed) function to segment the image into foreground and background. Then you can crop around the foreground (which will be the document).

The watershed algorithm needs some markers pre-defining the regions. You can for example assume the document to be in the middle of the image, so create a marked region in the middle of the image to get the watershed algorithm started.

littleimp
  • 1,159
  • 9
  • 13
1

That depends on what you intend to capture and crop, but there are many ways to achieve this. Like littleimp suggested, you should use OpenCv for the effect.

I suggest you use edge-detection algorithms, such as Sobel, and perform image transformation on it with, for example, a Threshold function that will turn the image into a binary one (only black and white). Afterwards, you can search the image for the geometric shape you want, using what's suggested here. Filter the object you want by calculating the detected geometric figure's area and ratio.

It would help a lot to know what you're trying to detect in an image. Those methods I described were the ones I used for my specific case, which was developing an algorithm to detect and crop the license plate from a given vehicle image. It works close to perfect and it was all done by using OpenCV.

If you have anything else you'd like to know, don't hesitate to ask. I'm watching this post :)

Community
  • 1
  • 1
Rafael Matos
  • 516
  • 1
  • 5
  • 16