Path: blob/master/Model-5/testparse.py
427 views
import csv1import cv22import numpy as np34# ******************* Enter the input of rows and cols here(below)********************5# ******************* using format x1,y1,x2,y2,Word where x1,y1 for top left and x2,y2 for bottom right********************6# ******************* Use scal_fact as scaling factor for normalisation of font size in cv2.putText Function*********************7rows = 6008cols = 6009scal_fact = 1010img = np.zeros((rows,cols,3))11# np.zeroes()12for h in range(rows):13for w in range(cols):14img[h,w] = [255,255,255]15max = 016with open('bounding_boxes_normal.csv') as File:17reader = csv.reader(File, delimiter=',', quotechar=',',18quoting=csv.QUOTE_MINIMAL)19for row in reader:20a = int(row[0])21b = int(row[1])22c = int(row[2])23d = int(row[3])24x = abs((c-a)*(d-b))25if (x>max):26max = x27print('The value of max is')28print max29with open('bounding_boxes_normal.csv') as File:30reader = csv.reader(File, delimiter=',', quotechar=',',31quoting=csv.QUOTE_MINIMAL)32for row in reader:33a = int(row[0])34b = int(row[1])35c = int(row[2])36d = int(row[3])37e = row[4]38x = abs((c-a)*(d-b))39# print e40# print a41# print d42cv2.putText(img, str(e),(a,d), cv2.FONT_HERSHEY_SIMPLEX, float(scal_fact*x)/float(max),(0,0,0),2)43# cv2.imshow('image', img)44# cv2.waitKey(0)45cv2.imshow('image', img)46cv2.waitKey(0)47484950