How do I install a specific version of OpenCV with Homebrew?

Is there a way to install a specific version of OpenCV with Homebrew?

There’s some SO posts and answers about this, but the proposed procedures seem deprecated now.

Would appreciate if anyone has a way that works currently.