-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
100 lines (82 loc) · 2.82 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import logging
import sys
import numpy as np
import pandas as pd
import mlops.ml_verify as mas
for name in logging.Logger.manager.loggerDict.keys():
logging.getLogger(name).setLevel(logging.CRITICAL)
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
from ocr import ankocr
class tester:
def check_adhar(file):
image = ankocr.api_p2i(file)
bar=mas.check.check_similarity(image,'adhatest3.jpg')
t=ankocr.get_text(image)
ankocr.delete('save.png')
if(bar>0.40):
# print("similar")
# print(t)
if('GOVERNMENT OF INDIA' in t):
return True
else:
return False
else:
# print(t)
if('GOVERNMENT OF INDIA' in t):
return True
else:
return False
# test jee_admit card
def check_jee_allot(file):
image = ankocr.api_p2i(file)
bar=mas.check.check_similarity(image,'jee allot.jpg')
t=ankocr.get_text(image)
ankocr.delete('save.png')
if(bar>0.40):
# print("similar")
# print(t)
if(('Provisional Admission Letter' in t) or ('Partial Admission Fee' in t)):
return True
else:
return False
else:
# print(t)
if(('Provisional Admission Letter' in t) or ('Partial Admission Fee' in t) ): # error
return True
else:
return False
def check_pan(file):
image = ankocr.api_p2i(file)
bar=mas.check.check_similarity(image,'test.jpeg')
t=ankocr.get_text(image)
ankocr.delete('save.png')
if(bar>0.40):
# print("similar")
# print(t)
if(('INCOME TAX DEPARTMENT' in t) or ('Permanent Account Number Card' in t)):
return True
else:
return False
else:
# print(t)
if(('INCOME TAX DEPARTMENT' in t) or ('Permanent Account Number Card' in t)):
return True
else:
return False
# def pdf_to_image(pdf_file):
# from pdf2image import convert_from_path
# pages = convert_from_path(pdf_file, 500)
# for page in pages:
# page.save('out.jpg', 'JPEG')
# return 'out.jpg'
# def delete__image(image):
# os.remove(image)
# return True
# def pdf_to_analysis(file):
# ifile= tester.pdf_to_image(file)
# pass
# # PDF TO IMAGE WITHOUT PLOPPER
# def pdf_to_image_without_ploper(pdf_file):
# # pdf to image without ploper
# pass