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:
@@ -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")
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -562,5 +560,5 @@ def test5():
|
||||
|
||||
if __name__ == "__main__":
|
||||
setup_logging(level="DEBUG", enqueue=False, console_show_time=False, console_tracebacks=True)
|
||||
|
||||
|
||||
test5()
|
||||
|
||||
Reference in New Issue
Block a user