0

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, i don't know how to detect each other. But the color is different suggestion possible get by color or the best idea is to get name of each card and after crop each card by name ??

I'm so new in this domain and i work in emergency project that why i will very grateful if someone can help me.

The image look like

enter image description here

With this code i get only bank card, not work like i want :(

  # I want here to get name of each object i dont know how after loop and crop
 for i in range(len(contours)):
   area = cv2.contourArea(contours[i])
   if hierarchy[i][3] == -1:
      cv2.drawContours(orig, contours, -1, (0, 255, 0), 3) 

I can get draw now i need to crop.

So how can i get name of each object and crop using opencv and deep learning and thanks?

A.khalifa
  • 2,366
  • 3
  • 27
  • 40
  • It's the most basic use case for deep learning. I am pretty sure an accurate classifier can be trained to distinguish between a credit cards and an ID. You just need to learn to use Keras and create a collection of manually classified images for training. – Andriy Makukha Dec 03 '20 at 22:01
  • @AndriyMakukha thank you for this comment, i just work in multiple project and deep learning not my expertise field, but if you can share with me some ressource or trainning courses i will be very grateful thanks :) – A.khalifa Dec 04 '20 at 09:22
  • Hi AndriyMakukha @AndriyMakukha i hope you are doing well, in previous day i read a lot of books about deep learning but i think it's much harder for me to build a dataset because i don't know all id card of users, idon't know how can i extract this object otherwise if you can help me i will be very grateful :) – – A.khalifa Dec 12 '20 at 20:41
  • It took me one Google search to find a video dataset [MIDV-500](https://arxiv.org/abs/1807.05786). I'm sure there are image datasets for ID cards and banking cards as well. – Andriy Makukha Dec 13 '20 at 03:16

1 Answers1

2

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

Abdelsalam Hamdi
  • 465
  • 3
  • 13