Fixed variable name in map size calculation

- accidentlally used cal_right_border instead of cal_bottom_border. Always pay attention to warnings of unused variables
- commented out unused code
This commit is contained in:
Doc
2026-01-13 09:57:09 -05:00
parent 3ab553fb6d
commit 4e4d3fc854
2 changed files with 25 additions and 28 deletions

View File

@@ -1,6 +1,5 @@
import json
import time
import timeit
from pathlib import Path
import cv2
@@ -369,7 +368,7 @@ class DFWINDOW:
self._map_height = (
(img.shape[0] - cal_top_border) # Grid x = 0
+ ((self._gridy_max - 1) * self._step_size_y) # All the middle
+ cal_right_border # grid x = max
+ cal_bottom_border # grid x = max
)
self.setGridPos(0, 0)
@@ -382,31 +381,31 @@ class DFWINDOW:
def test1(self):
# rawimg = cv2.imread("./test_img.png")
rawimg = cv2.imread("grid_base_3.png")
img = rawimg[100 : -self.bottom_to_ignore - 70, 65:-65]
tlb = self.TOOLS.firstNotBlackX(img)
ttb = self.TOOLS.firstNotBlackY(img)
# rawimg = cv2.imread("grid_base_3.png")
# img = rawimg[100 : -self.bottom_to_ignore - 70, 65:-65]
# tlb = self.TOOLS.firstNotBlackX(img)
# ttb = self.TOOLS.firstNotBlackY(img)
tt_setup = (
r"gc.enable() ; import cv2 ; import numpy as np ; timg = cv2.imread('./test_img.png', cv2.IMREAD_UNCHANGED)"
)
tt1 = timeit.Timer(
"np.where(np.mean(cv2.cvtColor(timg, cv2.COLOR_BGR2GRAY), axis=0) > 15)[0][0]",
setup=tt_setup,
)
tt2 = timeit.Timer(
"np.where(np.max(cv2.cvtColor(timg, cv2.COLOR_BGR2GRAY), axis=0) > 25)[0][0]",
setup=tt_setup,
)
tt3 = timeit.Timer(
"np.where(np.max(cv2.cvtColor(timg, cv2.COLOR_BGRA2GRAY), axis=0) > 25)[0][0]",
setup=tt_setup,
)
# tt_setup = (
# r"gc.enable() ; import cv2 ; import numpy as np ; timg = cv2.imread('./test_img.png', cv2.IMREAD_UNCHANGED)"
# )
# tt1 = timeit.Timer(
# "np.where(np.mean(cv2.cvtColor(timg, cv2.COLOR_BGR2GRAY), axis=0) > 15)[0][0]",
# setup=tt_setup,
# )
# tt2 = timeit.Timer(
# "np.where(np.max(cv2.cvtColor(timg, cv2.COLOR_BGR2GRAY), axis=0) > 25)[0][0]",
# setup=tt_setup,
# )
# tt3 = timeit.Timer(
# "np.where(np.max(cv2.cvtColor(timg, cv2.COLOR_BGRA2GRAY), axis=0) > 25)[0][0]",
# setup=tt_setup,
# )
num_tests = 80
r1 = tt1.timeit(number=num_tests)
r2 = tt2.timeit(number=num_tests)
r3 = tt3.timeit(number=num_tests)
# num_tests = 80
# r1 = tt1.timeit(number=num_tests)
# r2 = tt2.timeit(number=num_tests)
# r3 = tt3.timeit(number=num_tests)
logger.debug("Pause here for testing")

View File

@@ -2,8 +2,6 @@ import json
import subprocess
import pydantic as pyd
import cv2
import numpy as np
from .dfwindow import DFWINDOW
from .mylogging import logger, setup_logging