I don’t see anything that would cause it to hang. A few comments:
- What are you passing in for the camera matrix? It looks like the code that is currently active is not using the intrinsic guess / fix aspect ratio currently.
- Can you post the images you are using as input to the detectMarkers call?
- The choice of Aruco dictionary depends on how many unique markers you need - a 3x3 marker has only 9 bits of information, and due to rotational symmetry (and some degenerate cases, like all black / all white, maybe?) you may end up only with 100 uniquely identifiable markers…so if you need more than that, you need a larger marker size. There are also supposed false-positive rejection benefits when using a small dictionary with larger marker sizes. To be clear, by “marker size” I’m referring to the 3x3, 4x4, 5x5, or 6x6 part…not the physical size of the displayed marker.
- Are you drawing the detected markers to an image and checking it? If not, I would to make sure you are getting good detection results. You don’t need 6x6 markers, so if your detection is struggling you might try a 4x4 marker size since each individual marker bit will occupy more space in the camera image (and therefore be easier to detect/identify)
- For your parameters I’d use more iterations for the calibration. I’m not sure how fast it converges, but you might want to use a larger number (and a smaller epsilon). I use 50 and 0.0001 for mine. My understanding is that the calibration process will stop trying to improve the result either after 50 iterations (in my case) or when the reprojection error fails to improve by at least 0.0001.
- If you are able to get good undistorted images without passing in an intrinsic guess, keep doing that. Your actual intrinsics (focal length, in particular) won’t be valid, but if all you need is a way to undistort the image, it sounds like you have that. (Notwithstanding the debug/release problem)
Again, nothing obvious for why it should lock up. I’d maybe try to debug it (I know, it’s not a debug build) and see if you can figure out where it is getting stuck.
You could look at the code for calibrateCameraCharuco and see if there are any obvious code path differences between debug and release builds. Or add some logging to see how far it’s getting (and hopefully determine where it is getting stuck) in release mode. Locking up / not returning smells like a bug to me.