コード例 #1
0
ファイル: Accuracy.py プロジェクト: neilfordyce/HonsProject
	print "USAGE: python Accuracy cascade_xml_path test_annotation_dir"
	exit()

try:
	#Open up the cascade classifier
	cascade = CascadeClassifier(cascade_xml_path)
except:
	print "Error reading cascade xml"
	exit()


#Get the file paths to read from
detector_output_files = directory_paths(test_annotation_dir)

#Open all the files and read the JSON
annotation_files = batch_open_deserialise(detector_output_files)

#For each of the hand marked test files
for annotation_file in annotation_files:	
	#Read the image corresponding to the annotation
	img = imread(fix_path(annotation_file['imagePath']))
	print "detecting... "
	classifier_output = cascade.detectMultiScale(img, 
												minNeighbors=3,
												minSize=(175, 175), #Constrain scale within a range around training scale
												maxSize=(225, 225))	#Run the detector
	
	total_detections = len(classifier_output)
	fp = 0
	tp = 0
	
コード例 #2
0
		'''Get command line args'''
		input_dir = sys.argv[1]
		output_dir = sys.argv[2]
	except:
		print "USAGE: python GroundTruthMasks input_dir output_dir"
		exit()
		
	#Output fill colours for different types of annotations
	annotation2fill = {	'golgi': 'white',
						'ambiguous': 'blue'} #'white'}

	#Get the file paths to read from
	annotation_files = directory_paths(input_dir)

	#Open all the files and read the JSON
	files = batch_open_deserialise(annotation_files)

	#For all the ground truths
	for file in files:
		polygons = file['shapes']
		file['imagePath'] = fix_path(file['imagePath'])	#Force the file ext. to .jpg.  Sometimes it's stored wrong and needs this correction. 
		print "opening " + file['imagePath']
		image = Image.open(file['imagePath'])
		
		polygon_images = []
		
		#For each ground truth annotation
		for polygon in polygons:	
			polygon_label = polygon['label']
		
			#Make the list of points into a Shapely Polygon object