summaryrefslogtreecommitdiffstats
path: root/data/face-detection-accuracy.py
blob: 161f93291482a7bb29a8518d78e2b0de1c056204 (plain)
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
#!/usr/bin/python
import matplotlib.pyplot as plt
import matplotlib.mlab as ml
import numpy as np
import sys

numbins_distance = 15
numbins_brightness = 30
face_detection_filename = sys.argv[1]
brightness_filename = sys.argv[2]
distance,detected = ml.load(face_detection_filename,delimiter=",",usecols=[3,4],unpack=True)
brightness = ml.load(brightness_filename,delimiter=",",usecols=[3],unpack=True)
distance_detected = distance[detected>0]
brightness_detected = brightness[detected>0]
range_distance = (min(distance),max(distance))
range_brightness = (min(brightness),max(brightness))
hist_detected,bins = np.histogram(distance_detected,bins=numbins_distance,range=range_distance)
hist,bins = np.histogram(distance, bins=numbins_distance, range=range_distance)
brightness_hist_detected,bins_brightness = np.histogram(brightness_detected,bins=numbins_brightness, range=range_brightness)
brightness_hist,bins_brightness = np.histogram(brightness,bins=numbins_brightness, range=range_brightness)

result1 = hist_detected*1./hist
result2 = brightness_hist_detected*1./brightness_hist
plt.subplot(211)
plt.bar(bins[:-1],result1,width=np.diff(bins))
plt.subplot(212)
plt.bar(bins_brightness[:-1],result2,width=np.diff(bins_brightness))
plt.show()