I want to output a threshold image for AR detection

I am currently doing AR detection from the camera footage.
I am adjusting exposure time and white balance.

I would like to have a THRESHOLD IMAGE as pasted in this URL for this purpose.
How can I output the threshold image for AR detection?

you can’t. that was made manually, for illustration purposes, with deep knowledge of the implementation.

you could investigate the code and generate that mask yourself

or you could request the feature, i.e. for ArucoDetector to be extended to store or return it in detectMarkers()