mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Co-authored-by: Kwabena W Agyeman <kwagyeman@users.noreply.github.com> Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
46 lines
798 B
Python
46 lines
798 B
Python
def unittest(data_path, temp_path):
|
|
import image
|
|
|
|
e = 0.0000001
|
|
# Load image
|
|
img = image.Image(data_path + "/cat.pgm", copy_to_fb=True)
|
|
|
|
# Load histogram
|
|
with open(data_path + "/cat.csv", "r") as f:
|
|
hist1 = [float(x) for x in f.read().split(",")]
|
|
|
|
# Get histogram
|
|
hist2 = img.get_histogram()
|
|
|
|
# Compare
|
|
for a, b in zip(hist1, hist2[0]):
|
|
if abs(a - b) > e:
|
|
return False
|
|
|
|
return hist2.get_percentile(0.5)[0] == 96 and hist2.get_statistics()[0:] == (
|
|
81,
|
|
96,
|
|
0,
|
|
59,
|
|
0,
|
|
255,
|
|
13,
|
|
128,
|
|
0,
|
|
0,
|
|
0,
|
|
0,
|
|
0,
|
|
0,
|
|
0,
|
|
0,
|
|
0,
|
|
0,
|
|
0,
|
|
0,
|
|
0,
|
|
0,
|
|
0,
|
|
0,
|
|
)
|