Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArucoDetector detectMarkers Memory leak and severe slowdown in recent versions #1067

Open
urishab opened this issue Dec 30, 2024 · 0 comments

Comments

@urishab
Copy link

urishab commented Dec 30, 2024

Expected behaviour

detectMarkers should run in the same time every time (on the same input)
Here's the output with an older version of opencv-python (OpenCV 4.9.0.80)

iteration 0 took 0.5849573612213135 seconds. Total process memory: 106,168,320
iteration 1 took 0.5812480449676514 seconds. Total process memory: 107,143,168
iteration 2 took 0.5951583385467529 seconds. Total process memory: 107,868,160
iteration 3 took 0.601895809173584 seconds. Total process memory: 108,466,176
iteration 4 took 0.5014839172363281 seconds. Total process memory: 228,802,560
iteration 5 took 0.5855703353881836 seconds. Total process memory: 109,469,696
iteration 6 took 0.5641584396362305 seconds. Total process memory: 257,597,440
iteration 7 took 0.5695486068725586 seconds. Total process memory: 263,557,120
iteration 8 took 0.592726469039917 seconds. Total process memory: 110,755,840
iteration 9 took 0.5882177352905273 seconds. Total process memory: 298,942,464
iteration 10 took 0.47766566276550293 seconds. Total process memory: 314,290,176

Actual behaviour

Running detectMarkers over and over takes longer every time and memory is increasing in a severe manner.
Here's the output with the most recent version:

iteration 0 took 2.370551586151123 seconds. Total process memory: 123,441,152
iteration 1 took 3.1970834732055664 seconds. Total process memory: 131,985,408
iteration 2 took 3.3649799823760986 seconds. Total process memory: 136,482,816
iteration 3 took 3.5040178298950195 seconds. Total process memory: 1,671,176,192
iteration 4 took 4.196935415267944 seconds. Total process memory: 145,444,864
iteration 5 took 4.476127862930298 seconds. Total process memory: 2,117,165,056
iteration 6 took 5.6765806674957275 seconds. Total process memory: 2,338,840,576
iteration 7 took 7.461204767227173 seconds. Total process memory: 158,998,528
iteration 8 took 7.712129831314087 seconds. Total process memory: 2,753,626,112
iteration 9 took 8.872538089752197 seconds. Total process memory: 2,983,907,328
iteration 10 took 9.44568419456482 seconds. Total process memory: 168,304,640

Steps to reproduce


import cv2
import psutil
import time

params = cv2.aruco.DetectorParameters()
aruco_dict = cv2.aruco.getPredefinedDictionary(0)
detector = cv2.aruco.ArucoDetector(aruco_dict, params)

process = psutil.Process()
img = cv2.imread('noisy.jpg')
for i in range(100):
    b = time.time()
    detector.detectMarkers(img)
    print(f'iteration {i} took {time.time()-b} seconds. Total process memory: {process.memory_info().rss:,}')  # in bytes
    time.sleep(0.01)

  • operating system: Windows 11 Home 24H2
  • architecture (e.g. x86): x64
  • opencv-python version OpenCV 4.10.0.84 on Python 3.11.9
Issue submission checklist

Not sure if this issue should go here or on the OpenCV repository. I posted the bug in both.

noisy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant