Beispiel #1
0
	#print "annotation"
	#print ann_food
	bbox = ann_food['bbox']
	catId = ann_food['category_id']
	cat = coco.loadCats(catId)[0]
	left_x = bbox[0]
	left_y = bbox[1]
	right_x = left_x + bbox[2]
	right_y = left_y + bbox[3]
	food_type = cat['name']

	last_real_name = img_annotation_jpg_name.split('/')
	if food_type == 'hot dog':
		food_type = 'hotdog' ## must be a word, coco's dataset is not right

 	write_to_file(last_real_name[-1], food_type, img_annotation_xml_name, str(img_width), str(img_height), str(left_x), str(left_y), str(right_x), str(right_y))
	file.close()

### ?????? 

# Generat the configuration for ImageSet


img = coco.loadImgs(foodImageId[5])[0]
img_name = '%s/images/%s/%s'%(dataDir,dataType,img['file_name'])
I = io.imread(img_name)
#plt.figure()
#plt.imshow(I)
#plt.show()

# JUST FOR DEBUGGING
	elif food_type == 'hot dog':
		shutil.copy(img_annotation_jpg_name, "./hotdog/")
	elif food_type == 'sandwich':
		shutil.copy(img_annotation_jpg_name, "./sandwich/")
	elif food_type == 'carrot':
		shutil.copy(img_annotation_jpg_name, "./carrot/")
	elif food_type == 'apple':
		shutil.copy(img_annotation_jpg_name, "./apple/")
	elif food_type == 'orange':
		shutil.copy(img_annotation_jpg_name, "./orange/")
	elif food_type == 'banana':
		shutil.copy(img_annotation_jpg_name, "./banana/")
	elif food_type == 'pizza':
		shutil.copy(img_annotation_jpg_name, "./pizza/")

 	write_to_file(img_annotation_jpg_name, food_type, img_annotation_xml_name, str(img_width), str(img_height), str(left_x), str(left_y), str(right_x), str(right_y))
	file.close()

### ?????? 

# Generat the configuration for ImageSet


img = coco.loadImgs(foodImageId[5])[0]
img_name = '%s/images/%s/%s'%(dataDir,dataType,img['file_name'])
I = io.imread(img_name)
#plt.figure()
#plt.imshow(I)
#plt.show()

# JUST FOR DEBUGGING
Beispiel #3
0
#!/usr/bin/env python
from write_xml import write_to_file

# ''' This is just for single test of one function write_to_file
# Because I found that the generated xml is not compatiable with
# original xml, containing the head `<?xml xxx>`, this may harm
# r-cnn code and it crashes when finishing parsing
#'''

write_to_file("aaa.xml", "orange", "stest.xml", "480", "640", "0", "0", "123", "123")