Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions imgcorrect/corrections.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ def compute_reflectance_correction(
else:
band_df["ils_scaling_factor"] = 1

band_df.to_csv("D:\\Stitching\\Datasets\\CS-25318\\band_df.csv", index=False)
band_df["slope_coefficient"] = (
band_df.apply(lambda row: _get_band_coeff(row), axis=1)
/ (band_df.mean_reflectance / band_df.autoexposure)
Expand Down
40 changes: 40 additions & 0 deletions imgcorrect/detect_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,46 @@ def extract_panel_bounds(image):
dictionary = cv.aruco.Dictionary_get(cv.aruco.DICT_6X6_250)
corners, ids, rejected_img_points = cv.aruco.detectMarkers(image, dictionary)

# --- CORE CORRECTION FOR NIR DETECTION ---
# 1. Ensure we are working with a clean, single-channel grayscale copy
if len(image.shape) == 3:
gray = cv.cvtColor(image, cv.COLOR_BGR2GRAY)
else:
gray = image.copy()

# 2. Fix Sentera's dynamic range squash bug across ALL bands
if gray.max() > gray.min():
gray = cv.normalize(gray, None, 0, 255, cv.NORM_MINMAX)

# 3. Setup ArUco dictionary and standard parameters
try:
dictionary = cv.aruco.Dictionary_get(cv.aruco.DICT_6X6_250)
parameters = cv.aruco.DetectorParameters_create()
except AttributeError:
dictionary = cv.aruco.getPredefinedDictionary(cv.aruco.DICT_6X6_250)
parameters = cv.aruco.DetectorParameters()

# --- ATTEMPT 1: Standard Search (Optimized for Red Edge, Red, Green, Blue) ---
corners, ids, rejected_img_points = cv.aruco.detectMarkers(
gray, dictionary, parameters=parameters
)

# --- ATTEMPT 2: Aggressive Search Fallback (Only triggers if Attempt 1 fails, e.g., NIR) ---
if ids is None:
# Fine-tune thresholds to look for faint, low-contrast ink borders
parameters.adaptiveThreshConstant = 4
parameters.adaptiveThreshWinSizeMax = 33
parameters.adaptiveThreshWinSizeStep = 5

# Apply CLAHE local enhancement to pop out the invisible NIR lines
clahe = cv.createCLAHE(clipLimit=3.0, tileGridSize=(8, 8))
enhanced_gray = clahe.apply(gray)

corners, ids, rejected_img_points = cv.aruco.detectMarkers(
enhanced_gray, dictionary, parameters=parameters
)
# --- END OF CORRECTION CODE ---

# if at least one marker detected
if ids is not None and (
ids[0][0] == 23 or ids[0][0] == 63 or ids[0][0] == 217 or ids[0][0] == 220
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "imgcorrect"
version = "2.1.4"
version = "2.1.5"
description = "Library to perform various corrections on imagery from supported sensors"
authors = ["Samuel Williams <sam.williams@sentera.com>", "Joseph Franck <joseph.franck@sentera.com>"]

Expand Down
Loading