Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Aniket025
GitHub Repository: Aniket025/Medical-Prescription-OCR
Path: blob/master/Model-5/create_prescription.py
427 views
1
import csv
2
import cv2
3
import numpy as np
4
5
def draw(bboxes, entities, filename,rows,cols):
6
#rows = 3282
7
8
#cols = 2592
9
scal_fact = 10
10
img = np.zeros((rows,cols,3))
11
12
for h in range(rows):
13
for w in range(cols):
14
img[h,w] = [255,255,255]
15
16
max = 0
17
for i in bboxes:
18
a = i[0]['x']
19
b = i[0]['y']
20
c = i[2]['x']
21
d = i[2]['y']
22
x = abs((c-a)*(d-b))
23
if (x>max):
24
max = x
25
for i in range(len(bboxes)):
26
a = bboxes[i][0]['x']
27
b = bboxes[i][0]['y']
28
c = bboxes[i][2]['x']
29
d = bboxes[i][2]['y']
30
31
e = entities[i]
32
x = abs((c-a)*(d-b))
33
#float(scal_fact*x)/float(max)
34
cv2.putText(img, str(e),(a,d), cv2.FONT_HERSHEY_SIMPLEX,2 ,(0,0,0),2)
35
cv2.imwrite(filename, img)
36
37
if __name__ == "__main__":
38
print "hello"
39
40