Thank you so much for sharing this! I'm working on something similar right now (a framework to build game agents using computer vision tools) and I just went from capturing at 10-15fps with ImageGrabber, to 15-25fps with FFMpeg and finally 70-80 fps with this technique. Insane!
Really nice and can see why you needed the performance for this project. Funny that you mention Super Hexagon because it's the game I'm using for my POCs!
https://www.pastery.net/xafjmn/
Takes around 5ms per frame for me, rather than 50.
Slightly shorter code (still using the same method): https://askubuntu.com/a/400384/73044