-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathannotate.py
More file actions
26 lines (24 loc) · 869 Bytes
/
Copy pathannotate.py
File metadata and controls
26 lines (24 loc) · 869 Bytes
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
'''Fixes problems with annotation to label corners in correct order'''
import os
import csv
'''IMPORTANT SETTINGS'''
dir = "./iphone24/" # folder name
width = 3264 # image size
height = 2448
if not os.path.isdir(dir+"annotations/"):
os.mkdir(dir+"annotations/")
annotations = dir+"annotations/"
for gt in os.listdir(dir):
if gt.endswith("csv"):
current_file = dir+gt
# change JPG to jpg or vice versa according to the image extension
with open(annotations+gt[:-3]+"JPG.csv", "a") as csvfile, open(current_file, "r") as coming:
print current_file
for _ in range(4):
#read
data = coming.readline().split()
x, y = float(data[0].strip()), float(data[1].strip())
print x, y
#write
spamwriter = csv.writer(csvfile, delimiter=' ', quotechar='|', quoting=csv.QUOTE_MINIMAL)
spamwriter.writerow([str(x/640*width), str(y/640*height)])