import csv
import sys

def csv2json(row):
    output = f'''{{"image": "{row[0]}",
    "annotations": [{{"label": "{row[2]}", 
      "coordinates": {{"x": {float(row[3]) + (float(row[4]) - float(row[3]))/2}, "y": {float(row[5]) + (float(row[6]) - float(row[5]))/2}, "width": {float(row[4]) - float(row[3])}, "height": {float(row[6]) - float(row[5])}}}
}}]}},'''
    print(output)

csv_file = open(sys.argv[1], 'r', encoding='utf-8')
f = csv.reader(csv_file, delimiter=',')
header = next(f)

for row in f:
    #print(row[1])
    csv2json(row)
