Fix unit tests

* Fix find line segments test
* Fix drawing script
This commit is contained in:
Kwabena W. Agyeman 2018-06-29 11:23:45 -04:00 committed by Ibrahim Abd Elkader
parent 14617a0713
commit 3743e1e9aa
2 changed files with 10 additions and 15 deletions

View File

@ -1,17 +1,12 @@
def unittest(data_path, temp_path):
import image
img = image.Image("unittest/data/shapes.ppm", copy_to_fb=True)
lines = img.find_line_segments(threshold = 10000, theta_margin = 15, rho_margin = 15, segment_threshold = 100)
return len(lines) == 6 and\
lines[0][0:] == (56, 38, 24, 38, 32, 19, 90, 38) and\
lines[1][0:] == (26, 74, 54, 74, 28, 14, 90, 74) and\
lines[2][0:] == (104, 70, 114, 76, 12, 2, 121, 6) and\
lines[3][0:] == (139, 51, 133, 41, 12, 2, 149, -93) and\
lines[4][0:] == (109, 37, 100, 46, 13, 12, 45, 103) and\
lines[5][0:] == (127, 75, 138, 64, 16, 1, 45, 143)
lines = img.find_line_segments()
return len(lines) == 7 and\
lines[0][0:] == (23, 58, 22, 58, 1, 16, 90, 58) and\
lines[1][0:] == (24, 74, 56, 74, 32, 19, 90, 74) and\
lines[2][0:] == (54, 38, 26, 38, 28, 14, 90, 38) and\
lines[3][0:] == (104, 70, 114, 76, 12, 2, 121, 6) and\
lines[4][0:] == (139, 51, 133, 41, 12, 2, 149, -93) and\
lines[5][0:] == (109, 37, 100, 46, 13, 12, 45, 103) and\
lines[6][0:] == (127, 75, 138, 64, 16, 1, 45, 143)

View File

@ -9,7 +9,7 @@ def unittest(data_path, temp_path):
img.draw_line([img.width()//2-50, 50, img.width()//2+50, 50])
img.draw_rectangle([img.width()//2-25, img.height()//2-25, 50, 50])
img.draw_circle(img.width()//2, img.height()//2, 40)
img.draw_string(10, 10, "HelloWorld!")
img.draw_string(11, 10, "HelloWorld!")
img.draw_cross(img.width()//2, img.height()//2)
sensor.flush()
img.difference(data_path+"/drawing.pgm")