Reputation: 691
I would like to get some tips/ snippets about recognising a desired shape/ pattern inside a picture with the help of PHP.
I want to crop fixed areas (using percentages) of an image containing an identity card but, in order to do this, first I have to detect the boundaries of the identity card and crop the image so that there will be nothing left in it except the card. The identity card contained in the picture will not be rotated (not more than a few degrees) and the background may vary.
My final goal is to use the cropped areas with an OCR. I thought that this method will be good for removing the unwanted parts and also helping out the OCR. If you have a better idea, tell me.
Upvotes: 2
Views: 2633
Reputation: 8591
I'm not aware of any software you could just plug into your PHP application to do exactly what you need.
You will probably need to program, test and fine-tune the detection algorithm yourself.
Image processing is fairly CPU and memory intensive, so you probably don't want to do it all in PHP. However, you could use a generic image processing library with image manipulation primitives that suffice to express your detection algorithm.
An obvious candidate is ImageMagick, which has primitives used for cropping off unwanted borders from images. Let me warn you that I find ImageMagick very difficult to understand and use, especially its command-line utilities (convert
, montage
, mogrify
, etc.), because the bazillion features appear to just have been amassed into a big heap without discernible organization; this will be less of a problem when using the PHP interface rather than the command-line executables, which is a lot faster anyway.
Upvotes: 2