Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Aniket025
GitHub Repository: Aniket025/Medical-Prescription-OCR
Path: blob/master/Model-5/testparse.py
427 views
1
import csv
2
import cv2
3
import numpy as np
4
5
# ******************* Enter the input of rows and cols here(below)********************
6
# ******************* using format x1,y1,x2,y2,Word where x1,y1 for top left and x2,y2 for bottom right********************
7
# ******************* Use scal_fact as scaling factor for normalisation of font size in cv2.putText Function*********************
8
rows = 600
9
cols = 600
10
scal_fact = 10
11
img = np.zeros((rows,cols,3))
12
# np.zeroes()
13
for h in range(rows):
14
for w in range(cols):
15
img[h,w] = [255,255,255]
16
max = 0
17
with open('bounding_boxes_normal.csv') as File:
18
reader = csv.reader(File, delimiter=',', quotechar=',',
19
quoting=csv.QUOTE_MINIMAL)
20
for row in reader:
21
a = int(row[0])
22
b = int(row[1])
23
c = int(row[2])
24
d = int(row[3])
25
x = abs((c-a)*(d-b))
26
if (x>max):
27
max = x
28
print('The value of max is')
29
print max
30
with open('bounding_boxes_normal.csv') as File:
31
reader = csv.reader(File, delimiter=',', quotechar=',',
32
quoting=csv.QUOTE_MINIMAL)
33
for row in reader:
34
a = int(row[0])
35
b = int(row[1])
36
c = int(row[2])
37
d = int(row[3])
38
e = row[4]
39
x = abs((c-a)*(d-b))
40
# print e
41
# print a
42
# print d
43
cv2.putText(img, str(e),(a,d), cv2.FONT_HERSHEY_SIMPLEX, float(scal_fact*x)/float(max),(0,0,0),2)
44
# cv2.imshow('image', img)
45
# cv2.waitKey(0)
46
cv2.imshow('image', img)
47
cv2.waitKey(0)
48
49
50