Detect Object By Name Of Card And Crop It Using Opencv
I have a image with ID card, Bank card and signature i want to get id_card.jpg and bank_card.jpg and signature.jpg. The problem ID card and Bank card has the same width and height,
Solution 1:
there's a plenty of things you could do, a good way is to crop the logo at the most top corner of the Mastercard or the id card, and save it as template, than every time you want to check if it's Mastercard you look for a good match between the logo and the image, if you find a good match than this is a MasterCard. Here is a simple code to do a template matching using opencv
image = cv2.imread("scan.jpg")
template = cv2.imread("masterCardLogo.jpg")
res = cv2.matchTemplate(image,template,cv2.TM_SQDIFF_NORMED)
min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(res)
if(max_val>0.5):
print("This is a master Card")
as I mentioned before, there are a lot of other methods, like the following
- Do Feature Matching with another template image https://docs.opencv.org/master/dc/dc3/tutorial_py_matcher.html
- You can find the edges in each picture and the one with more edges will be the ID card https://docs.opencv.org/master/da/d22/tutorial_py_canny.html
- You can use OCR by using Tessract library, to look for the word MasterCard or any special Word in the ID card https://www.pyimagesearch.com/2017/07/10/using-tesseract-ocr-python/
Post a Comment for "Detect Object By Name Of Card And Crop It Using Opencv"