Skip to content

Commit

Permalink
Merge pull request #8 from mo-mo-666/develop
Browse files Browse the repository at this point in the history
v1.1.0
  • Loading branch information
mo-mo-666 committed May 21, 2021
2 parents 124be44 + 98f987c commit 40aa9ff
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
Binary file removed settings/setting.xlsx
Binary file not shown.
9 changes: 6 additions & 3 deletions src/align_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,12 @@ def __find_one_marker(
max_area = areas[max_idx]
# calculate center of gravity
M = cv2.moments(max_cnt)
cx = M["m10"] / M["m00"]
cy = M["m01"] / M["m00"]
return (cx, cy), max_area
try:
cx = M["m10"] / M["m00"]
cy = M["m01"] / M["m00"]
return (cx, cy), max_area
except ZeroDivisionError:
return (0, 0), 0

def _find_markers(self, binary_img: np.ndarray) -> np.ndarray:
"""
Expand Down
2 changes: 1 addition & 1 deletion src/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def pipeline(
# read metadata
# metadata = read_metadata(metadata_path, pt2px = dpi[0])
baseimg, dpi = read_image(baseimg_path)
metadata = read_metadata(None, pt2px=dpi[0])
metadata = read_metadata(metadata_path, pt2px=dpi[0])
resize_ratio: float = metadata["resize_ratio"]
is_align: bool = metadata["is_align"]
is_marksheet: bool = metadata["is_marksheet"]
Expand Down
10 changes: 6 additions & 4 deletions src/setting_io_ds.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,12 @@ def read_metadata(
metadata = {}
if filepath:
wb = load_workbook(filepath, read_only=True)
ws = wb[excel_sheet_name]
for row in ws.iter_rows(min_row=3):
key, value = row[0].value, row[1].value
metadata[key] = value
if excel_sheet_name in wb:
logger.debug(f"We found the sheet {excel_sheet_name}.")
ws = wb[excel_sheet_name]
for row in ws.iter_rows(min_row=3):
key, value = row[0].value, row[1].value
metadata[key] = value

# put default value
for key, value in SETTING_KEYS_DEFAULT.items():
Expand Down

0 comments on commit 40aa9ff

Please sign in to comment.