What is setNumThreads for?

opencv applies internal parallelization to speed up various functions, and setNumThreads() controls, how many threads to use for this (e.g. set it to 1 for debugging)

no, not at all, it’s for the internal library functions

there’s a tutorial with sample code