Browse Source

wider face transform mat to txt

tags/v0.5-sensible
kkkim 8 years ago
parent
commit
70728bedb9
1 changed files with 46 additions and 0 deletions
  1. +46
    -0
      src/prepare_data/widerface_annotation_gen/transform.py

+ 46
- 0
src/prepare_data/widerface_annotation_gen/transform.py View File

@@ -0,0 +1,46 @@
from wider_loader import WIDER
import cv2
import time
#wider face original images path
path_to_image = '/idata/data/wider_face/WIDER_train/images'
#matlab file path
file_to_label = './wider_face_train.mat'
#target file path
target_file = './anno.txt'
wider = WIDER(file_to_label, path_to_image)
line_count = 0
box_count = 0
print 'start transforming....'
t = time.time()
with open(target_file, 'w+') as f:
# press ctrl-C to stop the process
for data in wider.next():
line = []
line.append(str(data.image_name))
line_count += 1
for i,box in enumerate(data.bboxes):
box_count += 1
for j,bvalue in enumerate(box):
line.append(str(bvalue))
line.append('\n')
line_str = ' '.join(line)
f.write(line_str)
st = time.time()-t
print 'end transforming'
print 'spend time:%ld'%st
print 'total line(images):%d'%line_count
print 'total boxes(faces):%d'%box_count

Loading…
Cancel
Save