Native window capture between Linux, MacOS, and Windows

I want to capture a window regardless of whether or not it's being displayed currently. For example, the user could have a window minimized or on another screen and the program would still capture it. I need (most likely three) methods native to all operating systems in order to get the most efficiency out of the program. I also need to convert the image to a unified type, such as an OpenCV mat in a timely manner in order to preserve performance alongside OpenCV running object recognition.

OBS Studio Backend Design — OBS Studio 30.0.2 documentation (if scrap can't cover your needs, libobs probably can, but it's a C library and you'll need to use FFI to call into it).