Skip to content

Commit

Permalink
Issue #75: Fix linting.
Browse files Browse the repository at this point in the history
  • Loading branch information
MattClarkson committed May 5, 2020
1 parent b9140d3 commit 8ccef6b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
14 changes: 10 additions & 4 deletions sksurgeryimage/calibration/charuco.py
Expand Up @@ -236,12 +236,16 @@ def make_charuco_with_chessboard(
charuco_squares[1] * charuco_pixels_per_square)
)

centre_of_image = (((charuco_squares[0] * charuco_pixels_per_square) - 1) / 2.0,
((charuco_squares[1] * charuco_pixels_per_square) - 1) / 2.0)
centre_of_image = (
((charuco_squares[0] * charuco_pixels_per_square) - 1) / 2.0,
((charuco_squares[1] * charuco_pixels_per_square) - 1) / 2.0
)

# Creates minimum size chessboard, one pixel per chessboard square.
chessboard_image = np.zeros((chessboard_squares[1],
chessboard_squares[0]), dtype=np.uint8)

# pylint: disable=invalid-name
for x in range(0, chessboard_squares[0]):
for y in range(0, chessboard_squares[1]):
if x % 2 == 0 and y % 2 == 0 or x % 2 == 1 and y % 2 == 1:
Expand All @@ -257,8 +261,10 @@ def make_charuco_with_chessboard(

# Draw white polygon around chessboard
corners = np.zeros((4, 2))
corner_offsets = (((chessboard_squares[0] / 2) + chessboard_border) * chessboard_scale,
((chessboard_squares[1] / 2) + chessboard_border) * chessboard_scale)
corner_offsets = (
((chessboard_squares[0] / 2) + chessboard_border) * chessboard_scale,
((chessboard_squares[1] / 2) + chessboard_border) * chessboard_scale
)
corners[0][0] = int(centre_of_image[0] - corner_offsets[0])
corners[0][1] = int(centre_of_image[1] - corner_offsets[1])
corners[1][0] = int(centre_of_image[0] + corner_offsets[0])
Expand Down
11 changes: 9 additions & 2 deletions sksurgeryimage/calibration/point_detector_utils.py
Expand Up @@ -14,10 +14,17 @@ def write_annotated_image(input_image, ids, image_points, image_file_name):
image = copy.deepcopy(input_image)
font = cv2.FONT_HERSHEY_SIMPLEX
for counter in range(ids.shape[0]):
cv2.putText(image, str(ids[counter][0]), (int(image_points[counter][0]), int(image_points[counter][1])), font, 0.5, (0, 255, 0), 2, cv2.LINE_AA)
cv2.putText(image,
str(ids[counter][0]),
(int(image_points[counter][0]),
int(image_points[counter][1])),
font, 0.5, (0, 255, 0), 2, cv2.LINE_AA)
split_path = os.path.splitext(image_file_name)
previous_dir = os.path.dirname(split_path[0])
previous_dir = os.path.basename(previous_dir)
base_name = os.path.basename(split_path[0])
output_file = os.path.join('tests/output', base_name + '_' + previous_dir + '_labelled.png')
output_file = os.path.join('tests/output', base_name
+ '_'
+ previous_dir
+ '_labelled.png')
cv2.imwrite(output_file, image)

0 comments on commit 8ccef6b

Please sign in to comment.