I’m developing an Android application using Kivy and Python, which involves processing images selected by the user through the Chooser
widget from the androidstorage4kivy library. The core functionality of my app revolves around the calculation of object areas using OpenCV, and for this reason I am trying to allow the user to calibrate the camera using a reference board.
The calibration works as follows:
- The user selects a list of images using the
Chooser
widget. - A callback function is triggered upon selection, which takes the list of file paths as argument.
- For each path,
cv2.imread()
is used to load the image, followed bycv2.aruco.detectMarkers()
to detect markers within the image andcv2.aruco.interpolateCornersCharuco()
to get the corners of the calibration board. - After getting the markers from all the images, the app calls
cv2.aruco.calibrateCameraCharuco()
to get the calibration matrix.
However, I’ve encountered an issue when attempting to process more than approximately 10 images at once. The application crashes, but strangely, this happens after the callback function has already completed its execution and the calibration matrix has been successfully returned.
Given this behavior, I suspect there might be a memory management issue or a limitation related to the number of images being processed simultaneously. Is there a way to pinpoint what is causing the crash (ideally from within VScode)? All other errors have showed up in the console, while in this case the app crashes silently.
I think the problem is not that I am loading all the images at once in memory, since I load them in a loop like this, so at most there should be one copy in memory:
for image_path in image_list:
image = cv2.imread(image_path)
do.stuff()
del image