-
Notifications
You must be signed in to change notification settings - Fork 1
/
join_bb_lm_Files.py
105 lines (85 loc) · 3.01 KB
/
join_bb_lm_Files.py
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Nov 14 23:42:06 2019
@author: caleb
"""
#combine landmark and bbox data... landmark first then bbox
import cv2
import os
import numpy as np
import matplotlib.pyplot as plt
import pdb
outPath='/home/csse/DATASETS/DataSets/mtcnn-head-detector-master/Ara-2013-Canon/'
# "/home/caleb/Downloads/DataSets/plantDB/Phenotyping_Leaf_detection_dataset/"
#csv_file = raw_input(dataPath +"ara2012_plant001_bbox.csv")
txt_file = 'serverDir_All_bb.txt'
in1bb =outPath+"bbox_all_ara2012.txt"
in2bb =outPath+"bbox_all_ara2013.txt"
in3bb =outPath+"bbox_all_tobacco.txt"
in1lm=outPath+"ara2012Landmark.txt"
in2lm=outPath+"ara2013Landmark.txt"
in3lm=outPath+"tobaccoLandmark.txt"
#print(fileNames)
process_bbfiles = [in1bb,in2bb,in3bb]
process_lmfiles = [in1lm,in2lm,in3lm]
with open(txt_file, 'w') as f:
for i in range(0,len(process_bbfiles)):
with open(process_bbfiles[i],'r') as bbFile:
bbcontents = bbFile.read
es()
with open(process_lmfiles[i]) as lmFile:
lmcontents = lmFile.readlines()
#contents= contents.split(" ",1)
print(len(bbcontents))
max_2012 = 118
max_2013 = 107
max_tobacco=61
goTo =0
if i == 0:
goTo = max_2012
if i ==1:
goTo=max_2013
if i==2:
goTo=max_tobacco
for j in range(0,goTo):#,len(bbcontents)):
bbcoord = bbcontents[j].strip().split(' ')
lmcoord = lmcontents[j].strip().split(' ')
#print(coord[0])
try:
int(bbcoord[0])
print("bad first char, skip!")
continue
except:
#print("cool..not a number")
print(".."+bbcoord)
#/home/caleb/Downloads/DataSets/plantDB/Phenotyping_Leaf_detection_dataset/Plant_Phenotyping_Datasets/Plant_Phenotyping_Datasets/Plant/Ara2013-Canon/train
if i==0:
filePath=bbcoord[0][:140]+"3-Canon/train/"+bbcoord[0][142:]
#pdb.set_trace()
if i == 1:
filePath=bbcoord[0][:148]+"train/"+bbcoord[0][148:]
if i== 2:
filePath = bbcoord[0][:134]+'Ara2013-Canon/train/'+bbcoord[0][142:]
#filePath=bbcoord[0]
# f.writelines("[")
f.writelines(filePath+" ")#"] [ ")
#n=0
for k in range(2,len(bbcoord)):
f.writelines(bbcoord[k]+" ")
'''
n+=1
if n ==4:
f.writelines("\n")
n=0
'''
f.writelines("\n")
#f.writelines(" ] [ ")
#for k in range(4,14):
# f.writelines(lmcoord[k]+" ")
#f.writelines(" ]\n")
#bbFile.read()
bbFile.close()
lmFile.close()
#bbFile.close()
f.close()