User Tools

Site Tools


No ACL setup yet! Denying access to everyone.
en:edu:zmitac:ai:projects:idrecognition

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:edu:zmitac:ai:projects:idrecognition [2018/04/13 23:12] – [2.2 Verify Engine] maribaj746en:edu:zmitac:ai:projects:idrecognition [2018/04/13 23:20] (current) – [2.3 Video MRZ Recognition] maribaj746
Line 153: Line 153:
 </code>| </code>|
 ====2.3 Photo MRZ Recognition ==== ====2.3 Photo MRZ Recognition ====
-Zadaniem tego Modul jest zdekodowanie strefy MRZ ze zrobionego zdjęcia. +This module is responsible for decoding MRZ zone from static picture. Algorithm works like this:
-Algorytm działania:+
 ^Step ^Description ^ ^Step ^Description ^
-| 1 | Program Włącza kamerę i wyświetla obraz, użytkownik robi zdjęcie naciskając klawisz „SPACE” , klawisz „q” zamyka program i wraca do głównego Menu:<code python>+| 1 | Application turn on camera and shows image, user are taking picture using 'space' on keyboard. The 'q' key turn off program and goes to main menu:<code python>
 def capture_process(self, cam): def capture_process(self, cam):
     cap = cv2.VideoCapture(cam)     cap = cv2.VideoCapture(cam)
Line 172: Line 171:
             break             break
 </code>| </code>|
-| 2 |Po zrobieniu zdjecia na obraz nakładane są niezbędne filtry a następnie obraz jest przekazany do funkcji oryginalny obraz oraz obraz z nałożonymi filtrami jest przekazany do funkcji locate_MRZ która to zlokalizuje i wekstraktuje strefę MRZ z dostarczonego zdjęcia. Funkcja filtr() - która lokalizuje strefe MRZ na dowodzie:<code python>+| 2 |When picture are taken necessary filters are put and picture is passing to function. Original picture and picture with filters is passed to locate_MRZ function which localize and extract MRZ from picture.Filtr() function which localize MRZ zone on ID:<code python>
 def filtr(self, image): def filtr(self, image):
     rectKernel = cv2.getStructuringElement(cv2.MORPH_RECT, (13, 5))     rectKernel = cv2.getStructuringElement(cv2.MORPH_RECT, (13, 5))
Line 203: Line 202:
     thresh[:, image.shape[1] - p:] = 0     thresh[:, image.shape[1] - p:] = 0
     return thresh         return thresh    
-</code> Wynik działania funkc: Na miało zaznaczone są zlokalizowane obszary tekstu: {{ :en:edu:zmitac:ai:projects:id_recognition_1.png?nolink |}} następnie ten obraz przekazujemy do funkcji locate_MRZ, która rzyjmuje że największy „bialy” obszar jest obszarem MRZ i na tej podstawie wycina dane ze zdjęcia oryginalnego (celowo zamaskowano nr dowodu) :<code python>+</code> Result of function: white places are the localized text area: {{ :en:edu:zmitac:ai:projects:id_recognition_1.png?nolink |}} Next step is to pass this picture to locate_MRZ function which assumes that the largest white place of them are the MRZ and based on that cut data from original picture:<code python>
 def locate_MRZ(self, _thresh, _oryginal): def locate_MRZ(self, _thresh, _oryginal):
     _oryginal = cv2.adaptiveThreshold(_oryginal, 255, 1, 1, 11, 2)     _oryginal = cv2.adaptiveThreshold(_oryginal, 255, 1, 1, 11, 2)
Line 218: Line 217:
         result = _oryginal[y:y + h, x:x + w].copy()         result = _oryginal[y:y + h, x:x + w].copy()
         return self.decode(result)          return self.decode(result) 
-</code>Wynik dziłania funkcji locate_MRZ:{{ :en:edu:zmitac:ai:projects:id_recognition_2.png?nolink |}}| +</code>Result of locate_MRZ function:{{ :en:edu:zmitac:ai:projects:id_recognition_2.png?nolink |}}| 
-| 3 | Takie zdjęcie przekazane jest do funkcji Decode() która wycina obrazki  każdej Lini na podstawie otrzymanych parametrów z extract_lines i przekazujemy je do funkcji OCR.<code python>+| 3 | This picture are passing to Decode function which cuts picture of every line based on returned parameters of extract_lines function and pass it to OCR function.<code python>
 def decode(self, image): def decode(self, image):
     if len(image) > 0 and image is not None:     if len(image) > 0 and image is not None:
Line 234: Line 233:
     return None     return None
 </code>| </code>|
-| 4 |Funkcja OCR extraktuje z każdej linii znak przy użyciu funkcji extract_chars_from_line: <code python>+| 4 |OCR function extract characters of every line using extract_chars_from_line function: <code python>
 def extract_chars_from_line(self, image): def extract_chars_from_line(self, image):
     image, contours, _ = cv2.findContours(image, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)     image, contours, _ = cv2.findContours(image, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
Line 246: Line 245:
             lista_rect[x] = [x, y, w, h]             lista_rect[x] = [x, y, w, h]
     return sorted(lista_rect.items())     return sorted(lista_rect.items())
-</code> Następnie na podstawie zwróconych parametrów znaku funkcja OCR wycina obrazek, skaluje do rozmiaru 20x20 i przekazuje do Sieci KNN jako dane wejściowe. Jako informacje zwrotną sieć KNN zwraca kod rozpoznanego znaku. <code python> def ocr(self, image):+</code> Next, based on returned character parameters, OCR function cuts picture, scale it to 20x20 pixels and pass it to KNN network as an input data. As an output information  network returns code of recognized character. <code python> def ocr(self, image):
     self.clear_folder('./log/ocr_img/')     self.clear_folder('./log/ocr_img/')
     result = ""     result = ""
Line 267: Line 266:
     return result     return result
 </code>| </code>|
-| 5 | Wynik jest zwracany na konsolę w formie tekstowej.|+| 5 | Result are printed to console.|
  
  
 ====2.3 Video MRZ Recognition ==== ====2.3 Video MRZ Recognition ====
-Zadaniem tego Modul jest zdekodowanie strefy MRZ „live” na podstawie strumienia danych z kamery dostarczanym w czasie rzeczywistym. Funkcja ta nie wymaga naciskania SPACE, wszystko dzieje się automatycznie i po wykryciu 3 linie w strefie MRZ dane zostają zdekodowane a wynik zostaje naniesiony na strumien danych wejsciowych.  Dekodowanie odbywa się dokładnie tak samo jak w 2.3 „Photo MRZ Recognition ” pkt 2-4+The task of this module is decoding  MRZ zone in 'live' mode based on data stream from camera in real time. This function doesn't require using a space bar on keyboard becuse everything are automatically decoded. When application found 3 lines on MRZ zone, data are decoded and result are passed to output data stream. Decoding are made in the same way as Photo MRZ Recogition option described above. Decoded information are shown in the left upper corner
  
 {{ :en:edu:zmitac:ai:projects:video_result.png?nolink&600 |}} {{ :en:edu:zmitac:ai:projects:video_result.png?nolink&600 |}}
en/edu/zmitac/ai/projects/idrecognition.1523653954.txt.gz · Last modified: by maribaj746