Traian Posted August 26, 2014 Share Posted August 26, 2014 Hi! 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. Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/290657-php-shape-pattern-recognition-inside-image/ Share on other sites More sharing options...
CroNiX Posted August 26, 2014 Share Posted August 26, 2014 PHP really wouldn't be best for this. Its just not designed for this kind of task and it would be very inefficient, slow and resource (cpu/ram) intensive. That said, it would be helpful to see an example image as I have no idea on what you mean by "identity card" or what the rest of the background looks like. If these images are all fairly consistent, like a drivers license, there are php "edge detection" scripts that could help give you coordinates of the "contrasted" border, so you can crop from those. It does it by creating several copies of the image, like in greyscale, and contrast the dark/light areas. There is very little useful info I could find in google. Quote Link to comment https://forums.phpfreaks.com/topic/290657-php-shape-pattern-recognition-inside-image/#findComment-1488961 Share on other sites More sharing options...
cpd Posted August 27, 2014 Share Posted August 27, 2014 Your better off using Python as it has a variety of useful libraries such as nupmpy and scikit. You'll want to apply a kernel to the image such as a 3x3 kernel with -1 along the top row and 1 along the bottom. This will highlight horizontal edges and rotating the kernel 90 degrees will yield vertical edges. Combining the two will yield edge detection. The topic gets increasingly complex and to be totally honest, is probably unnecessary for your purpose. If you're always scanning cards of the same size, why not predefine the area and cut that area out? Quote Link to comment https://forums.phpfreaks.com/topic/290657-php-shape-pattern-recognition-inside-image/#findComment-1489080 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.