Skip to content

Commit

Permalink
Merge pull request #88 from UCL/87-dot-multiple-points
Browse files Browse the repository at this point in the history
87 dot multiple points
  • Loading branch information
tdowrick committed Jan 26, 2021
2 parents acbc821 + ca0feb8 commit 135f9d3
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 8 deletions.
10 changes: 10 additions & 0 deletions sksurgeryimage/calibration/dotty_grid_point_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,16 @@ def _internal_get_points(self, image):
img_points[counter][0] = distorted_x
img_points[counter][1] = distorted_y

unique_ids, unique_idxs, counts = \
np.unique(indexes, return_index=True, return_counts=True)

unique_ids = unique_ids[counts==1]
unique_idxs = unique_idxs[counts==1]

indexes = indexes[unique_idxs]
object_points = object_points[unique_idxs]
img_points = img_points[unique_idxs]

return indexes, object_points, img_points

# If we didn't find all points, of the fit was poor,
Expand Down
3 changes: 1 addition & 2 deletions tests/calibration/test_dotty_grid_detector_metal.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ def test_metal_1a(setup_dotty_metal_model_OR):
number_of_points = tdgu.__check_real_OR_image(model_points,
img_path,
'tests/data/calib-ucl-circles/10_54_44/viking.calib.left.intrinsics.txt',
'tests/data/calib-ucl-circles/10_54_44/viking.calib.left.distortion.txt',
True
'tests/data/calib-ucl-circles/10_54_44/viking.calib.left.distortion.txt'
)

assert (326 == number_of_points)
Expand Down
15 changes: 13 additions & 2 deletions tests/calibration/test_dotty_grid_point_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def test_dotty_uncalibrated_5(setup_dotty_calibration_model):
'tests/data/calib-ucl-circles/calib.left.intrinsics.txt',
'tests/data/calib-ucl-circles/calib.left.distortion.txt',
)
assert(357 == number_of_points)
assert(355 == number_of_points)


def test_dotty_uncalibrated_6(setup_dotty_calibration_model):
Expand All @@ -127,7 +127,7 @@ def test_dotty_uncalibrated_6(setup_dotty_calibration_model):
'tests/data/calib-ucl-circles/calib.right.intrinsics.txt',
'tests/data/calib-ucl-circles/calib.right.distortion.txt',
)
assert(356 == number_of_points)
assert(354 == number_of_points)


def test_dotty_uncalibrated_7(setup_dotty_calibration_model):
Expand Down Expand Up @@ -555,3 +555,14 @@ def test_metal_6(setup_dotty_metal_model):
)
assert (224 == number_of_points)

def test_all_unique_points_detected(setup_dotty_metal_model_OR):
# Test an image on which the dot detector was previously detecting multiple instances of the same dot.
model_points = setup_dotty_metal_model_OR

number_of_points = tdgu.__check_real_OR_image(model_points,
'tests/data/calib-ucl-circles/detecting_same_point_twice_dots.png',
'tests/data/calib-ucl-circles/10_54_44/viking.calib.left.intrinsics.txt',
'tests/data/calib-ucl-circles/10_54_44/viking.calib.right.distortion.txt'
)

assert(number_of_points) == 366
5 changes: 1 addition & 4 deletions tests/calibration/test_dotty_grid_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ def __check_real_OR_image(model_points,
image_file_name,
intrinsics_file_name,
distortion_file_name,
is_metal=False
):
logging.basicConfig(level=logging.DEBUG)
image = cv2.imread(image_file_name)
Expand All @@ -73,9 +72,7 @@ def __check_real_OR_image(model_points,

size = (2600, 1900)
fiducials = [133, 141, 308, 316]
if is_metal:
fiducials = [133, 141, 308, 316]
size = (2600, 1900)


detector = DottyGridPointDetector(model_points,
fiducials,
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 135f9d3

Please sign in to comment.