From 3a7bb9487ccf87ab561cae0c0645f737a557dd12 Mon Sep 17 00:00:00 2001 From: iabdalkader Date: Tue, 8 Aug 2017 00:18:05 +0200 Subject: [PATCH] Add more unit-tests. --- usr/unittest/script/image/10-find_circles.py | 5 +++++ usr/unittest/script/image/11-find_lines.py | 9 +++++++++ .../script/image/12-find_line_segments.py | 19 +++++++++++++++++++ usr/unittest/script/image/13-find_rects.py | 5 +++++ 4 files changed, 38 insertions(+) create mode 100644 usr/unittest/script/image/10-find_circles.py create mode 100644 usr/unittest/script/image/11-find_lines.py create mode 100644 usr/unittest/script/image/12-find_line_segments.py create mode 100644 usr/unittest/script/image/13-find_rects.py diff --git a/usr/unittest/script/image/10-find_circles.py b/usr/unittest/script/image/10-find_circles.py new file mode 100644 index 000000000..1aa96aaea --- /dev/null +++ b/usr/unittest/script/image/10-find_circles.py @@ -0,0 +1,5 @@ +def unittest(data_path, temp_path): + import image + img = image.Image("unittest/data/shapes.ppm", copy_to_fb=True) + circles = img.find_circles(threshold = 5000, x_margin = 30, y_margin = 30, r_margin = 30) + return len(circles) == 1 and circles[0][0:] == (118, 56, 22, 5829) diff --git a/usr/unittest/script/image/11-find_lines.py b/usr/unittest/script/image/11-find_lines.py new file mode 100644 index 000000000..a95d6b619 --- /dev/null +++ b/usr/unittest/script/image/11-find_lines.py @@ -0,0 +1,9 @@ +def unittest(data_path, temp_path): + import image + img = image.Image("unittest/data/shapes.ppm", copy_to_fb=True) + lines = img.find_lines(threshold = 10000, theta_margin = 25, rho_margin = 25) + return len(lines) == 4 and\ + lines[0][0:] == (22, 0, 22, 119, 119, 17340, 0, 22) and\ + lines[1][0:] == (0, 39, 159, 39, 159, 17340, 90, 39) and\ + lines[2][0:] == (57, 0, 57, 119, 119, 17340, 0, 57) and\ + lines[3][0:] == (0, 75, 159, 75, 159, 21420, 90, 75) diff --git a/usr/unittest/script/image/12-find_line_segments.py b/usr/unittest/script/image/12-find_line_segments.py new file mode 100644 index 000000000..7895459d5 --- /dev/null +++ b/usr/unittest/script/image/12-find_line_segments.py @@ -0,0 +1,19 @@ +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:] ==(22, 40, 22, 73, 33, 17340, 0, 22) and\ + lines[1][0:] ==(111, 37, 124, 37, 13, 17340, 90, 39) and\ + lines[2][0:] ==(24, 39, 56, 39, 32, 17340, 90, 39) and\ + lines[3][0:] ==(57, 40, 57, 73, 33, 17340, 0, 57) and\ + lines[4][0:] ==(24, 75, 56, 75, 32, 21420, 90, 75) and\ + lines[5][0:] ==(112, 75, 126, 75, 14, 21420, 90, 75) + + + + + + + + diff --git a/usr/unittest/script/image/13-find_rects.py b/usr/unittest/script/image/13-find_rects.py new file mode 100644 index 000000000..816813780 --- /dev/null +++ b/usr/unittest/script/image/13-find_rects.py @@ -0,0 +1,5 @@ +def unittest(data_path, temp_path): + import image + img = image.Image("unittest/data/shapes.ppm", copy_to_fb=True) + rects = img.find_rects(threshold = 50000) + return len(rects) == 1 and rects[0][0:] == (23, 39, 35, 36, 146566)